Major changes to enable much more wifi information
This commit is contained in:
parent
8e67b46173
commit
577a0e2d36
19 changed files with 1337 additions and 726 deletions
|
@ -2,6 +2,7 @@
|
|||
#include <gpio.h>
|
||||
#include <ccconfig.h>
|
||||
#include <eagle_soc.h>
|
||||
#include "mystuff.h"
|
||||
#include <DFT32.h>
|
||||
#include <embeddednf.h>
|
||||
#include <embeddedout.h>
|
||||
|
@ -10,6 +11,8 @@ extern volatile uint8_t sounddata[];
|
|||
extern volatile uint16_t soundhead;
|
||||
|
||||
|
||||
#define CONFIGURABLES 16 //(plus1)
|
||||
|
||||
extern uint8_t RootNoteOffset; //Set to define what the root note is. 0 = A.
|
||||
uint8_t gDFTIIR = 6;
|
||||
uint8_t gFUZZ_IIR_BITS = 1;
|
||||
|
@ -24,17 +27,37 @@ uint8_t gMINIMUM_AMP_FOR_NOTE_TO_DISAPPEAR = 64;
|
|||
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;
|
||||
|
||||
struct SaveLoad
|
||||
{
|
||||
uint8_t configs[CONFIGURABLES];
|
||||
} settings;
|
||||
|
||||
uint8_t * gConfigurables[] = { &RootNoteOffset, &gDFTIIR, &gFUZZ_IIR_BITS, &gFILTER_BLUR_PASSES,
|
||||
uint8_t gConfigDefaults[CONFIGURABLES] = { 0, 6, 1, 2, 3, 4, 7, 4, 2, 80, 64, 12, 15, NUM_LIN_LEDS, 1, 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, 0 };
|
||||
&gNERF_NOTE_PORP, &gUSE_NUM_LIN_LEDS, &gCOLORCHORD_ACTIVE, 0 };
|
||||
|
||||
char * gConfigurableNames[] = { "gROOT_NOTE_OFFSET", "gDFTIIR", "gFUZZ_IIR_BITS", "gFILTER_BLUR_PASSES",
|
||||
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", 0 };
|
||||
"gNERF_NOTE_PORP", "gUSE_NUM_LIN_LEDS", "gCOLORCHORD_ACTIVE", 0 };
|
||||
|
||||
void ICACHE_FLASH_ATTR CustomStart( )
|
||||
{
|
||||
int i;
|
||||
spi_flash_read( 0x3D000, (uint32*)&settings, sizeof( settings ) );
|
||||
for( i = 0; i < CONFIGURABLES; i++ )
|
||||
{
|
||||
if( gConfigurables[i] )
|
||||
{
|
||||
*gConfigurables[i] = settings.configs[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ICACHE_FLASH_ATTR CustomCommand(char * buffer, int retsize, char *pusrdata, unsigned short len)
|
||||
{
|
||||
|
@ -50,6 +73,7 @@ int ICACHE_FLASH_ATTR CustomCommand(char * buffer, int retsize, char *pusrdata,
|
|||
int whichSel = my_atoi( &pusrdata[2] );
|
||||
|
||||
uint16_t * which = 0;
|
||||
uint16_t qty = FIXBINS;
|
||||
switch( whichSel )
|
||||
{
|
||||
case 0:
|
||||
|
@ -57,13 +81,14 @@ int ICACHE_FLASH_ATTR CustomCommand(char * buffer, int retsize, char *pusrdata,
|
|||
case 1:
|
||||
which = fuzzed_bins; break;
|
||||
case 2:
|
||||
qty = FIXBPERO;
|
||||
which = folded_bins; break;
|
||||
default:
|
||||
buffend += ets_sprintf( buffend, "!CB" );
|
||||
return buffend-buffer;
|
||||
}
|
||||
|
||||
buffend += ets_sprintf( buffend, "CB%d:%d:", whichSel, FIXBINS );
|
||||
buffend += ets_sprintf( buffend, "CB%d:%d:", whichSel, qty );
|
||||
for( i = 0; i < FIXBINS; i++ )
|
||||
{
|
||||
uint16_t samp = which[i];
|
||||
|
@ -76,6 +101,22 @@ int ICACHE_FLASH_ATTR CustomCommand(char * buffer, int retsize, char *pusrdata,
|
|||
}
|
||||
|
||||
|
||||
case 'l': case 'L': //LEDs
|
||||
{
|
||||
int i, it = 0;
|
||||
buffend += ets_sprintf( buffend, "CL:%d:", gUSE_NUM_LIN_LEDS );
|
||||
uint16_t toledsvals = gUSE_NUM_LIN_LEDS*3;
|
||||
if( toledsvals > 600 ) toledsvals = 600;
|
||||
for( i = 0; i < toledsvals; i++ )
|
||||
{
|
||||
uint8_t samp = ledOut[it++];
|
||||
*(buffend++) = tohex1( samp>>4 );
|
||||
*(buffend++) = tohex1( samp&0x0f );
|
||||
}
|
||||
return buffend-buffer;
|
||||
}
|
||||
|
||||
|
||||
case 'm': case 'M': //Oscilloscope
|
||||
{
|
||||
int i, it = soundhead;
|
||||
|
@ -118,6 +159,61 @@ int ICACHE_FLASH_ATTR CustomCommand(char * buffer, int retsize, char *pusrdata,
|
|||
}
|
||||
|
||||
|
||||
case 's': case 'S':
|
||||
{
|
||||
switch (pusrdata[2] )
|
||||
{
|
||||
|
||||
case 'd': case 'D':
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < CONFIGURABLES-1; i++ )
|
||||
{
|
||||
if( gConfigurables[i] )
|
||||
*gConfigurables[i] = gConfigDefaults[i];
|
||||
}
|
||||
buffend += ets_sprintf( buffend, "CD" );
|
||||
return buffend-buffer;
|
||||
}
|
||||
|
||||
case 'r': case 'R':
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < CONFIGURABLES-1; i++ )
|
||||
{
|
||||
if( gConfigurables[i] )
|
||||
*gConfigurables[i] = settings.configs[i];
|
||||
}
|
||||
buffend += ets_sprintf( buffend, "CSR" );
|
||||
return buffend-buffer;
|
||||
}
|
||||
|
||||
case 's': case 'S':
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < CONFIGURABLES-1; i++ )
|
||||
{
|
||||
if( gConfigurables[i] )
|
||||
settings.configs[i] = *gConfigurables[i];
|
||||
}
|
||||
|
||||
EnterCritical();
|
||||
ets_intr_lock();
|
||||
spi_flash_erase_sector( 0x3D000/4096 );
|
||||
spi_flash_write( 0x3D000, (uint32*)&settings, ((sizeof( settings )-1)&(~0xf))+0x10 );
|
||||
ets_intr_unlock();
|
||||
ExitCritical();
|
||||
|
||||
buffend += ets_sprintf( buffend, "CS" );
|
||||
return buffend-buffer;
|
||||
}
|
||||
}
|
||||
buffend += ets_sprintf( buffend, "!CS" );
|
||||
return buffend-buffer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
case 'v': case 'V': //ColorChord Values
|
||||
{
|
||||
|
@ -125,10 +221,7 @@ int ICACHE_FLASH_ATTR CustomCommand(char * buffer, int retsize, char *pusrdata,
|
|||
{
|
||||
int i;
|
||||
|
||||
buffend += ets_sprintf( buffend, "CVR:rBASE_FREQ=%d:rDFREQ=%d:rOCTAVES=%d:rFIXBPERO=%d:NOTERANGE=%d:",
|
||||
(int)BASE_FREQ, (int)DFREQ, (int)OCTAVES, (int)FIXBPERO, (int)(NOTERANGE) );
|
||||
buffend += ets_sprintf( buffend, "CVR:rMAXNOTES=%d:rNUM_LIN_LEDS=%d:rLIN_WRAPAROUND=%d:rLIN_WRAPAROUND=%d:",
|
||||
(int)MAXNOTES, (int)NUM_LIN_LEDS, (int)LIN_WRAPAROUND, (int)LIN_WRAPAROUND );
|
||||
buffend += ets_sprintf( buffend, "CVR:" );
|
||||
|
||||
i = 0;
|
||||
while( gConfigurableNames[i] )
|
||||
|
@ -137,6 +230,11 @@ int ICACHE_FLASH_ATTR CustomCommand(char * buffer, int retsize, char *pusrdata,
|
|||
i++;
|
||||
}
|
||||
|
||||
buffend += ets_sprintf( buffend, "rBASE_FREQ=%d:rDFREQ=%d:rOCTAVES=%d:rFIXBPERO=%d:rNOTERANGE=%d:rSORT_NOTES=%d:",
|
||||
(int)BASE_FREQ, (int)DFREQ, (int)OCTAVES, (int)FIXBPERO, (int)(NOTERANGE),(int)SORT_NOTES );
|
||||
buffend += ets_sprintf( buffend, "rMAXNOTES=%d:rNUM_LIN_LEDS=%d:rLIN_WRAPAROUND=%d:rLIN_WRAPAROUND=%d:",
|
||||
(int)MAXNOTES, (int)NUM_LIN_LEDS, (int)LIN_WRAPAROUND, (int)LIN_WRAPAROUND );
|
||||
|
||||
return buffend-buffer;
|
||||
}
|
||||
else if( pusrdata[2] == 'W' || pusrdata[2] == 'w' )
|
||||
|
|
|
@ -31,10 +31,16 @@
|
|||
static volatile os_timer_t some_timer;
|
||||
static struct espconn *pUdpServer;
|
||||
|
||||
void EnterCritical();
|
||||
void ExitCritical();
|
||||
|
||||
extern volatile uint8_t sounddata[HPABUFFSIZE];
|
||||
extern volatile uint16_t soundhead;
|
||||
uint16_t soundtail;
|
||||
extern uint8_t gCOLORCHORD_ACTIVE;
|
||||
static uint8_t hpa_running = 0;
|
||||
|
||||
void ICACHE_FLASH_ATTR CustomStart( );
|
||||
|
||||
void user_rf_pre_init()
|
||||
{
|
||||
|
@ -43,6 +49,8 @@ void user_rf_pre_init()
|
|||
//Call this once we've stacked together one full colorchord frame.
|
||||
static void NewFrame()
|
||||
{
|
||||
if( !gCOLORCHORD_ACTIVE ) return;
|
||||
|
||||
//uint8_t led_outs[NUM_LIN_LEDS*3];
|
||||
int i;
|
||||
HandleFrameInfo();
|
||||
|
@ -63,6 +71,18 @@ static void procTask(os_event_t *events)
|
|||
{
|
||||
system_os_post(procTaskPrio, 0, 0 );
|
||||
|
||||
if( gCOLORCHORD_ACTIVE && !hpa_running )
|
||||
{
|
||||
ExitCritical();
|
||||
hpa_running = 1;
|
||||
}
|
||||
|
||||
if( !gCOLORCHORD_ACTIVE && hpa_running )
|
||||
{
|
||||
EnterCritical();
|
||||
hpa_running = 0;
|
||||
}
|
||||
|
||||
CSTick( 0 );
|
||||
|
||||
//For profiling so we can see how much CPU is spent in this loop.
|
||||
|
@ -97,7 +117,7 @@ static void procTask(os_event_t *events)
|
|||
|
||||
int stat = wifi_station_get_connect_status();
|
||||
|
||||
// printf( "STAT: %d\n", stat );
|
||||
//printf( "STAT: %d %d\n", stat, wifi_get_opmode() );
|
||||
|
||||
if( stat == STATION_WRONG_PASSWORD || stat == STATION_NO_AP_FOUND || stat == STATION_CONNECT_FAIL )
|
||||
{
|
||||
|
@ -142,7 +162,7 @@ static void udpserver_recv(void *arg, char *pusrdata, unsigned short len)
|
|||
|
||||
// uint8_t ledout[] = { 0x00, 0xff, 0xaa, 0x00, 0xff, 0xaa, };
|
||||
uart0_sendStr("X");
|
||||
ws2812_push( pusrdata, len );
|
||||
ws2812_push( pusrdata+3, len );
|
||||
}
|
||||
|
||||
void ICACHE_FLASH_ATTR charrx( uint8_t c )
|
||||
|
@ -158,11 +178,37 @@ void ICACHE_FLASH_ATTR user_init(void)
|
|||
|
||||
uart0_sendStr("\r\nCustom Server\r\n");
|
||||
|
||||
// system_restore();
|
||||
CustomStart();
|
||||
|
||||
#ifdef PROFILE
|
||||
GPIO_OUTPUT_SET(GPIO_ID_PIN(0), 0);
|
||||
#endif
|
||||
int opmode = wifi_get_opmode();
|
||||
printf( "Opmode: %d\n", opmode );
|
||||
if( opmode == 1 )
|
||||
{
|
||||
struct station_config sc;
|
||||
wifi_station_get_config(&sc);
|
||||
printf( "Station mode: \"%s\":\"%s\" (bssid_set:%d)\n", sc.ssid, sc.password, sc.bssid_set );
|
||||
if( sc.ssid[0] == 0 && !sc.bssid_set )
|
||||
{
|
||||
wifi_set_opmode( 2 );
|
||||
opmode = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
wifi_station_connect();
|
||||
}
|
||||
}
|
||||
if( opmode == 2 )
|
||||
{
|
||||
struct softap_config sc;
|
||||
wifi_softap_get_config(&sc);
|
||||
printf( "SoftAP mode: \"%s\":\"%s\"\n", sc.ssid, sc.password );
|
||||
}
|
||||
|
||||
wifi_set_opmode( 2 ); //We broadcast our ESSID, wait for peopel to join.
|
||||
// wifi_set_opmode( 2 ); //We broadcast our ESSID, wait for peopel to join.
|
||||
|
||||
/*
|
||||
struct station_config stationConf;
|
||||
|
@ -202,6 +248,7 @@ void ICACHE_FLASH_ATTR user_init(void)
|
|||
InitColorChord(); //Init colorchord
|
||||
|
||||
StartHPATimer(); //Init the high speed ADC timer.
|
||||
hpa_running = 1;
|
||||
|
||||
ws2812_init();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue