From 654fde5f6819cb52a198a524ab78d97e51ab97c7 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Tue, 2 Apr 2024 20:41:36 +1100 Subject: Support disabling automatic database updates --- src/ui/ui_fsm.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/ui/ui_fsm.cpp') diff --git a/src/ui/ui_fsm.cpp b/src/ui/ui_fsm.cpp index 835da19e..bb1503b2 100644 --- a/src/ui/ui_fsm.cpp +++ b/src/ui/ui_fsm.cpp @@ -282,6 +282,14 @@ lua::Property UiState::sScrollSensitivity{ lua::Property UiState::sLockSwitch{false}; lua::Property UiState::sDatabaseUpdating{false}; +lua::Property UiState::sDatabaseAutoUpdate{ + false, [](const lua::LuaValue& val) { + if (!std::holds_alternative(val)) { + return false; + } + sServices->nvs().DbAutoIndex(std::get(val)); + return true; + }}; lua::Property UiState::sUsbMassStorageEnabled{ false, [](const lua::LuaValue& val) { @@ -557,14 +565,18 @@ void Lua::entry() { "time", { {"ticks", [&](lua_State* s) { return Ticks(s); }}, }); - registry.AddPropertyModule("database", { - {"updating", &sDatabaseUpdating}, - }); + registry.AddPropertyModule("database", + { + {"updating", &sDatabaseUpdating}, + {"auto_update", &sDatabaseAutoUpdate}, + }); registry.AddPropertyModule("usb", { {"msc_enabled", &sUsbMassStorageEnabled}, }); + sDatabaseAutoUpdate.Update(sServices->nvs().DbAutoIndex()); + auto bt = sServices->bluetooth(); sBluetoothEnabled.Update(bt.IsEnabled()); sBluetoothConnected.Update(bt.IsConnected()); -- cgit v1.2.3 From 5f1a6507d8f7a0f9ecea179f94aeb182eac77cfe Mon Sep 17 00:00:00 2001 From: jacqueline Date: Mon, 8 Apr 2024 13:50:35 +1000 Subject: Warn and block MSC disable if the sd card is busy --- src/ui/ui_fsm.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/ui/ui_fsm.cpp') diff --git a/src/ui/ui_fsm.cpp b/src/ui/ui_fsm.cpp index bb1503b2..28733123 100644 --- a/src/ui/ui_fsm.cpp +++ b/src/ui/ui_fsm.cpp @@ -43,6 +43,7 @@ #include "nvs.hpp" #include "property.hpp" #include "relative_wheel.hpp" +#include "samd.hpp" #include "screen.hpp" #include "screen_lua.hpp" #include "screen_splash.hpp" @@ -302,6 +303,8 @@ lua::Property UiState::sUsbMassStorageEnabled{ return true; }}; +lua::Property UiState::sUsbMassStorageBusy{false}; + auto UiState::InitBootSplash(drivers::IGpios& gpios, drivers::NvsStorage& nvs) -> bool { // Init LVGL first, since the display driver registers itself with LVGL. @@ -360,6 +363,11 @@ void UiState::react(const system_fsm::KeyLockChanged& ev) { sLockSwitch.Update(ev.locking); } +void UiState::react(const system_fsm::SamdUsbStatusChanged& ev) { + sUsbMassStorageBusy.Update(ev.new_status == + drivers::Samd::UsbStatus::kAttachedBusy); +} + void UiState::react(const internal::ControlSchemeChanged&) { if (!sInput) { return; @@ -573,6 +581,7 @@ void Lua::entry() { registry.AddPropertyModule("usb", { {"msc_enabled", &sUsbMassStorageEnabled}, + {"msc_busy", &sUsbMassStorageBusy}, }); sDatabaseAutoUpdate.Update(sServices->nvs().DbAutoIndex()); -- cgit v1.2.3