add an indicator for database updates

custom
jacqueline 1 year ago
parent 2626c0cffc
commit ee867f2dbc
  1. BIN
      lua/img/db.png
  2. 11
      lua/widgets.lua
  3. 6
      src/ui/include/ui_fsm.hpp
  4. 15
      src/ui/ui_fsm.cpp
  5. 2
      tools/cmake/common.cmake

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

@ -4,6 +4,7 @@ local bluetooth = require("bluetooth")
local font = require("font") local font = require("font")
local backstack = require("backstack") local backstack = require("backstack")
local theme = require("theme") local theme = require("theme")
local database = require("database")
local widgets = {} local widgets = {}
@ -92,6 +93,9 @@ function widgets.StatusBar(parent, opts)
status_bar.title:set { text = opts.title } status_bar.title:set { text = opts.title }
end end
status_bar.db_updating = status_bar.root:Image {
src = "//lua/img/db.png"
}
status_bar.bluetooth = status_bar.root:Image {} status_bar.bluetooth = status_bar.root:Image {}
status_bar.battery = status_bar.root:Image {} status_bar.battery = status_bar.root:Image {}
status_bar.chg = status_bar.battery:Image { status_bar.chg = status_bar.battery:Image {
@ -131,6 +135,13 @@ function widgets.StatusBar(parent, opts)
end end
status_bar.bindings = { 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) power.battery_pct:bind(function(pct)
percent = pct percent = pct
update_battery_icon() update_battery_icon()

@ -71,9 +71,9 @@ class UiState : public tinyfsm::Fsm<UiState> {
void react(const internal::DismissAlerts&); void react(const internal::DismissAlerts&);
void react(const internal::ControlSchemeChanged&); 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::UpdateProgress&){};
void react(const database::event::UpdateFinished&){}; void react(const database::event::UpdateFinished&);
void react(const system_fsm::BluetoothEvent&); void react(const system_fsm::BluetoothEvent&);
@ -129,6 +129,8 @@ class UiState : public tinyfsm::Fsm<UiState> {
static lua::Property sControlsScheme; static lua::Property sControlsScheme;
static lua::Property sControlSensitivity; static lua::Property sControlSensitivity;
static lua::Property sDatabaseUpdating;
}; };
namespace states { namespace states {

@ -11,6 +11,7 @@
#include <variant> #include <variant>
#include "bluetooth_types.hpp" #include "bluetooth_types.hpp"
#include "db_events.hpp"
#include "freertos/portmacro.h" #include "freertos/portmacro.h"
#include "freertos/projdefs.h" #include "freertos/projdefs.h"
#include "lua.h" #include "lua.h"
@ -213,6 +214,8 @@ lua::Property UiState::sControlsScheme{
return true; return true;
}}; }};
lua::Property UiState::sDatabaseUpdating{false};
auto UiState::InitBootSplash(drivers::IGpios& gpios) -> bool { auto UiState::InitBootSplash(drivers::IGpios& gpios) -> bool {
// Init LVGL first, since the display driver registers itself with LVGL. // Init LVGL first, since the display driver registers itself with LVGL.
lv_init(); lv_init();
@ -258,6 +261,14 @@ void UiState::react(const internal::ControlSchemeChanged&) {
sInput->mode(sServices->nvs().PrimaryInput()); 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&) { void UiState::react(const internal::DismissAlerts&) {
lv_obj_clean(sAlertContainer); lv_obj_clean(sAlertContainer);
} }
@ -435,6 +446,10 @@ void Lua::entry() {
{"show", [&](lua_State* s) { return ShowAlert(s); }}, {"show", [&](lua_State* s) { return ShowAlert(s); }},
{"hide", [&](lua_State* s) { return HideAlert(s); }}, {"hide", [&](lua_State* s) { return HideAlert(s); }},
}); });
sLua->bridge().AddPropertyModule("database",
{
{"updating", &sDatabaseUpdating},
});
auto bt = sServices->bluetooth(); auto bt = sServices->bluetooth();
sBluetoothEnabled.Update(bt.IsEnabled()); sBluetoothEnabled.Update(bt.IsEnabled());

@ -5,7 +5,7 @@
# For more information about build system see # For more information about build system see
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html # 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. # esp-idf sets the C++ standard weird. Set cmake vars to match.
set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD 23)

Loading…
Cancel
Save