diff --git a/html_orig/_pages.php b/html_orig/_pages.php index 129cfd2..4be6cf6 100644 --- a/html_orig/_pages.php +++ b/html_orig/_pages.php @@ -41,6 +41,8 @@ pg('help', 'cfg page-help', 'help', '/help'); pg('about', 'cfg page-about', 'about', '/about'); pg('term', 'term', '', '/', 'title.term'); +pg('reset_screen', 'api', '', '/system/cls', 'title.term'); + // ajax API return $pages; diff --git a/html_orig/lang/en.php b/html_orig/lang/en.php index 461e975..422c191 100644 --- a/html_orig/lang/en.php +++ b/html_orig/lang/en.php @@ -40,6 +40,7 @@ return [ 'term.example' => 'Default colors preview', + 'term.reset_screen' => 'Reset screen & parser', 'term.term_title' => 'Header text', 'term.term_width' => 'Width / height', 'term.default_fg_bg' => 'Text / background', diff --git a/html_orig/pages/cfg_term.php b/html_orig/pages/cfg_term.php index 7140d4c..5f38f25 100644 --- a/html_orig/pages/cfg_term.php +++ b/html_orig/pages/cfg_term.php @@ -1,3 +1,7 @@ +
+ +
+

diff --git a/user/ansi_parser.c b/user/ansi_parser.c index 117ebb5..73304c2 100644 --- a/user/ansi_parser.c +++ b/user/ansi_parser.c @@ -51,7 +51,7 @@ ansi_parser_reset(void) { cs = ansi_start; inside_string = false; apars_reset_utf8buffer(); - ansi_warn("Parser timeout, state reset"); + ansi_warn("Parser state reset (timeout?)"); } } diff --git a/user/ansi_parser.rl b/user/ansi_parser.rl index d8c9f69..ce2e3ee 100644 --- a/user/ansi_parser.rl +++ b/user/ansi_parser.rl @@ -26,7 +26,7 @@ ansi_parser_reset(void) { cs = ansi_start; inside_string = false; apars_reset_utf8buffer(); - ansi_warn("Parser timeout, state reset"); + ansi_warn("Parser state reset (timeout?)"); } } diff --git a/user/cgi_system.c b/user/cgi_system.c index f1c044c..ee45b6b 100755 --- a/user/cgi_system.c +++ b/user/cgi_system.c @@ -7,6 +7,7 @@ #include "persist.h" #include "syscfg.h" #include "uart_driver.h" +#include "ansi_parser.h" #define SET_REDIR_SUC "/cfg/system" #define SET_REDIR_ERR SET_REDIR_SUC"?err=" @@ -18,6 +19,22 @@ static void ICACHE_FLASH_ATTR tmrCb(void *arg) system_restart(); } +httpd_cgi_state ICACHE_FLASH_ATTR cgiResetScreen(HttpdConnData *connData) +{ + if (connData->conn==NULL) { + //Connection aborted. Clean up. + return HTTPD_CGI_DONE; + } + + info("--- User request to reset screen! ---"); + // this copies termconf to scratch and also resets the screen + terminal_apply_settings(); + ansi_parser_reset(); + + httpdRedirect(connData, "/"); + return HTTPD_CGI_DONE; +} + httpd_cgi_state ICACHE_FLASH_ATTR cgiResetDevice(HttpdConnData *connData) { if (connData->conn==NULL) { diff --git a/user/cgi_system.h b/user/cgi_system.h index b90c274..6aca8b8 100755 --- a/user/cgi_system.h +++ b/user/cgi_system.h @@ -8,5 +8,6 @@ httpd_cgi_state cgiPing(HttpdConnData *connData); httpd_cgi_state cgiResetDevice(HttpdConnData *connData); httpd_cgi_state cgiSystemCfgSetParams(HttpdConnData *connData); httpd_cgi_state tplSystemCfg(HttpdConnData *connData, char *token, void **arg); +httpd_cgi_state cgiResetScreen(HttpdConnData *connData); #endif // CGI_PING_H diff --git a/user/routes.c b/user/routes.c index 9a5845e..6523cc3 100644 --- a/user/routes.c +++ b/user/routes.c @@ -38,6 +38,7 @@ HttpdBuiltInUrl routes[] = { // --- System control --- ROUTE_CGI("/system/reset/?", cgiResetDevice), ROUTE_CGI("/system/ping/?", cgiPing), + ROUTE_CGI("/system/cls/?", cgiResetScreen), // --- WiFi config --- (TODO make this conditional and configurable) #if WIFI_PROTECT