Switch ColorChord over to the new dev esp82xx.

This commit is contained in:
cnlohr 2017-06-21 23:43:11 -04:00
parent bf3b8f3e56
commit 454ca08025
7 changed files with 257 additions and 143 deletions

View file

@ -12,52 +12,54 @@
#define memcpy ets_memcpy
#define memset ets_memset
extern uint8_t gDFTIIR; //=6
#define DFTIIR gDFTIIR
extern uint8_t gFUZZ_IIR_BITS; //=1
#define FUZZ_IIR_BITS gFUZZ_IIR_BITS
#define ROOT_NOTE_OFFSET CCS.gROOT_NOTE_OFFSET
#define DFTIIR CCS.gDFTIIR
#define FUZZ_IIR_BITS CCS.gFUZZ_IIR_BITS
#define MAXNOTES 12 //MAXNOTES cannot be changed dynamically.
extern uint8_t gFILTER_BLUR_PASSES; //=2
#define FILTER_BLUR_PASSES gFILTER_BLUR_PASSES
extern uint8_t gSEMIBITSPERBIN; //=3
#define SEMIBITSPERBIN gSEMIBITSPERBIN
extern uint8_t gMAX_JUMP_DISTANCE; //=4
#define MAX_JUMP_DISTANCE gMAX_JUMP_DISTANCE
extern uint8_t gMAX_COMBINE_DISTANCE; //=7
#define MAX_COMBINE_DISTANCE gMAX_COMBINE_DISTANCE
extern uint8_t gAMP_1_IIR_BITS; //=4
#define AMP_1_IIR_BITS gAMP_1_IIR_BITS
extern uint8_t gAMP_2_IIR_BITS; //=2
#define AMP_2_IIR_BITS gAMP_2_IIR_BITS
extern uint8_t gMIN_AMP_FOR_NOTE; //=80
#define MIN_AMP_FOR_NOTE gMIN_AMP_FOR_NOTE
extern uint8_t gMINIMUM_AMP_FOR_NOTE_TO_DISAPPEAR; //=64
#define MINIMUM_AMP_FOR_NOTE_TO_DISAPPEAR gMINIMUM_AMP_FOR_NOTE_TO_DISAPPEAR
extern uint8_t gNOTE_FINAL_AMP; //=12
#define NOTE_FINAL_AMP gNOTE_FINAL_AMP
extern uint8_t gNERF_NOTE_PORP; //=15
#define NERF_NOTE_PORP gNERF_NOTE_PORP
extern uint8_t gUSE_NUM_LIN_LEDS; // = NUM_LIN_LEDS
#define USE_NUM_LIN_LEDS gUSE_NUM_LIN_LEDS
#define FILTER_BLUR_PASSES CCS.gFILTER_BLUR_PASSES
#define SEMIBITSPERBIN CCS.gSEMIBITSPERBIN
#define MAX_JUMP_DISTANCE CCS.gMAX_JUMP_DISTANCE
#define MAX_COMBINE_DISTANCE CCS.gMAX_COMBINE_DISTANCE
#define AMP_1_IIR_BITS CCS.gAMP_1_IIR_BITS
#define AMP_2_IIR_BITS CCS.gAMP_2_IIR_BITS
#define MIN_AMP_FOR_NOTE CCS.gMIN_AMP_FOR_NOTE
#define MINIMUM_AMP_FOR_NOTE_TO_DISAPPEAR CCS.gMINIMUM_AMP_FOR_NOTE_TO_DISAPPEAR
#define NOTE_FINAL_AMP CCS.gNOTE_FINAL_AMP
#define NERF_NOTE_PORP CCS.gNERF_NOTE_PORP
#define USE_NUM_LIN_LEDS CCS.gUSE_NUM_LIN_LEDS
#define COLORCHORD_OUTPUT_DRIVER CCS.gCOLORCHORD_OUTPUT_DRIVER
#define COLORCHORD_ACTIVE CCS.gCOLORCHORD_ACTIVE
//We are not enabling these for the ESP8266 port.
#define LIN_WRAPAROUND 0
#define SORT_NOTES 0
struct CCSettings
{
uint8_t gSETTINGS_KEY;
uint8_t gROOT_NOTE_OFFSET; //Set to define what the root note is. 0 = A.
uint8_t gDFTIIR; //=6
uint8_t gFUZZ_IIR_BITS; //=1
uint8_t gFILTER_BLUR_PASSES; //=2
uint8_t gSEMIBITSPERBIN; //=3
uint8_t gMAX_JUMP_DISTANCE; //=4
uint8_t gMAX_COMBINE_DISTANCE; //=7
uint8_t gAMP_1_IIR_BITS; //=4
uint8_t gAMP_2_IIR_BITS; //=2
uint8_t gMIN_AMP_FOR_NOTE; //=80
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;
uint8_t gCOLORCHORD_OUTPUT_DRIVER;
};
extern struct CCSettings CCS;
#endif

@ -1 +1 @@
Subproject commit 113e0d1a182cd138510f748abf2854c0e84cfa23
Subproject commit 21e23b5c360045425abe6c855853f2d973420fc2

View file

@ -12,12 +12,17 @@ PAGE_OFFSET = 65536 # 1048576
#SDK_DEFAULT = $(HOME)/esp8266/esp-open-sdk
ESP_GCC_VERS = 4.8.5
SDK = $(HOME)/esp8266/esp_iot_sdk_v1.5.2
#SDK = $(HOME)/esp8266/esp_iot_sdk_v1.5.2
PAGE_SCRIPTS = main.js
FWBURNFLAGS = -b 1000000
FWBURNFLAGS = -b 1500000
OPTS += -DICACHE_FLASH
OPTS += -DDISABLE_CHARRX #Saves about 48 bytes.
OPTS += -DQUIET_REFLASH #Saves about 128 bytes.
OPTS += -DWS2812_FOUR_SAMPLE #Saves about 224 bytes.
#OPTS += -DWS2812_THREE_SAMPLE
#OPTS += -DVERIFY_FLASH_WRITE
#OPTS += -DDEBUG
#OPTS += -DFREQ=12500

View file

@ -4,6 +4,7 @@
#include <eagle_soc.h>
#include "esp82xxutil.h"
#include <DFT32.h>
#include <settings.h>
#include <embeddednf.h>
#include <embeddedout.h>
@ -13,34 +14,21 @@ extern volatile uint16_t soundhead;
#define CONFIGURABLES 17 //(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;
uint8_t gFILTER_BLUR_PASSES = 2;
uint8_t gSEMIBITSPERBIN = 3;
uint8_t gMAX_JUMP_DISTANCE = 4;
uint8_t gMAX_COMBINE_DISTANCE = 7;
uint8_t gAMP_1_IIR_BITS = 4;
uint8_t gAMP_2_IIR_BITS = 2;
uint8_t gMIN_AMP_FOR_NOTE = 80;
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;
uint8_t gCOLORCHORD_OUTPUT_DRIVER = 0;
struct SaveLoad
{
uint8_t configs[CONFIGURABLES];
uint8_t SaveLoadKey; //Must be 0xaa to be valid.
} settings;
struct CCSettings CCS;
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, &gCOLORCHORD_OUTPUT_DRIVER, 0 };
uint8_t * gConfigurables[CONFIGURABLES] = { &CCS.gROOT_NOTE_OFFSET, &CCS.gDFTIIR, &CCS.gFUZZ_IIR_BITS, &CCS.gFILTER_BLUR_PASSES,
&CCS.gSEMIBITSPERBIN, &CCS.gMAX_JUMP_DISTANCE, &CCS.gMAX_COMBINE_DISTANCE, &CCS.gAMP_1_IIR_BITS,
&CCS.gAMP_2_IIR_BITS, &CCS.gMIN_AMP_FOR_NOTE, &CCS.gMINIMUM_AMP_FOR_NOTE_TO_DISAPPEAR, &CCS.gNOTE_FINAL_AMP,
&CCS.gNERF_NOTE_PORP, &CCS.gUSE_NUM_LIN_LEDS, &CCS.gCOLORCHORD_ACTIVE, &CCS.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",
@ -51,11 +39,24 @@ void ICACHE_FLASH_ATTR CustomStart( )
{
int i;
spi_flash_read( 0x3D000, (uint32*)&settings, sizeof( settings ) );
for( i = 0; i < CONFIGURABLES; i++ )
if( settings.SaveLoadKey == 0xaa )
{
if( gConfigurables[i] )
for( i = 0; i < CONFIGURABLES; i++ )
{
*gConfigurables[i] = settings.configs[i];
if( gConfigurables[i] )
{
*gConfigurables[i] = settings.configs[i];
}
}
}
else
{
for( i = 0; i < CONFIGURABLES; i++ )
{
if( gConfigurables[i] )
{
*gConfigurables[i] = gConfigDefaults[i];
}
}
}
}
@ -105,8 +106,8 @@ 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\t%d\t", gUSE_NUM_LIN_LEDS );
uint16_t toledsvals = gUSE_NUM_LIN_LEDS*3;
buffend += ets_sprintf( buffend, "CL\t%d\t", USE_NUM_LIN_LEDS );
uint16_t toledsvals = USE_NUM_LIN_LEDS*3;
if( toledsvals > 600 ) toledsvals = 600;
for( i = 0; i < toledsvals; i++ )
{

View file

@ -15,9 +15,10 @@
#include "ccconfig.h"
#include <embeddednf.h>
#include <embeddedout.h>
#include <commonservices.h>
#include "ets_sys.h"
#include "gpio.h"
#include "settings.h"
//#define PROFILE
#define PORT 7777
@ -28,6 +29,7 @@
#define procTaskPrio 0
#define procTaskQueueLen 1
struct CCSettings CCS;
static volatile os_timer_t some_timer;
static struct espconn *pUdpServer;
@ -37,27 +39,26 @@ 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;
static uint8_t hpa_running = 0;
static uint8_t hpa_is_paused_for_wifi;
void ICACHE_FLASH_ATTR CustomStart( );
void ICACHE_FLASH_ATTR user_rf_pre_init()
{
}
extern uint8_t gCOLORCHORD_OUTPUT_DRIVER;
//Call this once we've stacked together one full colorchord frame.
static void NewFrame()
{
if( !gCOLORCHORD_ACTIVE ) return;
if( !COLORCHORD_ACTIVE ) return;
//uint8_t led_outs[NUM_LIN_LEDS*3];
int i;
HandleFrameInfo();
switch( gCOLORCHORD_OUTPUT_DRIVER )
switch( COLORCHORD_OUTPUT_DRIVER )
{
case 0:
UpdateLinearLEDs();
@ -72,56 +73,22 @@ static void NewFrame()
}
os_event_t procTaskQueue[procTaskQueueLen];
static uint8_t printed_ip = 0;
uint32_t samp_iir = 0;
int wf = 0;
//Tasks that happen all the time.
static void ICACHE_FLASH_ATTR HandleIPStuff()
{
//Idle Event.
struct station_config wcfg;
char stret[256];
char *stt = &stret[0];
struct ip_info ipi;
int stat = wifi_station_get_connect_status();
//printf( "STAT: %d %d\n", stat, wifi_get_opmode() );
if( stat == STATION_WRONG_PASSWORD || stat == STATION_NO_AP_FOUND || stat == STATION_CONNECT_FAIL )
{
wifi_set_opmode_current( 2 );
stt += ets_sprintf( stt, "Connection failed: %d\n", stat );
uart0_sendStr(stret);
}
if( stat == STATION_GOT_IP && !printed_ip )
{
wifi_station_get_config( &wcfg );
wifi_get_ip_info(0, &ipi);
stt += ets_sprintf( stt, "STAT: %d\n", stat );
stt += ets_sprintf( stt, "IP: %d.%d.%d.%d\n", (ipi.ip.addr>>0)&0xff,(ipi.ip.addr>>8)&0xff,(ipi.ip.addr>>16)&0xff,(ipi.ip.addr>>24)&0xff );
stt += ets_sprintf( stt, "NM: %d.%d.%d.%d\n", (ipi.netmask.addr>>0)&0xff,(ipi.netmask.addr>>8)&0xff,(ipi.netmask.addr>>16)&0xff,(ipi.netmask.addr>>24)&0xff );
stt += ets_sprintf( stt, "GW: %d.%d.%d.%d\n", (ipi.gw.addr>>0)&0xff,(ipi.gw.addr>>8)&0xff,(ipi.gw.addr>>16)&0xff,(ipi.gw.addr>>24)&0xff );
stt += ets_sprintf( stt, "WCFG: /%s/%s/\n", wcfg.ssid, wcfg.password );
uart0_sendStr(stret);
printed_ip = 1;
}
}
static void procTask(os_event_t *events)
{
system_os_post(procTaskPrio, 0, 0 );
if( gCOLORCHORD_ACTIVE && !hpa_running )
if( COLORCHORD_ACTIVE && !hpa_running )
{
ExitCritical();
hpa_running = 1;
}
if( !gCOLORCHORD_ACTIVE && hpa_running )
if( !COLORCHORD_ACTIVE && hpa_running )
{
EnterCritical();
hpa_running = 0;
@ -152,7 +119,6 @@ static void procTask(os_event_t *events)
if( events->sig == 0 && events->par == 0 )
{
CSTick( 0 );
HandleIPStuff();
}
}
@ -161,6 +127,12 @@ static void procTask(os_event_t *events)
static void ICACHE_FLASH_ATTR myTimer(void *arg)
{
CSTick( 1 );
if( hpa_is_paused_for_wifi && printed_ip )
{
StartHPATimer(); //Init the high speed ADC timer.
hpa_running = 1;
}
// uart0_sendStr(".");
// printf( "%d/%d\n",soundtail,soundhead );
// printf( "%d/%d\n",soundtail,soundhead );
@ -238,8 +210,16 @@ void ICACHE_FLASH_ATTR user_init(void)
InitColorChord(); //Init colorchord
StartHPATimer(); //Init the high speed ADC timer.
hpa_running = 1;
//Tricky: If we are in station mode, wait for that to get resolved before enabling the high speed timer.
if( wifi_get_opmode() == 1 )
{
hpa_is_paused_for_wifi = 1;
}
else
{
StartHPATimer(); //Init the high speed ADC timer.
hpa_running = 1;
}
ws2812_init();

View file

@ -23,7 +23,8 @@
//4 takes up more RAM per LED than 3.
//3 has slightly more restrictve timing requirements.
//4 has more DMA load when running.
#define WS2812_THREE_SAMPLE
//#define WS2812_THREE_SAMPLE
//#define WS2812_FOUR_SAMPLE
void ICACHE_FLASH_ATTR ws2812_init();

View file

@ -6,7 +6,7 @@ var output;
var websocket;
var commsup = 0;
var mpfs_start_at = 1048576;
var mpfs_start_at = 65536; //1048576; NOTE: If you select 1048576, it will override the 65536 sector, but has much more room.
var flash_scratchpad_at = 524288;
var flash_blocksize = 65536;
var flash_sendsize = 256;
@ -44,10 +44,12 @@ function QueueOperation( command, callback )
workqueue.push( vp );
}
did_init = false;
function init()
{
var GPIOlines = '';
if( did_init ) return;
did_init = true;
GPIOlines = '';
for(var i=0; i<16; ++i)
GPIOlines += "<td align=center>"+ i
+ "<input type=button id=ButtonGPIO"+ i +" value=0 onclick=\"TwiddleGPIO("+ i +");\">"
@ -56,10 +58,11 @@ function init()
$('#MainMenu > tbody:first-child').before( "\
<tr><td width=1> \
<input type=submit onclick=\"ShowHideEvent( 'SystemStatus' );\" value='System Status' id=SystemStatusClicker></td><td> \
<input type=submit onclick=\"ShowHideEvent( 'SystemStatus' ); SystemInfoTick();\" value='System Status' id=SystemStatusClicker></td><td> \
<div id=SystemStatus class='collapsible'> \
<table width=100% border=1><tr><td> \
<div id=output> \n </td></tr></table></div></td></tr>" );
<div id=output></div><div id=systemsettings></div> \n </td></tr></table></div></td></tr>"
);
$('#MainMenu > tbody:last-child').after( "\
<tr><td width=1> \
@ -118,16 +121,19 @@ function init()
$("#custom_command_response").val( "" );
//Preclude drag and drop on rest of document in event user misses firmware boxes.
var donothing = function(e) {e.stopPropagation();e.preventDefault();};
donothing = function(e) {e.stopPropagation();e.preventDefault();};
$(document).on('drop', donothing );
$(document).on('dragover', donothing );
$(document).on('dragenter', donothing );
output = document.getElementById("output");
Ticker();
KickWifiTicker();
GPIODataTickerStart();
InitSystemTicker();
console.log( "Load complete.\n" );
Ticker();
}
window.addEventListener("load", init, false);
@ -141,6 +147,7 @@ function StartWebSocket()
workqueue = [];
lastitem = null;
websocket = new WebSocket(wsUri);
websocket.binaryType = 'arraybuffer';
websocket.onopen = function(evt) { onOpen(evt) };
websocket.onclose = function(evt) { onClose(evt) };
websocket.onmessage = function(evt) { onMessage(evt) };
@ -161,7 +168,8 @@ function onClose(evt)
var msg = 0;
var tickmessage = 0;
var lasthz = 0;
var time_since_hz = 0;
var time_since_hz = 10; //Make it realize it was disconnected to begin with.
function Ticker()
{
setTimeout( Ticker, 1000 );
@ -203,17 +211,24 @@ function onMessage(evt)
}
var rawdat = new Uint8Array(evt.data)
var stringdata = String.fromCharCode.apply(null, rawdat);
if( lastitem )
{
if( lastitem.callback )
{
lastitem.callback( lastitem, evt.data );
lastitem.callback( lastitem, stringdata, rawdat );
lastitem = null;
}
}
else
{
output.innerHTML = "<p>Messages: " + msg + "</p><p>RSSI: " + evt.data.substr(2) + "</p>";
if( stringdata.length > 2 )
{
var wxresp = stringdata.substr(2).split("\t");
output.innerHTML = "<p>Messages: " + msg + "</p><p>RSSI: " + wxresp[0] + " / IP: " + ((wxresp.length>1)?HexToIP( wxresp[1] ):"") + "</p>";
}
}
@ -278,27 +293,27 @@ function IssueCustomCommand()
function MakeDragDrop( divname, callback )
{
var obj = $("#" + divname);
obj.on('dragenter', function (e)
obj.on('dragenter', function (e)
{
e.stopPropagation();
e.preventDefault();
$(this).css('border', '2px solid #0B85A1');
});
obj.on('dragover', function (e)
obj.on('dragover', function (e)
{
e.stopPropagation();
e.preventDefault();
});
obj.on('dragend', function (e)
obj.on('dragend', function (e)
{
e.stopPropagation();
e.preventDefault();
$(this).css('border', '2px dotted #0B85A1');
});
obj.on('drop', function (e)
obj.on('drop', function (e)
{
$(this).css('border', '2px dotted #0B85A1');
e.preventDefault();
@ -318,9 +333,108 @@ function MakeDragDrop( divname, callback )
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///Below here are mostly just events...
var did_wifi_get_config = false;
var is_data_ticker_running = false;
var is_waiting_on_stations = false;
var sysset = null;
var snchanged = false;
var sdchanged = false;
var lastpeerdata = "";
function CallbackForPeers(req,data)
{
if( data == lastpeerdata ) return;
lastpeerdata = data;
var lines = data.split( "\n" );
var searchcount = 0;
if( lines.length > 0 )
{
var line1 = lines[0].split( "\t" );
if( line1.length > 1 ) searchcount = Number( line1[1] );
}
var htm = "<TABLE BORDER=1 STYLE='width:150'><TR><TH>Address</TH><TH>Service</TH><TH>Name</TH><TH>Description</TH></TR>";
for( var i = 1; i < lines.length; i++ )
{
var elems = lines[i].split( "\t" );
if( elems.length < 4 ) continue;
IP = HexToIP( elems[0] );
htm += "<TR><TD><A HREF=http://" + IP + ">" + IP + "</A></TD><TD>" + elems[1] + "</TD><TD>" + elems[2] + "</TD><TD>" + elems[3] + "</TD></TR>";
}
htm += "</TABLE>";
if( searchcount == 0 )
{
htm += "<INPUT TYPE=SUBMIT VALUE=\"Initiate Search\" ONCLICK='QueueOperation(\"BS\");'>";
}
$("#peers").html( htm );
}
function SysTickBack(req,data)
{
var params = data.split( "\t" );
if( !snchanged )
{
$("#SystemName").prop( "value", params[3] );
$("#SystemName").removeClass( "unsaved-input");
}
if( !sdchanged )
{
$("#SystemDescription").prop( "value", params[4] );
$("#SystemDescription").removeClass( "unsaved-input");
}
$("#ServiceName").html( params[5] );
$("#FreeHeap").html( params[6] );
QueueOperation( "BL", CallbackForPeers );
}
function SystemInfoTick()
{
if( IsTabOpen('SystemStatus') )
{
QueueOperation( "I", SysTickBack );
setTimeout( SystemInfoTick, 500 );
}
else
{
//Stop.
}
}
function SystemChangesReset()
{
snchanged = false;
sdchanged = false;
}
function SystemUncommittedChanges()
{
if( sdchanged || snchanged ) return true;
else return false;
}
function InitSystemTicker()
{
sysset = document.getElementById( "systemsettings" );
SystemInfoTick();
sysset.innerHTML = "<TABLE style='width:150'><TR><TD>System Name:</TD><TD><INPUT TYPE=TEXT ID='SystemName' maxlength=10></TD><TD><INPUT TYPE=SUBMIT VALUE=Change ONCLICK='QueueOperation(\"IN\" + document.getElementById(\"SystemName\").value ); snchanged = false;'></TD></TR>\
<TR><TD NOWRAP>System Description:</TD><TD><INPUT TYPE=TEXT ID='SystemDescription' maxlength=16></TD><TD><INPUT TYPE=SUBMIT VALUE=Change ONCLICK='QueueOperation(\"ID\" + document.getElementById(\"SystemDescription\").value ); sdchanged = false;'></TD></TR><TR><TD>Service Name:</TD><TD><DIV ID=\"ServiceName\"></DIV></TD></TR><TR><TD>Free Heap:</TD><TD><DIV ID=\"FreeHeap\"></DIV></TD></TR></TABLE>\
<INPUT TYPE=SUBMIT VALUE=\"Reset To Current\" ONCLICK='SystemChangesReset();'>\
<INPUT TYPE=SUBMIT VALUE=Save ONCLICK='if( SystemUncommittedChanges() ) { IssueSystemMessage( \"Cannot save. Uncommitted changes.\"); return; } QueueOperation(\"IS\", function() { IssueSystemMessage( \"Saving\" ); } ); SystemChangesReset(); '>\
<INPUT TYPE=SUBMIT VALUE=\"Revert From Saved\" ONCLICK='QueueOperation(\"IL\", function() { IssueSystemMessage( \"Reverting.\" ); } ); SystemChangesReset();'>\
<INPUT TYPE=SUBMIT VALUE=\"Revert To Factory\" ONCLICK='if( confirm( \"Are you sure you want to revert to factory settings?\" ) ) QueueOperation(\"IR\"); SystemChangesReset();'>\
<INPUT TYPE=SUBMIT VALUE=Reboot ONCLICK='QueueOperation(\"IB\");'>\
<P>Search for others:</P>\
<DIV id=peers></DIV>";
$("#SystemName").on("input propertychange paste",function(){snchanged = true; $("#SystemName").addClass( "unsaved-input"); });
$("#SystemDescription").on("input propertychange paste",function(){sdchanged = true;$("#SystemDescription").addClass( "unsaved-input"); });
}
did_wifi_get_config = false;
is_data_ticker_running = false;
is_waiting_on_stations = false;
function ScanForWifi()
{
@ -378,7 +492,7 @@ function WifiDataTicker()
QueueOperation( "WI", function(req,data)
{
var params = data.split( "\t" );
var opmode = Number( params[0].substr(2) );
document.wifisection.wifitype.value = opmode;
document.wifisection.wificurname.value = params[1];
@ -394,6 +508,7 @@ function WifiDataTicker()
QueueOperation( "WR", function(req,data) {
var lines = data.split( "\n" );
var innerhtml;
if( data[0] == '!' ) return; //If no APs, don't deal with list.
if( lines.length < 3 )
{
@ -425,7 +540,7 @@ function WifiDataTicker()
innerhtml += "</TABLE>";
document.getElementById("WifiStations").innerHTML = innerhtml;
} );
setTimeout( WifiDataTicker, 12000 );
setTimeout( WifiDataTicker, 500 );
}
else
{
@ -435,7 +550,7 @@ function WifiDataTicker()
function ChangeWifiConfig()
{
var st = "W";
st += document.wifisection.wifitype.value;
st += "\t" + document.wifisection.wificurname.value;
@ -549,7 +664,7 @@ function SystemPushImageProgress( is_ok, comment, pushop )
pushop.ctx.file1md5 = faultylabs.MD5( pushop.paddata ).toLowerCase();
var reader = new FileReader();
reader.onload = function(e) {
reader.onload = function(e) {
$("#innersystemflashtext").html( "Pusing second half..." );
PushImageTo( e.target.result, flash_scratchpad_at + 0x40000, SystemPushImageProgress, pushop.ctx );
}
@ -567,7 +682,7 @@ function SystemPushImageProgress( is_ok, comment, pushop )
var stf = "FM" + flash_scratchpad_at + "\t0\t" + f1s + "\t" + f1m + "\t" + (flash_scratchpad_at+0x40000) + "\t" + 0x40000 + "\t" + f2s + "\t" + f2m + "\n";
var fun = function( fsrd, flashresponse ) { $("#innerflashtext").html( (flashresponse[0] == '!')?"Flashing failed.":"Flash success." ) };
QueueOperation( stf, fun);
QueueOperation( stf, fun);
}
return false;
@ -578,7 +693,7 @@ function SystemPushImageProgress( is_ok, comment, pushop )
function WebPagePushImageFunction( ok, comment, pushop )
{
{
if( pushop.place == pushop.padlen )
{
$("#innersystemflashtext").html("Push complete. Reload page.");
@ -589,7 +704,7 @@ function WebPagePushImageFunction( ok, comment, pushop )
}
return true;
}
}
function DragDropSystemFiles( file )
{
@ -607,7 +722,7 @@ function DragDropSystemFiles( file )
var reader = new FileReader();
reader.onload = function(e) {
reader.onload = function(e) {
PushImageTo( e.target.result, mpfs_start_at, WebPagePushImageFunction );
}
@ -620,18 +735,19 @@ function DragDropSystemFiles( file )
for( var i = 0; i < file.length; i++ )
{
if( file[i].name.substr( 0, 7 ) == "0x00000" ) file1 = file[i];
if( file[i].name.substr( 0, 7 ) == "0x40000" ) file2 = file[i];
console.log( "Found: " + file[i].name );
if( file[i].name.substr( 0, 17 ) == "image.elf-0x00000" ) file1 = file[i];
if( file[i].name.substr( 0, 17 ) == "image.elf-0x40000" ) file2 = file[i];
}
if( !file1 )
{
$("#innersystemflashtext").html( "Could not find a 0x00000... file." ); return;
$("#innersystemflashtext").html( "Could not find a image.elf-0x00000... file." ); return;
}
if( !file2 )
{
$("#innersystemflashtext").html( "Could not find a 0x40000... file." ); return;
$("#innersystemflashtext").html( "Could not find a image.elf-0x40000... file." ); return;
}
if( file1.size > 65536 )
@ -650,7 +766,7 @@ function DragDropSystemFiles( file )
var reader = new FileReader();
reader.onload = function(e) {
reader.onload = function(e) {
var ctx = new Object();
ctx.file1 = file1;
ctx.file2 = file2;
@ -682,6 +798,15 @@ function tohex8( c )
}
function HexToIP( hexstr )
{
if( !hexstr ) return "";
return parseInt( hexstr.substr( 6, 2 ), 16 ) + "." +
parseInt( hexstr.substr( 4, 2 ), 16 ) + "." +
parseInt( hexstr.substr( 2, 2 ), 16 ) + "." +
parseInt( hexstr.substr( 0, 2 ), 16 );
}
function ContinueSystemFlash( fsrd, flashresponse, pushop )
{
if( flashresponse[0] == '!' )