app: add Art-Net receiver

This commit is contained in:
King Kévin 2022-07-14 19:00:46 +02:00
parent af9d0d685a
commit 32aa557a00
1 changed files with 16 additions and 0 deletions

View File

@ -35,6 +35,7 @@
#include "terminal.h" // handle the terminal interface
#include "menu.h" // menu utilities
#include "font.h" // to draw text
#include "radio_esp8266.h" // to receive ARTnet
#include "led_ws2812b.h" // control WS2812b LEDs
/** watchdog period in ms */
@ -1065,6 +1066,12 @@ void main(void)
*/
puts_debug("OK\n");
puts_debug("setup ESP8266 Art-Net: ");
sleep_ms(1000); // wit for ESP to boot
radio_esp8266_setup(); // connect to WiFi network
radio_esp8266_listen(true, 6454); // open UDP Art-Net
puts_debug("OK");
// setup terminal
terminal_prefix = ""; // set default prefix
terminal_process = &process_command; // set central function to process commands
@ -1126,6 +1133,15 @@ void main(void)
puts("midnight reached\n");
}
}
if (radio_esp8266_received_len) {
if (radio_esp8266_received_len >= 18 && 0 == memcmp((char*)radio_esp8266_received, "Art-Net", 7)) {
const uint16_t dmx_universe = radio_esp8266_received[14] + (radio_esp8266_received[15] << 8);
const uint16_t dmx_length = radio_esp8266_received[17] + (radio_esp8266_received[16] << 8);
printf("Art-Net packet (uni=%u, len=%u)\n", dmx_universe, dmx_length);
}
radio_esp8266_received_len = 0; // reset flag
action = true; // redo main loop
}
if (action) { // go to sleep if nothing had to be done, else recheck for activity
action = false;
} else {