from i2c import I2C
from enum import IntEnum

class Command(IntEnum) :
    MOVE_UP = 1
    MOVE_DOWN = 0

class Adress(IntEnum) :
    SERVO_CLAMP = 0
    SERVO_DYNAMIXEL = 1
    SERVO_PUSH = 2


class Kinematics(I2C) :
    """
    This class is an abstraction around the I2C communication with
    the servo-arduino module.

    Details of the "protocol" used:

    The Raspberry Pi sends a byte to the module containing a command
    and a servo number. Both informations are coded on 4 bits
    totalling 8 bits together. The 4 first bits are for the servo address,
    and the 4 next is used for the action to do with it.

    """

    def __init__(self, address):
        """Constructor takes the adress of the I2C module"""
        super(Kinematics, self).__init__(address)

    def up_clamp(self) :
        cmd = I2C.pack8(Adress.SERVO_DYNAMIXEL, Command.MOVE_UP)
        self.send(cmd)

    def down_clamp(self) :
        cmd = I2C.pack8(Adress.SERVO_DYNAMIXEL, Command.MOVE_DOWN)
        self.send(cmd)

    def close_clamp(self) :
        cmd = I2C.pack8(Adress.SERVO_CLAMP, Command.MOVE_UP)
        self.send(cmd)

    def open_clamp(self) :
        cmd = I2C.pack8(Adress.SERVO_CLAMP, Command.MOVE_DOWN)
        self.send(cmd)

    def push_out(self) :
        cmd = I2C.pack8(Adress.SERVO_PUSH, Command.MOVE_UP)
        self.send(cmd)

    def push_back(self) :
        cmd = I2C.pack8(Adress.SERVO_PUSH, Command.MOVE_DOWN)
        self.send(cmd)

@@ -186,16 +186,36 @@
 USH = 2%0A
+    SERVO_FUNNY = 3%0A
 %0A%0Aclass 
@@ -807,33 +807,32 @@
 f up_clamp(self)
- 
 :%0A        cmd = 
@@ -922,33 +922,32 @@
 down_clamp(self)
- 
 :%0A        cmd = 
@@ -1015,32 +1015,117 @@
 self.send(cmd)%0A%0A
+    def middle_clamp(self):%0A        self.send(I2C.pack8(Adress.SERVO_DYNAMIXEL, 2))%0A%0A
     def close_cl
@@ -1125,33 +1125,32 @@
 lose_clamp(self)
- 
 :%0A        cmd = 
@@ -1240,25 +1240,24 @@
 _clamp(self)
- 
 :%0A        cm
@@ -1351,25 +1351,24 @@
 sh_out(self)
- 
 :%0A        cm
@@ -1464,17 +1464,16 @@
 ck(self)
- 
 :%0A      
@@ -1531,28 +1531,255 @@
 OWN)%0A        self.send(cmd)%0A
+%0A    def launch_funny(self):%0A        cmd = I2C.pack8(Adress.SERVO_FUNNY, Command.MOVE_UP)%0A        self.send(cmd)%0A%0A    def reset_funny(self):%0A        cmd = I2C.pack8(Adress.SERVO_FUNNY, Command.MOVE_DOWN)%0A        self.send(cmd)%0A

fix formatting and add funny code