More performance and usability tweaks
- pin ui and decoder to opposite cores - disable touch wheel when controls are locked
This commit is contained in:
@@ -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_;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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&) {
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user