diff --git a/html/console.tpl b/html/console.tpl index 32ed8c4..7d9ef2b 100644 --- a/html/console.tpl +++ b/html/console.tpl @@ -3,8 +3,9 @@
-

ESP Link - Debug Console

-
+
%topnav%
+

esp link - Debug Console

+
 %console%
 
diff --git a/html/help.tpl b/html/help.tpl index b60faa2..6057e7a 100644 --- a/html/help.tpl +++ b/html/help.tpl @@ -4,10 +4,8 @@
-

Home | Wifi | - Serial | LED

- -

ESP Link Help

+
%topnav%
+

esp link - Help

The ESP Link functions in two wifi modes: Station+AccessPoint (STA+AP) and Station (STA). In the STA+AP mode it presents a network called esp8266 that you can connect to using the diff --git a/html/index.tpl b/html/index.tpl index 70c4bd8..fc7b2c3 100644 --- a/html/index.tpl +++ b/html/index.tpl @@ -4,24 +4,11 @@
-

Home | Wifi | - Serial | LED | Help | - Console -

- -

ESP Link

+
%topnav%
+

esp link

The ESP Link connects the ESP's serial port to Wifi and it can program microcontrollers over the serial port, in particular Arduinos, AVRs, and NXP's LPC800-series ARM processors.

- -

Status

- -

-
diff --git a/html/led.tpl b/html/led.tpl index 2e7ea62..78ea6c0 100644 --- a/html/led.tpl +++ b/html/led.tpl @@ -3,7 +3,8 @@
-

ESP Link - LED test

+
%topnav%
+

esp link - LED test

If there's a LED connected to GPIO2, it's now %ledstate%. You can change that using the buttons below.

diff --git a/html/style.css b/html/style.css index 7074375..1554cbc 100644 --- a/html/style.css +++ b/html/style.css @@ -7,15 +7,54 @@ body { #main { background-color: #FFFFCC; - -moz-border-radius: 5px; - -webkit-border-radius: 5px; - border-radius: 5px; + -moz-border-radius: 10px; + -webkit-border-radius: 10px; + border-radius: 10px; border: 2px solid #000000; width: 800px; margin: 0 auto; padding: 20px } +h1 { + margin-top: 0; + font-size: 2.4em; +} +h1 .esp { + font-size: 3em; +} + +#topnav { + background-color: #CC9966; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + border-radius: 5px; + border: 0px solid #000000; + padding: 10px; + margin-left: auto; + margin-right: auto; + color: #ffff99; +} +#topnav a { + color: #ffff99; + font-weight: bold; + font-stretch: expanded; +} + +pre.console { + background-color: #663300; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + border-radius: 5px; + border: 0px solid #000000; + color: #66ff66; + padding: 5px; +} + +pre.console a { + color: #66ff66; +} + .lock-icon { background-image: url("/wifi/icons.png"); background-color: transparent; diff --git a/html/wifi/wifi.tpl b/html/wifi/wifi.tpl index 02bc58e..a230371 100644 --- a/html/wifi/wifi.tpl +++ b/html/wifi/wifi.tpl @@ -74,9 +74,8 @@ window.onload=function(e) {
-

Home | Wifi | Serial | LED

- -

ESP Link - Wifi Configuration

+
%topnav%
+

esp link - Wifi Configuration

Current WiFi mode: %WiFiMode%
Current network: %currSsid% Status: %currStatus% Phy:%currPhy% diff --git a/user/cgi.c b/user/cgi.c index ad6a2bc..fbcd714 100644 --- a/user/cgi.c +++ b/user/cgi.c @@ -6,9 +6,9 @@ flash as a binary. Also handles the hit counter on the main page. /* * ---------------------------------------------------------------------------- * "THE BEER-WARE LICENSE" (Revision 42): - * Jeroen Domburg wrote this file. As long as you retain - * this notice you can do whatever you want with this stuff. If we meet some day, - * and you think this stuff is worth it, you can buy me a beer in return. + * Jeroen Domburg wrote this file. As long as you retain + * this notice you can do whatever you want with this stuff. If we meet some day, + * and you think this stuff is worth it, you can buy me a beer in return. * ---------------------------------------------------------------------------- */ @@ -25,7 +25,7 @@ static char currLedState=0; int ICACHE_FLASH_ATTR cgiLed(HttpdConnData *connData) { int len; char buff[1024]; - + if (connData->conn==NULL) { //Connection aborted. Clean up. return HTTPD_CGI_DONE; @@ -55,6 +55,8 @@ int ICACHE_FLASH_ATTR tplLed(HttpdConnData *connData, char *token, void **arg) { } else { os_strcpy(buff, "off"); } + } else if (os_strcmp(token, "topnav")==0) { + printNav(buff); } httpdSend(connData, buff, -1); return HTTPD_CGI_DONE; @@ -64,13 +66,33 @@ static long hitCounter=0; //Template code for the counter on the index page. int ICACHE_FLASH_ATTR tplCounter(HttpdConnData *connData, char *token, void **arg) { - char buff[128]; + char buff[256]; if (token==NULL) return HTTPD_CGI_DONE; - if (os_strcmp(token, "counter")==0) { + if (os_strcmp(token, "topnav")==0) { + printNav(buff); + } else if (os_strcmp(token, "counter")==0) { hitCounter++; os_sprintf(buff, "%ld", hitCounter); } httpdSend(connData, buff, -1); return HTTPD_CGI_DONE; } + +static char *navLinks[][2] = { + { "Home", "/index.tpl" }, { "Wifi", "/wifi/wifi.tpl" }, { "Serial", "/index.tpl" }, + { "Esp log", "/console.tpl" }, { "Help", "/help.tpl" }, + { 0, 0 }, +}; + +// Print the navigation links into the buffer and return the length of what got added +int ICACHE_FLASH_ATTR printNav(char *buff) { + int len = 0; + for (uint8_t i=0; navLinks[i][0] != NULL; i++) { + if (i > 0) buff[len++] = '|'; + //os_printf("nav %d: %s -> %s\n", i, navLinks[i][0], navLinks[i][1]); + len += os_sprintf(buff+len, " %s ", navLinks[i][1], navLinks[i][0]); + } + //os_printf("nav: %s\n", buff); + return len; +} diff --git a/user/cgi.h b/user/cgi.h index 4ae5d6d..3cd8441 100644 --- a/user/cgi.h +++ b/user/cgi.h @@ -6,5 +6,6 @@ int cgiLed(HttpdConnData *connData); int tplLed(HttpdConnData *connData, char *token, void **arg); int tplCounter(HttpdConnData *connData, char *token, void **arg); +int printNav(char *buff); -#endif \ No newline at end of file +#endif diff --git a/user/cgiwifi.c b/user/cgiwifi.c index c3fb80b..392f9bd 100644 --- a/user/cgiwifi.c +++ b/user/cgiwifi.c @@ -14,6 +14,7 @@ Cgi/template routines for the /wifi url. #include #include "cgiwifi.h" +#include "cgi.h" #include "status.h" //Enable this to disallow any changes in AP settings @@ -397,6 +398,8 @@ int ICACHE_FLASH_ATTR tplWlan(HttpdConnData *connData, char *token, void **arg) os_strcpy(buff, "Click here to go to STA mode."); break; } + } else if (os_strcmp(token, "topnav")==0) { + printNav(buff); } httpdSend(connData, buff, -1); return HTTPD_CGI_DONE; diff --git a/user/console.c b/user/console.c index 827e8c0..77c9e1f 100644 --- a/user/console.c +++ b/user/console.c @@ -1,5 +1,6 @@ #include #include "uart.h" +#include "cgi.h" #include "console.h" // Web console for the esp8266 to replace outputting to uart1. @@ -13,12 +14,13 @@ static int console_wr, console_rd; static void ICACHE_FLASH_ATTR console_write(char c) { int wr = (console_wr+1)%BUF_MAX; - if (wr != console_rd) { - console_buf[console_wr] = c; - console_wr = wr; - } + if (wr == console_rd) + console_rd = (console_rd+1) % BUF_MAX; // full, eat first char + console_buf[console_wr] = c; + console_wr = wr; } +#if 0 static char ICACHE_FLASH_ATTR console_read(void) { char c = 0; @@ -28,10 +30,11 @@ console_read(void) { } return c; } +#endif static void ICACHE_FLASH_ATTR console_write_char(char c) { - //uart0_write_char(c); + uart0_write_char(c); if (c == '\n') console_write('\r'); console_write(c); } @@ -40,18 +43,18 @@ console_write_char(char c) { int ICACHE_FLASH_ATTR tplConsole(HttpdConnData *connData, char *token, void **arg) { if (token==NULL) return HTTPD_CGI_DONE; + char buff[256]; if (os_strcmp(token, "console") == 0) { - char buf[128]; - int n = 0; - while (console_rd != console_wr) { - buf[n++] = console_read(); - if (n == 128) { - httpdSend(connData, buf, n); - n = 0; - } + if (console_wr > console_rd) { + httpdSend(connData, console_buf+console_rd, console_wr-console_rd); + } else if (console_rd != console_wr) { + httpdSend(connData, console_buf+console_rd, BUF_MAX-console_rd); + httpdSend(connData, console_buf, console_wr); } - if (n > 0) httpdSend(connData, buf, n); + } else if (os_strcmp(token, "topnav")==0) { + printNav(buff); + httpdSend(connData, buff, -1); } else { httpdSend(connData, "Unknown\n", -1); } diff --git a/user/user_main.c b/user/user_main.c index c3faab8..586a7e7 100644 --- a/user/user_main.c +++ b/user/user_main.c @@ -64,8 +64,8 @@ HttpdBuiltInUrl builtInUrls[]={ {"/flash/next", cgiGetFirmwareNext, NULL}, {"/flash/upload", cgiUploadFirmware, NULL}, {"/flash/reboot", cgiRebootFirmware, NULL}, - {"/led.tpl", cgiEspFsTemplate, tplLed}, {"/index.tpl", cgiEspFsTemplate, tplCounter}, + {"/help.tpl", cgiEspFsTemplate, tplCounter}, {"/led.cgi", cgiLed, NULL}, {"/console.tpl", cgiEspFsTemplate, tplConsole},