You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//First byte: contains checksum and motorVal, in the Order Checksum:[7:3], motorVal[2:0]
//Second byte: is the power value.
/*
Input[0],[1],[2] correspond to motor
KEY:
Motor ID:
0: Left Drive
1: Right Drive
2: Bucket Ladder M
3: dump conveyor LA
4: bucket ladder LA
5: agitator
6: dump conveyor M
7: stops motors
*/
def power_to_bytes(self) -> bytes: #converts self.power into bytes
x = abs(self.power) + 256 * self.numMotor + 256 * 16
#x is two bits, power must be between -127 and 127. probably.
#first byte should be # of motor + b'00010000 <- makes sure non-inputs are not read as power (similar to CRC)
#second byte is power (most significant bit is negative sign)
if(self.power < 0):
x += 128
return x.to_bytes((x.bit_length() + 7) // 8, 'big')
def sendPower(self):
self.arduino.write(self.power_to_bytes()) #writes power to serial
The text was updated successfully, but these errors were encountered: