Add encoder resetting, SPI health check
This commit is contained in:
parent
63b8f868c9
commit
0f103cb34d
6 changed files with 138 additions and 80 deletions
|
@ -1,5 +1,5 @@
|
|||
import atexit
|
||||
from enum import Enum
|
||||
from enum import IntEnum
|
||||
|
||||
from compLib.LogstashLogging import Logging
|
||||
from compLib.Spi import Spi, Register
|
||||
|
@ -9,7 +9,7 @@ MAX_MOTOR_SPEED = 65535
|
|||
MOTOR_PERCENTAGE_MULT = MAX_MOTOR_SPEED / 100.0
|
||||
|
||||
|
||||
class MotorMode(Enum):
|
||||
class MotorMode(IntEnum):
|
||||
COAST = 0,
|
||||
FORWARD = 1,
|
||||
BACKWARD = 2,
|
||||
|
@ -34,16 +34,16 @@ class Motor(object):
|
|||
|
||||
if port == 1:
|
||||
Spi.write(Register.MOTOR_1_PWM_H, 2, pwm)
|
||||
Spi.write(Register.MOTOR_1_CTRL, 1, mode)
|
||||
Spi.write(Register.MOTOR_1_CTRL, 1, int(mode))
|
||||
elif port == 2:
|
||||
Spi.write(Register.MOTOR_2_PWM_H, 2, pwm)
|
||||
Spi.write(Register.MOTOR_2_CTRL, 1, mode)
|
||||
Spi.write(Register.MOTOR_2_CTRL, 1, int(mode))
|
||||
elif port == 3:
|
||||
Spi.write(Register.MOTOR_3_PWM_H, 2, pwm)
|
||||
Spi.write(Register.MOTOR_3_CTRL, 1, mode)
|
||||
Spi.write(Register.MOTOR_3_CTRL, 1, int(mode))
|
||||
elif port == 4:
|
||||
Spi.write(Register.MOTOR_4_PWM_H, 2, pwm)
|
||||
Spi.write(Register.MOTOR_4_CTRL, 1, mode)
|
||||
Spi.write(Register.MOTOR_4_CTRL, 1, int(mode))
|
||||
|
||||
@staticmethod
|
||||
def power(port: int, percent: float):
|
||||
|
|
Reference in a new issue