MatrixMiniR4 1.1.5
Matrix Mini R4 Arduino Library API Documentation
Loading...
Searching...
No Matches
MiniR4MxCtrlExt.h
Go to the documentation of this file.
1
6#ifndef _MiniR4MxCtrlExt_H_
7#define _MiniR4MxCtrlExt_H_
8
9#include <Arduino.h>
10#include <Wire.h>
11
12#ifndef ADDR_PCA954X
13# define ADDR_PCA954X 0x70
14#endif
15
16#define MatrixCtrl_ADDR 0x08
17
18#define MC_REG_STATUS 0x41
19#define MC_REG_TIMEOUT 0x42
20#define MC_REG_BATTERY 0x43
21#define MC_REG_STARTFLAG 0x44
22
23#define MC_REG_SERVO_ENABLE 0x45
24#define MC_REG_SERVO_SPEED 0x46
25#define MC_REG_SERVO_TARGET 0x47
26
27#define MC_REG_SERVO_OFFSET 2
28
29#define MC_REG_MOTOR_POS 0x4E
30#define MC_REG_MOTOR_TARGET 0x52
31#define MC_REG_MOTOR_SPEED 0x56
32#define MC_REG_MOTOR_MODE 0x57
33
34#define MC_REG_MOTOR_OFFSET 10
35
36#define MODE_BRAKE 1
37#define MODE_POSITION 0
38
48 private:
49 uint8_t _ver=1;
50 uint8_t _invert1, _invert2, _invert3, _invert4;
51 void motorMode(uint8_t motor, uint8_t mode);
52 uint32_t motorPosition(uint8_t);
53
54 void i2cMUXSelect();
55 void i2cWriteData(uint8_t reg, uint8_t data);
56 uint32_t i2cReadData(int reg, int num);
57
58 public:
59 uint8_t _ch=0;
60 TwoWire* _pWire;
61
65 void begin();
66
73 void motorSet(uint8_t motor_ch, uint8_t speed);
74
81 void motorRound(uint8_t motor_ch, float round);
82
89 void motorInvert(uint8_t motor_ch, bool invert);
90
97 void servoSet(uint8_t servo_ch, uint8_t angle);
98
104 float getBattery();
105};
106
107#endif
Class for controlling motors and servos in the Matrix Controller (HT).
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.