2020-02-16 18:32:36 +01:00
|
|
|
#include "Tile.h"
|
2020-11-15 16:49:36 +01:00
|
|
|
#include "../DisplayApp.h"
|
2020-02-16 18:32:36 +01:00
|
|
|
|
|
|
|
using namespace Pinetime::Applications::Screens;
|
|
|
|
|
|
|
|
static void event_handler(lv_obj_t * obj, lv_event_t event) {
|
|
|
|
Tile* screen = static_cast<Tile *>(obj->user_data);
|
2020-02-23 16:14:03 +01:00
|
|
|
uint32_t* eventDataPtr = (uint32_t*) lv_event_get_data();
|
|
|
|
uint32_t eventData = *eventDataPtr;
|
|
|
|
screen->OnObjectEvent(obj, event, eventData);
|
2020-02-16 18:32:36 +01:00
|
|
|
}
|
|
|
|
|
2021-02-24 20:40:24 +01:00
|
|
|
Tile::Tile(uint8_t screenID, DisplayApp* app, Controllers::Settings& settingsController, std::array<Applications, 6>& applications) : Screen(app) {
|
|
|
|
|
|
|
|
settingsController.SetAppMenu(screenID);
|
|
|
|
|
2020-08-14 09:46:37 +02:00
|
|
|
for(int i = 0, appIndex = 0; i < 8; i++) {
|
|
|
|
if(i == 3) btnm_map1[i] = "\n";
|
|
|
|
else if(i == 7) btnm_map1[i] = "";
|
|
|
|
else {
|
|
|
|
btnm_map1[i] = applications[appIndex].icon;
|
|
|
|
apps[appIndex] = applications[appIndex].application;
|
|
|
|
appIndex++;
|
|
|
|
}
|
|
|
|
}
|
2020-02-16 18:32:36 +01:00
|
|
|
|
2021-01-28 18:13:28 +01:00
|
|
|
btnm1 = lv_btnmatrix_create(lv_scr_act(), nullptr);
|
|
|
|
lv_btnmatrix_set_map(btnm1, btnm_map1);
|
2020-02-16 18:32:36 +01:00
|
|
|
lv_obj_set_size(btnm1, LV_HOR_RES, LV_VER_RES);
|
|
|
|
|
|
|
|
btnm1->user_data = this;
|
|
|
|
lv_obj_set_event_cb(btnm1, event_handler);
|
|
|
|
}
|
|
|
|
|
|
|
|
Tile::~Tile() {
|
|
|
|
lv_obj_clean(lv_scr_act());
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:14:03 +01:00
|
|
|
bool Tile::Refresh() {
|
2020-02-23 13:44:39 +01:00
|
|
|
return running;
|
2020-02-16 18:32:36 +01:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:14:03 +01:00
|
|
|
void Tile::OnObjectEvent(lv_obj_t *obj, lv_event_t event, uint32_t buttonId) {
|
|
|
|
if(event == LV_EVENT_VALUE_CHANGED) {
|
2020-08-14 09:46:37 +02:00
|
|
|
app->StartApp(apps[buttonId]);
|
|
|
|
running = false;
|
2020-02-16 18:32:36 +01:00
|
|
|
}
|
|
|
|
}
|
2020-02-23 13:44:39 +01:00
|
|
|
|
|
|
|
bool Tile::OnButtonPushed() {
|
2020-08-14 09:46:37 +02:00
|
|
|
app->StartApp(Apps::Clock);
|
2020-02-23 13:44:39 +01:00
|
|
|
running = false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-02-26 20:49:26 +01:00
|
|
|
|