some improvements and changes but it's not working

pull/30/head
Ondřej Hruška 8 years ago
parent fd6587d2bb
commit e3eddca176
  1. 2
      Makefile
  2. 3
      build_web.sh
  3. 0
      html/term.tpl
  4. 36
      user/user_main.c

@ -65,7 +65,7 @@ LIBS += esphttpd
# compiler flags using during compilation of source files # compiler flags using during compilation of source files
CFLAGS = -Os -ggdb -std=gnu99 -Werror -Wpointer-arith -Wundef -Wall -Wl,-EL -fno-inline-functions \ CFLAGS = -Os -ggdb -std=gnu99 -Werror -Wpointer-arith -Wundef -Wall -Wl,-EL -fno-inline-functions \
-nostdlib -mlongcalls -mtext-section-literals -D__ets__ -DICACHE_FLASH \ -nostdlib -mlongcalls -mtext-section-literals -D__ets__ -DICACHE_FLASH \
-Wno-address -Wno-address -Wno-unused
# linker flags used to generate the main object file # linker flags used to generate the main object file
LDFLAGS = -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static LDFLAGS = -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static

@ -1,5 +1,6 @@
#!/bin/bash #!/bin/bash
mkdir -p html
yuicompressor html_orig/style.css > html/style.css yuicompressor html_orig/style.css > html/style.css
yuicompressor html_orig/script.js > html/script.js 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

@ -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();

Loading…
Cancel
Save