33 i2cWriteData(addr, speed);
34 i2cWriteData(addr, speed);
44 uint32_t target = motorPosition(motor_ch) + round * 756;
48 i2cWriteData(addr+4, 100);
50 for(
int i=0; i<4; i++){
52 data = target >> shift;
53 i2cWriteData(addr+i, data);
54 target = target - (data << shift);
108 angle = round(
float(angle)*1.388);
112 i2cWriteData(addr, angle);
113 i2cWriteData(addr, angle);
120void MatrixController::motorMode(uint8_t motor_ch, uint8_t mode){
161uint32_t MatrixController::motorPosition(uint8_t motor_ch){
163 return i2cReadData(addr, 4);
166void MatrixController::i2cMUXSelect(){
170 _pWire->endTransmission(1);
171 delayMicroseconds(300);
174void MatrixController::i2cWriteData(uint8_t reg, uint8_t data){
181 _pWire->endTransmission(1);
184uint32_t MatrixController::i2cReadData(
int reg,
int num){
188 _pWire->endTransmission(1);
196 uint32_t dataBuf = 0;
200 while (
_pWire->available() && i<num){
201 dataBuf = dataBuf << 8;
202 dataBuf +=
_pWire->read();
Handling Matrix Controller (HT) functions.
#define MC_REG_SERVO_ENABLE
#define MC_REG_MOTOR_SPEED
#define MC_REG_MOTOR_MODE
#define MC_REG_SERVO_OFFSET
#define MC_REG_SERVO_TARGET
#define MC_REG_MOTOR_TARGET
#define MC_REG_MOTOR_OFFSET
#define MC_REG_SERVO_SPEED
void motorRound(uint8_t motor_ch, float round)
Moves the specified motor a certain number of rounds.
void begin()
Initializes the MatrixController.
void motorSet(uint8_t motor_ch, uint8_t speed)
Sets the speed of the specified motor.
float getBattery()
Gets the current battery status.
void motorInvert(uint8_t motor_ch, bool invert)
Inverts the direction of the specified motor.
void servoSet(uint8_t servo_ch, uint8_t angle)
Sets the angle of the specified servo.