Update with make-all-the-leds-the-same solo option.

This commit is contained in:
cnlohr 2015-08-08 23:02:39 -04:00
parent 68e7bd6bb6
commit ee756a820d
6 changed files with 61 additions and 5 deletions

Binary file not shown.

View file

@ -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( )
{

View file

@ -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 );

View file

@ -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;

View file

@ -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!!!

View file

@ -37,7 +37,9 @@ void NewFrame()
// uint8_t led_outs[NUM_LIN_LEDS*3];
int i;
HandleFrameInfo();
UpdateLinearLEDs();
// UpdateAllSameLEDs();
SendSPI2812( ledOut, NUM_LIN_LEDS );
}