Skip to content

Commit

Permalink
Adds ERROR_BYTE and MACRO_STATUS requests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabien-B committed Feb 12, 2019
1 parent 16cc134 commit 305d5ae
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
6 changes: 6 additions & 0 deletions armothy.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ def start_pump(self):

def execute_macro(self, macro, args):
self.communication.send_macro_command(macro.value, args)

def get_macro_status(self):
return self.communication.get_macro_status()

def get_error_byte(self):
return self.communication.get_error_byte()

def update(self):
self._pump_state = ePumpState(self.communication.is_pump_on())
Expand Down
20 changes: 17 additions & 3 deletions communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
AXIS_3_POSITION_RQST = 0x0D # 4 bytes(float)
PUMP_STATE_RQST = 0x0E # 1 byte(0: stopped; 1: started)
VALVE_STATE_RQST = 0x0F # 1 byte(0: closed; 1: opened)
PRESSURE_RQST = 0x10 # 4 bytes(float)
ERROR_BYTE_RQST = 0x10 # 1byte ?????
MACRO_STATUS_RQST = 0x11 # 1 byte
PRESSURE_RQST = 0x12 # 4 bytes(float)


class Communication:
Expand Down Expand Up @@ -98,17 +100,29 @@ def get_axis_value(self, axis):
def is_pump_off(self):
self.i2c.write_byte(self.armothy_address, PUMP_STATE_RQST)
block = self.i2c.read_i2c_block_data(self.armothy_address, PUMP_STATE_RQST, 1)
value = bitstring.pack('uint:8', block)
value = bitstring.pack('uint:8', *block)
return value.int

def is_valve_closed(self):
self.i2c.write_byte(self.armothy_address, VALVE_STATE_RQST)
block = self.i2c.read_i2c_block_data(self.armothy_address, VALVE_STATE_RQST, 1)
value = bitstring.pack('uint:8', block)
value = bitstring.pack('uint:8', *block)
return value.int

def get_pressure_value(self):
self.i2c.write_byte(self.armothy_address, PRESSURE_RQST) # Needed because we need to specify twice the command
block = self.i2c.read_i2c_block_data(self.armothy_address, PRESSURE_RQST, 4)
value = bitstring.pack('4*uint:8', *block)
return value.floatle

def get_macro_status(self):
self.i2c.write_byte(self.armothy_address, MACRO_STATUS_RQST)
block = self.i2c.read_i2c_block_data(self.armothy_address, MACRO_STATUS_RQST, 1)
value = bitstring.pack('uint:8', *block)
return value.int

def get_error_byte(self):
self.i2c.write_byte(self.armothy_address, ERROR_BYTE_RQST)
block = self.i2c.read_i2c_block_data(self.armothy_address, ERROR_BYTE_RQST, 1)
value = bitstring.pack('uint:8',* block)
return value.int

0 comments on commit 305d5ae

Please sign in to comment.