added preliminary implementation of Team Button LEDs

This commit is contained in:
2025-04-08 09:30:22 +02:00
parent b82e4eb58b
commit 70d4b3886d
2 changed files with 56 additions and 8 deletions

View File

@@ -96,9 +96,18 @@ typedef struct struct_message_Clock {
struct_message_Clock sendClockDATA;
// send config, pilot buttons:
uint8_t broadcastAddressREDTEAMbutton[] = {0x84, 0xFC, 0xE6, 0xC7, 0x27, 0x14};
uint8_t broadcastAddressREDTEAMbutton[] = {0x84, 0xFC, 0xE6, 0xC7, 0x23, 0x14};
uint8_t broadcastAddressBLUETEAMbutton[] = {0x84, 0xFC, 0xE6, 0xC7, 0x1A, 0x02};
// Structure for sending data
typedef struct struct_message_send {
bool TEAMLED; // LED state
} struct_message_send;
// Create struct_message instances for sending to both receivers
struct_message_send sendToREDTEAMbutton;
struct_message_send sendToBLUETEAMbutton;
esp_now_peer_info_t peerInfo;
// callback when data is sent
@@ -206,7 +215,7 @@ void setup() {
// get the status of Transmitted packet
esp_now_register_send_cb(OnDataSent);
// Register peer
// Register clock peer
memcpy(peerInfo.peer_addr, broadcastAddressClock, 6);
peerInfo.channel = 0;
peerInfo.encrypt = false;
@@ -216,19 +225,38 @@ void setup() {
return;
}
// set rumble stopwatch resolution to seconds
esp_err_t result = esp_now_send(broadcastAddressClock, (uint8_t *) &sendClockDATA, sizeof(sendClockDATA));
// Register Red Team Button peer
memcpy(peerInfo.peer_addr, broadcastAddressREDTEAMbutton, 6);
peerInfo.channel = 0;
peerInfo.encrypt = false;
if (esp_now_add_peer(&peerInfo) != ESP_OK) {
Serial.println("Failed to add receiver 1");
return;
}
// Register Blue Team Button peer
memcpy(peerInfo.peer_addr, broadcastAddressBLUETEAMbutton, 6);
peerInfo.channel = 0;
peerInfo.encrypt = false;
if (esp_now_add_peer(&peerInfo) != ESP_OK) {
Serial.println("Failed to add receiver 2");
return;
}
// Initialize both Team button LED states
sendToREDTEAMbutton.TEAMLED = false;
sendToBLUETEAMbutton.TEAMLED = false;
// reset remote button LEDs
esp_now_send(broadcastAddressREDTEAMbutton, (uint8_t *)&sendToREDTEAMbutton, sizeof(sendToREDTEAMbutton));
esp_now_send(broadcastAddressBLUETEAMbutton, (uint8_t *)&sendToBLUETEAMbutton, sizeof(sendToBLUETEAMbutton));
//------------------------------------------------------------------------------------
// ESP Now receive part:
// Once ESPNow is successfully Init, we will register for recv CB to
// get recv packer info
esp_now_register_recv_cb(esp_now_recv_cb_t(OnDataRecv));
// set rumble stopwatch resolution to seconds
}
int XDAS = 255;