|
- import board
- import busio
- import adafruit_pca9685
- import adafruit_motor
-
- import hexapod.servo_mapping
-
- class Hal:
- def __init__(self):
- self.i2c = busio.I2C(board.SCL, board.SDA)
-
- self.pca9685 = {}
- self.pwm = {}
-
- for s in hexapod.servo_mapping.servo_mapping:
- m = hexapod.servo_mapping.servo_mapping[s]
-
- address = m['address']
- channel = m['channel']
-
-
- if address not in self.pca9685:
- self.pca9685[address] = adafruit_pca9685.PCA9685(self.i2c, address=address)
- self.pca9685[address].frequency = 50
-
- self.pwm[s] = self.pca9685[address].channels[channel]
-
-
|