Railway Challenge
/
challenge
Uncommenting of part that allow supercaps to charge up from the batteries
remoteControl.h@30:a04afea230fb, 2022-06-15 (annotated)
- Committer:
- jamesmcildowietfl
- Date:
- Wed Jun 15 11:33:56 2022 +0000
- Revision:
- 30:a04afea230fb
- Parent:
- 0:4788e1df7b55
Forgot to add light pins to header, done now ;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rwcjoliver | 0:4788e1df7b55 | 1 | #ifndef REMOTECONTROL_H |
rwcjoliver | 0:4788e1df7b55 | 2 | #define REMOTECONTROL_H |
rwcjoliver | 0:4788e1df7b55 | 3 | |
rwcjoliver | 0:4788e1df7b55 | 4 | #include <mbed.h> |
rwcjoliver | 0:4788e1df7b55 | 5 | |
rwcjoliver | 0:4788e1df7b55 | 6 | class Remote{ |
rwcjoliver | 0:4788e1df7b55 | 7 | public: |
rwcjoliver | 0:4788e1df7b55 | 8 | // CONSTRUCTOR |
rwcjoliver | 0:4788e1df7b55 | 9 | Remote(SPI& remoteControl, DigitalOut& remoteControlCS); |
rwcjoliver | 0:4788e1df7b55 | 10 | |
rwcjoliver | 0:4788e1df7b55 | 11 | bool commsGood; // Successful Comms Between Nucleo and Remote Control |
rwcjoliver | 0:4788e1df7b55 | 12 | |
rwcjoliver | 0:4788e1df7b55 | 13 | volatile int throttle; |
rwcjoliver | 0:4788e1df7b55 | 14 | volatile int braking; |
rwcjoliver | 0:4788e1df7b55 | 15 | volatile bool start; |
rwcjoliver | 0:4788e1df7b55 | 16 | volatile bool forward; |
rwcjoliver | 0:4788e1df7b55 | 17 | volatile bool park; |
rwcjoliver | 0:4788e1df7b55 | 18 | volatile bool reverse; |
rwcjoliver | 0:4788e1df7b55 | 19 | volatile bool compressor; |
rwcjoliver | 0:4788e1df7b55 | 20 | volatile bool autoStop; |
rwcjoliver | 0:4788e1df7b55 | 21 | volatile bool regenBrake; |
rwcjoliver | 0:4788e1df7b55 | 22 | volatile bool regenThrottle; |
rwcjoliver | 0:4788e1df7b55 | 23 | volatile bool whistle; |
rwcjoliver | 0:4788e1df7b55 | 24 | volatile bool innovation; |
rwcjoliver | 0:4788e1df7b55 | 25 | |
rwcjoliver | 0:4788e1df7b55 | 26 | void initialiseRemoteComms(); |
rwcjoliver | 0:4788e1df7b55 | 27 | int sendData(int precursor, int data); |
rwcjoliver | 0:4788e1df7b55 | 28 | void sendError(int error); |
rwcjoliver | 0:4788e1df7b55 | 29 | void commsCheck(); |
rwcjoliver | 0:4788e1df7b55 | 30 | void getSwitchStates(); |
rwcjoliver | 0:4788e1df7b55 | 31 | void setTime(int hr, int min, int sec, int day, int mon, int yr); |
rwcjoliver | 0:4788e1df7b55 | 32 | |
rwcjoliver | 0:4788e1df7b55 | 33 | private: |
rwcjoliver | 0:4788e1df7b55 | 34 | SPI& _remoteControl; |
rwcjoliver | 0:4788e1df7b55 | 35 | DigitalOut& _remoteControlCS; |
rwcjoliver | 0:4788e1df7b55 | 36 | |
rwcjoliver | 0:4788e1df7b55 | 37 | int spiDelay; |
rwcjoliver | 0:4788e1df7b55 | 38 | int commsFailures; // Number of consecutive remote comms failures |
rwcjoliver | 0:4788e1df7b55 | 39 | int errorIndex; |
rwcjoliver | 0:4788e1df7b55 | 40 | int errorBuffer[27]; |
rwcjoliver | 0:4788e1df7b55 | 41 | |
rwcjoliver | 0:4788e1df7b55 | 42 | void ByteToBits(unsigned char character, bool *boolArray); |
rwcjoliver | 0:4788e1df7b55 | 43 | |
rwcjoliver | 0:4788e1df7b55 | 44 | Ticker commsCheckTicker; //ticker for recurring comms check |
rwcjoliver | 0:4788e1df7b55 | 45 | Ticker remoteSwitchStateTicker; //ticker for recurring remote switch state update |
rwcjoliver | 0:4788e1df7b55 | 46 | }; |
rwcjoliver | 0:4788e1df7b55 | 47 | |
rwcjoliver | 0:4788e1df7b55 | 48 | #endif |