Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: remoteControl.h
- Revision:
- 0:4788e1df7b55
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/remoteControl.h Fri Mar 13 11:48:04 2020 +0000
@@ -0,0 +1,48 @@
+#ifndef REMOTECONTROL_H
+#define REMOTECONTROL_H
+
+#include <mbed.h>
+
+class Remote{
+ public:
+ // CONSTRUCTOR
+ Remote(SPI& remoteControl, DigitalOut& remoteControlCS);
+
+ bool commsGood; // Successful Comms Between Nucleo and Remote Control
+
+ volatile int throttle;
+ volatile int braking;
+ volatile bool start;
+ volatile bool forward;
+ volatile bool park;
+ volatile bool reverse;
+ volatile bool compressor;
+ volatile bool autoStop;
+ volatile bool regenBrake;
+ volatile bool regenThrottle;
+ volatile bool whistle;
+ volatile bool innovation;
+
+ void initialiseRemoteComms();
+ int sendData(int precursor, int data);
+ void sendError(int error);
+ void commsCheck();
+ void getSwitchStates();
+ void setTime(int hr, int min, int sec, int day, int mon, int yr);
+
+ private:
+ SPI& _remoteControl;
+ DigitalOut& _remoteControlCS;
+
+ int spiDelay;
+ int commsFailures; // Number of consecutive remote comms failures
+ int errorIndex;
+ int errorBuffer[27];
+
+ void ByteToBits(unsigned char character, bool *boolArray);
+
+ Ticker commsCheckTicker; //ticker for recurring comms check
+ Ticker remoteSwitchStateTicker; //ticker for recurring remote switch state update
+};
+
+#endif
\ No newline at end of file