button to force screen reset

pull/111/merge
Ondřej Hruška 7 years ago
parent 0af62f47e6
commit f693373a34
  1. 2
      html_orig/_pages.php
  2. 1
      html_orig/lang/en.php
  3. 4
      html_orig/pages/cfg_term.php
  4. 2
      user/ansi_parser.c
  5. 2
      user/ansi_parser.rl
  6. 17
      user/cgi_system.c
  7. 1
      user/cgi_system.h
  8. 1
      user/routes.c

@ -41,6 +41,8 @@ pg('help', 'cfg page-help', 'help', '/help');
pg('about', 'cfg page-about', 'about', '/about'); pg('about', 'cfg page-about', 'about', '/about');
pg('term', 'term', '', '/', 'title.term'); pg('term', 'term', '', '/', 'title.term');
pg('reset_screen', 'api', '', '/system/cls', 'title.term');
// ajax API // ajax API
return $pages; return $pages;

@ -40,6 +40,7 @@ return [
'term.example' => 'Default colors preview', 'term.example' => 'Default colors preview',
'term.reset_screen' => 'Reset screen & parser',
'term.term_title' => 'Header text', 'term.term_title' => 'Header text',
'term.term_width' => 'Width / height', 'term.term_width' => 'Width / height',
'term.default_fg_bg' => 'Text / background', 'term.default_fg_bg' => 'Text / background',

@ -1,3 +1,7 @@
<div class="Box">
<a href="<?= e(url('reset_screen')) ?>"><?= tr('term.reset_screen') ?></a>
</div>
<form class="Box mobopen str" action="<?= e(url('term_set')) ?>" method="GET" id='form-1'> <form class="Box mobopen str" action="<?= e(url('term_set')) ?>" method="GET" id='form-1'>
<h2><?= tr('term.defaults') ?></h2> <h2><?= tr('term.defaults') ?></h2>

@ -51,7 +51,7 @@ ansi_parser_reset(void) {
cs = ansi_start; cs = ansi_start;
inside_string = false; inside_string = false;
apars_reset_utf8buffer(); apars_reset_utf8buffer();
ansi_warn("Parser timeout, state reset"); ansi_warn("Parser state reset (timeout?)");
} }
} }

@ -26,7 +26,7 @@ ansi_parser_reset(void) {
cs = ansi_start; cs = ansi_start;
inside_string = false; inside_string = false;
apars_reset_utf8buffer(); apars_reset_utf8buffer();
ansi_warn("Parser timeout, state reset"); ansi_warn("Parser state reset (timeout?)");
} }
} }

@ -7,6 +7,7 @@
#include "persist.h" #include "persist.h"
#include "syscfg.h" #include "syscfg.h"
#include "uart_driver.h" #include "uart_driver.h"
#include "ansi_parser.h"
#define SET_REDIR_SUC "/cfg/system" #define SET_REDIR_SUC "/cfg/system"
#define SET_REDIR_ERR SET_REDIR_SUC"?err=" #define SET_REDIR_ERR SET_REDIR_SUC"?err="
@ -18,6 +19,22 @@ static void ICACHE_FLASH_ATTR tmrCb(void *arg)
system_restart(); 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) httpd_cgi_state ICACHE_FLASH_ATTR cgiResetDevice(HttpdConnData *connData)
{ {
if (connData->conn==NULL) { if (connData->conn==NULL) {

@ -8,5 +8,6 @@ httpd_cgi_state cgiPing(HttpdConnData *connData);
httpd_cgi_state cgiResetDevice(HttpdConnData *connData); httpd_cgi_state cgiResetDevice(HttpdConnData *connData);
httpd_cgi_state cgiSystemCfgSetParams(HttpdConnData *connData); httpd_cgi_state cgiSystemCfgSetParams(HttpdConnData *connData);
httpd_cgi_state tplSystemCfg(HttpdConnData *connData, char *token, void **arg); httpd_cgi_state tplSystemCfg(HttpdConnData *connData, char *token, void **arg);
httpd_cgi_state cgiResetScreen(HttpdConnData *connData);
#endif // CGI_PING_H #endif // CGI_PING_H

@ -38,6 +38,7 @@ HttpdBuiltInUrl routes[] = {
// --- System control --- // --- System control ---
ROUTE_CGI("/system/reset/?", cgiResetDevice), ROUTE_CGI("/system/reset/?", cgiResetDevice),
ROUTE_CGI("/system/ping/?", cgiPing), ROUTE_CGI("/system/ping/?", cgiPing),
ROUTE_CGI("/system/cls/?", cgiResetScreen),
// --- WiFi config --- (TODO make this conditional and configurable) // --- WiFi config --- (TODO make this conditional and configurable)
#if WIFI_PROTECT #if WIFI_PROTECT

Loading…
Cancel
Save