refactored and added rumble mode, added 'pit hold by ref'
This commit is contained in:
@@ -13,7 +13,7 @@ void pollInput (){
|
|||||||
buttonSTARTforced = buttonSTART.longPress();
|
buttonSTARTforced = buttonSTART.longPress();
|
||||||
buttonPAUSEvar = buttonPAUSE.singleClick();
|
buttonPAUSEvar = buttonPAUSE.singleClick();
|
||||||
buttonPITvar = buttonPIT.singleClick();
|
buttonPITvar = buttonPIT.singleClick();
|
||||||
buttonPIThold = buttonPIT.longPress();
|
buttonPIThold = buttonPIT.on();
|
||||||
buttonRESETvar = buttonRESET.longPress();
|
buttonRESETvar = buttonRESET.longPress();
|
||||||
|
|
||||||
// if (buttonREDTEAM.pushed()) {
|
// if (buttonREDTEAM.pushed()) {
|
||||||
|
|||||||
@@ -12,6 +12,12 @@ void openPIT() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void openPITmanually() {
|
||||||
|
PITreleased = true;
|
||||||
|
PITopenTimestamp = millis();
|
||||||
|
digitalWrite(PIT_RELEASE_PIN, HIGH);
|
||||||
|
}
|
||||||
|
|
||||||
// usage: blink_LED_BlueTeam(<interval in milliseconds>);
|
// usage: blink_LED_BlueTeam(<interval in milliseconds>);
|
||||||
// void blink_LED_BlueTeam(int BLINK_INTERVAL) {
|
// void blink_LED_BlueTeam(int BLINK_INTERVAL) {
|
||||||
// EVERY_N_MILLISECONDS(BLINK_INTERVAL) {
|
// EVERY_N_MILLISECONDS(BLINK_INTERVAL) {
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ bool countdownPAUSED = false;
|
|||||||
CountDown FightCountDown[1];
|
CountDown FightCountDown[1];
|
||||||
|
|
||||||
// Rumble stopwatch
|
// Rumble stopwatch
|
||||||
StopWatch rumbleTIME;
|
StopWatch rumbleTIME(StopWatch::SECONDS);
|
||||||
|
|
||||||
int CLOCK_LED_BRIGHTNESS = 16; // 64 is okay
|
int CLOCK_LED_BRIGHTNESS = 16; // 64 is okay
|
||||||
|
|
||||||
@@ -166,7 +166,6 @@ void setup() {
|
|||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
// set outputs
|
// set outputs
|
||||||
pinMode(PIT_RELEASE_PIN, OUTPUT);
|
pinMode(PIT_RELEASE_PIN, OUTPUT);
|
||||||
|
|
||||||
digitalWrite(PIT_RELEASE_PIN, LOW);
|
digitalWrite(PIT_RELEASE_PIN, LOW);
|
||||||
|
|
||||||
// Set device as a Wi-Fi Station
|
// Set device as a Wi-Fi Station
|
||||||
@@ -180,7 +179,7 @@ void setup() {
|
|||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// ESP Now send part:
|
// ESP Now send part:
|
||||||
// Once ESPNow is successfully Init, we will register for Send CB to
|
// 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);
|
esp_now_register_send_cb(OnDataSent);
|
||||||
|
|
||||||
// Register peer
|
// Register peer
|
||||||
@@ -216,83 +215,98 @@ void loop() {
|
|||||||
// deactivate solenoids if needed
|
// deactivate solenoids if needed
|
||||||
checkPIT();
|
checkPIT();
|
||||||
|
|
||||||
// Normal fight routine
|
// start button logic
|
||||||
while (!switchRUMBLE.on()) {
|
if (buttonSTARTvar) {
|
||||||
// poll all the switch/button inputs
|
buttonSTARTvar = false;
|
||||||
pollInput();
|
if (!FightCountDown[0].isRunning() && !rumbleTIME.isRunning() && countdownPAUSED == false) {
|
||||||
// deactivate solenoids if needed
|
if (switchRUMBLE.on()) {
|
||||||
checkPIT();
|
buttonREDTEAMvar = false;
|
||||||
// start button logic
|
buttonBLUETEAMvar = false;
|
||||||
if (buttonSTARTvar) {
|
rumbleTIME.start();
|
||||||
buttonSTARTvar = false;
|
} else if (buttonREDTEAMvar && buttonBLUETEAMvar && !switchRUMBLE.on()) {
|
||||||
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) {
|
|
||||||
buttonREDTEAMvar = false;
|
buttonREDTEAMvar = false;
|
||||||
buttonBLUETEAMvar = false;
|
buttonBLUETEAMvar = false;
|
||||||
FightCountDown[0].start(0,0,countdownTIME,0);
|
FightCountDown[0].start(0,0,countdownTIME,0);
|
||||||
}
|
}
|
||||||
else {
|
}
|
||||||
|
else {
|
||||||
|
if (buttonREDTEAMvar && buttonBLUETEAMvar && !switchRUMBLE.on()) {
|
||||||
buttonREDTEAMvar = false;
|
buttonREDTEAMvar = false;
|
||||||
buttonBLUETEAMvar = false;
|
buttonBLUETEAMvar = false;
|
||||||
countdownPAUSED = false;
|
countdownPAUSED = false;
|
||||||
FightCountDown[0].cont();
|
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);
|
|
||||||
}
|
}
|
||||||
|
// forced start of countdown
|
||||||
|
if (buttonSTARTforced) {
|
||||||
// Rumble fightroutine
|
buttonSTARTforced = false;
|
||||||
while (switchRUMBLE.on()) {
|
if (!FightCountDown[0].isRunning() && !rumbleTIME.isRunning() && countdownPAUSED == false) {
|
||||||
// poll all the switch/button inputs
|
buttonREDTEAMvar = false;
|
||||||
pollInput();
|
buttonBLUETEAMvar = false;
|
||||||
// deactivate solenoids if needed
|
if (!switchRUMBLE.on()) {
|
||||||
checkPIT();
|
FightCountDown[0].start(0,0,countdownTIME,0);
|
||||||
// update the LED Display
|
} else if (switchRUMBLE.on()) {
|
||||||
sendTimeDisplay(12, 34, XDAS, 0, XDAS, CLOCK_LED_BRIGHTNESS);
|
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