Merge branch 'develop' into recovery-firmware

# Conflicts:
#	src/CMakeLists.txt
#	src/displayapp/DisplayApp.h
#	src/systemtask/SystemTask.cpp
#	src/systemtask/SystemTask.h
This commit is contained in:
Jean-François Milants
2021-03-07 08:44:14 +01:00
559 changed files with 33795 additions and 100474 deletions

View File

@@ -2,6 +2,6 @@
namespace Pinetime {
namespace Applications {
enum class Apps {None, Launcher, Clock, SysInfo, Meter, Gauge, Brightness, Music, FirmwareValidation, Paint, Paddle, Notifications, Twos, HeartRate, Navigation};
enum class Apps {None, Launcher, Clock, SysInfo, Meter, Brightness, Music, FirmwareValidation, Paint, Paddle, Notifications, Twos, HeartRate, Navigation};
}
}

View File

@@ -10,7 +10,6 @@
#include "displayapp/screens/Clock.h"
#include "displayapp/screens/FirmwareUpdate.h"
#include "displayapp/screens/FirmwareValidation.h"
#include "displayapp/screens/Gauge.h"
#include "displayapp/screens/InfiniPaint.h"
#include "displayapp/screens/Paddle.h"
#include "displayapp/screens/Meter.h"
@@ -47,7 +46,6 @@ DisplayApp::DisplayApp(Drivers::St7789 &lcd, Components::LittleVgl &lvgl, Driver
heartRateController{heartRateController} {
msgQueue = xQueueCreate(queueSize, itemSize);
onClockApp = true;
modal.reset(new Screens::Modal(this));
}
void DisplayApp::Start() {
@@ -111,9 +109,6 @@ void DisplayApp::Refresh() {
brightnessController.Restore();
state = States::Running;
break;
case Messages::UpdateDateTime:
// modal->Show();
break;
case Messages::UpdateBleConnection:
// clockScreen.SetBleConnectionState(bleController.IsConnected() ? Screens::Clock::BleConnectionStates::Connected : Screens::Clock::BleConnectionStates::NotConnected);
break;
@@ -125,7 +120,7 @@ void DisplayApp::Refresh() {
currentScreen.reset(nullptr);
lvgl.SetFullRefresh(Components::LittleVgl::FullRefreshDirections::Up);
onClockApp = false;
currentScreen.reset(new Screens::Notifications(this, notificationManager, Screens::Notifications::Modes::Preview));
currentScreen.reset(new Screens::Notifications(this, notificationManager, systemTask.nimble().alertService(), Screens::Notifications::Modes::Preview));
}
}
break;
@@ -205,18 +200,16 @@ void DisplayApp::RunningState() {
currentScreen.reset(new Screens::Clock(this, dateTimeController, batteryController, bleController, notificationManager, heartRateController));
onClockApp = true;
break;
// case Apps::Test: currentScreen.reset(new Screens::Message(this)); break;
case Apps::SysInfo: currentScreen.reset(new Screens::SystemInfo(this, dateTimeController, batteryController, brightnessController, bleController, watchdog)); break;
case Apps::Meter: currentScreen.reset(new Screens::Meter(this)); break;
case Apps::Twos: currentScreen.reset(new Screens::Twos(this)); break;
case Apps::Gauge: currentScreen.reset(new Screens::Gauge(this)); break;
case Apps::Paint: currentScreen.reset(new Screens::InfiniPaint(this, lvgl)); break;
case Apps::Paddle: currentScreen.reset(new Screens::Paddle(this, lvgl)); break;
case Apps::Brightness : currentScreen.reset(new Screens::Brightness(this, brightnessController)); break;
case Apps::Music : currentScreen.reset(new Screens::Music(this, systemTask.nimble().music())); break;
case Apps::Navigation : currentScreen.reset(new Screens::Navigation(this, systemTask.nimble().navigation())); break;
case Apps::FirmwareValidation: currentScreen.reset(new Screens::FirmwareValidation(this, validator)); break;
case Apps::Notifications: currentScreen.reset(new Screens::Notifications(this, notificationManager, Screens::Notifications::Modes::Normal)); break;
case Apps::Notifications: currentScreen.reset(new Screens::Notifications(this, notificationManager, systemTask.nimble().alertService(), Screens::Notifications::Modes::Normal)); break;
case Apps::HeartRate: currentScreen.reset(new Screens::HeartRate(this, heartRateController)); break;
}
nextApp = Apps::None;

View File

@@ -9,7 +9,7 @@
#include "TouchEvents.h"
#include "components/brightness/BrightnessController.h"
#include "components/firmwarevalidator/FirmwareValidator.h"
#include "displayapp/screens/Modal.h"
#include "displayapp/screens/Screen.h"
#include "Messages.h"
namespace Pinetime {
@@ -83,7 +83,6 @@ namespace Pinetime {
Apps nextApp = Apps::None;
bool onClockApp = false; // TODO find a better way to know that we should handle gestures and button differently for the Clock app.
Controllers::BrightnessController brightnessController;
std::unique_ptr<Screens::Modal> modal;
Pinetime::Controllers::NotificationManager& notificationManager;
Pinetime::Controllers::FirmwareValidator validator;
TouchModes touchMode = TouchModes::Gestures;

View File

@@ -15,7 +15,6 @@
#include "drivers/Cst816s.h"
#include <date/date.h>
#include "displayapp/screens/Clock.h"
#include "displayapp/screens/Modal.h"
#include <drivers/Watchdog.h>
#include "TouchEvents.h"
#include "Apps.h"

View File

@@ -1,4 +1,5 @@
#include "LittleVgl.h"
#include "lv_pinetime_theme.h"
#include <FreeRTOS.h>
#include <task.h>
@@ -8,11 +9,6 @@
using namespace Pinetime::Components;
extern "C" {
LV_FONT_DECLARE(jetbrains_mono_extrabold_compressed)
LV_FONT_DECLARE(jetbrains_mono_bold_20)
}
lv_style_t* LabelBigStyle = nullptr;
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p) {
@@ -210,620 +206,15 @@ bool LittleVgl::GetTouchPadInfo(lv_indev_data_t *ptr) {
}
void LittleVgl::InitTheme() {
uint16_t i;
lv_style_t ** style_p = (lv_style_t **)&theme.style;
for(i = 0; i < LV_THEME_STYLE_COUNT; i++) {
*style_p = &def;
style_p++;
}
InitBaseTheme();
InitThemeContainer();
InitThemeButton();
InitThemeLabel();
InitThemeLine();
InitThemeLed();
InitThemeImage();
InitThemeBar();
InitThemeSlider();
InitThemeSwitch();
InitThemeMeter();
InitThemeGauge();
InitThemeArc();
InitThemePreload();
InitThemeChart();
InitThemeCalendar();
InitThemeCheckBox();
InitThemeButtonMatrix();
InitThemeKnob();
InitThemeMessageBox();
InitThemePage();
InitThemeTextArea();
InitThemeSpinBox();
InitThemeList();
InitThemeDropDownList();
InitThemeRoller();
InitThemeTabView();
InitThemeTileView();
InitThemeTable();
InitThemeWindow();
lv_theme_t * th = lv_pinetime_theme_init(
LV_COLOR_WHITE, LV_COLOR_SILVER,
0,
&jetbrains_mono_bold_20,
&jetbrains_mono_bold_20,
&jetbrains_mono_bold_20,
&jetbrains_mono_bold_20);
lv_theme_set_act(th);
lv_theme_set_current(&theme);
}
void LittleVgl::InitBaseTheme() {
if(font == nullptr) font = &jetbrains_mono_bold_20;
lv_style_copy(&def, &lv_style_plain); /*Initialize the default style*/
def.text.font = font;
lv_style_copy(&bg, &lv_style_plain);
bg.body.main_color = LV_COLOR_BLACK;
bg.body.grad_color = LV_COLOR_BLACK;
bg.text.color = LV_COLOR_WHITE;
bg.text.font = font;
bg.image.color = LV_COLOR_WHITE;
lv_style_copy(&scr, &bg);
scr.body.padding.bottom = 0;
scr.body.padding.top = 0;
scr.body.padding.left = 0;
scr.body.padding.right = 0;
lv_style_copy(&sb, &def);
sb.body.main_color = lv_color_hsv_to_rgb(hue, 30, 60);
sb.body.grad_color = lv_color_hsv_to_rgb(hue, 30, 60);
sb.body.border.width = 0;
sb.body.padding.inner = LV_DPI / 20;
sb.body.padding.left = 0;
sb.body.padding.right = 0;
sb.body.padding.top = 0;
sb.body.padding.bottom = 0;
sb.body.radius = LV_DPI / 30;
sb.body.opa = LV_OPA_COVER;
lv_style_copy(&panel, &bg);
panel.body.main_color = lv_color_hsv_to_rgb(hue, 11, 18);
panel.body.grad_color = lv_color_hsv_to_rgb(hue, 11, 18);
panel.body.radius = LV_DPI / 20;
panel.body.border.color = lv_color_hsv_to_rgb(hue, 10, 25);
panel.body.border.width = 1;
panel.body.border.opa = LV_OPA_COVER;
panel.body.padding.left = LV_DPI / 10;
panel.body.padding.right = LV_DPI / 10;
panel.body.padding.top = LV_DPI / 10;
panel.body.padding.bottom = LV_DPI / 10;
panel.line.color = lv_color_hsv_to_rgb(hue, 20, 40);
panel.line.width = 1;
theme.style.scr = &scr;
theme.style.bg = &bg;
theme.style.panel = &def;
}
void LittleVgl::InitThemeContainer() {
theme.style.cont = &panel;
}
void LittleVgl::InitThemeButton() {
lv_style_copy(&btn_rel, &def);
btn_rel.body.main_color = lv_color_hsv_to_rgb(hue, 10, 40);
btn_rel.body.grad_color = lv_color_hsv_to_rgb(hue, 10, 20);
btn_rel.body.border.color = lv_color_hex3(0x111);
btn_rel.body.border.width = 1;
btn_rel.body.border.opa = LV_OPA_70;
btn_rel.body.padding.left = LV_DPI / 4;
btn_rel.body.padding.right = LV_DPI / 4;
btn_rel.body.padding.top = LV_DPI / 8;
btn_rel.body.padding.bottom = LV_DPI / 8;
btn_rel.body.shadow.type = LV_SHADOW_BOTTOM;
btn_rel.body.shadow.color = lv_color_hex3(0x111);
btn_rel.body.shadow.width = LV_DPI / 30;
btn_rel.text.color = lv_color_hex3(0xeee);
btn_rel.image.color = lv_color_hex3(0xeee);
lv_style_copy(&btn_pr, &btn_rel);
btn_pr.body.main_color = lv_color_hsv_to_rgb(hue, 10, 30);
btn_pr.body.grad_color = lv_color_hsv_to_rgb(hue, 10, 10);
lv_style_copy(&btn_tgl_rel, &btn_rel);
btn_tgl_rel.body.main_color = lv_color_hsv_to_rgb(hue, 10, 20);
btn_tgl_rel.body.grad_color = lv_color_hsv_to_rgb(hue, 10, 40);
btn_tgl_rel.body.shadow.width = LV_DPI / 40;
btn_tgl_rel.text.color = lv_color_hex3(0xddd);
btn_tgl_rel.image.color = lv_color_hex3(0xddd);
lv_style_copy(&btn_tgl_pr, &btn_rel);
btn_tgl_pr.body.main_color = lv_color_hsv_to_rgb(hue, 10, 10);
btn_tgl_pr.body.grad_color = lv_color_hsv_to_rgb(hue, 10, 30);
btn_tgl_pr.body.shadow.width = LV_DPI / 30;
btn_tgl_pr.text.color = lv_color_hex3(0xddd);
btn_tgl_pr.image.color = lv_color_hex3(0xddd);
lv_style_copy(&btn_ina, &btn_rel);
btn_ina.body.main_color = lv_color_hsv_to_rgb(hue, 10, 20);
btn_ina.body.grad_color = lv_color_hsv_to_rgb(hue, 10, 20);
btn_ina.body.shadow.width = 0;
btn_ina.text.color = lv_color_hex3(0xaaa);
btn_ina.image.color = lv_color_hex3(0xaaa);
theme.style.btn.rel = &btn_rel;
theme.style.btn.pr = &btn_pr;
theme.style.btn.tgl_rel = &btn_tgl_rel;
theme.style.btn.tgl_pr = &btn_tgl_pr;
theme.style.btn.ina = &btn_ina;
}
void LittleVgl::InitThemeLabel() {
lv_style_copy(&prim, &bg);
prim.text.color = lv_color_hsv_to_rgb(hue, 5, 95);
lv_style_copy(&labelBigStyle, &prim);
labelBigStyle.text.font = &jetbrains_mono_extrabold_compressed;
LabelBigStyle = &(this->labelBigStyle);
lv_style_copy(&sec, &bg);
sec.text.color = lv_color_hsv_to_rgb(hue, 15, 65);
lv_style_copy(&hint, &bg);
hint.text.color = lv_color_hsv_to_rgb(hue, 20, 55);
theme.style.label.prim = &prim;
theme.style.label.sec = &sec;
theme.style.label.hint = &hint;
}
void LittleVgl::InitThemeLine() {
theme.style.line.decor = &def;
}
void LittleVgl::InitThemeLed() {
lv_style_copy(&led, &def);
led.body.shadow.width = LV_DPI / 10;
led.body.radius = LV_RADIUS_CIRCLE;
led.body.border.width = LV_DPI / 30;
led.body.border.opa = LV_OPA_30;
led.body.main_color = lv_color_hsv_to_rgb(hue, 100, 100);
led.body.grad_color = lv_color_hsv_to_rgb(hue, 100, 40);
led.body.border.color = lv_color_hsv_to_rgb(hue, 60, 60);
led.body.shadow.color = lv_color_hsv_to_rgb(hue, 100, 100);
theme.style.led = &led;
}
void LittleVgl::InitThemeImage() {
theme.style.img.light = &def;
theme.style.img.dark = &def;
}
void LittleVgl::InitThemeBar() {
lv_style_copy(&bar_bg, &panel);
bar_bg.body.padding.left = LV_DPI / 16;
bar_bg.body.padding.right = LV_DPI / 16;
bar_bg.body.padding.top = LV_DPI / 16;
bar_bg.body.padding.bottom = LV_DPI / 16;
bar_bg.body.radius = LV_RADIUS_CIRCLE;
lv_style_copy(&bar_indic, &def);
bar_indic.body.main_color = lv_color_hsv_to_rgb(hue, 80, 70);
bar_indic.body.grad_color = lv_color_hsv_to_rgb(hue, 80, 70);
bar_indic.body.border.color = lv_color_hsv_to_rgb(hue, 20, 15);
bar_indic.body.border.width = 1;
bar_indic.body.border.opa = LV_OPA_COVER;
bar_indic.body.radius = LV_RADIUS_CIRCLE;
bar_indic.body.padding.left = 0;
bar_indic.body.padding.right = 0;
bar_indic.body.padding.top = 0;
bar_indic.body.padding.bottom = 0;
theme.style.bar.bg = &bar_bg;
theme.style.bar.indic = &bar_indic;
}
void LittleVgl::InitThemeSlider() {
lv_style_copy(&slider_knob, theme.style.btn.rel);
slider_knob.body.radius = LV_RADIUS_CIRCLE;
theme.style.slider.bg = theme.style.bar.bg;
theme.style.slider.indic = theme.style.bar.indic;
theme.style.slider.knob = &slider_knob;
}
void LittleVgl::InitThemeSwitch() {
theme.style.sw.bg = theme.style.bar.bg;
theme.style.sw.indic = theme.style.bar.indic;
theme.style.sw.knob_off = theme.style.slider.knob;
theme.style.sw.knob_on = theme.style.slider.knob;
}
void LittleVgl::InitThemeMeter() {
static lv_style_t lmeter_bg;
lv_style_copy(&lmeter_bg, &def);
lmeter_bg.body.main_color = lv_color_hsv_to_rgb(hue, 10, 70);
lmeter_bg.body.grad_color = lv_color_hsv_to_rgb(hue, 95, 90);
lmeter_bg.body.padding.left = LV_DPI / 10; /*Scale line length*/
lmeter_bg.body.padding.inner = LV_DPI / 10; /*Text padding*/
lmeter_bg.body.border.color = lv_color_hex3(0x333);
lmeter_bg.line.color = lv_color_hex3(0x555);
lmeter_bg.line.width = 1;
lmeter_bg.text.color = lv_color_hex3(0xddd);
theme.style.lmeter = &lmeter_bg;
}
void LittleVgl::InitThemeGauge() {
static lv_style_t gauge_bg;
lv_style_copy(&gauge_bg, &def);
gauge_bg.body.main_color = lv_color_hsv_to_rgb(hue, 10, 70);
gauge_bg.body.grad_color = gauge_bg.body.main_color;
gauge_bg.line.color = lv_color_hsv_to_rgb(hue, 80, 75);
gauge_bg.line.width = 1;
gauge_bg.text.color = lv_color_hex3(0xddd);
theme.style.gauge = &gauge_bg;
}
void LittleVgl::InitThemeArc() {
lv_style_copy(&arc, &def);
arc.line.width = 8;
arc.line.color = lv_color_hsv_to_rgb(hue, 80, 70);
arc.line.rounded = 1;
/*For preloader*/
arc.body.border.width = 7;
arc.body.border.color = lv_color_hsv_to_rgb(hue, 11, 48);
arc.body.padding.left = 1;
arc.body.padding.right = 1;
arc.body.padding.top = 1;
arc.body.padding.bottom = 1;
theme.style.arc = &arc;
}
void LittleVgl::InitThemePreload() {
// theme.style.preload = theme.style.arc;
}
void LittleVgl::InitThemeChart() {
theme.style.chart = &panel;
}
void LittleVgl::InitThemeCalendar() {
lv_style_copy(&cal_bg, &bg);
cal_bg.body.main_color = lv_color_hsv_to_rgb(hue, 10, 40);
cal_bg.body.grad_color = lv_color_hsv_to_rgb(hue, 10, 40);
cal_bg.body.border.color = lv_color_hex3(0x333);
cal_bg.body.border.width = 1;
cal_bg.body.radius = LV_DPI / 20;
cal_bg.body.padding.left = LV_DPI / 10;
cal_bg.body.padding.right = LV_DPI / 10;
cal_bg.body.padding.top = LV_DPI / 10;
cal_bg.body.padding.bottom = LV_DPI / 10;
lv_style_copy(&cal_header, &bg);
cal_header.body.main_color = lv_color_hsv_to_rgb(hue, 10, 20);
cal_header.body.grad_color = lv_color_hsv_to_rgb(hue, 10, 20);
cal_header.body.radius = 0;
cal_header.body.border.width = 1;
cal_header.body.border.color = lv_color_hex3(0x333);
cal_header.body.padding.left = LV_DPI / 10;
cal_header.body.padding.right = LV_DPI / 10;
cal_header.body.padding.top = LV_DPI / 10;
cal_header.body.padding.bottom = LV_DPI / 10;
lv_style_copy(&week_box, &panel);
week_box.body.main_color = lv_color_hsv_to_rgb(hue, 30, 45);
week_box.body.grad_color = lv_color_hsv_to_rgb(hue, 30, 45);
week_box.body.radius = LV_DPI / 20;
week_box.body.border.width = 1;
week_box.body.padding.left = LV_DPI / 20;
week_box.body.padding.right = LV_DPI / 20;
week_box.body.padding.top = LV_DPI / 25;
week_box.body.padding.bottom = LV_DPI / 25;
lv_style_copy(&today_box, &week_box);
today_box.body.main_color = lv_color_hsv_to_rgb(hue, 80, 70);
today_box.body.grad_color = lv_color_hsv_to_rgb(hue, 80, 70);
today_box.body.radius = LV_DPI / 20;
today_box.body.padding.left = LV_DPI / 14;
today_box.body.padding.right = LV_DPI / 14;
today_box.body.padding.top = LV_DPI / 14;
today_box.body.padding.bottom = LV_DPI / 14;
lv_style_copy(&highlighted_days, &bg);
highlighted_days.text.color = lv_color_hsv_to_rgb(hue, 40, 80);
lv_style_copy(&ina_days, &bg);
ina_days.text.color = lv_color_hsv_to_rgb(hue, 0, 60);
theme.style.calendar.bg = &cal_bg;
theme.style.calendar.header = &cal_header;
theme.style.calendar.week_box = &week_box;
theme.style.calendar.today_box = &today_box;
theme.style.calendar.highlighted_days = &highlighted_days;
theme.style.calendar.day_names = &cal_bg;
theme.style.calendar.inactive_days = &ina_days;
}
void LittleVgl::InitThemeCheckBox() {
lv_style_copy(&rel, &def);
rel.body.radius = LV_DPI / 20;
rel.body.main_color = lv_color_hsv_to_rgb(hue, 10, 95);
rel.body.grad_color = lv_color_hsv_to_rgb(hue, 10, 95);
rel.body.border.color = lv_color_hsv_to_rgb(hue, 10, 50);
rel.body.border.width = 2;
;
lv_style_copy(&pr, &rel);
pr.body.main_color = lv_color_hsv_to_rgb(hue, 10, 80);
pr.body.grad_color = lv_color_hsv_to_rgb(hue, 10, 80);
pr.body.border.color = lv_color_hsv_to_rgb(hue, 10, 20);
pr.body.border.width = 1;
;
lv_style_copy(&tgl_rel, &rel);
tgl_rel.body.main_color = lv_color_hsv_to_rgb(hue, 80, 90);
tgl_rel.body.grad_color = lv_color_hsv_to_rgb(hue, 80, 90);
tgl_rel.body.border.color = lv_color_hsv_to_rgb(hue, 80, 50);
lv_style_copy(&tgl_pr, &tgl_rel);
tgl_pr.body.main_color = lv_color_hsv_to_rgb(hue, 80, 70);
tgl_pr.body.grad_color = lv_color_hsv_to_rgb(hue, 80, 70);
tgl_pr.body.border.color = lv_color_hsv_to_rgb(hue, 80, 30);
tgl_pr.body.border.width = 1;
;
lv_style_copy(&ina, &rel);
ina.body.main_color = lv_color_hex3(0x777);
ina.body.grad_color = lv_color_hex3(0x777);
ina.body.border.width = 0;
theme.style.cb.bg = &lv_style_transp;
theme.style.cb.box.rel = &rel;
theme.style.cb.box.pr = &pr;
theme.style.cb.box.tgl_rel = &tgl_rel;
theme.style.cb.box.tgl_pr = &tgl_pr;
theme.style.cb.box.ina = &def;
}
void LittleVgl::InitThemeButtonMatrix() {
lv_style_copy(&btnm_bg, theme.style.btn.rel);
btnm_bg.body.padding.left = 2;
btnm_bg.body.padding.right = 2;
btnm_bg.body.padding.top = 2;
btnm_bg.body.padding.bottom = 2;
btnm_bg.body.padding.inner = 0;
btnm_bg.body.border.width = 1;
lv_style_copy(&btnm_rel, theme.style.btn.rel);
btnm_rel.body.border.part = LV_BORDER_FULL | LV_BORDER_INTERNAL;
btnm_rel.body.border.width = 1;
btnm_rel.body.radius = 2;
lv_style_copy(&btnm_pr, theme.style.btn.pr);
btnm_pr.body.border.part = btnm_rel.body.border.part;
btnm_pr.body.border.width = btnm_rel.body.border.width;
btnm_pr.body.radius = btnm_rel.body.radius;
lv_style_copy(&btnm_tgl_rel, theme.style.btn.tgl_rel);
btnm_tgl_rel.body.border.part = btnm_rel.body.border.part;
btnm_tgl_rel.body.border.width = btnm_rel.body.border.width;
btnm_tgl_rel.body.radius = btnm_rel.body.radius;
lv_style_copy(&btnm_tgl_pr, theme.style.btn.pr);
btnm_tgl_pr.body.border.part = btnm_rel.body.border.part;
btnm_tgl_pr.body.border.width = btnm_rel.body.border.width;
btnm_tgl_pr.body.radius = btnm_rel.body.radius;
lv_style_copy(&btnm_ina, theme.style.btn.ina);
btnm_ina.body.border.part = btnm_rel.body.border.part;
btnm_ina.body.border.width = btnm_rel.body.border.width;
btnm_ina.body.radius = btnm_rel.body.radius;
theme.style.btnm.bg = &btnm_bg;
theme.style.btnm.btn.rel = &btnm_rel;
theme.style.btnm.btn.pr = &btnm_pr;
theme.style.btnm.btn.tgl_rel = &btnm_tgl_rel;
theme.style.btnm.btn.tgl_pr = &btnm_tgl_pr;
theme.style.btnm.btn.ina = &btnm_ina;
}
void LittleVgl::InitThemeKnob() {
theme.style.kb.bg = &bg;
theme.style.kb.btn.rel = theme.style.btn.rel;
theme.style.kb.btn.pr = theme.style.btn.pr;
theme.style.kb.btn.tgl_rel = theme.style.btn.tgl_rel;
theme.style.kb.btn.tgl_pr = theme.style.btn.tgl_pr;
theme.style.kb.btn.ina = theme.style.btn.ina;
}
void LittleVgl::InitThemeMessageBox() {
lv_style_copy(&mbox_bg, &bg);
mbox_bg.body.main_color = lv_color_hsv_to_rgb(hue, 30, 30);
mbox_bg.body.grad_color = lv_color_hsv_to_rgb(hue, 30, 30);
mbox_bg.body.border.color = lv_color_hsv_to_rgb(hue, 11, 20);
mbox_bg.body.border.width = 1;
mbox_bg.body.shadow.width = LV_DPI / 10;
mbox_bg.body.shadow.color = lv_color_hex3(0x222);
mbox_bg.body.radius = LV_DPI / 20;
theme.style.mbox.bg = &mbox_bg;
theme.style.mbox.btn.bg = &lv_style_transp;
theme.style.mbox.btn.rel = theme.style.btn.rel;
theme.style.mbox.btn.pr = theme.style.btn.pr;
}
void LittleVgl::InitThemePage() {
lv_style_copy(&page_scrl, &bg);
page_scrl.body.main_color = lv_color_hsv_to_rgb(hue, 10, 40);
page_scrl.body.grad_color = lv_color_hsv_to_rgb(hue, 10, 40);
page_scrl.body.border.color = lv_color_hex3(0x333);
page_scrl.body.border.width = 1;
page_scrl.body.radius = LV_DPI / 20;
theme.style.page.bg = &panel;
theme.style.page.scrl = &page_scrl;
theme.style.page.sb = &sb;
}
void LittleVgl::InitThemeTextArea() {
theme.style.ta.area = &panel;
theme.style.ta.oneline = &panel;
theme.style.ta.cursor = NULL;
theme.style.ta.sb = &def;
}
void LittleVgl::InitThemeSpinBox() {
theme.style.spinbox.bg = &panel;
theme.style.spinbox.cursor = theme.style.ta.cursor;
theme.style.spinbox.sb = theme.style.ta.sb;
}
void LittleVgl::InitThemeList() {
lv_style_copy(&list_bg, &panel);
list_bg.body.padding.top = 0;
list_bg.body.padding.bottom = 0;
list_bg.body.padding.left = 0;
list_bg.body.padding.right = 0;
list_bg.body.padding.inner = 0;
lv_style_copy(&list_btn_rel, &bg);
list_btn_rel.body.opa = LV_OPA_TRANSP;
list_btn_rel.body.border.part = LV_BORDER_BOTTOM;
list_btn_rel.body.border.color = lv_color_hsv_to_rgb(hue, 10, 5);
list_btn_rel.body.border.width = 1;
list_btn_rel.body.radius = LV_DPI / 10;
list_btn_rel.text.color = lv_color_hsv_to_rgb(hue, 5, 80);
list_btn_rel.image.color = lv_color_hsv_to_rgb(hue, 5, 80);
list_btn_rel.body.padding.top = LV_DPI / 6;
list_btn_rel.body.padding.bottom = LV_DPI / 6;
list_btn_rel.body.padding.left = LV_DPI / 8;
list_btn_rel.body.padding.right = LV_DPI / 8;
lv_style_copy(&list_btn_pr, theme.style.btn.pr);
list_btn_pr.body.main_color = lv_color_hsv_to_rgb(hue, 10, 5);
list_btn_pr.body.grad_color = lv_color_hsv_to_rgb(hue, 10, 5);
list_btn_pr.body.border.color = lv_color_hsv_to_rgb(hue, 10, 5);
list_btn_pr.body.border.width = 0;
list_btn_pr.body.padding.top = LV_DPI / 6;
list_btn_pr.body.padding.bottom = LV_DPI / 6;
list_btn_pr.body.padding.left = LV_DPI / 8;
list_btn_pr.body.padding.right = LV_DPI / 8;
list_btn_pr.text.color = lv_color_hsv_to_rgb(hue, 5, 80);
list_btn_pr.image.color = lv_color_hsv_to_rgb(hue, 5, 80);
lv_style_copy(&list_btn_tgl_rel, &list_btn_rel);
list_btn_tgl_rel.body.opa = LV_OPA_COVER;
list_btn_tgl_rel.body.main_color = lv_color_hsv_to_rgb(hue, 80, 70);
list_btn_tgl_rel.body.grad_color = lv_color_hsv_to_rgb(hue, 80, 70);
list_btn_tgl_rel.body.border.color = lv_color_hsv_to_rgb(hue, 60, 40);
list_btn_tgl_rel.body.radius = list_bg.body.radius;
lv_style_copy(&list_btn_tgl_pr, &list_btn_tgl_rel);
list_btn_tgl_pr.body.main_color = lv_color_hsv_to_rgb(hue, 80, 60);
list_btn_tgl_pr.body.grad_color = lv_color_hsv_to_rgb(hue, 80, 60);
theme.style.list.sb = &sb;
theme.style.list.bg = &list_bg;
theme.style.list.scrl = &lv_style_transp_tight;
theme.style.list.btn.rel = &list_btn_rel;
theme.style.list.btn.pr = &list_btn_pr;
theme.style.list.btn.tgl_rel = &list_btn_tgl_rel;
theme.style.list.btn.tgl_pr = &list_btn_tgl_pr;
theme.style.list.btn.ina = &def;
}
void LittleVgl::InitThemeDropDownList() {
lv_style_copy(&ddlist_bg, theme.style.btn.rel);
ddlist_bg.text.line_space = LV_DPI / 8;
ddlist_bg.body.padding.top = LV_DPI / 8;
ddlist_bg.body.padding.bottom = LV_DPI / 8;
ddlist_bg.body.padding.left = LV_DPI / 8;
ddlist_bg.body.padding.right = LV_DPI / 8;
ddlist_bg.body.radius = LV_DPI / 30;
lv_style_copy(&ddlist_sel, theme.style.btn.rel);
ddlist_sel.body.main_color = lv_color_hsv_to_rgb(hue, 20, 50);
ddlist_sel.body.grad_color = lv_color_hsv_to_rgb(hue, 20, 50);
ddlist_sel.body.radius = 0;
theme.style.ddlist.bg = &ddlist_bg;
theme.style.ddlist.sel = &ddlist_sel;
theme.style.ddlist.sb = &def;
}
void LittleVgl::InitThemeRoller() {
lv_style_t roller_bg;
lv_style_copy(&roller_bg, theme.style.ddlist.bg);
roller_bg.body.main_color = lv_color_hsv_to_rgb(hue, 10, 20);
roller_bg.body.grad_color = lv_color_hsv_to_rgb(hue, 10, 40);
roller_bg.text.color = lv_color_hsv_to_rgb(hue, 5, 70);
roller_bg.text.opa = LV_OPA_60;
theme.style.roller.bg = &roller_bg;
theme.style.roller.sel = theme.style.ddlist.sel;
}
void LittleVgl::InitThemeTabView() {
theme.style.tabview.bg = &bg;
theme.style.tabview.indic = &lv_style_transp;
theme.style.tabview.btn.bg = &lv_style_transp;
theme.style.tabview.btn.rel = theme.style.btn.rel;
theme.style.tabview.btn.pr = theme.style.btn.pr;
theme.style.tabview.btn.tgl_rel = theme.style.btn.tgl_rel;
theme.style.tabview.btn.tgl_pr = theme.style.btn.tgl_pr;
}
void LittleVgl::InitThemeTileView() {
theme.style.tileview.bg = &lv_style_transp_tight;
theme.style.tileview.scrl = &lv_style_transp_tight;
theme.style.tileview.sb = theme.style.page.sb;
}
void LittleVgl::InitThemeTable() {
lv_style_copy(&cell, &panel);
cell.body.radius = 0;
cell.body.border.width = 1;
cell.body.padding.left = LV_DPI / 12;
cell.body.padding.right = LV_DPI / 12;
cell.body.padding.top = LV_DPI / 12;
cell.body.padding.bottom = LV_DPI / 12;
theme.style.table.bg = &lv_style_transp_tight;
theme.style.table.cell = &cell;
}
void LittleVgl::InitThemeWindow() {
// lv_style_copy(&win_bg, &bg);
// win_bg.body.border.color = lv_color_hex3(0x333);
// win_bg.body.border.width = 1;
//
// lv_style_copy(&win_header, &win_bg);
// win_header.body.main_color = lv_color_hsv_to_rgb(hue, 10, 20);
// win_header.body.grad_color = lv_color_hsv_to_rgb(hue, 10, 20);
// win_header.body.radius = 0;
// win_header.body.padding.left = 0;
// win_header.body.padding.right = 0;
// win_header.body.padding.top = 0;
// win_header.body.padding.bottom = 0;
//
// lv_style_copy(&win_btn_pr, &def);
// win_btn_pr.body.main_color = lv_color_hsv_to_rgb(hue, 10, 10);
// win_btn_pr.body.grad_color = lv_color_hsv_to_rgb(hue, 10, 10);
// win_btn_pr.text.color = lv_color_hex3(0xaaa);
// win_btn_pr.image.color = lv_color_hex3(0xaaa);
//
// theme.style.win.bg = &win_bg;
// theme.style.win.sb = &sb;
// theme.style.win.header = &win_header;
// theme.style.win.content = &lv_style_transp;
// theme.style.win.btn.rel = &lv_style_transp;
// theme.style.win.btn.pr = &win_btn_pr;
}

View File

@@ -28,36 +28,7 @@ namespace Pinetime {
void InitDisplay();
void InitTouchpad();
void InitTheme();
void InitBaseTheme();
void InitThemeContainer();
void InitThemeButton();
void InitThemeLabel();
void InitThemeLine();
void InitThemeLed();
void InitThemeImage();
void InitThemeBar();
void InitThemeSlider();
void InitThemeSwitch();
void InitThemeMeter();
void InitThemeGauge();
void InitThemeArc();
void InitThemePreload();
void InitThemeChart();
void InitThemeCalendar();
void InitThemeCheckBox();
void InitThemeButtonMatrix();
void InitThemeKnob();
void InitThemeMessageBox();
void InitThemePage();
void InitThemeTextArea();
void InitThemeSpinBox();
void InitThemeList();
void InitThemeDropDownList();
void InitThemeRoller();
void InitThemeTabView();
void InitThemeTileView();
void InitThemeTable();
void InitThemeWindow();
Pinetime::Drivers::St7789& lcd;
Pinetime::Drivers::Cst816S& touchPanel;
@@ -70,35 +41,6 @@ namespace Pinetime {
lv_disp_drv_t disp_drv;
lv_point_t previousClick;
lv_style_t def;
lv_style_t scr, bg, sb, panel;
lv_font_t * font = nullptr;
uint16_t hue = 10;
lv_theme_t theme;
lv_style_t btn_rel, btn_pr, btn_tgl_rel, btn_tgl_pr, btn_ina;
lv_style_t labelBigStyle;
lv_style_t prim, sec, hint;
lv_style_t led;
lv_style_t bar_bg, bar_indic;
lv_style_t slider_knob;
lv_style_t arc;
lv_style_t cal_bg;
lv_style_t cal_header;
lv_style_t week_box;
lv_style_t today_box;
lv_style_t highlighted_days;
lv_style_t ina_days;
lv_style_t rel, pr, tgl_rel, tgl_pr, ina;
lv_style_t btnm_bg, btnm_rel, btnm_pr, btnm_tgl_rel, btnm_tgl_pr, btnm_ina;
lv_style_t mbox_bg;
lv_style_t page_scrl;
lv_style_t list_bg, list_btn_rel, list_btn_pr, list_btn_tgl_rel, list_btn_tgl_pr;
lv_style_t ddlist_bg, ddlist_sel;
lv_style_t cell;
lv_style_t win_bg;
lv_style_t win_header;
lv_style_t win_btn_pr;
bool firstTouch = true;
static constexpr uint8_t nbWriteLines = 4;
static constexpr uint16_t totalNbLines = 320;

View File

@@ -9,13 +9,13 @@
* Size : 20
* Bpp : 1 bit-per-pixel
* Do not enable font compression and horizontal subpixel hinting
* Load the file `JetBrainsMono-Bold.woff` and specify the following range : `0x20-0x7f, 0x410-0x44f`
* Add a 2nd font, load the file `FontAwesome5-Solid+Brands+Regular.woff` and specify the following range : `0xf293, 0xf294, 0xf244, 0xf240, 0xf242, 0xf243, 0xf241, 0xf54b, 0xf21e, 0xf1e6, 0xf54b, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf069, 0xf1fc, 0xf45d`
* Load the file `JetBrainsMono-Bold.tff` and specify the following range : `0x20-0x7f, 0x410-0x44f`
* Add a 2nd font, load the file `FontAwesome5-Solid+Brands+Regular.woff` and specify the following range : `0xf293, 0xf294, 0xf244, 0xf240, 0xf242, 0xf243, 0xf241, 0xf54b, 0xf21e, 0xf1e6, 0xf54b, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf069, 0xf1fc, 0xf45d, 0xf59f, 0xf5a0, 0xf029, 0xf027, 0xf028, 0xf6a9, 0xf04b, 0xf04c, 0xf048, 0xf051, 0xf095, 0xf3dd`
* Click on Convert, and download the file `jetbrains_mono_bold_20.c` and copy it in `src/DisplayApp/Fonts`
Add new symbols:
* Browse the [cheatsheet](https://fontawesome.com/cheatsheet/free/solid) and find your new symbols
* For each symbol, add its hex code (0xf641 for the 'Ad' icon, for example) to the *Range* list
* For each symbol, add its hex code (0xf641 for the 'Ad' icon, for example) to the *Range* list (Remember to keep this readme updated with newest range list)
* Convert this hex value into a UTF-8 code using [this site](http://www.ltg.ed.ac.uk/~richard/utf-8.cgi?input=f185&mode=hex)
* Define the new symbols in `src/DisplayApp/Screens/Symbols.h`:
```

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,482 @@
/**
* @file lv_pinetime_theme.c
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_pinetime_theme.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
static void theme_apply(lv_obj_t * obj, lv_theme_style_t name);
/**********************
* STATIC VARIABLES
**********************/
static lv_theme_t theme;
static lv_style_t style_pad;
static lv_style_t style_circle;
static lv_style_t style_bg;
static lv_style_t style_box;
static lv_style_t style_box_border;
static lv_style_t style_btn;
static lv_style_t style_btn_border;
static lv_style_t style_title;
static lv_style_t style_label_white;
static lv_style_t style_back;
static lv_style_t style_icon;
static lv_style_t style_bar_indic;
static lv_style_t style_slider_knob;
static lv_style_t style_scrollbar;
static lv_style_t style_list_btn;
static lv_style_t style_ddlist_list;
static lv_style_t style_ddlist_selected;
static lv_style_t style_sw_bg;
static lv_style_t style_sw_indic;
static lv_style_t style_sw_knob;
static lv_style_t style_arc_bg;
static lv_style_t style_arc_indic;
static lv_style_t style_table_cell;
static lv_style_t style_pad_small;
static lv_style_t style_bg_grad;
static lv_style_t style_lmeter;
static bool inited;
/**********************
* MACROS
**********************/
/**********************
* STATIC FUNCTIONS
**********************/
static void style_init_reset(lv_style_t * style)
{
if(inited) lv_style_reset(style);
else lv_style_init(style);
}
static void basic_init(void)
{
style_init_reset(&style_pad);
lv_style_set_pad_top(&style_pad, LV_STATE_DEFAULT, LV_VER_RES / 30);
lv_style_set_pad_bottom(&style_pad, LV_STATE_DEFAULT, LV_VER_RES / 30);
lv_style_set_pad_left(&style_pad, LV_STATE_DEFAULT, LV_VER_RES / 40);
lv_style_set_pad_right(&style_pad, LV_STATE_DEFAULT, LV_VER_RES / 40);
style_init_reset(&style_circle);
lv_style_set_radius(&style_circle, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
style_init_reset(&style_bg);
lv_style_set_bg_opa(&style_bg, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&style_bg, LV_STATE_DEFAULT, LV_COLOR_BLACK);
lv_style_set_text_font(&style_bg, LV_STATE_DEFAULT, theme.font_normal);
style_init_reset(&style_box);
lv_style_set_bg_opa(&style_box, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_radius(&style_box, LV_STATE_DEFAULT, 10);
lv_style_set_value_color(&style_box, LV_STATE_DEFAULT, LV_PINETIME_BLUE);
lv_style_set_value_font(&style_box, LV_STATE_DEFAULT, theme.font_normal);
style_init_reset(&style_box_border);
lv_style_set_bg_opa(&style_box_border, LV_STATE_DEFAULT, LV_OPA_TRANSP);
lv_style_set_border_width(&style_box_border, LV_STATE_DEFAULT, 2);
lv_style_set_border_color(&style_box_border, LV_STATE_DEFAULT, LV_PINETIME_GRAY);
lv_style_set_text_color(&style_box, LV_STATE_DEFAULT, LV_PINETIME_BLUE);
style_init_reset(&style_title);
lv_style_set_text_color(&style_title, LV_STATE_DEFAULT, LV_PINETIME_WHITE);
lv_style_set_text_font(&style_title, LV_STATE_DEFAULT, theme.font_subtitle);
style_init_reset(&style_label_white);
lv_style_set_text_color(&style_label_white, LV_STATE_DEFAULT, LV_PINETIME_WHITE);
style_init_reset(&style_btn);
lv_style_set_radius(&style_btn, LV_STATE_DEFAULT, 10);
lv_style_set_bg_opa(&style_btn, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&style_btn, LV_STATE_DEFAULT, LV_PINETIME_GRAY);
lv_style_set_text_color(&style_btn, LV_STATE_DEFAULT, LV_PINETIME_WHITE);
lv_style_set_value_color(&style_btn, LV_STATE_DEFAULT, LV_PINETIME_WHITE);
lv_style_set_pad_top(&style_btn, LV_STATE_DEFAULT, LV_VER_RES / 40);
lv_style_set_pad_bottom(&style_btn, LV_STATE_DEFAULT, LV_VER_RES / 40);
lv_style_set_pad_left(&style_btn, LV_STATE_DEFAULT, LV_DPX(15));
lv_style_set_pad_right(&style_btn, LV_STATE_DEFAULT, LV_DPX(15));
lv_style_set_pad_top(&style_btn, LV_STATE_DEFAULT, LV_DPX(10));
lv_style_set_pad_bottom(&style_btn, LV_STATE_DEFAULT, LV_DPX(10));
lv_style_set_pad_inner(&style_btn, LV_STATE_DEFAULT, LV_DPX(5));
lv_style_set_outline_width(&style_btn, LV_STATE_DEFAULT, LV_DPX(2));
style_init_reset(&style_btn_border);
lv_style_set_radius(&style_btn_border, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
lv_style_set_border_color(&style_btn_border, LV_STATE_DEFAULT, LV_PINETIME_WHITE);
lv_style_set_border_width(&style_btn_border, LV_STATE_DEFAULT, 2);
lv_style_set_bg_opa(&style_btn_border, LV_STATE_DEFAULT, LV_OPA_TRANSP);
lv_style_set_bg_color(&style_btn_border, LV_STATE_DEFAULT, LV_PINETIME_WHITE);
lv_style_set_text_color(&style_btn_border, LV_STATE_DEFAULT, LV_PINETIME_WHITE);
lv_style_set_value_color(&style_btn_border, LV_STATE_DEFAULT, LV_PINETIME_WHITE);
lv_style_set_transition_prop_3(&style_btn_border, LV_STATE_DEFAULT, LV_STYLE_BG_OPA);
style_init_reset(&style_icon);
lv_style_set_text_color(&style_icon, LV_STATE_DEFAULT, LV_PINETIME_WHITE);
style_init_reset(&style_back);
lv_style_set_value_color(&style_back, LV_STATE_DEFAULT, LV_PINETIME_GRAY);
lv_style_set_value_str(&style_back, LV_STATE_DEFAULT, LV_SYMBOL_LEFT);
lv_style_set_value_font(&style_back, LV_STATE_DEFAULT, theme.font_subtitle);
style_init_reset(&style_bar_indic);
lv_style_set_bg_opa(&style_bar_indic, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_radius(&style_bar_indic, LV_STATE_DEFAULT, 10);
style_init_reset(&style_scrollbar);
lv_style_set_bg_opa(&style_scrollbar, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_radius(&style_scrollbar, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
lv_style_set_bg_color(&style_scrollbar, LV_STATE_DEFAULT, LV_PINETIME_LIGHT_GRAY);
lv_style_set_size(&style_scrollbar, LV_STATE_DEFAULT, LV_HOR_RES / 80);
lv_style_set_pad_right(&style_scrollbar, LV_STATE_DEFAULT, LV_HOR_RES / 60);
style_init_reset(&style_list_btn);
lv_style_set_bg_opa(&style_list_btn, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&style_list_btn, LV_STATE_DEFAULT, LV_PINETIME_WHITE);
lv_style_set_bg_color(&style_list_btn, LV_STATE_CHECKED, LV_PINETIME_GRAY);
lv_style_set_bg_color(&style_list_btn, LV_STATE_CHECKED | LV_STATE_PRESSED, lv_color_darken(LV_PINETIME_GRAY, LV_OPA_20));
lv_style_set_text_color(&style_list_btn, LV_STATE_DEFAULT, LV_PINETIME_BLUE);
lv_style_set_text_color(&style_list_btn, LV_STATE_CHECKED, LV_PINETIME_WHITE);
lv_style_set_text_color(&style_list_btn, LV_STATE_CHECKED | LV_STATE_PRESSED, LV_PINETIME_WHITE);
lv_style_set_image_recolor(&style_list_btn, LV_STATE_DEFAULT, LV_PINETIME_BLUE);
lv_style_set_image_recolor(&style_list_btn, LV_STATE_CHECKED, LV_PINETIME_WHITE);
lv_style_set_image_recolor(&style_list_btn, LV_STATE_CHECKED | LV_STATE_PRESSED, LV_PINETIME_WHITE);
lv_style_set_pad_left(&style_list_btn, LV_STATE_DEFAULT, LV_HOR_RES / 25);
lv_style_set_pad_right(&style_list_btn, LV_STATE_DEFAULT, LV_HOR_RES / 25);
lv_style_set_pad_top(&style_list_btn, LV_STATE_DEFAULT, LV_HOR_RES / 100);
lv_style_set_pad_bottom(&style_list_btn, LV_STATE_DEFAULT, LV_HOR_RES / 100);
lv_style_set_pad_inner(&style_list_btn, LV_STATE_DEFAULT, LV_HOR_RES / 50);
style_init_reset(&style_ddlist_list);
lv_style_set_text_line_space(&style_ddlist_list, LV_STATE_DEFAULT, LV_VER_RES / 25);
lv_style_set_shadow_width(&style_ddlist_list, LV_STATE_DEFAULT, LV_VER_RES / 20);
lv_style_set_shadow_color(&style_ddlist_list, LV_STATE_DEFAULT, LV_PINETIME_GRAY);
style_init_reset(&style_ddlist_selected);
lv_style_set_bg_opa(&style_ddlist_selected, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&style_ddlist_selected, LV_STATE_DEFAULT, LV_PINETIME_BLUE);
style_init_reset(&style_sw_bg);
lv_style_set_bg_opa(&style_sw_bg, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&style_sw_bg, LV_STATE_DEFAULT, LV_PINETIME_LIGHT_GRAY);
lv_style_set_radius(&style_sw_bg, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
lv_style_set_value_color(&style_sw_bg, LV_STATE_DEFAULT, LV_PINETIME_BLUE);
style_init_reset(&style_sw_indic);
lv_style_set_bg_opa(&style_sw_indic, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&style_sw_indic, LV_STATE_DEFAULT, LV_PINETIME_GREEN);
style_init_reset(&style_sw_knob);
lv_style_set_bg_opa(&style_sw_knob, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&style_sw_knob, LV_STATE_DEFAULT, LV_PINETIME_WHITE);
lv_style_set_radius(&style_sw_knob, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
lv_style_set_pad_top(&style_sw_knob, LV_STATE_DEFAULT, - 4);
lv_style_set_pad_bottom(&style_sw_knob, LV_STATE_DEFAULT, - 4);
lv_style_set_pad_left(&style_sw_knob, LV_STATE_DEFAULT, - 4);
lv_style_set_pad_right(&style_sw_knob, LV_STATE_DEFAULT, - 4);
style_init_reset(&style_slider_knob);
lv_style_set_bg_opa(&style_slider_knob, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&style_slider_knob, LV_STATE_DEFAULT, LV_COLOR_RED);
lv_style_set_border_color(&style_slider_knob, LV_STATE_DEFAULT, LV_COLOR_WHITE);
lv_style_set_border_width(&style_slider_knob, LV_STATE_DEFAULT, 6);
lv_style_set_radius(&style_slider_knob, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
lv_style_set_pad_top(&style_slider_knob, LV_STATE_DEFAULT, 10);
lv_style_set_pad_bottom(&style_slider_knob, LV_STATE_DEFAULT, 10);
lv_style_set_pad_left(&style_slider_knob, LV_STATE_DEFAULT, 10);
lv_style_set_pad_right(&style_slider_knob, LV_STATE_DEFAULT, 10);
lv_style_set_pad_top(&style_slider_knob, LV_STATE_PRESSED, 14);
lv_style_set_pad_bottom(&style_slider_knob, LV_STATE_PRESSED, 14);
lv_style_set_pad_left(&style_slider_knob, LV_STATE_PRESSED, 14);
lv_style_set_pad_right(&style_slider_knob, LV_STATE_PRESSED, 14);
style_init_reset(&style_arc_indic);
lv_style_set_line_color(&style_arc_indic, LV_STATE_DEFAULT, LV_PINETIME_BLUE);
lv_style_set_line_width(&style_arc_indic, LV_STATE_DEFAULT, LV_DPX(25));
lv_style_set_line_rounded(&style_arc_indic, LV_STATE_DEFAULT, true);
style_init_reset(&style_arc_bg);
lv_style_set_line_color(&style_arc_bg, LV_STATE_DEFAULT, LV_PINETIME_GRAY);
lv_style_set_line_width(&style_arc_bg, LV_STATE_DEFAULT, LV_DPX(25));
lv_style_set_line_rounded(&style_arc_bg, LV_STATE_DEFAULT, true);
style_init_reset(&style_table_cell);
lv_style_set_border_color(&style_table_cell, LV_STATE_DEFAULT, LV_PINETIME_GRAY);
lv_style_set_border_width(&style_table_cell, LV_STATE_DEFAULT, 1);
lv_style_set_border_side(&style_table_cell, LV_STATE_DEFAULT, LV_BORDER_SIDE_FULL);
lv_style_set_pad_left(&style_table_cell, LV_STATE_DEFAULT, 12);
lv_style_set_pad_right(&style_table_cell, LV_STATE_DEFAULT, 12);
lv_style_set_pad_top(&style_table_cell, LV_STATE_DEFAULT, 12);
lv_style_set_pad_bottom(&style_table_cell, LV_STATE_DEFAULT, 12);
style_init_reset(&style_pad_small);
lv_style_int_t pad_small_value = 10;
lv_style_set_pad_left(&style_pad_small, LV_STATE_DEFAULT, pad_small_value);
lv_style_set_pad_right(&style_pad_small, LV_STATE_DEFAULT, pad_small_value);
lv_style_set_pad_top(&style_pad_small, LV_STATE_DEFAULT, pad_small_value);
lv_style_set_pad_bottom(&style_pad_small, LV_STATE_DEFAULT, pad_small_value);
lv_style_set_pad_inner(&style_pad_small, LV_STATE_DEFAULT, pad_small_value);
style_init_reset(&style_bg_grad);
lv_style_set_bg_color(&style_bg_grad, LV_STATE_DEFAULT, lv_color_hsv_to_rgb(10, 10, 40));
lv_style_set_bg_grad_color(&style_bg_grad, LV_STATE_DEFAULT, lv_color_hsv_to_rgb(10, 10, 20));
lv_style_set_bg_grad_dir(&style_bg_grad, LV_STATE_DEFAULT, LV_GRAD_DIR_VER);
style_init_reset(&style_lmeter);
lv_style_set_radius(&style_lmeter, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
lv_style_set_pad_left(&style_lmeter, LV_STATE_DEFAULT, LV_DPX(20));
lv_style_set_pad_right(&style_lmeter, LV_STATE_DEFAULT, LV_DPX(20));
lv_style_set_pad_top(&style_lmeter, LV_STATE_DEFAULT, LV_DPX(20));
lv_style_set_pad_inner(&style_lmeter, LV_STATE_DEFAULT, LV_DPX(30));
lv_style_set_scale_width(&style_lmeter, LV_STATE_DEFAULT, LV_DPX(25));
lv_style_set_line_color(&style_lmeter, LV_STATE_DEFAULT, theme.color_primary);
lv_style_set_scale_grad_color(&style_lmeter, LV_STATE_DEFAULT, theme.color_primary);
lv_style_set_scale_end_color(&style_lmeter, LV_STATE_DEFAULT, lv_color_hex3(0x888));
lv_style_set_line_width(&style_lmeter, LV_STATE_DEFAULT, LV_DPX(10));
lv_style_set_scale_end_line_width(&style_lmeter, LV_STATE_DEFAULT, LV_DPX(7));
}
/**********************
* GLOBAL FUNCTIONS
**********************/
/**
* Initialize the default
* @param color_primary the primary color of the theme
* @param color_secondary the secondary color for the theme
* @param flags ORed flags starting with `LV_THEME_DEF_FLAG_...`
* @param font_small pointer to a small font
* @param font_normal pointer to a normal font
* @param font_subtitle pointer to a large font
* @param font_title pointer to a extra large font
* @return a pointer to reference this theme later
*/
lv_theme_t * lv_pinetime_theme_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags,
const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_subtitle,
const lv_font_t * font_title)
{
theme.color_primary = color_primary;
theme.color_secondary = color_secondary;
theme.font_small = font_small;
theme.font_normal = font_normal;
theme.font_subtitle = font_subtitle;
theme.font_title = font_title;
theme.flags = flags;
basic_init();
theme.apply_xcb = theme_apply;
inited = true;
return &theme;
}
static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
{
lv_style_list_t * list;
/*To avoid warnings*/
uint32_t name_int = (uint32_t) name;
switch(name_int) {
case LV_THEME_NONE:
break;
case LV_THEME_SCR:
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN);
_lv_style_list_add_style(list, &style_bg);
break;
case LV_THEME_OBJ:
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN);
_lv_style_list_add_style(list, &style_box);
break;
case LV_THEME_CONT:
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_CONT_PART_MAIN);
_lv_style_list_add_style(list, &style_box);
break;
case LV_THEME_BTN:
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
_lv_style_list_add_style(list, &style_btn);
_lv_style_list_add_style(list, &style_bg_grad);
break;
case LV_THEME_BTNMATRIX:
list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BG);
_lv_style_list_add_style(list, &style_bg);
_lv_style_list_add_style(list, &style_pad_small);
list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BTN);
_lv_style_list_add_style(list, &style_btn);
_lv_style_list_add_style(list, &style_bg_grad);
//_lv_style_list_add_style(list, &styles->bg_click);
break;
case LV_THEME_BAR:
lv_obj_clean_style_list(obj, LV_BAR_PART_BG);
list = lv_obj_get_style_list(obj, LV_BAR_PART_BG);
lv_obj_clean_style_list(obj, LV_BAR_PART_INDIC);
list = lv_obj_get_style_list(obj, LV_BAR_PART_INDIC);
_lv_style_list_add_style(list, &style_bar_indic);
break;
case LV_THEME_IMAGE:
lv_obj_clean_style_list(obj, LV_IMG_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_IMG_PART_MAIN);
_lv_style_list_add_style(list, &style_icon);
break;
case LV_THEME_LABEL:
lv_obj_clean_style_list(obj, LV_LABEL_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_LABEL_PART_MAIN);
_lv_style_list_add_style(list, &style_label_white);
break;
case LV_THEME_SLIDER:
lv_obj_clean_style_list(obj, LV_SLIDER_PART_BG);
list = lv_obj_get_style_list(obj, LV_SLIDER_PART_BG);
_lv_style_list_add_style(list, &style_sw_bg);
lv_obj_clean_style_list(obj, LV_SLIDER_PART_INDIC);
list = lv_obj_get_style_list(obj, LV_SLIDER_PART_INDIC);
lv_obj_clean_style_list(obj, LV_SLIDER_PART_KNOB);
list = lv_obj_get_style_list(obj, LV_SLIDER_PART_KNOB);
_lv_style_list_add_style(list, &style_slider_knob);
break;
case LV_THEME_LIST:
lv_obj_clean_style_list(obj, LV_LIST_PART_BG);
list = lv_obj_get_style_list(obj, LV_LIST_PART_BG);
_lv_style_list_add_style(list, &style_box);
lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLABLE);
list = lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLABLE);
lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLBAR);
list = lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLBAR);
_lv_style_list_add_style(list, &style_scrollbar);
break;
case LV_THEME_LIST_BTN:
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
_lv_style_list_add_style(list, &style_list_btn);
break;
case LV_THEME_ARC:
lv_obj_clean_style_list(obj, LV_ARC_PART_BG);
list = lv_obj_get_style_list(obj, LV_ARC_PART_BG);
_lv_style_list_add_style(list, &style_arc_bg);
lv_obj_clean_style_list(obj, LV_ARC_PART_INDIC);
list = lv_obj_get_style_list(obj, LV_ARC_PART_INDIC);
_lv_style_list_add_style(list, &style_arc_indic);
break;
case LV_THEME_SWITCH:
lv_obj_clean_style_list(obj, LV_SWITCH_PART_BG);
list = lv_obj_get_style_list(obj, LV_SWITCH_PART_BG);
_lv_style_list_add_style(list, &style_sw_bg);
lv_obj_clean_style_list(obj, LV_SWITCH_PART_INDIC);
list = lv_obj_get_style_list(obj, LV_SWITCH_PART_INDIC);
_lv_style_list_add_style(list, &style_sw_indic);
lv_obj_clean_style_list(obj, LV_SWITCH_PART_KNOB);
list = lv_obj_get_style_list(obj, LV_SWITCH_PART_KNOB);
_lv_style_list_add_style(list, &style_sw_knob);
break;
case LV_THEME_DROPDOWN:
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_MAIN);
_lv_style_list_add_style(list, &style_btn);
_lv_style_list_add_style(list, &style_pad);
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_LIST);
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_LIST);
_lv_style_list_add_style(list, &style_box);
_lv_style_list_add_style(list, &style_ddlist_list);
_lv_style_list_add_style(list, &style_pad);
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SELECTED);
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SELECTED);
_lv_style_list_add_style(list, &style_ddlist_selected);
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR);
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR);
_lv_style_list_add_style(list, &style_scrollbar);
break;
case LV_THEME_TABLE:
list = lv_obj_get_style_list(obj, LV_TABLE_PART_BG);
_lv_style_list_add_style(list, &style_bg);
int idx = 1; /* start value should be 1, not zero, since cell styles
start at 1 due to presence of LV_TABLE_PART_BG=0
in the enum (lv_table.h) */
/* declaring idx outside loop to work with older compilers */
for(; idx <= LV_TABLE_CELL_STYLE_CNT; idx ++) {
list = lv_obj_get_style_list(obj, idx);
_lv_style_list_add_style(list, &style_table_cell);
}
break;
case LV_THEME_LINEMETER:
list = lv_obj_get_style_list(obj, LV_LINEMETER_PART_MAIN);
_lv_style_list_add_style(list, &style_bg);
_lv_style_list_add_style(list, &style_lmeter);
break;
default:
break;
}
lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
}
/**********************
* STATIC FUNCTIONS
**********************/

View File

@@ -0,0 +1,62 @@
/**
* @file lv_pinetime_theme.h
*
*/
#ifndef LV_PINETIME_THEME_H
#define LV_PINETIME_THEME_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include <lvgl/lvgl.h>
/*********************
* DEFINES
*********************/
/*Colors*/
#define LV_PINETIME_WHITE lv_color_hex(0xffffff)
#define LV_PINETIME_LIGHT lv_color_hex(0xf3f8fe)
#define LV_PINETIME_GRAY lv_color_hex(0x8a8a8a)
#define LV_PINETIME_LIGHT_GRAY lv_color_hex(0xc4c4c4)
#define LV_PINETIME_BLUE lv_color_hex(0x2f3243) //006fb6
#define LV_PINETIME_GREEN lv_color_hex(0x4cb242)
#define LV_PINETIME_RED lv_color_hex(0xd51732)
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initialize the default
* @param color_primary the primary color of the theme
* @param color_secondary the secondary color for the theme
* @param flags ORed flags starting with `LV_THEME_DEF_FLAG_...`
* @param font_small pointer to a small font
* @param font_normal pointer to a normal font
* @param font_subtitle pointer to a large font
* @param font_title pointer to a extra large font
* @return a pointer to reference this theme later
*/
lv_theme_t * lv_pinetime_theme_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags,
const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_subtitle,
const lv_font_t * font_title);
/**********************
* MACROS
**********************/
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif

View File

@@ -71,7 +71,7 @@ std::unique_ptr<Screen> ApplicationList::CreateScreen2() {
std::unique_ptr<Screen> ApplicationList::CreateScreen3() {
std::array<Screens::Tile::Applications, 6> applications {
{{"A", Apps::Meter},
{"B", Apps::Gauge},
{"B", Apps::Navigation},
{"C", Apps::Clock},
{"D", Apps::Music},
{"E", Apps::SysInfo},

View File

@@ -22,7 +22,7 @@ Brightness::Brightness(Pinetime::Applications::DisplayApp *app, Controllers::Bri
slider_label = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text(slider_label, LevelToString(brightness.Level()));
lv_obj_set_auto_realign(slider_label, true);
lv_obj_align(slider_label, slider, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
lv_obj_align(slider_label, slider, LV_ALIGN_OUT_BOTTOM_MID, 0, 30);
}
Brightness::~Brightness() {
@@ -75,6 +75,9 @@ bool Brightness::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
switch(event) {
case TouchEvents::SwipeLeft:
brightness.Lower();
if ( brightness.Level() == Pinetime::Controllers::BrightnessController::Levels::Off) {
brightness.Set(Controllers::BrightnessController::Levels::Low);
}
SetValue();
return true;
case TouchEvents::SwipeRight:

View File

@@ -14,9 +14,45 @@
#include "../DisplayApp.h"
using namespace Pinetime::Applications::Screens;
extern lv_font_t jetbrains_mono_extrabold_compressed;
extern lv_font_t jetbrains_mono_bold_20;
extern lv_style_t* LabelBigStyle;
namespace {
char const *DaysString[] = {
"",
"MONDAY",
"TUESDAY",
"WEDNESDAY",
"THURSDAY",
"FRIDAY",
"SATURDAY",
"SUNDAY"
};
char const *MonthsString[] = {
"",
"JAN",
"FEB",
"MAR",
"APR",
"MAY",
"JUN",
"JUL",
"AUG",
"SEP",
"OCT",
"NOV",
"DEC"
};
const char *MonthToString(Pinetime::Controllers::DateTime::Months month) {
return MonthsString[static_cast<uint8_t>(month)];
}
const char *DayOfWeekToString(Pinetime::Controllers::DateTime::Days dayOfWeek) {
return DaysString[static_cast<uint8_t>(dayOfWeek)];
}
}
static void event_handler(lv_obj_t * obj, lv_event_t event) {
Clock* screen = static_cast<Clock *>(obj->user_data);
@@ -59,7 +95,9 @@ Clock::Clock(DisplayApp* app,
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 60);
label_time = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_style(label_time, LV_LABEL_STYLE_MAIN, LabelBigStyle);
lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_extrabold_compressed);
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 0);
backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
@@ -201,40 +239,6 @@ bool Clock::Refresh() {
return running;
}
const char *Clock::MonthToString(Pinetime::Controllers::DateTime::Months month) {
return Clock::MonthsString[static_cast<uint8_t>(month)];
}
const char *Clock::DayOfWeekToString(Pinetime::Controllers::DateTime::Days dayOfWeek) {
return Clock::DaysString[static_cast<uint8_t>(dayOfWeek)];
}
char const *Clock::DaysString[] = {
"",
"MONDAY",
"TUESDAY",
"WEDNESDAY",
"THURSDAY",
"FRIDAY",
"SATURDAY",
"SUNDAY"
};
char const *Clock::MonthsString[] = {
"",
"JAN",
"FEB",
"MAR",
"APR",
"MAY",
"JUN",
"JUL",
"AUG",
"SEP",
"OCT",
"NOV",
"DEC"
};
void Clock::OnObjectEvent(lv_obj_t *obj, lv_event_t event) {
if(obj == backgroundLabel) {

View File

@@ -21,11 +21,10 @@ namespace Pinetime {
template <class T>
class DirtyValue {
public:
explicit DirtyValue(T v) { value = v; }
explicit DirtyValue(T& v) { value = v; }
DirtyValue() = default; // Use NSDMI
explicit DirtyValue(T const& v):value{v}{} // Use MIL and const-lvalue-ref
bool IsUpdated() const { return isUpdated; }
T& Get() { this->isUpdated = false; return value; }
T const& Get() { this->isUpdated = false; return value; } // never expose a non-const lvalue-ref
DirtyValue& operator=(const T& other) {
if (this->value != other) {
this->value = other;
@@ -34,9 +33,10 @@ namespace Pinetime {
return *this;
}
private:
T value;
bool isUpdated = true;
T value{}; // NSDMI - default initialise type
bool isUpdated{true}; // NSDMI - use brace initilisation
};
class Clock : public Screen {
public:
Clock(DisplayApp* app,
@@ -52,11 +52,6 @@ namespace Pinetime {
void OnObjectEvent(lv_obj_t *pObj, lv_event_t i);
private:
static const char* MonthToString(Pinetime::Controllers::DateTime::Months month);
static const char* DayOfWeekToString(Pinetime::Controllers::DateTime::Days dayOfWeek);
static char const *DaysString[];
static char const *MonthsString[];
char displayedChar[5];
uint16_t currentYear = 1970;
@@ -64,13 +59,13 @@ namespace Pinetime {
Pinetime::Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown;
uint8_t currentDay = 0;
DirtyValue<int> batteryPercentRemaining {0};
DirtyValue<bool> bleState {false};
DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime;
DirtyValue<uint32_t> stepCount {0};
DirtyValue<uint8_t> heartbeat {0};
DirtyValue<bool> heartbeatRunning {false};
DirtyValue<bool> notificationState {false};
DirtyValue<int> batteryPercentRemaining {};
DirtyValue<bool> bleState {};
DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime{};
DirtyValue<uint32_t> stepCount {};
DirtyValue<uint8_t> heartbeat {};
DirtyValue<bool> heartbeatRunning {};
DirtyValue<bool> notificationState {};
lv_obj_t* label_time;
lv_obj_t* label_date;

View File

@@ -4,8 +4,6 @@
#include "../DisplayApp.h"
using namespace Pinetime::Applications::Screens;
extern lv_font_t jetbrains_mono_extrabold_compressed;
extern lv_font_t jetbrains_mono_bold_20;
DropDownDemo::DropDownDemo(Pinetime::Applications::DisplayApp *app) : Screen(app) {
// Create the dropdown object, with many item, and fix its height

View File

@@ -4,8 +4,6 @@
#include "../DisplayApp.h"
using namespace Pinetime::Applications::Screens;
extern lv_font_t jetbrains_mono_extrabold_compressed;
extern lv_font_t jetbrains_mono_bold_20;
FirmwareUpdate::FirmwareUpdate(Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::Ble& bleController) :

View File

@@ -5,8 +5,6 @@
#include "../DisplayApp.h"
using namespace Pinetime::Applications::Screens;
extern lv_font_t jetbrains_mono_extrabold_compressed;
extern lv_font_t jetbrains_mono_bold_20;
namespace {
static void ButtonEventHandler(lv_obj_t * obj, lv_event_t event)

View File

@@ -1,57 +0,0 @@
#include "Gauge.h"
#include "../DisplayApp.h"
using namespace Pinetime::Applications::Screens;
extern lv_font_t jetbrains_mono_extrabold_compressed;
extern lv_font_t jetbrains_mono_bold_20;
Gauge::Gauge(Pinetime::Applications::DisplayApp *app) : Screen(app) {
/*Create a style*/
lv_style_copy(&style, &lv_style_pretty_color);
style.body.main_color = LV_COLOR_CYAN; /*Line color at the beginning*/
style.body.grad_color = LV_COLOR_RED; /*Line color at the end*/
style.body.padding.left = 10; /*Scale line length*/
style.body.padding.inner = 8 ; /*Scale label padding*/
style.body.border.color = lv_color_hex3(0x333); /*Needle middle circle color*/
style.line.width = 3;
style.text.color = LV_COLOR_WHITE;
style.line.color = LV_COLOR_RED; /*Line color after the critical value*/
/*Describe the color for the needles*/
needle_colors[0] = LV_COLOR_ORANGE;
/*Create a gauge*/
gauge1 = lv_gauge_create(lv_scr_act(), nullptr);
lv_gauge_set_style(gauge1, LV_GAUGE_STYLE_MAIN, &style);
lv_gauge_set_needle_count(gauge1, 1, needle_colors);
lv_obj_set_size(gauge1, 180, 180);
lv_obj_align(gauge1, nullptr, LV_ALIGN_CENTER, 0, 0);
lv_gauge_set_scale(gauge1, 360, 60, 0);
lv_gauge_set_range(gauge1, 0, 59);
/*Set the values*/
lv_gauge_set_value(gauge1, 0, value);
}
Gauge::~Gauge() {
lv_obj_clean(lv_scr_act());
}
bool Gauge::Refresh() {
// lv_lmeter_set_value(lmeter, value++); /*Set the current value*/
// if(value>=60) value = 0;
lv_gauge_set_value(gauge1, 0, value++);
if(value == 59) value = 0;
return running;
}
bool Gauge::OnButtonPushed() {
running = false;
return true;
}

View File

@@ -1,30 +0,0 @@
#pragma once
#include <cstdint>
#include "Screen.h"
#include <lvgl/lvgl.h>
namespace Pinetime {
namespace Applications {
namespace Screens {
class Gauge : public Screen{
public:
Gauge(DisplayApp* app);
~Gauge() override;
bool Refresh() override;
bool OnButtonPushed() override;
private:
lv_style_t style;
lv_color_t needle_colors[3];
lv_obj_t * gauge1;
uint32_t value=30;
bool running = true;
};
}
}
}

View File

@@ -5,8 +5,6 @@
#include "../DisplayApp.h"
using namespace Pinetime::Applications::Screens;
extern lv_font_t jetbrains_mono_extrabold_compressed;
extern lv_font_t jetbrains_mono_bold_20;
namespace {
const char *ToString(Pinetime::Controllers::HeartRateController::States s) {
@@ -30,28 +28,22 @@ namespace {
}
HeartRate::HeartRate(Pinetime::Applications::DisplayApp *app, Controllers::HeartRateController& heartRateController) : Screen(app), heartRateController{heartRateController} {
label_bpm = lv_label_create(lv_scr_act(), NULL);
labelStyle = const_cast<lv_style_t *>(lv_label_get_style(label_bpm, LV_LABEL_STYLE_MAIN));
labelStyle->text.font = &jetbrains_mono_bold_20;
lv_style_copy(&labelBigStyle, labelStyle);
labelBigStyle.text.font = &jetbrains_mono_extrabold_compressed;
lv_label_set_style(label_bpm, LV_LABEL_STYLE_MAIN, labelStyle);
label_hr = lv_label_create(lv_scr_act(), NULL);
lv_label_set_style(label_hr, LV_LABEL_STYLE_MAIN, &labelBigStyle);
lv_obj_set_style_local_text_font(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_extrabold_compressed);
lv_obj_align(label_hr, lv_scr_act(), LV_ALIGN_CENTER, -70, -40);
lv_label_set_text(label_hr, "000");
label_bpm = lv_label_create(lv_scr_act(), NULL);
lv_label_set_text(label_bpm, "Heart rate BPM");
lv_obj_align(label_bpm, label_hr, LV_ALIGN_OUT_TOP_MID, 0, -20);
label_status = lv_label_create(lv_scr_act(), NULL);
lv_label_set_text(label_status, ToString(Pinetime::Controllers::HeartRateController::States::NotEnoughData));
lv_label_set_style(label_status, LV_LABEL_STYLE_MAIN, labelStyle);
lv_obj_align(label_status, label_hr, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
btn_startStop = lv_btn_create(lv_scr_act(), NULL);

View File

@@ -3,8 +3,6 @@
#include "../LittleVgl.h"
using namespace Pinetime::Applications::Screens;
extern lv_font_t jetbrains_mono_extrabold_compressed;
extern lv_font_t jetbrains_mono_bold_20;
InfiniPaint::InfiniPaint(Pinetime::Applications::DisplayApp* app, Pinetime::Components::LittleVgl& lvgl) : Screen(app), lvgl{lvgl} {
app->SetTouchMode(DisplayApp::TouchModes::Polling);

View File

@@ -3,27 +3,23 @@
#include "../DisplayApp.h"
using namespace Pinetime::Applications::Screens;
extern lv_font_t jetbrains_mono_extrabold_compressed;
extern lv_font_t jetbrains_mono_bold_20;
Meter::Meter(Pinetime::Applications::DisplayApp *app) : Screen(app) {
lv_style_copy(&style_lmeter, &lv_style_pretty_color);
style_lmeter.line.width = 2;
style_lmeter.line.color = LV_COLOR_SILVER;
style_lmeter.body.main_color = lv_color_make(255,0,0);
style_lmeter.body.grad_color = lv_color_make(160,0,0);
style_lmeter.body.padding.left = 16; /*Line length*/
/*Create a line meter */
lmeter = lv_lmeter_create(lv_scr_act(), nullptr);
lv_lmeter_set_range(lmeter, 0, 60); /*Set the range*/
lv_lmeter_set_value(lmeter, value); /*Set the current value*/
lv_lmeter_set_angle_offset(lmeter, 180);
lv_lmeter_set_scale(lmeter, 360, 60); /*Set the angle and number of lines*/
lv_lmeter_set_style(lmeter, LV_LMETER_STYLE_MAIN, &style_lmeter); /*Apply the new style*/
lv_obj_set_size(lmeter, 150, 150);
lmeter = lv_linemeter_create(lv_scr_act(), nullptr);
lv_linemeter_set_range(lmeter, 0, 60); /*Set the range*/
lv_linemeter_set_value(lmeter, value); /*Set the current value*/
lv_linemeter_set_angle_offset(lmeter, 180);
lv_linemeter_set_scale(lmeter, 360, 60); /*Set the angle and number of lines*/
lv_obj_set_style_local_scale_end_color(lmeter, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, lv_color_make(255,0,0));
lv_obj_set_style_local_scale_grad_color(lmeter, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, lv_color_make(160,0,0));
lv_obj_set_style_local_line_width(lmeter, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 2);
lv_obj_set_style_local_line_color(lmeter, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_SILVER);
lv_obj_set_size(lmeter, 200, 200);
lv_obj_align(lmeter, nullptr, LV_ALIGN_CENTER, 0, 0);
}
@@ -35,7 +31,7 @@ Meter::~Meter() {
}
bool Meter::Refresh() {
lv_lmeter_set_value(lmeter, value++); /*Set the current value*/
lv_linemeter_set_value(lmeter, value++); /*Set the current value*/
if(value>=60) value = 0;
return running;

View File

@@ -1,81 +0,0 @@
#include "Modal.h"
#include <lvgl/lvgl.h>
#include "../DisplayApp.h"
using namespace Pinetime::Applications::Screens;
extern lv_font_t jetbrains_mono_extrabold_compressed;
extern lv_font_t jetbrains_mono_bold_20;
Modal::Modal(Pinetime::Applications::DisplayApp *app) : Screen(app) {
}
Modal::~Modal() {
lv_obj_clean(lv_scr_act());
}
bool Modal::Refresh() {
return running;
}
bool Modal::OnButtonPushed() {
running = false;
return true;
}
void Modal::Hide() {
/* Delete the parent modal background */
lv_obj_del_async(lv_obj_get_parent(mbox));
mbox = NULL; /* happens before object is actually deleted! */
isVisible = false;
}
void Modal::mbox_event_cb(lv_obj_t *obj, lv_event_t evt) {
auto* m = static_cast<Modal *>(obj->user_data);
m->OnEvent(obj, evt);
}
void Modal::OnEvent(lv_obj_t *event_obj, lv_event_t evt) {
if(evt == LV_EVENT_DELETE && event_obj == mbox) {
Hide();
} else if(evt == LV_EVENT_VALUE_CHANGED) {
/* A button was clicked */
lv_mbox_start_auto_close(mbox, 0);
// Hide();
}
}
void Modal::Show(const char* msg) {
if(isVisible) return;
isVisible = true;
lv_style_copy(&modal_style, &lv_style_plain_color);
modal_style.body.main_color = modal_style.body.grad_color = LV_COLOR_BLACK;
modal_style.body.opa = LV_OPA_50;
obj = lv_obj_create(lv_scr_act(), nullptr);
lv_obj_set_style(obj, &modal_style);
lv_obj_set_pos(obj, 0, 0);
lv_obj_set_size(obj, LV_HOR_RES, LV_VER_RES);
lv_obj_set_opa_scale_enable(obj, true); /* Enable opacity scaling for the animation */
static const char * btns2[] = {"Ok", ""};
/* Create the message box as a child of the modal background */
mbox = lv_mbox_create(obj, nullptr);
lv_mbox_add_btns(mbox, btns2);
lv_mbox_set_text(mbox, msg);
lv_obj_align(mbox, nullptr, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_event_cb(mbox, Modal::mbox_event_cb);
mbox->user_data = this;
/* Fade the message box in with an animation */
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_time(&a, 500, 0);
lv_anim_set_values(&a, LV_OPA_TRANSP, LV_OPA_COVER);
lv_anim_set_exec_cb(&a, obj, (lv_anim_exec_xcb_t)lv_obj_set_opa_scale);
lv_anim_create(&a);
}

View File

@@ -1,36 +0,0 @@
#pragma once
#include "Screen.h"
#include <lvgl/src/lv_core/lv_style.h>
#include <lvgl/src/lv_core/lv_obj.h>
namespace Pinetime {
namespace Applications {
namespace Screens {
class Modal : public Screen{
public:
Modal(DisplayApp* app);
~Modal() override;
void Show(const char* msg);
void Hide();
bool Refresh() override;
bool OnButtonPushed() override;
static void mbox_event_cb(lv_obj_t *obj, lv_event_t evt);
private:
void OnEvent(lv_obj_t *event_obj, lv_event_t evt);
lv_style_t modal_style;
lv_obj_t *obj;
lv_obj_t *mbox;
lv_obj_t *info;
bool running = true;
bool isVisible = false;
};
}
}
}

View File

@@ -16,6 +16,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "Music.h"
#include "Symbols.h"
#include <cstdint>
#include "../DisplayApp.h"
#include "components/ble/MusicService.h"
@@ -25,9 +26,6 @@
using namespace Pinetime::Applications::Screens;
extern lv_font_t jetbrains_mono_extrabold_compressed;
extern lv_font_t jetbrains_mono_bold_20;
static void event_handler(lv_obj_t *obj, lv_event_t event) {
Music *screen = static_cast<Music *>(obj->user_data);
screen->OnObjectEvent(obj, event);
@@ -58,7 +56,7 @@ Music::Music(Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::Mus
lv_obj_set_size(btnVolDown, LV_HOR_RES / 3, 80);
lv_obj_align(btnVolDown, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
label = lv_label_create(btnVolDown, nullptr);
lv_label_set_text(label, "V-");
lv_label_set_text(label, Symbols::volumDown);
lv_obj_set_hidden(btnVolDown, !displayVolumeButtons);
btnVolUp = lv_btn_create(lv_scr_act(), nullptr);
@@ -67,7 +65,7 @@ Music::Music(Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::Mus
lv_obj_set_size(btnVolUp, LV_HOR_RES / 3, 80);
lv_obj_align(btnVolUp, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
label = lv_label_create(btnVolUp, nullptr);
lv_label_set_text(label, "V+");
lv_label_set_text(label, Symbols::volumUp);
lv_obj_set_hidden(btnVolDown, !displayVolumeButtons);
btnPrev = lv_btn_create(lv_scr_act(), nullptr);
@@ -76,7 +74,7 @@ Music::Music(Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::Mus
lv_obj_set_size(btnPrev, LV_HOR_RES / 3, 80);
lv_obj_align(btnPrev, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
label = lv_label_create(btnPrev, nullptr);
lv_label_set_text(label, "<<");
lv_label_set_text(label, Symbols::stepBackward);
btnNext = lv_btn_create(lv_scr_act(), nullptr);
btnNext->user_data = this;
@@ -84,7 +82,7 @@ Music::Music(Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::Mus
lv_obj_set_size(btnNext, LV_HOR_RES / 3, 80);
lv_obj_align(btnNext, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
label = lv_label_create(btnNext, nullptr);
lv_label_set_text(label, ">>");
lv_label_set_text(label, Symbols::stepForward);
btnPlayPause = lv_btn_create(lv_scr_act(), nullptr);
btnPlayPause->user_data = this;
@@ -92,7 +90,7 @@ Music::Music(Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::Mus
lv_obj_set_size(btnPlayPause, LV_HOR_RES / 3, 80);
lv_obj_align(btnPlayPause, nullptr, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
txtPlayPause = lv_label_create(btnPlayPause, nullptr);
lv_label_set_text(txtPlayPause, ">");
lv_label_set_text(txtPlayPause, Symbols::play);
txtTrackDuration = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_long_mode(txtTrackDuration, LV_LABEL_LONG_SROLL);
@@ -179,7 +177,7 @@ bool Music::Refresh() {
}
if (playing == Pinetime::Controllers::MusicService::MusicStatus::Playing) {
lv_label_set_text(txtPlayPause, "||");
lv_label_set_text(txtPlayPause, Symbols::pause);
if (xTaskGetTickCount() - 1024 >= lastIncrement) {
if (frameB) {
@@ -203,7 +201,7 @@ bool Music::Refresh() {
UpdateLength();
}
} else {
lv_label_set_text(txtPlayPause, ">");
lv_label_set_text(txtPlayPause, Symbols::play);
}
return running;

View File

@@ -22,9 +22,6 @@
using namespace Pinetime::Applications::Screens;
extern lv_font_t jetbrains_mono_extrabold_compressed;
extern lv_font_t jetbrains_mono_bold_20;
/**
* Set the pixel array to display by the image
* This just calls lv_img_set_src but adds type safety

View File

@@ -1,30 +1,48 @@
#include "Notifications.h"
#include <displayapp/DisplayApp.h>
#include "components/ble/MusicService.h"
#include "components/ble/AlertNotificationService.h"
#include "Symbols.h"
using namespace Pinetime::Applications::Screens;
extern lv_font_t jetbrains_mono_extrabold_compressed;
extern lv_font_t jetbrains_mono_bold_20;
Notifications::Notifications(DisplayApp *app, Pinetime::Controllers::NotificationManager &notificationManager, Modes mode) :
Screen(app), notificationManager{notificationManager}, mode{mode} {
Notifications::Notifications(DisplayApp *app,
Pinetime::Controllers::NotificationManager &notificationManager,
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
Modes mode) :
Screen(app), notificationManager{notificationManager}, alertNotificationService{alertNotificationService}, mode{mode} {
notificationManager.ClearNewNotificationFlag();
auto notification = notificationManager.GetLastNotification();
if(notification.valid) {
currentId = notification.id;
currentItem.reset(new NotificationItem("\nNotification", notification.message.data(), notification.index, notificationManager.NbNotifications(), mode));
currentItem.reset(new NotificationItem("\nNotification",
notification.message.data(),
notification.index,
notification.category,
notificationManager.NbNotifications(),
mode,
alertNotificationService));
validDisplay = true;
} else {
currentItem.reset(new NotificationItem("\nNotification", "No notification to display", 0, notificationManager.NbNotifications(), Modes::Preview));
currentItem.reset(new NotificationItem("\nNotification",
"No notification to display",
0,
notification.category,
notificationManager.NbNotifications(),
Modes::Preview,
alertNotificationService));
}
if(mode == Modes::Preview) {
static lv_style_t style_line;
lv_style_copy(&style_line, &lv_style_plain);
style_line.line.color = LV_COLOR_WHITE;
style_line.line.width = 3;
style_line.line.rounded = 0;
timeoutLine = lv_line_create(lv_scr_act(), nullptr);
lv_line_set_style(timeoutLine, LV_LINE_STYLE_MAIN, &style_line);
lv_obj_set_style_local_line_width(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3);
lv_obj_set_style_local_line_color(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
lv_obj_set_style_local_line_rounded(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, true);
lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
timeoutTickCountStart = xTaskGetTickCount();
timeoutTickCountEnd = timeoutTickCountStart + (5*1024);
@@ -69,7 +87,13 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
currentId = previousNotification.id;
currentItem.reset(nullptr);
app->SetFullRefresh(DisplayApp::FullRefreshDirections::Up);
currentItem.reset(new NotificationItem("\nNotification", previousNotification.message.data(), previousNotification.index, notificationManager.NbNotifications(), mode));
currentItem.reset(new NotificationItem("\nNotification",
previousNotification.message.data(),
previousNotification.index,
previousNotification.category,
notificationManager.NbNotifications(),
mode,
alertNotificationService));
}
return true;
case Pinetime::Applications::TouchEvents::SwipeDown: {
@@ -85,9 +109,19 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
currentId = nextNotification.id;
currentItem.reset(nullptr);
app->SetFullRefresh(DisplayApp::FullRefreshDirections::Down);
currentItem.reset(new NotificationItem("\nNotification", nextNotification.message.data(), nextNotification.index, notificationManager.NbNotifications(), mode));
currentItem.reset(new NotificationItem("\nNotification",
nextNotification.message.data(),
nextNotification.index,
nextNotification.category,
notificationManager.NbNotifications(),
mode,
alertNotificationService));
}
return true;
case Pinetime::Applications::TouchEvents::LongTap: {
notificationManager.ToggleVibrations();
return true;
}
default:
return false;
}
@@ -99,73 +133,137 @@ bool Notifications::OnButtonPushed() {
return true;
}
namespace {
static void AcceptIncomingCallEventHandler(lv_obj_t* obj, lv_event_t event) {
auto* item = static_cast<Notifications::NotificationItem*>(obj->user_data);
item->OnAcceptIncomingCall(event);
}
Notifications::NotificationItem::NotificationItem(const char *title, const char *msg, uint8_t notifNr, uint8_t notifNb, Modes mode)
: notifNr{notifNr}, notifNb{notifNb}, mode{mode} {
container1 = lv_cont_create(lv_scr_act(), nullptr);
static lv_style_t contStyle;
lv_style_copy(&contStyle, lv_cont_get_style(container1, LV_CONT_STYLE_MAIN));
contStyle.body.padding.inner = 20;
lv_cont_set_style(container1, LV_CONT_STYLE_MAIN, &contStyle);
lv_obj_set_width(container1, LV_HOR_RES);
lv_obj_set_height(container1, LV_VER_RES);
lv_obj_set_pos(container1, 0, 0);
lv_cont_set_layout(container1, LV_LAYOUT_OFF);
lv_cont_set_fit2(container1, LV_FIT_FLOOD, LV_FIT_FLOOD);
static void MuteIncomingCallEventHandler(lv_obj_t* obj, lv_event_t event) {
auto* item = static_cast<Notifications::NotificationItem*>(obj->user_data);
item->OnMuteIncomingCall(event);
}
t1 = lv_label_create(container1, nullptr);
static lv_style_t titleStyle;
static lv_style_t textStyle;
static lv_style_t bottomStyle;
lv_style_copy(&titleStyle, lv_label_get_style(t1, LV_LABEL_STYLE_MAIN));
lv_style_copy(&textStyle, lv_label_get_style(t1, LV_LABEL_STYLE_MAIN));
lv_style_copy(&bottomStyle, lv_label_get_style(t1, LV_LABEL_STYLE_MAIN));
titleStyle.body.padding.inner = 5;
titleStyle.body.grad_color = LV_COLOR_GRAY;
titleStyle.body.main_color = LV_COLOR_GRAY;
titleStyle.body.radius = 20;
textStyle.body.border.part = LV_BORDER_NONE;
textStyle.body.padding.inner = 5;
bottomStyle.body.main_color = LV_COLOR_GREEN;
bottomStyle.body.grad_color = LV_COLOR_GREEN;
bottomStyle.body.border.part = LV_BORDER_TOP;
bottomStyle.body.border.color = LV_COLOR_RED;
lv_label_set_style(t1, LV_LABEL_STYLE_MAIN, &titleStyle);
lv_label_set_long_mode(t1, LV_LABEL_LONG_BREAK);
lv_label_set_body_draw(t1, true);
lv_obj_set_width(t1, LV_HOR_RES - (titleStyle.body.padding.left + titleStyle.body.padding.right));
lv_label_set_text(t1, title);
static constexpr int16_t offscreenOffset = -20 ;
lv_obj_set_pos(t1, titleStyle.body.padding.left, offscreenOffset);
auto titleHeight = lv_obj_get_height(t1);
l1 = lv_label_create(container1, nullptr);
lv_label_set_style(l1, LV_LABEL_STYLE_MAIN, &textStyle);
lv_obj_set_pos(l1, textStyle.body.padding.left,
titleHeight + offscreenOffset + textStyle.body.padding.bottom +
textStyle.body.padding.top);
lv_label_set_long_mode(l1, LV_LABEL_LONG_BREAK);
lv_label_set_body_draw(l1, true);
lv_obj_set_width(l1, LV_HOR_RES - (textStyle.body.padding.left + textStyle.body.padding.right));
lv_label_set_text(l1, msg);
if(mode == Modes::Normal) {
if(notifNr < notifNb) {
bottomPlaceholder = lv_label_create(container1, nullptr);
lv_label_set_style(bottomPlaceholder, LV_LABEL_STYLE_MAIN, &titleStyle);
lv_label_set_long_mode(bottomPlaceholder, LV_LABEL_LONG_BREAK);
lv_label_set_body_draw(bottomPlaceholder, true);
lv_obj_set_width(bottomPlaceholder, LV_HOR_RES - (titleStyle.body.padding.left + titleStyle.body.padding.right));
lv_label_set_text(bottomPlaceholder, " ");
lv_obj_set_pos(bottomPlaceholder, titleStyle.body.padding.left, LV_VER_RES - 5);
}
static void RejectIncomingCallEventHandler(lv_obj_t *obj, lv_event_t event) {
auto* item = static_cast<Notifications::NotificationItem *>(obj->user_data);
item->OnRejectIncomingCall(event);
}
}
Notifications::NotificationItem::NotificationItem(const char *title,
const char *msg,
uint8_t notifNr,
Controllers::NotificationManager::Categories category,
uint8_t notifNb,
Modes mode,
Pinetime::Controllers::AlertNotificationService& alertNotificationService)
: notifNr{notifNr}, notifNb{notifNb}, mode{mode}, alertNotificationService{alertNotificationService} {
lv_obj_t* container1 = lv_cont_create(lv_scr_act(), NULL);
lv_obj_set_style_local_bg_color(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x222222));
lv_obj_set_style_local_pad_all(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 10);
lv_obj_set_style_local_pad_inner(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 5);
lv_obj_set_style_local_border_width(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0);
lv_obj_set_pos(container1, 0, 50);
lv_obj_set_width(container1, 240);
lv_obj_set_height(container1, 190);
lv_cont_set_layout(container1, LV_LAYOUT_COLUMN_LEFT);
lv_obj_t* alert_count = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text_fmt(alert_count, "%i/%i", notifNr, notifNb);
lv_obj_align(alert_count, NULL, LV_ALIGN_IN_TOP_RIGHT, 0, 16);
lv_obj_t* alert_type = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(alert_type, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x888888));
lv_label_set_text(alert_type, title);
lv_obj_align(alert_type, NULL, LV_ALIGN_IN_TOP_LEFT, 0, -4);
/////////
switch(category) {
default: {
lv_obj_t* alert_subject = lv_label_create(container1, nullptr);
lv_obj_set_style_local_text_color(alert_subject, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
lv_label_set_long_mode(alert_subject, LV_LABEL_LONG_BREAK);
lv_obj_set_width(alert_subject, LV_HOR_RES - 20);
lv_label_set_text(alert_subject, msg);
}
break;
case Controllers::NotificationManager::Categories::IncomingCall: {
lv_obj_t* alert_subject = lv_label_create(container1, nullptr);
lv_obj_set_style_local_text_color(alert_subject, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
lv_label_set_long_mode(alert_subject, LV_LABEL_LONG_BREAK);
lv_obj_set_width(alert_subject, LV_HOR_RES - 20);
lv_label_set_text(alert_subject, "Incoming call from");
lv_obj_t* alert_caller = lv_label_create(container1, nullptr);
lv_obj_align(alert_caller, alert_subject, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
lv_label_set_long_mode(alert_caller, LV_LABEL_LONG_BREAK);
lv_obj_set_width(alert_caller, LV_HOR_RES - 20);
lv_label_set_text(alert_caller, msg);
lv_obj_t* callBtnContainer = lv_cont_create(container1, NULL);
lv_obj_set_width(callBtnContainer, 240);
lv_obj_set_height(callBtnContainer, 90);
lv_cont_set_layout(callBtnContainer, LV_LAYOUT_ROW_MID);
lv_obj_set_style_local_bg_color(callBtnContainer, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x222222));
lv_obj_set_style_local_pad_all(callBtnContainer, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0);
lv_obj_set_style_local_margin_top(callBtnContainer, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 40);
lv_obj_set_style_local_margin_left(callBtnContainer, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, -8);
lv_obj_set_style_local_pad_inner(callBtnContainer, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 5);
lv_obj_set_style_local_border_width(callBtnContainer, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0);
bt_accept = lv_btn_create(callBtnContainer, nullptr);
bt_accept->user_data = this;
lv_obj_set_event_cb(bt_accept, AcceptIncomingCallEventHandler);
lv_obj_set_size(bt_accept, (LV_HOR_RES / 3) - 5, 80);
label_accept = lv_label_create(bt_accept, nullptr);
lv_label_set_text(label_accept, Symbols::phone);
bt_reject = lv_btn_create(callBtnContainer, nullptr);
bt_reject->user_data = this;
lv_obj_set_event_cb(bt_reject, RejectIncomingCallEventHandler);
lv_obj_set_size(bt_reject, (LV_HOR_RES / 3) - 5, 80);
label_reject = lv_label_create(bt_reject, nullptr);
lv_label_set_text(label_reject, Symbols::phoneSlash);
bt_mute = lv_btn_create(callBtnContainer, nullptr);
bt_mute->user_data = this;
lv_obj_set_event_cb(bt_mute, MuteIncomingCallEventHandler);
lv_obj_set_size(bt_mute, (LV_HOR_RES / 3) - 5, 80);
label_mute = lv_label_create(bt_mute, nullptr);
lv_label_set_text(label_mute, Symbols::volumMute);
}
break;
}
lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
lv_obj_set_size(backgroundLabel, 240, 240);
lv_obj_set_pos(backgroundLabel, 0, 0);
lv_label_set_text(backgroundLabel, "");
}
void Notifications::NotificationItem::OnAcceptIncomingCall(lv_event_t event) {
if (event != LV_EVENT_CLICKED) return;
alertNotificationService.AcceptIncomingCall();
}
void Notifications::NotificationItem::OnMuteIncomingCall(lv_event_t event) {
if (event != LV_EVENT_CLICKED) return;
alertNotificationService.MuteIncomingCall();
}
void Notifications::NotificationItem::OnRejectIncomingCall(lv_event_t event) {
if (event != LV_EVENT_CLICKED) return;
alertNotificationService.RejectIncomingCall();
}
Notifications::NotificationItem::~NotificationItem() {
lv_obj_clean(lv_scr_act());

View File

@@ -7,50 +7,68 @@
#include "components/ble/NotificationManager.h"
namespace Pinetime {
namespace Controllers {
class AlertNotificationService;
}
namespace Applications {
namespace Screens {
class Notifications : public Screen {
public:
enum class Modes {Normal, Preview};
explicit Notifications(DisplayApp* app, Pinetime::Controllers::NotificationManager& notificationManager, Modes mode);
explicit Notifications(DisplayApp* app, Pinetime::Controllers::NotificationManager& notificationManager, Pinetime::Controllers::AlertNotificationService& alertNotificationService, Modes mode);
~Notifications() override;
bool Refresh() override;
bool OnButtonPushed() override;
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
class NotificationItem {
public:
NotificationItem(const char* title, const char* msg, uint8_t notifNr, Controllers::NotificationManager::Categories, uint8_t notifNb, Modes mode, Pinetime::Controllers::AlertNotificationService& alertNotificationService);
~NotificationItem();
bool Refresh() {return false;}
void OnAcceptIncomingCall(lv_event_t event);
void OnMuteIncomingCall(lv_event_t event);
void OnRejectIncomingCall(lv_event_t event);
private:
uint8_t notifNr = 0;
uint8_t notifNb = 0;
char pageText[4];
lv_obj_t* container1;
lv_obj_t* t1;
lv_obj_t* l1;
lv_obj_t* l2;
lv_obj_t* bt_accept;
lv_obj_t* bt_mute;
lv_obj_t* bt_reject;
lv_obj_t* label_accept;
lv_obj_t* label_mute;
lv_obj_t* label_reject;
lv_obj_t* bottomPlaceholder;
Modes mode;
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
};
private:
bool running = true;
class NotificationItem {
public:
NotificationItem(const char* title, const char* msg, uint8_t notifNr, uint8_t notifNb, Modes mode);
~NotificationItem();
bool Refresh() {return false;}
private:
uint8_t notifNr = 0;
uint8_t notifNb = 0;
char pageText[4];
lv_obj_t* container1;
lv_obj_t* t1;
lv_obj_t* l1;
lv_obj_t* bottomPlaceholder;
Modes mode;
};
struct NotificationData {
const char* title;
const char* text;
};
Pinetime::Controllers::NotificationManager& notificationManager;
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
Modes mode = Modes::Normal;
std::unique_ptr<NotificationItem> currentItem;
Controllers::NotificationManager::Notification::Id currentId;
bool validDisplay = false;
lv_point_t timeoutLinePoints[2] { {0, 237}, {239, 237} };
lv_point_t timeoutLinePoints[2] { {0, 1}, {239, 1} };
lv_obj_t* timeoutLine;
uint32_t timeoutTickCountStart;
uint32_t timeoutTickCountEnd;

View File

@@ -3,8 +3,6 @@
#include "../LittleVgl.h"
using namespace Pinetime::Applications::Screens;
extern lv_font_t jetbrains_mono_extrabold_compressed;
extern lv_font_t jetbrains_mono_bold_20;
namespace{
const uint8_t paddle_map[] = {

View File

@@ -26,6 +26,16 @@ namespace Pinetime {
static constexpr const char* paintbrush = "\xEF\x87\xBC";
static constexpr const char* paddle = "\xEF\x91\x9D";
static constexpr const char* map = "\xEF\x96\xa0";
static constexpr const char* qrcode = "\xEF\x80\xa9";
static constexpr const char* phone = "\xEF\x82\x95";
static constexpr const char* phoneSlash = "\xEF\x8F\x9D";
static constexpr const char* volumMute = "\xEF\x9A\xA9";
static constexpr const char* volumUp = "\xEF\x80\xA8";
static constexpr const char* volumDown = "\xEF\x80\xA7";
static constexpr const char* stepForward = "\xEF\x81\x91";
static constexpr const char* stepBackward = "\xEF\x81\x88";
static constexpr const char* play = "\xEF\x81\x8B";
static constexpr const char* pause = "\xEF\x81\x8C";
}
}
}

View File

@@ -3,8 +3,6 @@
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);
uint32_t* eventDataPtr = (uint32_t*) lv_event_get_data();
@@ -22,10 +20,9 @@ Tile::Tile(DisplayApp* app, std::array<Applications, 6>& applications) : Screen(
appIndex++;
}
}
modal.reset(new Modal(app));
btnm1 = lv_btnm_create(lv_scr_act(), nullptr);
lv_btnm_set_map(btnm1, btnm_map1);
btnm1 = lv_btnmatrix_create(lv_scr_act(), nullptr);
lv_btnmatrix_set_map(btnm1, btnm_map1);
lv_obj_set_size(btnm1, LV_HOR_RES, LV_VER_RES);
btnm1->user_data = this;

View File

@@ -3,7 +3,6 @@
#include <lvgl/lvgl.h>
#include <cstdint>
#include <memory>
#include "Modal.h"
#include "Screen.h"
#include "../Apps.h"
@@ -29,8 +28,6 @@ namespace Pinetime {
lv_obj_t * btnm1;
bool running = true;
std::unique_ptr<Modal> modal;
const char* btnm_map1[8];
Pinetime::Applications::Apps apps[6];
};

View File

@@ -8,43 +8,50 @@
using namespace Pinetime::Applications::Screens;
extern lv_font_t jetbrains_mono_bold_20;
Twos::Twos(Pinetime::Applications::DisplayApp *app) : Screen(app) {
// create styles to apply to different valued tiles
static lv_style_t style_cell1;
lv_style_copy(&style_cell1, &lv_style_plain);
style_cell1.body.border.width = 1;
style_cell1.text.font = &jetbrains_mono_bold_20;
style_cell1.body.padding.top = 16;
style_cell1.body.padding.bottom = 16;
style_cell1.body.main_color = LV_COLOR_MAKE(214, 197, 165);
style_cell1.body.grad_color = LV_COLOR_MAKE(214, 197, 165);
style_cell1.text.color = LV_COLOR_BLACK;
lv_style_init(&style_cell1);
lv_style_init(&style_cell2);
lv_style_init(&style_cell3);
lv_style_init(&style_cell4);
lv_style_init(&style_cell5);
static lv_style_t style_cell2;
lv_style_copy(&style_cell2, &style_cell1);
style_cell2.body.main_color = LV_COLOR_MAKE(209, 146, 92);
style_cell2.body.grad_color = LV_COLOR_MAKE(209, 146, 92);
style_cell2.text.color = LV_COLOR_WHITE;
lv_style_set_border_color(&style_cell1, LV_STATE_DEFAULT, lv_color_hex(0xbbada0));
lv_style_set_border_width(&style_cell1, LV_STATE_DEFAULT, 3);
lv_style_set_bg_opa(&style_cell1, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&style_cell1, LV_STATE_DEFAULT, lv_color_hex(0xcdc0b4));
static lv_style_t style_cell3;
lv_style_copy(&style_cell3, &style_cell2);
style_cell3.body.main_color = LV_COLOR_MAKE(246, 94, 59);
style_cell3.body.grad_color = LV_COLOR_MAKE(246, 94, 59);
lv_style_set_border_color(&style_cell2, LV_STATE_DEFAULT, lv_color_hex(0xbbada0));
lv_style_set_border_width(&style_cell2, LV_STATE_DEFAULT, 3);
lv_style_set_bg_opa(&style_cell2, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&style_cell2, LV_STATE_DEFAULT, lv_color_hex(0xefdfc6));
static lv_style_t style_cell4;
lv_style_copy(&style_cell4, &style_cell3);
style_cell4.body.main_color = LV_COLOR_MAKE(212, 170, 28);
style_cell4.body.grad_color = LV_COLOR_MAKE(212, 170, 28);
lv_style_set_border_color(&style_cell3, LV_STATE_DEFAULT, lv_color_hex(0xbbada0));
lv_style_set_border_width(&style_cell3, LV_STATE_DEFAULT, 3);
lv_style_set_bg_opa(&style_cell3, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&style_cell3, LV_STATE_DEFAULT, lv_color_hex(0xef9263));
lv_style_set_border_color(&style_cell4, LV_STATE_DEFAULT, lv_color_hex(0xbbada0));
lv_style_set_border_width(&style_cell4, LV_STATE_DEFAULT, 3);
lv_style_set_bg_opa(&style_cell4, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&style_cell4, LV_STATE_DEFAULT, lv_color_hex(0xf76142));
//lv_style_set_text_color(&style_cell4, LV_STATE_DEFAULT, LV_COLOR_WHITE);
lv_style_set_border_color(&style_cell5, LV_STATE_DEFAULT, lv_color_hex(0xbbada0));
lv_style_set_border_width(&style_cell5, LV_STATE_DEFAULT, 3);
lv_style_set_bg_opa(&style_cell5, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&style_cell5, LV_STATE_DEFAULT, lv_color_hex(0x007dc5));
//lv_style_set_text_color(&style_cell5, LV_STATE_DEFAULT, LV_COLOR_WHITE);
// format grid display
gridDisplay = lv_table_create(lv_scr_act(), nullptr);
lv_table_set_style(gridDisplay, LV_TABLE_STYLE_CELL1, &style_cell1);
lv_table_set_style(gridDisplay, LV_TABLE_STYLE_CELL2, &style_cell2);
lv_table_set_style(gridDisplay, LV_TABLE_STYLE_CELL3, &style_cell3);
lv_table_set_style(gridDisplay, LV_TABLE_STYLE_CELL4, &style_cell4);
gridDisplay = lv_table_create(lv_scr_act(), nullptr);
lv_obj_add_style(gridDisplay, LV_TABLE_PART_CELL1, &style_cell1);
lv_obj_add_style(gridDisplay, LV_TABLE_PART_CELL2, &style_cell2);
lv_obj_add_style(gridDisplay, LV_TABLE_PART_CELL3, &style_cell3);
lv_obj_add_style(gridDisplay, LV_TABLE_PART_CELL4, &style_cell4);
lv_obj_add_style(gridDisplay, LV_TABLE_PART_CELL4 + 1, &style_cell5);
lv_table_set_col_cnt(gridDisplay, 4);
lv_table_set_row_cnt(gridDisplay, 4);
lv_table_set_col_width(gridDisplay, 0, LV_HOR_RES/4);
@@ -53,11 +60,13 @@ Twos::Twos(Pinetime::Applications::DisplayApp *app) : Screen(app) {
lv_table_set_col_width(gridDisplay, 3, LV_HOR_RES/4);
lv_obj_align(gridDisplay, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
lv_obj_clean_style_list(gridDisplay, LV_TABLE_PART_BG);
// initialize grid
for(int row = 0; row < 4; row++) {
for(int col = 0; col < 4; col++) {
grid[row][col].value = 0;
lv_table_set_cell_type(gridDisplay, row, col, 2);
lv_table_set_cell_type(gridDisplay, row, col, 1);
lv_table_set_cell_align(gridDisplay, row, col, LV_LABEL_ALIGN_CENTER);
}
}
@@ -68,11 +77,23 @@ Twos::Twos(Pinetime::Applications::DisplayApp *app) : Screen(app) {
scoreText = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_width(scoreText, LV_HOR_RES);
lv_label_set_align(scoreText, LV_ALIGN_IN_LEFT_MID);
lv_obj_align(scoreText, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0);
lv_label_set_text(scoreText, ("Score: " + std::to_string(score)).c_str());
lv_obj_align(scoreText, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 10);
lv_label_set_recolor(scoreText, true);
lv_label_set_text_fmt(scoreText, "Score #FFFF00 %i#", score);
lv_obj_t * backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
lv_obj_set_size(backgroundLabel, 240, 240);
lv_obj_set_pos(backgroundLabel, 0, 0);
lv_label_set_text(backgroundLabel, "");
}
Twos::~Twos() {
lv_style_reset(&style_cell1);
lv_style_reset(&style_cell2);
lv_style_reset(&style_cell3);
lv_style_reset(&style_cell4);
lv_style_reset(&style_cell5);
lv_obj_clean(lv_scr_act());
}
@@ -117,7 +138,7 @@ bool Twos::tryMerge(Tile grid[][4], int &newRow, int &newCol, int oldRow, int ol
unsigned int newVal = grid[oldRow][oldCol].value *= 2;
grid[newRow][newCol].value = newVal;
score += newVal;
lv_label_set_text(scoreText, ("Score: " + std::to_string(score)).c_str());
lv_label_set_text_fmt(scoreText, "Score #FFFF00 %i#", score);
grid[oldRow][oldCol].value = 0;
grid[newRow][newCol].merged = true;
return true;
@@ -250,20 +271,22 @@ void Twos::updateGridDisplay(Tile grid[][4]) {
}
switch (grid[row][col].value) {
case 0:
lv_table_set_cell_type(gridDisplay, row, col, 1);
break;
case 2:
case 4:
lv_table_set_cell_type(gridDisplay, row, col, 1);
lv_table_set_cell_type(gridDisplay, row, col, 2);
break;
case 8:
case 16:
lv_table_set_cell_type(gridDisplay, row, col, 2);
lv_table_set_cell_type(gridDisplay, row, col, 3);
break;
case 32:
case 64:
lv_table_set_cell_type(gridDisplay, row, col, 3);
lv_table_set_cell_type(gridDisplay, row, col, 4);
break;
default:
lv_table_set_cell_type(gridDisplay, row, col, 4);
lv_table_set_cell_type(gridDisplay, row, col, 5);
break;
}
}

View File

@@ -19,6 +19,13 @@ namespace Pinetime {
bool OnTouchEvent(TouchEvents event) override;
private:
lv_style_t style_cell1;
lv_style_t style_cell2;
lv_style_t style_cell3;
lv_style_t style_cell4;
lv_style_t style_cell5;
bool running = true;
lv_obj_t *scoreText;
lv_obj_t *gridDisplay;