summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-02-01 11:43:01 +1100
committerjacqueline <me@jacqueline.id.au>2024-02-01 11:43:01 +1100
commitee867f2dbcad624948d73253577ef4bf887cbfad (patch)
tree698e096574b60cdb61e8c268e963a26ac5e89b2f /src/ui
parent2626c0cffc23c22382ef72aeafecdc107f7ea92c (diff)
downloadtangara-fw-ee867f2dbcad624948d73253577ef4bf887cbfad.tar.gz
add an indicator for database updates
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/include/ui_fsm.hpp6
-rw-r--r--src/ui/ui_fsm.cpp15
2 files changed, 19 insertions, 2 deletions
diff --git a/src/ui/include/ui_fsm.hpp b/src/ui/include/ui_fsm.hpp
index 3ddef738..93a19b02 100644
--- a/src/ui/include/ui_fsm.hpp
+++ b/src/ui/include/ui_fsm.hpp
@@ -71,9 +71,9 @@ class UiState : public tinyfsm::Fsm<UiState> {
void react(const internal::DismissAlerts&);
void react(const internal::ControlSchemeChanged&);
- void react(const database::event::UpdateStarted&){};
+ void react(const database::event::UpdateStarted&);
void react(const database::event::UpdateProgress&){};
- void react(const database::event::UpdateFinished&){};
+ void react(const database::event::UpdateFinished&);
void react(const system_fsm::BluetoothEvent&);
@@ -129,6 +129,8 @@ class UiState : public tinyfsm::Fsm<UiState> {
static lua::Property sControlsScheme;
static lua::Property sControlSensitivity;
+
+ static lua::Property sDatabaseUpdating;
};
namespace states {
diff --git a/src/ui/ui_fsm.cpp b/src/ui/ui_fsm.cpp
index fe790816..228e61b6 100644
--- a/src/ui/ui_fsm.cpp
+++ b/src/ui/ui_fsm.cpp
@@ -11,6 +11,7 @@
#include <variant>
#include "bluetooth_types.hpp"
+#include "db_events.hpp"
#include "freertos/portmacro.h"
#include "freertos/projdefs.h"
#include "lua.h"
@@ -213,6 +214,8 @@ lua::Property UiState::sControlsScheme{
return true;
}};
+lua::Property UiState::sDatabaseUpdating{false};
+
auto UiState::InitBootSplash(drivers::IGpios& gpios) -> bool {
// Init LVGL first, since the display driver registers itself with LVGL.
lv_init();
@@ -258,6 +261,14 @@ void UiState::react(const internal::ControlSchemeChanged&) {
sInput->mode(sServices->nvs().PrimaryInput());
}
+void UiState::react(const database::event::UpdateStarted&) {
+ sDatabaseUpdating.Update(true);
+}
+
+void UiState::react(const database::event::UpdateFinished&) {
+ sDatabaseUpdating.Update(false);
+}
+
void UiState::react(const internal::DismissAlerts&) {
lv_obj_clean(sAlertContainer);
}
@@ -435,6 +446,10 @@ void Lua::entry() {
{"show", [&](lua_State* s) { return ShowAlert(s); }},
{"hide", [&](lua_State* s) { return HideAlert(s); }},
});
+ sLua->bridge().AddPropertyModule("database",
+ {
+ {"updating", &sDatabaseUpdating},
+ });
auto bt = sServices->bluetooth();
sBluetoothEnabled.Update(bt.IsEnabled());