From ea50ead19a82fbcc057a9d081c2c2351f9db9191 Mon Sep 17 00:00:00 2001 From: Alex Wulff Date: Tue, 19 Jul 2022 09:24:06 -0400 Subject: [PATCH] working pipeline and model --- pico-light-voice/source/lights.cpp | 26 +++++++++++++------ pico-light-voice/source/main.cpp | 41 +++++++++++++----------------- 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/pico-light-voice/source/lights.cpp b/pico-light-voice/source/lights.cpp index 38426cb..f7d9d18 100644 --- a/pico-light-voice/source/lights.cpp +++ b/pico-light-voice/source/lights.cpp @@ -1,9 +1,11 @@ -#define PIN 7 - #include #include #include "Adafruit_NeoPixel.hpp" +#define PIN 7 +#define NUM_STATES 4 +#define NUM_LIGHTS 60 + bool update_state(uint32_t *state, bool strip_on) { // check for new state information if (multicore_fifo_rvalid()) { @@ -24,8 +26,8 @@ bool update_state(uint32_t *state, bool strip_on) { return true; } - // SET NUM STATES HERE - *state = (*state+1) % 3; + // check this!! + *state = (*state+1) % NUM_STATES; printf("Incrementing state to %u\n", *state); multicore_fifo_push_blocking(0); return true; @@ -37,11 +39,10 @@ bool update_state(uint32_t *state, bool strip_on) { } void core1_entry() { - Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, + Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LIGHTS, PIN, NEO_GRB + NEO_KHZ800); strip.begin(); - //strip.setBrightness(64); - strip.show(); + strip.setBrightness(64); // tell the other core we're ready for data multicore_fifo_push_blocking(0); @@ -105,6 +106,15 @@ void core1_entry() { strip.show(); sleep_ms(100); } + + // boring + else if (state == 2) { + for(int i=0; i< strip.numPixels(); i++) { + strip.setPixelColor(i, strip.Color(10,50,5)); + } + + strip.show(); + sleep_ms(100); + } } } - diff --git a/pico-light-voice/source/main.cpp b/pico-light-voice/source/main.cpp index 3d1a48f..c49a7c0 100644 --- a/pico-light-voice/source/main.cpp +++ b/pico-light-voice/source/main.cpp @@ -107,18 +107,21 @@ int main() if (EI_CLASSIFIER_HAS_ANOMALY == 1) printf("Anomaly!\n"); - const float thresh = 0.7; + const float thresh = 0.8; uint32_t state = 0; for (size_t ix = 0; ix < EI_CLASSIFIER_LABEL_COUNT; ix++) { - if (ix == 0 && result.classification[ix].value > thresh) { - //printf("EXTINGUISH\n"); - //state = 1; + if (ix == 2 && result.classification[ix].value > thresh) { + printf("START\n"); + // Set the state to 1 for the keyword you use to turn the lights + // on and change the lighting state + state = 1; } - if (ix == 1 && result.classification[ix].value > thresh) { - //printf("ILLUMINATE\n"); - //state = 2; + if (ix == 3 && result.classification[ix].value > thresh) { + printf("STOP\n"); + // Set the state to 2 for the keyword that turns off the lights + state = 2; } printf("%0.2f, ",result.classification[ix].value); @@ -126,6 +129,8 @@ int main() printf("\n"); + // If the lighting core wants a state update, and there's a state + // update to give, then we'll send it over. if (multicore_fifo_rvalid() && state != 0) { multicore_fifo_pop_blocking(); multicore_fifo_push_blocking(state); @@ -134,22 +139,8 @@ int main() gpio_put(LED_PIN, 0); dma_channel_wait_for_finish_blocking(dma_chan); - // copy everything to feature buffer to run model - // this is probably slow, idk - - // copy everything to feature buffer to run model - // this is probably slow, idk - /* - uint64_t sum = 0; - for (uint32_t i=0; i