More performance and usability tweaks

- pin ui and decoder to opposite cores
 - disable touch wheel when controls are locked
custom
jacqueline 2 years ago
parent 485e9adfce
commit 0f5cf25e73
  1. 12
      src/drivers/include/relative_wheel.hpp
  2. 14
      src/drivers/relative_wheel.cpp
  3. 2
      src/ui/lvgl_task.cpp
  4. 1
      src/ui/screen_track_browser.cpp
  5. 1
      src/ui/ui_fsm.cpp
  6. 10
      src/ui/widget_top_bar.cpp

@ -26,17 +26,21 @@ class RelativeWheel {
explicit RelativeWheel(TouchWheel* touch); explicit RelativeWheel(TouchWheel* touch);
// Not copyable or movable.
RelativeWheel(const RelativeWheel&) = delete;
RelativeWheel& operator=(const RelativeWheel&) = delete;
auto Update() -> void; auto Update() -> void;
auto SetEnabled(bool) -> void;
auto is_clicking() -> bool; auto is_clicking() -> bool;
auto ticks() -> std::int_fast16_t; auto ticks() -> std::int_fast16_t;
// Not copyable or movable.
RelativeWheel(const RelativeWheel&) = delete;
RelativeWheel& operator=(const RelativeWheel&) = delete;
private: private:
TouchWheel* touch_; TouchWheel* touch_;
bool is_enabled_;
bool is_clicking_; bool is_clicking_;
bool was_clicking_; bool was_clicking_;
bool is_first_read_; bool is_first_read_;

@ -15,6 +15,7 @@ namespace drivers {
RelativeWheel::RelativeWheel(TouchWheel* touch) RelativeWheel::RelativeWheel(TouchWheel* touch)
: touch_(touch), : touch_(touch),
is_enabled_(true),
is_clicking_(false), is_clicking_(false),
was_clicking_(false), was_clicking_(false),
is_first_read_(true), 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 { auto RelativeWheel::is_clicking() -> bool {
if (!is_enabled_) {
return false;
}
bool ret = is_clicking_; bool ret = is_clicking_;
is_clicking_ = 0; is_clicking_ = 0;
return ret; return ret;
} }
auto RelativeWheel::ticks() -> std::int_fast16_t { auto RelativeWheel::ticks() -> std::int_fast16_t {
int_fast16_t t = ticks_; if (!is_enabled_) {
if (t != 0) { return 0;
ESP_LOGI("teeks", "ticks %d", t);
} }
int_fast16_t t = ticks_;
ticks_ = 0; ticks_ = 0;
return t; return t;
} }

@ -109,7 +109,7 @@ void LvglMain(std::weak_ptr<drivers::RelativeWheel> weak_touch_wheel,
auto StartLvgl(std::weak_ptr<drivers::RelativeWheel> touch_wheel, auto StartLvgl(std::weak_ptr<drivers::RelativeWheel> touch_wheel,
std::weak_ptr<drivers::Display> display) -> void { std::weak_ptr<drivers::Display> display) -> void {
tasks::StartPersistent<tasks::Type::kUi>( tasks::StartPersistent<tasks::Type::kUi>(
[=]() { LvglMain(touch_wheel, display); }); 0, [=]() { LvglMain(touch_wheel, display); });
} }
} // namespace ui } // namespace ui

@ -177,6 +177,7 @@ auto TrackBrowser::AddResults(
text = "[ no data ]"; text = "[ no data ]";
} }
lv_obj_t* item = lv_list_add_btn(list_, NULL, text->c_str()); 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_click_cb, LV_EVENT_CLICKED, this);
lv_obj_add_event_cb(item, item_select_cb, LV_EVENT_FOCUSED, this); lv_obj_add_event_cb(item, item_select_cb, LV_EVENT_FOCUSED, this);

@ -97,6 +97,7 @@ void UiState::PopScreen() {
void UiState::react(const system_fsm::KeyLockChanged& ev) { void UiState::react(const system_fsm::KeyLockChanged& ev) {
sDisplay->SetDisplayOn(ev.falling); sDisplay->SetDisplayOn(ev.falling);
sRelativeWheel->SetEnabled(ev.falling);
} }
void UiState::react(const system_fsm::BatteryPercentChanged&) { void UiState::react(const system_fsm::BatteryPercentChanged&) {

@ -66,15 +66,15 @@ auto TopBar::Update(const State& state) -> void {
} }
if (state.battery_percent >= 95) { 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) { } 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) { } 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) { } else if (state.battery_percent >= 10) {
lv_label_set_text(battery_, LV_SYMBOL_BATTERY_3); lv_label_set_text(battery_, ">10");
} else { } else {
lv_label_set_text(battery_, LV_SYMBOL_BATTERY_EMPTY); lv_label_set_text(battery_, "0");
} }
} }

Loading…
Cancel
Save