summaryrefslogtreecommitdiff
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
parent2626c0cffc23c22382ef72aeafecdc107f7ea92c (diff)
downloadtangara-fw-ee867f2dbcad624948d73253577ef4bf887cbfad.tar.gz
add an indicator for database updates
-rw-r--r--lua/img/db.pngbin0 -> 4557 bytes
-rw-r--r--lua/widgets.lua11
-rw-r--r--src/ui/include/ui_fsm.hpp6
-rw-r--r--src/ui/ui_fsm.cpp15
-rw-r--r--tools/cmake/common.cmake2
5 files changed, 31 insertions, 3 deletions
diff --git a/lua/img/db.png b/lua/img/db.png
new file mode 100644
index 00000000..3952ded2
--- /dev/null
+++ b/lua/img/db.png
Binary files differ
diff --git a/lua/widgets.lua b/lua/widgets.lua
index 732093f0..8905fa43 100644
--- a/lua/widgets.lua
+++ b/lua/widgets.lua
@@ -4,6 +4,7 @@ local bluetooth = require("bluetooth")
local font = require("font")
local backstack = require("backstack")
local theme = require("theme")
+local database = require("database")
local widgets = {}
@@ -92,6 +93,9 @@ function widgets.StatusBar(parent, opts)
status_bar.title:set { text = opts.title }
end
+ status_bar.db_updating = status_bar.root:Image {
+ src = "//lua/img/db.png"
+ }
status_bar.bluetooth = status_bar.root:Image {}
status_bar.battery = status_bar.root:Image {}
status_bar.chg = status_bar.battery:Image {
@@ -131,6 +135,13 @@ function widgets.StatusBar(parent, opts)
end
status_bar.bindings = {
+ database.updating:bind(function(yes)
+ if yes then
+ status_bar.db_updating:clear_flag(lvgl.FLAG.HIDDEN)
+ else
+ status_bar.db_updating:add_flag(lvgl.FLAG.HIDDEN)
+ end
+ end),
power.battery_pct:bind(function(pct)
percent = pct
update_battery_icon()
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());
diff --git a/tools/cmake/common.cmake b/tools/cmake/common.cmake
index 12730b9b..25eee96e 100644
--- a/tools/cmake/common.cmake
+++ b/tools/cmake/common.cmake
@@ -5,7 +5,7 @@
# For more information about build system see
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
-set(PROJECT_VER "0.2.1")
+set(PROJECT_VER "0.3.0")
# esp-idf sets the C++ standard weird. Set cmake vars to match.
set(CMAKE_CXX_STANDARD 23)