diff --git a/Makefile b/Makefile index c0a05fe..c8883f9 100644 --- a/Makefile +++ b/Makefile @@ -65,7 +65,7 @@ LIBS += esphttpd # compiler flags using during compilation of source files CFLAGS = -Os -ggdb -std=gnu99 -Werror -Wpointer-arith -Wundef -Wall -Wl,-EL -fno-inline-functions \ -nostdlib -mlongcalls -mtext-section-literals -D__ets__ -DICACHE_FLASH \ - -Wno-address + -Wno-address -Wno-unused # linker flags used to generate the main object file LDFLAGS = -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static diff --git a/compress_html.sh b/build_web.sh similarity index 61% rename from compress_html.sh rename to build_web.sh index d71b43b..b15671a 100755 --- a/compress_html.sh +++ b/build_web.sh @@ -1,5 +1,6 @@ #!/bin/bash +mkdir -p html yuicompressor html_orig/style.css > html/style.css yuicompressor html_orig/script.js > html/script.js -minify --type=html html_orig/index.html -o html/index.html +minify --type=html html_orig/index.html -o html/term.tpl diff --git a/html/index.html b/html/term.tpl similarity index 100% rename from html/index.html rename to html/term.tpl diff --git a/user/user_main.c b/user/user_main.c index 1e8a45d..6b2b4a3 100644 --- a/user/user_main.c +++ b/user/user_main.c @@ -23,8 +23,9 @@ #define FIRMWARE_VERSION "0.1" -#define SHOW_HEAP_USE 1 - +/** + * Broadcast screen state to sockets + */ void screen_notifyChange() { // TODO cooldown / buffering to reduce nr of such events dbg("Screen notifyChange"); @@ -40,10 +41,19 @@ void screen_notifyChange() { } } +/** Socket connected for updates */ void ICACHE_FLASH_ATTR myWebsocketConnect(Websock *ws) { 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) { // cleanup if (!connData) { @@ -94,25 +104,30 @@ HttpdBuiltInUrl builtInUrls[]={ //ICACHE_RODATA_ATTR // 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_END(), }; - -#ifdef SHOW_HEAP_USE static ETSTimer prHeapTimer; +/** Blink & show heap usage */ static void ICACHE_FLASH_ATTR prHeapTimerCb(void *arg) { 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); led = !led; + + cnt++; } -#endif //Main routine. Initialize stdout, the I/O, filesystem and the webserver and we're done. void user_init(void) { @@ -137,11 +152,10 @@ void user_init(void) { httpdInit(builtInUrls, 80); -#ifdef SHOW_HEAP_USE + // Heap use timer & blink os_timer_disarm(&prHeapTimer); os_timer_setfn(&prHeapTimer, prHeapTimerCb, NULL); - os_timer_arm(&prHeapTimer, 3000, 1); -#endif + os_timer_arm(&prHeapTimer, 1000, 1); screen_init();