|
|
@ -23,8 +23,9 @@ |
|
|
|
|
|
|
|
|
|
|
|
#define FIRMWARE_VERSION "0.1" |
|
|
|
#define FIRMWARE_VERSION "0.1" |
|
|
|
|
|
|
|
|
|
|
|
#define SHOW_HEAP_USE 1 |
|
|
|
/**
|
|
|
|
|
|
|
|
* Broadcast screen state to sockets |
|
|
|
|
|
|
|
*/ |
|
|
|
void screen_notifyChange() { |
|
|
|
void screen_notifyChange() { |
|
|
|
// TODO cooldown / buffering to reduce nr of such events
|
|
|
|
// TODO cooldown / buffering to reduce nr of such events
|
|
|
|
dbg("Screen notifyChange"); |
|
|
|
dbg("Screen notifyChange"); |
|
|
@ -40,10 +41,19 @@ void screen_notifyChange() { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Socket connected for updates */ |
|
|
|
void ICACHE_FLASH_ATTR myWebsocketConnect(Websock *ws) { |
|
|
|
void ICACHE_FLASH_ATTR myWebsocketConnect(Websock *ws) { |
|
|
|
dbg("Socket connected."); |
|
|
|
dbg("Socket connected."); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Main page template substitution |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param connData |
|
|
|
|
|
|
|
* @param token |
|
|
|
|
|
|
|
* @param arg |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
httpd_cgi_state ICACHE_FLASH_ATTR tplScreen(HttpdConnData *connData, char *token, void **arg) { |
|
|
|
httpd_cgi_state ICACHE_FLASH_ATTR tplScreen(HttpdConnData *connData, char *token, void **arg) { |
|
|
|
// cleanup
|
|
|
|
// cleanup
|
|
|
|
if (!connData) { |
|
|
|
if (!connData) { |
|
|
@ -94,25 +104,30 @@ HttpdBuiltInUrl builtInUrls[]={ //ICACHE_RODATA_ATTR |
|
|
|
|
|
|
|
|
|
|
|
// TODO add funcs for WiFi management (when web UI is added)
|
|
|
|
// TODO add funcs for WiFi management (when web UI is added)
|
|
|
|
|
|
|
|
|
|
|
|
ROUTE_TPL_FILE("/", tplScreen, "index.html"), |
|
|
|
// ROUTE_TPL_FILE("/", tplScreen, "term.tpl"),
|
|
|
|
|
|
|
|
ROUTE_TPL("/term.tpl", tplScreen), |
|
|
|
ROUTE_FILESYSTEM(), |
|
|
|
ROUTE_FILESYSTEM(), |
|
|
|
ROUTE_END(), |
|
|
|
ROUTE_END(), |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef SHOW_HEAP_USE |
|
|
|
|
|
|
|
static ETSTimer prHeapTimer; |
|
|
|
static ETSTimer prHeapTimer; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Blink & show heap usage */ |
|
|
|
static void ICACHE_FLASH_ATTR prHeapTimerCb(void *arg) { |
|
|
|
static void ICACHE_FLASH_ATTR prHeapTimerCb(void *arg) { |
|
|
|
static int led = 0; |
|
|
|
static int led = 0; |
|
|
|
os_printf("Heap: %ld\n", (unsigned long)system_get_free_heap_size()); |
|
|
|
static unsigned int cnt = 0; |
|
|
|
|
|
|
|
|
|
|
|
cgiWebsockBroadcast("/ws/update.cgi", "HELLO", 5, WEBSOCK_FLAG_NONE); |
|
|
|
if (cnt%3==0) { |
|
|
|
|
|
|
|
os_printf("Free heap: %ld bytes\n", (unsigned long) system_get_free_heap_size()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//cgiWebsockBroadcast("/ws/update.cgi", "HELLO", 5, WEBSOCK_FLAG_NONE);
|
|
|
|
|
|
|
|
|
|
|
|
ioLed(led); |
|
|
|
ioLed(led); |
|
|
|
led = !led; |
|
|
|
led = !led; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cnt++; |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Main routine. Initialize stdout, the I/O, filesystem and the webserver and we're done.
|
|
|
|
//Main routine. Initialize stdout, the I/O, filesystem and the webserver and we're done.
|
|
|
|
void user_init(void) { |
|
|
|
void user_init(void) { |
|
|
@ -137,11 +152,10 @@ void user_init(void) { |
|
|
|
|
|
|
|
|
|
|
|
httpdInit(builtInUrls, 80); |
|
|
|
httpdInit(builtInUrls, 80); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef SHOW_HEAP_USE |
|
|
|
// Heap use timer & blink
|
|
|
|
os_timer_disarm(&prHeapTimer); |
|
|
|
os_timer_disarm(&prHeapTimer); |
|
|
|
os_timer_setfn(&prHeapTimer, prHeapTimerCb, NULL); |
|
|
|
os_timer_setfn(&prHeapTimer, prHeapTimerCb, NULL); |
|
|
|
os_timer_arm(&prHeapTimer, 3000, 1); |
|
|
|
os_timer_arm(&prHeapTimer, 1000, 1); |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
screen_init(); |
|
|
|
screen_init(); |
|
|
|
|
|
|
|
|
|
|
|