diff --git a/embedded8266/image.elf b/embedded8266/image.elf index 76d2887..d72df94 100755 Binary files a/embedded8266/image.elf and b/embedded8266/image.elf differ diff --git a/embedded8266/user/custom_commands.c b/embedded8266/user/custom_commands.c index b49913f..dc0e74b 100644 --- a/embedded8266/user/custom_commands.c +++ b/embedded8266/user/custom_commands.c @@ -11,7 +11,7 @@ extern volatile uint8_t sounddata[]; extern volatile uint16_t soundhead; -#define CONFIGURABLES 16 //(plus1) +#define CONFIGURABLES 17 //(plus1) extern uint8_t RootNoteOffset; //Set to define what the root note is. 0 = A. uint8_t gDFTIIR = 6; @@ -28,23 +28,24 @@ uint8_t gNOTE_FINAL_AMP = 12; uint8_t gNERF_NOTE_PORP = 15; uint8_t gUSE_NUM_LIN_LEDS = NUM_LIN_LEDS; uint8_t gCOLORCHORD_ACTIVE = 1; +uint8_t gCOLORCHORD_OUTPUT_DRIVER = 0; struct SaveLoad { uint8_t configs[CONFIGURABLES]; } settings; -uint8_t gConfigDefaults[CONFIGURABLES] = { 0, 6, 1, 2, 3, 4, 7, 4, 2, 80, 64, 12, 15, NUM_LIN_LEDS, 1, 0 }; +uint8_t gConfigDefaults[CONFIGURABLES] = { 0, 6, 1, 2, 3, 4, 7, 4, 2, 80, 64, 12, 15, NUM_LIN_LEDS, 1, 0, 0 }; uint8_t * gConfigurables[CONFIGURABLES] = { &RootNoteOffset, &gDFTIIR, &gFUZZ_IIR_BITS, &gFILTER_BLUR_PASSES, &gSEMIBITSPERBIN, &gMAX_JUMP_DISTANCE, &gMAX_COMBINE_DISTANCE, &gAMP_1_IIR_BITS, &gAMP_2_IIR_BITS, &gMIN_AMP_FOR_NOTE, &gMINIMUM_AMP_FOR_NOTE_TO_DISAPPEAR, &gNOTE_FINAL_AMP, - &gNERF_NOTE_PORP, &gUSE_NUM_LIN_LEDS, &gCOLORCHORD_ACTIVE, 0 }; + &gNERF_NOTE_PORP, &gUSE_NUM_LIN_LEDS, &gCOLORCHORD_ACTIVE, &gCOLORCHORD_OUTPUT_DRIVER, 0 }; char * gConfigurableNames[CONFIGURABLES] = { "gROOT_NOTE_OFFSET", "gDFTIIR", "gFUZZ_IIR_BITS", "gFILTER_BLUR_PASSES", "gSEMIBITSPERBIN", "gMAX_JUMP_DISTANCE", "gMAX_COMBINE_DISTANCE", "gAMP_1_IIR_BITS", "gAMP_2_IIR_BITS", "gMIN_AMP_FOR_NOTE", "gMINIMUM_AMP_FOR_NOTE_TO_DISAPPEAR", "gNOTE_FINAL_AMP", - "gNERF_NOTE_PORP", "gUSE_NUM_LIN_LEDS", "gCOLORCHORD_ACTIVE", 0 }; + "gNERF_NOTE_PORP", "gUSE_NUM_LIN_LEDS", "gCOLORCHORD_ACTIVE", "gCOLORCHORD_OUTPUT_DRIVER", 0 }; void ICACHE_FLASH_ATTR CustomStart( ) { diff --git a/embedded8266/user/user_main.c b/embedded8266/user/user_main.c index 1d4b705..0538364 100644 --- a/embedded8266/user/user_main.c +++ b/embedded8266/user/user_main.c @@ -46,6 +46,8 @@ void user_rf_pre_init() { } +extern uint8_t gCOLORCHORD_OUTPUT_DRIVER; + //Call this once we've stacked together one full colorchord frame. static void NewFrame() { @@ -54,7 +56,16 @@ static void NewFrame() //uint8_t led_outs[NUM_LIN_LEDS*3]; int i; HandleFrameInfo(); - UpdateLinearLEDs(); + + switch( gCOLORCHORD_OUTPUT_DRIVER ) + { + case 0: + UpdateLinearLEDs(); + break; + case 1: + UpdateAllSameLEDs(); + break; + }; //SendSPI2812( ledOut, NUM_LIN_LEDS ); ws2812_push( ledOut, USE_NUM_LIN_LEDS * 3 ); diff --git a/embeddedcommon/embeddedout.c b/embeddedcommon/embeddedout.c index ddb046f..12a3cf1 100644 --- a/embeddedcommon/embeddedout.c +++ b/embeddedcommon/embeddedout.c @@ -235,6 +235,43 @@ void UpdateLinearLEDs() } + + +void UpdateAllSameLEDs() +{ + int i; + uint8_t freq = 0; + uint16_t amp = 0; + + for( i = 0; i < MAXNOTES; i++ ) + { + uint16_t ist = note_peak_amps2[i]; + uint8_t ifrq = note_peak_freqs[i]; + if( ist > amp && ifrq != 255 ) + { + freq = ifrq; + amp = ist; + } + } + + amp = (((uint32_t)(amp))*NOTE_FINAL_AMP)>>10; + + if( amp > 255 ) amp = 255; + uint32_t color = ECCtoHEX( (freq+RootNoteOffset)%NOTERANGE, 255, amp ); + + for( i = 0; i < USE_NUM_LIN_LEDS; i++ ) + { + ledOut[i*3+0] = ( color >> 0 ) & 0xff; + ledOut[i*3+1] = ( color >> 8 ) & 0xff; + ledOut[i*3+2] = ( color >>16 ) & 0xff; + } +} + + + + + + uint32_t ECCtoHEX( uint8_t note, uint8_t sat, uint8_t val ) { uint16_t hue = 0; diff --git a/embeddedcommon/embeddedout.h b/embeddedcommon/embeddedout.h index 1328128..146f010 100644 --- a/embeddedcommon/embeddedout.h +++ b/embeddedcommon/embeddedout.h @@ -38,8 +38,13 @@ extern uint8_t ledArray[]; extern uint8_t ledOut[]; //[NUM_LIN_LEDS*3] extern uint8_t RootNoteOffset; //Set to define what the root note is. 0 = A. + +//For doing the nice linear strip LED updates void UpdateLinearLEDs(); +//For making all the LEDs the same and quickest. Good for solo instruments? +void UpdateAllSameLEDs(); + uint32_t ECCtoHEX( uint8_t note, uint8_t sat, uint8_t val ); uint32_t EHSVtoHEX( uint8_t hue, uint8_t sat, uint8_t val ); //hue = 0..255 // TODO: TEST ME!!! diff --git a/embeddedstm32f407/main.c b/embeddedstm32f407/main.c index 1572c26..6234871 100644 --- a/embeddedstm32f407/main.c +++ b/embeddedstm32f407/main.c @@ -37,7 +37,9 @@ void NewFrame() // uint8_t led_outs[NUM_LIN_LEDS*3]; int i; HandleFrameInfo(); + UpdateLinearLEDs(); +// UpdateAllSameLEDs(); SendSPI2812( ledOut, NUM_LIN_LEDS ); }