#include "NDP.h" #include // UART TX-Pin auf LP101EXT/P0.20 #define NICLA_TX Serial1 void sendit(char* label) { // LED blau bei Match nicla::leds.begin(); nicla::leds.setColor(blue); delay(200); nicla::leds.setColor(off); nicla::leds.end(); // Senden der Bytes an ESP32 if (strcmp(label, "NN0:Helmet") == 0) { NICLA_TX.write(0x01); } else if (strcmp(label, "NN0:Iron Man") == 0) { NICLA_TX.write(0x02); } else if (strcmp(label, "NN0:Shutdown") == 0) { NICLA_TX.write(0x03); } else if (strcmp(label, "NN0:Startup") == 0) { NICLA_TX.write(0x04); } else if (strcmp(label, "NN0:Repulsor") == 0) { NICLA_TX.write(0x05); } else if (strcmp(label, "NN0:Stones") == 0) { NICLA_TX.write(0x06); } else if (strcmp(label, "NN0:Combat") == 0) { NICLA_TX.write(0x07); } } /** * LED grün blinkt bei Event */ void ledGreenOn() { nicla::leds.begin(); nicla::leds.setColor(green); delay(200); nicla::leds.setColor(off); nicla::leds.end(); } /** * Infinite blinking red LED bei Fehler */ void ledRedBlink() { while (1) { nicla::leds.begin(); nicla::leds.setColor(red); delay(200); nicla::leds.setColor(off); delay(200); nicla::leds.end(); } } void setup() { NICLA_TX.begin(115200); // TX = LP101EXT/P0.20 Serial.begin(115200); Serial.println("Nicla Voice ready"); Serial.println("Loading synpackages..."); // Nicla System setup nicla::begin(); nicla::disableLDO(); nicla::leds.begin(); // NDP callbacks NDP.onError(ledRedBlink); NDP.onMatch(sendit); NDP.onEvent(ledGreenOn); // NDP Firmware + Modelle NDP.begin("mcu_fw_120_v91.synpkg"); NDP.load("dsp_firmware_v91.synpkg"); NDP.load("ei_model.synpkg"); Serial.println("Packages loaded. Turning on mic..."); NDP.turnOnMicrophone(); nicla::leds.end(); NDP.interrupts(); } void loop() { // Alles läuft über Callback }