summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-08-25 16:59:39 +1000
committerjacqueline <me@jacqueline.id.au>2023-08-25 16:59:39 +1000
commit0f5cf25e73fb2e789b472317966ff80323dddd75 (patch)
tree714bce08328a8cc86e1cb97a1c60fb0a267ff49d /src
parent485e9adfce01b9b4e21dae927fb3b7ed3d5fc83d (diff)
downloadtangara-fw-0f5cf25e73fb2e789b472317966ff80323dddd75.tar.gz
More performance and usability tweaks
- pin ui and decoder to opposite cores - disable touch wheel when controls are locked
Diffstat (limited to 'src')
-rw-r--r--src/drivers/include/relative_wheel.hpp12
-rw-r--r--src/drivers/relative_wheel.cpp14
-rw-r--r--src/ui/lvgl_task.cpp2
-rw-r--r--src/ui/screen_track_browser.cpp1
-rw-r--r--src/ui/ui_fsm.cpp1
-rw-r--r--src/ui/widget_top_bar.cpp10
6 files changed, 27 insertions, 13 deletions
diff --git a/src/drivers/include/relative_wheel.hpp b/src/drivers/include/relative_wheel.hpp
index 6edc006a..5e801aba 100644
--- a/src/drivers/include/relative_wheel.hpp
+++ b/src/drivers/include/relative_wheel.hpp
@@ -26,17 +26,21 @@ class RelativeWheel {
explicit RelativeWheel(TouchWheel* touch);
- // Not copyable or movable.
- RelativeWheel(const RelativeWheel&) = delete;
- RelativeWheel& operator=(const RelativeWheel&) = delete;
-
auto Update() -> void;
+ auto SetEnabled(bool) -> void;
auto is_clicking() -> bool;
auto ticks() -> std::int_fast16_t;
+ // Not copyable or movable.
+ RelativeWheel(const RelativeWheel&) = delete;
+ RelativeWheel& operator=(const RelativeWheel&) = delete;
+
private:
TouchWheel* touch_;
+
+ bool is_enabled_;
+
bool is_clicking_;
bool was_clicking_;
bool is_first_read_;
diff --git a/src/drivers/relative_wheel.cpp b/src/drivers/relative_wheel.cpp
index 846d0e7b..75b62ae7 100644
--- a/src/drivers/relative_wheel.cpp
+++ b/src/drivers/relative_wheel.cpp
@@ -15,6 +15,7 @@ namespace drivers {
RelativeWheel::RelativeWheel(TouchWheel* touch)
: touch_(touch),
+ is_enabled_(true),
is_clicking_(false),
was_clicking_(false),
is_first_read_(true),
@@ -60,17 +61,24 @@ auto RelativeWheel::Update() -> void {
}
}
+auto RelativeWheel::SetEnabled(bool en) -> void {
+ is_enabled_ = en;
+}
+
auto RelativeWheel::is_clicking() -> bool {
+ if (!is_enabled_) {
+ return false;
+ }
bool ret = is_clicking_;
is_clicking_ = 0;
return ret;
}
auto RelativeWheel::ticks() -> std::int_fast16_t {
- int_fast16_t t = ticks_;
- if (t != 0) {
- ESP_LOGI("teeks", "ticks %d", t);
+ if (!is_enabled_) {
+ return 0;
}
+ int_fast16_t t = ticks_;
ticks_ = 0;
return t;
}
diff --git a/src/ui/lvgl_task.cpp b/src/ui/lvgl_task.cpp
index d13ef5aa..a9af0900 100644
--- a/src/ui/lvgl_task.cpp
+++ b/src/ui/lvgl_task.cpp
@@ -109,7 +109,7 @@ void LvglMain(std::weak_ptr<drivers::RelativeWheel> weak_touch_wheel,
auto StartLvgl(std::weak_ptr<drivers::RelativeWheel> touch_wheel,
std::weak_ptr<drivers::Display> display) -> void {
tasks::StartPersistent<tasks::Type::kUi>(
- [=]() { LvglMain(touch_wheel, display); });
+ 0, [=]() { LvglMain(touch_wheel, display); });
}
} // namespace ui
diff --git a/src/ui/screen_track_browser.cpp b/src/ui/screen_track_browser.cpp
index c534b423..67c47628 100644
--- a/src/ui/screen_track_browser.cpp
+++ b/src/ui/screen_track_browser.cpp
@@ -177,6 +177,7 @@ auto TrackBrowser::AddResults(
text = "[ no data ]";
}
lv_obj_t* item = lv_list_add_btn(list_, NULL, text->c_str());
+ lv_label_set_long_mode(lv_obj_get_child(item, -1), LV_LABEL_LONG_DOT);
lv_obj_add_event_cb(item, item_click_cb, LV_EVENT_CLICKED, this);
lv_obj_add_event_cb(item, item_select_cb, LV_EVENT_FOCUSED, this);
diff --git a/src/ui/ui_fsm.cpp b/src/ui/ui_fsm.cpp
index e8660207..508fb740 100644
--- a/src/ui/ui_fsm.cpp
+++ b/src/ui/ui_fsm.cpp
@@ -97,6 +97,7 @@ void UiState::PopScreen() {
void UiState::react(const system_fsm::KeyLockChanged& ev) {
sDisplay->SetDisplayOn(ev.falling);
+ sRelativeWheel->SetEnabled(ev.falling);
}
void UiState::react(const system_fsm::BatteryPercentChanged&) {
diff --git a/src/ui/widget_top_bar.cpp b/src/ui/widget_top_bar.cpp
index 2d2e13dc..7d4ef98c 100644
--- a/src/ui/widget_top_bar.cpp
+++ b/src/ui/widget_top_bar.cpp
@@ -66,15 +66,15 @@ auto TopBar::Update(const State& state) -> void {
}
if (state.battery_percent >= 95) {
- lv_label_set_text(battery_, LV_SYMBOL_BATTERY_FULL);
+ lv_label_set_text(battery_, "100");
} else if (state.battery_percent >= 70) {
- lv_label_set_text(battery_, LV_SYMBOL_BATTERY_1);
+ lv_label_set_text(battery_, ">70");
} else if (state.battery_percent >= 40) {
- lv_label_set_text(battery_, LV_SYMBOL_BATTERY_2);
+ lv_label_set_text(battery_, ">40");
} else if (state.battery_percent >= 10) {
- lv_label_set_text(battery_, LV_SYMBOL_BATTERY_3);
+ lv_label_set_text(battery_, ">10");
} else {
- lv_label_set_text(battery_, LV_SYMBOL_BATTERY_EMPTY);
+ lv_label_set_text(battery_, "0");
}
}