From 36de380a33c18501b13037948674e88f08263f6c Mon Sep 17 00:00:00 2001 From: Charles Lohr Date: Tue, 23 Aug 2016 02:05:07 -0400 Subject: [PATCH] Update to latest esp8266 and leverage new functionality. Also, uses less IRAM so it fits with SDK 1.5.4 --- embedded8266/esp82xx | 2 +- embedded8266/user/custom_commands.c | 40 ++++++++++++----------------- embedded8266/user/user_main.c | 2 +- embedded8266/user/ws2812_i2s.c | 2 +- embedded8266/web/page/main.js | 12 ++++----- 5 files changed, 26 insertions(+), 32 deletions(-) diff --git a/embedded8266/esp82xx b/embedded8266/esp82xx index a863e69..d5732eb 160000 --- a/embedded8266/esp82xx +++ b/embedded8266/esp82xx @@ -1 +1 @@ -Subproject commit a863e6984ed0fb5617983e4cae185871d5f0fff6 +Subproject commit d5732eb9ca52796d6511728ba80231790d127e45 diff --git a/embedded8266/user/custom_commands.c b/embedded8266/user/custom_commands.c index dc0e74b..b3dee1e 100644 --- a/embedded8266/user/custom_commands.c +++ b/embedded8266/user/custom_commands.c @@ -2,7 +2,7 @@ #include #include #include -#include "mystuff.h" +#include "esp82xxutil.h" #include #include #include @@ -71,7 +71,7 @@ int ICACHE_FLASH_ATTR CustomCommand(char * buffer, int retsize, char *pusrdata, case 'b': case 'B': //bins { int i; - int whichSel = my_atoi( &pusrdata[2] ); + int whichSel = ParamCaptureAndAdvanceInt( ); uint16_t * which = 0; uint16_t qty = FIXBINS; @@ -89,7 +89,7 @@ int ICACHE_FLASH_ATTR CustomCommand(char * buffer, int retsize, char *pusrdata, return buffend-buffer; } - buffend += ets_sprintf( buffend, "CB%d:%d:", whichSel, qty ); + buffend += ets_sprintf( buffend, "CB%d\t%d\t", whichSel, qty ); for( i = 0; i < FIXBINS; i++ ) { uint16_t samp = which[i]; @@ -105,7 +105,7 @@ 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 ); + buffend += ets_sprintf( buffend, "CL\t%d\t", gUSE_NUM_LIN_LEDS ); uint16_t toledsvals = gUSE_NUM_LIN_LEDS*3; if( toledsvals > 600 ) toledsvals = 600; for( i = 0; i < toledsvals; i++ ) @@ -121,7 +121,7 @@ int ICACHE_FLASH_ATTR CustomCommand(char * buffer, int retsize, char *pusrdata, case 'm': case 'M': //Oscilloscope { int i, it = soundhead; - buffend += ets_sprintf( buffend, "CM:512:" ); + buffend += ets_sprintf( buffend, "CM\t512\t" ); for( i = 0; i < 512; i++ ) { uint8_t samp = sounddata[it++]; @@ -135,7 +135,7 @@ int ICACHE_FLASH_ATTR CustomCommand(char * buffer, int retsize, char *pusrdata, case 'n': case 'N': //Notes { int i; - buffend += ets_sprintf( buffend, "CN:%d:", MAXNOTES ); + buffend += ets_sprintf( buffend, "CN\t%d\t", MAXNOTES ); for( i = 0; i < MAXNOTES; i++ ) { uint16_t dat; @@ -222,42 +222,36 @@ int ICACHE_FLASH_ATTR CustomCommand(char * buffer, int retsize, char *pusrdata, { int i; - buffend += ets_sprintf( buffend, "CVR:" ); + buffend += ets_sprintf( buffend, "CVR\t" ); i = 0; while( gConfigurableNames[i] ) { - buffend += ets_sprintf( buffend, "%s=%d:", gConfigurableNames[i], *gConfigurables[i] ); + buffend += ets_sprintf( buffend, "%s=%d\t", gConfigurableNames[i], *gConfigurables[i] ); i++; } - buffend += ets_sprintf( buffend, "rBASE_FREQ=%d:rDFREQ=%d:rOCTAVES=%d:rFIXBPERO=%d:rNOTERANGE=%d:rSORT_NOTES=%d:", + buffend += ets_sprintf( buffend, "rBASE_FREQ=%d\trDFREQ=%d\trOCTAVES=%d\trFIXBPERO=%d\trNOTERANGE=%d\trSORT_NOTES=%d\t", (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:", + buffend += ets_sprintf( buffend, "rMAXNOTES=%d\trNUM_LIN_LEDS=%d\trLIN_WRAPAROUND=%d\trLIN_WRAPAROUND=%d\t", (int)MAXNOTES, (int)NUM_LIN_LEDS, (int)LIN_WRAPAROUND, (int)LIN_WRAPAROUND ); return buffend-buffer; } else if( pusrdata[2] == 'W' || pusrdata[2] == 'w' ) { - char * colon = 0, * colon2 = 0; + parameters+=2; + char * name = ParamCaptureAndAdvance(); + int val = ParamCaptureAndAdvanceInt(); + int i = 0; + printf( "%s:=%d\n", name, val ); do { - int i = 0; - colon = (char *) ets_strstr( (char*)&pusrdata[2], ":" ); - if( !colon ) break; - *colon = 0; - colon++; - colon2 = (char *) ets_strstr( (char*)colon, ":" ); - if( !colon2 ) break; - *colon2 = 0; - colon2++; - while( gConfigurableNames[i] ) { - if( strcmp( colon, gConfigurableNames[i] ) == 0 ) + if( strcmp( name, gConfigurableNames[i] ) == 0 ) { - *gConfigurables[i] = my_atoi(colon2); + *gConfigurables[i] = val; buffend += ets_sprintf( buffend, "CVW" ); return buffend-buffer; } diff --git a/embedded8266/user/user_main.c b/embedded8266/user/user_main.c index eb169a9..3b858e7 100644 --- a/embedded8266/user/user_main.c +++ b/embedded8266/user/user_main.c @@ -8,7 +8,7 @@ #include "uart.h" #include "osapi.h" #include "espconn.h" -#include "mystuff.h" +#include "esp82xxutil.h" #include "ws2812_i2s.h" #include "hpatimer.h" #include "DFT32.h" diff --git a/embedded8266/user/ws2812_i2s.c b/embedded8266/user/ws2812_i2s.c index 2953eea..2149e4b 100644 --- a/embedded8266/user/ws2812_i2s.c +++ b/embedded8266/user/ws2812_i2s.c @@ -36,7 +36,7 @@ Extra copyright info: #include "slc_register.h" -#include "mystuff.h" +#include "esp82xxutil.h" #include #include "ws2812_i2s.h" #include "user_interface.h" diff --git a/embedded8266/web/page/main.js b/embedded8266/web/page/main.js index 42d16d5..ff4e4fe 100644 --- a/embedded8266/web/page/main.js +++ b/embedded8266/web/page/main.js @@ -31,13 +31,13 @@ function ChangeParam( p ) { var num = Number( p.value ); var elem = p.id.substr( 5 ); - QueueOperation( "CVW:" + elem + ":" + num ); + QueueOperation( "CVW\t" + elem + "\t" + num ); } var hasCreateParams = false; function ReceiveParameters(req,data) { - var elems = data.split( ":" ); + var elems = data.split( "\t" ); for( var v = 0; v < elems.length; v++ ) { @@ -113,7 +113,7 @@ function GotOScope(req,data) $( "#OScopePauseButton" ).css( "background-color", "green" ); - var secs = data.split( ":" ); + var secs = data.split( "\t" ); var samps = Number( secs[1] ); var data = secs[2]; @@ -195,7 +195,7 @@ function GotDFT(req,data) if( ctx.canvas.width != canvas.clientWidth ) ctx.canvas.width = canvas.clientWidth; if( ctx.canvas.height != canvas.clientHeight ) ctx.canvas.height = canvas.clientHeight; - var secs = data.split( ":" ); + var secs = data.split( "\t" ); $( "#DFTPauseButton" ).css( "background-color", "green" ); @@ -272,7 +272,7 @@ function GotLED(req,data) if( canvas.width != ls.clientWidth-10 ) canvas.width = ls.clientWidth-10; if( ctx.canvas.width != canvas.clientWidth ) ctx.canvas.width = canvas.clientWidth; - var secs = data.split( ":" ); + var secs = data.split( "\t" ); $( "#LEDPauseButton" ).css( "background-color", "green" ); @@ -345,7 +345,7 @@ function GotNotes(req,data) var canvas = document.getElementById('NotesCanvas'); var ctx = canvas.getContext('2d'); - var secs = data.split( ":" ); + var secs = data.split( "\t" ); var elems = Number(secs[1] );