added tap out to the display firmware, added a test firmware for sending to the display via ESP-NOW

This commit is contained in:
2025-02-23 01:57:53 +01:00
parent fe9173ca88
commit 9e708d461a
4 changed files with 134 additions and 51 deletions

View File

@@ -0,0 +1,106 @@
// ROFLS+ Arena Controller
#include <WiFi.h>
#include <esp_now.h> // automatically installed for ESP32 boards, I think?
#include <Preferences.h> // automatically installed for ESP32 boards
#include <CountDown.h> // https://github.com/RobTillaart/CountDown
#include <StopWatch.h> // https://github.com/RobTillaart/StopWatch_RT
const int countdownTIME = 3; // countdown timer length in minutes
const int countdownToFight = 3; // countdown timer length in seconds
const int PITreleaseTime = 90; // automatic pit release time in seconds until end of countdown
bool countdownPAUSED = false;
CountDown FightCountDown[1];
// Rumble stopwatch
StopWatch rumbleTIME;
int CLOCK_LED_BRIGHTNESS = 16; // 64 is okay
// REPLACE WITH YOUR RECEIVER MAC Address
uint8_t broadcastAddress[] = {0x48, 0x27, 0xE2, 0x5D, 0xB6, 0x84};
// ESP-NOW config
// Structure example to send data
// Must match the receiver structure
typedef struct struct_message {
int sendMinutes;
int sendSeconds;
int sendREDchannel;
int sendGREENchannel;
int sendBLUEchannel;
int sendBrightness;
} struct_message;
// Create a struct_message called remoteDATA
struct_message 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);
// Set device as a Wi-Fi Station
WiFi.mode(WIFI_STA);
// Init ESP-NOW
if (esp_now_init() != ESP_OK) {
Serial.println("Error initializing ESP-NOW");
return;
}
// Once ESPNow is successfully Init, we will register for Send CB to
// get the status of Trasnmitted packet
esp_now_register_send_cb(OnDataSent);
// Register peer
memcpy(peerInfo.peer_addr, broadcastAddress, 6);
peerInfo.channel = 0;
peerInfo.encrypt = false;
// Add peer
if (esp_now_add_peer(&peerInfo) != ESP_OK){
Serial.println("Failed to add peer");
return;
}
// set rumble stopwatch resolution to seconds
esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *) &sendDATA, sizeof(sendDATA));
sendDATA.sendMinutes = 88;
sendDATA.sendSeconds = 88;
sendDATA.sendREDchannel = 63;
sendDATA.sendGREENchannel = 0;
sendDATA.sendBLUEchannel = 0;
sendDATA.sendBrightness = 32;
}
void loop() {
esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *) &sendDATA, sizeof(sendDATA));
sendDATA.sendMinutes = 88;
sendDATA.sendSeconds = 88;
sendDATA.sendREDchannel = 63;
sendDATA.sendGREENchannel = 0;
sendDATA.sendBLUEchannel = 0;
sendDATA.sendBrightness = 32;
delay(2000);
// if (result == ESP_OK) {
// Serial.println("Sent with success");
// }
// else {
// Serial.println("Error sending the data");
// }
//showTimeDisplay((FightCountDown[0].remaining()/60%10), (FightCountDown[0].remaining()%60), 0, XDAS, 0);
}