refactored and added rumble mode, added 'pit hold by ref'
This commit is contained in:
@@ -49,7 +49,7 @@ bool countdownPAUSED = false;
|
||||
CountDown FightCountDown[1];
|
||||
|
||||
// Rumble stopwatch
|
||||
StopWatch rumbleTIME;
|
||||
StopWatch rumbleTIME(StopWatch::SECONDS);
|
||||
|
||||
int CLOCK_LED_BRIGHTNESS = 16; // 64 is okay
|
||||
|
||||
@@ -166,7 +166,6 @@ void setup() {
|
||||
Serial.begin(115200);
|
||||
// set outputs
|
||||
pinMode(PIT_RELEASE_PIN, OUTPUT);
|
||||
|
||||
digitalWrite(PIT_RELEASE_PIN, LOW);
|
||||
|
||||
// Set device as a Wi-Fi Station
|
||||
@@ -180,7 +179,7 @@ void setup() {
|
||||
//------------------------------------------------------------------------------------
|
||||
// ESP Now send part:
|
||||
// Once ESPNow is successfully Init, we will register for Send CB to
|
||||
// get the status of Trasnmitted packet
|
||||
// get the status of Transmitted packet
|
||||
esp_now_register_send_cb(OnDataSent);
|
||||
|
||||
// Register peer
|
||||
@@ -216,83 +215,98 @@ void loop() {
|
||||
// deactivate solenoids if needed
|
||||
checkPIT();
|
||||
|
||||
// Normal fight routine
|
||||
while (!switchRUMBLE.on()) {
|
||||
// poll all the switch/button inputs
|
||||
pollInput();
|
||||
// deactivate solenoids if needed
|
||||
checkPIT();
|
||||
// start button logic
|
||||
if (buttonSTARTvar) {
|
||||
buttonSTARTvar = false;
|
||||
if (!FightCountDown[0].isRunning() && countdownPAUSED == false) {
|
||||
if (buttonREDTEAMvar && buttonBLUETEAMvar) {
|
||||
buttonREDTEAMvar = false;
|
||||
buttonBLUETEAMvar = false;
|
||||
FightCountDown[0].start(0,0,countdownTIME,0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (buttonREDTEAMvar && buttonBLUETEAMvar) {
|
||||
buttonREDTEAMvar = false;
|
||||
buttonBLUETEAMvar = false;
|
||||
countdownPAUSED = false;
|
||||
FightCountDown[0].cont();
|
||||
}
|
||||
}
|
||||
}
|
||||
// forced start of countdown
|
||||
if (buttonSTARTforced) {
|
||||
buttonSTARTforced = false;
|
||||
if (!FightCountDown[0].isRunning() && countdownPAUSED == false) {
|
||||
// start button logic
|
||||
if (buttonSTARTvar) {
|
||||
buttonSTARTvar = false;
|
||||
if (!FightCountDown[0].isRunning() && !rumbleTIME.isRunning() && countdownPAUSED == false) {
|
||||
if (switchRUMBLE.on()) {
|
||||
buttonREDTEAMvar = false;
|
||||
buttonBLUETEAMvar = false;
|
||||
rumbleTIME.start();
|
||||
} else if (buttonREDTEAMvar && buttonBLUETEAMvar && !switchRUMBLE.on()) {
|
||||
buttonREDTEAMvar = false;
|
||||
buttonBLUETEAMvar = false;
|
||||
FightCountDown[0].start(0,0,countdownTIME,0);
|
||||
}
|
||||
else {
|
||||
}
|
||||
else {
|
||||
if (buttonREDTEAMvar && buttonBLUETEAMvar && !switchRUMBLE.on()) {
|
||||
buttonREDTEAMvar = false;
|
||||
buttonBLUETEAMvar = false;
|
||||
countdownPAUSED = false;
|
||||
FightCountDown[0].cont();
|
||||
} else if (switchRUMBLE.on()) {
|
||||
buttonREDTEAMvar = false;
|
||||
buttonBLUETEAMvar = false;
|
||||
countdownPAUSED = false;
|
||||
rumbleTIME.start();
|
||||
}
|
||||
}
|
||||
// pause button logic
|
||||
if (buttonPAUSEvar) {
|
||||
buttonPAUSEvar = false;
|
||||
if (FightCountDown[0].isRunning()) {
|
||||
countdownPAUSED = true;
|
||||
FightCountDown[0].stop();
|
||||
}
|
||||
}
|
||||
// pit button logic
|
||||
if (buttonPITvar) {
|
||||
buttonPITvar = false;
|
||||
openPIT();
|
||||
}
|
||||
// automatic pit release
|
||||
if (FightCountDown[0].remaining() <= PITreleaseTime && FightCountDown[0].remaining() > 0 && switchPIT.on()) {
|
||||
openPIT();
|
||||
}
|
||||
// reset button logic
|
||||
if (buttonRESETvar) {
|
||||
buttonRESETvar = false;
|
||||
PITreleased = false;
|
||||
ESP.restart();
|
||||
}
|
||||
//blink_LED_RedTeam(200);
|
||||
//blink_LED_BlueTeam(200);
|
||||
// update the LED Display
|
||||
sendTimeDisplay((FightCountDown[0].remaining()/60%10), (FightCountDown[0].remaining()%60), 0, XDAS, 0, CLOCK_LED_BRIGHTNESS);
|
||||
}
|
||||
|
||||
|
||||
// Rumble fightroutine
|
||||
while (switchRUMBLE.on()) {
|
||||
// poll all the switch/button inputs
|
||||
pollInput();
|
||||
// deactivate solenoids if needed
|
||||
checkPIT();
|
||||
// update the LED Display
|
||||
sendTimeDisplay(12, 34, XDAS, 0, XDAS, CLOCK_LED_BRIGHTNESS);
|
||||
// forced start of countdown
|
||||
if (buttonSTARTforced) {
|
||||
buttonSTARTforced = false;
|
||||
if (!FightCountDown[0].isRunning() && !rumbleTIME.isRunning() && countdownPAUSED == false) {
|
||||
buttonREDTEAMvar = false;
|
||||
buttonBLUETEAMvar = false;
|
||||
if (!switchRUMBLE.on()) {
|
||||
FightCountDown[0].start(0,0,countdownTIME,0);
|
||||
} else if (switchRUMBLE.on()) {
|
||||
rumbleTIME.start();
|
||||
}
|
||||
}
|
||||
else {
|
||||
buttonREDTEAMvar = false;
|
||||
buttonBLUETEAMvar = false;
|
||||
countdownPAUSED = false;
|
||||
if (!switchRUMBLE.on()) {
|
||||
FightCountDown[0].cont();
|
||||
} else if (switchRUMBLE.on()) {
|
||||
rumbleTIME.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
// pause button logic
|
||||
if (buttonPAUSEvar) {
|
||||
buttonPAUSEvar = false;
|
||||
if (FightCountDown[0].isRunning()) {
|
||||
countdownPAUSED = true;
|
||||
FightCountDown[0].stop();
|
||||
}
|
||||
if (rumbleTIME.isRunning()) {
|
||||
countdownPAUSED = true;
|
||||
rumbleTIME.stop();
|
||||
}
|
||||
}
|
||||
// pit button logic
|
||||
if (buttonPITvar) {
|
||||
buttonPITvar = false;
|
||||
buttonPIThold = false;
|
||||
openPITmanually();
|
||||
}
|
||||
// automatic pit release
|
||||
if (FightCountDown[0].remaining() == PITreleaseTime && switchPIT.on() && buttonPIThold == false) {
|
||||
openPIT();
|
||||
}
|
||||
if (rumbleTIME.elapsed() == PITreleaseTime && switchPIT.on() && buttonPIThold == false) {
|
||||
openPIT();
|
||||
}
|
||||
// reset button logic
|
||||
if (buttonRESETvar) {
|
||||
buttonRESETvar = false;
|
||||
PITreleased = false;
|
||||
ESP.restart();
|
||||
}
|
||||
//blink_LED_RedTeam(200);
|
||||
//blink_LED_BlueTeam(200);
|
||||
// update the LED Display
|
||||
if (!switchRUMBLE.on()) {
|
||||
if (!FightCountDown[0].isRunning() && countdownPAUSED == false) {
|
||||
sendTimeDisplay(countdownTIME, 0, 0, XDAS, 0, CLOCK_LED_BRIGHTNESS);
|
||||
} else {
|
||||
sendTimeDisplay((FightCountDown[0].remaining()/60%10), (FightCountDown[0].remaining()%60), 0, XDAS, 0, CLOCK_LED_BRIGHTNESS);
|
||||
}
|
||||
} else if (switchRUMBLE.on()) {
|
||||
sendTimeDisplay((rumbleTIME.elapsed()/60%10), (rumbleTIME.elapsed()%60), 0, XDAS, XDAS, CLOCK_LED_BRIGHTNESS);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user