From a97faf8e9e84053d6db37549cc4211866cb3b89f Mon Sep 17 00:00:00 2001 From: JF Date: Sat, 8 Feb 2020 18:01:02 +0100 Subject: First quick'n'dirty integration of LittleVGL. Needs some cleaning. --- src/DisplayApp/DisplayApp.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/DisplayApp/DisplayApp.cpp') diff --git a/src/DisplayApp/DisplayApp.cpp b/src/DisplayApp/DisplayApp.cpp index ca139423..d2bf1bc3 100644 --- a/src/DisplayApp/DisplayApp.cpp +++ b/src/DisplayApp/DisplayApp.cpp @@ -11,6 +11,8 @@ #include #include #include +#include +#include "lv_port_disp.h" using namespace Pinetime::Applications; @@ -26,13 +28,14 @@ DisplayApp::DisplayApp(Pinetime::Drivers::St7789& lcd, batteryController{batteryController}, bleController{bleController}, dateTimeController{dateTimeController}, - clockScreen{gfx} { + clockScreen{gfx}, + messageScreen{gfx}{ msgQueue = xQueueCreate(queueSize, itemSize); - currentScreen = &clockScreen; + currentScreen = &messageScreen; } void DisplayApp::Start() { - if (pdPASS != xTaskCreate(DisplayApp::Process, "DisplayApp", 256, this, 0, &taskHandle)) + if (pdPASS != xTaskCreate(DisplayApp::Process, "DisplayApp", 1024, this, 0, &taskHandle)) APP_ERROR_HANDLER(NRF_ERROR_NO_MEM); } @@ -40,7 +43,11 @@ void DisplayApp::Process(void *instance) { auto *app = static_cast(instance); NRF_LOG_INFO("DisplayApp task started!"); app->InitHw(); + lv_init(); + lv_port_disp_init(); + while (1) { + lv_task_handler(); app->Refresh(); } } @@ -53,7 +60,7 @@ void DisplayApp::InitHw() { nrf_gpio_pin_clear(pinLcdBacklight2); nrf_gpio_pin_clear(pinLcdBacklight3); - currentScreen->Refresh(true); + } uint32_t acc = 0; @@ -112,11 +119,14 @@ void DisplayApp::Refresh() { } } +bool first = true; + void DisplayApp::RunningState() { clockScreen.SetCurrentDateTime(dateTimeController.CurrentDateTime()); if(currentScreen != nullptr) { - currentScreen->Refresh(false); + currentScreen->Refresh(first); + first = false; } } -- cgit v1.2.3-70-g09d2 From e65c9fa18138e8623d5f8e5e8f25fcf0e3d3cf67 Mon Sep 17 00:00:00 2001 From: JF Date: Mon, 10 Feb 2020 21:05:33 +0100 Subject: Integration of lvgl : continued... --- src/CMakeLists.txt | 11 +- src/Components/DateTime/DateTimeController.cpp | 2 +- src/DisplayApp/DisplayApp.cpp | 21 +- src/DisplayApp/DisplayApp.h | 3 + src/DisplayApp/Fonts/jetbrains_mono_bold_20.c | 594 +++++++++++++++++++++ .../Fonts/jetbrains_mono_extrabold_compressed.c | 507 ++++++++++++++++++ src/DisplayApp/LittleVgl.cpp | 59 ++ src/DisplayApp/LittleVgl.h | 29 + src/DisplayApp/Screens/Clock.cpp | 77 +-- src/DisplayApp/Screens/Clock.h | 15 +- src/DisplayApp/Screens/Message.cpp | 17 +- src/DisplayApp/Screens/Message.h | 3 + src/DisplayApp/lv_port_disp.cpp | 206 ------- src/DisplayApp/lv_port_disp.h | 45 -- src/libs/lv_conf.h | 12 +- src/main.cpp | 8 +- src/sdk_config.h | 6 +- 17 files changed, 1301 insertions(+), 314 deletions(-) create mode 100644 src/DisplayApp/Fonts/jetbrains_mono_bold_20.c create mode 100644 src/DisplayApp/Fonts/jetbrains_mono_extrabold_compressed.c create mode 100644 src/DisplayApp/LittleVgl.cpp create mode 100644 src/DisplayApp/LittleVgl.h delete mode 100644 src/DisplayApp/lv_port_disp.cpp delete mode 100644 src/DisplayApp/lv_port_disp.h (limited to 'src/DisplayApp/DisplayApp.cpp') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3395ebef..0b220423 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -118,7 +118,6 @@ set(LVGL_SRC libs/lvgl/src/lv_font/lv_font_fmt_txt.c libs/lvgl/src/lv_font/lv_font_fmt_txt.h libs/lvgl/src/lv_font/lv_font_roboto_16.c - libs/lvgl/src/lv_font/lv_font_roboto_28_compressed.c libs/lvgl/src/lv_font/lv_symbol_def.h libs/lvgl/src/lv_themes/lv_theme.c @@ -133,6 +132,10 @@ set(LVGL_SRC libs/lvgl/src/lv_objx/lv_label.h libs/lvgl/src/lv_objx/lv_label.c + libs/lvgl/src/lv_themes/lv_theme.c + libs/lvgl/src/lv_themes/lv_theme.h + libs/lvgl/src/lv_themes/lv_theme_night.h + libs/lvgl/src/lv_themes/lv_theme_night.c ) @@ -159,7 +162,9 @@ list(APPEND SOURCE_FILES FreeRTOS/port_cmsis.c ${LVGL_SRC} - DisplayApp/lv_port_disp.cpp + DisplayApp/LittleVgl.cpp + DisplayApp/Fonts/jetbrains_mono_extrabold_compressed.c + DisplayApp/Fonts/jetbrains_mono_bold_20.c ) set(INCLUDE_FILES @@ -191,7 +196,7 @@ set(INCLUDE_FILES libs/date/includes/date/ptz.h libs/date/includes/date/tz_private.h - DisplayApp/lv_port_disp.h + DisplayApp/LittleVgl.h ) include_directories( diff --git a/src/Components/DateTime/DateTimeController.cpp b/src/Components/DateTime/DateTimeController.cpp index ed6d70fb..81d45416 100644 --- a/src/Components/DateTime/DateTimeController.cpp +++ b/src/Components/DateTime/DateTimeController.cpp @@ -49,7 +49,7 @@ void DateTime::UpdateTime(uint32_t systickCounter) { previousSystickCounter = 0xffffff - (rest - systickCounter); } - currentDateTime += std::chrono::seconds (correctedDelta); + currentDateTime += std::chrono::milliseconds (systickDelta*10); auto dp = date::floor(currentDateTime); auto time = date::make_time(currentDateTime-dp); diff --git a/src/DisplayApp/DisplayApp.cpp b/src/DisplayApp/DisplayApp.cpp index d2bf1bc3..d29027fb 100644 --- a/src/DisplayApp/DisplayApp.cpp +++ b/src/DisplayApp/DisplayApp.cpp @@ -12,18 +12,19 @@ #include #include #include -#include "lv_port_disp.h" using namespace Pinetime::Applications; DisplayApp::DisplayApp(Pinetime::Drivers::St7789& lcd, Pinetime::Components::Gfx& gfx, + Pinetime::Components::LittleVgl& lvgl, Pinetime::Drivers::Cst816S& touchPanel, Controllers::Battery &batteryController, Controllers::Ble &bleController, Controllers::DateTime &dateTimeController) : lcd{lcd}, gfx{gfx}, + lvgl{lvgl}, touchPanel{touchPanel}, batteryController{batteryController}, bleController{bleController}, @@ -31,7 +32,7 @@ DisplayApp::DisplayApp(Pinetime::Drivers::St7789& lcd, clockScreen{gfx}, messageScreen{gfx}{ msgQueue = xQueueCreate(queueSize, itemSize); - currentScreen = &messageScreen; + currentScreen = &clockScreen; } void DisplayApp::Start() { @@ -43,12 +44,15 @@ void DisplayApp::Process(void *instance) { auto *app = static_cast(instance); NRF_LOG_INFO("DisplayApp task started!"); app->InitHw(); - lv_init(); - lv_port_disp_init(); while (1) { - lv_task_handler(); + app->Refresh(); + + auto before = nrf_rtc_counter_get(portNRF_RTC_REG); + lv_task_handler(); + auto after = nrf_rtc_counter_get(portNRF_RTC_REG); + NRF_LOG_INFO("duration : %d", (after-before)); } } @@ -59,8 +63,6 @@ void DisplayApp::InitHw() { nrf_gpio_pin_clear(pinLcdBacklight1); nrf_gpio_pin_clear(pinLcdBacklight2); nrf_gpio_pin_clear(pinLcdBacklight3); - - } uint32_t acc = 0; @@ -75,10 +77,10 @@ void DisplayApp::Refresh() { break; case States::Running: RunningState(); - queueTimeout = 1000; + queueTimeout = 1; break; } - +/* Messages msg; if (xQueueReceive(msgQueue, &msg, queueTimeout)) { switch (msg) { @@ -117,6 +119,7 @@ void DisplayApp::Refresh() { break; } } + */ } bool first = true; diff --git a/src/DisplayApp/DisplayApp.h b/src/DisplayApp/DisplayApp.h index 00637a05..8cd26ce8 100644 --- a/src/DisplayApp/DisplayApp.h +++ b/src/DisplayApp/DisplayApp.h @@ -11,6 +11,7 @@ #include #include "Fonts/lcdfont14.h" #include "../drivers/Cst816s.h" +#include "LittleVgl.h" #include #include #include @@ -25,6 +26,7 @@ namespace Pinetime { enum class Messages : uint8_t {GoToSleep, GoToRunning, UpdateDateTime, UpdateBleConnection, UpdateBatteryLevel, TouchEvent} ; DisplayApp(Pinetime::Drivers::St7789& lcd, Pinetime::Components::Gfx& gfx, + Pinetime::Components::LittleVgl& lvgl, Pinetime::Drivers::Cst816S&, Controllers::Battery &batteryController, Controllers::Ble &bleController, @@ -38,6 +40,7 @@ namespace Pinetime { void InitHw(); Pinetime::Drivers::St7789& lcd; Pinetime::Components::Gfx& gfx; + Pinetime::Components::LittleVgl lvgl; const FONT_INFO largeFont {lCD_70ptFontInfo.height, lCD_70ptFontInfo.startChar, lCD_70ptFontInfo.endChar, lCD_70ptFontInfo.spacePixels, lCD_70ptFontInfo.charInfo, lCD_70ptFontInfo.data}; const FONT_INFO smallFont {lCD_14ptFontInfo.height, lCD_14ptFontInfo.startChar, lCD_14ptFontInfo.endChar, lCD_14ptFontInfo.spacePixels, lCD_14ptFontInfo.charInfo, lCD_14ptFontInfo.data}; void Refresh(); diff --git a/src/DisplayApp/Fonts/jetbrains_mono_bold_20.c b/src/DisplayApp/Fonts/jetbrains_mono_bold_20.c new file mode 100644 index 00000000..e7d053b8 --- /dev/null +++ b/src/DisplayApp/Fonts/jetbrains_mono_bold_20.c @@ -0,0 +1,594 @@ +#include "lvgl/lvgl.h" + +/******************************************************************************* + * Size: 20 px + * Bpp: 1 + * Opts: + ******************************************************************************/ + +#ifndef JETBRAINS_MONO_BOLD_20 +#define JETBRAINS_MONO_BOLD_20 1 +#endif + +#if JETBRAINS_MONO_BOLD_20 + +/*----------------- + * BITMAPS + *----------------*/ + +/*Store the image of the glyphs*/ +static LV_ATTRIBUTE_LARGE_CONST const uint8_t gylph_bitmap[] = { + /* U+20 " " */ + 0x0, + + /* U+21 "!" */ + 0xff, 0xff, 0xff, 0xe0, 0xf, 0xc0, + + /* U+22 "\"" */ + 0xef, 0xdf, 0xbf, 0x7e, 0xfd, 0xc0, + + /* U+23 "#" */ + 0x8, 0xc3, 0x10, 0x62, 0x3f, 0xf7, 0xfe, 0x23, + 0x4, 0x61, 0x88, 0x31, 0x1f, 0xfb, 0xff, 0x19, + 0x82, 0x30, 0xc4, 0x0, + + /* U+24 "$" */ + 0x1c, 0x7, 0x3, 0xf1, 0xfe, 0xe3, 0xf8, 0x7e, + 0x3, 0xe0, 0x7f, 0x7, 0xe0, 0x3c, 0x7, 0xe1, + 0xfc, 0xf7, 0xf8, 0xfc, 0x1c, 0x7, 0x0, + + /* U+25 "%" */ + 0x78, 0x1f, 0x83, 0x30, 0x66, 0x1f, 0xcc, 0xf2, + 0x1, 0x80, 0xde, 0x67, 0xf8, 0xcc, 0x19, 0x83, + 0x30, 0x7e, 0x7, 0x80, + + /* U+26 "&" */ + 0x1e, 0x7, 0xe1, 0xce, 0x38, 0x7, 0x0, 0x70, + 0x1e, 0x7, 0x66, 0xed, 0xdc, 0xf3, 0x9c, 0x73, + 0xcf, 0xfc, 0xf9, 0x80, + + /* U+27 "'" */ + 0xff, 0xff, 0xc0, + + /* U+28 "(" */ + 0x2, 0x1c, 0xfb, 0xc7, 0x1e, 0x38, 0x70, 0xe1, + 0xc3, 0x87, 0xe, 0x1c, 0x3c, 0x38, 0x38, 0x7c, + 0x38, + + /* U+29 ")" */ + 0x1, 0xc3, 0xc1, 0xc1, 0xc3, 0xc3, 0x87, 0xe, + 0x1c, 0x38, 0x70, 0xe1, 0xc7, 0x8e, 0x79, 0xe3, + 0x80, + + /* U+2A "*" */ + 0xc, 0x3, 0x8, 0xc7, 0xb7, 0x7f, 0x83, 0x1, + 0xe0, 0xcc, 0x73, 0x80, 0x0, + + /* U+2B "+" */ + 0x1c, 0x7, 0x1, 0xc3, 0xff, 0xff, 0xc7, 0x1, + 0xc0, 0x70, 0x1c, 0x0, + + /* U+2C "," */ + 0x7b, 0x9c, 0xce, 0x60, + + /* U+2D "-" */ + 0xff, 0xff, + + /* U+2E "." */ + 0x6f, 0xf6, + + /* U+2F "/" */ + 0x1, 0xc0, 0x60, 0x38, 0xe, 0x3, 0x1, 0xc0, + 0x70, 0x18, 0xe, 0x3, 0x1, 0xc0, 0x70, 0x18, + 0xe, 0x3, 0x80, 0xc0, 0x70, 0x18, 0xe, 0x0, + + /* U+30 "0" */ + 0x3f, 0x1f, 0xef, 0x3f, 0x87, 0xe1, 0xfb, 0x7e, + 0xdf, 0xb7, 0xed, 0xf8, 0x7e, 0x1f, 0xcf, 0x7f, + 0x8f, 0x80, + + /* U+31 "1" */ + 0x3c, 0x3e, 0x3f, 0x13, 0x81, 0xc0, 0xe0, 0x70, + 0x38, 0x1c, 0xe, 0x7, 0x3, 0x8f, 0xff, 0xfc, + + /* U+32 "2" */ + 0x1f, 0x1f, 0xef, 0x3f, 0x87, 0x1, 0xc0, 0x70, + 0x38, 0x1e, 0xf, 0x7, 0x87, 0x83, 0xc0, 0xff, + 0xff, 0xf0, + + /* U+33 "3" */ + 0x7f, 0xdf, 0xf0, 0x3c, 0x1c, 0x1c, 0x7, 0xc1, + 0xf8, 0xf, 0x1, 0xc0, 0x7e, 0x1d, 0x8f, 0x7f, + 0x87, 0xc0, + + /* U+34 "4" */ + 0x7, 0x7, 0x3, 0x83, 0x83, 0x81, 0xc1, 0xcf, + 0xe7, 0xe3, 0xff, 0xff, 0xe0, 0x70, 0x38, 0x1c, + + /* U+35 "5" */ + 0xff, 0x7f, 0xb8, 0x1c, 0xe, 0x7, 0x73, 0xfd, + 0xcf, 0x3, 0x81, 0xc0, 0xfc, 0xff, 0xf1, 0xf0, + + /* U+36 "6" */ + 0x6, 0x3, 0x1, 0xc0, 0x60, 0x30, 0x1b, 0xc7, + 0xfb, 0xcf, 0xe1, 0xf8, 0x7e, 0x1f, 0xcf, 0x7f, + 0x87, 0x80, + + /* U+37 "7" */ + 0xff, 0xff, 0xfe, 0xb, 0x86, 0x1, 0x80, 0xc0, + 0x30, 0x18, 0x6, 0x3, 0x80, 0xc0, 0x70, 0x18, + 0xe, 0x0, + + /* U+38 "8" */ + 0x3e, 0x1f, 0xce, 0x3b, 0x6, 0xe3, 0x9f, 0xc7, + 0xf1, 0x8e, 0xc1, 0xf0, 0x7c, 0x1f, 0x8f, 0x7f, + 0x8f, 0x80, + + /* U+39 "9" */ + 0x1e, 0x1f, 0xef, 0x3f, 0x87, 0xe1, 0xf8, 0x7f, + 0x3d, 0xfe, 0x3d, 0x80, 0xc0, 0x60, 0x38, 0xc, + 0x6, 0x0, + + /* U+3A ":" */ + 0xff, 0x80, 0x0, 0xff, 0x80, + + /* U+3B ";" */ + 0x7b, 0xde, 0x0, 0x0, 0x0, 0x7b, 0x9c, 0xce, + 0x60, + + /* U+3C "<" */ + 0x0, 0x81, 0xc3, 0xe7, 0xcf, 0x6, 0x3, 0xc0, + 0x7c, 0xf, 0x81, 0xc0, 0x20, + + /* U+3D "=" */ + 0xff, 0xff, 0xc0, 0x0, 0x0, 0x7, 0xff, 0xfe, + + /* U+3E ">" */ + 0x0, 0x70, 0x3e, 0x7, 0xc0, 0xf8, 0xc, 0x1e, + 0x7c, 0xf8, 0x70, 0x20, 0x0, + + /* U+3F "?" */ + 0xfc, 0xfe, 0xf, 0x7, 0x7, 0xf, 0x3e, 0x3c, + 0x30, 0x30, 0x0, 0x0, 0x70, 0x70, + + /* U+40 "@" */ + 0x1f, 0x87, 0xf9, 0xc3, 0xf0, 0x3c, 0x77, 0x9f, + 0xf3, 0x1e, 0x63, 0xcc, 0x79, 0x8f, 0x31, 0xe7, + 0xfc, 0x77, 0xc0, 0x1c, 0x1, 0xf0, 0x1e, 0x0, + + /* U+41 "A" */ + 0xf, 0x0, 0xf0, 0xf, 0x1, 0xf8, 0x19, 0x81, + 0x98, 0x19, 0x83, 0x9c, 0x3f, 0xc3, 0xfc, 0x70, + 0xe7, 0xe, 0x60, 0x66, 0x6, + + /* U+42 "B" */ + 0xfe, 0x3f, 0xce, 0x3b, 0x8e, 0xe3, 0xb8, 0xcf, + 0xe3, 0xfc, 0xe3, 0xb8, 0x7e, 0x1f, 0x8f, 0xff, + 0xbf, 0xc0, + + /* U+43 "C" */ + 0x3f, 0x1f, 0xef, 0x3f, 0x87, 0xe0, 0x38, 0xe, + 0x3, 0x80, 0xe0, 0x38, 0xe, 0x1f, 0xcf, 0x7f, + 0x8f, 0xc0, + + /* U+44 "D" */ + 0xfe, 0x3f, 0xee, 0x3f, 0x87, 0xe1, 0xf8, 0x7e, + 0x1f, 0x87, 0xe1, 0xf8, 0x7e, 0x1f, 0x8f, 0xff, + 0xbf, 0x80, + + /* U+45 "E" */ + 0xff, 0xff, 0xf8, 0x1c, 0xe, 0x7, 0x3, 0xfd, + 0xfe, 0xe0, 0x70, 0x38, 0x1c, 0xf, 0xff, 0xfc, + + /* U+46 "F" */ + 0xff, 0xff, 0xf8, 0x1c, 0xe, 0x7, 0x3, 0xff, + 0xff, 0xe0, 0x70, 0x38, 0x1c, 0xe, 0x7, 0x0, + + /* U+47 "G" */ + 0x3f, 0x1f, 0xef, 0x3f, 0x87, 0xe0, 0x38, 0xe, + 0x7f, 0x9f, 0xe1, 0xf8, 0x7e, 0x1f, 0xcf, 0x7f, + 0x87, 0x80, + + /* U+48 "H" */ + 0xe3, 0xf1, 0xf8, 0xfc, 0x7e, 0x3f, 0x1f, 0xff, + 0xff, 0xe3, 0xf1, 0xf8, 0xfc, 0x7e, 0x3f, 0x1c, + + /* U+49 "I" */ + 0xff, 0xff, 0xc7, 0x3, 0x81, 0xc0, 0xe0, 0x70, + 0x38, 0x1c, 0xe, 0x7, 0x3, 0x8f, 0xff, 0xfc, + + /* U+4A "J" */ + 0x3f, 0xcf, 0xf0, 0x1c, 0x7, 0x1, 0xc0, 0x70, + 0x1c, 0x7, 0x1, 0xc0, 0x7e, 0x1f, 0x8f, 0x7f, + 0x8f, 0xc0, + + /* U+4B "K" */ + 0xe1, 0xdc, 0x3b, 0x8e, 0x71, 0xce, 0x31, 0xce, + 0x3f, 0x87, 0xf0, 0xe7, 0x1c, 0x63, 0x8e, 0x70, + 0xce, 0x1d, 0xc3, 0x80, + + /* U+4C "L" */ + 0xe0, 0x70, 0x38, 0x1c, 0xe, 0x7, 0x3, 0x81, + 0xc0, 0xe0, 0x70, 0x38, 0x1c, 0xf, 0xff, 0xfc, + + /* U+4D "M" */ + 0xe1, 0xf8, 0x7f, 0x3f, 0xcf, 0xda, 0xf7, 0xbd, + 0xef, 0x33, 0xc0, 0xf0, 0x3c, 0xf, 0x3, 0xc0, + 0xf0, 0x30, + + /* U+4E "N" */ + 0xe1, 0xf0, 0xfc, 0x7e, 0x3d, 0x9e, 0xcf, 0x67, + 0x9b, 0xcd, 0xe6, 0xf1, 0xf8, 0xfc, 0x3e, 0x1c, + + /* U+4F "O" */ + 0x3f, 0x1f, 0xef, 0x3f, 0x87, 0xe1, 0xf8, 0x7e, + 0x1f, 0x87, 0xe1, 0xf8, 0x7e, 0x1f, 0xcf, 0x7f, + 0x8f, 0x80, + + /* U+50 "P" */ + 0xff, 0x3f, 0xee, 0x3f, 0x87, 0xe1, 0xf8, 0xff, + 0xfb, 0xfc, 0xe0, 0x38, 0xe, 0x3, 0x80, 0xe0, + 0x38, 0x0, + + /* U+51 "Q" */ + 0x3f, 0x1f, 0xef, 0x3f, 0x87, 0xe1, 0xf8, 0x7e, + 0x1f, 0x87, 0xe1, 0xf8, 0x7e, 0x1f, 0xcf, 0x7f, + 0x8f, 0x80, 0x70, 0xe, 0x1, 0xc0, + + /* U+52 "R" */ + 0xff, 0x3f, 0xee, 0x3f, 0x87, 0xe1, 0xf8, 0xff, + 0xfb, 0xf8, 0xe6, 0x39, 0xce, 0x33, 0x8e, 0xe3, + 0xb8, 0x70, + + /* U+53 "S" */ + 0x3f, 0x1f, 0xee, 0x3f, 0x87, 0xe0, 0x3e, 0x7, + 0xf0, 0x7e, 0x3, 0xc0, 0x7e, 0x1f, 0xcf, 0x7f, + 0x8f, 0xc0, + + /* U+54 "T" */ + 0xff, 0xff, 0xf0, 0xe0, 0x38, 0xe, 0x3, 0x80, + 0xe0, 0x38, 0xe, 0x3, 0x80, 0xe0, 0x38, 0xe, + 0x3, 0x80, + + /* U+55 "U" */ + 0xe3, 0xf1, 0xf8, 0xfc, 0x7e, 0x3f, 0x1f, 0x8f, + 0xc7, 0xe3, 0xf1, 0xf8, 0xfc, 0x77, 0xf1, 0xf0, + + /* U+56 "V" */ + 0x60, 0x66, 0x6, 0x70, 0xe7, 0xe, 0x30, 0xc3, + 0xc, 0x39, 0xc1, 0x98, 0x19, 0x81, 0x98, 0x1f, + 0x80, 0xf0, 0xf, 0x0, 0xf0, + + /* U+57 "W" */ + 0xc6, 0x3c, 0x73, 0x47, 0x36, 0xf3, 0x6f, 0x26, + 0xf6, 0x6d, 0x66, 0xd6, 0x69, 0x66, 0x9e, 0x69, + 0xe6, 0x9e, 0x39, 0xe3, 0x9e, + + /* U+58 "X" */ + 0xe1, 0xd8, 0x67, 0x38, 0xcc, 0x3f, 0x7, 0x81, + 0xe0, 0x78, 0x1e, 0xf, 0xc3, 0x31, 0xce, 0xe1, + 0xf8, 0x70, + + /* U+59 "Y" */ + 0xe0, 0xfc, 0x1d, 0xc7, 0x38, 0xe3, 0x98, 0x77, + 0x6, 0xc0, 0xf8, 0xe, 0x1, 0xc0, 0x38, 0x7, + 0x0, 0xe0, 0x1c, 0x0, + + /* U+5A "Z" */ + 0xff, 0xff, 0xc0, 0xe0, 0xe0, 0x60, 0x70, 0x70, + 0x38, 0x38, 0x38, 0x1c, 0x1c, 0xf, 0xff, 0xfc, + + /* U+5B "[" */ + 0xff, 0xfe, 0x38, 0xe3, 0x8e, 0x38, 0xe3, 0x8e, + 0x38, 0xe3, 0x8e, 0x38, 0xff, 0xf0, + + /* U+5C "\\" */ + 0xe0, 0x18, 0x7, 0x1, 0xc0, 0x30, 0xe, 0x3, + 0x80, 0x60, 0x1c, 0x3, 0x0, 0xe0, 0x38, 0x6, + 0x1, 0xc0, 0x70, 0xc, 0x3, 0x80, 0x60, 0x1c, + + /* U+5D "]" */ + 0xff, 0xf1, 0xc7, 0x1c, 0x71, 0xc7, 0x1c, 0x71, + 0xc7, 0x1c, 0x71, 0xc7, 0xff, 0xf0, + + /* U+5E "^" */ + 0xc, 0x7, 0x81, 0xe0, 0xfc, 0x33, 0x1c, 0xe6, + 0x19, 0x86, + + /* U+5F "_" */ + 0xff, 0xff, 0xf0, + + /* U+60 "`" */ + 0x63, 0x8e, + + /* U+61 "a" */ + 0x1f, 0x1f, 0xef, 0x1c, 0x7, 0x3f, 0xdf, 0xfe, + 0x1f, 0x87, 0xe3, 0xff, 0xf7, 0x9c, + + /* U+62 "b" */ + 0xe0, 0x38, 0xe, 0x3, 0xbc, 0xff, 0xbc, 0xfe, + 0x1f, 0x87, 0xe1, 0xf8, 0x7e, 0x1f, 0xcf, 0xff, + 0xbb, 0xc0, + + /* U+63 "c" */ + 0x3f, 0x1f, 0xef, 0x1f, 0x83, 0xe0, 0x38, 0xe, + 0x3, 0x87, 0xf1, 0xdf, 0xe3, 0xe0, + + /* U+64 "d" */ + 0x1, 0xc0, 0x70, 0x1c, 0xf7, 0x7f, 0xfc, 0xfe, + 0x1f, 0x87, 0xe1, 0xf8, 0x7e, 0x1f, 0xcf, 0x7f, + 0xcf, 0x70, + + /* U+65 "e" */ + 0x3f, 0x1f, 0xef, 0x3f, 0x87, 0xff, 0xff, 0xfe, + 0x3, 0x80, 0xf1, 0xdf, 0xe3, 0xf0, + + /* U+66 "f" */ + 0xf, 0xc7, 0xf1, 0xc0, 0x70, 0xff, 0xff, 0xf1, + 0xc0, 0x70, 0x1c, 0x7, 0x1, 0xc0, 0x70, 0x1c, + 0x7, 0x0, + + /* U+67 "g" */ + 0x3d, 0xdf, 0xff, 0x3f, 0x87, 0xe1, 0xf8, 0x7e, + 0x1f, 0xcf, 0x7f, 0xcf, 0x70, 0x1c, 0xf, 0x3f, + 0x8f, 0xc0, + + /* U+68 "h" */ + 0xe0, 0x70, 0x38, 0x1d, 0xcf, 0xf7, 0x9f, 0x8f, + 0xc7, 0xe3, 0xf1, 0xf8, 0xfc, 0x7e, 0x3f, 0x1c, + + /* U+69 "i" */ + 0x8, 0x7, 0x0, 0x80, 0x0, 0xfc, 0x3f, 0x1, + 0xc0, 0x70, 0x1c, 0x7, 0x1, 0xc0, 0x70, 0x1c, + 0x3f, 0xff, 0xfc, + + /* U+6A "j" */ + 0x2, 0x7, 0x2, 0x0, 0x7f, 0x7f, 0x7, 0x7, + 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0xf, + 0xfe, 0xfc, + + /* U+6B "k" */ + 0xe0, 0x38, 0xe, 0x3, 0x87, 0xe1, 0xb8, 0xee, + 0x33, 0x9c, 0xfe, 0x3f, 0x8e, 0x73, 0x8e, 0xe3, + 0xb8, 0x70, + + /* U+6C "l" */ + 0xfe, 0x1f, 0xc0, 0x38, 0x7, 0x0, 0xe0, 0x1c, + 0x3, 0x80, 0x70, 0xe, 0x1, 0xc0, 0x38, 0x7, + 0x0, 0xfe, 0xf, 0xc0, + + /* U+6D "m" */ + 0xd9, 0xbf, 0xfc, 0xcf, 0x33, 0xcc, 0xf3, 0x3c, + 0xcf, 0x33, 0xcc, 0xf3, 0x3c, 0xcc, + + /* U+6E "n" */ + 0xee, 0x7f, 0xbc, 0xfc, 0x7e, 0x3f, 0x1f, 0x8f, + 0xc7, 0xe3, 0xf1, 0xf8, 0xe0, + + /* U+6F "o" */ + 0x3f, 0x1f, 0xef, 0x3f, 0x87, 0xe1, 0xf8, 0x7e, + 0x1f, 0x87, 0xf3, 0xdf, 0xe1, 0xf0, + + /* U+70 "p" */ + 0xef, 0x3f, 0xef, 0x3f, 0x87, 0xe1, 0xf8, 0x7e, + 0x1f, 0x87, 0xf3, 0xff, 0xee, 0xf3, 0x80, 0xe0, + 0x38, 0x0, + + /* U+71 "q" */ + 0x3d, 0xdf, 0xff, 0x3f, 0x87, 0xe1, 0xf8, 0x7e, + 0x1f, 0x87, 0xf3, 0xdf, 0xf3, 0xdc, 0x7, 0x1, + 0xc0, 0x70, + + /* U+72 "r" */ + 0xef, 0x3f, 0xef, 0x3f, 0x87, 0xe1, 0xf8, 0xe, + 0x3, 0x80, 0xe0, 0x38, 0xe, 0x0, + + /* U+73 "s" */ + 0x3f, 0x3f, 0xee, 0x1f, 0x80, 0xfc, 0x1f, 0xe0, + 0x3c, 0x7, 0xe1, 0xff, 0xe3, 0xf0, + + /* U+74 "t" */ + 0x1c, 0x7, 0x1, 0xc3, 0xff, 0xff, 0xc7, 0x1, + 0xc0, 0x70, 0x1c, 0x7, 0x1, 0xc0, 0x70, 0xf, + 0xc1, 0xf0, + + /* U+75 "u" */ + 0xe3, 0xf1, 0xf8, 0xfc, 0x7e, 0x3f, 0x1f, 0x8f, + 0xc7, 0xe3, 0xbf, 0x8f, 0x80, + + /* U+76 "v" */ + 0xc0, 0xf8, 0x76, 0x19, 0x86, 0x73, 0x8c, 0xc3, + 0x30, 0xfc, 0x1e, 0x7, 0x81, 0xe0, + + /* U+77 "w" */ + 0xc6, 0x24, 0x62, 0x4e, 0x66, 0xf6, 0x6f, 0x66, + 0xf6, 0x6b, 0x66, 0x94, 0x79, 0x43, 0x9c, 0x39, + 0xc0, + + /* U+78 "x" */ + 0xe1, 0xdc, 0xe3, 0x30, 0xfc, 0x1e, 0x7, 0x81, + 0xe0, 0xfc, 0x73, 0x9c, 0x6e, 0x1c, + + /* U+79 "y" */ + 0xe1, 0xf8, 0x76, 0x19, 0xce, 0x33, 0x8e, 0xc3, + 0xf0, 0x7c, 0x1e, 0x3, 0x80, 0xc0, 0x70, 0x1c, + 0x6, 0x0, + + /* U+7A "z" */ + 0xff, 0xff, 0xc0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, + 0xe0, 0xe0, 0x7f, 0xff, 0xe0, + + /* U+7B "{" */ + 0x3, 0x87, 0xc3, 0x81, 0xc0, 0xe0, 0x70, 0x38, + 0x1c, 0xfc, 0x7e, 0x3, 0x81, 0xc0, 0xe0, 0x70, + 0x38, 0x1c, 0xf, 0x83, 0xc0, + + /* U+7C "|" */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, + + /* U+7D "}" */ + 0xf0, 0x3f, 0x1, 0xc0, 0x70, 0x1c, 0x7, 0x1, + 0xc0, 0x70, 0xf, 0xc3, 0xf1, 0xc0, 0x70, 0x1c, + 0x7, 0x1, 0xc0, 0x70, 0xf8, 0x3c, 0x0, + + /* U+7E "~" */ + 0x78, 0xff, 0x3c, 0xff, 0x1e +}; + + +/*--------------------- + * GLYPH DESCRIPTION + *--------------------*/ + +static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = { + {.bitmap_index = 0, .adv_w = 0, .box_w = 0, .box_h = 0, .ofs_x = 0, .ofs_y = 0} /* id = 0 reserved */, + {.bitmap_index = 0, .adv_w = 192, .box_w = 1, .box_h = 1, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1, .adv_w = 192, .box_w = 3, .box_h = 14, .ofs_x = 4, .ofs_y = 0}, + {.bitmap_index = 7, .adv_w = 192, .box_w = 7, .box_h = 6, .ofs_x = 3, .ofs_y = 8}, + {.bitmap_index = 13, .adv_w = 192, .box_w = 11, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 33, .adv_w = 192, .box_w = 10, .box_h = 18, .ofs_x = 1, .ofs_y = -2}, + {.bitmap_index = 56, .adv_w = 192, .box_w = 11, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 76, .adv_w = 192, .box_w = 11, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 96, .adv_w = 192, .box_w = 3, .box_h = 6, .ofs_x = 5, .ofs_y = 8}, + {.bitmap_index = 99, .adv_w = 192, .box_w = 7, .box_h = 19, .ofs_x = 3, .ofs_y = -2}, + {.bitmap_index = 116, .adv_w = 192, .box_w = 7, .box_h = 19, .ofs_x = 2, .ofs_y = -2}, + {.bitmap_index = 133, .adv_w = 192, .box_w = 10, .box_h = 10, .ofs_x = 1, .ofs_y = 1}, + {.bitmap_index = 146, .adv_w = 192, .box_w = 10, .box_h = 9, .ofs_x = 1, .ofs_y = 2}, + {.bitmap_index = 158, .adv_w = 192, .box_w = 5, .box_h = 6, .ofs_x = 3, .ofs_y = -3}, + {.bitmap_index = 162, .adv_w = 192, .box_w = 8, .box_h = 2, .ofs_x = 2, .ofs_y = 5}, + {.bitmap_index = 164, .adv_w = 192, .box_w = 4, .box_h = 4, .ofs_x = 4, .ofs_y = 0}, + {.bitmap_index = 166, .adv_w = 192, .box_w = 10, .box_h = 19, .ofs_x = 1, .ofs_y = -2}, + {.bitmap_index = 190, .adv_w = 192, .box_w = 10, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 208, .adv_w = 192, .box_w = 9, .box_h = 14, .ofs_x = 2, .ofs_y = 0}, + {.bitmap_index = 224, .adv_w = 192, .box_w = 10, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 242, .adv_w = 192, .box_w = 10, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 260, .adv_w = 192, .box_w = 9, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 276, .adv_w = 192, .box_w = 9, .box_h = 14, .ofs_x = 2, .ofs_y = 0}, + {.bitmap_index = 292, .adv_w = 192, .box_w = 10, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 310, .adv_w = 192, .box_w = 10, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 328, .adv_w = 192, .box_w = 10, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 346, .adv_w = 192, .box_w = 10, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 364, .adv_w = 192, .box_w = 3, .box_h = 11, .ofs_x = 4, .ofs_y = 0}, + {.bitmap_index = 369, .adv_w = 192, .box_w = 5, .box_h = 14, .ofs_x = 3, .ofs_y = -3}, + {.bitmap_index = 378, .adv_w = 192, .box_w = 9, .box_h = 11, .ofs_x = 2, .ofs_y = 1}, + {.bitmap_index = 391, .adv_w = 192, .box_w = 9, .box_h = 7, .ofs_x = 2, .ofs_y = 3}, + {.bitmap_index = 399, .adv_w = 192, .box_w = 9, .box_h = 11, .ofs_x = 2, .ofs_y = 1}, + {.bitmap_index = 412, .adv_w = 192, .box_w = 8, .box_h = 14, .ofs_x = 2, .ofs_y = 0}, + {.bitmap_index = 426, .adv_w = 192, .box_w = 11, .box_h = 17, .ofs_x = 1, .ofs_y = -3}, + {.bitmap_index = 450, .adv_w = 192, .box_w = 12, .box_h = 14, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 471, .adv_w = 192, .box_w = 10, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 489, .adv_w = 192, .box_w = 10, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 507, .adv_w = 192, .box_w = 10, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 525, .adv_w = 192, .box_w = 9, .box_h = 14, .ofs_x = 2, .ofs_y = 0}, + {.bitmap_index = 541, .adv_w = 192, .box_w = 9, .box_h = 14, .ofs_x = 2, .ofs_y = 0}, + {.bitmap_index = 557, .adv_w = 192, .box_w = 10, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 575, .adv_w = 192, .box_w = 9, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 591, .adv_w = 192, .box_w = 9, .box_h = 14, .ofs_x = 2, .ofs_y = 0}, + {.bitmap_index = 607, .adv_w = 192, .box_w = 10, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 625, .adv_w = 192, .box_w = 11, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 645, .adv_w = 192, .box_w = 9, .box_h = 14, .ofs_x = 2, .ofs_y = 0}, + {.bitmap_index = 661, .adv_w = 192, .box_w = 10, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 679, .adv_w = 192, .box_w = 9, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 695, .adv_w = 192, .box_w = 10, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 713, .adv_w = 192, .box_w = 10, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 731, .adv_w = 192, .box_w = 10, .box_h = 17, .ofs_x = 1, .ofs_y = -3}, + {.bitmap_index = 753, .adv_w = 192, .box_w = 10, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 771, .adv_w = 192, .box_w = 10, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 789, .adv_w = 192, .box_w = 10, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 807, .adv_w = 192, .box_w = 9, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 823, .adv_w = 192, .box_w = 12, .box_h = 14, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 844, .adv_w = 192, .box_w = 12, .box_h = 14, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 865, .adv_w = 192, .box_w = 10, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 883, .adv_w = 192, .box_w = 11, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 903, .adv_w = 192, .box_w = 9, .box_h = 14, .ofs_x = 2, .ofs_y = 0}, + {.bitmap_index = 919, .adv_w = 192, .box_w = 6, .box_h = 18, .ofs_x = 4, .ofs_y = -2}, + {.bitmap_index = 933, .adv_w = 192, .box_w = 10, .box_h = 19, .ofs_x = 1, .ofs_y = -2}, + {.bitmap_index = 957, .adv_w = 192, .box_w = 6, .box_h = 18, .ofs_x = 3, .ofs_y = -2}, + {.bitmap_index = 971, .adv_w = 192, .box_w = 10, .box_h = 8, .ofs_x = 1, .ofs_y = 6}, + {.bitmap_index = 981, .adv_w = 192, .box_w = 10, .box_h = 2, .ofs_x = 1, .ofs_y = -3}, + {.bitmap_index = 984, .adv_w = 192, .box_w = 5, .box_h = 3, .ofs_x = 3, .ofs_y = 13}, + {.bitmap_index = 986, .adv_w = 192, .box_w = 10, .box_h = 11, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 1000, .adv_w = 192, .box_w = 10, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 1018, .adv_w = 192, .box_w = 10, .box_h = 11, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 1032, .adv_w = 192, .box_w = 10, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 1050, .adv_w = 192, .box_w = 10, .box_h = 11, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 1064, .adv_w = 192, .box_w = 10, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 1082, .adv_w = 192, .box_w = 10, .box_h = 14, .ofs_x = 1, .ofs_y = -3}, + {.bitmap_index = 1100, .adv_w = 192, .box_w = 9, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 1116, .adv_w = 192, .box_w = 10, .box_h = 15, .ofs_x = 2, .ofs_y = 0}, + {.bitmap_index = 1135, .adv_w = 192, .box_w = 8, .box_h = 18, .ofs_x = 1, .ofs_y = -3}, + {.bitmap_index = 1153, .adv_w = 192, .box_w = 10, .box_h = 14, .ofs_x = 2, .ofs_y = 0}, + {.bitmap_index = 1171, .adv_w = 192, .box_w = 11, .box_h = 14, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1191, .adv_w = 192, .box_w = 10, .box_h = 11, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 1205, .adv_w = 192, .box_w = 9, .box_h = 11, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 1218, .adv_w = 192, .box_w = 10, .box_h = 11, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 1232, .adv_w = 192, .box_w = 10, .box_h = 14, .ofs_x = 1, .ofs_y = -3}, + {.bitmap_index = 1250, .adv_w = 192, .box_w = 10, .box_h = 14, .ofs_x = 1, .ofs_y = -3}, + {.bitmap_index = 1268, .adv_w = 192, .box_w = 10, .box_h = 11, .ofs_x = 2, .ofs_y = 0}, + {.bitmap_index = 1282, .adv_w = 192, .box_w = 10, .box_h = 11, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 1296, .adv_w = 192, .box_w = 10, .box_h = 14, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 1314, .adv_w = 192, .box_w = 9, .box_h = 11, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 1327, .adv_w = 192, .box_w = 10, .box_h = 11, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 1341, .adv_w = 192, .box_w = 12, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1358, .adv_w = 192, .box_w = 10, .box_h = 11, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 1372, .adv_w = 192, .box_w = 10, .box_h = 14, .ofs_x = 1, .ofs_y = -3}, + {.bitmap_index = 1390, .adv_w = 192, .box_w = 9, .box_h = 11, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 1403, .adv_w = 192, .box_w = 9, .box_h = 18, .ofs_x = 2, .ofs_y = -2}, + {.bitmap_index = 1424, .adv_w = 192, .box_w = 3, .box_h = 18, .ofs_x = 5, .ofs_y = -2}, + {.bitmap_index = 1431, .adv_w = 192, .box_w = 10, .box_h = 18, .ofs_x = 1, .ofs_y = -2}, + {.bitmap_index = 1454, .adv_w = 192, .box_w = 10, .box_h = 4, .ofs_x = 1, .ofs_y = 5} +}; + +/*--------------------- + * CHARACTER MAPPING + *--------------------*/ + + + +/*Collect the unicode lists and glyph_id offsets*/ +static const lv_font_fmt_txt_cmap_t cmaps[] = +{ + { + .range_start = 32, .range_length = 95, .glyph_id_start = 1, + .unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY + } +}; + + + +/*-------------------- + * ALL CUSTOM DATA + *--------------------*/ + +/*Store all the custom data of the font*/ +static lv_font_fmt_txt_dsc_t font_dsc = { + .glyph_bitmap = gylph_bitmap, + .glyph_dsc = glyph_dsc, + .cmaps = cmaps, + .kern_dsc = NULL, + .kern_scale = 0, + .cmap_num = 1, + .bpp = 1, + .kern_classes = 0, + .bitmap_format = 0 +}; + + +/*----------------- + * PUBLIC FONT + *----------------*/ + +/*Initialize a public general font descriptor*/ +lv_font_t jetbrains_mono_bold_20 = { + .get_glyph_dsc = lv_font_get_glyph_dsc_fmt_txt, /*Function pointer to get glyph's data*/ + .get_glyph_bitmap = lv_font_get_bitmap_fmt_txt, /*Function pointer to get glyph's bitmap*/ + .line_height = 20, /*The maximum line height required by the font*/ + .base_line = 3, /*Baseline measured from the bottom of the line*/ +#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) + .subpx = LV_FONT_SUBPX_NONE, +#endif + .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ +}; + +#endif /*#if JETBRAINS_MONO_BOLD_20*/ + diff --git a/src/DisplayApp/Fonts/jetbrains_mono_extrabold_compressed.c b/src/DisplayApp/Fonts/jetbrains_mono_extrabold_compressed.c new file mode 100644 index 00000000..c850cd91 --- /dev/null +++ b/src/DisplayApp/Fonts/jetbrains_mono_extrabold_compressed.c @@ -0,0 +1,507 @@ +#include "lvgl/lvgl.h" + +/******************************************************************************* + * Size: 80 px + * Bpp: 1 + * Opts: + ******************************************************************************/ + +#ifndef JETBRAINS_MONO_EXTRABOLD_COMPRESSEDEXTRABOLD_COMPRESSED +#define JETBRAINS_MONO_EXTRABOLD_COMPRESSEDEXTRABOLD_COMPRESSED 1 +#endif + +#if JETBRAINS_MONO_EXTRABOLD_COMPRESSEDEXTRABOLD_COMPRESSED + +/*----------------- + * BITMAPS + *----------------*/ + +/*Store the image of the glyphs*/ +static LV_ATTRIBUTE_LARGE_CONST const uint8_t gylph_bitmap[] = { + /* U+30 "0" */ + 0x0, 0x1, 0xff, 0xc0, 0x0, 0x0, 0xf, 0xff, + 0xfe, 0x0, 0x0, 0x1f, 0xff, 0xff, 0xc0, 0x0, + 0x3f, 0xff, 0xff, 0xf8, 0x0, 0x3f, 0xff, 0xff, + 0xfe, 0x0, 0x3f, 0xff, 0xff, 0xff, 0x80, 0x3f, + 0xff, 0xff, 0xff, 0xe0, 0x3f, 0xff, 0xff, 0xff, + 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xfc, 0x1f, 0xff, + 0xff, 0xff, 0xff, 0x1f, 0xff, 0xe0, 0x3f, 0xff, + 0xcf, 0xff, 0xc0, 0x7, 0xff, 0xe7, 0xff, 0xc0, + 0x1, 0xff, 0xf7, 0xff, 0xc0, 0x0, 0x7f, 0xff, + 0xff, 0xe0, 0x0, 0x3f, 0xff, 0xff, 0xe0, 0x0, + 0xf, 0xff, 0xff, 0xf0, 0x0, 0x7, 0xff, 0xff, + 0xf8, 0x0, 0x3, 0xff, 0xff, 0xfc, 0x0, 0x1, + 0xff, 0xff, 0xfe, 0x0, 0x0, 0xff, 0xff, 0xff, + 0x0, 0x0, 0x7f, 0xff, 0xff, 0x80, 0x0, 0x3f, + 0xff, 0xff, 0xc0, 0x70, 0x1f, 0xff, 0xff, 0xe0, + 0x7c, 0xf, 0xff, 0xff, 0xf0, 0x7f, 0x7, 0xff, + 0xff, 0xf8, 0x3f, 0x83, 0xff, 0xff, 0xfc, 0x1f, + 0xc1, 0xff, 0xff, 0xfe, 0xf, 0xe0, 0xff, 0xff, + 0xff, 0x7, 0xf0, 0x7f, 0xff, 0xff, 0x83, 0xf8, + 0x3f, 0xff, 0xff, 0xc1, 0xfc, 0x1f, 0xff, 0xff, + 0xe0, 0xfe, 0xf, 0xff, 0xff, 0xf0, 0x7f, 0x7, + 0xff, 0xff, 0xf8, 0x3f, 0x83, 0xff, 0xff, 0xfc, + 0x1f, 0xc1, 0xff, 0xff, 0xfe, 0xf, 0xe0, 0xff, + 0xff, 0xff, 0x3, 0xe0, 0x7f, 0xff, 0xff, 0x80, + 0xe0, 0x3f, 0xff, 0xff, 0xc0, 0x0, 0x1f, 0xff, + 0xff, 0xe0, 0x0, 0xf, 0xff, 0xff, 0xf0, 0x0, + 0x7, 0xff, 0xff, 0xf8, 0x0, 0x3, 0xff, 0xff, + 0xfc, 0x0, 0x1, 0xff, 0xff, 0xfe, 0x0, 0x0, + 0xff, 0xff, 0xff, 0x80, 0x0, 0xff, 0xff, 0xff, + 0xc0, 0x0, 0x7f, 0xf9, 0xff, 0xf0, 0x0, 0x7f, + 0xfc, 0xff, 0xfc, 0x0, 0x7f, 0xfe, 0x7f, 0xff, + 0x80, 0xff, 0xfe, 0x1f, 0xff, 0xff, 0xff, 0xff, + 0x7, 0xff, 0xff, 0xff, 0xff, 0x3, 0xff, 0xff, + 0xff, 0xff, 0x80, 0xff, 0xff, 0xff, 0xff, 0x80, + 0x3f, 0xff, 0xff, 0xff, 0x80, 0xf, 0xff, 0xff, + 0xff, 0x80, 0x3, 0xff, 0xff, 0xff, 0x0, 0x0, + 0x7f, 0xff, 0xff, 0x0, 0x0, 0xf, 0xff, 0xfc, + 0x0, 0x0, 0x0, 0x7f, 0xf0, 0x0, 0x0, + + /* U+31 "1" */ + 0x0, 0x7, 0xff, 0xe0, 0x0, 0x0, 0xf, 0xff, + 0xe0, 0x0, 0x0, 0x3f, 0xff, 0xe0, 0x0, 0x0, + 0x7f, 0xff, 0xe0, 0x0, 0x1, 0xff, 0xff, 0xe0, + 0x0, 0x3, 0xff, 0xff, 0xe0, 0x0, 0x7, 0xff, + 0xff, 0xe0, 0x0, 0x1f, 0xff, 0xff, 0xe0, 0x0, + 0x3f, 0xff, 0xff, 0xe0, 0x0, 0x7f, 0xff, 0xff, + 0xe0, 0x0, 0x7f, 0xff, 0xff, 0xe0, 0x0, 0x7f, + 0xfd, 0xff, 0xe0, 0x0, 0x7f, 0xf9, 0xff, 0xe0, + 0x0, 0x7f, 0xf1, 0xff, 0xe0, 0x0, 0x7f, 0xe1, + 0xff, 0xe0, 0x0, 0x7f, 0x81, 0xff, 0xe0, 0x0, + 0x7f, 0x1, 0xff, 0xe0, 0x0, 0x7c, 0x1, 0xff, + 0xe0, 0x0, 0x78, 0x1, 0xff, 0xe0, 0x0, 0x60, + 0x1, 0xff, 0xe0, 0x0, 0x40, 0x1, 0xff, 0xe0, + 0x0, 0x0, 0x1, 0xff, 0xe0, 0x0, 0x0, 0x1, + 0xff, 0xe0, 0x0, 0x0, 0x1, 0xff, 0xe0, 0x0, + 0x0, 0x1, 0xff, 0xe0, 0x0, 0x0, 0x1, 0xff, + 0xe0, 0x0, 0x0, 0x1, 0xff, 0xe0, 0x0, 0x0, + 0x1, 0xff, 0xe0, 0x0, 0x0, 0x1, 0xff, 0xe0, + 0x0, 0x0, 0x1, 0xff, 0xe0, 0x0, 0x0, 0x1, + 0xff, 0xe0, 0x0, 0x0, 0x1, 0xff, 0xe0, 0x0, + 0x0, 0x1, 0xff, 0xe0, 0x0, 0x0, 0x1, 0xff, + 0xe0, 0x0, 0x0, 0x1, 0xff, 0xe0, 0x0, 0x0, + 0x1, 0xff, 0xe0, 0x0, 0x0, 0x1, 0xff, 0xe0, + 0x0, 0x0, 0x1, 0xff, 0xe0, 0x0, 0x0, 0x1, + 0xff, 0xe0, 0x0, 0x0, 0x1, 0xff, 0xe0, 0x0, + 0x0, 0x1, 0xff, 0xe0, 0x0, 0x0, 0x1, 0xff, + 0xe0, 0x0, 0x0, 0x1, 0xff, 0xe0, 0x0, 0x0, + 0x1, 0xff, 0xe0, 0x0, 0x0, 0x1, 0xff, 0xe0, + 0x0, 0x0, 0x1, 0xff, 0xe0, 0x0, 0x0, 0x1, + 0xff, 0xe0, 0x0, 0x0, 0x1, 0xff, 0xe0, 0x0, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, + + /* U+32 "2" */ + 0x0, 0x1, 0xff, 0xc0, 0x0, 0x0, 0xf, 0xff, + 0xfc, 0x0, 0x0, 0x1f, 0xff, 0xff, 0x80, 0x0, + 0x3f, 0xff, 0xff, 0xf0, 0x0, 0x3f, 0xff, 0xff, + 0xfc, 0x0, 0x3f, 0xff, 0xff, 0xff, 0x0, 0x3f, + 0xff, 0xff, 0xff, 0xc0, 0x3f, 0xff, 0xff, 0xff, + 0xf0, 0x3f, 0xff, 0xff, 0xff, 0xfc, 0x1f, 0xff, + 0xff, 0xff, 0xfe, 0x1f, 0xff, 0xe0, 0x7f, 0xff, + 0x8f, 0xff, 0xc0, 0xf, 0xff, 0xc7, 0xff, 0xc0, + 0x3, 0xff, 0xe7, 0xff, 0xc0, 0x0, 0xff, 0xfb, + 0xff, 0xc0, 0x0, 0x7f, 0xfd, 0xff, 0xe0, 0x0, + 0x1f, 0xfe, 0xff, 0xf0, 0x0, 0xf, 0xff, 0x0, + 0x0, 0x0, 0x7, 0xff, 0x80, 0x0, 0x0, 0x3, + 0xff, 0xc0, 0x0, 0x0, 0x1, 0xff, 0xe0, 0x0, + 0x0, 0x0, 0xff, 0xf0, 0x0, 0x0, 0x0, 0xff, + 0xf8, 0x0, 0x0, 0x0, 0x7f, 0xf8, 0x0, 0x0, + 0x0, 0x7f, 0xfc, 0x0, 0x0, 0x0, 0x3f, 0xfe, + 0x0, 0x0, 0x0, 0x3f, 0xfe, 0x0, 0x0, 0x0, + 0x3f, 0xff, 0x0, 0x0, 0x0, 0x3f, 0xff, 0x0, + 0x0, 0x0, 0x3f, 0xff, 0x0, 0x0, 0x0, 0x3f, + 0xff, 0x80, 0x0, 0x0, 0x7f, 0xff, 0x80, 0x0, + 0x0, 0x7f, 0xff, 0x80, 0x0, 0x0, 0x7f, 0xff, + 0x80, 0x0, 0x0, 0x7f, 0xff, 0x80, 0x0, 0x0, + 0xff, 0xff, 0x80, 0x0, 0x0, 0xff, 0xff, 0x80, + 0x0, 0x0, 0xff, 0xff, 0x80, 0x0, 0x0, 0xff, + 0xff, 0x80, 0x0, 0x1, 0xff, 0xff, 0x0, 0x0, + 0x1, 0xff, 0xff, 0x0, 0x0, 0x1, 0xff, 0xff, + 0x0, 0x0, 0x1, 0xff, 0xfe, 0x0, 0x0, 0x3, + 0xff, 0xfe, 0x0, 0x0, 0x3, 0xff, 0xfe, 0x0, + 0x0, 0x3, 0xff, 0xfc, 0x0, 0x0, 0x3, 0xff, + 0xfc, 0x0, 0x0, 0x1, 0xff, 0xf0, 0x0, 0x0, + 0x0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, + 0xff, 0xff, 0xff, 0xbf, 0xff, 0xff, 0xff, 0xff, + 0xdf, 0xff, 0xff, 0xff, 0xff, 0xef, 0xff, 0xff, + 0xff, 0xff, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xfb, + 0xff, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, + 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, + 0xff, 0xff, 0xff, 0xff, 0xbf, 0xff, 0xff, 0xff, + 0xff, 0xc0, + + /* U+33 "3" */ + 0x1f, 0xff, 0xff, 0xff, 0xfe, 0xf, 0xff, 0xff, + 0xff, 0xff, 0x7, 0xff, 0xff, 0xff, 0xff, 0x83, + 0xff, 0xff, 0xff, 0xff, 0xc1, 0xff, 0xff, 0xff, + 0xff, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x7f, + 0xff, 0xff, 0xff, 0xf8, 0x3f, 0xff, 0xff, 0xff, + 0xfc, 0x1f, 0xff, 0xff, 0xff, 0xfe, 0xf, 0xff, + 0xff, 0x8f, 0xff, 0x0, 0x0, 0x0, 0xf, 0xff, + 0x80, 0x0, 0x0, 0x1f, 0xff, 0x80, 0x0, 0x0, + 0x1f, 0xff, 0x80, 0x0, 0x0, 0x3f, 0xff, 0x80, + 0x0, 0x0, 0x3f, 0xff, 0x0, 0x0, 0x0, 0x3f, + 0xff, 0x0, 0x0, 0x0, 0x3f, 0xff, 0x0, 0x0, + 0x0, 0x3f, 0xff, 0x0, 0x0, 0x0, 0x3f, 0xfe, + 0x0, 0x0, 0x0, 0x3f, 0xfe, 0x0, 0x0, 0x0, + 0x3f, 0xfe, 0x0, 0x0, 0x0, 0x3f, 0xfc, 0x0, + 0x0, 0x0, 0x1f, 0xff, 0x80, 0x0, 0x0, 0xf, + 0xff, 0xf8, 0x0, 0x0, 0x7, 0xff, 0xff, 0x0, + 0x0, 0x3, 0xff, 0xff, 0xe0, 0x0, 0x1, 0xff, + 0xff, 0xf8, 0x0, 0x0, 0xff, 0xff, 0xfe, 0x0, + 0x0, 0x7f, 0xff, 0xff, 0x80, 0x0, 0x3f, 0xff, + 0xff, 0xe0, 0x0, 0x1f, 0xff, 0xff, 0xf0, 0x0, + 0xf, 0xff, 0xff, 0xfc, 0x0, 0x0, 0x0, 0xff, + 0xfe, 0x0, 0x0, 0x0, 0x1f, 0xff, 0x80, 0x0, + 0x0, 0x7, 0xff, 0xc0, 0x0, 0x0, 0x1, 0xff, + 0xe0, 0x0, 0x0, 0x0, 0xff, 0xf8, 0x0, 0x0, + 0x0, 0x3f, 0xfc, 0x0, 0x0, 0x0, 0x1f, 0xfe, + 0x0, 0x0, 0x0, 0xf, 0xff, 0x0, 0x0, 0x0, + 0x7, 0xff, 0x80, 0x0, 0x0, 0x3, 0xff, 0xc0, + 0x0, 0x0, 0x1, 0xff, 0xff, 0xfe, 0x0, 0x0, + 0xff, 0xff, 0xff, 0x80, 0x0, 0xff, 0xff, 0xff, + 0xc0, 0x0, 0x7f, 0xf9, 0xff, 0xf0, 0x0, 0x7f, + 0xfc, 0xff, 0xfc, 0x0, 0x7f, 0xfe, 0x7f, 0xff, + 0x80, 0xff, 0xfe, 0x1f, 0xff, 0xff, 0xff, 0xff, + 0xf, 0xff, 0xff, 0xff, 0xff, 0x3, 0xff, 0xff, + 0xff, 0xff, 0x80, 0xff, 0xff, 0xff, 0xff, 0x80, + 0x3f, 0xff, 0xff, 0xff, 0x80, 0xf, 0xff, 0xff, + 0xff, 0x80, 0x3, 0xff, 0xff, 0xff, 0x0, 0x0, + 0x7f, 0xff, 0xff, 0x0, 0x0, 0xf, 0xff, 0xfc, + 0x0, 0x0, 0x0, 0x7f, 0xf0, 0x0, 0x0, + + /* U+34 "4" */ + 0x0, 0x0, 0x3, 0xff, 0xf0, 0x0, 0x0, 0x1f, + 0xff, 0x80, 0x0, 0x0, 0x7f, 0xfc, 0x0, 0x0, + 0x3, 0xff, 0xe0, 0x0, 0x0, 0x1f, 0xff, 0x80, + 0x0, 0x0, 0xff, 0xfc, 0x0, 0x0, 0x3, 0xff, + 0xe0, 0x0, 0x0, 0x1f, 0xff, 0x0, 0x0, 0x0, + 0xff, 0xfc, 0x0, 0x0, 0x7, 0xff, 0xe0, 0x0, + 0x0, 0x1f, 0xff, 0x0, 0x0, 0x0, 0xff, 0xfc, + 0x0, 0x0, 0x7, 0xff, 0xe0, 0x0, 0x0, 0x3f, + 0xff, 0x0, 0x0, 0x0, 0xff, 0xf8, 0x0, 0x0, + 0x7, 0xff, 0xe0, 0x0, 0x0, 0x3f, 0xff, 0x0, + 0x0, 0x0, 0xff, 0xf8, 0x0, 0x0, 0x7, 0xff, + 0xc0, 0x0, 0x0, 0x3f, 0xff, 0x0, 0x0, 0x1, + 0xff, 0xf8, 0x0, 0x0, 0x7, 0xff, 0xc0, 0x0, + 0x0, 0x3f, 0xfe, 0x0, 0x0, 0x1, 0xff, 0xf8, + 0x0, 0x0, 0xf, 0xff, 0xc0, 0x0, 0x0, 0x3f, + 0xfe, 0x0, 0xff, 0xf1, 0xff, 0xf0, 0x3, 0xff, + 0xcf, 0xff, 0xc0, 0xf, 0xff, 0x7f, 0xfe, 0x0, + 0x3f, 0xfd, 0xff, 0xf0, 0x0, 0xff, 0xff, 0xff, + 0xc0, 0x3, 0xff, 0xff, 0xfe, 0x0, 0xf, 0xff, + 0xff, 0xf0, 0x0, 0x3f, 0xff, 0xff, 0x80, 0x0, + 0xff, 0xff, 0xfe, 0x0, 0x3, 0xff, 0xff, 0xf8, + 0x0, 0xf, 0xff, 0xff, 0xe0, 0x0, 0x3f, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, + 0x0, 0x0, 0xf, 0xff, 0x0, 0x0, 0x0, 0x3f, + 0xfc, 0x0, 0x0, 0x0, 0xff, 0xf0, 0x0, 0x0, + 0x3, 0xff, 0xc0, 0x0, 0x0, 0xf, 0xff, 0x0, + 0x0, 0x0, 0x3f, 0xfc, 0x0, 0x0, 0x0, 0xff, + 0xf0, 0x0, 0x0, 0x3, 0xff, 0xc0, 0x0, 0x0, + 0xf, 0xff, 0x0, 0x0, 0x0, 0x3f, 0xfc, 0x0, + 0x0, 0x0, 0xff, 0xf0, + + /* U+35 "5" */ + 0x3f, 0xff, 0xff, 0xff, 0xfe, 0x1f, 0xff, 0xff, + 0xff, 0xff, 0xf, 0xff, 0xff, 0xff, 0xff, 0x87, + 0xff, 0xff, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xff, + 0xff, 0xe1, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, + 0xff, 0xff, 0xff, 0xf8, 0x7f, 0xff, 0xff, 0xff, + 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xfe, 0x1f, 0xff, + 0xff, 0xff, 0xff, 0xf, 0xff, 0x0, 0x0, 0x0, + 0x7, 0xff, 0x80, 0x0, 0x0, 0x3, 0xff, 0xc0, + 0x0, 0x0, 0x1, 0xff, 0xe0, 0x0, 0x0, 0x0, + 0xff, 0xf0, 0x0, 0x0, 0x0, 0x7f, 0xf8, 0x0, + 0x0, 0x0, 0x3f, 0xfc, 0x0, 0x0, 0x0, 0x1f, + 0xfe, 0x0, 0x0, 0x0, 0xf, 0xff, 0x0, 0x0, + 0x0, 0x7, 0xff, 0x80, 0x0, 0x0, 0x3, 0xff, + 0xc0, 0x7f, 0x80, 0x1, 0xff, 0xe1, 0xff, 0xf8, + 0x0, 0xff, 0xf1, 0xff, 0xff, 0x0, 0x7f, 0xf9, + 0xff, 0xff, 0xc0, 0x3f, 0xfd, 0xff, 0xff, 0xf0, + 0x1f, 0xff, 0xff, 0xff, 0xfc, 0xf, 0xff, 0xff, + 0xff, 0xff, 0x7, 0xff, 0xff, 0xff, 0xff, 0xc3, + 0xff, 0xff, 0xff, 0xff, 0xe1, 0xff, 0xfc, 0x7, + 0xff, 0xf8, 0xff, 0xf8, 0x0, 0xff, 0xfc, 0x0, + 0x0, 0x0, 0x3f, 0xfe, 0x0, 0x0, 0x0, 0xf, + 0xff, 0x80, 0x0, 0x0, 0x7, 0xff, 0xc0, 0x0, + 0x0, 0x1, 0xff, 0xe0, 0x0, 0x0, 0x0, 0xff, + 0xf0, 0x0, 0x0, 0x0, 0x7f, 0xf8, 0x0, 0x0, + 0x0, 0x3f, 0xfc, 0x0, 0x0, 0x0, 0x1f, 0xfe, + 0x0, 0x0, 0x0, 0xf, 0xff, 0x0, 0x0, 0x0, + 0x7, 0xff, 0x80, 0x0, 0x0, 0x3, 0xff, 0xc0, + 0x0, 0x0, 0x1, 0xff, 0xff, 0xff, 0x0, 0x1, + 0xff, 0xff, 0xff, 0x80, 0x0, 0xff, 0xfb, 0xff, + 0xe0, 0x0, 0xff, 0xf9, 0xff, 0xf8, 0x0, 0xff, + 0xfc, 0xff, 0xff, 0x81, 0xff, 0xfe, 0x3f, 0xff, + 0xff, 0xff, 0xfe, 0x1f, 0xff, 0xff, 0xff, 0xff, + 0x7, 0xff, 0xff, 0xff, 0xff, 0x1, 0xff, 0xff, + 0xff, 0xff, 0x0, 0x7f, 0xff, 0xff, 0xff, 0x0, + 0x1f, 0xff, 0xff, 0xff, 0x0, 0x7, 0xff, 0xff, + 0xff, 0x0, 0x0, 0xff, 0xff, 0xfe, 0x0, 0x0, + 0x1f, 0xff, 0xfc, 0x0, 0x0, 0x0, 0xff, 0xe0, + 0x0, 0x0, + + /* U+36 "6" */ + 0x0, 0x0, 0xf, 0xff, 0x80, 0x0, 0x0, 0x7, + 0xff, 0xe0, 0x0, 0x0, 0x3, 0xff, 0xf0, 0x0, + 0x0, 0x0, 0xff, 0xf8, 0x0, 0x0, 0x0, 0x7f, + 0xfe, 0x0, 0x0, 0x0, 0x3f, 0xff, 0x0, 0x0, + 0x0, 0xf, 0xff, 0x80, 0x0, 0x0, 0x7, 0xff, + 0xc0, 0x0, 0x0, 0x3, 0xff, 0xf0, 0x0, 0x0, + 0x0, 0xff, 0xf8, 0x0, 0x0, 0x0, 0x7f, 0xfc, + 0x0, 0x0, 0x0, 0x3f, 0xff, 0x0, 0x0, 0x0, + 0xf, 0xff, 0x80, 0x0, 0x0, 0x7, 0xff, 0xc0, + 0x0, 0x0, 0x3, 0xff, 0xf0, 0x0, 0x0, 0x1, + 0xff, 0xf8, 0x0, 0x0, 0x0, 0x7f, 0xfc, 0x0, + 0x0, 0x0, 0x3f, 0xfe, 0x0, 0x0, 0x0, 0xf, + 0xff, 0x80, 0x0, 0x0, 0x7, 0xff, 0xc0, 0x0, + 0x0, 0x3, 0xff, 0xe0, 0x0, 0x0, 0x0, 0xff, + 0xf8, 0x0, 0x0, 0x0, 0x7f, 0xfc, 0x3f, 0xc0, + 0x0, 0x1f, 0xfe, 0x3f, 0xfe, 0x0, 0xf, 0xff, + 0xbf, 0xff, 0xe0, 0x3, 0xff, 0xdf, 0xff, 0xfc, + 0x1, 0xff, 0xef, 0xff, 0xff, 0x80, 0x7f, 0xff, + 0xff, 0xff, 0xf0, 0x3f, 0xff, 0xff, 0xff, 0xfe, + 0xf, 0xff, 0xff, 0xff, 0xff, 0x87, 0xff, 0xff, + 0xff, 0xff, 0xf1, 0xff, 0xff, 0x3, 0xff, 0xfc, + 0x7f, 0xff, 0x0, 0x3f, 0xff, 0x9f, 0xff, 0x0, + 0x3, 0xff, 0xef, 0xff, 0xc0, 0x0, 0xff, 0xfb, + 0xff, 0xe0, 0x0, 0x1f, 0xff, 0xff, 0xf8, 0x0, + 0x7, 0xff, 0xff, 0xfc, 0x0, 0x0, 0xff, 0xff, + 0xff, 0x0, 0x0, 0x3f, 0xff, 0xff, 0xc0, 0x0, + 0xf, 0xff, 0xff, 0xf0, 0x0, 0x3, 0xff, 0xff, + 0xfc, 0x0, 0x0, 0xff, 0xff, 0xff, 0x0, 0x0, + 0x3f, 0xff, 0xff, 0xe0, 0x0, 0x1f, 0xff, 0x7f, + 0xf8, 0x0, 0x7, 0xff, 0xdf, 0xfe, 0x0, 0x3, + 0xff, 0xe7, 0xff, 0xc0, 0x0, 0xff, 0xf9, 0xff, + 0xfc, 0x0, 0xff, 0xfe, 0x3f, 0xff, 0xc0, 0xff, + 0xff, 0xf, 0xff, 0xff, 0xff, 0xff, 0xc1, 0xff, + 0xff, 0xff, 0xff, 0xe0, 0x3f, 0xff, 0xff, 0xff, + 0xf0, 0x7, 0xff, 0xff, 0xff, 0xf8, 0x0, 0xff, + 0xff, 0xff, 0xfe, 0x0, 0x1f, 0xff, 0xff, 0xfe, + 0x0, 0x3, 0xff, 0xff, 0xff, 0x0, 0x0, 0x3f, + 0xff, 0xff, 0x0, 0x0, 0x3, 0xff, 0xff, 0x0, + 0x0, 0x0, 0xf, 0xfc, 0x0, 0x0, + + /* U+37 "7" */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xe0, 0x0, 0xf, 0xff, 0xff, 0xe0, 0x0, 0x1f, + 0xfe, 0xff, 0xe0, 0x0, 0x1f, 0xfe, 0xff, 0xe0, + 0x0, 0x3f, 0xfc, 0xff, 0xe0, 0x0, 0x3f, 0xfc, + 0xff, 0xe0, 0x0, 0x7f, 0xf8, 0xff, 0xe0, 0x0, + 0x7f, 0xf8, 0xff, 0xe0, 0x0, 0xff, 0xf8, 0xff, + 0xe0, 0x0, 0xff, 0xf0, 0x0, 0x0, 0x1, 0xff, + 0xf0, 0x0, 0x0, 0x1, 0xff, 0xe0, 0x0, 0x0, + 0x3, 0xff, 0xe0, 0x0, 0x0, 0x3, 0xff, 0xc0, + 0x0, 0x0, 0x7, 0xff, 0xc0, 0x0, 0x0, 0x7, + 0xff, 0x80, 0x0, 0x0, 0x7, 0xff, 0x80, 0x0, + 0x0, 0xf, 0xff, 0x80, 0x0, 0x0, 0xf, 0xff, + 0x0, 0x0, 0x0, 0x1f, 0xff, 0x0, 0x0, 0x0, + 0x1f, 0xfe, 0x0, 0x0, 0x0, 0x3f, 0xfe, 0x0, + 0x0, 0x0, 0x3f, 0xfc, 0x0, 0x0, 0x0, 0x7f, + 0xfc, 0x0, 0x0, 0x0, 0x7f, 0xf8, 0x0, 0x0, + 0x0, 0xff, 0xf8, 0x0, 0x0, 0x0, 0xff, 0xf8, + 0x0, 0x0, 0x1, 0xff, 0xf0, 0x0, 0x0, 0x1, + 0xff, 0xf0, 0x0, 0x0, 0x1, 0xff, 0xe0, 0x0, + 0x0, 0x3, 0xff, 0xe0, 0x0, 0x0, 0x3, 0xff, + 0xc0, 0x0, 0x0, 0x7, 0xff, 0xc0, 0x0, 0x0, + 0x7, 0xff, 0x80, 0x0, 0x0, 0xf, 0xff, 0x80, + 0x0, 0x0, 0xf, 0xff, 0x80, 0x0, 0x0, 0x1f, + 0xff, 0x0, 0x0, 0x0, 0x1f, 0xff, 0x0, 0x0, + 0x0, 0x3f, 0xfe, 0x0, 0x0, 0x0, 0x3f, 0xfe, + 0x0, 0x0, 0x0, 0x7f, 0xfc, 0x0, 0x0, 0x0, + 0x7f, 0xfc, 0x0, 0x0, 0x0, 0x7f, 0xf8, 0x0, + 0x0, 0x0, 0xff, 0xf8, 0x0, 0x0, 0x0, 0xff, + 0xf8, 0x0, 0x0, 0x1, 0xff, 0xf0, 0x0, 0x0, + 0x1, 0xff, 0xf0, 0x0, 0x0, 0x3, 0xff, 0xe0, + 0x0, 0x0, + + /* U+38 "8" */ + 0x0, 0x1, 0xff, 0xe0, 0x0, 0x0, 0x7, 0xff, + 0xff, 0x80, 0x0, 0x7, 0xff, 0xff, 0xf8, 0x0, + 0x7, 0xff, 0xff, 0xff, 0x80, 0x3, 0xff, 0xff, + 0xff, 0xf0, 0x1, 0xff, 0xff, 0xff, 0xfe, 0x0, + 0xff, 0xff, 0xff, 0xff, 0xc0, 0x7f, 0xff, 0xff, + 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xfe, 0xf, + 0xff, 0xe0, 0x3f, 0xff, 0xc3, 0xff, 0xe0, 0x3, + 0xff, 0xf0, 0xff, 0xf0, 0x0, 0x7f, 0xfc, 0x7f, + 0xf8, 0x0, 0xf, 0xff, 0x9f, 0xfe, 0x0, 0x3, + 0xff, 0xe7, 0xff, 0x0, 0x0, 0x7f, 0xf9, 0xff, + 0xc0, 0x0, 0x1f, 0xfe, 0x7f, 0xf0, 0x0, 0x7, + 0xff, 0x9f, 0xfc, 0x0, 0x1, 0xff, 0xe7, 0xff, + 0x0, 0x0, 0x7f, 0xf9, 0xff, 0xc0, 0x0, 0x1f, + 0xfe, 0x3f, 0xf8, 0x0, 0xf, 0xff, 0xf, 0xfe, + 0x0, 0x3, 0xff, 0xc3, 0xff, 0xc0, 0x1, 0xff, + 0xe0, 0x7f, 0xf8, 0x0, 0xff, 0xf8, 0xf, 0xff, + 0x80, 0xff, 0xfc, 0x1, 0xff, 0xff, 0xff, 0xfe, + 0x0, 0x3f, 0xff, 0xff, 0xff, 0x0, 0x7, 0xff, + 0xff, 0xff, 0x0, 0x0, 0x7f, 0xff, 0xff, 0x0, + 0x0, 0x3, 0xff, 0xfe, 0x0, 0x0, 0x7, 0xff, + 0xff, 0xf0, 0x0, 0x7, 0xff, 0xff, 0xff, 0x80, + 0x7, 0xff, 0xff, 0xff, 0xf0, 0x3, 0xff, 0xff, + 0xff, 0xff, 0x1, 0xff, 0xf8, 0xf, 0xff, 0xe0, + 0xff, 0xf8, 0x0, 0x7f, 0xf8, 0x3f, 0xfc, 0x0, + 0xf, 0xff, 0x1f, 0xfe, 0x0, 0x1, 0xff, 0xe7, + 0xff, 0x80, 0x0, 0x7f, 0xfb, 0xff, 0xc0, 0x0, + 0xf, 0xfe, 0xff, 0xf0, 0x0, 0x3, 0xff, 0xff, + 0xfc, 0x0, 0x0, 0xff, 0xff, 0xff, 0x0, 0x0, + 0x3f, 0xff, 0xff, 0xc0, 0x0, 0xf, 0xff, 0xff, + 0xf0, 0x0, 0x3, 0xff, 0xff, 0xfe, 0x0, 0x1, + 0xff, 0xff, 0xff, 0x80, 0x0, 0x7f, 0xff, 0xff, + 0xf0, 0x0, 0x3f, 0xff, 0x7f, 0xfe, 0x0, 0x1f, + 0xff, 0x9f, 0xff, 0xe0, 0x3f, 0xff, 0xe3, 0xff, + 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, + 0xfc, 0x1f, 0xff, 0xff, 0xff, 0xfe, 0x3, 0xff, + 0xff, 0xff, 0xff, 0x0, 0x7f, 0xff, 0xff, 0xff, + 0x80, 0xf, 0xff, 0xff, 0xff, 0xc0, 0x1, 0xff, + 0xff, 0xff, 0xe0, 0x0, 0x1f, 0xff, 0xff, 0xe0, + 0x0, 0x1, 0xff, 0xff, 0xe0, 0x0, 0x0, 0x7, + 0xff, 0x80, 0x0, + + /* U+39 "9" */ + 0x0, 0x0, 0xff, 0xc0, 0x0, 0x0, 0x3, 0xff, + 0xff, 0x0, 0x0, 0x3, 0xff, 0xff, 0xf0, 0x0, + 0x3, 0xff, 0xff, 0xff, 0x0, 0x1, 0xff, 0xff, + 0xff, 0xe0, 0x1, 0xff, 0xff, 0xff, 0xfc, 0x0, + 0x7f, 0xff, 0xff, 0xff, 0x80, 0x3f, 0xff, 0xff, + 0xff, 0xf0, 0x1f, 0xff, 0xff, 0xff, 0xfe, 0xf, + 0xff, 0xff, 0xff, 0xff, 0x83, 0xff, 0xfc, 0xf, + 0xff, 0xf1, 0xff, 0xf8, 0x0, 0xff, 0xfc, 0x7f, + 0xfc, 0x0, 0xf, 0xff, 0x9f, 0xff, 0x0, 0x3, + 0xff, 0xef, 0xff, 0x80, 0x0, 0x7f, 0xfb, 0xff, + 0xe0, 0x0, 0x1f, 0xff, 0xff, 0xf0, 0x0, 0x3, + 0xff, 0xff, 0xfc, 0x0, 0x0, 0xff, 0xff, 0xff, + 0x0, 0x0, 0x3f, 0xff, 0xff, 0xc0, 0x0, 0xf, + 0xff, 0xff, 0xf0, 0x0, 0x3, 0xff, 0xff, 0xfc, + 0x0, 0x0, 0xff, 0xff, 0xff, 0x80, 0x0, 0x7f, + 0xff, 0xff, 0xe0, 0x0, 0x1f, 0xff, 0x7f, 0xf8, + 0x0, 0xf, 0xff, 0xdf, 0xff, 0x0, 0x3, 0xff, + 0xe7, 0xff, 0xf0, 0x3, 0xff, 0xf8, 0xff, 0xff, + 0x3, 0xff, 0xfe, 0x3f, 0xff, 0xff, 0xff, 0xff, + 0x87, 0xff, 0xff, 0xff, 0xff, 0xc1, 0xff, 0xff, + 0xff, 0xff, 0xf0, 0x3f, 0xff, 0xff, 0xff, 0xf8, + 0x7, 0xff, 0xff, 0xdf, 0xfe, 0x0, 0xff, 0xff, + 0xef, 0xff, 0x80, 0x1f, 0xff, 0xf7, 0xff, 0xc0, + 0x1, 0xff, 0xf1, 0xff, 0xf0, 0x0, 0xf, 0xf0, + 0xff, 0xf8, 0x0, 0x0, 0x0, 0x7f, 0xfc, 0x0, + 0x0, 0x0, 0x1f, 0xff, 0x0, 0x0, 0x0, 0xf, + 0xff, 0x80, 0x0, 0x0, 0x7, 0xff, 0xe0, 0x0, + 0x0, 0x1, 0xff, 0xf0, 0x0, 0x0, 0x0, 0xff, + 0xf8, 0x0, 0x0, 0x0, 0x7f, 0xfe, 0x0, 0x0, + 0x0, 0x1f, 0xff, 0x0, 0x0, 0x0, 0xf, 0xff, + 0x80, 0x0, 0x0, 0x7, 0xff, 0xe0, 0x0, 0x0, + 0x1, 0xff, 0xf0, 0x0, 0x0, 0x0, 0xff, 0xf8, + 0x0, 0x0, 0x0, 0x7f, 0xfe, 0x0, 0x0, 0x0, + 0x1f, 0xff, 0x0, 0x0, 0x0, 0xf, 0xff, 0x80, + 0x0, 0x0, 0x7, 0xff, 0xe0, 0x0, 0x0, 0x3, + 0xff, 0xf0, 0x0, 0x0, 0x0, 0xff, 0xf8, 0x0, + 0x0, 0x0, 0x7f, 0xfe, 0x0, 0x0, 0x0, 0x3f, + 0xff, 0x0, 0x0, 0x0, 0xf, 0xff, 0x80, 0x0, + 0x0, 0x7, 0xff, 0xe0, 0x0, 0x0, + + /* U+3A ":" */ + 0x7, 0xe0, 0x1f, 0xf8, 0x3f, 0xfc, 0x7f, 0xfe, + 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, + 0x7f, 0xfe, 0x3f, 0xfc, 0x1f, 0xf8, 0x7, 0xe0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x7, 0xe0, 0x1f, 0xf8, + 0x3f, 0xfc, 0x7f, 0xfe, 0x7f, 0xfe, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x7f, 0xfe, 0x7f, 0xfe, 0x3f, 0xfc, + 0x1f, 0xf8, 0x7, 0xe0 +}; + + +/*--------------------- + * GLYPH DESCRIPTION + *--------------------*/ + +static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = { + {.bitmap_index = 0, .adv_w = 0, .box_w = 0, .box_h = 0, .ofs_x = 0, .ofs_y = 0} /* id = 0 reserved */, + {.bitmap_index = 0, .adv_w = 768, .box_w = 41, .box_h = 59, .ofs_x = 4, .ofs_y = -1}, + {.bitmap_index = 303, .adv_w = 768, .box_w = 40, .box_h = 58, .ofs_x = 6, .ofs_y = 0}, + {.bitmap_index = 593, .adv_w = 768, .box_w = 41, .box_h = 58, .ofs_x = 4, .ofs_y = 0}, + {.bitmap_index = 891, .adv_w = 768, .box_w = 41, .box_h = 59, .ofs_x = 3, .ofs_y = -1}, + {.bitmap_index = 1194, .adv_w = 768, .box_w = 38, .box_h = 58, .ofs_x = 4, .ofs_y = 0}, + {.bitmap_index = 1470, .adv_w = 768, .box_w = 41, .box_h = 58, .ofs_x = 4, .ofs_y = -1}, + {.bitmap_index = 1768, .adv_w = 768, .box_w = 42, .box_h = 59, .ofs_x = 3, .ofs_y = -1}, + {.bitmap_index = 2078, .adv_w = 768, .box_w = 40, .box_h = 58, .ofs_x = 4, .ofs_y = 0}, + {.bitmap_index = 2368, .adv_w = 768, .box_w = 42, .box_h = 60, .ofs_x = 3, .ofs_y = -1}, + {.bitmap_index = 2683, .adv_w = 768, .box_w = 42, .box_h = 59, .ofs_x = 3, .ofs_y = 0}, + {.bitmap_index = 2993, .adv_w = 768, .box_w = 16, .box_h = 46, .ofs_x = 16, .ofs_y = -1} +}; + +/*--------------------- + * CHARACTER MAPPING + *--------------------*/ + + + +/*Collect the unicode lists and glyph_id offsets*/ +static const lv_font_fmt_txt_cmap_t cmaps[] = +{ + { + .range_start = 48, .range_length = 11, .glyph_id_start = 1, + .unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY + } +}; + + + +/*-------------------- + * ALL CUSTOM DATA + *--------------------*/ + +/*Store all the custom data of the font*/ +static lv_font_fmt_txt_dsc_t font_dsc = { + .glyph_bitmap = gylph_bitmap, + .glyph_dsc = glyph_dsc, + .cmaps = cmaps, + .kern_dsc = NULL, + .kern_scale = 0, + .cmap_num = 1, + .bpp = 1, + .kern_classes = 0, + .bitmap_format = 0 +}; + + +/*----------------- + * PUBLIC FONT + *----------------*/ + +/*Initialize a public general font descriptor*/ +lv_font_t jetbrains_mono_extrabold_compressedextrabold_compressed = { + .get_glyph_dsc = lv_font_get_glyph_dsc_fmt_txt, /*Function pointer to get glyph's data*/ + .get_glyph_bitmap = lv_font_get_bitmap_fmt_txt, /*Function pointer to get glyph's bitmap*/ + .line_height = 60, /*The maximum line height required by the font*/ + .base_line = 1, /*Baseline measured from the bottom of the line*/ +#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) + .subpx = LV_FONT_SUBPX_NONE, +#endif + .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ +}; + +#endif /*#if JETBRAINS_MONO_EXTRABOLD_COMPRESSEDEXTRABOLD_COMPRESSED*/ + diff --git a/src/DisplayApp/LittleVgl.cpp b/src/DisplayApp/LittleVgl.cpp new file mode 100644 index 00000000..7830953a --- /dev/null +++ b/src/DisplayApp/LittleVgl.cpp @@ -0,0 +1,59 @@ +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "LittleVgl.h" + +using namespace Pinetime::Components; + +static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p) { + auto* lvgl = static_cast(disp_drv->user_data); + lvgl->FlushDisplay(area, color_p); +} + +LittleVgl::LittleVgl(Pinetime::Drivers::St7789& lcd) : lcd{lcd} { + lv_init(); + lv_theme_t* theme = lv_theme_night_init(10, NULL); + lv_theme_set_current(theme); + + lv_disp_buf_init(&disp_buf_2, buf2_1, buf2_2, LV_HOR_RES_MAX * 2); /*Initialize the display buffer*/ + lv_disp_drv_init(&disp_drv); /*Basic initialization*/ + + /*Set up the functions to access to your display*/ + + /*Set the resolution of the display*/ + disp_drv.hor_res = 240; + disp_drv.ver_res = 240; + + /*Used to copy the buffer's content to the display*/ + disp_drv.flush_cb = disp_flush; + /*Set a display buffer*/ + disp_drv.buffer = &disp_buf_2; + disp_drv.user_data = this; + + /*Finally register the driver*/ + lv_disp_drv_register(&disp_drv); + + +} + +void LittleVgl::FlushDisplay(const lv_area_t *area, lv_color_t *color_p) { + auto x = area->x1; + auto y = area->y1; + auto width = (area->x2-area->x1)+1; + auto height = (area->y2-area->y1)+1; + lcd.BeginDrawBuffer(x, y, width, height); + lcd.NextDrawBuffer(reinterpret_cast(color_p), width * height*2) ; + + ulTaskNotifyTake(pdTRUE, 500); + + /* IMPORTANT!!! + * Inform the graphics library that you are ready with the flushing*/ + lv_disp_flush_ready(&disp_drv); +} diff --git a/src/DisplayApp/LittleVgl.h b/src/DisplayApp/LittleVgl.h new file mode 100644 index 00000000..cff1c3b1 --- /dev/null +++ b/src/DisplayApp/LittleVgl.h @@ -0,0 +1,29 @@ +#pragma once + +#include +#include + + +static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p); + +namespace Pinetime { + namespace Components { + class LittleVgl { + public: + LittleVgl(Pinetime::Drivers::St7789& lcd); + void FlushDisplay(const lv_area_t * area, lv_color_t * color_p); + + + private: + Pinetime::Drivers::St7789& lcd; + + lv_disp_buf_t disp_buf_2; + lv_color_t buf2_1[LV_HOR_RES_MAX * 2]; + lv_color_t buf2_2[LV_HOR_RES_MAX * 2]; + + lv_disp_drv_t disp_drv; + + }; + } +} + diff --git a/src/DisplayApp/Screens/Clock.cpp b/src/DisplayApp/Screens/Clock.cpp index 155cb581..a413476a 100644 --- a/src/DisplayApp/Screens/Clock.cpp +++ b/src/DisplayApp/Screens/Clock.cpp @@ -2,17 +2,46 @@ #include #include #include +#include #include "Clock.h" using namespace Pinetime::Applications::Screens; +extern lv_font_t jetbrains_mono_extrabold_compressedextrabold_compressed; +extern lv_font_t jetbrains_mono_bold_20; + +Clock::Clock(Pinetime::Components::Gfx &gfx) : Screen(gfx), currentDateTime{{}}, version {{}} { + label_battery = lv_label_create(lv_scr_act(), NULL); + lv_obj_align(label_battery, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, -80, 0); + + labelStyle = const_cast(lv_label_get_style(label_battery, LV_LABEL_STYLE_MAIN)); + labelStyle->text.font = &jetbrains_mono_bold_20; + + lv_style_copy(&labelBigStyle, labelStyle); + labelBigStyle.text.font = &jetbrains_mono_extrabold_compressedextrabold_compressed; + + lv_label_set_style(label_battery, LV_LABEL_STYLE_MAIN, labelStyle); + + label_ble = lv_label_create(lv_scr_act(), NULL); + lv_label_set_style(label_ble, LV_LABEL_STYLE_MAIN, labelStyle); + lv_obj_align(label_ble, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 10, 0); + + label_time = lv_label_create(lv_scr_act(), NULL); + lv_label_set_style(label_time, LV_LABEL_STYLE_MAIN, &labelBigStyle); + lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 0); + + + label_date = lv_label_create(lv_scr_act(), NULL); + lv_label_set_style(label_date, LV_LABEL_STYLE_MAIN, labelStyle); + lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 80); + + label_version = lv_label_create(lv_scr_act(), NULL); + lv_label_set_style(label_version, LV_LABEL_STYLE_MAIN, labelStyle); + lv_obj_align(label_version, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 100); + +} void Clock::Refresh(bool fullRefresh) { if(fullRefresh) { - gfx.FillRectangle(0,0,240,240,0x0000); - currentChar[0] = 1; - currentChar[1] = 2; - currentChar[2] = 3; - currentChar[3] = 4; auto dummy = currentDateTime.Get(); } @@ -23,12 +52,14 @@ void Clock::Refresh(bool fullRefresh) { newBatteryValue = (newBatteryValue < 0) ? 0 : newBatteryValue; sprintf(batteryChar, "BAT: %d%%", newBatteryValue); - gfx.DrawString((240 - 108), 0, 0xffff, batteryChar, &smallFont, false); + lv_label_set_text(label_battery, batteryChar); } if (fullRefresh || bleState.IsUpdated()) { uint16_t color = (bleState.Get() == BleConnectionStates::Connected) ? 0xffff : 0x0000; gfx.DrawString(10, 0, color, "BLE", &smallFont, false); + lv_label_set_text(label_ble, "BLE"); + // TODO color } if(fullRefresh || currentDateTime.IsUpdated()) { @@ -53,35 +84,16 @@ void Clock::Refresh(bool fullRefresh) { char hoursChar[3]; sprintf(hoursChar, "%02d", hour); - uint8_t x = 7; - if (hoursChar[0] != currentChar[0]) { - gfx.DrawChar(&largeFont, hoursChar[0], &x, 78, 0xffff); - currentChar[0] = hoursChar[0]; - } - - x = 61; - if (hoursChar[1] != currentChar[1]) { - gfx.DrawChar(&largeFont, hoursChar[1], &x, 78, 0xffff); - currentChar[1] = hoursChar[1]; - } - - x = 127; - if (minutesChar[0] != currentChar[2]) { - gfx.DrawChar(&largeFont, minutesChar[0], &x, 78, 0xffff); - currentChar[2] = minutesChar[0]; - } - - x = 181; - if (minutesChar[1] != currentChar[3]) { - gfx.DrawChar(&largeFont, minutesChar[1], &x, 78, 0xffff); - currentChar[3] = minutesChar[1]; - } + char timeStr[6]; + sprintf(timeStr, "%c%c:%c%c", hoursChar[0],hoursChar[1],minutesChar[0], minutesChar[1]); + lv_label_set_text(label_time, timeStr); if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) { gfx.FillRectangle(0,180, 240, 15, 0x0000); char dateStr[22]; sprintf(dateStr, "%s %d %s %d", DayOfWeekToString(dayOfWeek), day, MonthToString(month), year); - gfx.DrawString(10, 180, 0xffff, dateStr, &smallFont, false); + lv_label_set_text(label_date, dateStr); + currentYear = year; currentMonth = month; @@ -93,8 +105,9 @@ void Clock::Refresh(bool fullRefresh) { if(fullRefresh || version.IsUpdated()) { char version[20]; sprintf(version, "VERSION: %d.%d.%d", Version::Major(), Version::Minor(), Version::Patch()); - gfx.DrawString(20, 220, 0xffff, version, &smallFont, false); + lv_label_set_text(label_version, version); } + } const char *Clock::MonthToString(Pinetime::Controllers::DateTime::Months month) { @@ -131,3 +144,5 @@ char const *Clock::MonthsString[] = { "NOV", "DEC" }; + + diff --git a/src/DisplayApp/Screens/Clock.h b/src/DisplayApp/Screens/Clock.h index 12dd8850..f5328535 100644 --- a/src/DisplayApp/Screens/Clock.h +++ b/src/DisplayApp/Screens/Clock.h @@ -5,6 +5,8 @@ #include #include "Screen.h" #include +#include +#include #include "../Fonts/lcdfont14.h" #include "../Fonts/lcdfont70.h" #include "../../Version.h" @@ -33,7 +35,7 @@ namespace Pinetime { class Clock : public Screen{ public: enum class BleConnectionStates{ NotConnected, Connected}; - Clock(Components::Gfx& gfx) : Screen(gfx), currentDateTime{{}}, version {{}} {} + Clock(Components::Gfx& gfx); void Refresh(bool fullRefresh) override; void SetBatteryPercentRemaining(uint8_t percent) { batteryPercentRemaining = percent; } @@ -49,7 +51,6 @@ namespace Pinetime { const FONT_INFO largeFont {lCD_70ptFontInfo.height, lCD_70ptFontInfo.startChar, lCD_70ptFontInfo.endChar, lCD_70ptFontInfo.spacePixels, lCD_70ptFontInfo.charInfo, lCD_70ptFontInfo.data}; const FONT_INFO smallFont {lCD_14ptFontInfo.height, lCD_14ptFontInfo.startChar, lCD_14ptFontInfo.endChar, lCD_14ptFontInfo.spacePixels, lCD_14ptFontInfo.charInfo, lCD_14ptFontInfo.data}; - char currentChar[4]; uint16_t currentYear = 1970; Pinetime::Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown; Pinetime::Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown; @@ -59,6 +60,16 @@ namespace Pinetime { DirtyValue bleState {BleConnectionStates::NotConnected}; DirtyValue> currentDateTime; DirtyValue version; + + lv_style_t* labelStyle; + lv_style_t labelBigStyle; + lv_obj_t * label_battery; + + lv_obj_t * label_ble; + lv_obj_t* label_time; + lv_obj_t* label_date; + lv_obj_t* label_version; + }; } } diff --git a/src/DisplayApp/Screens/Message.cpp b/src/DisplayApp/Screens/Message.cpp index 7b1ed9ae..8ffad413 100644 --- a/src/DisplayApp/Screens/Message.cpp +++ b/src/DisplayApp/Screens/Message.cpp @@ -3,19 +3,26 @@ #include #include #include +#include #include #include "Message.h" using namespace Pinetime::Applications::Screens; +extern lv_font_t jetbrains_mono_extrabold_compressedextrabold_compressed; + lv_obj_t * label; +int x = 0; void Message::Refresh(bool fullRefresh) { if(fullRefresh) { - lv_obj_t * btn = lv_btn_create(lv_scr_act(), NULL); /*Add a button the current screen*/ - lv_obj_set_pos(btn, 10, 10); /*Set its position*/ - lv_obj_set_size(btn, 100, 50); /*Set its size*/ - label = lv_label_create(btn, NULL); /*Add a label to the button*/ - lv_label_set_text(label, "Button"); /*Set the labels text*/ + label = lv_label_create(lv_scr_act(), NULL); /*Add a label to the button*/ + labelStyle = const_cast(lv_label_get_style(label, LV_LABEL_STYLE_MAIN)); + labelStyle->text.font = &jetbrains_mono_extrabold_compressedextrabold_compressed; + lv_label_set_style(label, LV_LABEL_STYLE_MAIN, labelStyle); + lv_label_set_text(label, "01:23"); /*Set the labels text*/ + } else { + lv_obj_set_pos(label, 0, x++); + if(x > 200) x = 0; } } diff --git a/src/DisplayApp/Screens/Message.h b/src/DisplayApp/Screens/Message.h index ac300faf..419c2e62 100644 --- a/src/DisplayApp/Screens/Message.h +++ b/src/DisplayApp/Screens/Message.h @@ -8,6 +8,7 @@ #include "../Fonts/lcdfont14.h" #include "../Fonts/lcdfont70.h" #include "../../Version.h" +#include namespace Pinetime { namespace Applications { @@ -20,6 +21,8 @@ namespace Pinetime { private: const FONT_INFO largeFont {lCD_70ptFontInfo.height, lCD_70ptFontInfo.startChar, lCD_70ptFontInfo.endChar, lCD_70ptFontInfo.spacePixels, lCD_70ptFontInfo.charInfo, lCD_70ptFontInfo.data}; const FONT_INFO smallFont {lCD_14ptFontInfo.height, lCD_14ptFontInfo.startChar, lCD_14ptFontInfo.endChar, lCD_14ptFontInfo.spacePixels, lCD_14ptFontInfo.charInfo, lCD_14ptFontInfo.data}; + + lv_style_t* labelStyle; }; } } diff --git a/src/DisplayApp/lv_port_disp.cpp b/src/DisplayApp/lv_port_disp.cpp deleted file mode 100644 index 6f6acc44..00000000 --- a/src/DisplayApp/lv_port_disp.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/** - * @file lv_port_disp_templ.c - * - */ - -/*Copy this file as "lv_port_disp.c" and set this value to "1" to enable content*/ -#if 1 - -/********************* - * INCLUDES - *********************/ -#include -#include -#include -#include "lv_port_disp.h" -#include "../drivers/St7789.h" -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ -static void disp_init(void); - -static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p); -#if LV_USE_GPU -static void gpu_blend(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa); -static void gpu_fill(lv_color_t * dest, uint32_t length, lv_color_t color); -#endif - -/********************** - * STATIC VARIABLES - **********************/ - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -void lv_port_disp_init(void) -{ - /*------------------------- - * Initialize your display - * -----------------------*/ - disp_init(); - - /*----------------------------- - * Create a buffer for drawing - *----------------------------*/ - - /* LittlevGL requires a buffer where it draws the objects. The buffer's has to be greater than 1 display row - * - * There are three buffering configurations: - * 1. Create ONE buffer with some rows: - * LittlevGL will draw the display's content here and writes it to your display - * - * 2. Create TWO buffer with some rows: - * LittlevGL will draw the display's content to a buffer and writes it your display. - * You should use DMA to write the buffer's content to the display. - * It will enable LittlevGL to draw the next part of the screen to the other buffer while - * the data is being sent form the first buffer. It makes rendering and flushing parallel. - * - * 3. Create TWO screen-sized buffer: - * Similar to 2) but the buffer have to be screen sized. When LittlevGL is ready it will give the - * whole frame to display. This way you only need to change the frame buffer's address instead of - * copying the pixels. - * */ - - /* Example for 1) */ -#if 0 - static lv_disp_buf_t disp_buf_1; - static lv_color_t buf1_1[LV_HOR_RES_MAX * 10]; /*A buffer for 10 rows*/ - lv_disp_buf_init(&disp_buf_1, buf1_1, NULL, LV_HOR_RES_MAX * 10); /*Initialize the display buffer*/ -#endif - /* Example for 2) */ - static lv_disp_buf_t disp_buf_2; - static lv_color_t buf2_1[LV_HOR_RES_MAX * 2]; /*A buffer for 10 rows*/ - static lv_color_t buf2_2[LV_HOR_RES_MAX * 2]; /*An other buffer for 10 rows*/ - lv_disp_buf_init(&disp_buf_2, buf2_1, buf2_2, LV_HOR_RES_MAX * 2); /*Initialize the display buffer*/ - - /* Example for 3) */ -#if 0 - static lv_disp_buf_t disp_buf_3; - static lv_color_t buf3_1[LV_HOR_RES_MAX * LV_VER_RES_MAX]; /*A screen sized buffer*/ - static lv_color_t buf3_2[LV_HOR_RES_MAX * LV_VER_RES_MAX]; /*An other screen sized buffer*/ - lv_disp_buf_init(&disp_buf_3, buf3_1, buf3_2, LV_HOR_RES_MAX * LV_VER_RES_MAX); /*Initialize the display buffer*/ -#endif - - /*----------------------------------- - * Register the display in LittlevGL - *----------------------------------*/ - - lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/ - lv_disp_drv_init(&disp_drv); /*Basic initialization*/ - - /*Set up the functions to access to your display*/ - - /*Set the resolution of the display*/ - disp_drv.hor_res = 240; - disp_drv.ver_res = 240; - - /*Used to copy the buffer's content to the display*/ - disp_drv.flush_cb = disp_flush; - /*Set a display buffer*/ - disp_drv.buffer = &disp_buf_2; - -#if LV_USE_GPU - /*Optionally add functions to access the GPU. (Only in buffered mode, LV_VDB_SIZE != 0)*/ - - /*Blend two color array using opacity*/ - disp_drv.gpu_blend = gpu_blend; - - /*Fill a memory array with a color*/ - disp_drv.gpu_fill = gpu_fill; -#endif - - /*Finally register the driver*/ - lv_disp_drv_register(&disp_drv); -} - -/********************** - * STATIC FUNCTIONS - **********************/ - -/* Initialize your display and the required peripherals. */ -extern Pinetime::Drivers::St7789* ptrLcd; -static void disp_init(void) -{ - /*You code here*/ -} - -void NotifyEndOfTransfert(TaskHandle_t task) { - if(task != nullptr) { - BaseType_t xHigherPriorityTaskWoken = pdFALSE; - vTaskNotifyGiveFromISR(task, &xHigherPriorityTaskWoken); - portYIELD_FROM_ISR(xHigherPriorityTaskWoken); - } -} - -/* Flush the content of the internal buffer the specific area on the display - * You can use DMA or any hardware acceleration to do this operation in the background but - * 'lv_disp_flush_ready()' has to be called when finished. */ -static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p) -{ - /*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/ - auto x = area->x1; - auto y = area->y1; - auto width = (area->x2-area->x1)+1; - auto height = (area->y2-area->y1)+1; - ptrLcd->BeginDrawBuffer(x, y, width, height); - ptrLcd->NextDrawBuffer(reinterpret_cast(color_p), width * height*2) ; - - ulTaskNotifyTake(pdTRUE, 500); - - /* IMPORTANT!!! - * Inform the graphics library that you are ready with the flushing*/ - lv_disp_flush_ready(disp_drv); -} - - -/*OPTIONAL: GPU INTERFACE*/ -#if LV_USE_GPU - -/* If your MCU has hardware accelerator (GPU) then you can use it to blend to memories using opacity - * It can be used only in buffered mode (LV_VDB_SIZE != 0 in lv_conf.h)*/ -static void gpu_blend(lv_disp_drv_t * disp_drv, lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa) -{ - /*It's an example code which should be done by your GPU*/ - uint32_t i; - for(i = 0; i < length; i++) { - dest[i] = lv_color_mix(dest[i], src[i], opa); - } -} - -/* If your MCU has hardware accelerator (GPU) then you can use it to fill a memory with a color - * It can be used only in buffered mode (LV_VDB_SIZE != 0 in lv_conf.h)*/ -static void gpu_fill_cb(lv_disp_drv_t * disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width, - const lv_area_t * fill_area, lv_color_t color); -{ - /*It's an example code which should be done by your GPU*/ - uint32_t x, y; - dest_buf += dest_width * fill_area->y1; /*Go to the first line*/ - - for(y = fill_area->y1; y < fill_area->y2; y++) { - for(x = fill_area->x1; x < fill_area->x2; x++) { - dest_buf[x] = color; - } - dest_buf+=dest_width; /*Go to the next line*/ - } -} - -#endif /*LV_USE_GPU*/ - -#else /* Enable this file at the top */ - -/* This dummy typedef exists purely to silence -Wpedantic. */ -typedef int keep_pedantic_happy; -#endif diff --git a/src/DisplayApp/lv_port_disp.h b/src/DisplayApp/lv_port_disp.h deleted file mode 100644 index e0d70506..00000000 --- a/src/DisplayApp/lv_port_disp.h +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @file lv_port_disp_templ.h - * - */ - - /*Copy this file as "lv_port_disp.h" and set this value to "1" to enable content*/ -#if 1 - -#ifndef LV_PORT_DISP_TEMPL_H -#define LV_PORT_DISP_TEMPL_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ -#include "lvgl/lvgl.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * GLOBAL PROTOTYPES - **********************/ -void lv_port_disp_init(void); - -/********************** - * MACROS - **********************/ - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /*LV_PORT_DISP_TEMPL_H*/ - -#endif /*Disable/Enable content*/ diff --git a/src/libs/lv_conf.h b/src/libs/lv_conf.h index 49a3072d..603339ee 100644 --- a/src/libs/lv_conf.h +++ b/src/libs/lv_conf.h @@ -123,7 +123,7 @@ typedef int16_t lv_coord_t; *==================*/ /*1: Enable the Animations */ -#define LV_USE_ANIMATION 1 +#define LV_USE_ANIMATION 0 #if LV_USE_ANIMATION /*Declare the type of the user data of animations (can be e.g. `void *`, `int`, `struct`)*/ @@ -132,7 +132,7 @@ typedef void * lv_anim_user_data_t; #endif /* 1: Enable shadow drawing*/ -#define LV_USE_SHADOW 1 +#define LV_USE_SHADOW 0 /* 1: Enable object groups (for keyboard/encoder navigation) */ #define LV_USE_GROUP 0 @@ -278,9 +278,9 @@ typedef void * lv_indev_drv_user_data_t; /*Type of user data in the i #define LV_THEME_LIVE_UPDATE 0 /*1: Allow theme switching at run time. Uses 8..10 kB of RAM*/ #define LV_USE_THEME_TEMPL 0 /*Just for test*/ -#define LV_USE_THEME_DEFAULT 0 /*Built mainly from the built-in styles. Consumes very few RAM*/ +#define LV_USE_THEME_DEFAULT 1 /*Built mainly from the built-in styles. Consumes very few RAM*/ #define LV_USE_THEME_ALIEN 0 /*Dark futuristic theme*/ -#define LV_USE_THEME_NIGHT 0 /*Dark elegant theme*/ +#define LV_USE_THEME_NIGHT 1 /*Dark elegant theme*/ #define LV_USE_THEME_MONO 0 /*Mono color theme for monochrome displays*/ #define LV_USE_THEME_MATERIAL 0 /*Flat theme with bold colors and light shadows*/ #define LV_USE_THEME_ZEN 0 /*Peaceful, mainly light theme */ @@ -314,7 +314,7 @@ typedef void * lv_indev_drv_user_data_t; /*Type of user data in the i /* Optionally declare your custom fonts here. * You can use these fonts as default font too * and they will be available globally. E.g. - * #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) \ + * #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) \LV_SUBPX_BGR * LV_FONT_DECLARE(my_font_2) */ #define LV_FONT_CUSTOM_DECLARE @@ -513,7 +513,7 @@ typedef void * lv_obj_user_data_t; #endif /*Preload (dependencies: lv_arc, lv_anim)*/ -#define LV_USE_PRELOAD 1 +#define LV_USE_PRELOAD 0 #if LV_USE_PRELOAD != 0 # define LV_PRELOAD_DEF_ARC_LENGTH 60 /*[deg]*/ # define LV_PRELOAD_DEF_SPIN_TIME 1000 /*[ms]*/ diff --git a/src/main.cpp b/src/main.cpp index 4da92b27..d655ad33 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,6 +21,7 @@ #include #include +#include #if NRF_LOG_ENABLED #include "Logging/NrfLogger.h" @@ -34,6 +35,7 @@ std::unique_ptr spi; std::unique_ptr lcd; Pinetime::Drivers::St7789* ptrLcd; std::unique_ptr gfx; +std::unique_ptr lvgl; std::unique_ptr touchPanel; static constexpr uint8_t pinSpiSck = 2; @@ -124,6 +126,7 @@ void SystemTask(void *) { lcd.reset(new Pinetime::Drivers::St7789(*spi, pinLcdDataCommand)); gfx.reset(new Pinetime::Components::Gfx(*lcd)); + lvgl.reset(new Pinetime::Components::LittleVgl(*lcd)); touchPanel.reset(new Pinetime::Drivers::Cst816S()); ptrLcd = lcd.get(); @@ -132,7 +135,7 @@ void SystemTask(void *) { touchPanel->Init(); batteryController.Init(); - displayApp.reset(new Pinetime::Applications::DisplayApp(*lcd, *gfx, *touchPanel, batteryController, bleController, dateTimeController)); + displayApp.reset(new Pinetime::Applications::DisplayApp(*lcd, *gfx, *lvgl, *touchPanel, batteryController, bleController, dateTimeController)); displayApp->Start(); batteryController.Update(); @@ -168,8 +171,7 @@ void SystemTask(void *) { while(true) { uint8_t msg; - - if (xQueueReceive(systemTaksMsgQueue, &msg, systemTaskSleeping?3600000 : 1000)) { + if (xQueueReceive(systemTaksMsgQueue, &msg, systemTaskSleeping?3600000 : 10)) { SystemTaskMessages message = static_cast(msg); switch(message) { case SystemTaskMessages::GoToRunning: systemTaskSleeping = false; break; diff --git a/src/sdk_config.h b/src/sdk_config.h index 0d9b2744..d1570718 100644 --- a/src/sdk_config.h +++ b/src/sdk_config.h @@ -8452,15 +8452,15 @@ // NRF_LOG_ENABLED - nrf_log - Logger //========================================================== #ifndef NRF_LOG_ENABLED -#define NRF_LOG_ENABLED 0 +#define NRF_LOG_ENABLED 1 #endif #ifndef NRF_LOG_BACKEND_RTT_ENABLED -#define NRF_LOG_BACKEND_RTT_ENABLED 0 +#define NRF_LOG_BACKEND_RTT_ENABLED 1 #endif #ifndef NRF_LOG_BACKEND_SERIAL_USES_RTT -#define NRF_LOG_BACKEND_SERIAL_USES_RTT 0 +#define NRF_LOG_BACKEND_SERIAL_USES_RTT 1 #endif // Log message pool - Configuration of log message pool -- cgit v1.2.3-70-g09d2 From 52539a5ff1b6f52c65b032ef1668d43d4df2dc24 Mon Sep 17 00:00:00 2001 From: JF Date: Wed, 12 Feb 2020 19:57:04 +0100 Subject: Log Touchpanel data (position + gesture!) --- src/DisplayApp/DisplayApp.cpp | 9 ++----- src/drivers/Cst816s.cpp | 57 ++++++++++++++++++++++++++++++++----------- src/drivers/Cst816s.h | 12 +++++++++ src/main.cpp | 2 +- 4 files changed, 58 insertions(+), 22 deletions(-) (limited to 'src/DisplayApp/DisplayApp.cpp') diff --git a/src/DisplayApp/DisplayApp.cpp b/src/DisplayApp/DisplayApp.cpp index d29027fb..365855ed 100644 --- a/src/DisplayApp/DisplayApp.cpp +++ b/src/DisplayApp/DisplayApp.cpp @@ -48,11 +48,7 @@ void DisplayApp::Process(void *instance) { while (1) { app->Refresh(); - - auto before = nrf_rtc_counter_get(portNRF_RTC_REG); lv_task_handler(); - auto after = nrf_rtc_counter_get(portNRF_RTC_REG); - NRF_LOG_INFO("duration : %d", (after-before)); } } @@ -77,10 +73,10 @@ void DisplayApp::Refresh() { break; case States::Running: RunningState(); - queueTimeout = 1; + queueTimeout = 1000; break; } -/* + Messages msg; if (xQueueReceive(msgQueue, &msg, queueTimeout)) { switch (msg) { @@ -119,7 +115,6 @@ void DisplayApp::Refresh() { break; } } - */ } bool first = true; diff --git a/src/drivers/Cst816s.cpp b/src/drivers/Cst816s.cpp index 67700f53..b1af12d4 100644 --- a/src/drivers/Cst816s.cpp +++ b/src/drivers/Cst816s.cpp @@ -50,29 +50,58 @@ Cst816S::TouchInfos Cst816S::GetTouchInfo() { nrfx_twi_rx(&twi, address, touchData, 63); auto nbTouchPoints = touchData[2] & 0x0f; - uint8_t i = 0; +// uint8_t i = 0; +// NRF_LOG_INFO("#########################") + for(int i = 0; i < 1; i++) { uint8_t pointId = (touchData[touchIdIndex + (touchStep * i)]) >> 4; if(nbTouchPoints == 0 && pointId == lastTouchId) return info; // We fetch only the first touch point (the controller seems to handle only one anyway...) info.isTouch = true; - auto xHigh = touchData[touchXHighIndex + (touchStep * i)] & 0x0f; - auto xLow = touchData[touchXLowIndex + (touchStep * i)]; - uint16_t x = (xHigh << 8) | xLow; - auto yHigh = touchData[touchYHighIndex + (touchStep * i)] & 0x0f; - auto yLow = touchData[touchYLowIndex + (touchStep * i)]; - uint16_t y = (yHigh << 8) | yLow; + auto xHigh = touchData[touchXHighIndex + (touchStep * i)] & 0x0f; + auto xLow = touchData[touchXLowIndex + (touchStep * i)]; + uint16_t x = (xHigh << 8) | xLow; + + auto yHigh = touchData[touchYHighIndex + (touchStep * i)] & 0x0f; + auto yLow = touchData[touchYLowIndex + (touchStep * i)]; + uint16_t y = (yHigh << 8) | yLow; + + auto action = touchData[touchEventIndex + (touchStep * i)] >> 6; /* 0 = Down, 1 = Up, 2 = contact*/ + auto finger = touchData[touchIdIndex + (touchStep * i)] >> 4; + auto pressure = touchData[touchXYIndex + (touchStep * i)]; + auto area = touchData[touchMiscIndex + (touchStep * i)] >> 4; + + info.x = x; + info.y = y; + info.action = action; + info.gesture = static_cast(touchData[gestureIndex]); + + NRF_LOG_INFO("---------------") + NRF_LOG_INFO("ID : %d", pointId); + NRF_LOG_INFO("NB : %d", nbTouchPoints); + NRF_LOG_INFO("X/Y :%d / %d", info.x, info.y); + NRF_LOG_INFO("Action : %d", action); + NRF_LOG_INFO("Finger : %d", finger); + NRF_LOG_INFO("Pressure : %d", pressure); + NRF_LOG_INFO("area : %d", area); + NRF_LOG_INFO("Touch : %s", info.isTouch?"Yes" : "No"); + switch(info.gesture) {// gesture + case Gestures::None: NRF_LOG_INFO("Gesture : None"); break; + case Gestures::SlideDown: NRF_LOG_INFO("Gesture : Slide Down"); break; + case Gestures::SlideUp: NRF_LOG_INFO("Gesture : Slide Up"); break; + case Gestures::SlideLeft: NRF_LOG_INFO("Gesture : Slide Left"); break; + case Gestures::SlideRight: NRF_LOG_INFO("Gesture : Slide Right"); break; + case Gestures::SingleTap: NRF_LOG_INFO("Gesture : Single click"); break; + case Gestures::DoubleTap: NRF_LOG_INFO("Gesture : Double click"); break; + case Gestures::LongPress: NRF_LOG_INFO("Gesture : Long press"); break; + default : NRF_LOG_INFO("Unknown"); break; + } + + } - auto action = touchData[touchEventIndex + (touchStep * i)] >> 6; /* 0 = Down, 1 = Up, 2 = contact*/ - auto finger = touchData[touchIdIndex + (touchStep * i)] >> 4; - auto pressure = touchData[touchXYIndex + (touchStep * i)]; - auto area = touchData[touchMiscIndex + (touchStep * i)] >> 4; - info.x = x; - info.y = y; - info.action = action; return info; } diff --git a/src/drivers/Cst816s.h b/src/drivers/Cst816s.h index 0adb448b..93b05df1 100644 --- a/src/drivers/Cst816s.h +++ b/src/drivers/Cst816s.h @@ -6,6 +6,16 @@ namespace Pinetime { namespace Drivers { class Cst816S { public : + enum class Gestures : uint8_t { + None = 0x00, + SlideDown = 0x01, + SlideUp = 0x02, + SlideLeft = 0x03, + SlideRight = 0x04, + SingleTap = 0x05, + DoubleTap = 0x0B, + LongPress = 0x0C + }; struct TouchInfos { uint16_t x; uint16_t y; @@ -13,6 +23,7 @@ namespace Pinetime { uint8_t finger; uint8_t pressure; uint8_t area; + Gestures gesture; bool isTouch = false; }; @@ -36,6 +47,7 @@ namespace Pinetime { static constexpr uint8_t touchYLowIndex = 6; static constexpr uint8_t touchIdIndex = 5; static constexpr uint8_t touchStep = 6; + static constexpr uint8_t gestureIndex = 1; uint8_t touchData[63]; diff --git a/src/main.cpp b/src/main.cpp index d655ad33..0d374c6b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -171,7 +171,7 @@ void SystemTask(void *) { while(true) { uint8_t msg; - if (xQueueReceive(systemTaksMsgQueue, &msg, systemTaskSleeping?3600000 : 10)) { + if (xQueueReceive(systemTaksMsgQueue, &msg, systemTaskSleeping?3600000 : 1000)) { SystemTaskMessages message = static_cast(msg); switch(message) { case SystemTaskMessages::GoToRunning: systemTaskSleeping = false; break; -- cgit v1.2.3-70-g09d2 From 167a0ffc873a2442af43d0347efd00f84932b8cc Mon Sep 17 00:00:00 2001 From: JF Date: Sun, 16 Feb 2020 18:32:36 +0100 Subject: Add touch panel port to lvgl. PoC of user interaction with 3 screen (clock, menu and app). --- src/CMakeLists.txt | 17 ++++ src/Components/DateTime/DateTimeController.cpp | 2 +- src/DisplayApp/DisplayApp.cpp | 46 +++++++--- src/DisplayApp/DisplayApp.h | 8 +- src/DisplayApp/LittleVgl.cpp | 38 +++++++- src/DisplayApp/LittleVgl.h | 12 ++- src/DisplayApp/Screens/Clock.cpp | 57 ++++++++++-- src/DisplayApp/Screens/Clock.h | 11 ++- src/DisplayApp/Screens/Message.cpp | 77 +++++++++++++--- src/DisplayApp/Screens/Message.h | 12 ++- src/DisplayApp/Screens/Screen.h | 9 +- src/DisplayApp/Screens/Tab.cpp | 67 ++++++++++++++ src/DisplayApp/Screens/Tab.h | 28 ++++++ src/DisplayApp/Screens/Tile.cpp | 118 +++++++++++++++++++++++++ src/DisplayApp/Screens/Tile.h | 56 ++++++++++++ src/drivers/Cst816s.cpp | 40 ++++----- src/libs/lv_conf.h | 2 +- src/main.cpp | 8 +- 18 files changed, 540 insertions(+), 68 deletions(-) create mode 100644 src/DisplayApp/Screens/Tab.cpp create mode 100644 src/DisplayApp/Screens/Tab.h create mode 100644 src/DisplayApp/Screens/Tile.cpp create mode 100644 src/DisplayApp/Screens/Tile.h (limited to 'src/DisplayApp/DisplayApp.cpp') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0b220423..a5971f27 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -137,6 +137,19 @@ set(LVGL_SRC libs/lvgl/src/lv_themes/lv_theme_night.h libs/lvgl/src/lv_themes/lv_theme_night.c + libs/lvgl/src/lv_objx/lv_list.c + libs/lvgl/src/lv_objx/lv_list.h + libs/lvgl/src/lv_objx/lv_tileview.c + libs/lvgl/src/lv_objx/lv_tileview.h + libs/lvgl/src/lv_objx/lv_tabview.c + libs/lvgl/src/lv_objx/lv_tabview.h + libs/lvgl/src/lv_objx/lv_btnm.c + libs/lvgl/src/lv_objx/lv_btnm.h + libs/lvgl/src/lv_objx/lv_page.c + libs/lvgl/src/lv_objx/lv_page.h + libs/lvgl/src/lv_objx/lv_img.c + libs/lvgl/src/lv_objx/lv_img.h + ) list(APPEND SOURCE_FILES @@ -148,6 +161,8 @@ list(APPEND SOURCE_FILES DisplayApp/Screens/Screen.cpp DisplayApp/Screens/Clock.cpp DisplayApp/Screens/Message.cpp + DisplayApp/Screens/Tile.cpp + DisplayApp/Screens/Tab.cpp main.cpp drivers/St7789.cpp drivers/SpiMaster.cpp @@ -177,6 +192,8 @@ set(INCLUDE_FILES DisplayApp/Screens/Screen.h DisplayApp/Screens/Clock.h DisplayApp/Screens/Message.h + DisplayApp/Screens/Tile.h + DisplayApp/Screens/Tab.h drivers/St7789.h drivers/SpiMaster.h Components/Gfx/Gfx.h diff --git a/src/Components/DateTime/DateTimeController.cpp b/src/Components/DateTime/DateTimeController.cpp index 81d45416..ed6d70fb 100644 --- a/src/Components/DateTime/DateTimeController.cpp +++ b/src/Components/DateTime/DateTimeController.cpp @@ -49,7 +49,7 @@ void DateTime::UpdateTime(uint32_t systickCounter) { previousSystickCounter = 0xffffff - (rest - systickCounter); } - currentDateTime += std::chrono::milliseconds (systickDelta*10); + currentDateTime += std::chrono::seconds (correctedDelta); auto dp = date::floor(currentDateTime); auto time = date::make_time(currentDateTime-dp); diff --git a/src/DisplayApp/DisplayApp.cpp b/src/DisplayApp/DisplayApp.cpp index 365855ed..959c84a0 100644 --- a/src/DisplayApp/DisplayApp.cpp +++ b/src/DisplayApp/DisplayApp.cpp @@ -12,6 +12,8 @@ #include #include #include +#include +#include using namespace Pinetime::Applications; @@ -29,14 +31,12 @@ DisplayApp::DisplayApp(Pinetime::Drivers::St7789& lcd, batteryController{batteryController}, bleController{bleController}, dateTimeController{dateTimeController}, - clockScreen{gfx}, - messageScreen{gfx}{ + currentScreen{new Screens::Tile(this, gfx) } { msgQueue = xQueueCreate(queueSize, itemSize); - currentScreen = &clockScreen; } void DisplayApp::Start() { - if (pdPASS != xTaskCreate(DisplayApp::Process, "DisplayApp", 1024, this, 0, &taskHandle)) + if (pdPASS != xTaskCreate(DisplayApp::Process, "DisplayApp", 512, this, 0, &taskHandle)) APP_ERROR_HANDLER(NRF_ERROR_NO_MEM); } @@ -73,7 +73,7 @@ void DisplayApp::Refresh() { break; case States::Running: RunningState(); - queueTimeout = 1000; + queueTimeout = 20; break; } @@ -104,15 +104,17 @@ void DisplayApp::Refresh() { case Messages::UpdateDateTime: break; case Messages::UpdateBleConnection: - clockScreen.SetBleConnectionState(bleController.IsConnected() ? Screens::Clock::BleConnectionStates::Connected : Screens::Clock::BleConnectionStates::NotConnected); +// clockScreen.SetBleConnectionState(bleController.IsConnected() ? Screens::Clock::BleConnectionStates::Connected : Screens::Clock::BleConnectionStates::NotConnected); break; case Messages::UpdateBatteryLevel: - clockScreen.SetBatteryPercentRemaining(batteryController.PercentRemaining()); +// clockScreen.SetBatteryPercentRemaining(batteryController.PercentRemaining()); break; case Messages::TouchEvent: if(state != States::Running) break; OnTouchEvent(); break; + case Messages::ButtonPushed: + currentScreen->OnButtonPushed(); } } } @@ -120,10 +122,26 @@ void DisplayApp::Refresh() { bool first = true; void DisplayApp::RunningState() { - clockScreen.SetCurrentDateTime(dateTimeController.CurrentDateTime()); +// clockScreen.SetCurrentDateTime(dateTimeController.CurrentDateTime()); if(currentScreen != nullptr) { currentScreen->Refresh(first); + if(currentScreen->GetNextScreen() != Screens::Screen::NextScreen::None) { + switch(currentScreen->GetNextScreen()) { + case Screens::Screen::NextScreen::Clock: + currentScreen.reset(nullptr); + currentScreen.reset(new Screens::Clock(this, gfx, dateTimeController)); + break; + case Screens::Screen::NextScreen::Menu: + currentScreen.reset(nullptr); + currentScreen.reset(new Screens::Tile(this, gfx)); + break; + case Screens::Screen::NextScreen::App: + currentScreen.reset(nullptr); + currentScreen.reset(new Screens::Message(this, gfx)); + break; + } + } first = false; } } @@ -144,10 +162,10 @@ void DisplayApp::PushMessage(DisplayApp::Messages msg) { static uint16_t pointColor = 0x07e0; void DisplayApp::OnTouchEvent() { - auto info = touchPanel.GetTouchInfo(); - - if(info.isTouch) { - gfx.FillRectangle(info.x-10, info.y-10, 20,20, pointColor); - pointColor+=10; - } +// auto info = touchPanel.GetTouchInfo(); +// +// if(info.isTouch) { +// gfx.FillRectangle(info.x-10, info.y-10, 20,20, pointColor); +// pointColor+=10; +// } } diff --git a/src/DisplayApp/DisplayApp.h b/src/DisplayApp/DisplayApp.h index 8cd26ce8..f8101536 100644 --- a/src/DisplayApp/DisplayApp.h +++ b/src/DisplayApp/DisplayApp.h @@ -23,7 +23,7 @@ namespace Pinetime { class DisplayApp { public: enum class States {Idle, Running}; - enum class Messages : uint8_t {GoToSleep, GoToRunning, UpdateDateTime, UpdateBleConnection, UpdateBatteryLevel, TouchEvent} ; + enum class Messages : uint8_t {GoToSleep, GoToRunning, UpdateDateTime, UpdateBleConnection, UpdateBatteryLevel, TouchEvent, SwitchScreen,ButtonPushed} ; DisplayApp(Pinetime::Drivers::St7789& lcd, Pinetime::Components::Gfx& gfx, Pinetime::Components::LittleVgl& lvgl, @@ -60,12 +60,12 @@ namespace Pinetime { Pinetime::Drivers::Cst816S& touchPanel; void OnTouchEvent(); - Screens::Clock clockScreen; - Screens::Message messageScreen; - Screens::Screen* currentScreen = nullptr; + std::unique_ptr currentScreen; static constexpr uint8_t pinLcdBacklight1 = 14; static constexpr uint8_t pinLcdBacklight2 = 22; static constexpr uint8_t pinLcdBacklight3 = 23; + + bool isClock = true; }; } } diff --git a/src/DisplayApp/LittleVgl.cpp b/src/DisplayApp/LittleVgl.cpp index 7830953a..50744acc 100644 --- a/src/DisplayApp/LittleVgl.cpp +++ b/src/DisplayApp/LittleVgl.cpp @@ -17,8 +17,18 @@ static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_colo lvgl->FlushDisplay(area, color_p); } -LittleVgl::LittleVgl(Pinetime::Drivers::St7789& lcd) : lcd{lcd} { +bool touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) { + auto* lvgl = static_cast(indev_drv->user_data); + return lvgl->GetTouchPadInfo(data); +} + +LittleVgl::LittleVgl(Pinetime::Drivers::St7789& lcd, Pinetime::Drivers::Cst816S& touchPanel) : lcd{lcd}, touchPanel{touchPanel} { lv_init(); + InitDisplay(); + InitTouchpad(); +} + +void LittleVgl::InitDisplay() { lv_theme_t* theme = lv_theme_night_init(10, NULL); lv_theme_set_current(theme); @@ -39,8 +49,16 @@ LittleVgl::LittleVgl(Pinetime::Drivers::St7789& lcd) : lcd{lcd} { /*Finally register the driver*/ lv_disp_drv_register(&disp_drv); +} +void LittleVgl::InitTouchpad() { + lv_indev_drv_t indev_drv; + lv_indev_drv_init(&indev_drv); + indev_drv.type = LV_INDEV_TYPE_POINTER; + indev_drv.read_cb = touchpad_read; + indev_drv.user_data = this; + lv_indev_drv_register(&indev_drv); } void LittleVgl::FlushDisplay(const lv_area_t *area, lv_color_t *color_p) { @@ -57,3 +75,21 @@ void LittleVgl::FlushDisplay(const lv_area_t *area, lv_color_t *color_p) { * Inform the graphics library that you are ready with the flushing*/ lv_disp_flush_ready(&disp_drv); } + +bool LittleVgl::GetTouchPadInfo(lv_indev_data_t *ptr) { + auto info = touchPanel.GetTouchInfo(); + + if((previousClick.x != info.x || previousClick.y != info.y) && + (info.gesture == Drivers::Cst816S::Gestures::SingleTap)) { + ptr->state = LV_INDEV_STATE_PR; + previousClick.x = ptr->point.x; + previousClick.y = ptr->point.y; + } + else { + ptr->state = LV_INDEV_STATE_REL; + } + + ptr->point.x = info.x; + ptr->point.y = info.y; + return false; +} diff --git a/src/DisplayApp/LittleVgl.h b/src/DisplayApp/LittleVgl.h index cff1c3b1..ef104969 100644 --- a/src/DisplayApp/LittleVgl.h +++ b/src/DisplayApp/LittleVgl.h @@ -2,26 +2,36 @@ #include #include +#include static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p); +static bool touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data); namespace Pinetime { namespace Components { class LittleVgl { public: - LittleVgl(Pinetime::Drivers::St7789& lcd); + LittleVgl(Pinetime::Drivers::St7789& lcd, Pinetime::Drivers::Cst816S& touchPanel); void FlushDisplay(const lv_area_t * area, lv_color_t * color_p); + bool GetTouchPadInfo(lv_indev_data_t *ptr); private: + void InitDisplay(); + void InitTouchpad(); + Pinetime::Drivers::St7789& lcd; + Pinetime::Drivers::Cst816S& touchPanel; + lv_disp_buf_t disp_buf_2; lv_color_t buf2_1[LV_HOR_RES_MAX * 2]; lv_color_t buf2_2[LV_HOR_RES_MAX * 2]; lv_disp_drv_t disp_drv; + lv_point_t previousClick; + }; } diff --git a/src/DisplayApp/Screens/Clock.cpp b/src/DisplayApp/Screens/Clock.cpp index a413476a..8513d3ed 100644 --- a/src/DisplayApp/Screens/Clock.cpp +++ b/src/DisplayApp/Screens/Clock.cpp @@ -4,12 +4,24 @@ #include #include #include "Clock.h" +#include "../DisplayApp.h" using namespace Pinetime::Applications::Screens; extern lv_font_t jetbrains_mono_extrabold_compressedextrabold_compressed; extern lv_font_t jetbrains_mono_bold_20; -Clock::Clock(Pinetime::Components::Gfx &gfx) : Screen(gfx), currentDateTime{{}}, version {{}} { +static void event_handler(lv_obj_t * obj, lv_event_t event) { + Clock* screen = static_cast(obj->user_data); + screen->OnObjectEvent(obj, event); +} + +Clock::Clock(DisplayApp* app, Pinetime::Components::Gfx &gfx, Controllers::DateTime& dateTimeController) : Screen(app, gfx), currentDateTime{{}}, version {{}}, dateTimeController{dateTimeController} { + displayedChar[0] = 0; + displayedChar[1] = 0; + displayedChar[2] = 0; + displayedChar[3] = 0; + displayedChar[4] = 0; + label_battery = lv_label_create(lv_scr_act(), NULL); lv_obj_align(label_battery, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, -80, 0); @@ -38,11 +50,24 @@ Clock::Clock(Pinetime::Components::Gfx &gfx) : Screen(gfx), currentDateTime{{}}, lv_label_set_style(label_version, LV_LABEL_STYLE_MAIN, labelStyle); lv_obj_align(label_version, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 100); + backgroundLabel = lv_label_create(lv_scr_act(), NULL); + backgroundLabel->user_data = this; + lv_label_set_style(backgroundLabel, LV_LABEL_STYLE_MAIN, labelStyle); + lv_obj_set_click(backgroundLabel, true); + lv_obj_set_event_cb(backgroundLabel, event_handler); + 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, ""); +} + +Clock::~Clock() { + lv_obj_clean(lv_scr_act()); } void Clock::Refresh(bool fullRefresh) { if(fullRefresh) { - auto dummy = currentDateTime.Get(); + auto currentDateTime = dateTimeController.CurrentDateTime(); } if (fullRefresh || batteryPercentRemaining.IsUpdated()) { @@ -62,6 +87,8 @@ void Clock::Refresh(bool fullRefresh) { // TODO color } + currentDateTime = dateTimeController.CurrentDateTime(); + if(fullRefresh || currentDateTime.IsUpdated()) { auto newDateTime = currentDateTime.Get(); @@ -86,10 +113,17 @@ void Clock::Refresh(bool fullRefresh) { char timeStr[6]; sprintf(timeStr, "%c%c:%c%c", hoursChar[0],hoursChar[1],minutesChar[0], minutesChar[1]); - lv_label_set_text(label_time, timeStr); + + if(hoursChar[0] != displayedChar[0] || hoursChar[1] != displayedChar[1] || minutesChar[0] != displayedChar[2] || minutesChar[1] != displayedChar[3]) { + displayedChar[0] = hoursChar[0]; + displayedChar[1] = hoursChar[1]; + displayedChar[2] = minutesChar[0]; + displayedChar[3] = minutesChar[1]; + + lv_label_set_text(label_time, timeStr); + } if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) { - gfx.FillRectangle(0,180, 240, 15, 0x0000); char dateStr[22]; sprintf(dateStr, "%s %d %s %d", DayOfWeekToString(dayOfWeek), day, MonthToString(month), year); lv_label_set_text(label_date, dateStr); @@ -103,9 +137,10 @@ void Clock::Refresh(bool fullRefresh) { } if(fullRefresh || version.IsUpdated()) { - char version[20]; - sprintf(version, "VERSION: %d.%d.%d", Version::Major(), Version::Minor(), Version::Patch()); - lv_label_set_text(label_version, version); + auto dummy = version.Get(); + char versionStr[20]; + sprintf(versionStr, "VERSION: %d.%d.%d", Version::Major(), Version::Minor(), Version::Patch()); + lv_label_set_text(label_version, versionStr); } } @@ -145,4 +180,12 @@ char const *Clock::MonthsString[] = { "DEC" }; +void Clock::OnObjectEvent(lv_obj_t *obj, lv_event_t event) { + if(obj == backgroundLabel) { + if (event == LV_EVENT_CLICKED) { + nextScreen = NextScreen::Menu; + } + } +} + diff --git a/src/DisplayApp/Screens/Clock.h b/src/DisplayApp/Screens/Clock.h index f5328535..d6e5a288 100644 --- a/src/DisplayApp/Screens/Clock.h +++ b/src/DisplayApp/Screens/Clock.h @@ -21,7 +21,7 @@ namespace Pinetime { explicit DirtyValue(T v) { value = v; } explicit DirtyValue(T& v) { value = v; } bool IsUpdated() const { return isUpdated; } - T& Get() { return value; this->isUpdated = false;} + T& Get() { this->isUpdated = false; return value; } DirtyValue& operator=(const T& other) { this->value = other; @@ -35,19 +35,23 @@ namespace Pinetime { class Clock : public Screen{ public: enum class BleConnectionStates{ NotConnected, Connected}; - Clock(Components::Gfx& gfx); + Clock(DisplayApp* app, Components::Gfx& gfx, Controllers::DateTime& dateTimeController); + ~Clock() override; void Refresh(bool fullRefresh) override; void SetBatteryPercentRemaining(uint8_t percent) { batteryPercentRemaining = percent; } void SetBleConnectionState(BleConnectionStates state) { bleState = state; } void SetCurrentDateTime(const std::chrono::time_point& tp) { currentDateTime = tp;} + 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]; + const FONT_INFO largeFont {lCD_70ptFontInfo.height, lCD_70ptFontInfo.startChar, lCD_70ptFontInfo.endChar, lCD_70ptFontInfo.spacePixels, lCD_70ptFontInfo.charInfo, lCD_70ptFontInfo.data}; const FONT_INFO smallFont {lCD_14ptFontInfo.height, lCD_14ptFontInfo.startChar, lCD_14ptFontInfo.endChar, lCD_14ptFontInfo.spacePixels, lCD_14ptFontInfo.charInfo, lCD_14ptFontInfo.data}; @@ -69,6 +73,9 @@ namespace Pinetime { lv_obj_t* label_time; lv_obj_t* label_date; lv_obj_t* label_version; + lv_obj_t* backgroundLabel; + + Controllers::DateTime& dateTimeController; }; } diff --git a/src/DisplayApp/Screens/Message.cpp b/src/DisplayApp/Screens/Message.cpp index 8ffad413..c9e0938f 100644 --- a/src/DisplayApp/Screens/Message.cpp +++ b/src/DisplayApp/Screens/Message.cpp @@ -5,24 +5,77 @@ #include #include #include +#include #include "Message.h" +#include + using namespace Pinetime::Applications::Screens; -extern lv_font_t jetbrains_mono_extrabold_compressedextrabold_compressed; +extern lv_font_t jetbrains_mono_bold_20; + +static void event_handler(lv_obj_t * obj, lv_event_t event) { + Message* screen = static_cast(obj->user_data); + screen->OnObjectEvent(obj, event); +} + +Message::Message(DisplayApp* app, Pinetime::Components::Gfx &gfx) : Screen(app, gfx) { + + backgroundLabel = lv_label_create(lv_scr_act(), NULL); + backgroundLabel->user_data = this; + + labelStyle = const_cast(lv_label_get_style(backgroundLabel, LV_LABEL_STYLE_MAIN)); + labelStyle->text.font = &jetbrains_mono_bold_20; + + lv_label_set_style(backgroundLabel, LV_LABEL_STYLE_MAIN, labelStyle); + lv_obj_set_click(backgroundLabel, true); + lv_obj_set_event_cb(backgroundLabel, event_handler); + 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, ""); +// lv_obj_align(backgroundLabel, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0); + + button = lv_btn_create(lv_scr_act(), NULL); + lv_obj_set_event_cb(button, event_handler); + lv_obj_align(button, NULL, LV_ALIGN_CENTER, 0, -40); + button->user_data = this; + + label = lv_label_create(button, NULL); + lv_label_set_style(label, LV_LABEL_STYLE_MAIN, labelStyle); + lv_label_set_text(label, "Hello!"); + + labelClick = lv_label_create(lv_scr_act(), NULL); + lv_label_set_style(labelClick, LV_LABEL_STYLE_MAIN, labelStyle); + lv_obj_align(labelClick, button, LV_ALIGN_OUT_BOTTOM_MID, 0, 30); + lv_label_set_text(labelClick, "0"); +} + +Message::~Message() { + lv_obj_clean(lv_scr_act()); +} -lv_obj_t * label; -int x = 0; void Message::Refresh(bool fullRefresh) { - if(fullRefresh) { - label = lv_label_create(lv_scr_act(), NULL); /*Add a label to the button*/ - labelStyle = const_cast(lv_label_get_style(label, LV_LABEL_STYLE_MAIN)); - labelStyle->text.font = &jetbrains_mono_extrabold_compressedextrabold_compressed; - lv_label_set_style(label, LV_LABEL_STYLE_MAIN, labelStyle); - lv_label_set_text(label, "01:23"); /*Set the labels text*/ - } else { - lv_obj_set_pos(label, 0, x++); - if(x > 200) x = 0; + if(previousClickCount != clickCount) { + lv_label_set_text_fmt(labelClick, "%d", clickCount); + previousClickCount = clickCount; } +} +void Message::OnObjectEvent(lv_obj_t *obj, lv_event_t event) { + if(obj == backgroundLabel) { + if(event == LV_EVENT_CLICKED) { + app->PushMessage(DisplayApp::Messages::SwitchScreen); + NRF_LOG_INFO("SCREEN"); + } + return ; + } + + if(event == LV_EVENT_CLICKED) { + NRF_LOG_INFO("Clicked"); + clickCount++; + } + else if(event == LV_EVENT_VALUE_CHANGED) { + NRF_LOG_INFO("Toggled"); + } } diff --git a/src/DisplayApp/Screens/Message.h b/src/DisplayApp/Screens/Message.h index 419c2e62..2f1da942 100644 --- a/src/DisplayApp/Screens/Message.h +++ b/src/DisplayApp/Screens/Message.h @@ -15,14 +15,24 @@ namespace Pinetime { namespace Screens { class Message : public Screen{ public: - Message(Components::Gfx& gfx) : Screen(gfx) {} + explicit Message(DisplayApp* app, Components::Gfx& gfx); + ~Message() override; void Refresh(bool fullRefresh) override; + void OnObjectEvent(lv_obj_t* obj, lv_event_t event); + void OnButtonPushed() override { nextScreen = Screen::NextScreen::Menu; } private: const FONT_INFO largeFont {lCD_70ptFontInfo.height, lCD_70ptFontInfo.startChar, lCD_70ptFontInfo.endChar, lCD_70ptFontInfo.spacePixels, lCD_70ptFontInfo.charInfo, lCD_70ptFontInfo.data}; const FONT_INFO smallFont {lCD_14ptFontInfo.height, lCD_14ptFontInfo.startChar, lCD_14ptFontInfo.endChar, lCD_14ptFontInfo.spacePixels, lCD_14ptFontInfo.charInfo, lCD_14ptFontInfo.data}; lv_style_t* labelStyle; + lv_obj_t * label; + lv_obj_t* backgroundLabel; + lv_obj_t * button; + lv_obj_t * labelClick; + + uint32_t clickCount = 0 ; + uint32_t previousClickCount = 0; }; } } diff --git a/src/DisplayApp/Screens/Screen.h b/src/DisplayApp/Screens/Screen.h index 5e2fa43e..57b8ea2a 100644 --- a/src/DisplayApp/Screens/Screen.h +++ b/src/DisplayApp/Screens/Screen.h @@ -4,14 +4,21 @@ namespace Pinetime { namespace Applications { + class DisplayApp; namespace Screens { class Screen { public: - Screen(Components::Gfx& gfx) : gfx{gfx} {} + enum class NextScreen {None, Clock, Menu, App}; + Screen(DisplayApp* app, Components::Gfx& gfx) : app{app}, gfx{gfx} {} + virtual ~Screen() = default; virtual void Refresh(bool fullRefresh) = 0; + NextScreen GetNextScreen() {return nextScreen;} + virtual void OnButtonPushed() {}; protected: + DisplayApp* app; Components::Gfx& gfx; + NextScreen nextScreen = NextScreen::None; }; } } diff --git a/src/DisplayApp/Screens/Tab.cpp b/src/DisplayApp/Screens/Tab.cpp new file mode 100644 index 00000000..adc32578 --- /dev/null +++ b/src/DisplayApp/Screens/Tab.cpp @@ -0,0 +1,67 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include "Tab.h" +#include + + +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(obj->user_data); +// screen->OnObjectEvent(obj, event); +//} + +Tab::Tab(DisplayApp* app, Pinetime::Components::Gfx &gfx) : Screen(app, gfx) { +/*Create a Tab view object*/ + lv_obj_t *tabview; + tabview = lv_tabview_create(lv_scr_act(), NULL); + + /*Add 3 tabs (the tabs are page (lv_page) and can be scrolled*/ + lv_obj_t *tab1 = lv_tabview_add_tab(tabview, "Tab 1"); + lv_obj_t *tab2 = lv_tabview_add_tab(tabview, "Tab 2"); + lv_obj_t *tab3 = lv_tabview_add_tab(tabview, "Tab 3"); + + + /*Add content to the tabs*/ + lv_obj_t * label = lv_label_create(tab1, NULL); + lv_label_set_text(label, "This the first tab\n\n" + "If the content\n" + "of a tab\n" + "become too long\n" + "the it \n" + "automatically\n" + "become\n" + "scrollable."); + + label = lv_label_create(tab2, NULL); + lv_label_set_text(label, "Second tab"); + + label = lv_label_create(tab3, NULL); + lv_label_set_text(label, "Third tab"); + +} + +Tab::~Tab() { + lv_obj_clean(lv_scr_act()); +} + +void Tab::Refresh(bool fullRefresh) { + +} + +void Tab::OnObjectEvent(lv_obj_t *obj, lv_event_t event) { + if(event == LV_EVENT_CLICKED) { + NRF_LOG_INFO("Clicked"); + } + else if(event == LV_EVENT_VALUE_CHANGED) { + NRF_LOG_INFO("Toggled"); + } +} diff --git a/src/DisplayApp/Screens/Tab.h b/src/DisplayApp/Screens/Tab.h new file mode 100644 index 00000000..1af956f4 --- /dev/null +++ b/src/DisplayApp/Screens/Tab.h @@ -0,0 +1,28 @@ +#pragma once + +#include +#include +#include +#include "Screen.h" +#include +#include "../Fonts/lcdfont14.h" +#include "../Fonts/lcdfont70.h" +#include "../../Version.h" +#include + +namespace Pinetime { + namespace Applications { + namespace Screens { + class Tab : public Screen { + public: + explicit Tab(DisplayApp* app, Components::Gfx& gfx); + ~Tab() override; + void Refresh(bool fullRefresh) override; + void OnObjectEvent(lv_obj_t* obj, lv_event_t event); + + private: + + }; + } + } +} diff --git a/src/DisplayApp/Screens/Tile.cpp b/src/DisplayApp/Screens/Tile.cpp new file mode 100644 index 00000000..d89562c7 --- /dev/null +++ b/src/DisplayApp/Screens/Tile.cpp @@ -0,0 +1,118 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include "Tile.h" +#include +#include + + +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(obj->user_data); + screen->OnObjectEvent(obj, event); +} + +//static const char * btnm_map1[] = {"App1", "App2", "App3", "\n", "App4", "App5", "App11", ""}; +//static const char * btnm_map2[] = {"App6", "App7", "App8", "\n", "App9", "App10", "App22",""}; +static const char * btnm_map1[] = {"App1", ""}; + +Tile::Tile(DisplayApp* app, Pinetime::Components::Gfx &gfx) : Screen(app, gfx) { + + static lv_point_t valid_pos[] = {{0,0}, {LV_COORD_MIN, LV_COORD_MIN}}; + tileview = lv_tileview_create(lv_scr_act(), NULL); + lv_tileview_set_valid_positions(tileview, valid_pos, 1); + lv_tileview_set_edge_flash(tileview, false); + + tile1 = lv_obj_create(tileview, NULL); + lv_obj_set_pos(tile1, 0, 0); + lv_obj_set_size(tile1, LV_HOR_RES, LV_VER_RES); + lv_tileview_add_element(tileview, tile1); + + btnm1 = lv_btnm_create(tile1, NULL); + lv_btnm_set_map(btnm1, btnm_map1); + lv_obj_set_size(btnm1, LV_HOR_RES, LV_VER_RES); + + labelStyle = const_cast(lv_label_get_style(btnm1, LV_BTNM_STYLE_BTN_REL)); + labelStyle->text.font = &jetbrains_mono_bold_20; + labelStyle->body.grad_color = labelStyle->body.main_color; + lv_btnm_set_style(btnm1, LV_BTNM_STYLE_BTN_REL, labelStyle); + lv_btnm_set_style(btnm1, LV_BTNM_STYLE_BTN_PR, labelStyle); + + lv_obj_align(btnm1, tile1, LV_ALIGN_CENTER, 0, 0); + btnm1->user_data = this; + lv_obj_set_event_cb(btnm1, event_handler); +/* + tile2 = lv_obj_create(tileview, NULL); + lv_obj_set_pos(tile2, 0, LV_VER_RES); + lv_obj_set_size(tile2, LV_HOR_RES, LV_VER_RES); + lv_tileview_add_element(tileview, tile2); + + btnm2 = lv_btnm_create(tileview, NULL); + lv_btnm_set_map(btnm2, btnm_map2); + lv_obj_align(btnm2, tile2, LV_ALIGN_CENTER, 0, 0); +*/ +/* + tile1 = lv_obj_create(tileview, NULL); + lv_obj_set_pos(tile1, 0, 0); + lv_obj_set_size(tile1, LV_HOR_RES, LV_VER_RES); + lv_tileview_add_element(tileview, tile1); + + btn1 = lv_btn_create(tile1, NULL); + lv_obj_align(btn1, tile1, LV_ALIGN_CENTER, 0, 0); + + label1 = lv_label_create(btn1, NULL); + lv_label_set_text(label1, "Button1"); +*/ +/* + tile2 = lv_obj_create(tileview, NULL); + lv_obj_set_pos(tile2, 0, LV_VER_RES); + lv_obj_set_size(tile2, LV_HOR_RES, LV_VER_RES); + lv_tileview_add_element(tileview, tile2); + + btn2 = lv_btn_create(tile2, NULL); + lv_obj_align(btn2, tile2, LV_ALIGN_CENTER, 0, 0); + + + label2 = lv_label_create(btn2, NULL); + lv_label_set_text(label2, "Button2"); + + tile3 = lv_obj_create(tileview, NULL); + lv_obj_set_pos(tile3, 0, LV_VER_RES*2); + lv_obj_set_size(tile3, LV_HOR_RES, LV_VER_RES); + lv_tileview_add_element(tileview, tile3); + + btn3 = lv_btn_create(tile3, NULL); + lv_obj_align(btn3, tile3, LV_ALIGN_CENTER, 0, 0); + + + label3 = lv_label_create(btn3, NULL); + lv_label_set_text(label3, "Button3"); +*/ +} + +Tile::~Tile() { + lv_obj_clean(lv_scr_act()); +} + +void Tile::Refresh(bool fullRefresh) { + +} + +void Tile::OnObjectEvent(lv_obj_t *obj, lv_event_t event) { + if(event == LV_EVENT_CLICKED) { + NRF_LOG_INFO("Clicked"); + nextScreen = Screen::NextScreen::App; + clickCount++; + } + else if(event == LV_EVENT_VALUE_CHANGED) { + NRF_LOG_INFO("Toggled"); + } +} diff --git a/src/DisplayApp/Screens/Tile.h b/src/DisplayApp/Screens/Tile.h new file mode 100644 index 00000000..c9de2c5c --- /dev/null +++ b/src/DisplayApp/Screens/Tile.h @@ -0,0 +1,56 @@ +#pragma once + +#include +#include +#include +#include "Screen.h" +#include +#include "../Fonts/lcdfont14.h" +#include "../Fonts/lcdfont70.h" +#include "../../Version.h" +#include + +namespace Pinetime { + namespace Applications { + namespace Screens { + class Tile : public Screen { + public: + explicit Tile(DisplayApp* app, Components::Gfx& gfx); + ~Tile() override; + void Refresh(bool fullRefresh) override; + void OnObjectEvent(lv_obj_t* obj, lv_event_t event); + + void OnButtonPushed() override {nextScreen = NextScreen::Clock;} + + private: + const FONT_INFO largeFont {lCD_70ptFontInfo.height, lCD_70ptFontInfo.startChar, lCD_70ptFontInfo.endChar, lCD_70ptFontInfo.spacePixels, lCD_70ptFontInfo.charInfo, lCD_70ptFontInfo.data}; + const FONT_INFO smallFont {lCD_14ptFontInfo.height, lCD_14ptFontInfo.startChar, lCD_14ptFontInfo.endChar, lCD_14ptFontInfo.spacePixels, lCD_14ptFontInfo.charInfo, lCD_14ptFontInfo.data}; + + lv_style_t* labelStyle; + lv_obj_t * label1; + lv_obj_t * label2; + lv_obj_t * label3; + + lv_obj_t* backgroundLabel; + lv_obj_t * button; + lv_obj_t * labelClick; + + lv_obj_t *tileview; + lv_obj_t * tile1; + lv_obj_t * tile2; + lv_obj_t * list; + lv_obj_t * list_btn; + lv_obj_t * tile3; + lv_obj_t * btn1; + lv_obj_t * btn2; + lv_obj_t * btn3; + + lv_obj_t * btnm1; + lv_obj_t * btnm2; + + uint32_t clickCount = 0 ; + uint32_t previousClickCount = 0; + }; + } + } +} diff --git a/src/drivers/Cst816s.cpp b/src/drivers/Cst816s.cpp index b1af12d4..61bce94c 100644 --- a/src/drivers/Cst816s.cpp +++ b/src/drivers/Cst816s.cpp @@ -78,26 +78,26 @@ Cst816S::TouchInfos Cst816S::GetTouchInfo() { info.action = action; info.gesture = static_cast(touchData[gestureIndex]); - NRF_LOG_INFO("---------------") - NRF_LOG_INFO("ID : %d", pointId); - NRF_LOG_INFO("NB : %d", nbTouchPoints); - NRF_LOG_INFO("X/Y :%d / %d", info.x, info.y); - NRF_LOG_INFO("Action : %d", action); - NRF_LOG_INFO("Finger : %d", finger); - NRF_LOG_INFO("Pressure : %d", pressure); - NRF_LOG_INFO("area : %d", area); - NRF_LOG_INFO("Touch : %s", info.isTouch?"Yes" : "No"); - switch(info.gesture) {// gesture - case Gestures::None: NRF_LOG_INFO("Gesture : None"); break; - case Gestures::SlideDown: NRF_LOG_INFO("Gesture : Slide Down"); break; - case Gestures::SlideUp: NRF_LOG_INFO("Gesture : Slide Up"); break; - case Gestures::SlideLeft: NRF_LOG_INFO("Gesture : Slide Left"); break; - case Gestures::SlideRight: NRF_LOG_INFO("Gesture : Slide Right"); break; - case Gestures::SingleTap: NRF_LOG_INFO("Gesture : Single click"); break; - case Gestures::DoubleTap: NRF_LOG_INFO("Gesture : Double click"); break; - case Gestures::LongPress: NRF_LOG_INFO("Gesture : Long press"); break; - default : NRF_LOG_INFO("Unknown"); break; - } +// NRF_LOG_INFO("---------------") +// NRF_LOG_INFO("ID : %d", pointId); +// NRF_LOG_INFO("NB : %d", nbTouchPoints); +// NRF_LOG_INFO("X/Y :%d / %d", info.x, info.y); +// NRF_LOG_INFO("Action : %d", action); +// NRF_LOG_INFO("Finger : %d", finger); +// NRF_LOG_INFO("Pressure : %d", pressure); +// NRF_LOG_INFO("area : %d", area); +// NRF_LOG_INFO("Touch : %s", info.isTouch?"Yes" : "No"); +// switch(info.gesture) {// gesture +// case Gestures::None: NRF_LOG_INFO("Gesture : None"); break; +// case Gestures::SlideDown: NRF_LOG_INFO("Gesture : Slide Down"); break; +// case Gestures::SlideUp: NRF_LOG_INFO("Gesture : Slide Up"); break; +// case Gestures::SlideLeft: NRF_LOG_INFO("Gesture : Slide Left"); break; +// case Gestures::SlideRight: NRF_LOG_INFO("Gesture : Slide Right"); break; +// case Gestures::SingleTap: NRF_LOG_INFO("Gesture : Single click"); break; +// case Gestures::DoubleTap: NRF_LOG_INFO("Gesture : Double click"); break; +// case Gestures::LongPress: NRF_LOG_INFO("Gesture : Long press"); break; +// default : NRF_LOG_INFO("Unknown"); break; +// } } diff --git a/src/libs/lv_conf.h b/src/libs/lv_conf.h index 603339ee..8d7a6f7e 100644 --- a/src/libs/lv_conf.h +++ b/src/libs/lv_conf.h @@ -563,7 +563,7 @@ typedef void * lv_obj_user_data_t; #define LV_USE_TILEVIEW 1 #if LV_USE_TILEVIEW /*Time of slide animation [ms] (0: no animation)*/ -# define LV_TILEVIEW_DEF_ANIM_TIME 300 +# define LV_TILEVIEW_DEF_ANIM_TIME 0 #endif /*Window (dependencies: lv_cont, lv_btn, lv_label, lv_img, lv_page)*/ diff --git a/src/main.cpp b/src/main.cpp index 0d374c6b..2a272677 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -82,7 +82,7 @@ extern "C" { void DebounceTimerCallback(TimerHandle_t xTimer) { xTimerStop(xTimer, 0); - if(isSleeping) { + /*if(isSleeping) { SystemTask_PushMessage(SystemTaskMessages::GoToRunning); displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::GoToRunning); isSleeping = false; @@ -93,7 +93,8 @@ void DebounceTimerCallback(TimerHandle_t xTimer) { SystemTask_PushMessage(SystemTaskMessages::GoToSleep); displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::GoToSleep); isSleeping = true; - } + }*/ + displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::ButtonPushed); } void SystemTask_PushMessage(SystemTaskMessages message) { @@ -126,8 +127,9 @@ void SystemTask(void *) { lcd.reset(new Pinetime::Drivers::St7789(*spi, pinLcdDataCommand)); gfx.reset(new Pinetime::Components::Gfx(*lcd)); - lvgl.reset(new Pinetime::Components::LittleVgl(*lcd)); touchPanel.reset(new Pinetime::Drivers::Cst816S()); + + lvgl.reset(new Pinetime::Components::LittleVgl(*lcd, *touchPanel)); ptrLcd = lcd.get(); spi->Init(); -- cgit v1.2.3-70-g09d2 From 2bdff7ed2b490cb8ce5599341e12d707c0ba7fd0 Mon Sep 17 00:00:00 2001 From: JF Date: Thu, 20 Feb 2020 18:17:53 +0100 Subject: Re-enable BLE display on Clock screen --- src/DisplayApp/DisplayApp.cpp | 2 +- src/DisplayApp/Screens/Clock.cpp | 10 ++++++---- src/DisplayApp/Screens/Tile.cpp | 4 +--- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/DisplayApp/DisplayApp.cpp') diff --git a/src/DisplayApp/DisplayApp.cpp b/src/DisplayApp/DisplayApp.cpp index 959c84a0..34d81ddc 100644 --- a/src/DisplayApp/DisplayApp.cpp +++ b/src/DisplayApp/DisplayApp.cpp @@ -31,7 +31,7 @@ DisplayApp::DisplayApp(Pinetime::Drivers::St7789& lcd, batteryController{batteryController}, bleController{bleController}, dateTimeController{dateTimeController}, - currentScreen{new Screens::Tile(this, gfx) } { + currentScreen{new Screens::Clock(this, gfx, dateTimeController) } { msgQueue = xQueueCreate(queueSize, itemSize); } diff --git a/src/DisplayApp/Screens/Clock.cpp b/src/DisplayApp/Screens/Clock.cpp index 8513d3ed..806a1c2c 100644 --- a/src/DisplayApp/Screens/Clock.cpp +++ b/src/DisplayApp/Screens/Clock.cpp @@ -81,10 +81,12 @@ void Clock::Refresh(bool fullRefresh) { } if (fullRefresh || bleState.IsUpdated()) { - uint16_t color = (bleState.Get() == BleConnectionStates::Connected) ? 0xffff : 0x0000; - gfx.DrawString(10, 0, color, "BLE", &smallFont, false); - lv_label_set_text(label_ble, "BLE"); - // TODO color + if(bleState.Get() == BleConnectionStates::Connected) { + lv_obj_set_hidden(label_ble, false); + lv_label_set_text(label_ble, "BLE"); + } else { + lv_obj_set_hidden(label_ble, true); + } } currentDateTime = dateTimeController.CurrentDateTime(); diff --git a/src/DisplayApp/Screens/Tile.cpp b/src/DisplayApp/Screens/Tile.cpp index d89562c7..ac930ba7 100644 --- a/src/DisplayApp/Screens/Tile.cpp +++ b/src/DisplayApp/Screens/Tile.cpp @@ -20,9 +20,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { screen->OnObjectEvent(obj, event); } -//static const char * btnm_map1[] = {"App1", "App2", "App3", "\n", "App4", "App5", "App11", ""}; -//static const char * btnm_map2[] = {"App6", "App7", "App8", "\n", "App9", "App10", "App22",""}; -static const char * btnm_map1[] = {"App1", ""}; +static const char * btnm_map1[] = {"App1", "App2", "App3", "\n", "App4", "App5", "App11", ""}; Tile::Tile(DisplayApp* app, Pinetime::Components::Gfx &gfx) : Screen(app, gfx) { -- cgit v1.2.3-70-g09d2 From 02772b996fb26146cf38fc6deccff7f43a49dfd6 Mon Sep 17 00:00:00 2001 From: JF Date: Sun, 23 Feb 2020 13:44:39 +0100 Subject: Do not compile GFX and older fonts anymore. Refactor SystemTask in its own class. Refactor Screen to be able to close current screen and open a new one. Re-enable sleep/wake up and propagate button event to Screens. --- src/CMakeLists.txt | 19 +++-- src/DisplayApp/DisplayApp.cpp | 51 +++++++------- src/DisplayApp/DisplayApp.h | 19 +++-- src/DisplayApp/Screens/Clock.cpp | 12 +++- src/DisplayApp/Screens/Clock.h | 11 +-- src/DisplayApp/Screens/Screen.h | 14 ++-- src/DisplayApp/Screens/Tile.cpp | 39 +++++++---- src/DisplayApp/Screens/Tile.h | 16 +++-- src/SystemTask/SystemTask.cpp | 115 ++++++++++++++++++++++++++++++ src/SystemTask/SystemTask.h | 60 ++++++++++++++++ src/libs/lv_conf.h | 4 +- src/main.cpp | 146 +++++++-------------------------------- src/main.h | 7 ++ 13 files changed, 313 insertions(+), 200 deletions(-) create mode 100644 src/SystemTask/SystemTask.cpp create mode 100644 src/SystemTask/SystemTask.h create mode 100644 src/main.h (limited to 'src/DisplayApp/DisplayApp.cpp') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a5971f27..efbb3861 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -156,17 +156,15 @@ list(APPEND SOURCE_FILES Logging/NrfLogger.cpp BlinkApp/BlinkApp.cpp DisplayApp/DisplayApp.cpp - DisplayApp/Fonts/lcdfont70.c - DisplayApp/Fonts/lcdfont14.c DisplayApp/Screens/Screen.cpp DisplayApp/Screens/Clock.cpp - DisplayApp/Screens/Message.cpp +# DisplayApp/Screens/Message.cpp DisplayApp/Screens/Tile.cpp - DisplayApp/Screens/Tab.cpp +# DisplayApp/Screens/Tab.cpp main.cpp drivers/St7789.cpp drivers/SpiMaster.cpp - Components/Gfx/Gfx.cpp +# Components/Gfx/Gfx.cpp BLE/BleManager.c Components/Battery/BatteryController.cpp Components/Ble/BleController.cpp @@ -180,6 +178,8 @@ list(APPEND SOURCE_FILES DisplayApp/LittleVgl.cpp DisplayApp/Fonts/jetbrains_mono_extrabold_compressed.c DisplayApp/Fonts/jetbrains_mono_bold_20.c + + SystemTask/SystemTask.cpp ) set(INCLUDE_FILES @@ -187,16 +187,13 @@ set(INCLUDE_FILES Logging/NrfLogger.h BlinkApp/BlinkApp.h DisplayApp/DisplayApp.h - DisplayApp/Fonts/lcdfont70.h - DisplayApp/Fonts/lcdfont14.h DisplayApp/Screens/Screen.h DisplayApp/Screens/Clock.h - DisplayApp/Screens/Message.h +# DisplayApp/Screens/Message.h DisplayApp/Screens/Tile.h - DisplayApp/Screens/Tab.h +# DisplayApp/Screens/Tab.h drivers/St7789.h drivers/SpiMaster.h - Components/Gfx/Gfx.h BLE/BleManager.h Components/Battery/BatteryController.h Components/Ble/BleController.h @@ -214,6 +211,8 @@ set(INCLUDE_FILES libs/date/includes/date/tz_private.h DisplayApp/LittleVgl.h + + SystemTask/SystemTask.h ) include_directories( diff --git a/src/DisplayApp/DisplayApp.cpp b/src/DisplayApp/DisplayApp.cpp index 34d81ddc..d70726dd 100644 --- a/src/DisplayApp/DisplayApp.cpp +++ b/src/DisplayApp/DisplayApp.cpp @@ -13,25 +13,26 @@ #include #include #include -#include +#include "../SystemTask/SystemTask.h" +//#include using namespace Pinetime::Applications; DisplayApp::DisplayApp(Pinetime::Drivers::St7789& lcd, - Pinetime::Components::Gfx& gfx, Pinetime::Components::LittleVgl& lvgl, Pinetime::Drivers::Cst816S& touchPanel, Controllers::Battery &batteryController, Controllers::Ble &bleController, - Controllers::DateTime &dateTimeController) : + Controllers::DateTime &dateTimeController, + Pinetime::System::SystemTask& systemTask) : lcd{lcd}, - gfx{gfx}, lvgl{lvgl}, touchPanel{touchPanel}, batteryController{batteryController}, bleController{bleController}, dateTimeController{dateTimeController}, - currentScreen{new Screens::Clock(this, gfx, dateTimeController) } { + currentScreen{new Screens::Clock(this, dateTimeController) }, + systemTask{systemTask} { msgQueue = xQueueCreate(queueSize, itemSize); } @@ -48,7 +49,7 @@ void DisplayApp::Process(void *instance) { while (1) { app->Refresh(); - lv_task_handler(); + } } @@ -114,36 +115,28 @@ void DisplayApp::Refresh() { OnTouchEvent(); break; case Messages::ButtonPushed: - currentScreen->OnButtonPushed(); + if(!currentScreen->OnButtonPushed()) { + systemTask.PushMessage(System::SystemTask::Messages::GoToSleep); + } + break; } } } -bool first = true; - void DisplayApp::RunningState() { // clockScreen.SetCurrentDateTime(dateTimeController.CurrentDateTime()); - if(currentScreen != nullptr) { - currentScreen->Refresh(first); - if(currentScreen->GetNextScreen() != Screens::Screen::NextScreen::None) { - switch(currentScreen->GetNextScreen()) { - case Screens::Screen::NextScreen::Clock: - currentScreen.reset(nullptr); - currentScreen.reset(new Screens::Clock(this, gfx, dateTimeController)); - break; - case Screens::Screen::NextScreen::Menu: - currentScreen.reset(nullptr); - currentScreen.reset(new Screens::Tile(this, gfx)); - break; - case Screens::Screen::NextScreen::App: - currentScreen.reset(nullptr); - currentScreen.reset(new Screens::Message(this, gfx)); - break; - } + if(!currentScreen->Refresh(true)) { + currentScreen.reset(nullptr); + switch(nextApp) { + case Apps::None: + case Apps::Launcher: currentScreen.reset(new Screens::Tile(this)); break; + case Apps::Clock: currentScreen.reset(new Screens::Clock(this, dateTimeController)); break; +// case Apps::Test: currentScreen.reset(new Screens::Message(this)); break; } - first = false; + nextApp = Apps::None; } + lv_task_handler(); } void DisplayApp::IdleState() { @@ -169,3 +162,7 @@ void DisplayApp::OnTouchEvent() { // pointColor+=10; // } } + +void DisplayApp::StartApp(DisplayApp::Apps app) { + nextApp = app; +} diff --git a/src/DisplayApp/DisplayApp.h b/src/DisplayApp/DisplayApp.h index f8101536..656dd4ed 100644 --- a/src/DisplayApp/DisplayApp.h +++ b/src/DisplayApp/DisplayApp.h @@ -14,35 +14,37 @@ #include "LittleVgl.h" #include #include -#include +//#include -extern const FONT_INFO lCD_70ptFontInfo; namespace Pinetime { + namespace System { + class SystemTask; + }; namespace Applications { class DisplayApp { public: enum class States {Idle, Running}; enum class Messages : uint8_t {GoToSleep, GoToRunning, UpdateDateTime, UpdateBleConnection, UpdateBatteryLevel, TouchEvent, SwitchScreen,ButtonPushed} ; DisplayApp(Pinetime::Drivers::St7789& lcd, - Pinetime::Components::Gfx& gfx, Pinetime::Components::LittleVgl& lvgl, Pinetime::Drivers::Cst816S&, Controllers::Battery &batteryController, Controllers::Ble &bleController, - Controllers::DateTime& dateTimeController); + Controllers::DateTime& dateTimeController, + Pinetime::System::SystemTask& systemTask); void Start(); void PushMessage(Messages msg); + enum class Apps {None, Launcher, Clock, Test}; + void StartApp(Apps app); + private: TaskHandle_t taskHandle; static void Process(void* instance); void InitHw(); Pinetime::Drivers::St7789& lcd; - Pinetime::Components::Gfx& gfx; Pinetime::Components::LittleVgl lvgl; - const FONT_INFO largeFont {lCD_70ptFontInfo.height, lCD_70ptFontInfo.startChar, lCD_70ptFontInfo.endChar, lCD_70ptFontInfo.spacePixels, lCD_70ptFontInfo.charInfo, lCD_70ptFontInfo.data}; - const FONT_INFO smallFont {lCD_14ptFontInfo.height, lCD_14ptFontInfo.startChar, lCD_14ptFontInfo.endChar, lCD_14ptFontInfo.spacePixels, lCD_14ptFontInfo.charInfo, lCD_14ptFontInfo.data}; void Refresh(); States state = States::Running; @@ -66,6 +68,9 @@ namespace Pinetime { static constexpr uint8_t pinLcdBacklight3 = 23; bool isClock = true; + + Pinetime::System::SystemTask& systemTask; + Apps nextApp = Apps::None; }; } } diff --git a/src/DisplayApp/Screens/Clock.cpp b/src/DisplayApp/Screens/Clock.cpp index 806a1c2c..3b849150 100644 --- a/src/DisplayApp/Screens/Clock.cpp +++ b/src/DisplayApp/Screens/Clock.cpp @@ -15,7 +15,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { screen->OnObjectEvent(obj, event); } -Clock::Clock(DisplayApp* app, Pinetime::Components::Gfx &gfx, Controllers::DateTime& dateTimeController) : Screen(app, gfx), currentDateTime{{}}, version {{}}, dateTimeController{dateTimeController} { +Clock::Clock(DisplayApp* app, Controllers::DateTime& dateTimeController) : Screen(app), currentDateTime{{}}, version {{}}, dateTimeController{dateTimeController} { displayedChar[0] = 0; displayedChar[1] = 0; displayedChar[2] = 0; @@ -65,7 +65,7 @@ Clock::~Clock() { lv_obj_clean(lv_scr_act()); } -void Clock::Refresh(bool fullRefresh) { +bool Clock::Refresh(bool fullRefresh) { if(fullRefresh) { auto currentDateTime = dateTimeController.CurrentDateTime(); } @@ -145,6 +145,7 @@ void Clock::Refresh(bool fullRefresh) { lv_label_set_text(label_version, versionStr); } + return running; } const char *Clock::MonthToString(Pinetime::Controllers::DateTime::Months month) { @@ -185,9 +186,14 @@ char const *Clock::MonthsString[] = { void Clock::OnObjectEvent(lv_obj_t *obj, lv_event_t event) { if(obj == backgroundLabel) { if (event == LV_EVENT_CLICKED) { - nextScreen = NextScreen::Menu; + + running = false; } } } +bool Clock::OnButtonPushed() { + return Screen::OnButtonPushed(); +} + diff --git a/src/DisplayApp/Screens/Clock.h b/src/DisplayApp/Screens/Clock.h index d6e5a288..a358e41b 100644 --- a/src/DisplayApp/Screens/Clock.h +++ b/src/DisplayApp/Screens/Clock.h @@ -35,9 +35,11 @@ namespace Pinetime { class Clock : public Screen{ public: enum class BleConnectionStates{ NotConnected, Connected}; - Clock(DisplayApp* app, Components::Gfx& gfx, Controllers::DateTime& dateTimeController); + Clock(DisplayApp* app, Controllers::DateTime& dateTimeController); ~Clock() override; - void Refresh(bool fullRefresh) override; + + bool Refresh(bool fullRefresh) override; + bool OnButtonPushed() override; void SetBatteryPercentRemaining(uint8_t percent) { batteryPercentRemaining = percent; } void SetBleConnectionState(BleConnectionStates state) { bleState = state; } @@ -52,9 +54,6 @@ namespace Pinetime { char displayedChar[5]; - const FONT_INFO largeFont {lCD_70ptFontInfo.height, lCD_70ptFontInfo.startChar, lCD_70ptFontInfo.endChar, lCD_70ptFontInfo.spacePixels, lCD_70ptFontInfo.charInfo, lCD_70ptFontInfo.data}; - const FONT_INFO smallFont {lCD_14ptFontInfo.height, lCD_14ptFontInfo.startChar, lCD_14ptFontInfo.endChar, lCD_14ptFontInfo.spacePixels, lCD_14ptFontInfo.charInfo, lCD_14ptFontInfo.data}; - uint16_t currentYear = 1970; Pinetime::Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown; Pinetime::Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown; @@ -77,6 +76,8 @@ namespace Pinetime { Controllers::DateTime& dateTimeController; + bool running = true; + }; } } diff --git a/src/DisplayApp/Screens/Screen.h b/src/DisplayApp/Screens/Screen.h index 57b8ea2a..625daada 100644 --- a/src/DisplayApp/Screens/Screen.h +++ b/src/DisplayApp/Screens/Screen.h @@ -9,16 +9,18 @@ namespace Pinetime { class Screen { public: enum class NextScreen {None, Clock, Menu, App}; - Screen(DisplayApp* app, Components::Gfx& gfx) : app{app}, gfx{gfx} {} + + Screen(DisplayApp* app) : app{app} {} virtual ~Screen() = default; - virtual void Refresh(bool fullRefresh) = 0; - NextScreen GetNextScreen() {return nextScreen;} - virtual void OnButtonPushed() {}; + + // Return false if the app can be closed, true if it must continue to run + virtual bool Refresh(bool fullRefresh) = 0; + + // Return false if the button hasn't been handled by the app, true if it has been handled + virtual bool OnButtonPushed() { return false; } protected: DisplayApp* app; - Components::Gfx& gfx; - NextScreen nextScreen = NextScreen::None; }; } } diff --git a/src/DisplayApp/Screens/Tile.cpp b/src/DisplayApp/Screens/Tile.cpp index ac930ba7..c9e33544 100644 --- a/src/DisplayApp/Screens/Tile.cpp +++ b/src/DisplayApp/Screens/Tile.cpp @@ -22,8 +22,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { static const char * btnm_map1[] = {"App1", "App2", "App3", "\n", "App4", "App5", "App11", ""}; -Tile::Tile(DisplayApp* app, Pinetime::Components::Gfx &gfx) : Screen(app, gfx) { - +Tile::Tile(DisplayApp* app) : Screen(app) { static lv_point_t valid_pos[] = {{0,0}, {LV_COORD_MIN, LV_COORD_MIN}}; tileview = lv_tileview_create(lv_scr_act(), NULL); lv_tileview_set_valid_positions(tileview, valid_pos, 1); @@ -38,11 +37,16 @@ Tile::Tile(DisplayApp* app, Pinetime::Components::Gfx &gfx) : Screen(app, gfx) { lv_btnm_set_map(btnm1, btnm_map1); lv_obj_set_size(btnm1, LV_HOR_RES, LV_VER_RES); - labelStyle = const_cast(lv_label_get_style(btnm1, LV_BTNM_STYLE_BTN_REL)); - labelStyle->text.font = &jetbrains_mono_bold_20; - labelStyle->body.grad_color = labelStyle->body.main_color; - lv_btnm_set_style(btnm1, LV_BTNM_STYLE_BTN_REL, labelStyle); - lv_btnm_set_style(btnm1, LV_BTNM_STYLE_BTN_PR, labelStyle); + labelRelStyle = const_cast(lv_label_get_style(btnm1, LV_BTNM_STYLE_BTN_REL)); + labelRelStyle->text.font = &jetbrains_mono_bold_20; + labelRelStyle->body.grad_color = labelRelStyle->body.main_color; + lv_btnm_set_style(btnm1, LV_BTNM_STYLE_BTN_REL, labelRelStyle); + + labelPrStyle = const_cast(lv_label_get_style(btnm1, LV_BTNM_STYLE_BTN_PR)); + labelPrStyle->text.font = &jetbrains_mono_bold_20; + labelPrStyle->body.grad_color = labelPrStyle->body.shadow.color; +// lv_btnm_set_style(btnm1, LV_BTNM_STYLE_BTN_PR, labelPrStyle); +//TODO better style handling lv_obj_align(btnm1, tile1, LV_ALIGN_CENTER, 0, 0); btnm1->user_data = this; @@ -100,17 +104,28 @@ Tile::~Tile() { lv_obj_clean(lv_scr_act()); } -void Tile::Refresh(bool fullRefresh) { - +bool Tile::Refresh(bool fullRefresh) { + return running; } void Tile::OnObjectEvent(lv_obj_t *obj, lv_event_t event) { + auto* tile = static_cast(obj->user_data); if(event == LV_EVENT_CLICKED) { - NRF_LOG_INFO("Clicked"); - nextScreen = Screen::NextScreen::App; + + tile->StartApp(); clickCount++; } else if(event == LV_EVENT_VALUE_CHANGED) { - NRF_LOG_INFO("Toggled"); } } + +bool Tile::OnButtonPushed() { + app->StartApp(DisplayApp::Apps::Clock); + running = false; + return true; +} + +void Tile::StartApp() { + app->StartApp(DisplayApp::Apps::Clock); + running = false; +} diff --git a/src/DisplayApp/Screens/Tile.h b/src/DisplayApp/Screens/Tile.h index c9de2c5c..03cfb6d2 100644 --- a/src/DisplayApp/Screens/Tile.h +++ b/src/DisplayApp/Screens/Tile.h @@ -15,18 +15,18 @@ namespace Pinetime { namespace Screens { class Tile : public Screen { public: - explicit Tile(DisplayApp* app, Components::Gfx& gfx); + explicit Tile(DisplayApp* app); ~Tile() override; - void Refresh(bool fullRefresh) override; - void OnObjectEvent(lv_obj_t* obj, lv_event_t event); - void OnButtonPushed() override {nextScreen = NextScreen::Clock;} + bool Refresh(bool fullRefresh) override; + bool OnButtonPushed() override; + + void OnObjectEvent(lv_obj_t* obj, lv_event_t event); private: - const FONT_INFO largeFont {lCD_70ptFontInfo.height, lCD_70ptFontInfo.startChar, lCD_70ptFontInfo.endChar, lCD_70ptFontInfo.spacePixels, lCD_70ptFontInfo.charInfo, lCD_70ptFontInfo.data}; - const FONT_INFO smallFont {lCD_14ptFontInfo.height, lCD_14ptFontInfo.startChar, lCD_14ptFontInfo.endChar, lCD_14ptFontInfo.spacePixels, lCD_14ptFontInfo.charInfo, lCD_14ptFontInfo.data}; - lv_style_t* labelStyle; + lv_style_t* labelRelStyle; + lv_style_t* labelPrStyle; lv_obj_t * label1; lv_obj_t * label2; lv_obj_t * label3; @@ -50,6 +50,8 @@ namespace Pinetime { uint32_t clickCount = 0 ; uint32_t previousClickCount = 0; + void StartApp(); + bool running = true; }; } } diff --git a/src/SystemTask/SystemTask.cpp b/src/SystemTask/SystemTask.cpp new file mode 100644 index 00000000..642e36a2 --- /dev/null +++ b/src/SystemTask/SystemTask.cpp @@ -0,0 +1,115 @@ +#include +#include +#include +#include +#include +#include "SystemTask.h" +#include "../main.h" +using namespace Pinetime::System; + +SystemTask::SystemTask(Pinetime::Drivers::SpiMaster &spi, Pinetime::Drivers::St7789 &lcd, + Pinetime::Drivers::Cst816S &touchPanel, Pinetime::Components::LittleVgl &lvgl, + Pinetime::Controllers::Battery &batteryController, Pinetime::Controllers::Ble &bleController, + Pinetime::Controllers::DateTime& dateTimeController) : + spi{spi}, lcd{lcd}, touchPanel{touchPanel}, lvgl{lvgl}, batteryController{batteryController}, bleController{bleController}, dateTimeController{dateTimeController} { + systemTaksMsgQueue = xQueueCreate(10, 1); +} + +void SystemTask::Start() { + if (pdPASS != xTaskCreate(SystemTask::Process, "MAIN", 256, this, 0, &taskHandle)) + APP_ERROR_HANDLER(NRF_ERROR_NO_MEM); +} + +void SystemTask::Process(void *instance) { + auto *app = static_cast(instance); + NRF_LOG_INFO("SystemTask task started!"); + app->Work(); +} + +void SystemTask::Work() { + APP_GPIOTE_INIT(2); + bool erase_bonds=false; +// nrf_sdh_freertos_init(ble_manager_start_advertising, &erase_bonds); + + spi.Init(); + lcd.Init(); + touchPanel.Init(); + batteryController.Init(); + + displayApp.reset(new Pinetime::Applications::DisplayApp(lcd, lvgl, touchPanel, batteryController, bleController, dateTimeController, *this)); + displayApp->Start(); + + batteryController.Update(); + displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::UpdateBatteryLevel); + + nrf_gpio_cfg_sense_input(pinButton, (nrf_gpio_pin_pull_t)GPIO_PIN_CNF_PULL_Pulldown, (nrf_gpio_pin_sense_t)GPIO_PIN_CNF_SENSE_High); + nrf_gpio_cfg_output(15); + nrf_gpio_pin_set(15); + + nrfx_gpiote_in_config_t pinConfig; + pinConfig.skip_gpio_setup = true; + pinConfig.hi_accuracy = false; + pinConfig.is_watcher = false; + pinConfig.sense = (nrf_gpiote_polarity_t)NRF_GPIOTE_POLARITY_HITOLO; + pinConfig.pull = (nrf_gpio_pin_pull_t)GPIO_PIN_CNF_PULL_Pulldown; + + nrfx_gpiote_in_init(pinButton, &pinConfig, nrfx_gpiote_evt_handler); + + nrf_gpio_cfg_sense_input(pinTouchIrq, (nrf_gpio_pin_pull_t)GPIO_PIN_CNF_PULL_Pullup, (nrf_gpio_pin_sense_t)GPIO_PIN_CNF_SENSE_Low); + + pinConfig.skip_gpio_setup = true; + pinConfig.hi_accuracy = false; + pinConfig.is_watcher = false; + pinConfig.sense = (nrf_gpiote_polarity_t)NRF_GPIOTE_POLARITY_HITOLO; + pinConfig.pull = (nrf_gpio_pin_pull_t)GPIO_PIN_CNF_PULL_Pullup; + + nrfx_gpiote_in_init(pinTouchIrq, &pinConfig, nrfx_gpiote_evt_handler); + + + while(true) { + uint8_t msg; + if (xQueueReceive(systemTaksMsgQueue, &msg, isSleeping?3600000 : 1000)) { + Messages message = static_cast(msg); + switch(message) { + case Messages::GoToRunning: isSleeping = false; break; + case Messages::GoToSleep: + NRF_LOG_INFO("[SystemTask] Going to sleep"); + displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::GoToSleep); + isSleeping = true; break; + default: break; + } + } + uint32_t systick_counter = nrf_rtc_counter_get(portNRF_RTC_REG); + dateTimeController.UpdateTime(systick_counter); + } +} + +void SystemTask::OnButtonPushed() { + + if(!isSleeping) { + NRF_LOG_INFO("[SystemTask] Button pushed"); + displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::ButtonPushed); + } + else { + NRF_LOG_INFO("[SystemTask] Button pushed, waking up"); + displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::GoToRunning); + isSleeping = false; + batteryController.Update(); + displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::UpdateBatteryLevel); + } +} + +void SystemTask::OnTouchEvent() { + NRF_LOG_INFO("[SystemTask] Touch event"); + displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::TouchEvent); +} + +void SystemTask::PushMessage(SystemTask::Messages msg) { + BaseType_t xHigherPriorityTaskWoken; + xHigherPriorityTaskWoken = pdFALSE; + xQueueSendFromISR(systemTaksMsgQueue, &msg, &xHigherPriorityTaskWoken); + if (xHigherPriorityTaskWoken) { + /* Actual macro used here is port specific. */ + // TODO : should I do something here? + } +} diff --git a/src/SystemTask/SystemTask.h b/src/SystemTask/SystemTask.h new file mode 100644 index 00000000..cb913545 --- /dev/null +++ b/src/SystemTask/SystemTask.h @@ -0,0 +1,60 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +namespace Pinetime { + namespace System { + class SystemTask { + public: + enum class Messages {GoToSleep, GoToRunning}; + + SystemTask(Pinetime::Drivers::SpiMaster& spi, + Pinetime::Drivers::St7789& lcd, + Pinetime::Drivers::Cst816S& touchPanel, + Pinetime::Components::LittleVgl& lvgl, + Pinetime::Controllers::Battery& batteryController, + Pinetime::Controllers::Ble& bleController, + Pinetime::Controllers::DateTime& dateTimeController); + + + void Start(); + void PushMessage(Messages msg); + + void OnButtonPushed(); + void OnTouchEvent(); + private: + TaskHandle_t taskHandle; + + Pinetime::Drivers::SpiMaster& spi; + Pinetime::Drivers::St7789& lcd; + Pinetime::Drivers::Cst816S& touchPanel; + Pinetime::Components::LittleVgl& lvgl; + Pinetime::Controllers::Battery& batteryController; + std::unique_ptr displayApp; + Pinetime::Controllers::Ble& bleController; + Pinetime::Controllers::DateTime& dateTimeController; + QueueHandle_t systemTaksMsgQueue; + bool isSleeping = false; + + + static constexpr uint8_t pinSpiSck = 2; + static constexpr uint8_t pinSpiMosi = 3; + static constexpr uint8_t pinSpiMiso = 4; + static constexpr uint8_t pinSpiCsn = 25; + static constexpr uint8_t pinLcdDataCommand = 18; + static constexpr uint8_t pinButton = 13; + static constexpr uint8_t pinTouchIrq = 28; + + static void Process(void* instance); + void Work(); + + + }; + } +} \ No newline at end of file diff --git a/src/libs/lv_conf.h b/src/libs/lv_conf.h index 8d7a6f7e..34457953 100644 --- a/src/libs/lv_conf.h +++ b/src/libs/lv_conf.h @@ -123,7 +123,7 @@ typedef int16_t lv_coord_t; *==================*/ /*1: Enable the Animations */ -#define LV_USE_ANIMATION 0 +#define LV_USE_ANIMATION 1 #if LV_USE_ANIMATION /*Declare the type of the user data of animations (can be e.g. `void *`, `int`, `struct`)*/ @@ -563,7 +563,7 @@ typedef void * lv_obj_user_data_t; #define LV_USE_TILEVIEW 1 #if LV_USE_TILEVIEW /*Time of slide animation [ms] (0: no animation)*/ -# define LV_TILEVIEW_DEF_ANIM_TIME 0 +# define LV_TILEVIEW_DEF_ANIM_TIME 300 #endif /*Window (dependencies: lv_cont, lv_btn, lv_label, lv_img, lv_page)*/ diff --git a/src/main.cpp b/src/main.cpp index 2a272677..08b15f62 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,10 +18,10 @@ #include "../drivers/Cst816s.h" #include #include -#include #include #include +#include #if NRF_LOG_ENABLED #include "Logging/NrfLogger.h" @@ -33,8 +33,6 @@ Pinetime::Logging::DummyLogger logger; std::unique_ptr spi; std::unique_ptr lcd; -Pinetime::Drivers::St7789* ptrLcd; -std::unique_ptr gfx; std::unique_ptr lvgl; std::unique_ptr touchPanel; @@ -45,27 +43,19 @@ static constexpr uint8_t pinSpiCsn = 25; static constexpr uint8_t pinLcdDataCommand = 18; -std::unique_ptr displayApp; -TaskHandle_t systemThread; -bool isSleeping = false; TimerHandle_t debounceTimer; Pinetime::Controllers::Battery batteryController; Pinetime::Controllers::Ble bleController; Pinetime::Controllers::DateTime dateTimeController; - - void ble_manager_set_ble_connection_callback(void (*connection)()); void ble_manager_set_ble_disconnection_callback(void (*disconnection)()); -static constexpr uint8_t pinButton = 13; static constexpr uint8_t pinTouchIrq = 28; -QueueHandle_t systemTaksMsgQueue; -enum class SystemTaskMessages {GoToSleep, GoToRunning}; -void SystemTask_PushMessage(SystemTaskMessages message); +std::unique_ptr systemTask; void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) { if(pin == pinTouchIrq) { - displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::TouchEvent); - if(!isSleeping) return; + systemTask->OnTouchEvent(); + return ; } BaseType_t xHigherPriorityTaskWoken = pdFALSE; @@ -73,7 +63,6 @@ void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action portYIELD_FROM_ISR(xHigherPriorityTaskWoken); } - extern "C" { void vApplicationIdleHook(void) { lv_tick_inc(1); @@ -82,118 +71,17 @@ extern "C" { void DebounceTimerCallback(TimerHandle_t xTimer) { xTimerStop(xTimer, 0); - /*if(isSleeping) { - SystemTask_PushMessage(SystemTaskMessages::GoToRunning); - displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::GoToRunning); - isSleeping = false; - batteryController.Update(); - displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::UpdateBatteryLevel); - } - else { - SystemTask_PushMessage(SystemTaskMessages::GoToSleep); - displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::GoToSleep); - isSleeping = true; - }*/ - displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::ButtonPushed); -} - -void SystemTask_PushMessage(SystemTaskMessages message) { - BaseType_t xHigherPriorityTaskWoken; - xHigherPriorityTaskWoken = pdFALSE; - xQueueSendFromISR(systemTaksMsgQueue, &message, &xHigherPriorityTaskWoken); - if (xHigherPriorityTaskWoken) { - /* Actual macro used here is port specific. */ - // TODO : should I do something here? - } -} - -// TODO The whole SystemTask should go in its own class -// BUT... it has to work with pure C callback (nrfx_gpiote_evt_handler) and i've still not found -// a good design for that (the callback does not allow to pass a pointer to an instance...) -void SystemTask(void *) { - APP_GPIOTE_INIT(2); - bool erase_bonds=false; -// nrf_sdh_freertos_init(ble_manager_start_advertising, &erase_bonds); - - spi.reset(new Pinetime::Drivers::SpiMaster {Pinetime::Drivers::SpiMaster::SpiModule::SPI0, { - Pinetime::Drivers::SpiMaster::BitOrder::Msb_Lsb, - Pinetime::Drivers::SpiMaster::Modes::Mode3, - Pinetime::Drivers::SpiMaster::Frequencies::Freq8Mhz, - pinSpiSck, - pinSpiMosi, - pinSpiMiso, - pinSpiCsn - }}); - - lcd.reset(new Pinetime::Drivers::St7789(*spi, pinLcdDataCommand)); - gfx.reset(new Pinetime::Components::Gfx(*lcd)); - touchPanel.reset(new Pinetime::Drivers::Cst816S()); - - lvgl.reset(new Pinetime::Components::LittleVgl(*lcd, *touchPanel)); - ptrLcd = lcd.get(); - - spi->Init(); - lcd->Init(); - touchPanel->Init(); - batteryController.Init(); - - displayApp.reset(new Pinetime::Applications::DisplayApp(*lcd, *gfx, *lvgl, *touchPanel, batteryController, bleController, dateTimeController)); - displayApp->Start(); - - batteryController.Update(); - displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::UpdateBatteryLevel); - - debounceTimer = xTimerCreate ("debounceTimer", 200, pdFALSE, (void *) 0, DebounceTimerCallback); - - nrf_gpio_cfg_sense_input(pinButton, (nrf_gpio_pin_pull_t)GPIO_PIN_CNF_PULL_Pulldown, (nrf_gpio_pin_sense_t)GPIO_PIN_CNF_SENSE_High); - nrf_gpio_cfg_output(15); - nrf_gpio_pin_set(15); - - nrfx_gpiote_in_config_t pinConfig; - pinConfig.skip_gpio_setup = true; - pinConfig.hi_accuracy = false; - pinConfig.is_watcher = false; - pinConfig.sense = (nrf_gpiote_polarity_t)NRF_GPIOTE_POLARITY_HITOLO; - pinConfig.pull = (nrf_gpio_pin_pull_t)GPIO_PIN_CNF_PULL_Pulldown; - - nrfx_gpiote_in_init(pinButton, &pinConfig, nrfx_gpiote_evt_handler); - - nrf_gpio_cfg_sense_input(pinTouchIrq, (nrf_gpio_pin_pull_t)GPIO_PIN_CNF_PULL_Pullup, (nrf_gpio_pin_sense_t)GPIO_PIN_CNF_SENSE_Low); - - pinConfig.skip_gpio_setup = true; - pinConfig.hi_accuracy = false; - pinConfig.is_watcher = false; - pinConfig.sense = (nrf_gpiote_polarity_t)NRF_GPIOTE_POLARITY_HITOLO; - pinConfig.pull = (nrf_gpio_pin_pull_t)GPIO_PIN_CNF_PULL_Pullup; - - nrfx_gpiote_in_init(pinTouchIrq, &pinConfig, nrfx_gpiote_evt_handler); - - systemTaksMsgQueue = xQueueCreate(10, 1); - bool systemTaskSleeping = false; - - while(true) { - uint8_t msg; - if (xQueueReceive(systemTaksMsgQueue, &msg, systemTaskSleeping?3600000 : 1000)) { - SystemTaskMessages message = static_cast(msg); - switch(message) { - case SystemTaskMessages::GoToRunning: systemTaskSleeping = false; break; - case SystemTaskMessages::GoToSleep: systemTaskSleeping = true; break; - default: break; - } - } - uint32_t systick_counter = nrf_rtc_counter_get(portNRF_RTC_REG); - dateTimeController.UpdateTime(systick_counter); - } + systemTask->OnButtonPushed(); } void OnBleConnection() { bleController.Connect(); - displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::UpdateBleConnection); + // TODO Notify system/Display app } void OnBleDisconnection() { bleController.Disconnect(); - displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::UpdateBleConnection); + // TODO Notify system/Display app } void OnNewTime(current_time_char_t* currentTime) { @@ -224,12 +112,28 @@ void SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler(void) { NRF_SPIM0->EVENTS_STOPPED = 0; } } + int main(void) { logger.Init(); nrf_drv_clock_init(); - if (pdPASS != xTaskCreate(SystemTask, "MAIN", 256, nullptr, 0, &systemThread)) - APP_ERROR_HANDLER(NRF_ERROR_NO_MEM); + spi.reset(new Pinetime::Drivers::SpiMaster {Pinetime::Drivers::SpiMaster::SpiModule::SPI0, { + Pinetime::Drivers::SpiMaster::BitOrder::Msb_Lsb, + Pinetime::Drivers::SpiMaster::Modes::Mode3, + Pinetime::Drivers::SpiMaster::Frequencies::Freq8Mhz, + pinSpiSck, + pinSpiMosi, + pinSpiMiso, + pinSpiCsn + }}); + lcd.reset(new Pinetime::Drivers::St7789(*spi, pinLcdDataCommand)); + touchPanel.reset(new Pinetime::Drivers::Cst816S()); + lvgl.reset(new Pinetime::Components::LittleVgl(*lcd, *touchPanel)); + debounceTimer = xTimerCreate ("debounceTimer", 200, pdFALSE, (void *) 0, DebounceTimerCallback); + + systemTask.reset(new Pinetime::System::SystemTask(*spi, *lcd, *touchPanel, *lvgl, batteryController, bleController, dateTimeController)); + systemTask->Start(); + /* ble_manager_init(); ble_manager_set_new_time_callback(OnNewTime); diff --git a/src/main.h b/src/main.h new file mode 100644 index 00000000..b0a8a57e --- /dev/null +++ b/src/main.h @@ -0,0 +1,7 @@ +#pragma once + +#include +#include + +void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action); +void DebounceTimerCallback(TimerHandle_t xTimer); \ No newline at end of file -- cgit v1.2.3-70-g09d2 From f07ffab4c1fa876e8da9a1bcc895ecf0dfa75acf Mon Sep 17 00:00:00 2001 From: JF Date: Sun, 23 Feb 2020 16:14:03 +0100 Subject: Re-enable BLE, BLE status on display and battery level on display. --- doc/SPI-LCD-driver.md | 46 ++++++++++++++++++++++++++++++++++++++ src/BLE/BleManager.h | 1 + src/CMakeLists.txt | 4 ++-- src/DisplayApp/DisplayApp.cpp | 15 +++++-------- src/DisplayApp/DisplayApp.h | 1 - src/DisplayApp/Screens/Clock.cpp | 24 +++++++++++--------- src/DisplayApp/Screens/Clock.h | 24 +++++++++++--------- src/DisplayApp/Screens/Message.cpp | 11 +++++++-- src/DisplayApp/Screens/Message.h | 9 ++++---- src/DisplayApp/Screens/Screen.h | 6 +---- src/DisplayApp/Screens/Tile.cpp | 40 ++++++++++++++++++++------------- src/DisplayApp/Screens/Tile.h | 7 +++--- src/SystemTask/SystemTask.cpp | 6 +++-- src/main.cpp | 9 +------- 14 files changed, 130 insertions(+), 73 deletions(-) create mode 100644 doc/SPI-LCD-driver.md (limited to 'src/DisplayApp/DisplayApp.cpp') diff --git a/doc/SPI-LCD-driver.md b/doc/SPI-LCD-driver.md new file mode 100644 index 00000000..3c33c258 --- /dev/null +++ b/doc/SPI-LCD-driver.md @@ -0,0 +1,46 @@ +# The SPI LCD driver +## Introduction +The LCD controller that drive the display of the Pinetime is the Sitronix ST7789V. This controller is easy to integrate with an MCU thanks to its SPI interface, and has some interesting features like: +- an on-chip display data RAM that can store the whole framebuffer +- partial screen update +- hardware assisted vertical scrolling +- interrupt pin, allowing to drive the display with DMA and IRQ +- ... + +When you want to write a device driver for a specific component, its datasheet is your holy bible. This document contains a lot of information about the chip, its specification, characteristics, features and functionalities. +Luckily for us, the datasheet of the ST7789 is great! It contains everything we need to write a nice driver for our beloved Pinetime. + +In this document, I'll try to explain the process I've followed to write a device driver for the LCD. There were multiple iterations: +- First, I tried to find the correct initialization sequence so that the controller is configured correctly according to the hardware configuration; +- Then, I tried to display some pixels on the screen; +- Next, I wanted to display squares, colors and text; +- Following, there was a need to make that faster and faster again; +- And finally, I wanted to draw beautiful and useful UIs + +I'll describe all these steps in the following chapters. + +## The datasheet +As I said in the introduction, the datasheet will be your bedside book during your journey as a device driver designer. You'll read it from the beginning to the end once, twice, maybe ten times. Then, each time you'll want to do something new, you'll reopen the file and search for that specific paragraph or diagram than explains how the controller works so that you can figure out how to use it. + +The schematic of your board (the Pinetime schematics in this case) will also be very important, as you'll need to know how the LCD controller is physically connected to the MCU. + +How to read the datasheet? I recommand to read it from the beginning to the end (no joke) at least once. You certainly do not need to read everything in details, but it's good to know what information is available and where in the document. It'll be very useful during the developpment phase. +You'll want to read some part with more attention : +- Data color coding in 4-Line Serial Interface : how to send the pixel to be display to the controller +- Display Data Ram : how is the memory organised +- Power On/Off sequence +- System function commands : all the commands you can send to the controller. + +## One Pixel at a time + + +## Bulk transfert + +## DMA + +## IRQ + +## Bare metal integration +Integration customisée dans la lib GFX que j'ai écrite + +## Integration with LittleVGL \ No newline at end of file diff --git a/src/BLE/BleManager.h b/src/BLE/BleManager.h index 13b12a62..68fdff9a 100644 --- a/src/BLE/BleManager.h +++ b/src/BLE/BleManager.h @@ -1,4 +1,5 @@ #pragma once +#include #ifdef __cplusplus extern "C" { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index efbb3861..3fb4dd6e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -158,7 +158,7 @@ list(APPEND SOURCE_FILES DisplayApp/DisplayApp.cpp DisplayApp/Screens/Screen.cpp DisplayApp/Screens/Clock.cpp -# DisplayApp/Screens/Message.cpp + DisplayApp/Screens/Message.cpp DisplayApp/Screens/Tile.cpp # DisplayApp/Screens/Tab.cpp main.cpp @@ -189,7 +189,7 @@ set(INCLUDE_FILES DisplayApp/DisplayApp.h DisplayApp/Screens/Screen.h DisplayApp/Screens/Clock.h -# DisplayApp/Screens/Message.h + DisplayApp/Screens/Message.h DisplayApp/Screens/Tile.h # DisplayApp/Screens/Tab.h drivers/St7789.h diff --git a/src/DisplayApp/DisplayApp.cpp b/src/DisplayApp/DisplayApp.cpp index d70726dd..1a794e04 100644 --- a/src/DisplayApp/DisplayApp.cpp +++ b/src/DisplayApp/DisplayApp.cpp @@ -4,17 +4,14 @@ #include #include #include -#include -#include "Components/Gfx/Gfx.h" #include #include #include -#include #include #include #include +#include #include "../SystemTask/SystemTask.h" -//#include using namespace Pinetime::Applications; @@ -31,7 +28,7 @@ DisplayApp::DisplayApp(Pinetime::Drivers::St7789& lcd, batteryController{batteryController}, bleController{bleController}, dateTimeController{dateTimeController}, - currentScreen{new Screens::Clock(this, dateTimeController) }, + currentScreen{new Screens::Clock(this, dateTimeController, batteryController, bleController) }, systemTask{systemTask} { msgQueue = xQueueCreate(queueSize, itemSize); } @@ -126,13 +123,13 @@ void DisplayApp::Refresh() { void DisplayApp::RunningState() { // clockScreen.SetCurrentDateTime(dateTimeController.CurrentDateTime()); - if(!currentScreen->Refresh(true)) { + if(!currentScreen->Refresh()) { currentScreen.reset(nullptr); switch(nextApp) { case Apps::None: case Apps::Launcher: currentScreen.reset(new Screens::Tile(this)); break; - case Apps::Clock: currentScreen.reset(new Screens::Clock(this, dateTimeController)); break; -// case Apps::Test: currentScreen.reset(new Screens::Message(this)); break; + case Apps::Clock: currentScreen.reset(new Screens::Clock(this, dateTimeController, batteryController, bleController)); break; + case Apps::Test: currentScreen.reset(new Screens::Message(this)); break; } nextApp = Apps::None; } @@ -158,7 +155,7 @@ void DisplayApp::OnTouchEvent() { // auto info = touchPanel.GetTouchInfo(); // // if(info.isTouch) { -// gfx.FillRectangle(info.x-10, info.y-10, 20,20, pointColor); +// lcd.DrawPixel(info.x, info.y, pointColor); // pointColor+=10; // } } diff --git a/src/DisplayApp/DisplayApp.h b/src/DisplayApp/DisplayApp.h index 656dd4ed..cb5e9f3b 100644 --- a/src/DisplayApp/DisplayApp.h +++ b/src/DisplayApp/DisplayApp.h @@ -14,7 +14,6 @@ #include "LittleVgl.h" #include #include -//#include namespace Pinetime { diff --git a/src/DisplayApp/Screens/Clock.cpp b/src/DisplayApp/Screens/Clock.cpp index 3b849150..f0bd8338 100644 --- a/src/DisplayApp/Screens/Clock.cpp +++ b/src/DisplayApp/Screens/Clock.cpp @@ -15,7 +15,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { screen->OnObjectEvent(obj, event); } -Clock::Clock(DisplayApp* app, Controllers::DateTime& dateTimeController) : Screen(app), currentDateTime{{}}, version {{}}, dateTimeController{dateTimeController} { +Clock::Clock(DisplayApp* app, + Controllers::DateTime& dateTimeController, + Controllers::Battery& batteryController, + Controllers::Ble& bleController) : Screen(app), currentDateTime{{}}, version {{}}, + dateTimeController{dateTimeController}, batteryController{batteryController}, bleController{bleController} { displayedChar[0] = 0; displayedChar[1] = 0; displayedChar[2] = 0; @@ -65,12 +69,9 @@ Clock::~Clock() { lv_obj_clean(lv_scr_act()); } -bool Clock::Refresh(bool fullRefresh) { - if(fullRefresh) { - auto currentDateTime = dateTimeController.CurrentDateTime(); - } - - if (fullRefresh || batteryPercentRemaining.IsUpdated()) { +bool Clock::Refresh() { + batteryPercentRemaining = batteryController.PercentRemaining(); + if (batteryPercentRemaining.IsUpdated()) { char batteryChar[11]; auto newBatteryValue = batteryPercentRemaining.Get(); newBatteryValue = (newBatteryValue > 100) ? 100 : newBatteryValue; @@ -80,8 +81,9 @@ bool Clock::Refresh(bool fullRefresh) { lv_label_set_text(label_battery, batteryChar); } - if (fullRefresh || bleState.IsUpdated()) { - if(bleState.Get() == BleConnectionStates::Connected) { + bleState = bleController.IsConnected(); + if (bleState.IsUpdated()) { + if(bleState.Get() == true) { lv_obj_set_hidden(label_ble, false); lv_label_set_text(label_ble, "BLE"); } else { @@ -91,7 +93,7 @@ bool Clock::Refresh(bool fullRefresh) { currentDateTime = dateTimeController.CurrentDateTime(); - if(fullRefresh || currentDateTime.IsUpdated()) { + if(currentDateTime.IsUpdated()) { auto newDateTime = currentDateTime.Get(); auto dp = date::floor(newDateTime); @@ -138,7 +140,7 @@ bool Clock::Refresh(bool fullRefresh) { } } - if(fullRefresh || version.IsUpdated()) { + if(version.IsUpdated()) { auto dummy = version.Get(); char versionStr[20]; sprintf(versionStr, "VERSION: %d.%d.%d", Version::Major(), Version::Minor(), Version::Patch()); diff --git a/src/DisplayApp/Screens/Clock.h b/src/DisplayApp/Screens/Clock.h index a358e41b..d6e44fda 100644 --- a/src/DisplayApp/Screens/Clock.h +++ b/src/DisplayApp/Screens/Clock.h @@ -7,6 +7,8 @@ #include #include #include +#include +#include #include "../Fonts/lcdfont14.h" #include "../Fonts/lcdfont70.h" #include "../../Version.h" @@ -24,8 +26,10 @@ namespace Pinetime { T& Get() { this->isUpdated = false; return value; } DirtyValue& operator=(const T& other) { - this->value = other; - this->isUpdated = true; + if (this->value != other) { + this->value = other; + this->isUpdated = true; + } return *this; } private: @@ -34,17 +38,15 @@ namespace Pinetime { }; class Clock : public Screen{ public: - enum class BleConnectionStates{ NotConnected, Connected}; - Clock(DisplayApp* app, Controllers::DateTime& dateTimeController); + Clock(DisplayApp* app, + Controllers::DateTime& dateTimeController, + Controllers::Battery& batteryController, + Controllers::Ble& bleController); ~Clock() override; - bool Refresh(bool fullRefresh) override; + bool Refresh() override; bool OnButtonPushed() override; - void SetBatteryPercentRemaining(uint8_t percent) { batteryPercentRemaining = percent; } - void SetBleConnectionState(BleConnectionStates state) { bleState = state; } - void SetCurrentDateTime(const std::chrono::time_point& tp) { currentDateTime = tp;} - void OnObjectEvent(lv_obj_t *pObj, lv_event_t i); private: static const char* MonthToString(Pinetime::Controllers::DateTime::Months month); @@ -60,7 +62,7 @@ namespace Pinetime { uint8_t currentDay = 0; DirtyValue batteryPercentRemaining {0}; - DirtyValue bleState {BleConnectionStates::NotConnected}; + DirtyValue bleState {false}; DirtyValue> currentDateTime; DirtyValue version; @@ -75,6 +77,8 @@ namespace Pinetime { lv_obj_t* backgroundLabel; Controllers::DateTime& dateTimeController; + Controllers::Battery& batteryController; + Controllers::Ble& bleController; bool running = true; diff --git a/src/DisplayApp/Screens/Message.cpp b/src/DisplayApp/Screens/Message.cpp index c9e0938f..c8a4ea1f 100644 --- a/src/DisplayApp/Screens/Message.cpp +++ b/src/DisplayApp/Screens/Message.cpp @@ -19,7 +19,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { screen->OnObjectEvent(obj, event); } -Message::Message(DisplayApp* app, Pinetime::Components::Gfx &gfx) : Screen(app, gfx) { +Message::Message(DisplayApp* app) : Screen(app) { backgroundLabel = lv_label_create(lv_scr_act(), NULL); backgroundLabel->user_data = this; @@ -55,11 +55,13 @@ Message::~Message() { lv_obj_clean(lv_scr_act()); } -void Message::Refresh(bool fullRefresh) { +bool Message::Refresh() { if(previousClickCount != clickCount) { lv_label_set_text_fmt(labelClick, "%d", clickCount); previousClickCount = clickCount; } + + return running; } void Message::OnObjectEvent(lv_obj_t *obj, lv_event_t event) { @@ -79,3 +81,8 @@ void Message::OnObjectEvent(lv_obj_t *obj, lv_event_t event) { NRF_LOG_INFO("Toggled"); } } + +bool Message::OnButtonPushed() { + running = false; + return true; +} diff --git a/src/DisplayApp/Screens/Message.h b/src/DisplayApp/Screens/Message.h index 2f1da942..4e87bba4 100644 --- a/src/DisplayApp/Screens/Message.h +++ b/src/DisplayApp/Screens/Message.h @@ -15,15 +15,13 @@ namespace Pinetime { namespace Screens { class Message : public Screen{ public: - explicit Message(DisplayApp* app, Components::Gfx& gfx); + explicit Message(DisplayApp* app); ~Message() override; - void Refresh(bool fullRefresh) override; + bool Refresh() override; + bool OnButtonPushed(); void OnObjectEvent(lv_obj_t* obj, lv_event_t event); - void OnButtonPushed() override { nextScreen = Screen::NextScreen::Menu; } private: - const FONT_INFO largeFont {lCD_70ptFontInfo.height, lCD_70ptFontInfo.startChar, lCD_70ptFontInfo.endChar, lCD_70ptFontInfo.spacePixels, lCD_70ptFontInfo.charInfo, lCD_70ptFontInfo.data}; - const FONT_INFO smallFont {lCD_14ptFontInfo.height, lCD_14ptFontInfo.startChar, lCD_14ptFontInfo.endChar, lCD_14ptFontInfo.spacePixels, lCD_14ptFontInfo.charInfo, lCD_14ptFontInfo.data}; lv_style_t* labelStyle; lv_obj_t * label; @@ -33,6 +31,7 @@ namespace Pinetime { uint32_t clickCount = 0 ; uint32_t previousClickCount = 0; + bool running = true; }; } } diff --git a/src/DisplayApp/Screens/Screen.h b/src/DisplayApp/Screens/Screen.h index 625daada..6cbd41ad 100644 --- a/src/DisplayApp/Screens/Screen.h +++ b/src/DisplayApp/Screens/Screen.h @@ -1,20 +1,16 @@ #pragma once -#include - namespace Pinetime { namespace Applications { class DisplayApp; namespace Screens { class Screen { public: - enum class NextScreen {None, Clock, Menu, App}; - Screen(DisplayApp* app) : app{app} {} virtual ~Screen() = default; // Return false if the app can be closed, true if it must continue to run - virtual bool Refresh(bool fullRefresh) = 0; + virtual bool Refresh() = 0; // Return false if the button hasn't been handled by the app, true if it has been handled virtual bool OnButtonPushed() { return false; } diff --git a/src/DisplayApp/Screens/Tile.cpp b/src/DisplayApp/Screens/Tile.cpp index c9e33544..6ee677dc 100644 --- a/src/DisplayApp/Screens/Tile.cpp +++ b/src/DisplayApp/Screens/Tile.cpp @@ -1,14 +1,8 @@ -#include -#include -#include -#include #include #include #include -#include #include "Tile.h" #include -#include using namespace Pinetime::Applications::Screens; @@ -17,7 +11,9 @@ extern lv_font_t jetbrains_mono_bold_20; static void event_handler(lv_obj_t * obj, lv_event_t event) { Tile* screen = static_cast(obj->user_data); - screen->OnObjectEvent(obj, event); + uint32_t* eventDataPtr = (uint32_t*) lv_event_get_data(); + uint32_t eventData = *eventDataPtr; + screen->OnObjectEvent(obj, event, eventData); } static const char * btnm_map1[] = {"App1", "App2", "App3", "\n", "App4", "App5", "App11", ""}; @@ -104,19 +100,28 @@ Tile::~Tile() { lv_obj_clean(lv_scr_act()); } -bool Tile::Refresh(bool fullRefresh) { +bool Tile::Refresh() { return running; } -void Tile::OnObjectEvent(lv_obj_t *obj, lv_event_t event) { +void Tile::OnObjectEvent(lv_obj_t *obj, lv_event_t event, uint32_t buttonId) { auto* tile = static_cast(obj->user_data); - if(event == LV_EVENT_CLICKED) { - - tile->StartApp(); + if(event == LV_EVENT_VALUE_CHANGED) { + switch(buttonId) { + case 0: + case 1: + case 2: + tile->StartClockApp(); + break; + case 3: + case 4: + case 5: + tile->StartTestApp(); + + break; + } clickCount++; } - else if(event == LV_EVENT_VALUE_CHANGED) { - } } bool Tile::OnButtonPushed() { @@ -125,7 +130,12 @@ bool Tile::OnButtonPushed() { return true; } -void Tile::StartApp() { +void Tile::StartClockApp() { app->StartApp(DisplayApp::Apps::Clock); running = false; } + +void Tile::StartTestApp() { + app->StartApp(DisplayApp::Apps::Test); + running = false; +} diff --git a/src/DisplayApp/Screens/Tile.h b/src/DisplayApp/Screens/Tile.h index 03cfb6d2..630fc666 100644 --- a/src/DisplayApp/Screens/Tile.h +++ b/src/DisplayApp/Screens/Tile.h @@ -18,10 +18,10 @@ namespace Pinetime { explicit Tile(DisplayApp* app); ~Tile() override; - bool Refresh(bool fullRefresh) override; + bool Refresh() override; bool OnButtonPushed() override; - void OnObjectEvent(lv_obj_t* obj, lv_event_t event); + void OnObjectEvent(lv_obj_t* obj, lv_event_t event, uint32_t buttonId); private: @@ -50,7 +50,8 @@ namespace Pinetime { uint32_t clickCount = 0 ; uint32_t previousClickCount = 0; - void StartApp(); + void StartClockApp(); + void StartTestApp(); bool running = true; }; } diff --git a/src/SystemTask/SystemTask.cpp b/src/SystemTask/SystemTask.cpp index 642e36a2..91822fa2 100644 --- a/src/SystemTask/SystemTask.cpp +++ b/src/SystemTask/SystemTask.cpp @@ -3,6 +3,8 @@ #include #include #include +#include +#include #include "SystemTask.h" #include "../main.h" using namespace Pinetime::System; @@ -16,7 +18,7 @@ SystemTask::SystemTask(Pinetime::Drivers::SpiMaster &spi, Pinetime::Drivers::St7 } void SystemTask::Start() { - if (pdPASS != xTaskCreate(SystemTask::Process, "MAIN", 256, this, 0, &taskHandle)) + if (pdPASS != xTaskCreate(SystemTask::Process, "MAIN", 350, this, 0, &taskHandle)) APP_ERROR_HANDLER(NRF_ERROR_NO_MEM); } @@ -29,7 +31,7 @@ void SystemTask::Process(void *instance) { void SystemTask::Work() { APP_GPIOTE_INIT(2); bool erase_bonds=false; -// nrf_sdh_freertos_init(ble_manager_start_advertising, &erase_bonds); + nrf_sdh_freertos_init(ble_manager_start_advertising, &erase_bonds); spi.Init(); lcd.Init(); diff --git a/src/main.cpp b/src/main.cpp index 08b15f62..6a271a49 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,25 +1,19 @@ #include #include -#include #include #include #include #include #include -#include #include #include -#include #include #include #include "BLE/BleManager.h" #include "Components/Battery/BatteryController.h" #include "Components/Ble/BleController.h" -#include "../drivers/Cst816s.h" #include #include - -#include #include #include @@ -134,12 +128,11 @@ int main(void) { systemTask.reset(new Pinetime::System::SystemTask(*spi, *lcd, *touchPanel, *lvgl, batteryController, bleController, dateTimeController)); systemTask->Start(); -/* ble_manager_init(); ble_manager_set_new_time_callback(OnNewTime); ble_manager_set_ble_connection_callback(OnBleConnection); ble_manager_set_ble_disconnection_callback(OnBleDisconnection); -*/ + vTaskStartScheduler(); for (;;) { -- cgit v1.2.3-70-g09d2 From 179b14f48c2c7506d1a7832899e134cc3868a41c Mon Sep 17 00:00:00 2001 From: JF Date: Wed, 26 Feb 2020 20:49:26 +0100 Subject: Add new Screens (gauge, meter,...) --- src/CMakeLists.txt | 17 +++++++++ src/DisplayApp/DisplayApp.cpp | 4 +++ src/DisplayApp/DisplayApp.h | 2 +- src/DisplayApp/Screens/Gauge.cpp | 57 +++++++++++++++++++++++++++++ src/DisplayApp/Screens/Gauge.h | 39 ++++++++++++++++++++ src/DisplayApp/Screens/Meter.cpp | 47 ++++++++++++++++++++++++ src/DisplayApp/Screens/Meter.h | 38 ++++++++++++++++++++ src/DisplayApp/Screens/Modal.cpp | 77 ++++++++++++++++++++++++++++++++++++++++ src/DisplayApp/Screens/Modal.h | 44 +++++++++++++++++++++++ src/DisplayApp/Screens/Tile.cpp | 21 ++++++++++- src/DisplayApp/Screens/Tile.h | 5 +++ src/SystemTask/SystemTask.cpp | 2 +- src/main.cpp | 8 ++--- 13 files changed, 354 insertions(+), 7 deletions(-) create mode 100644 src/DisplayApp/Screens/Gauge.cpp create mode 100644 src/DisplayApp/Screens/Gauge.h create mode 100644 src/DisplayApp/Screens/Meter.cpp create mode 100644 src/DisplayApp/Screens/Meter.h create mode 100644 src/DisplayApp/Screens/Modal.cpp create mode 100644 src/DisplayApp/Screens/Modal.h (limited to 'src/DisplayApp/DisplayApp.cpp') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6b5c5741..ac19cf09 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -48,6 +48,8 @@ set(LVGL_SRC libs/lvgl/src/lv_misc/lv_anim.c libs/lvgl/src/lv_misc/lv_anim.h + libs/lvgl/src/lv_misc/lv_async.h + libs/lvgl/src/lv_misc/lv_async.c libs/lvgl/src/lv_misc/lv_fs.c libs/lvgl/src/lv_misc/lv_fs.h libs/lvgl/src/lv_misc/lv_task.c @@ -149,6 +151,15 @@ set(LVGL_SRC libs/lvgl/src/lv_objx/lv_page.h libs/lvgl/src/lv_objx/lv_img.c libs/lvgl/src/lv_objx/lv_img.h + libs/lvgl/src/lv_objx/lv_lmeter.c + libs/lvgl/src/lv_objx/lv_lmeter.h + libs/lvgl/src/lv_objx/lv_arc.c + libs/lvgl/src/lv_objx/lv_arc.h + libs/lvgl/src/lv_objx/lv_gauge.c + libs/lvgl/src/lv_objx/lv_gauge.h + + libs/lvgl/src/lv_objx/lv_mbox.c + libs/lvgl/src/lv_objx/lv_mbox.h ) @@ -160,6 +171,9 @@ list(APPEND SOURCE_FILES DisplayApp/Screens/Clock.cpp DisplayApp/Screens/Message.cpp DisplayApp/Screens/Tile.cpp + DisplayApp/Screens/Meter.cpp + DisplayApp/Screens/Gauge.cpp + DisplayApp/Screens/Modal.cpp main.cpp drivers/St7789.cpp drivers/SpiMaster.cpp @@ -190,6 +204,9 @@ set(INCLUDE_FILES DisplayApp/Screens/Clock.h DisplayApp/Screens/Message.h DisplayApp/Screens/Tile.h + DisplayApp/Screens/Meter.h + DisplayApp/Screens/Gauge.h + DisplayApp/Screens/Modal.h # DisplayApp/Screens/Tab.h drivers/St7789.h drivers/SpiMaster.h diff --git a/src/DisplayApp/DisplayApp.cpp b/src/DisplayApp/DisplayApp.cpp index 1a794e04..2519f40e 100644 --- a/src/DisplayApp/DisplayApp.cpp +++ b/src/DisplayApp/DisplayApp.cpp @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include "../SystemTask/SystemTask.h" using namespace Pinetime::Applications; @@ -130,6 +132,8 @@ void DisplayApp::RunningState() { case Apps::Launcher: currentScreen.reset(new Screens::Tile(this)); break; case Apps::Clock: currentScreen.reset(new Screens::Clock(this, dateTimeController, batteryController, bleController)); break; case Apps::Test: currentScreen.reset(new Screens::Message(this)); break; + case Apps::Meter: currentScreen.reset(new Screens::Meter(this)); break; + case Apps::Gauge: currentScreen.reset(new Screens::Gauge(this)); break; } nextApp = Apps::None; } diff --git a/src/DisplayApp/DisplayApp.h b/src/DisplayApp/DisplayApp.h index cb5e9f3b..348fd5bf 100644 --- a/src/DisplayApp/DisplayApp.h +++ b/src/DisplayApp/DisplayApp.h @@ -35,7 +35,7 @@ namespace Pinetime { void Start(); void PushMessage(Messages msg); - enum class Apps {None, Launcher, Clock, Test}; + enum class Apps {None, Launcher, Clock, Test, Meter, Gauge}; void StartApp(Apps app); private: diff --git a/src/DisplayApp/Screens/Gauge.cpp b/src/DisplayApp/Screens/Gauge.cpp new file mode 100644 index 00000000..33f76a74 --- /dev/null +++ b/src/DisplayApp/Screens/Gauge.cpp @@ -0,0 +1,57 @@ +#include +#include "Gauge.h" +#include "../DisplayApp.h" + +using namespace Pinetime::Applications::Screens; +extern lv_font_t jetbrains_mono_extrabold_compressedextrabold_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(), NULL); + 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, NULL, 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; +} diff --git a/src/DisplayApp/Screens/Gauge.h b/src/DisplayApp/Screens/Gauge.h new file mode 100644 index 00000000..463654ee --- /dev/null +++ b/src/DisplayApp/Screens/Gauge.h @@ -0,0 +1,39 @@ +#pragma once + +#include +#include +#include +#include "Screen.h" +#include +#include +#include +#include +#include +#include "../Fonts/lcdfont14.h" +#include "../Fonts/lcdfont70.h" +#include "../../Version.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; + + }; + } + } +} diff --git a/src/DisplayApp/Screens/Meter.cpp b/src/DisplayApp/Screens/Meter.cpp new file mode 100644 index 00000000..9daafad3 --- /dev/null +++ b/src/DisplayApp/Screens/Meter.cpp @@ -0,0 +1,47 @@ +#include +#include "Meter.h" +#include "../DisplayApp.h" + +using namespace Pinetime::Applications::Screens; +extern lv_font_t jetbrains_mono_extrabold_compressedextrabold_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(), NULL); + 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); + lv_obj_align(lmeter, NULL, LV_ALIGN_CENTER, 0, 0); + +} + +Meter::~Meter() { + + + lv_obj_clean(lv_scr_act()); +} + +bool Meter::Refresh() { + lv_lmeter_set_value(lmeter, value++); /*Set the current value*/ + if(value>=60) value = 0; + + return running; +} + +bool Meter::OnButtonPushed() { + running = false; + return true; +} diff --git a/src/DisplayApp/Screens/Meter.h b/src/DisplayApp/Screens/Meter.h new file mode 100644 index 00000000..1a08b46c --- /dev/null +++ b/src/DisplayApp/Screens/Meter.h @@ -0,0 +1,38 @@ +#pragma once + +#include +#include +#include +#include "Screen.h" +#include +#include +#include +#include +#include +#include "../Fonts/lcdfont14.h" +#include "../Fonts/lcdfont70.h" +#include "../../Version.h" + +namespace Pinetime { + namespace Applications { + namespace Screens { + + class Meter : public Screen{ + public: + Meter(DisplayApp* app); + ~Meter() override; + + bool Refresh() override; + bool OnButtonPushed() override; + + private: + lv_style_t style_lmeter; + lv_obj_t * lmeter; + + uint32_t value=0; + bool running = true; + + }; + } + } +} diff --git a/src/DisplayApp/Screens/Modal.cpp b/src/DisplayApp/Screens/Modal.cpp new file mode 100644 index 00000000..a1b955cf --- /dev/null +++ b/src/DisplayApp/Screens/Modal.cpp @@ -0,0 +1,77 @@ +#include +#include "Modal.h" +#include "../DisplayApp.h" + +using namespace Pinetime::Applications::Screens; +extern lv_font_t jetbrains_mono_extrabold_compressedextrabold_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::Show() { + 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(), NULL); + 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", "Cancel", ""}; + + /* Create the message box as a child of the modal background */ + mbox = lv_mbox_create(obj, NULL); + lv_mbox_add_btns(mbox, btns2); + lv_mbox_set_text(mbox, "Hello world!"); + lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_set_event_cb(mbox, Modal::mbox_event_cb); + + /* 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); +} + +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! */ +} + +void Modal::mbox_event_cb(lv_obj_t *obj, lv_event_t evt) { + auto* m = static_cast(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) { + /* Delete the parent modal background */ + lv_obj_del_async(lv_obj_get_parent(mbox)); + mbox = NULL; /* happens before object is actually deleted! */ + } else if(evt == LV_EVENT_VALUE_CHANGED) { + /* A button was clicked */ + lv_mbox_start_auto_close(mbox, 100); + } +} diff --git a/src/DisplayApp/Screens/Modal.h b/src/DisplayApp/Screens/Modal.h new file mode 100644 index 00000000..de287293 --- /dev/null +++ b/src/DisplayApp/Screens/Modal.h @@ -0,0 +1,44 @@ +#pragma once + +#include +#include +#include +#include "Screen.h" +#include +#include +#include +#include +#include +#include "../Fonts/lcdfont14.h" +#include "../Fonts/lcdfont70.h" +#include "../../Version.h" + +namespace Pinetime { + namespace Applications { + namespace Screens { + + class Modal : public Screen{ + public: + Modal(DisplayApp* app); + ~Modal() override; + + void Show(); + 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; + + }; + } + } +} diff --git a/src/DisplayApp/Screens/Tile.cpp b/src/DisplayApp/Screens/Tile.cpp index 6ee677dc..1c85aa1d 100644 --- a/src/DisplayApp/Screens/Tile.cpp +++ b/src/DisplayApp/Screens/Tile.cpp @@ -16,9 +16,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { screen->OnObjectEvent(obj, event, eventData); } -static const char * btnm_map1[] = {"App1", "App2", "App3", "\n", "App4", "App5", "App11", ""}; +static const char * btnm_map1[] = {"Meter", "Gauge", "Clock", "\n", "App4", "App5", "App11", ""}; Tile::Tile(DisplayApp* app) : Screen(app) { + modal.reset(new Modal(app)); + static lv_point_t valid_pos[] = {{0,0}, {LV_COORD_MIN, LV_COORD_MIN}}; tileview = lv_tileview_create(lv_scr_act(), NULL); lv_tileview_set_valid_positions(tileview, valid_pos, 1); @@ -109,11 +111,17 @@ void Tile::OnObjectEvent(lv_obj_t *obj, lv_event_t event, uint32_t buttonId) { if(event == LV_EVENT_VALUE_CHANGED) { switch(buttonId) { case 0: + tile->StartMeterApp(); + break; case 1: + tile->StartGaugeApp(); + break; case 2: tile->StartClockApp(); break; case 3: + modal->Show(); + break; case 4: case 5: tile->StartTestApp(); @@ -139,3 +147,14 @@ void Tile::StartTestApp() { app->StartApp(DisplayApp::Apps::Test); running = false; } + +void Tile::StartMeterApp() { + app->StartApp(DisplayApp::Apps::Meter); + running = false; +} + +void Tile::StartGaugeApp() { + app->StartApp(DisplayApp::Apps::Gauge); + running = false; +} + diff --git a/src/DisplayApp/Screens/Tile.h b/src/DisplayApp/Screens/Tile.h index 630fc666..eb253435 100644 --- a/src/DisplayApp/Screens/Tile.h +++ b/src/DisplayApp/Screens/Tile.h @@ -8,6 +8,7 @@ #include "../Fonts/lcdfont14.h" #include "../Fonts/lcdfont70.h" #include "../../Version.h" +#include "Modal.h" #include namespace Pinetime { @@ -52,7 +53,11 @@ namespace Pinetime { uint32_t previousClickCount = 0; void StartClockApp(); void StartTestApp(); + void StartMeterApp(); + void StartGaugeApp(); bool running = true; + + std::unique_ptr modal; }; } } diff --git a/src/SystemTask/SystemTask.cpp b/src/SystemTask/SystemTask.cpp index e15846da..5a3d9ca6 100644 --- a/src/SystemTask/SystemTask.cpp +++ b/src/SystemTask/SystemTask.cpp @@ -34,7 +34,7 @@ void SystemTask::Work() { NRF_LOG_INFO("Last reset reason : %s", Pinetime::Drivers::Watchdog::ResetReasonToString(watchdog.ResetReason())); APP_GPIOTE_INIT(2); bool erase_bonds=false; - nrf_sdh_freertos_init(ble_manager_start_advertising, &erase_bonds); +// nrf_sdh_freertos_init(ble_manager_start_advertising, &erase_bonds); spi.Init(); lcd.Init(); diff --git a/src/main.cpp b/src/main.cpp index 6a271a49..5a9df6cb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -128,10 +128,10 @@ int main(void) { systemTask.reset(new Pinetime::System::SystemTask(*spi, *lcd, *touchPanel, *lvgl, batteryController, bleController, dateTimeController)); systemTask->Start(); - ble_manager_init(); - ble_manager_set_new_time_callback(OnNewTime); - ble_manager_set_ble_connection_callback(OnBleConnection); - ble_manager_set_ble_disconnection_callback(OnBleDisconnection); +// ble_manager_init(); +// ble_manager_set_new_time_callback(OnNewTime); +// ble_manager_set_ble_connection_callback(OnBleConnection); +// ble_manager_set_ble_disconnection_callback(OnBleDisconnection); vTaskStartScheduler(); -- cgit v1.2.3-70-g09d2 From e285ba9972fc2e0c74457b01db28dba9cb88c4e2 Mon Sep 17 00:00:00 2001 From: JF Date: Sun, 1 Mar 2020 15:57:58 +0100 Subject: Fix double-buffering for spi display (it's actually using double-buffering, now) --- src/DisplayApp/DisplayApp.cpp | 3 +++ src/DisplayApp/LittleVgl.cpp | 2 ++ 2 files changed, 5 insertions(+) (limited to 'src/DisplayApp/DisplayApp.cpp') diff --git a/src/DisplayApp/DisplayApp.cpp b/src/DisplayApp/DisplayApp.cpp index 2519f40e..316312ed 100644 --- a/src/DisplayApp/DisplayApp.cpp +++ b/src/DisplayApp/DisplayApp.cpp @@ -45,6 +45,9 @@ void DisplayApp::Process(void *instance) { NRF_LOG_INFO("DisplayApp task started!"); app->InitHw(); + // Send a dummy notification to unlock the lvgl display driver for the first iteration + xTaskNotifyGive(xTaskGetCurrentTaskHandle()); + while (1) { app->Refresh(); diff --git a/src/DisplayApp/LittleVgl.cpp b/src/DisplayApp/LittleVgl.cpp index 50744acc..95794546 100644 --- a/src/DisplayApp/LittleVgl.cpp +++ b/src/DisplayApp/LittleVgl.cpp @@ -62,6 +62,8 @@ void LittleVgl::InitTouchpad() { } void LittleVgl::FlushDisplay(const lv_area_t *area, lv_color_t *color_p) { + ulTaskNotifyTake(pdTRUE, 500); + auto x = area->x1; auto y = area->y1; auto width = (area->x2-area->x1)+1; -- cgit v1.2.3-70-g09d2 From 5bc0640b735573b465cfef16fb729ad5f5149eb4 Mon Sep 17 00:00:00 2001 From: JF Date: Sun, 1 Mar 2020 19:09:59 +0100 Subject: Fix typo in the name of the font "jetbrains_mono_extrabold_compressed" + use it as the default font. --- src/DisplayApp/DisplayApp.cpp | 11 +++++++++++ src/DisplayApp/Fonts/jetbrains_mono_extrabold_compressed.c | 10 +++++----- src/DisplayApp/LittleVgl.cpp | 8 ++++++-- src/DisplayApp/Screens/Clock.cpp | 4 ++-- src/DisplayApp/Screens/Gauge.cpp | 2 +- src/DisplayApp/Screens/Meter.cpp | 2 +- src/DisplayApp/Screens/Modal.cpp | 2 +- 7 files changed, 27 insertions(+), 12 deletions(-) (limited to 'src/DisplayApp/DisplayApp.cpp') diff --git a/src/DisplayApp/DisplayApp.cpp b/src/DisplayApp/DisplayApp.cpp index 316312ed..d7d62dde 100644 --- a/src/DisplayApp/DisplayApp.cpp +++ b/src/DisplayApp/DisplayApp.cpp @@ -120,6 +120,17 @@ void DisplayApp::Refresh() { if(!currentScreen->OnButtonPushed()) { systemTask.PushMessage(System::SystemTask::Messages::GoToSleep); } +// currentScreen.reset(nullptr); +// if(toggle) { +// modal.Show(); +//// currentScreen.reset(new Screens::Tile(this)); +// toggle = false; +// } else { +// modal.Hide(); +//// currentScreen.reset(new Screens::Clock(this, dateTimeController, batteryController, bleController)); +// toggle = true; +// } + break; } } diff --git a/src/DisplayApp/Fonts/jetbrains_mono_extrabold_compressed.c b/src/DisplayApp/Fonts/jetbrains_mono_extrabold_compressed.c index c850cd91..c9917e40 100644 --- a/src/DisplayApp/Fonts/jetbrains_mono_extrabold_compressed.c +++ b/src/DisplayApp/Fonts/jetbrains_mono_extrabold_compressed.c @@ -6,11 +6,11 @@ * Opts: ******************************************************************************/ -#ifndef JETBRAINS_MONO_EXTRABOLD_COMPRESSEDEXTRABOLD_COMPRESSED -#define JETBRAINS_MONO_EXTRABOLD_COMPRESSEDEXTRABOLD_COMPRESSED 1 +#ifndef JETBRAINS_MONO_EXTRABOLD_COMPRESSED +#define JETBRAINS_MONO_EXTRABOLD_COMPRESSED 1 #endif -#if JETBRAINS_MONO_EXTRABOLD_COMPRESSEDEXTRABOLD_COMPRESSED +#if JETBRAINS_MONO_EXTRABOLD_COMPRESSED /*----------------- * BITMAPS @@ -492,7 +492,7 @@ static lv_font_fmt_txt_dsc_t font_dsc = { *----------------*/ /*Initialize a public general font descriptor*/ -lv_font_t jetbrains_mono_extrabold_compressedextrabold_compressed = { +lv_font_t jetbrains_mono_extrabold_compressed = { .get_glyph_dsc = lv_font_get_glyph_dsc_fmt_txt, /*Function pointer to get glyph's data*/ .get_glyph_bitmap = lv_font_get_bitmap_fmt_txt, /*Function pointer to get glyph's bitmap*/ .line_height = 60, /*The maximum line height required by the font*/ @@ -503,5 +503,5 @@ lv_font_t jetbrains_mono_extrabold_compressedextrabold_compressed = { .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ }; -#endif /*#if JETBRAINS_MONO_EXTRABOLD_COMPRESSEDEXTRABOLD_COMPRESSED*/ +#endif /*#if JETBRAINS_MONO_EXTRABOLD_COMPRESSED*/ diff --git a/src/DisplayApp/LittleVgl.cpp b/src/DisplayApp/LittleVgl.cpp index c4fa1793..59334931 100644 --- a/src/DisplayApp/LittleVgl.cpp +++ b/src/DisplayApp/LittleVgl.cpp @@ -12,6 +12,11 @@ using namespace Pinetime::Components; +extern "C" { +LV_FONT_DECLARE(jetbrains_mono_extrabold_compressed) +LV_FONT_DECLARE(jetbrains_mono_bold_20) +} + static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p) { auto* lvgl = static_cast(disp_drv->user_data); lvgl->FlushDisplay(area, color_p); @@ -135,8 +140,7 @@ void LittleVgl::InitTheme() { } void LittleVgl::InitBaseTheme() { - if(font == nullptr) font = LV_FONT_DEFAULT; - + if(font == nullptr) font = &jetbrains_mono_bold_20; lv_style_copy(&def, &lv_style_plain); /*Initialize the default style*/ def.text.font = font; diff --git a/src/DisplayApp/Screens/Clock.cpp b/src/DisplayApp/Screens/Clock.cpp index f0bd8338..1dff88c2 100644 --- a/src/DisplayApp/Screens/Clock.cpp +++ b/src/DisplayApp/Screens/Clock.cpp @@ -7,7 +7,7 @@ #include "../DisplayApp.h" using namespace Pinetime::Applications::Screens; -extern lv_font_t jetbrains_mono_extrabold_compressedextrabold_compressed; +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) { @@ -33,7 +33,7 @@ Clock::Clock(DisplayApp* app, labelStyle->text.font = &jetbrains_mono_bold_20; lv_style_copy(&labelBigStyle, labelStyle); - labelBigStyle.text.font = &jetbrains_mono_extrabold_compressedextrabold_compressed; + labelBigStyle.text.font = &jetbrains_mono_extrabold_compressed; lv_label_set_style(label_battery, LV_LABEL_STYLE_MAIN, labelStyle); diff --git a/src/DisplayApp/Screens/Gauge.cpp b/src/DisplayApp/Screens/Gauge.cpp index 33f76a74..4c4cccd9 100644 --- a/src/DisplayApp/Screens/Gauge.cpp +++ b/src/DisplayApp/Screens/Gauge.cpp @@ -3,7 +3,7 @@ #include "../DisplayApp.h" using namespace Pinetime::Applications::Screens; -extern lv_font_t jetbrains_mono_extrabold_compressedextrabold_compressed; +extern lv_font_t jetbrains_mono_extrabold_compressed; extern lv_font_t jetbrains_mono_bold_20; diff --git a/src/DisplayApp/Screens/Meter.cpp b/src/DisplayApp/Screens/Meter.cpp index 9daafad3..c74b8bdf 100644 --- a/src/DisplayApp/Screens/Meter.cpp +++ b/src/DisplayApp/Screens/Meter.cpp @@ -3,7 +3,7 @@ #include "../DisplayApp.h" using namespace Pinetime::Applications::Screens; -extern lv_font_t jetbrains_mono_extrabold_compressedextrabold_compressed; +extern lv_font_t jetbrains_mono_extrabold_compressed; extern lv_font_t jetbrains_mono_bold_20; diff --git a/src/DisplayApp/Screens/Modal.cpp b/src/DisplayApp/Screens/Modal.cpp index 13bd42fa..7a0264e3 100644 --- a/src/DisplayApp/Screens/Modal.cpp +++ b/src/DisplayApp/Screens/Modal.cpp @@ -3,7 +3,7 @@ #include "../DisplayApp.h" using namespace Pinetime::Applications::Screens; -extern lv_font_t jetbrains_mono_extrabold_compressedextrabold_compressed; +extern lv_font_t jetbrains_mono_extrabold_compressed; extern lv_font_t jetbrains_mono_bold_20; Modal::Modal(Pinetime::Applications::DisplayApp *app) : Screen(app) { -- cgit v1.2.3-70-g09d2