From de0e291b786e29ebdd18db270dd59c137ced1012 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Sun, 1 Nov 2020 15:35:49 +0100 Subject: [PATCH] F-commands to flash and display them --- lib/uuid-console/src/shell.cpp | 19 ++++++++++++------- lib/uuid-console/src/uuid/console.h | 1 + src/emsesp.cpp | 2 +- src/system.cpp | 4 ++-- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/uuid-console/src/shell.cpp b/lib/uuid-console/src/shell.cpp index e68af84c8..d57c004f0 100644 --- a/lib/uuid-console/src/shell.cpp +++ b/lib/uuid-console/src/shell.cpp @@ -133,6 +133,14 @@ void Shell::loop_one() { } } +void Shell::set_command_str(const __FlashStringHelper * str) { + line_buffer_ = read_flash_string(str); + erase_current_line(); + prompt_displayed_ = false; + display_prompt(); + process_command(); +} + void Shell::loop_normal() { const int input = read_one_char(); @@ -246,20 +254,17 @@ void Shell::loop_normal() { cursor_ = line_buffer_.length(); } else if (esc_ == 11) { // F1 and F10 - line_buffer_ = "help"; - process_command(); + set_command_str(F("help")); } else if (esc_ == 12) { // F2 - line_buffer_ = "show"; - process_command(); + set_command_str(F("show")); } else if (esc_ == 20) { // F9 - line_buffer_ = "send telegram \"0B \""; + line_buffer_ = read_flash_string(F("send telegram \"0B \"")); cursor_ = 1; } else if (esc_ == 21) { // F10 - line_buffer_ = "call system report"; - process_command(); + set_command_str(F("call system report")); } esc_ = 0; } else { diff --git a/lib/uuid-console/src/uuid/console.h b/lib/uuid-console/src/uuid/console.h index 6918020cb..c1b1027d5 100644 --- a/lib/uuid-console/src/uuid/console.h +++ b/lib/uuid-console/src/uuid/console.h @@ -892,6 +892,7 @@ class Shell : public std::enable_shared_from_this, public uuid::log::Hand * @since 0.1.0 */ size_t vprintf(const __FlashStringHelper * format, va_list ap); + void set_command_str(const __FlashStringHelper * str); static const uuid::log::Logger logger_; /*!< uuid::log::Logger instance for shells. @since 0.1.0 */ static std::set> shells_; /*!< Registered running shells to be executed. @since 0.1.0 */ diff --git a/src/emsesp.cpp b/src/emsesp.cpp index f439ce1a1..91b30df71 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -917,7 +917,7 @@ void EMSESP::start() { emsdevices.reserve(5); // reserve space for initially 5 devices to avoid mem - LOG_INFO("EMS Device library loaded with %d records", device_library_.size()); + LOG_INFO(F("EMS Device library loaded with %d records"), device_library_.size()); #if defined(EMSESP_STANDALONE) mqtt_.on_connect(); // simulate an MQTT connection diff --git a/src/system.cpp b/src/system.cpp index dff320365..2a858b7c2 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -61,7 +61,7 @@ bool System::command_send(const char * value, const int8_t id) { // restart EMS-ESP void System::restart() { - LOG_NOTICE("Restarting system..."); + LOG_NOTICE(F("Restarting system...")); Shell::loop_all(); delay(1000); // wait a second #if defined(ESP8266) @@ -73,7 +73,7 @@ void System::restart() { // saves all settings void System::wifi_reconnect() { - LOG_NOTICE("The wifi will reconnect..."); + LOG_NOTICE(F("The wifi will reconnect...")); Shell::loop_all(); delay(1000); // wait a second EMSESP::webSettingsService.save(); // local settings