|
RSeries astromech firmware
|
|
Go to the documentation of this file. 1 #ifndef StealthController_h
2 #define StealthController_h
35 const byte pinS1 = 26,
36 const byte pinJ1 = 28,
37 const byte pinS2 = 27,
38 const byte pinJ2 = 29,
39 const byte pinLegMotors = 10,
40 const byte pinDomeMotor = 11) :
46 fPinLegMotors(pinLegMotors),
47 fPinDomeMotor(pinDomeMotor)
56 pinMode(fPinS1, INPUT_PULLUP);
57 pinMode(fPinJ1, INPUT_PULLUP);
58 pinMode(fPinS2, INPUT_PULLUP);
59 pinMode(fPinJ2, INPUT_PULLUP);
60 pinMode(fPinLegMotors, INPUT);
61 pinMode(fPinDomeMotor, INPUT);
66 if (degrees != fPosDegrees)
68 fPosDegrees = degrees;
69 int output = map(degrees, 0, 360, 0, 4095);
71 Wire.beginTransmission(0x62);
72 Wire.write(MCP4726_CMD_WRITEDAC);
74 Wire.write(output / 16);
76 Wire.write((output % 16) << 4);
77 Wire.endTransmission();
83 return ((fStatus &
S1_FLAG) != 0);
88 return ((fStatus &
S2_FLAG) != 0);
93 return ((fStatus &
J1_FLAG) != 0);
98 return ((fStatus &
J2_FLAG) != 0);
151 if (digitalRead(fPinS1) == HIGH)
153 if (digitalRead(fPinS2) == HIGH)
155 if (digitalRead(fPinJ1) == HIGH)
157 if (digitalRead(fPinJ2) == HIGH)
159 if (digitalRead(fPinLegMotors) == HIGH)
161 if (digitalRead(fPinDomeMotor) == HIGH)
163 if (status != fStatus)
168 fPrevStatus = fStatus;
175 const byte MCP4726_CMD_WRITEDAC = 0x40;
176 const byte MCP4726_CMD_WRITEDACEEPROM = 0x60;
177 uint16_t fPosDegrees;
bool getS2()
Definition: StealthController.h:86
virtual void setup() override
Setup pin mode for analog read.
Definition: StealthController.h:54
const byte DOMEMOTOR_FLAG
Definition: StealthController.h:28
#define DEBUG_PRINT(s)
Definition: ReelTwo.h:189
Base class for all animated devices. AnimatedEvent::animate() is called for each device once through ...
Definition: AnimatedEvent.h:18
Stealth Controller directly attached to the Arduino to read J1/J2 and S1/S2 status header and using a...
Definition: StealthController.h:19
bool didLegMotorsStart()
Definition: StealthController.h:111
Base class for all devices that require setup that cannot happen in the constructor....
Definition: SetupEvent.h:15
const byte S2_FLAG
Definition: StealthController.h:24
bool didDomeMotorStop()
Definition: StealthController.h:134
byte getStatusFlags()
Definition: StealthController.h:101
bool getJ1()
Definition: StealthController.h:91
bool getS1()
Definition: StealthController.h:81
#define DEBUG_PRINTLN(s)
Definition: ReelTwo.h:188
bool getStatusChanged()
Definition: StealthController.h:106
const byte LEGMOTORS_FLAG
Definition: StealthController.h:27
bool didLegMotorsStop()
Definition: StealthController.h:117
bool didDomeMotorStart()
Definition: StealthController.h:128
const byte J1_FLAG
Definition: StealthController.h:25
const byte S1_FLAG
Definition: StealthController.h:23
#define DEBUG_PRINT_HEX(s)
Definition: ReelTwo.h:192
bool getDomeMotorMoving()
Definition: StealthController.h:140
bool getLegMotorsMoving()
Definition: StealthController.h:123
bool getJ2()
Definition: StealthController.h:96
const byte J2_FLAG
Definition: StealthController.h:26
void setDomePosition(uint16_t degrees)
Definition: StealthController.h:64
StealthController(const byte pinS1=26, const byte pinJ1=28, const byte pinS2=27, const byte pinJ2=29, const byte pinLegMotors=10, const byte pinDomeMotor=11)
Default Constructor.
Definition: StealthController.h:34
virtual void animate() override
Read the pot once through the loop.
Definition: StealthController.h:147