2020-02-16 18:32:36 +01:00
|
|
|
#include <libs/lvgl/src/lv_core/lv_obj.h>
|
|
|
|
#include <libs/lvgl/src/lv_font/lv_font.h>
|
|
|
|
#include <libs/lvgl/lvgl.h>
|
|
|
|
#include "Tile.h"
|
|
|
|
#include <DisplayApp/DisplayApp.h>
|
2020-07-04 13:58:15 +02:00
|
|
|
#include "Symbols.h"
|
|
|
|
#include "../../Version.h"
|
2020-02-16 18:32:36 +01:00
|
|
|
|
|
|
|
using namespace Pinetime::Applications::Screens;
|
|
|
|
|
|
|
|
extern lv_font_t jetbrains_mono_bold_20;
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-07-04 13:58:15 +02:00
|
|
|
static const char * btnm_map1[] = {Symbols::heartBeat, Symbols::shoe, Symbols::clock, "\n", Symbols::info, Symbols::list, Symbols::sun, ""};
|
2020-02-16 18:32:36 +01:00
|
|
|
|
2020-02-23 13:44:39 +01:00
|
|
|
Tile::Tile(DisplayApp* app) : Screen(app) {
|
2020-02-26 20:49:26 +01:00
|
|
|
modal.reset(new Modal(app));
|
2020-02-16 18:32:36 +01:00
|
|
|
|
2020-03-01 16:01:53 +01:00
|
|
|
btnm1 = lv_btnm_create(lv_scr_act(), NULL);
|
2020-02-16 18:32:36 +01:00
|
|
|
lv_btnm_set_map(btnm1, btnm_map1);
|
|
|
|
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) {
|
2020-02-23 13:44:39 +01:00
|
|
|
auto* tile = static_cast<Tile*>(obj->user_data);
|
2020-02-23 16:14:03 +01:00
|
|
|
if(event == LV_EVENT_VALUE_CHANGED) {
|
|
|
|
switch(buttonId) {
|
|
|
|
case 0:
|
2020-02-26 20:49:26 +01:00
|
|
|
tile->StartMeterApp();
|
|
|
|
break;
|
2020-02-23 16:14:03 +01:00
|
|
|
case 1:
|
2020-02-26 20:49:26 +01:00
|
|
|
tile->StartGaugeApp();
|
|
|
|
break;
|
2020-02-23 16:14:03 +01:00
|
|
|
case 2:
|
|
|
|
tile->StartClockApp();
|
|
|
|
break;
|
|
|
|
case 3:
|
2020-03-28 19:05:28 +01:00
|
|
|
char versionStr[20];
|
|
|
|
sprintf(versionStr, "VERSION: %d.%d.%d", Version::Major(), Version::Minor(), Version::Patch());
|
|
|
|
modal->Show(versionStr);
|
2020-03-01 17:20:27 +01:00
|
|
|
break;
|
2020-02-23 16:14:03 +01:00
|
|
|
case 4:
|
2020-03-22 12:03:17 +01:00
|
|
|
tile->StartSysInfoApp();
|
2020-03-15 18:03:11 +01:00
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
tile->StartBrightnessApp();
|
2020-02-23 16:14:03 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2020-02-16 18:32:36 +01:00
|
|
|
clickCount++;
|
|
|
|
}
|
|
|
|
}
|
2020-02-23 13:44:39 +01:00
|
|
|
|
|
|
|
bool Tile::OnButtonPushed() {
|
|
|
|
app->StartApp(DisplayApp::Apps::Clock);
|
|
|
|
running = false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:14:03 +01:00
|
|
|
void Tile::StartClockApp() {
|
2020-02-23 13:44:39 +01:00
|
|
|
app->StartApp(DisplayApp::Apps::Clock);
|
|
|
|
running = false;
|
|
|
|
}
|
2020-02-23 16:14:03 +01:00
|
|
|
|
2020-03-22 12:03:17 +01:00
|
|
|
void Tile::StartSysInfoApp() {
|
|
|
|
app->StartApp(DisplayApp::Apps::SysInfo);
|
2020-02-23 16:14:03 +01:00
|
|
|
running = false;
|
|
|
|
}
|
2020-02-26 20:49:26 +01:00
|
|
|
|
2020-03-15 18:03:11 +01:00
|
|
|
void Tile::StartBrightnessApp() {
|
|
|
|
app->StartApp(DisplayApp::Apps::Brightness);
|
|
|
|
running = false;
|
|
|
|
}
|
|
|
|
|
2020-02-26 20:49:26 +01:00
|
|
|
void Tile::StartMeterApp() {
|
|
|
|
app->StartApp(DisplayApp::Apps::Meter);
|
|
|
|
running = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Tile::StartGaugeApp() {
|
2020-07-11 22:37:28 +02:00
|
|
|
app->StartApp(DisplayApp::Apps::Music);
|
2020-02-26 20:49:26 +01:00
|
|
|
running = false;
|
|
|
|
}
|
|
|
|
|