diff options
| author | ailurux <ailuruxx@gmail.com> | 2024-04-08 15:40:16 +1000 |
|---|---|---|
| committer | ailurux <ailuruxx@gmail.com> | 2024-04-08 15:40:16 +1000 |
| commit | f20ca9583af5312eea65cf144803d00be6e50602 (patch) | |
| tree | d6047ff952d6ad60a30ba038e6a5c72c64b8b0e7 /src/ui/ui_fsm.cpp | |
| parent | 01ae3fee30704577f4ea37ed7f2132990135163c (diff) | |
| parent | 96b62321c33ff5e146d52416dc5da3f0c240b4b0 (diff) | |
| download | tangara-fw-f20ca9583af5312eea65cf144803d00be6e50602.tar.gz | |
Merge branch 'main' of codeberg.org:cool-tech-zone/tangara-fw
Diffstat (limited to 'src/ui/ui_fsm.cpp')
| -rw-r--r-- | src/ui/ui_fsm.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/ui/ui_fsm.cpp b/src/ui/ui_fsm.cpp index 835da19e..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" @@ -282,6 +283,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<bool>(val)) { + return false; + } + sServices->nvs().DbAutoIndex(std::get<bool>(val)); + return true; + }}; lua::Property UiState::sUsbMassStorageEnabled{ false, [](const lua::LuaValue& val) { @@ -294,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. @@ -352,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; @@ -557,14 +573,19 @@ 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}, + {"msc_busy", &sUsbMassStorageBusy}, }); + sDatabaseAutoUpdate.Update(sServices->nvs().DbAutoIndex()); + auto bt = sServices->bluetooth(); sBluetoothEnabled.Update(bt.IsEnabled()); sBluetoothConnected.Update(bt.IsConnected()); |
