Railway Challenge / Mbed 2 deprecated challenge

Dependencies:   mbed millis

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers challenge.h Source File

challenge.h

00001 #ifndef _CHALLENGE_H_
00002 #define _CHALLENGE_H_
00003 
00004 #include <mbed.h>
00005 #include "dashboard.h"
00006 #include "remoteControl.h"
00007 #include "motor.h"
00008 
00009 class ChallengeMode {
00010     public:
00011         // CONSTURCTOR
00012         ChallengeMode(InterruptIn& autoStopTrigger, Dashboard& dashboard, Remote& remote, Motor& motor1);
00013         
00014         // FUNCTIONS
00015         // Regen Mode
00016         void regenThrottleOn();
00017         void regenThrottleOff();
00018         bool regenBrakingOn();
00019         void regenBrakingOff();
00020         
00021         // Auto-Stop Mode
00022         void autoStopOn();
00023         void autoStopOff();
00024         void autoStopTriggered();
00025         void autoStopControl();
00026         
00027         // Innovation Mode
00028         void innovationOn();
00029         void innovationOff();
00030         int innovationControl(int requestedThrottle);
00031         
00032         // VARIABLES
00033         bool regenThrottleActive;
00034         bool regenBrakingActive;
00035         bool autoStopActive;
00036         bool innovationActive;
00037         
00038         int autoStopCruiseSpeed;
00039         int autoStopThrottle;
00040         bool autoStopInProgress;
00041     
00042     private:
00043         InterruptIn& _autoStopTrigger;
00044         Dashboard& _dashboard;
00045         Remote& _remote;
00046         Motor& _motor1;
00047 //        Motor& _motor2;
00048         
00049         // AutoStop
00050         float targetDistance;
00051         float remainingDistance;
00052 
00053 //        float timeToReachTarget;
00054         float decelerationGradient;
00055         float requiredSpeed;
00056         
00057         // Innovation
00058         int innovationDistanceLimit;    // Distance(mm) from IR sensors to apply brakes
00059         bool stopLoco;
00060         
00061         // IR Output voltages at various distances (for calibration purposes)
00062         float voltageAt5500;
00063         float voltageAt5000;
00064         float voltageAt4500;
00065         float voltageAt4000;
00066         float voltageAt3500;
00067         float voltageAt3000;
00068         float voltageAt2500;
00069         float voltageAt2000;
00070         float voltageAt1500;
00071         float voltageAt1000;
00072         float voltageAt500;
00073 };
00074 
00075 #endif