diff options
-rw-r--r-- | CommandTerminal/CommandTerminal.cpp | 35 | ||||
-rw-r--r-- | Mode/ModeConfig.cpp | 3 | ||||
-rw-r--r-- | main.cpp | 33 |
3 files changed, 6 insertions, 65 deletions
diff --git a/CommandTerminal/CommandTerminal.cpp b/CommandTerminal/CommandTerminal.cpp index 9ca6b30..285b0fd 100644 --- a/CommandTerminal/CommandTerminal.cpp +++ b/CommandTerminal/CommandTerminal.cpp @@ -152,43 +152,10 @@ bool CommandTerminal::start() { int history_index = -1; std::vector<std::string> args; - if (_dot->getStartUpMode() == mDot::SERIAL_MODE) { - std::string escape_buffer; - char ch; - - int escape_timeout = 1000; - Timer tmr; - Timer escape_tmr; - - // wait one second for possible escape - tmr.reset(); - tmr.start(); - escape_tmr.reset(); - escape_tmr.start(); - while (tmr.read_ms() < escape_timeout) { - if (_serial.readable()) { - _serial.read(&ch, 1); - escape_buffer += ch; - } - - if (escape_buffer.find(escape_sequence) != std::string::npos) { - _mode = mDot::COMMAND_MODE; - command.clear(); - break; - } - - if (escape_tmr.read_ms() > escape_timeout) - escape_buffer.clear(); - - osDelay(1); - } - - } - //Run terminal session while (running) { - osEvent e = Thread::signal_wait(buttonSignal); + osEvent e = Thread::signal_wait(buttonSignal, 20); if (e.status == osEventSignal) { ButtonHandler::ButtonEvent _be = _buttons->getButtonEvent(); switch (_be) { diff --git a/Mode/ModeConfig.cpp b/Mode/ModeConfig.cpp index afabab5..523c5ce 100644 --- a/Mode/ModeConfig.cpp +++ b/Mode/ModeConfig.cpp @@ -17,9 +17,8 @@ bool ModeConfig::start() { _lc.display(); - logInfo("config mode"); - mts::MTSSerial serial(USBTX, USBRX, 512, 512); + serial.baud(115200); CommandTerminal term(serial, _dot, _buttons); return term.start(); @@ -24,6 +24,7 @@ #include "LoRaHandler.h" // mode objects #include "ModeJoin.h" +#include "ModeConfig.h" // misc heders #include <string> @@ -47,10 +48,10 @@ mDot* dot; // Modes ModeJoin* modeJoin; +ModeConfig* modeConfig; // Serial debug port Serial debug(USBTX, USBRX); -mts::MTSSerial serial(USBTX, USBRX, 512, 512); // Prototypes void mainMenu(); @@ -72,6 +73,7 @@ int main() { lora = new LoRaHandler(main_id); modeJoin = new ModeJoin(lcd, buttons, dot, lora, dot->getFrequencyBand()); + modeConfig = new ModeConfig(lcd, buttons, dot); // display startup screen for 3 seconds LayoutStartup ls(lcd); @@ -149,7 +151,7 @@ void mainMenu() { if (modeJoin->start()) loraDemo(); } else if (selected == menu_strings[config]) { - configuration(); + modeConfig->start(); } else if (selected == menu_strings[single]) { if (modeJoin->start()) surveySingle(); @@ -162,33 +164,6 @@ void mainMenu() { } } -void configuration() { - LayoutConfig lc(lcd); - - // clear any stale signals - osSignalClear(main_id, buttonSignal | loraSignal); - - lc.display(); - logInfo("config mode"); - - while (true) { - osEvent e = Thread::signal_wait(buttonSignal); - if (e.status == osEventSignal) { - ButtonHandler::ButtonEvent ev = buttons->getButtonEvent(); - switch (ev) { - case ButtonHandler::sw1_press: - break; - case ButtonHandler::sw2_press: - break; - case ButtonHandler::sw1_hold: - return; - default: - break; - } - } - } -} - void loraDemo() { LayoutDemoHelp ldh(lcd); |