Railway Challenge / Mbed 2 deprecated challenge

Dependencies:   mbed millis

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers remoteControl.h Source File

remoteControl.h

00001 #ifndef REMOTECONTROL_H
00002 #define REMOTECONTROL_H
00003 
00004 #include <mbed.h>
00005 
00006 class Remote{
00007     public:
00008         // CONSTRUCTOR
00009         Remote(SPI& remoteControl, DigitalOut& remoteControlCS);
00010         
00011         bool commsGood;                 // Successful Comms Between Nucleo and Remote Control
00012         
00013         volatile int throttle;
00014         volatile int braking;
00015         volatile bool start;
00016         volatile bool forward;
00017         volatile bool park;
00018         volatile bool reverse;
00019         volatile bool compressor;
00020         volatile bool autoStop;
00021         volatile bool regenBrake;
00022         volatile bool regenThrottle;
00023         volatile bool whistle;
00024         volatile bool innovation;
00025         
00026         void initialiseRemoteComms();
00027         int sendData(int precursor, int data);
00028         void sendError(int error);
00029         void commsCheck();
00030         void getSwitchStates();
00031         void setTime(int hr, int min, int sec, int day, int mon, int yr);
00032         
00033     private:
00034         SPI& _remoteControl;
00035         DigitalOut& _remoteControlCS;
00036 
00037         int spiDelay;
00038         int commsFailures;                      // Number of consecutive remote comms failures
00039         int errorIndex;
00040         int errorBuffer[27];
00041         
00042         void ByteToBits(unsigned char character, bool *boolArray);
00043         
00044         Ticker commsCheckTicker;                    //ticker for recurring comms check
00045         Ticker remoteSwitchStateTicker;             //ticker for recurring remote switch state update
00046 };
00047 
00048 #endif