watch command with no args shows value

This commit is contained in:
proddy
2020-08-17 22:00:22 +02:00
parent d9f61923c4
commit cf3c93c8dc
2 changed files with 24 additions and 22 deletions

View File

@@ -91,7 +91,6 @@ void EMSESPShell::display_banner() {
// turn off watch // turn off watch
emsesp::EMSESP::watch_id(WATCH_ID_NONE); emsesp::EMSESP::watch_id(WATCH_ID_NONE);
emsesp::EMSESP::watch(EMSESP::WATCH_OFF); emsesp::EMSESP::watch(EMSESP::WATCH_OFF);
} }
// pre-loads all the console commands into the MAIN context // pre-loads all the console commands into the MAIN context
@@ -392,8 +391,11 @@ void Console::load_standard_commands(unsigned int context) {
EMSESPShell::commands->add_command(context, EMSESPShell::commands->add_command(context,
CommandFlags::USER, CommandFlags::USER,
flash_string_vector{F_(watch)}, flash_string_vector{F_(watch)},
flash_string_vector{F_(watch_format_mandatory), F_(watchid_optional)}, flash_string_vector{F_(watch_format_optional), F_(watchid_optional)},
[](Shell & shell, const std::vector<std::string> & arguments) { [](Shell & shell, const std::vector<std::string> & arguments) {
uint16_t watch_id;
if (!arguments.empty()) {
// get raw/pretty // get raw/pretty
if (arguments[0] == read_flash_string(F_(raw))) { if (arguments[0] == read_flash_string(F_(raw))) {
emsesp::EMSESP::watch(EMSESP::WATCH_RAW); // raw emsesp::EMSESP::watch(EMSESP::WATCH_RAW); // raw
@@ -406,7 +408,6 @@ void Console::load_standard_commands(unsigned int context) {
return; return;
} }
uint16_t watch_id;
if (arguments.size() == 2) { if (arguments.size() == 2) {
// get the watch_id if its set // get the watch_id if its set
watch_id = Helpers::hextoint(arguments[1].c_str()); watch_id = Helpers::hextoint(arguments[1].c_str());
@@ -415,6 +416,7 @@ void Console::load_standard_commands(unsigned int context) {
} }
emsesp::EMSESP::watch_id(watch_id); emsesp::EMSESP::watch_id(watch_id);
}
uint8_t watch = emsesp::EMSESP::watch(); uint8_t watch = emsesp::EMSESP::watch();
if (watch == EMSESP::WATCH_OFF) { if (watch == EMSESP::WATCH_OFF) {

View File

@@ -96,7 +96,7 @@ MAKE_PSTR(deep_optional, "[deep]")
MAKE_PSTR(tx_mode_fmt, "Tx mode = %d") MAKE_PSTR(tx_mode_fmt, "Tx mode = %d")
MAKE_PSTR(bus_id_fmt, "Bus ID = %02X") MAKE_PSTR(bus_id_fmt, "Bus ID = %02X")
MAKE_PSTR(watchid_optional, "[ID]") MAKE_PSTR(watchid_optional, "[ID]")
MAKE_PSTR(watch_format_mandatory, "<off | on | raw>") MAKE_PSTR(watch_format_optional, "[off | on | raw]")
MAKE_PSTR(invalid_watch, "Invalid watch type") MAKE_PSTR(invalid_watch, "Invalid watch type")
MAKE_PSTR(data_mandatory, "<\"XX XX ...\">") MAKE_PSTR(data_mandatory, "<\"XX XX ...\">")
MAKE_PSTR(percent, "%") MAKE_PSTR(percent, "%")