updated Arena Controller to support two clocks at the same time
This commit is contained in:
@@ -84,7 +84,8 @@ bool resumeFight = false;
|
||||
//------------------------------------------------------------------------------------
|
||||
// ESP-NOW config
|
||||
// send config, Clock:
|
||||
uint8_t broadcastAddressClock[] = {0x48, 0x27, 0xE2, 0x5D, 0xB6, 0x84};
|
||||
uint8_t broadcastAddressClock1[] = {0x48, 0x27, 0xE2, 0x5D, 0xB6, 0x84};
|
||||
uint8_t broadcastAddressClock2[] = {0x48, 0x27, 0xE2, 0x5D, 0xB6, 0x84};
|
||||
// struct for clock data
|
||||
typedef struct struct_message_Clock {
|
||||
int sendMinutes;
|
||||
@@ -203,8 +204,10 @@ 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));
|
||||
// actually send it to first clock
|
||||
esp_err_t result1 = esp_now_send(broadcastAddressClock1, (uint8_t *) &sendClockDATA, sizeof(sendClockDATA));
|
||||
// actually send it to second clock
|
||||
esp_err_t result2 = esp_now_send(broadcastAddressClock2, (uint8_t *) &sendClockDATA, sizeof(sendClockDATA));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,17 +264,27 @@ void setup() {
|
||||
// get the status of Transmitted packet
|
||||
esp_now_register_send_cb(OnDataSent);
|
||||
|
||||
// Register clock peer
|
||||
memcpy(peerInfo.peer_addr, broadcastAddressClock, 6);
|
||||
// Register first clock peer
|
||||
memcpy(peerInfo.peer_addr, broadcastAddressClock1, 6);
|
||||
peerInfo.channel = 0;
|
||||
peerInfo.encrypt = false;
|
||||
// Add peer
|
||||
if (esp_now_add_peer(&peerInfo) != ESP_OK){
|
||||
Serial.println("Failed to add peer");
|
||||
Serial.println("Failed to add Clock1 peer");
|
||||
return;
|
||||
}
|
||||
|
||||
esp_err_t result = esp_now_send(broadcastAddressClock, (uint8_t *) &sendClockDATA, sizeof(sendClockDATA));
|
||||
// 2) Register second clock peer
|
||||
memcpy(peerInfo.peer_addr, broadcastAddressClock2, 6);
|
||||
// peerInfo.channel & peerInfo.encrypt already set above
|
||||
if (esp_now_add_peer(&peerInfo) != ESP_OK) {
|
||||
Serial.println("Failed to add Clock2 peer");
|
||||
return;
|
||||
}
|
||||
|
||||
// send initial data (I think that doesn't work but meh...)
|
||||
esp_err_t result1 = esp_now_send(broadcastAddressClock1, (uint8_t *) &sendClockDATA, sizeof(sendClockDATA));
|
||||
esp_err_t result2 = esp_now_send(broadcastAddressClock2, (uint8_t *) &sendClockDATA, sizeof(sendClockDATA));
|
||||
|
||||
// Register Red Team Button peer
|
||||
memcpy(peerInfo.peer_addr, broadcastAddressREDTEAMbutton, 6);
|
||||
|
||||
Reference in New Issue
Block a user