diff --git a/configs/config_testdevice.cmake b/configs/config_testdevice.cmake index e135919..738b12b 100644 --- a/configs/config_testdevice.cmake +++ b/configs/config_testdevice.cmake @@ -1,4 +1,5 @@ set(BOBBY_APP_NAME testdevice) +set(BOBBY_DEFAULT_OTA_NAME testdevice) add_definitions( -DUSER_SETUP_LOADED=1 diff --git a/configs/config_testdevice2.cmake b/configs/config_testdevice2.cmake index f9d08b9..4d5a9fe 100644 --- a/configs/config_testdevice2.cmake +++ b/configs/config_testdevice2.cmake @@ -1,4 +1,5 @@ set(BOBBY_APP_NAME testdevice2) +set(BOBBY_DEFAULT_OTA_NAME testdevice2) add_definitions( -DUSER_SETUP_LOADED=1 diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 770bea8..e978008 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -24,6 +24,7 @@ set(headers actions/modesettingsaction.h actions/qraction.h actions/rebootaction.h + actions/resetnvsaction.h actions/savesettingsaction.h actions/switchprofileaction.h actions/tempomatmodeapplycurrentpeedaction.h @@ -278,6 +279,7 @@ set(sources actions/modesettingsaction.cpp actions/qraction.cpp actions/rebootaction.cpp + actions/resetnvsaction.cpp actions/savesettingsaction.cpp actions/switchprofileaction.cpp actions/tempomatmodeapplycurrentpeedaction.cpp diff --git a/main/actions/resetnvsaction.cpp b/main/actions/resetnvsaction.cpp new file mode 100644 index 0000000..d8b4c90 --- /dev/null +++ b/main/actions/resetnvsaction.cpp @@ -0,0 +1,11 @@ +#include "resetnvsaction.h" + +// system includes +#include +#include + +void ResetNVSAction::triggered() +{ + nvs_flash_erase(); + esp_restart(); +} diff --git a/main/actions/resetnvsaction.h b/main/actions/resetnvsaction.h new file mode 100644 index 0000000..78ddc84 --- /dev/null +++ b/main/actions/resetnvsaction.h @@ -0,0 +1,10 @@ +#pragma once + +// 3rdparty lib includes +#include + +class ResetNVSAction : public virtual espgui::ActionInterface +{ +public: + void triggered() override; +}; diff --git a/main/displays/menus/recoverymenu.cpp b/main/displays/menus/recoverymenu.cpp index f2759cd..1053462 100644 --- a/main/displays/menus/recoverymenu.cpp +++ b/main/displays/menus/recoverymenu.cpp @@ -5,12 +5,15 @@ // local includes #include "actions/rebootaction.h" +#include "actions/resetnvsaction.h" #include "bobbycheckbox.h" #include "bobbyerrorhandler.h" +#include "icons/info.h" #include "icons/reboot.h" #include "newsettings.h" namespace { +constexpr char TEXT_RESET_NVS[] = "Reset NVS"; constexpr char TEXT_REBOOT[] = "Reboot"; } @@ -47,6 +50,7 @@ RecoveryMenu::RecoveryMenu() configs.callForEveryFeature([&](ConfiguredFeatureFlag &feature){ constructMenuItem(feature); }); + constructMenuItem, ResetNVSAction, StaticMenuItemIcon<&bobbyicons::info>>>(); constructMenuItem, RebootAction, StaticMenuItemIcon<&bobbyicons::reboot>>>(); } diff --git a/main/main.cpp b/main/main.cpp index 50f422f..85fb161 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -101,6 +101,8 @@ extern "C" void app_main() if (const auto result = configs.init("bobbycar"); result != ESP_OK) ESP_LOGE(TAG, "config_init_settings() failed with %s", esp_err_to_name(result)); + updateRotation(); + profileSettings = presets::defaultProfileSettings; if (settingsPersister.init()) diff --git a/main/screens.cpp b/main/screens.cpp index ad89e98..6f1f406 100644 --- a/main/screens.cpp +++ b/main/screens.cpp @@ -33,6 +33,16 @@ void initScreen() bootLabel.start(); } +void updateRotation() +{ + if (tft.getRotation() != (configs.boardcomputerHardware.flipScreen.value() ? 2 : 0)) + { + tft.setRotation(configs.boardcomputerHardware.flipScreen.value() ? 2 : 0); + if (currentDisplay) + currentDisplay->initScreen(); + } +} + void updateDisplay() { if (currentDisplay) @@ -44,12 +54,7 @@ void updateDisplay() changeScreenCallback = {}; } - if (tft.getRotation() != (configs.boardcomputerHardware.flipScreen.value() ? 2 : 0)) - { - tft.setRotation(configs.boardcomputerHardware.flipScreen.value() ? 2 : 0); - if (currentDisplay) - currentDisplay->initScreen(); - } + updateRotation(); if (const int8_t rawButton = rawButtonRequest.load(); rawButton != -1 && currentDisplay) { diff --git a/main/screens.h b/main/screens.h index f46cecb..37911e1 100644 --- a/main/screens.h +++ b/main/screens.h @@ -7,4 +7,5 @@ extern espgui::Label bootLabel; void initScreen(); void updateDisplay(); +void updateRotation(); void redrawDisplay();