summaryrefslogtreecommitdiff
path: root/src/displayapp/screens/Tile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/displayapp/screens/Tile.cpp')
-rw-r--r--src/displayapp/screens/Tile.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/displayapp/screens/Tile.cpp b/src/displayapp/screens/Tile.cpp
index ec36af38..d5d6cb80 100644
--- a/src/displayapp/screens/Tile.cpp
+++ b/src/displayapp/screens/Tile.cpp
@@ -6,15 +6,17 @@ using namespace Pinetime::Applications::Screens;
namespace {
static void lv_update_task(struct _lv_task_t* task) {
- auto user_data = static_cast<Tile*>(task->user_data);
+ auto* user_data = static_cast<Tile*>(task->user_data);
user_data->UpdateScreen();
}
static void event_handler(lv_obj_t* obj, lv_event_t event) {
+ if (event != LV_EVENT_VALUE_CHANGED) return;
+
Tile* screen = static_cast<Tile*>(obj->user_data);
- uint32_t* eventDataPtr = (uint32_t*) lv_event_get_data();
+ auto* eventDataPtr = (uint32_t*) lv_event_get_data();
uint32_t eventData = *eventDataPtr;
- screen->OnObjectEvent(obj, event, eventData);
+ screen->OnValueChangedEvent(obj, eventData);
}
}
@@ -107,7 +109,7 @@ Tile::Tile(uint8_t screenID,
lv_obj_set_pos(backgroundLabel, 0, 0);
lv_label_set_text_static(backgroundLabel, "");
- taskUpdate = lv_task_create(lv_update_task, 500000, LV_TASK_PRIO_MID, this);
+ taskUpdate = lv_task_create(lv_update_task, 5000, LV_TASK_PRIO_MID, this);
}
Tile::~Tile() {
@@ -124,9 +126,9 @@ bool Tile::Refresh() {
return running;
}
-void Tile::OnObjectEvent(lv_obj_t* obj, lv_event_t event, uint32_t buttonId) {
- if (event == LV_EVENT_VALUE_CHANGED) {
- app->StartApp(apps[buttonId], DisplayApp::FullRefreshDirections::Up);
- running = false;
- }
+void Tile::OnValueChangedEvent(lv_obj_t* obj, uint32_t buttonId) {
+ if(obj != btnm1) return;
+
+ app->StartApp(apps[buttonId], DisplayApp::FullRefreshDirections::Up);
+ running = false;
}