added forced start/continue, combined remote firmware
This commit is contained in:
@@ -9,18 +9,13 @@ void pollInput (){
|
||||
switchRUMBLE.poll();
|
||||
switchPIT.poll();
|
||||
|
||||
if (buttonSTART.pushed()) {
|
||||
buttonSTARTvar = true;
|
||||
}
|
||||
if (buttonPAUSE.pushed()) {
|
||||
buttonPAUSEvar = true;
|
||||
}
|
||||
if (buttonPIT.pushed()) {
|
||||
buttonPITvar = true;
|
||||
}
|
||||
if (buttonRESET.pushed()) {
|
||||
buttonRESETvar = true;
|
||||
}
|
||||
buttonSTARTvar = buttonSTART.singleClick();
|
||||
buttonSTARTforced = buttonSTART.longPress();
|
||||
buttonPAUSEvar = buttonPAUSE.singleClick();
|
||||
buttonPITvar = buttonPIT.singleClick();
|
||||
buttonPIThold = buttonPIT.longPress();
|
||||
buttonRESETvar = buttonRESET.longPress();
|
||||
|
||||
// if (buttonREDTEAM.pushed()) {
|
||||
// buttonREDTEAMvar = true;
|
||||
// if (ARENA_READY && !REDTEAM_READY) {
|
||||
|
||||
@@ -18,19 +18,26 @@
|
||||
#define PIT_RELEASE_PIN 39
|
||||
|
||||
// define buttons and switches
|
||||
Switch buttonSTART = Switch(START_BTN_PIN);
|
||||
//
|
||||
// constructor Switch
|
||||
// Parameters: byte _pin, byte PinMode = 5, bool polarity = 0, unsigned long debouncePeriod = 50, unsigned long longPressPeriod = 300, unsigned long doubleClickPeriod = 250, unsigned long deglitchPeriod = 10
|
||||
Switch buttonSTART = Switch(START_BTN_PIN, INPUT_PULLUP, LOW, 50, 1000);
|
||||
Switch buttonPAUSE = Switch(PAUSE_BTN_PIN);
|
||||
Switch buttonPIT = Switch(PIT_BTN_PIN);
|
||||
Switch buttonRESET = Switch(RESET_BTN_PIN);
|
||||
Switch buttonPIT = Switch(PIT_BTN_PIN, INPUT_PULLUP, LOW, 50, 1000);
|
||||
Switch buttonRESET = Switch(RESET_BTN_PIN, INPUT_PULLUP, LOW, 50, 1000);
|
||||
Switch switchRUMBLE = Switch(RUMBLE_SWITCH_PIN);
|
||||
Switch switchPIT = Switch(PIT_ENABLE_SWITCH_PIN);
|
||||
|
||||
bool buttonSTARTvar = false;
|
||||
bool buttonSTARTforced = false;
|
||||
bool buttonPAUSEvar = false;
|
||||
bool buttonPITvar = false;
|
||||
bool buttonPIThold = false;
|
||||
bool buttonRESETvar = false;
|
||||
bool buttonREDTEAMvar = false;
|
||||
bool buttonREDTEAMtapout = false;
|
||||
bool buttonBLUETEAMvar = false;
|
||||
bool buttonBLUETEAMtapout = false;
|
||||
unsigned long PITopenTimestamp = 0;
|
||||
const long PITopenTime = 1000; // activate solenoid for 1000ms
|
||||
bool PITreleased = false;
|
||||
@@ -94,12 +101,17 @@ void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {
|
||||
// Structure example to send data
|
||||
// Must match the receiver structure
|
||||
typedef struct struct_message_receive {
|
||||
int boardID;
|
||||
bool buttonSTART;
|
||||
bool buttonSTARTforced;
|
||||
bool buttonPAUSE;
|
||||
bool buttonPIT;
|
||||
bool buttonPIThold;
|
||||
bool buttonRESET;
|
||||
bool buttonREDTEAM;
|
||||
bool buttonREDTEAMtapout;
|
||||
bool buttonBLUETEAM;
|
||||
bool buttonBLUETEAMtapout;
|
||||
} struct_message_receive;
|
||||
|
||||
// Create a struct_message called receiveDATA
|
||||
@@ -108,23 +120,27 @@ struct_message_receive receiveDATA;
|
||||
// callback function that will be executed when data is received
|
||||
void OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, int len) {
|
||||
memcpy(&receiveDATA, incomingData, sizeof(receiveDATA));
|
||||
if (receiveDATA.buttonSTART) {
|
||||
buttonSTARTvar = true;
|
||||
}
|
||||
if (receiveDATA.buttonPAUSE) {
|
||||
buttonPAUSEvar = true;
|
||||
}
|
||||
if (receiveDATA.buttonPIT) {
|
||||
buttonPITvar = true;
|
||||
}
|
||||
if (receiveDATA.buttonRESET) {
|
||||
buttonRESETvar = true;
|
||||
}
|
||||
if (receiveDATA.buttonREDTEAM) {
|
||||
buttonREDTEAMvar = true;
|
||||
}
|
||||
if (receiveDATA.buttonBLUETEAM) {
|
||||
buttonBLUETEAMvar = true;
|
||||
// only fill the data to the right vars
|
||||
switch (receiveDATA.boardID) {
|
||||
case 0:
|
||||
// referee remote
|
||||
buttonSTARTvar = receiveDATA.buttonSTART;
|
||||
buttonSTARTforced = receiveDATA.buttonSTARTforced;
|
||||
buttonPAUSEvar = receiveDATA.buttonPAUSE;
|
||||
buttonPITvar = receiveDATA.buttonPIT;
|
||||
buttonPIThold = receiveDATA.buttonPIThold;
|
||||
buttonRESETvar = receiveDATA.buttonRESET;
|
||||
break;
|
||||
case 1:
|
||||
// RED team button
|
||||
buttonREDTEAMvar = receiveDATA.buttonREDTEAM;
|
||||
buttonREDTEAMtapout = receiveDATA.buttonREDTEAMtapout;
|
||||
break;
|
||||
case 2:
|
||||
// BLUE team button
|
||||
buttonBLUETEAMvar = receiveDATA.buttonBLUETEAM;
|
||||
buttonBLUETEAMtapout = receiveDATA.buttonBLUETEAMtapout;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +154,7 @@ void sendTimeDisplay(int MINUTES, int SECONDS, int RED, int GREEN, int BLUE, int
|
||||
sendClockDATA.sendGREENchannel = GREEN;
|
||||
sendClockDATA.sendBLUEchannel = BLUE;
|
||||
sendClockDATA.sendBrightness = BRIGHTNESS;
|
||||
|
||||
// actually send it
|
||||
esp_err_t result = esp_now_send(broadcastAddressClock, (uint8_t *) &sendClockDATA, sizeof(sendClockDATA));
|
||||
}
|
||||
}
|
||||
@@ -225,6 +241,21 @@ void loop() {
|
||||
}
|
||||
}
|
||||
}
|
||||
// forced start of countdown
|
||||
if (buttonSTARTforced) {
|
||||
buttonSTARTforced = false;
|
||||
if (!FightCountDown[0].isRunning() && countdownPAUSED == false) {
|
||||
buttonREDTEAMvar = false;
|
||||
buttonBLUETEAMvar = false;
|
||||
FightCountDown[0].start(0,0,countdownTIME,0);
|
||||
}
|
||||
else {
|
||||
buttonREDTEAMvar = false;
|
||||
buttonBLUETEAMvar = false;
|
||||
countdownPAUSED = false;
|
||||
FightCountDown[0].cont();
|
||||
}
|
||||
}
|
||||
// pause button logic
|
||||
if (buttonPAUSEvar) {
|
||||
buttonPAUSEvar = false;
|
||||
|
||||
@@ -6,16 +6,22 @@
|
||||
#include <avdweb_Switch.h> // https://github.com/avdwebLibraries/avdweb_Switch
|
||||
|
||||
// Hardware connections
|
||||
#define START_BTN_PIN 4
|
||||
#define PAUSE_BTN_PIN 3
|
||||
#define PIT_BTN_PIN 2
|
||||
#define RESET_BTN_PIN 1
|
||||
#define START_BTN_PIN 1
|
||||
#define PAUSE_BTN_PIN 2
|
||||
#define PIT_BTN_PIN 3
|
||||
#define RESET_BTN_PIN 4
|
||||
#define REDTEAM_BTN_PIN 5
|
||||
#define BLUETEAM_BTN_PIN 6
|
||||
#define REDTEAM_LED_PIN 39
|
||||
#define BLUETEAM_LED_PIN 40
|
||||
|
||||
// define buttons and switches
|
||||
Switch buttonSTART = Switch(START_BTN_PIN);
|
||||
Switch buttonSTART = Switch(START_BTN_PIN, INPUT_PULLUP, LOW, 50, 1000);
|
||||
Switch buttonPAUSE = Switch(PAUSE_BTN_PIN);
|
||||
Switch buttonPIT = Switch(PIT_BTN_PIN);
|
||||
Switch buttonRESET = Switch(RESET_BTN_PIN);
|
||||
Switch buttonPIT = Switch(PIT_BTN_PIN, INPUT_PULLUP, LOW, 50, 1000);
|
||||
Switch buttonRESET = Switch(RESET_BTN_PIN, INPUT_PULLUP, LOW, 50, 1000);
|
||||
Switch buttonREDTEAM = Switch(REDTEAM_BTN_PIN, INPUT_PULLUP, LOW, 50, 1000);
|
||||
Switch buttonBLUETEAM = Switch(BLUETEAM_BTN_PIN, INPUT_PULLUP, LOW, 50, 1000);
|
||||
|
||||
bool buttonSTARTvar = false;
|
||||
bool buttonPAUSEvar = false;
|
||||
@@ -31,25 +37,30 @@ uint8_t broadcastAddress[] = {0x84, 0xFC, 0xE6, 0xC7, 0x1A, 0x8C};
|
||||
|
||||
// Structure example to send data
|
||||
// Must match the receiver structure
|
||||
typedef struct struct_message {
|
||||
bool buttonSTARTremote;
|
||||
bool buttonPAUSEremote;
|
||||
bool buttonPITremote;
|
||||
bool buttonRESETremote;
|
||||
} struct_message;
|
||||
typedef struct struct_message_send {
|
||||
int boardID;
|
||||
bool buttonSTART;
|
||||
bool buttonSTARTforced;
|
||||
bool buttonPAUSE;
|
||||
bool buttonPIT;
|
||||
bool buttonPIThold;
|
||||
bool buttonRESET;
|
||||
bool buttonREDTEAM;
|
||||
bool buttonREDTEAMtapout;
|
||||
bool buttonBLUETEAM;
|
||||
bool buttonBLUETEAMtapout;
|
||||
} struct_message_send;
|
||||
|
||||
// Create a struct_message called myData
|
||||
struct_message remoteDATA;
|
||||
struct_message_send sendDATA;
|
||||
|
||||
esp_now_peer_info_t peerInfo;
|
||||
|
||||
// callback when data is sent
|
||||
/*
|
||||
void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {
|
||||
Serial.print("\r\nLast Packet Send Status:\t");
|
||||
Serial.println(status == ESP_NOW_SEND_SUCCESS ? "Delivery Success" : "Delivery Fail");
|
||||
}
|
||||
*/
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
Reference in New Issue
Block a user