diff options
Diffstat (limited to 'src/tangara/app_console/app_console.cpp')
| -rw-r--r-- | src/tangara/app_console/app_console.cpp | 59 |
1 files changed, 27 insertions, 32 deletions
diff --git a/src/tangara/app_console/app_console.cpp b/src/tangara/app_console/app_console.cpp index f3593e1b..21dec56a 100644 --- a/src/tangara/app_console/app_console.cpp +++ b/src/tangara/app_console/app_console.cpp @@ -418,28 +418,21 @@ int CmdBtList(int argc, char** argv) { return 1; } - auto devices = AppConsole::sServices->bluetooth().KnownDevices(); + auto devices = AppConsole::sServices->bluetooth().knownDevices(); if (argc == 2) { int index = std::atoi(argv[1]); if (index < 0 || index >= devices.size()) { std::cout << "index out of range" << std::endl; return -1; } - drivers::bluetooth::MacAndName dev{ - .mac = devices[index].address, - .name = {devices[index].name.data(), devices[index].name.size()}, - }; - AppConsole::sServices->bluetooth().SetPreferredDevice(dev); + AppConsole::sServices->bluetooth().pairedDevice(devices[index]); } else { - std::cout << "mac\t\trssi\tname" << std::endl; + std::cout << "mac\t\tname" << std::endl; for (const auto& device : devices) { - for (size_t i = 0; i < device.address.size(); i++) { + for (size_t i = 0; i < device.mac.size(); i++) { std::cout << std::hex << std::setfill('0') << std::setw(2) - << static_cast<int>(device.address[i]); + << static_cast<int>(device.mac[i]); } - float perc = - (static_cast<double>(device.signal_strength) + 127.0) / 256.0 * 100; - std::cout << "\t" << std::fixed << std::setprecision(0) << perc << "%"; std::cout << "\t" << device.name << std::endl; } } @@ -472,26 +465,7 @@ int CmdSamd(int argc, char** argv) { } else if (cmd == "charge") { auto res = samd.GetChargeStatus(); if (res) { - switch (res.value()) { - case drivers::Samd::ChargeStatus::kNoBattery: - std::cout << "kNoBattery" << std::endl; - break; - case drivers::Samd::ChargeStatus::kBatteryCritical: - std::cout << "kBatteryCritical" << std::endl; - break; - case drivers::Samd::ChargeStatus::kDischarging: - std::cout << "kDischarging" << std::endl; - break; - case drivers::Samd::ChargeStatus::kChargingRegular: - std::cout << "kChargingRegular" << std::endl; - break; - case drivers::Samd::ChargeStatus::kChargingFast: - std::cout << "kChargingFast" << std::endl; - break; - case drivers::Samd::ChargeStatus::kFullCharge: - std::cout << "kFullCharge" << std::endl; - break; - } + std::cout << drivers::Samd::chargeStatusToString(*res) << std::endl; } else { std::cout << "unknown" << std::endl; } @@ -690,6 +664,26 @@ void RegisterLua() { esp_console_cmd_register(&cmd_luarun); } +int CmdSnapshot(int argc, char** argv) { + if (argc != 2) { + std::cout << "snapshot expects 1 argument" << std::endl; + return 1; + } + + events::Ui().Dispatch(ui::Screenshot{.filename = argv[1]}); + return 0; +} + +void RegisterSnapshot() { + esp_console_cmd_t cmd_snapshot{ + .command = "snapshot", + .help = "Saves a screenshot of the display to a file", + .hint = "filename", + .func = &CmdSnapshot, + .argtable = NULL}; + esp_console_cmd_register(&cmd_snapshot); +} + auto AppConsole::PrerunCallback() -> void { Console::PrerunCallback(); esp_log_level_set("*", ESP_LOG_NONE); @@ -720,6 +714,7 @@ auto AppConsole::RegisterExtraComponents() -> void { RegisterHapticEffect(); RegisterLua(); + RegisterSnapshot(); } } // namespace console |
