Looking at the example, im not sure I understand how the different channels are tricked. Looking at the code it seems like its adjusting both channels at the same time. For instance:
if state == 'off':
if self.currently_dispensing:
self.currently_dispensing = False
self.logger.debug("Output turned off")
self.motor.motor_speed_set_a_b(0, 0)
Or
elif state == 'on' and output_type == 'sec':
if self.currently_dispensing:
self.logger.debug(
"Pump instructed to turn on while it's already dispensing. "
"Overriding current dispense with new instruction.")
self.logger.debug("Output turned on {}".format(direction))
self.motor.motor_speed_set_a_b(100, 100)
if amount > 0:
self.motor.motor_direction_set("cw")
elif amount < 0:
self.motor.motor_direction_set("ccw")
The reason I ask is because my board triggers each channel individuel. This drives the motor(s) in the current version
def motor_direction_set(self, direction):
"""Set motor direction, either cw or ccw"""
if direction == "cw":
direction_address = 0b1010
elif direction == "ccw":
direction_address = 0b1001
else:
return
self.bus.write_i2c_block_data(
int(str(self.i2c_address), 16),
self.DirectionSet,
[direction_address, 0])
time.sleep(0.02)
In my version this drives the motors
def motor_run(self, motor_channel, speed):
"""Set motor speed"""
speed = self.map_vals(speed, 0, 100, 0, 255)
self.bus.write_i2c_block_data(
int(str(self.i2c_address), 16),
self.speed,
self.GROVE_MOTOR_DRIVER_I2C_CMD_CW, #I know it only runs one way at the moment:)
[motor_channel, speed])
time.sleep(0.02)
# I2Cdev::writeBytes(_addr, _buffer[0], 2, _buffer + 1);
The last line is from the arduino library. Im a little unsure on how it differs with the pi