Railway Challenge
/
challenge
Uncommenting of part that allow supercaps to charge up from the batteries
challenge.h@30:a04afea230fb, 2022-06-15 (annotated)
- Committer:
- jamesmcildowietfl
- Date:
- Wed Jun 15 11:33:56 2022 +0000
- Revision:
- 30:a04afea230fb
- Parent:
- 15:4976d145fbd9
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 _CHALLENGE_H_ |
rwcjoliver | 0:4788e1df7b55 | 2 | #define _CHALLENGE_H_ |
rwcjoliver | 0:4788e1df7b55 | 3 | |
rwcjoliver | 0:4788e1df7b55 | 4 | #include <mbed.h> |
rwcjoliver | 0:4788e1df7b55 | 5 | #include "dashboard.h" |
rwcjoliver | 0:4788e1df7b55 | 6 | #include "remoteControl.h" |
rwcjoliver | 0:4788e1df7b55 | 7 | #include "motor.h" |
rwcjoliver | 0:4788e1df7b55 | 8 | |
rwcjoliver | 0:4788e1df7b55 | 9 | class ChallengeMode { |
rwcjoliver | 0:4788e1df7b55 | 10 | public: |
rwcjoliver | 0:4788e1df7b55 | 11 | // CONSTURCTOR |
jamesmcildowietfl | 15:4976d145fbd9 | 12 | ChallengeMode(InterruptIn& autoStopTrigger, Dashboard& dashboard, Remote& remote, Motor& motor1); |
rwcjoliver | 0:4788e1df7b55 | 13 | |
rwcjoliver | 0:4788e1df7b55 | 14 | // FUNCTIONS |
rwcjoliver | 0:4788e1df7b55 | 15 | // Regen Mode |
rwcjoliver | 0:4788e1df7b55 | 16 | void regenThrottleOn(); |
rwcjoliver | 0:4788e1df7b55 | 17 | void regenThrottleOff(); |
rwcjoliver | 0:4788e1df7b55 | 18 | bool regenBrakingOn(); |
rwcjoliver | 0:4788e1df7b55 | 19 | void regenBrakingOff(); |
rwcjoliver | 0:4788e1df7b55 | 20 | |
rwcjoliver | 0:4788e1df7b55 | 21 | // Auto-Stop Mode |
rwcjoliver | 0:4788e1df7b55 | 22 | void autoStopOn(); |
rwcjoliver | 0:4788e1df7b55 | 23 | void autoStopOff(); |
rwcjoliver | 0:4788e1df7b55 | 24 | void autoStopTriggered(); |
rwcjoliver | 0:4788e1df7b55 | 25 | void autoStopControl(); |
rwcjoliver | 0:4788e1df7b55 | 26 | |
rwcjoliver | 0:4788e1df7b55 | 27 | // Innovation Mode |
rwcjoliver | 0:4788e1df7b55 | 28 | void innovationOn(); |
rwcjoliver | 0:4788e1df7b55 | 29 | void innovationOff(); |
rwcjoliver | 0:4788e1df7b55 | 30 | int innovationControl(int requestedThrottle); |
rwcjoliver | 0:4788e1df7b55 | 31 | |
rwcjoliver | 0:4788e1df7b55 | 32 | // VARIABLES |
rwcjoliver | 0:4788e1df7b55 | 33 | bool regenThrottleActive; |
rwcjoliver | 0:4788e1df7b55 | 34 | bool regenBrakingActive; |
rwcjoliver | 0:4788e1df7b55 | 35 | bool autoStopActive; |
rwcjoliver | 0:4788e1df7b55 | 36 | bool innovationActive; |
rwcjoliver | 0:4788e1df7b55 | 37 | |
rwcjoliver | 0:4788e1df7b55 | 38 | int autoStopCruiseSpeed; |
rwcjoliver | 0:4788e1df7b55 | 39 | int autoStopThrottle; |
rwcjoliver | 0:4788e1df7b55 | 40 | bool autoStopInProgress; |
rwcjoliver | 0:4788e1df7b55 | 41 | |
rwcjoliver | 0:4788e1df7b55 | 42 | private: |
rwcjoliver | 0:4788e1df7b55 | 43 | InterruptIn& _autoStopTrigger; |
rwcjoliver | 0:4788e1df7b55 | 44 | Dashboard& _dashboard; |
rwcjoliver | 0:4788e1df7b55 | 45 | Remote& _remote; |
rwcjoliver | 0:4788e1df7b55 | 46 | Motor& _motor1; |
rwcjoliver | 0:4788e1df7b55 | 47 | // Motor& _motor2; |
rwcjoliver | 0:4788e1df7b55 | 48 | |
rwcjoliver | 0:4788e1df7b55 | 49 | // AutoStop |
rwcjoliver | 0:4788e1df7b55 | 50 | float targetDistance; |
rwcjoliver | 0:4788e1df7b55 | 51 | float remainingDistance; |
rwcjoliver | 0:4788e1df7b55 | 52 | |
rwcjoliver | 0:4788e1df7b55 | 53 | // float timeToReachTarget; |
rwcjoliver | 0:4788e1df7b55 | 54 | float decelerationGradient; |
rwcjoliver | 0:4788e1df7b55 | 55 | float requiredSpeed; |
rwcjoliver | 0:4788e1df7b55 | 56 | |
rwcjoliver | 0:4788e1df7b55 | 57 | // Innovation |
rwcjoliver | 0:4788e1df7b55 | 58 | int innovationDistanceLimit; // Distance(mm) from IR sensors to apply brakes |
rwcjoliver | 0:4788e1df7b55 | 59 | bool stopLoco; |
rwcjoliver | 0:4788e1df7b55 | 60 | |
rwcjoliver | 0:4788e1df7b55 | 61 | // IR Output voltages at various distances (for calibration purposes) |
rwcjoliver | 0:4788e1df7b55 | 62 | float voltageAt5500; |
rwcjoliver | 0:4788e1df7b55 | 63 | float voltageAt5000; |
rwcjoliver | 0:4788e1df7b55 | 64 | float voltageAt4500; |
rwcjoliver | 0:4788e1df7b55 | 65 | float voltageAt4000; |
rwcjoliver | 0:4788e1df7b55 | 66 | float voltageAt3500; |
rwcjoliver | 0:4788e1df7b55 | 67 | float voltageAt3000; |
rwcjoliver | 0:4788e1df7b55 | 68 | float voltageAt2500; |
rwcjoliver | 0:4788e1df7b55 | 69 | float voltageAt2000; |
rwcjoliver | 0:4788e1df7b55 | 70 | float voltageAt1500; |
rwcjoliver | 0:4788e1df7b55 | 71 | float voltageAt1000; |
rwcjoliver | 0:4788e1df7b55 | 72 | float voltageAt500; |
rwcjoliver | 0:4788e1df7b55 | 73 | }; |
rwcjoliver | 0:4788e1df7b55 | 74 | |
rwcjoliver | 0:4788e1df7b55 | 75 | #endif |