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.
challenge.h
- Committer:
- rwcjoliver
- Date:
- 2020-03-13
- Revision:
- 0:4788e1df7b55
- Child:
- 13:a9793222af20
File content as of revision 0:4788e1df7b55:
#ifndef _CHALLENGE_H_
#define _CHALLENGE_H_
#include <mbed.h>
#include "dashboard.h"
#include "remoteControl.h"
#include "motor.h"
class ChallengeMode {
public:
// CONSTURCTOR
ChallengeMode(InterruptIn& autoStopTrigger, Dashboard& dashboard, Remote& remote, Motor& motor1);
// FUNCTIONS
// Regen Mode
void regenThrottleOn();
void regenThrottleOff();
bool regenBrakingOn();
void regenBrakingOff();
// Auto-Stop Mode
void autoStopOn();
void autoStopOff();
void autoStopTriggered();
void autoStopControl();
// Innovation Mode
void innovationOn();
void innovationOff();
int innovationControl(int requestedThrottle);
// VARIABLES
bool regenThrottleActive;
bool regenBrakingActive;
bool autoStopActive;
bool innovationActive;
int autoStopCruiseSpeed;
int autoStopThrottle;
bool autoStopInProgress;
private:
InterruptIn& _autoStopTrigger;
Dashboard& _dashboard;
Remote& _remote;
Motor& _motor1;
// Motor& _motor2;
// AutoStop
float targetDistance;
float remainingDistance;
// float timeToReachTarget;
float decelerationGradient;
float requiredSpeed;
// Innovation
int innovationDistanceLimit; // Distance(mm) from IR sensors to apply brakes
bool stopLoco;
// IR Output voltages at various distances (for calibration purposes)
float voltageAt5500;
float voltageAt5000;
float voltageAt4500;
float voltageAt4000;
float voltageAt3500;
float voltageAt3000;
float voltageAt2500;
float voltageAt2000;
float voltageAt1500;
float voltageAt1000;
float voltageAt500;
};
#endif