diff options
40 files changed, 1486 insertions, 280 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ff5eb1d..6f42c9f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -509,12 +509,7 @@ list(APPEND SOURCE_FILES FreeRTOS/port_cmsis.c displayapp/LittleVgl.cpp - displayapp/fonts/jetbrains_mono_extrabold_compressed.c - displayapp/fonts/jetbrains_mono_bold_20.c - displayapp/fonts/jetbrains_mono_76.c - displayapp/fonts/jetbrains_mono_42.c - displayapp/fonts/lv_font_sys_48.c - displayapp/fonts/open_sans_light.c + displayapp/fonts/neofont.c displayapp/lv_pinetime_theme.c systemtask/SystemTask.cpp diff --git a/src/FreeRTOSConfig.h b/src/FreeRTOSConfig.h index 263d803..f9c6b6c 100644 --- a/src/FreeRTOSConfig.h +++ b/src/FreeRTOSConfig.h @@ -54,7 +54,7 @@ #define configTICK_SOURCE FREERTOS_USE_RTC -#define configUSE_PREEMPTION 1 +#define configUSE_PREEMPTION 0 #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 #define configUSE_TICKLESS_IDLE 1 #define configUSE_TICKLESS_IDLE_SIMPLE_DEBUG 0 /* See into vPortSuppressTicksAndSleep source code for explanation */ diff --git a/src/components/datetime/DateTimeController.cpp b/src/components/datetime/DateTimeController.cpp index 3bfbdc7..fbaa01b 100644 --- a/src/components/datetime/DateTimeController.cpp +++ b/src/components/datetime/DateTimeController.cpp @@ -14,7 +14,7 @@ namespace { DateTime::DateTime(Controllers::Settings& settingsController) : settingsController {settingsController} { } -void DateTime::SetCurrentTime(std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> t) { +void DateTime::SetCurrentTime(std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds> t) { this->currentDateTime = t; UpdateTime(previousSystickCounter); // Update internal state without updating the time } @@ -30,7 +30,7 @@ void DateTime::SetTime( /* .tm_year = */ year - 1900, }; tm.tm_isdst = -1; // Use DST value from local time zone - currentDateTime = std::chrono::system_clock::from_time_t(std::mktime(&tm)); + currentDateTime = std::chrono::time_point_cast<std::chrono::seconds>(std::chrono::system_clock::from_time_t(std::mktime(&tm))); NRF_LOG_INFO("%d %d %d ", day, month, year); NRF_LOG_INFO("%d %d %d ", hour, minute, second); @@ -45,27 +45,20 @@ void DateTime::SetTime( void DateTime::UpdateTime(uint32_t systickCounter) { // Handle systick counter overflow - uint32_t systickDelta = 0; - if (systickCounter < previousSystickCounter) { - systickDelta = 0xffffff - previousSystickCounter; - systickDelta += systickCounter + 1; - } else { - systickDelta = systickCounter - previousSystickCounter; - } + uint32_t systickDelta = (systickCounter - previousSystickCounter) & 0xffffff; + previousSystickCounter = systickCounter; /* * 1000 ms = 1024 ticks */ - auto correctedDelta = systickDelta / 1024; - auto rest = (systickDelta - (correctedDelta * 1024)); - if (systickCounter >= rest) { - previousSystickCounter = systickCounter - rest; - } else { - previousSystickCounter = 0xffffff - (rest - systickCounter); - } - - currentDateTime += std::chrono::seconds(correctedDelta); - uptime += std::chrono::seconds(correctedDelta); + // auto newSeconds = systickDelta >> 10; + // auto rest = systickDelta & ((1 << 10)-1); + subsecondTicks += systickDelta & ((1 << 10)-1); + systickDelta = (systickDelta >> 10) + (subsecondTicks >> 10); + subsecondTicks &= ((1 << 10)-1); + + currentDateTime += std::chrono::seconds(systickDelta); + uptime += std::chrono::seconds(systickDelta); auto dp = date::floor<date::days>(currentDateTime); auto time = date::make_time(currentDateTime - dp); diff --git a/src/components/datetime/DateTimeController.h b/src/components/datetime/DateTimeController.h index 00bbc2e..cf9d52c 100644 --- a/src/components/datetime/DateTimeController.h +++ b/src/components/datetime/DateTimeController.h @@ -65,7 +65,7 @@ namespace Pinetime { const char* DayOfWeekShortToString() const; static const char* MonthShortToStringLow(Months month); - std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> CurrentDateTime() const { + std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds> CurrentDateTime() const { return currentDateTime; } std::chrono::seconds Uptime() const { @@ -73,7 +73,7 @@ namespace Pinetime { } void Register(System::SystemTask* systemTask); - void SetCurrentTime(std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> t); + void SetCurrentTime(std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds> t); std::string FormattedTime(); private: @@ -84,9 +84,10 @@ namespace Pinetime { uint8_t hour = 0; uint8_t minute = 0; uint8_t second = 0; + uint16_t subsecondTicks = 0; - uint32_t previousSystickCounter = 0; - std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> currentDateTime; + uint32_t previousSystickCounter = 0; // FIXME: This could probably be 16 bits? + std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds> currentDateTime; std::chrono::seconds uptime {0}; bool isMidnightAlreadyNotified = false; diff --git a/src/components/motion/MotionController.cpp b/src/components/motion/MotionController.cpp index 7dd3212..c57d8aa 100644 --- a/src/components/motion/MotionController.cpp +++ b/src/components/motion/MotionController.cpp @@ -11,6 +11,7 @@ void MotionController::Update(int16_t x, int16_t y, int16_t z, uint32_t nbSteps) service->OnNewMotionValues(x, y, z); } + lastY = this->y; this->x = x; this->y = y; this->z = z; @@ -21,27 +22,8 @@ void MotionController::Update(int16_t x, int16_t y, int16_t z, uint32_t nbSteps) } } -bool MotionController::Should_RaiseWake(bool isSleeping) { - if ((x + 335) <= 670 && z < 0) { - if (not isSleeping) { - if (y <= 0) { - return false; - } else { - lastYForWakeUp = 0; - return false; - } - } - - if (y >= 0) { - lastYForWakeUp = 0; - return false; - } - if (y + 230 < lastYForWakeUp) { - lastYForWakeUp = y; - return true; - } - } - return false; +bool MotionController::ShouldRaiseWake() const { + return x >= -384 && x <= 384 && z <= 0 && y <= -160 && y <= lastY - 160; } bool MotionController::Should_ShakeWake(uint16_t thresh) { @@ -66,6 +48,10 @@ int32_t MotionController::currentShakeSpeed() { return accumulatedspeed; } +bool MotionController::ShouldLowerSleep() const { + return y >= 512 && y >= lastY + 192; +} + void MotionController::IsSensorOk(bool isOk) { isSensorOk = isOk; } diff --git a/src/components/motion/MotionController.h b/src/components/motion/MotionController.h index f80b11b..297db59 100644 --- a/src/components/motion/MotionController.h +++ b/src/components/motion/MotionController.h @@ -25,6 +25,9 @@ namespace Pinetime { int16_t Z() const { return z; } + int16_t LastY() const { + return lastY; + } uint32_t NbSteps() const { return nbSteps; } @@ -36,9 +39,10 @@ namespace Pinetime { return currentTripSteps; } + bool ShouldRaiseWake() const; bool Should_ShakeWake(uint16_t thresh); - bool Should_RaiseWake(bool isSleeping); int32_t currentShakeSpeed(); + bool ShouldLowerSleep() const; void IsSensorOk(bool isOk); bool IsSensorOk() const { return isSensorOk; @@ -54,9 +58,10 @@ namespace Pinetime { private: uint32_t nbSteps; uint32_t currentTripSteps = 0; - int16_t x; - int16_t y; - int16_t z; + int16_t x = 0; + int16_t y = 0; + int16_t z = 0; + int16_t lastY = 0; int16_t lastYForWakeUp = 0; bool isSensorOk = false; DeviceTypes deviceType = DeviceTypes::Unknown; @@ -69,4 +74,4 @@ namespace Pinetime { uint32_t lastShakeTime = 0; }; } -}
\ No newline at end of file +} diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h index 44a1a85..34e1af4 100644 --- a/src/components/settings/Settings.h +++ b/src/components/settings/Settings.h @@ -16,6 +16,7 @@ namespace Pinetime { DoubleTap = 1, RaiseWrist = 2, Shake = 3, + LowerWrist = 4 }; enum class Colors : uint8_t { White, @@ -172,7 +173,7 @@ namespace Pinetime { } }; - std::bitset<4> getWakeUpModes() const { + std::bitset<5> getWakeUpModes() const { return settings.wakeUpMode; } @@ -227,8 +228,9 @@ namespace Pinetime { PineTimeStyle PTS; - std::bitset<4> wakeUpMode {0}; + std::bitset<5> wakeUpMode {0}; uint16_t shakeWakeThreshold = 150; + Controllers::BrightnessController::Levels brightLevel = Controllers::BrightnessController::Levels::Medium; }; diff --git a/src/components/timer/TimerController.cpp b/src/components/timer/TimerController.cpp index 79e44d6..d6f8ffd 100644 --- a/src/components/timer/TimerController.cpp +++ b/src/components/timer/TimerController.cpp @@ -9,18 +9,16 @@ using namespace Pinetime::Controllers; - APP_TIMER_DEF(timerAppTimer); namespace { void TimerEnd(void* p_context) { - auto* controller = static_cast<Pinetime::Controllers::TimerController*> (p_context); - if(controller != nullptr) + auto* controller = static_cast<Pinetime::Controllers::TimerController*>(p_context); + if (controller != nullptr) controller->OnTimerEnd(); } } - void TimerController::Init() { app_timer_create(&timerAppTimer, APP_TIMER_MODE_SINGLE_SHOT, TimerEnd); } @@ -31,37 +29,37 @@ void TimerController::StartTimer(uint32_t duration) { app_timer_start(timerAppTimer, APP_TIMER_TICKS(duration), this); endTicks = currentTicks + APP_TIMER_TICKS(duration); timerRunning = true; + overtime = false; } -uint32_t TimerController::GetTimeRemaining() { +int32_t TimerController::GetSecondsRemaining() { if (!timerRunning) { return 0; } auto currentTicks = xTaskGetTickCount(); - - TickType_t deltaTicks = 0; - if (currentTicks > endTicks) { - deltaTicks = 0xffffffff - currentTicks; - deltaTicks += (endTicks + 1); - } else { - deltaTicks = endTicks - currentTicks; - } - - return (static_cast<TickType_t>(deltaTicks) / static_cast<TickType_t>(configTICK_RATE_HZ)) * 1000; + + int32_t deltaTicks = static_cast<int32_t>(endTicks) - static_cast<int32_t>(currentTicks); + + return (deltaTicks / static_cast<int32_t>(configTICK_RATE_HZ)); } void TimerController::StopTimer() { app_timer_stop(timerAppTimer); timerRunning = false; + overtime = false; } -bool TimerController::IsRunning() { - return timerRunning; +void TimerController::StopAlerting() { + if (systemTask != nullptr) { + systemTask->PushMessage(System::Messages::StopRinging); + } } + void TimerController::OnTimerEnd() { - timerRunning = false; - if(systemTask != nullptr) + overtime = true; + if (systemTask != nullptr) { systemTask->PushMessage(System::Messages::OnTimerDone); + } } void TimerController::Register(Pinetime::System::SystemTask* systemTask) { diff --git a/src/components/timer/TimerController.h b/src/components/timer/TimerController.h index fa7bc90..dbc9863 100644 --- a/src/components/timer/TimerController.h +++ b/src/components/timer/TimerController.h @@ -9,20 +9,22 @@ namespace Pinetime { class SystemTask; } namespace Controllers { - + class TimerController { public: TimerController() = default; - + void Init(); - void StartTimer(uint32_t duration); - void StopTimer(); - - uint32_t GetTimeRemaining(); - - bool IsRunning(); + void StopAlerting(); + int32_t GetSecondsRemaining(); + bool IsOvertime() { + return overtime; + } + bool IsRunning() { + return timerRunning; + } void OnTimerEnd(); @@ -32,6 +34,7 @@ namespace Pinetime { System::SystemTask* systemTask = nullptr; TickType_t endTicks; bool timerRunning = false; + bool overtime = false; }; } }
\ No newline at end of file diff --git a/src/displayapp/LittleVgl.cpp b/src/displayapp/LittleVgl.cpp index e7b58c1..5e33d1e 100644 --- a/src/displayapp/LittleVgl.cpp +++ b/src/displayapp/LittleVgl.cpp @@ -186,7 +186,7 @@ bool LittleVgl::GetTouchPadInfo(lv_indev_data_t* ptr) { void LittleVgl::InitTheme() { lv_theme_t* th = lv_pinetime_theme_init( - LV_COLOR_WHITE, LV_COLOR_SILVER, 0, &jetbrains_mono_bold_20, &jetbrains_mono_bold_20, &jetbrains_mono_bold_20, &jetbrains_mono_bold_20); + LV_COLOR_WHITE, LV_COLOR_SILVER, 0, &neofont15, &neofont15, &neofont15, &neofont15); lv_theme_set_act(th); } diff --git a/src/displayapp/fonts/neofont.c b/src/displayapp/fonts/neofont.c new file mode 100644 index 0000000..d883ad2 --- /dev/null +++ b/src/displayapp/fonts/neofont.c @@ -0,0 +1,1096 @@ +#ifdef LV_LVGL_H_INCLUDE_SIMPLE +#include "lvgl.h" +#else +#include "lvgl/lvgl.h" +#endif + + +#include <stdint.h> +// #include <stdio.h> +// #include <string.h> + +#define G( \ + a,b,c, \ + d,e,f, \ + g,h,i, \ + j,k,l, \ + m,n,o \ +) \ +{ \ + h + (g<<1) + (f<<2) + (e<<3) + (d << 4) + (c << 5) + (b << 6) + (a << 7), \ + 0 + (o<<1) + (n<<2) + (m<<3) + (l << 4) + (k << 5) + (j << 6) + (i << 7) \ +} + +#define X 1 +#define _ 0 + +static const uint8_t glyphs[][2] = { + G( _, X, _, + X, _, X, + X, _, X, + X, _, X, + _, X, _ ), + + G( _, X, _, + X, X, _, + _, X, _, + _, X, _, + X, X, X ), + + G( X, X, _, + _, _, X, + _, _, X, + _, X, _, + X, X, X ), + + G( X, X, _, + _, _, X, + _, X, _, + _, _, X, + X, X, _ ), + + G( _, _, X, + _, X, X, + X, _, X, + X, X, X, + _, _, X ), + + G( X, X, X, + X, _, _, + X, X, _, + _, _, X, + X, X, _ ), + + G( _, X, X, + X, _, _, + X, X, _, + X, _, X, + _, X, _ ), + + G( X, X, X, + _, _, X, + _, _, X, + _, X, _, + _, X, _ ), + + G( _, X, _, + X, _, X, + _, X, _, + X, _, X, + _, X, _ ), + + G( _, X, _, + X, _, X, + _, X, X, + _, _, X, + X, X, _ ), + + G( _, X, _, + X, _, X, + X, _, X, + X, X, X, + X, _, X ), + + G( X, X, _, + X, _, X, + X, X, _, + X, _, X, + X, X, _ ), + + G( _, X, X, + X, _, _, + X, _, _, + X, _, _, + _, X, X ), + + G( X, X, _, + X, _, X, + X, _, X, + X, _, X, + X, X, _ ), + + G( X, X, X, + X, _, _, + X, X, _, + X, _, _, + X, X, X ), + + G( X, X, X, + X, _, _, + X, X, _, + X, _, _, + X, _, _ ), + + G( _, X, X, + X, _, _, + X, _, _, + X, _, X, + _, X, X ), + + G( X, _, X, + X, _, X, + X, X, X, + X, _, X, + X, _, X ), + + G( X, X, X, + _, X, _, + _, X, _, + _, X, _, + X, X, X ), + + G( X, X, X, + _, _, X, + _, _, X, + X, _, X, + _, X, _ ), + + G( X, _, X, + X, _, X, + X, X, _, + X, _, X, + X, _, X ), + + G( X, _, _, + X, _, _, + X, _, _, + X, _, _, + X, X, X ), + + G( X, _, X, + X, X, X, + X, _, X, + X, _, X, + X, _, X ), + + G( X, X, _, + X, _, X, + X, _, X, + X, _, X, + X, _, X ), + + G( X, X, X, + X, _, X, + X, _, X, + X, _, X, + X, X, X ), + + G( X, X, X, + X, _, X, + X, X, X, + X, _, _, + X, _, _ ), + + G( _, X, _, + X, _, X, + X, _, X, + X, _, X, + _, X, X ), + + G( X, X, _, + X, _, X, + X, X, _, + X, _, X, + X, _, X ), + + G( _, X, X, + X, _, _, + _, X, _, + _, _, X, + X, X, _ ), + + G( X, X, X, + _, X, _, + _, X, _, + _, X, _, + _, X, _ ), + + G( X, _, X, + X, _, X, + X, _, X, + X, _, X, + X, X, X ), + + G( X, _, X, + X, _, X, + X, _, X, + _, X, _, + _, X, _ ), + + G( X, _, X, + X, _, X, + X, _, X, + X, X, X, + X, _, X ), + + G( X, _, X, + X, _, X, + _, X, _, + X, _, X, + X, _, X ), + + G( X, _, X, + X, _, X, + _, X, _, + _, X, _, + _, X, _ ), + + G( X, X, X, + _, _, X, + _, X, _, + X, _, _, + X, X, X ), + + + G( _, X, _, + _, X, _, + _, X, _, + _, X, _, + _, X, _ ), + + G( _, _, _, + _, _, _, + X, X, X, + _, _, _, + _, _, _ ), + + + G( _, _, _, + _, _, X, + _, X, _, + X, _, _, + _, _, _ ), + + G( _, _, _, + _, X, _, + _, _, _, + _, X, _, + _, _, _ ), + + G( _, _, _, + _, _, _, + _, _, _, + _, X, _, + _, _, _ ), + + G( _, _, _, + _, _, _, + _, _, _, + _, X, _, + X, _, _ ), + + G( _, _, _, + _, _, _, + _, _, _, + _, _, _, + X, X, X ), + + G( X, X, _, + _, _, X, + _, X, _, + _, _, _, + _, X, _ ), + + G( _, X, _, + _, X, _, + _, X, _, + _, _, _, + _, X, _ ), + + G( X, _, _, + _, _, X, + _, X, _, + X, _, _, + _, _, X ), + + G( _, _, _, + _, X, _, + X, X, X, + _, X, _, + _, _, _ ), + + G( _, X, _, + X, X, X, + _, X, _, + X, X, X, + _, X, _ ), + + G( _, X, _, + X, _, X, + _, X, _, + _, _, _, + _, _, _ ), + +}; + +#undef X +#undef _ +#undef G + +/* Get info about glyph of `unicode_letter` in `font` font. + * Store the result in `dsc_out`. + * The next letter (`unicode_letter_next`) might be used to calculate the width required by this glyph (kerning) + */ +static bool neofont0mono_glyph_dsc_cb(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) +{ + /*Your code here*/ + + /* Store the result. + * For example ... + */ + dsc_out->adv_w = 4; /*Horizontal space required by the glyph in [px]*/ + dsc_out->box_h = 5; /*Height of the bitmap in [px]*/ + dsc_out->box_w = 3; /*Width of the bitmap in [px]*/ + dsc_out->ofs_x = 0; /*X offset of the bitmap in [pf]*/ + dsc_out->ofs_y = 0; /*Y offset of the bitmap measured from the as line*/ + dsc_out->bpp = 1; /*Bits per pixel: 1/2/4/8*/ + + return true; /*true: glyph found; false: glyph was not found*/ +} + +/* Get the bitmap of `unicode_letter` from `font`. */ +static const uint8_t * neofont0mono_glyph_bitmap_cb(const lv_font_t * font, uint32_t unicode_letter) +{ + static const uint8_t spc[] = { 0, 0 }; + static uint8_t custom[2]; + /* Your code here */ + + // /* The bitmap should be a continuous bitstream where + // * each pixel is represented by `bpp` bits */ + if ('0' <= unicode_letter && unicode_letter <= '9') { + return glyphs[(unicode_letter - '0')]; + } + if ('A' <= unicode_letter && unicode_letter <= 'Z') { + return glyphs[(unicode_letter - 'A')+10]; + } + if ('a' <= unicode_letter && unicode_letter <= 'z') { + return glyphs[(unicode_letter - 'a')+10]; + } + + if (unicode_letter == ' ') { return spc; } + static const char *symbols = "|-/:.,_?!%+#"; + if (unicode_letter < 0x80) { + char*x = strchr(symbols,((uint8_t)unicode_letter)); + if (x != NULL) { + return glyphs[36+(x-symbols)]; + } + } + + switch (unicode_letter) { + case 0xB0: + return glyphs[sizeof(glyphs)/sizeof(glyphs[0])-1]; + } + + if ((0xF0000 < unicode_letter) && (unicode_letter < 0xF7FFF)) { + custom[0] = unicode_letter; + custom[1] = (unicode_letter >> 7); + return custom; + } + + return glyphs[sizeof(glyphs)/sizeof(glyphs[0])-2]; + +} + +lv_font_t neofont0mono = { + .get_glyph_dsc = neofont0mono_glyph_dsc_cb, /*Set a callback to get info about gylphs*/ + .get_glyph_bitmap = neofont0mono_glyph_bitmap_cb, /*Set a callback to get bitmap of a glyp*/ + .line_height = 6, /*The real line height where any text fits*/ + .base_line = 1, /*Base line measured from the top of line_height*/ + .dsc = 0, /*Store any implementation specific data here*/ +#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) + .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8 + .underline_position = 0, + .underline_thickness = 0, +#endif + .user_data = 0 /*Optionally some extra user data*/ +}; + +static bool neofont1mono_glyph_dsc_cb(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) +{ + /*Your code here*/ + + /* Store the result. + * For example ... + */ + + // ######..###### + // ##::::..::##:: + // ######..::##:: + // ::::##..::##:: + // ######..::##:: + + // ######..######.. + // ######..######.. + // ##::::..::##::.. + // ##::::..::##::.. + // ######..::##::.. + // ######..::##::.. + // ::::##..::##::.. + // ::::##..::##::.. + // ######..::##::.. + // ######..::##::.. + + dsc_out->adv_w = 8; /*Horizontal space required by the glyph in [px]*/ + dsc_out->box_h = 10; /*Height of the bitmap in [px]*/ + dsc_out->box_w = 6; /*Width of the bitmap in [px]*/ + dsc_out->ofs_x = 1; /*X offset of the bitmap in [pf]*/ + dsc_out->ofs_y = -1; /*Y offset of the bitmap measured from the as line*/ + dsc_out->bpp = 1; /*Bits per pixel: 1/2/4/8*/ + + return true; /*true: glyph found; false: glyph was not found*/ +} + +#if 0 +/* Get the bitmap of `unicode_letter` from `font`. */ +static const uint8_t * neofont1mono_glyph_bitmap_cb(const lv_font_t * font, uint32_t unicode_letter) +{ + const uint8_t *u = neofont0mono_glyph_bitmap_cb(font, unicode_letter); + static uint8_t v[(10*10+7)/8]; + uint8_t u0 = u[0]; + uint8_t u1 = u[1]; + + // .. .. .. .. .2 .2 .1 .1 .0 .0 + // .9 .8 .7 .6 .5 .4 .3 .2 .1 .0 + // .. .. .. .. .2 .2 .1 .1 .0 .0 + // 19 18 17 16 15 14 13 12 11 10 + // .. .. .. .5 .5 .4 .4 .3 .3 .. + // 29 28 27 26 25 24 23 22 21 20 + // .. .. .. .5 .5 .4 .4 .3 .3 .. + // 39 38 37 36 35 34 33 32 31 30 + + // v[7] = 0x00; + + uint8_t a,b,c, d,e,f, g,h,i, j,k,l, m,n,o; + a = (u0>>7)&1; u0 <<= 1; + b = (u0>>7)&1; u0 <<= 1; + c = (u0>>7)&1; u0 <<= 1; + d = (u0>>7)&1; u0 <<= 1; + e = (u0>>7)&1; u0 <<= 1; + f = (u0>>7)&1; u0 <<= 1; + g = (u0>>7)&1; u0 <<= 1; + h = (u0>>7)&1; + i = (u1>>7)&1; u1 <<= 1; + j = (u1>>7)&1; u1 <<= 1; + k = (u1>>7)&1; u1 <<= 1; + l = (u1>>7)&1; u1 <<= 1; + m = (u1>>7)&1; u1 <<= 1; + n = (u1>>7)&1; u1 <<= 1; + o = (u1>>7)&1; + +#define P(a,b,c,d, e,f,g,h) ((a<<7)|(b<<6)|(c<<5)|(d<<4)|(e<<3)|(f<<2)|(g<<1)|h) + + v[0] = P(0,0,a,a,b,b,c,c); + v[1] = P(0,0,a,a,b,b,c,c); + v[2] = P(0,0,d,d,e,e,f,f); + v[3] = P(0,d,d,e,e,f,f,0); + v[4] = P(0,g,g,h,h,i,i,0); + v[5] = P(g,g,h,h,i,i,0,0); + v[6] = P(j,j,k,k,l,l,0,0); + v[7] = P(j,j,k,k,l,l,0,0); + v[8] = P(m,m,n,n,o,o,0,0); + v[9] = P(m,m,n,n,o,o,0,0); + +#undef P + + return v; /*Or NULL if not found*/ +} +#endif + +/* Get the bitmap of `unicode_letter` from `font`. */ +static const uint8_t * neofont1mono_glyph_bitmap_cb(const lv_font_t * font, uint32_t unicode_letter) +{ + const uint8_t *u = neofont0mono_glyph_bitmap_cb(font, unicode_letter); + static uint8_t v[8]; + uint8_t u0 = u[0]; + uint8_t u1 = u[1]; + + // .. .. .. .. .2 .2 .1 .1 .0 .0 + // .9 .8 .7 .6 .5 .4 .3 .2 .1 .0 + // .. .. .. .. .2 .2 .1 .1 .0 .0 + // 19 18 17 16 15 14 13 12 11 10 + // .. .. .. .5 .5 .4 .4 .3 .3 .. + // 29 28 27 26 25 24 23 22 21 20 + // .. .. .. .5 .5 .4 .4 .3 .3 .. + // 39 38 37 36 35 34 33 32 31 30 + + // v[7] = 0x00; + + uint8_t a,b,c, d,e,f, g,h,i, j,k,l, m,n,o; + a = (u0>>7)&1; u0 <<= 1; + b = (u0>>7)&1; u0 <<= 1; + c = (u0>>7)&1; u0 <<= 1; + d = (u0>>7)&1; u0 <<= 1; + e = (u0>>7)&1; u0 <<= 1; + f = (u0>>7)&1; u0 <<= 1; + g = (u0>>7)&1; u0 <<= 1; + h = (u0>>7)&1; + i = (u1>>7)&1; u1 <<= 1; + j = (u1>>7)&1; u1 <<= 1; + k = (u1>>7)&1; u1 <<= 1; + l = (u1>>7)&1; u1 <<= 1; + m = (u1>>7)&1; u1 <<= 1; + n = (u1>>7)&1; u1 <<= 1; + o = (u1>>7)&1; + +#define P(a,b,c,d, e,f,g,h) ((a<<7)|(b<<6)|(c<<5)|(d<<4)|(e<<3)|(f<<2)|(g<<1)|h) + + v[0] = P(a,a,b,b,c,c, + + a,a); + v[1] = P(b,b,c,c, + + d,d,e,e); + v[2] = P(f,f, + + d,d,e,e,f,f); + + v[3] = P(g,g,h,h,i,i, + + g,g); + v[4] = P(h,h,i,i, + + j,j,k,k); + v[5] = P(l,l, + + j,j,k,k,l,l); + + v[6] = P(m,m,n,n,o,o, + + m,m); + v[7] = P(n,n,o,o, + + 0,0,0,0); + +#undef P + + return v; /*Or NULL if not found*/ +} + +/*Describe the properties of a font*/ +lv_font_t neofont1mono = { + .get_glyph_dsc = neofont1mono_glyph_dsc_cb, /*Set a callback to get info about gylphs*/ + .get_glyph_bitmap = neofont1mono_glyph_bitmap_cb, /*Set a callback to get bitmap of a glyp*/ + .line_height = 12, /*The real line height where any text fits*/ + .base_line = 2, /*Base line measured from the top of line_height*/ + .dsc = 0, /*Store any implementation specific data here*/ +#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) + .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8 + .underline_position = 0, + .underline_thickness = 0, +#endif + .user_data = 0 /*Optionally some extra user data*/ +}; + +static bool neofont15mono_glyph_dsc_cb(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) +{ + dsc_out->adv_w = 12; /*Horizontal space required by the glyph in [px]*/ + dsc_out->box_h = 15; /*Height of the bitmap in [px]*/ + dsc_out->box_w = 9; /*Width of the bitmap in [px]*/ + dsc_out->ofs_x = 1; /*X offset of the bitmap in [pf]*/ + dsc_out->ofs_y = -1; /*Y offset of the bitmap measured from the as line*/ + dsc_out->bpp = 1; /*Bits per pixel: 1/2/4/8*/ + + return true; /*true: glyph found; false: glyph was not found*/ +} + +/* Get the bitmap of `unicode_letter` from `font`. */ +static const uint8_t * neofont15mono_glyph_bitmap_cb(const lv_font_t * font, uint32_t unicode_letter) +{ + const uint8_t *u = neofont0mono_glyph_bitmap_cb(font, unicode_letter); + static uint8_t v[17]; + uint8_t u0 = u[0]; + uint8_t u1 = u[1]; + + // .. .. .. .. .2 .2 .1 .1 .0 .0 + // .9 .8 .7 .6 .5 .4 .3 .2 .1 .0 + // .. .. .. .. .2 .2 .1 .1 .0 .0 + // 19 18 17 16 15 14 13 12 11 10 + // .. .. .. .5 .5 .4 .4 .3 .3 .. + // 29 28 27 26 25 24 23 22 21 20 + // .. .. .. .5 .5 .4 .4 .3 .3 .. + // 39 38 37 36 35 34 33 32 31 30 + + // v[7] = 0x00; + + uint8_t a,b,c, d,e,f, g,h,i, j,k,l, m,n,o; + a = (u0>>7)&1; u0 <<= 1; + b = (u0>>7)&1; u0 <<= 1; + c = (u0>>7)&1; u0 <<= 1; + d = (u0>>7)&1; u0 <<= 1; + e = (u0>>7)&1; u0 <<= 1; + f = (u0>>7)&1; u0 <<= 1; + g = (u0>>7)&1; u0 <<= 1; + h = (u0>>7)&1; + i = (u1>>7)&1; u1 <<= 1; + j = (u1>>7)&1; u1 <<= 1; + k = (u1>>7)&1; u1 <<= 1; + l = (u1>>7)&1; u1 <<= 1; + m = (u1>>7)&1; u1 <<= 1; + n = (u1>>7)&1; u1 <<= 1; + o = (u1>>7)&1; + +#define P(a,b,c,d, e,f,g,h) ((a<<7)|(b<<6)|(c<<5)|(d<<4)|(e<<3)|(f<<2)|(g<<1)|h) + + v[0] = P(a,a,a,b,b,b,c,c); + v[1] = P(c, + a,a,a,b,b,b,c); + v[2] = P(c,c, + a,a,a,b,b,b); + v[3] = P(c,c,c, + + d,d,d,e,e); + v[4] = P(e,f,f,f, + d,d,d,e); + v[5] = P(e,e,f,f,f, + d,d,d); + v[6] = P(e,e,e,f,f,f, + + g,g); + v[7] = P(g,h,h,h,i,i,i, + g); + v[8] = P(g,g,h,h,h,i,i,i); + v[9] = P(g,g,g,h,h,h,i,i); + v[10] = P(i, + + j,j,j,k,k,k,l); + v[11] = P(l,l, + j,j,j,k,k,k); + v[12] = P(l,l,l, + j,j,j,k,k); + v[13] = P(k,l,l,l, + + m,m,m,n); + v[14] = P(n,n,o,o,o, + m,m,m); + v[15] = P(n,n,n,o,o,o, + m,m); + v[16] = P(m,n,n,n,o,o,o,0); + +#undef P + + return v; /*Or NULL if not found*/ +} + +/*Describe the properties of a font*/ +lv_font_t neofont15mono = { + .get_glyph_dsc = neofont15mono_glyph_dsc_cb, /*Set a callback to get info about gylphs*/ + .get_glyph_bitmap = neofont15mono_glyph_bitmap_cb, /*Set a callback to get bitmap of a glyp*/ + .line_height = 18, /*The real line height where any text fits*/ + .base_line = 2, + .dsc = 0, /*Store any implementation specific data here*/ +#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) + .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8 + .underline_position = 0, + .underline_thickness = 0, +#endif + .user_data = 0 /*Optionally some extra user data*/ +}; + +/* Get info about glyph of `unicode_letter` in `font` font. + * Store the result in `dsc_out`. + * The next letter (`unicode_letter_next`) might be used to calculate the width required by this glyph (kerning) + */ +static bool neofont2mono_glyph_dsc_cb(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) +{ + dsc_out->adv_w = 16; /*Horizontal space required by the glyph in [px]*/ + dsc_out->box_h = 20; /*Height of the bitmap in [px]*/ + dsc_out->box_w = 12; /*Width of the bitmap in [px]*/ + dsc_out->ofs_x = 2; /*X offset of the bitmap in [pf]*/ + dsc_out->ofs_y = -2; /*Y offset of the bitmap measured from the as line*/ + dsc_out->bpp = 1; /*Bits per pixel: 1/2/4/8*/ + return true; /*true: glyph found; false: glyph was not found*/ +} + +/* Get the bitmap of `unicode_letter` from `font`. */ +static const uint8_t * neofont2mono_glyph_bitmap_cb(const lv_font_t * font, uint32_t unicode_letter) +{ + const uint8_t *u = neofont0mono_glyph_bitmap_cb(font, unicode_letter); + static uint8_t v[30]; + uint8_t u0 = u[0]; + uint8_t u1 = u[1]; + + uint8_t a,b,c, d,e,f, g,h,i, j,k,l, m,n,o; + a = (u0>>7)&1; u0 <<= 1; + b = (u0>>7)&1; u0 <<= 1; + c = (u0>>7)&1; u0 <<= 1; + d = (u0>>7)&1; u0 <<= 1; + e = (u0>>7)&1; u0 <<= 1; + f = (u0>>7)&1; u0 <<= 1; + g = (u0>>7)&1; u0 <<= 1; + h = (u0>>7)&1; + i = (u1>>7)&1; u1 <<= 1; + j = (u1>>7)&1; u1 <<= 1; + k = (u1>>7)&1; u1 <<= 1; + l = (u1>>7)&1; u1 <<= 1; + m = (u1>>7)&1; u1 <<= 1; + n = (u1>>7)&1; u1 <<= 1; + o = (u1>>7)&1; + +#define P(a,b) (a?0xf0:0)|(b?0x0f:0) + + v[0] = P(a,b); + v[1] = P(c, + a); + v[2] = P(b,c); + + v[3] = v[0]; v[4] = v[1]; v[5] = v[2]; + + v[6] = P(d,e); + v[7] = P(f, + d); + v[8] = P(e,f); + + v[9] = v[6]; v[10] = v[7]; v[11] = v[8]; + + v[12] = P(g,h); + v[13] = P(i, + g); + v[14] = P(h,i); + + v[15] = v[12]; v[16] = v[13]; v[17] = v[14]; + + v[18] = P(j,k); + v[19] = P(l, + j); + v[20] = P(k,l); + + v[21] = v[18]; v[22] = v[19]; v[23] = v[20]; + + v[24] = P(m,n); + v[25] = P(o, + m); + v[26] = P(n,o); + + v[27] = v[24]; v[28] = v[25]; v[29] = v[26]; + +#undef P + + return v; /*Or NULL if not found*/ +} + +/*Describe the properties of a font*/ +lv_font_t neofont2mono = { + .get_glyph_dsc = neofont2mono_glyph_dsc_cb, /*Set a callback to get info about gylphs*/ + .get_glyph_bitmap = neofont2mono_glyph_bitmap_cb, /*Set a callback to get bitmap of a glyp*/ + .line_height = 24, /*The real line height where any text fits*/ + .base_line = 4, /*Base line measured from the top of line_height*/ + .dsc = 0, /*Store any implementation specific data here*/ +#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) + .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8 + .underline_position = 0, + .underline_thickness = 0, +#endif + .user_data = 0 /*Optionally some extra user data*/ +}; + +/* Get info about glyph of `unicode_letter` in `font` font. + * Store the result in `dsc_out`. + * The next letter (`unicode_letter_next`) might be used to calculate the width required by this glyph (kerning) + */ +static bool neofont3mono_glyph_dsc_cb(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) +{ + dsc_out->adv_w = 32; /*Horizontal space required by the glyph in [px]*/ + dsc_out->box_h = 40; /*Height of the bitmap in [px]*/ + dsc_out->box_w = 24; /*Width of the bitmap in [px]*/ + dsc_out->ofs_x = 4; /*X offset of the bitmap in [pf]*/ + dsc_out->ofs_y = -4; /*Y offset of the bitmap measured from the as line*/ + dsc_out->bpp = 1; /*Bits per pixel: 1/2/4/8*/ + return true; /*true: glyph found; false: glyph was not found*/ +} + +static void mono_bitmap_scale_4( + const uint8_t *u, uint8_t *v, unsigned int w, unsigned int h, + const uint8_t *u0, const uint8_t *u1, + const uint8_t *v0, const uint8_t *v1 +) { + unsigned int y = 0; + uint8_t U; + const uint8_t *V = v; + const uint8_t *v_line_end = &(v[w]); + const uint8_t *v_line_next = &(v[w<<2]); + for (;;) { + U = *u; + if (!(v0 <= v && v < v1)) { + // fprintf(stderr, "Overflow 0!\n"); + return; + } + *v = ( ((U&0x80) ? 0xf0 : 0) | ((U&0x40) ? 0x0f : 0) ); + U <<= 2; v++; + if (!(v0 <= v && v < v1)) { return; } + *v = ( ((U&0x80) ? 0xf0 : 0) | ((U&0x40) ? 0x0f : 0) ); + U <<= 2; v++; + if (v >= v_line_end) { + while (v < v_line_next) { + if (!(v0 <= v && v < v1)) { + // fprintf(stderr, "Overflow 1!\n"); + return; + } + *v = *V; v++; V++; + } + y++; + if (y >= h) { return; } + V = v; + v_line_end = &(v[w]); + v_line_next = &(v[w<<2]); + } + if (!(v0 <= v && v < v1)) { return; } + *v = ( ((U&0x80) ? 0xf0 : 0) | ((U&0x40) ? 0x0f : 0) ); + U <<= 2; v++; + if (!(v0 <= v && v < v1)) { return; } + *v = ( ((U&0x80) ? 0xf0 : 0) | ((U&0x40) ? 0x0f : 0) ); + u++; v++; + if (v >= v_line_end) { + while (v < v_line_next) { + if (!(v0 <= v && v < v1)) { + // fprintf(stderr, "Overflow 2!\n"); + return; + } + *v = *V; v++; V++; + } + y++; + if (y >= h) { return; } + V = v; + v_line_end = &(v[w]); + v_line_next = &(v[w<<2]); + } + } +} + +/* Get the bitmap of `unicode_letter` from `font`. */ +static const uint8_t * neofont3mono_glyph_bitmap_cb(const lv_font_t * font, uint32_t unicode_letter) +{ + const uint8_t *u = neofont1mono_glyph_bitmap_cb(font, unicode_letter); + static uint8_t v[120 /* = 40 * 24 / 8 */ ]; + mono_bitmap_scale_4(u,v,6,10,u,u+(60+7)/8,v,v+120); + return v; +} + +/*Describe the properties of a font*/ +lv_font_t neofont3mono = { + .get_glyph_dsc = neofont3mono_glyph_dsc_cb, /*Set a callback to get info about gylphs*/ + .get_glyph_bitmap = neofont3mono_glyph_bitmap_cb, /*Set a callback to get bitmap of a glyp*/ + .line_height = 48, /*The real line height where any text fits*/ + .base_line = 8, /*Base line measured from the top of line_height*/ + .dsc = 0, /*Store any implementation specific data here*/ +#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) + .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8 + .underline_position = 0, + .underline_thickness = 0, +#endif + .user_data = 0 /*Optionally some extra user data*/ +}; + +static bool isthin(uint32_t unicode_letter) { + return + unicode_letter == ' ' || + unicode_letter == ':' || + unicode_letter == 'I' || + unicode_letter == 'i' || + unicode_letter == '.'; + // May also add: "'|" +} + +static bool neofont3_glyph_dsc_cb(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) { + // if (unicode_letter == '\n') { return false; } + bool thin = isthin(unicode_letter); + dsc_out->adv_w = thin ? 16 : 32; /*Horizontal space required by the glyph in [px]*/ + dsc_out->box_h = 40; /*Height of the bitmap in [px]*/ + dsc_out->box_w = 24; /*Width of the bitmap in [px]*/ + dsc_out->ofs_x = thin ? (4-8) : 4; /*X offset of the bitmap in [pf]*/ + dsc_out->ofs_y = -4; /*Y offset of the bitmap measured from the as line*/ + dsc_out->bpp = 1; /*Bits per pixel: 1/2/4/8*/ + return true; /*true: glyph found; false: glyph was not found*/ +} + +/* Get the bitmap of `unicode_letter` from `font`. */ +static const uint8_t * neofont3_glyph_bitmap_cb(const lv_font_t * font, uint32_t unicode_letter) { + if ((unicode_letter == 'I') || (unicode_letter == 'i')) { + unicode_letter = '|'; + } + return neofont3mono_glyph_bitmap_cb(font, unicode_letter); +} + +/*Describe the properties of a font*/ +lv_font_t neofont3 = { + .get_glyph_dsc = neofont3_glyph_dsc_cb, /*Set a callback to get info about gylphs*/ + .get_glyph_bitmap = neofont3_glyph_bitmap_cb, /*Set a callback to get bitmap of a glyp*/ + .line_height = 48, /*The real line height where any text fits*/ + .base_line = 8, /*Base line measured from the top of line_height*/ + .dsc = 0, /*Store any implementation specific data here*/ +#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) + .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8 + .underline_position = 0, + .underline_thickness = 0, +#endif + .user_data = 0 /*Optionally some extra user data*/ +}; + +/* Get info about glyph of `unicode_letter` in `font` font. + * Store the result in `dsc_out`. + * The next letter (`unicode_letter_next`) might be used to calculate the width required by this glyph (kerning) + */ +static bool neofont2_glyph_dsc_cb(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) +{ + // if (unicode_letter == '\n') { return false; } + bool thin = isthin(unicode_letter); + dsc_out->adv_w = thin ? 8 : 16; /*Horizontal space required by the glyph in [px]*/ + dsc_out->box_h = 20; /*Height of the bitmap in [px]*/ + dsc_out->box_w = 12; /*Width of the bitmap in [px]*/ + dsc_out->ofs_x = thin ? (2-4) : 2; /*X offset of the bitmap in [pf]*/ + dsc_out->ofs_y = -2; /*Y offset of the bitmap measured from the as line*/ + dsc_out->bpp = 1; /*Bits per pixel: 1/2/4/8*/ + return true; /*true: glyph found; false: glyph was not found*/ +} + +/* Get the bitmap of `unicode_letter` from `font`. */ +static const uint8_t * neofont2_glyph_bitmap_cb(const lv_font_t * font, uint32_t unicode_letter) { + if ((unicode_letter == 'I') || (unicode_letter == 'i')) { + unicode_letter = '|'; + } + return neofont2mono_glyph_bitmap_cb(font, unicode_letter); +} + +/*Describe the properties of a font*/ +lv_font_t neofont2 = { + .get_glyph_dsc = neofont2_glyph_dsc_cb, /*Set a callback to get info about gylphs*/ + .get_glyph_bitmap = neofont2_glyph_bitmap_cb, /*Set a callback to get bitmap of a glyp*/ + .line_height = 24, /*The real line height where any text fits*/ + .base_line = 4, /*Base line measured from the top of line_height*/ + .dsc = 0, /*Store any implementation specific data here*/ +#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) + .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8 + .underline_position = 0, + .underline_thickness = 0, +#endif + .user_data = 0 /*Optionally some extra user data*/ +}; + +static bool neofont15_glyph_dsc_cb(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) { + // if (unicode_letter == '\n') { return false; } + bool thin = isthin(unicode_letter); + dsc_out->adv_w = thin ? 6 : 12; /*Horizontal space required by the glyph in [px]*/ + dsc_out->box_h = 15; /*Height of the bitmap in [px]*/ + dsc_out->box_w = 9; /*Width of the bitmap in [px]*/ + dsc_out->ofs_x = thin ? (1-3) : 1; /*X offset of the bitmap in [pf]*/ + dsc_out->ofs_y = -1; /*Y offset of the bitmap measured from the as line*/ + dsc_out->bpp = 1; /*Bits per pixel: 1/2/4/8*/ + + return true; /*true: glyph found; false: glyph was not found*/ +} + +/* Get the bitmap of `unicode_letter` from `font`. */ +static const uint8_t * neofont15_glyph_bitmap_cb(const lv_font_t * font, uint32_t unicode_letter) { + if ((unicode_letter == 'I') || (unicode_letter == 'i')) { + unicode_letter = '|'; + } + return neofont15mono_glyph_bitmap_cb(font, unicode_letter); +} + +/*Describe the properties of a font*/ +lv_font_t neofont15 = { + .get_glyph_dsc = neofont15_glyph_dsc_cb, /*Set a callback to get info about gylphs*/ + .get_glyph_bitmap = neofont15_glyph_bitmap_cb, /*Set a callback to get bitmap of a glyp*/ + .line_height = 18, /*The real line height where any text fits*/ + .base_line = 2, + .dsc = 0, /*Store any implementation specific data here*/ +#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) + .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8 + .underline_position = 0, + .underline_thickness = 0, +#endif + .user_data = 0 /*Optionally some extra user data*/ +}; + +static bool neofont1_glyph_dsc_cb(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) { + // if (unicode_letter == '\n') { return false; } + bool thin = isthin(unicode_letter); + dsc_out->adv_w = thin ? 4 : 8; /*Horizontal space required by the glyph in [px]*/ + dsc_out->box_h = 10; /*Height of the bitmap in [px]*/ + dsc_out->box_w = 6; /*Width of the bitmap in [px]*/ + dsc_out->ofs_x = thin ? (1-2) : 1; /*X offset of the bitmap in [pf]*/ + dsc_out->ofs_y = -1; /*Y offset of the bitmap measured from the as line*/ + dsc_out->bpp = 1; /*Bits per pixel: 1/2/4/8*/ + + return true; /*true: glyph found; false: glyph was not found*/ +} + +/* Get the bitmap of `unicode_letter` from `font`. */ +static const uint8_t * neofont1_glyph_bitmap_cb(const lv_font_t * font, uint32_t unicode_letter) { + if ((unicode_letter == 'I') || (unicode_letter == 'i')) { + unicode_letter = '|'; + } + return neofont1mono_glyph_bitmap_cb(font, unicode_letter); +} + +/*Describe the properties of a font*/ +lv_font_t neofont1 = { + .get_glyph_dsc = neofont1_glyph_dsc_cb, /*Set a callback to get info about gylphs*/ + .get_glyph_bitmap = neofont1_glyph_bitmap_cb, /*Set a callback to get bitmap of a glyp*/ + .line_height = 12, /*The real line height where any text fits*/ + .base_line = 2, + .dsc = 0, /*Store any implementation specific data here*/ +#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) + .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8 + .underline_position = 0, + .underline_thickness = 0, +#endif + .user_data = 0 /*Optionally some extra user data*/ +}; + +static bool neofont0_glyph_dsc_cb(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) { + // if (unicode_letter == '\n') { return false; } + bool thin = isthin(unicode_letter); + dsc_out->adv_w = thin ? 2 : 4; /*Horizontal space required by the glyph in [px]*/ + dsc_out->box_h = 5; /*Height of the bitmap in [px]*/ + dsc_out->box_w = 3; /*Width of the bitmap in [px]*/ + dsc_out->ofs_x = thin ? (0-1) : 0; /*X offset of the bitmap in [pf]*/ + dsc_out->ofs_y = 0; /*Y offset of the bitmap measured from the as line*/ + dsc_out->bpp = 1; /*Bits per pixel: 1/2/4/8*/ + + return true; /*true: glyph found; false: glyph was not found*/ +} + +/* Get the bitmap of `unicode_letter` from `font`. */ +static const uint8_t * neofont0_glyph_bitmap_cb(const lv_font_t * font, uint32_t unicode_letter) { + if ((unicode_letter == 'I') || (unicode_letter == 'i')) { + unicode_letter = '|'; + } + return neofont0mono_glyph_bitmap_cb(font, unicode_letter); +} + +/*Describe the properties of a font*/ +lv_font_t neofont0 = { + .get_glyph_dsc = neofont0_glyph_dsc_cb, /*Set a callback to get info about gylphs*/ + .get_glyph_bitmap = neofont0_glyph_bitmap_cb, /*Set a callback to get bitmap of a glyp*/ + .line_height = 12, /*The real line height where any text fits*/ + .base_line = 2, + .dsc = 0, /*Store any implementation specific data here*/ +#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) + .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8 + .underline_position = 0, + .underline_thickness = 0, +#endif + .user_data = 0 /*Optionally some extra user data*/ +}; + + diff --git a/src/displayapp/screens/Alarm.cpp b/src/displayapp/screens/Alarm.cpp index 879e50d..69d84e2 100644 --- a/src/displayapp/screens/Alarm.cpp +++ b/src/displayapp/screens/Alarm.cpp @@ -29,7 +29,7 @@ static void btnEventHandler(lv_obj_t* obj, lv_event_t event) { static void StopAlarmTaskCallback(lv_task_t* task) { auto* screen = static_cast<Alarm*>(task->user_data); - screen->StopAlerting(); + screen->StopAlarm(); } Alarm::Alarm(DisplayApp* app, @@ -39,7 +39,7 @@ Alarm::Alarm(DisplayApp* app, : Screen(app), alarmController {alarmController}, settingsController {settingsController}, systemTask {systemTask} { time = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76); + lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont3); lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); alarmHours = alarmController.Hours(); @@ -48,13 +48,6 @@ Alarm::Alarm(DisplayApp* app, lv_obj_align(time, lv_scr_act(), LV_ALIGN_CENTER, 0, -25); - lblampm = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(lblampm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_bold_20); - lv_obj_set_style_local_text_color(lblampm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); - lv_label_set_text_static(lblampm, " "); - lv_label_set_align(lblampm, LV_LABEL_ALIGN_CENTER); - lv_obj_align(lblampm, lv_scr_act(), LV_ALIGN_CENTER, 0, 30); - btnHoursUp = lv_btn_create(lv_scr_act(), nullptr); btnHoursUp->user_data = this; lv_obj_set_event_cb(btnHoursUp, btnEventHandler); @@ -87,15 +80,13 @@ Alarm::Alarm(DisplayApp* app, txtMinDown = lv_label_create(btnMinutesDown, nullptr); lv_label_set_text_static(txtMinDown, "-"); - btnStop = lv_btn_create(lv_scr_act(), nullptr); - btnStop->user_data = this; - lv_obj_set_event_cb(btnStop, btnEventHandler); - lv_obj_set_size(btnStop, 115, 50); - lv_obj_align(btnStop, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0); - lv_obj_set_style_local_bg_color(btnStop, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED); - txtStop = lv_label_create(btnStop, nullptr); - lv_label_set_text_static(txtStop, Symbols::stop); - lv_obj_set_hidden(btnStop, true); + btnEnable = lv_btn_create(lv_scr_act(), nullptr); + btnEnable->user_data = this; + lv_obj_set_event_cb(btnEnable, btnEventHandler); + lv_obj_set_size(btnEnable, 115, 50); + lv_obj_align(btnEnable, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0); + txtEnable = lv_label_create(btnEnable, nullptr); + SetEnableButtonState(); btnRecur = lv_btn_create(lv_scr_act(), nullptr); btnRecur->user_data = this; @@ -113,25 +104,14 @@ Alarm::Alarm(DisplayApp* app, txtInfo = lv_label_create(btnInfo, nullptr); lv_label_set_text_static(txtInfo, "i"); - enableSwitch = lv_switch_create(lv_scr_act(), nullptr); - enableSwitch->user_data = this; - lv_obj_set_event_cb(enableSwitch, btnEventHandler); - lv_obj_set_size(enableSwitch, 100, 50); - // Align to the center of 115px from edge - lv_obj_align(enableSwitch, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 7, 0); - - UpdateAlarmTime(); - - if (alarmController.State() == Controllers::AlarmController::AlarmState::Alerting) { - SetAlerting(); - } else { - SetSwitchState(LV_ANIM_OFF); + if (alarmController.State() == AlarmController::AlarmState::Alerting) { + OnAlarmStart(); } } Alarm::~Alarm() { if (alarmController.State() == AlarmController::AlarmState::Alerting) { - StopAlerting(); + StopAlarm(); } lv_obj_clean(lv_scr_act()); } @@ -139,8 +119,17 @@ Alarm::~Alarm() { void Alarm::OnButtonEvent(lv_obj_t* obj, lv_event_t event) { using Pinetime::Controllers::AlarmController; if (event == LV_EVENT_CLICKED) { - if (obj == btnStop) { - StopAlerting(); + if (obj == btnEnable) { + if (alarmController.State() == AlarmController::AlarmState::Alerting) { + StopAlarm(); + return; + } + if (alarmController.State() == AlarmController::AlarmState::Set) { + alarmController.DisableAlarm(); + } else { + alarmController.ScheduleAlarm(); + } + SetEnableButtonState(); return; } if (obj == btnInfo) { @@ -151,19 +140,11 @@ void Alarm::OnButtonEvent(lv_obj_t* obj, lv_event_t event) { HideInfo(); return; } - if (obj == enableSwitch) { - if (lv_switch_get_state(enableSwitch)) { - alarmController.ScheduleAlarm(); - } else { - alarmController.DisableAlarm(); - } - return; - } // If any other button was pressed, disable the alarm // this is to make it clear that the alarm won't be set until it is turned back on if (alarmController.State() == AlarmController::AlarmState::Set) { alarmController.DisableAlarm(); - lv_switch_off(enableSwitch, LV_ANIM_ON); + SetEnableButtonState(); } if (obj == btnMinutesUp) { if (alarmMinutes >= 59) { @@ -213,7 +194,7 @@ bool Alarm::OnButtonPushed() { return true; } if (alarmController.State() == AlarmController::AlarmState::Alerting) { - StopAlerting(); + StopAlarm(); return true; } return false; @@ -225,60 +206,43 @@ bool Alarm::OnTouchEvent(Pinetime::Applications::TouchEvents event) { } void Alarm::UpdateAlarmTime() { - if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) { - switch (alarmHours) { - case 0: - lv_label_set_text_static(lblampm, "AM"); - lv_label_set_text_fmt(time, "%02d:%02d", 12, alarmMinutes); - break; - case 1 ... 11: - lv_label_set_text_static(lblampm, "AM"); - lv_label_set_text_fmt(time, "%02d:%02d", alarmHours, alarmMinutes); - break; - case 12: - lv_label_set_text_static(lblampm, "PM"); - lv_label_set_text_fmt(time, "%02d:%02d", 12, alarmMinutes); - break; - case 13 ... 23: - lv_label_set_text_static(lblampm, "PM"); - lv_label_set_text_fmt(time, "%02d:%02d", alarmHours - 12, alarmMinutes); - break; - } - } else { - lv_label_set_text_fmt(time, "%02d:%02d", alarmHours, alarmMinutes); - } + lv_label_set_text_fmt(time, "%02d:%02d", alarmHours, alarmMinutes); alarmController.SetAlarmTime(alarmHours, alarmMinutes); } void Alarm::SetAlerting() { - lv_obj_set_hidden(enableSwitch, true); - lv_obj_set_hidden(btnStop, false); + SetEnableButtonState(); + OnAlarmStart(); +} + +void Alarm::OnAlarmStart() { taskStopAlarm = lv_task_create(StopAlarmTaskCallback, pdMS_TO_TICKS(60 * 1000), LV_TASK_PRIO_MID, this); systemTask.PushMessage(System::Messages::DisableSleeping); } -void Alarm::StopAlerting() { +void Alarm::StopAlarm() { alarmController.StopAlerting(); - SetSwitchState(LV_ANIM_OFF); + SetEnableButtonState(); if (taskStopAlarm != nullptr) { lv_task_del(taskStopAlarm); taskStopAlarm = nullptr; } systemTask.PushMessage(System::Messages::EnableSleeping); - lv_obj_set_hidden(enableSwitch, false); - lv_obj_set_hidden(btnStop, true); } -void Alarm::SetSwitchState(lv_anim_enable_t anim) { +void Alarm::SetEnableButtonState() { switch (alarmController.State()) { case AlarmController::AlarmState::Set: - lv_switch_on(enableSwitch, anim); + lv_label_set_text(txtEnable, "ON"); + lv_obj_set_style_local_bg_color(btnEnable, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN); break; case AlarmController::AlarmState::Not_Set: - lv_switch_off(enableSwitch, anim); - break; - default: + lv_label_set_text(txtEnable, "OFF"); + lv_obj_set_style_local_bg_color(btnEnable, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); break; + case AlarmController::AlarmState::Alerting: + lv_label_set_text(txtEnable, Symbols::stop); + lv_obj_set_style_local_bg_color(btnEnable, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED); } } diff --git a/src/displayapp/screens/Alarm.h b/src/displayapp/screens/Alarm.h index f74dd68..f5b54f7 100644 --- a/src/displayapp/screens/Alarm.h +++ b/src/displayapp/screens/Alarm.h @@ -36,7 +36,7 @@ namespace Pinetime { void OnButtonEvent(lv_obj_t* obj, lv_event_t event); bool OnButtonPushed() override; bool OnTouchEvent(TouchEvents event) override; - void StopAlerting(); + void StopAlarm(); private: uint8_t alarmHours; @@ -45,15 +45,16 @@ namespace Pinetime { Controllers::Settings& settingsController; System::SystemTask& systemTask; - lv_obj_t *time, *lblampm, *btnStop, *txtStop, *btnMinutesUp, *btnMinutesDown, *btnHoursUp, *btnHoursDown, *txtMinUp, - *txtMinDown, *txtHrUp, *txtHrDown, *btnRecur, *txtRecur, *btnInfo, *txtInfo, *enableSwitch; + lv_obj_t *time, *btnEnable, *txtEnable, *btnMinutesUp, *btnMinutesDown, *btnHoursUp, *btnHoursDown, *txtMinUp, *txtMinDown, + *txtHrUp, *txtHrDown, *btnRecur, *txtRecur, *btnInfo, *txtInfo; lv_obj_t* txtMessage = nullptr; lv_obj_t* btnMessage = nullptr; lv_task_t* taskStopAlarm = nullptr; enum class EnableButtonState { On, Off, Alerting }; + void SetEnableButtonState(); void SetRecurButtonState(); - void SetSwitchState(lv_anim_enable_t anim); + void OnAlarmStart(); void SetAlarm(); void ShowInfo(); void HideInfo(); diff --git a/src/displayapp/screens/BatteryInfo.cpp b/src/displayapp/screens/BatteryInfo.cpp index e17de9a..0377bdb 100644 --- a/src/displayapp/screens/BatteryInfo.cpp +++ b/src/displayapp/screens/BatteryInfo.cpp @@ -27,7 +27,7 @@ BatteryInfo::BatteryInfo(Pinetime::Applications::DisplayApp* app, Pinetime::Cont lv_obj_align(status, charging_bar, LV_ALIGN_OUT_BOTTOM_MID, 0, 20); percent = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(percent, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76); + lv_obj_set_style_local_text_font(percent, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont3); lv_label_set_text_fmt(percent, "%02i%%", batteryPercent); lv_label_set_align(percent, LV_LABEL_ALIGN_LEFT); lv_obj_align(percent, nullptr, LV_ALIGN_CENTER, 0, -60); diff --git a/src/displayapp/screens/FlashLight.cpp b/src/displayapp/screens/FlashLight.cpp index c4d0264..dba79a4 100644 --- a/src/displayapp/screens/FlashLight.cpp +++ b/src/displayapp/screens/FlashLight.cpp @@ -24,7 +24,7 @@ FlashLight::FlashLight(Pinetime::Applications::DisplayApp* app, brightnessLevel = brightnessController.Level(); flashLight = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(flashLight, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48); + lv_obj_set_style_local_text_font(flashLight, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont2); lv_label_set_text_static(flashLight, Symbols::highlight); lv_obj_align(flashLight, nullptr, LV_ALIGN_CENTER, 0, 0); diff --git a/src/displayapp/screens/HeartRate.cpp b/src/displayapp/screens/HeartRate.cpp index 513c40b..6f9154b 100644 --- a/src/displayapp/screens/HeartRate.cpp +++ b/src/displayapp/screens/HeartRate.cpp @@ -34,7 +34,7 @@ HeartRate::HeartRate(Pinetime::Applications::DisplayApp* app, bool isHrRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped; label_hr = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76); + lv_obj_set_style_local_text_font(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont3); if (isHrRunning) lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN); diff --git a/src/displayapp/screens/Metronome.cpp b/src/displayapp/screens/Metronome.cpp index f6f269d..df5e772 100644 --- a/src/displayapp/screens/Metronome.cpp +++ b/src/displayapp/screens/Metronome.cpp @@ -34,8 +34,8 @@ Metronome::Metronome(DisplayApp* app, Controllers::MotorController& motorControl lv_arc_set_adjustable(bpmArc, true); lv_obj_align(bpmArc, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 0, 0); - bpmValue = createLabel("120", bpmArc, LV_ALIGN_IN_TOP_MID, &jetbrains_mono_76, 0, 55); - createLabel("bpm", bpmValue, LV_ALIGN_OUT_BOTTOM_MID, &jetbrains_mono_bold_20, 0, 0); + bpmValue = createLabel("120", bpmArc, LV_ALIGN_IN_TOP_MID, &neofont3, 0, 55); + createLabel("bpm", bpmValue, LV_ALIGN_OUT_BOTTOM_MID, &neofont15, 0, 0); bpmTap = lv_btn_create(lv_scr_act(), nullptr); bpmTap->user_data = this; diff --git a/src/displayapp/screens/Motion.cpp b/src/displayapp/screens/Motion.cpp index 23eb276..77b6518 100644 --- a/src/displayapp/screens/Motion.cpp +++ b/src/displayapp/screens/Motion.cpp @@ -37,6 +37,11 @@ Motion::Motion(Pinetime::Applications::DisplayApp* app, Controllers::MotionContr lv_obj_align(labelStep, chart, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0); lv_label_set_text(labelStep, "Steps ---"); + labelLastY = lv_label_create(lv_scr_act(), NULL); + lv_label_set_text(labelLastY, "LastY 0"); + lv_label_set_align(labelLastY, LV_LABEL_ALIGN_RIGHT); + lv_obj_align(labelLastY, chart, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0); + taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); } @@ -58,4 +63,7 @@ void Motion::Refresh() { motionController.Y() / 0x10, motionController.Z() / 0x10); lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 10); + + lv_label_set_text_fmt(labelLastY, "LastY %d", motionController.LastY() / 0x10); + lv_obj_align(labelLastY, chart, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0); } diff --git a/src/displayapp/screens/Motion.h b/src/displayapp/screens/Motion.h index 4d2bd4f..315660c 100644 --- a/src/displayapp/screens/Motion.h +++ b/src/displayapp/screens/Motion.h @@ -27,6 +27,7 @@ namespace Pinetime { lv_obj_t* label; lv_obj_t* labelStep; + lv_obj_t* labelLastY; lv_task_t* taskRefresh; }; } diff --git a/src/displayapp/screens/Paddle.cpp b/src/displayapp/screens/Paddle.cpp index 608eb64..9ad9ca5 100644 --- a/src/displayapp/screens/Paddle.cpp +++ b/src/displayapp/screens/Paddle.cpp @@ -16,7 +16,7 @@ Paddle::Paddle(Pinetime::Applications::DisplayApp* app, Pinetime::Components::Li lv_obj_set_style_local_border_width(background, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 1); points = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(points, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); + lv_obj_set_style_local_text_font(points, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont2); lv_label_set_text(points, "0000"); lv_obj_align(points, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 0, 10); diff --git a/src/displayapp/screens/PassKey.cpp b/src/displayapp/screens/PassKey.cpp index 9e43a54..257ab22 100644 --- a/src/displayapp/screens/PassKey.cpp +++ b/src/displayapp/screens/PassKey.cpp @@ -6,7 +6,7 @@ using namespace Pinetime::Applications::Screens; PassKey::PassKey(Pinetime::Applications::DisplayApp* app, uint32_t key) : Screen(app) { passkeyLabel = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_color(passkeyLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFFFF00)); - lv_obj_set_style_local_text_font(passkeyLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); + lv_obj_set_style_local_text_font(passkeyLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont2); lv_label_set_text_fmt(passkeyLabel, "%06u", key); lv_obj_align(passkeyLabel, nullptr, LV_ALIGN_CENTER, 0, -20); diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp index e807289..526e8ea 100644 --- a/src/displayapp/screens/PineTimeStyle.cpp +++ b/src/displayapp/screens/PineTimeStyle.cpp @@ -76,13 +76,13 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, // Display the time timeDD1 = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light); + lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont3); lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime())); lv_label_set_text_static(timeDD1, "00"); lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5); timeDD2 = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light); + lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont3); lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime())); lv_label_set_text_static(timeDD2, "00"); lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5); @@ -292,7 +292,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, lv_obj_set_style_local_bg_opa(btnSet, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50); lv_obj_set_event_cb(btnSet, event_handler); lbl_btnSet = lv_label_create(btnSet, nullptr); - lv_obj_set_style_local_text_font(lbl_btnSet, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48); + lv_obj_set_style_local_text_font(lbl_btnSet, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont2); lv_label_set_text_static(lbl_btnSet, Symbols::settings); lv_obj_set_hidden(btnSet, true); diff --git a/src/displayapp/screens/Steps.cpp b/src/displayapp/screens/Steps.cpp index 3e7f820..e0e860c 100644 --- a/src/displayapp/screens/Steps.cpp +++ b/src/displayapp/screens/Steps.cpp @@ -33,7 +33,7 @@ Steps::Steps(Pinetime::Applications::DisplayApp* app, lSteps = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_color(lSteps, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FF00)); - lv_obj_set_style_local_text_font(lSteps, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); + lv_obj_set_style_local_text_font(lSteps, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont2); lv_label_set_text_fmt(lSteps, "%li", stepsCount); lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -40); diff --git a/src/displayapp/screens/StopWatch.cpp b/src/displayapp/screens/StopWatch.cpp index 8749839..0f84f59 100644 --- a/src/displayapp/screens/StopWatch.cpp +++ b/src/displayapp/screens/StopWatch.cpp @@ -53,7 +53,7 @@ StopWatch::StopWatch(DisplayApp* app, System::SystemTask& systemTask) lapNr {} { time = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76); + lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont3); lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); lv_label_set_text(time, "00:00"); lv_obj_align(time, lv_scr_act(), LV_ALIGN_CENTER, 0, -45); diff --git a/src/displayapp/screens/Symbols.h b/src/displayapp/screens/Symbols.h index e68a7af..ba5b46e 100644 --- a/src/displayapp/screens/Symbols.h +++ b/src/displayapp/screens/Symbols.h @@ -1,19 +1,101 @@ #pragma once + // For neofont: + // Layout for 3-byte codes: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx + // U+F0000: 11110011 10110000 000000 000000 + // Neofont glyph: 11110011 10110zzz zzzzyy yyyyyy + // CDD DEEEAA ABBBCC + // \xF3 \xB[0-7] \x[8-B]. \x[8-B]. + // "\xF3\xB5\x80\x97" + +// h + (g<<1) + (f<<2) + (e<<3) + (d << 4) + (c << 5) + (b << 6) + (a << 7), \ +// 0 + (o<<1) + (n<<2) + (m<<3) + (l << 4) + (k << 5) + (j << 6) + (i << 7) \ + +#define G( \ + a,b,c, \ + d,e,f, \ + g,h,i, \ + j,k,l, \ + m,n,o \ +) { \ + ((char)( 0xF3 )), \ + ((char)( 0xB0 | (i<<2) | (j<<1) | k )), \ + ((char)( 0x80 | (l<<5) | (m<<4) | (n<<3) | (o<<2) | (a<<1) | b )), \ + ((char)( 0x80 | (c<<5) | (d<<4) | (e<<3) | (f<<2) | (g<<1) | h )), \ + 0 \ +} + +#define X 1 +#define _ 0 + namespace Pinetime { namespace Applications { namespace Screens { namespace Symbols { static constexpr const char* none = ""; - static constexpr const char* batteryFull = "\xEF\x89\x80"; - static constexpr const char* batteryEmpty = "\xEF\x89\x84"; - static constexpr const char* batteryThreeQuarter = "\xEF\x89\x81"; - static constexpr const char* batteryHalf = "\xEF\x89\x82"; - static constexpr const char* batteryOneQuarter = "\xEF\x89\x83"; - static constexpr const char* heartBeat = "\xEF\x88\x9E"; - static constexpr const char* bluetoothFull = "\xEF\x8A\x93"; - static constexpr const char* bluetooth = "\xEF\x8A\x94"; - static constexpr const char* plug = "\xEF\x87\xA6"; + static constexpr const char batteryFull[] = + // "\xEF\x89\x80"; + G(_, X, _, + X, X, X, + X, X, X, + X, X, X, + X, X, X); + static constexpr const char batteryEmpty[] = + // "\xEF\x89\x84"; + G(_, X, _, + X, _, X, + X, _, X, + X, _, X, // l is ignored! + X, X, X); + static constexpr const char batteryThreeQuarter[] = + // Was: "\xEF\x89\x81"; + G(_, X, _, + X, X, X, + X, _, X, + X, X, X, + X, X, X); + static constexpr const char batteryHalf[] = + // Was: "\xEF\x89\x82"; + G(_, X, _, + X, _, X, + X, X, X, + X, X, X, + X, X, X); + static constexpr const char batteryOneQuarter[] = + // Was: "\xEF\x89\x83"; + G(_, X, _, + X, _, X, + X, _, X, + X, X, X, + X, X, X); + static constexpr const char heartBeat[] = + // Was: "\xEF\x88\x9E" + G(_, _, _, + X, _, X, + X, X, X, + _, X, _, + _, _, _); + static constexpr const char bluetoothFull[] = + // "\xEF\x8A\x93"; + G(X, X, _, + _, X, X, + X, X, _, + _, X, X, + X, X, _); + static constexpr const char bluetooth[] = + // "\xEF\x8A\x94"; + G(_, X, _, + _, X, X, + X, X, _, + _, X, X, + _, X, _); + static constexpr const char plug[] = + // "\xEF\x87\xA6"; + G(X, _, X, + X, X, X, + X, X, X, + _, X, _, + _, X, _); static constexpr const char* shoe = "\xEF\x95\x8B"; static constexpr const char* clock = "\xEF\x80\x97"; static constexpr const char* info = "\xEF\x84\xA9"; @@ -34,12 +116,48 @@ namespace Pinetime { static constexpr const char* volumDown = "\xEF\x80\xA7"; static constexpr const char* stepForward = "\xEF\x81\x91"; static constexpr const char* stepBackward = "\xEF\x81\x88"; - static constexpr const char* play = "\xEF\x81\x8B"; - static constexpr const char* pause = "\xEF\x81\x8C"; - static constexpr const char* stop = "\xEF\x81\x8D"; - static constexpr const char* stopWatch = "\xEF\x8B\xB2"; - static constexpr const char* hourGlass = "\xEF\x89\x92"; - static constexpr const char* lapsFlag = "\xEF\x80\xA4"; + static constexpr const char play[] = + // "\xEF\x81\x8B"; + G(X, _, _, + X, X, _, + X, X, X, + X, X, _, + X, _, _); + static constexpr const char pause[] = + // "\xEF\x81\x8C"; + G(_, _, _, + X, _, X, + X, _, X, + X, _, X, + _, _, _); + static constexpr const char stop[] = + // "\xEF\x81\x8D"; + G(_, _, _, + X, X, X, + X, X, X, + X, X, X, + _, _, _); + static constexpr const char stopWatch[] = + // "\xEF\x8B\xB2"; + G(X, _, _, + X, X, _, + X, X, X, + X, X, _, + X, _, _); + static constexpr const char hourGlass[] = + // "\xEF\x89\x92"; + G(X, X, X, + X, X, X, + _, X, _, + X, X, X, + X, X, X); + static constexpr const char lapsFlag[] = + // "\xEF\x80\xA4"; + G(_, X, _, + X, _, X, + X, _, _, + X, _, X, + _, X, _); static constexpr const char* drum = "\xEF\x95\xA9"; static constexpr const char* chartLine = "\xEF\x88\x81"; static constexpr const char* eye = "\xEF\x81\xAE"; @@ -61,3 +179,7 @@ namespace Pinetime { } } } + +#undef G +#undef X +#undef _ diff --git a/src/displayapp/screens/Timer.cpp b/src/displayapp/screens/Timer.cpp index 5cd496c..332fcef 100644 --- a/src/displayapp/screens/Timer.cpp +++ b/src/displayapp/screens/Timer.cpp @@ -1,4 +1,5 @@ #include "displayapp/screens/Timer.h" + #include "displayapp/screens/Screen.h" #include "displayapp/screens/Symbols.h" #include <lvgl/lvgl.h> @@ -6,48 +7,62 @@ using namespace Pinetime::Applications::Screens; static void btnEventHandler(lv_obj_t* obj, lv_event_t event) { - auto* screen = static_cast<Timer*>(obj->user_data); + Timer* screen = static_cast<Timer*>(obj->user_data); screen->OnButtonEvent(obj, event); } -void Timer::CreateButtons() { +void Timer::createButtons() { btnMinutesUp = lv_btn_create(lv_scr_act(), nullptr); btnMinutesUp->user_data = this; lv_obj_set_event_cb(btnMinutesUp, btnEventHandler); - lv_obj_align(btnMinutesUp, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 20, -80); - lv_obj_set_height(btnMinutesUp, 40); - lv_obj_set_width(btnMinutesUp, 60); + lv_obj_set_size(btnMinutesUp, 60, 40); + lv_obj_align(btnMinutesUp, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 20, -85); txtMUp = lv_label_create(btnMinutesUp, nullptr); lv_label_set_text(txtMUp, "+"); btnMinutesDown = lv_btn_create(lv_scr_act(), nullptr); btnMinutesDown->user_data = this; lv_obj_set_event_cb(btnMinutesDown, btnEventHandler); - lv_obj_align(btnMinutesDown, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 20, +40); - lv_obj_set_height(btnMinutesDown, 40); - lv_obj_set_width(btnMinutesDown, 60); + lv_obj_set_size(btnMinutesDown, 60, 40); + lv_obj_align(btnMinutesDown, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 20, +35); txtMDown = lv_label_create(btnMinutesDown, nullptr); lv_label_set_text(txtMDown, "-"); btnSecondsUp = lv_btn_create(lv_scr_act(), nullptr); btnSecondsUp->user_data = this; lv_obj_set_event_cb(btnSecondsUp, btnEventHandler); - lv_obj_align(btnSecondsUp, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 10, -80); - lv_obj_set_height(btnSecondsUp, 40); - lv_obj_set_width(btnSecondsUp, 60); + lv_obj_set_size(btnSecondsUp, 60, 40); + lv_obj_align(btnSecondsUp, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -20, -85); txtSUp = lv_label_create(btnSecondsUp, nullptr); lv_label_set_text(txtSUp, "+"); btnSecondsDown = lv_btn_create(lv_scr_act(), nullptr); btnSecondsDown->user_data = this; lv_obj_set_event_cb(btnSecondsDown, btnEventHandler); - lv_obj_align(btnSecondsDown, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 10, +40); - lv_obj_set_height(btnSecondsDown, 40); - lv_obj_set_width(btnSecondsDown, 60); + lv_obj_set_size(btnSecondsDown, 60, 40); + lv_obj_align(btnSecondsDown, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -20, +35); txtSDown = lv_label_create(btnSecondsDown, nullptr); lv_label_set_text(txtSDown, "-"); } +void Timer::stop() { + int32_t secondsRemaining = timerController.GetSecondsRemaining(); + if (timerController.IsOvertime()) { + minutesToSet = 0; + secondsToSet = 0; + secondsRemaining = 0; + } else { + minutesToSet = secondsRemaining / 60; + secondsToSet = secondsRemaining % 60; + } + timerController.StopTimer(); + timerController.StopAlerting(); + lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); + lv_label_set_text_fmt(time, "%02lu:%02lu", secondsRemaining / 60, secondsRemaining % 60); + lv_label_set_text(txtPlayPause, Symbols::play); + createButtons(); +} + Timer::Timer(DisplayApp* app, Controllers::TimerController& timerController) : Screen(app), running {true}, timerController {timerController} { backgroundLabel = lv_label_create(lv_scr_act(), nullptr); @@ -58,38 +73,58 @@ Timer::Timer(DisplayApp* app, Controllers::TimerController& timerController) lv_label_set_text(backgroundLabel, ""); time = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76); - lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); + lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont3); + + int32_t seconds = timerController.GetSecondsRemaining(); + bool overtime = timerController.IsOvertime(); + + if (overtime) { + seconds = -seconds + 1; // "+ 1" is to not show -00:00 again after +00:00 + lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED); + } else { + lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); + } - uint32_t seconds = timerController.GetTimeRemaining() / 1000; lv_label_set_text_fmt(time, "%02lu:%02lu", seconds / 60, seconds % 60); - lv_obj_align(time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -20); + lv_obj_align(time, lv_scr_act(), LV_ALIGN_CENTER, 0, -20); btnPlayPause = lv_btn_create(lv_scr_act(), nullptr); btnPlayPause->user_data = this; lv_obj_set_event_cb(btnPlayPause, btnEventHandler); - lv_obj_align(btnPlayPause, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, -10); - lv_obj_set_height(btnPlayPause, 40); + lv_obj_set_size(btnPlayPause, 115, 50); + lv_obj_align(btnPlayPause, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, 0); txtPlayPause = lv_label_create(btnPlayPause, nullptr); if (timerController.IsRunning()) { - lv_label_set_text(txtPlayPause, Symbols::pause); + lv_label_set_text(txtPlayPause, overtime ? Symbols::stop : Symbols::pause); } else { lv_label_set_text(txtPlayPause, Symbols::play); - CreateButtons(); + createButtons(); } - taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); } Timer::~Timer() { lv_task_del(taskRefresh); lv_obj_clean(lv_scr_act()); + if (timerController.IsRunning() && timerController.IsOvertime()) { + timerController.StopTimer(); + timerController.StopAlerting(); + } } void Timer::Refresh() { if (timerController.IsRunning()) { - uint32_t seconds = timerController.GetTimeRemaining() / 1000; + int32_t seconds = timerController.GetSecondsRemaining(); + if (timerController.IsOvertime()) { + seconds = -seconds + 1; // "+ 1" is to not show -00:00 again after +00:00 + + // safety measures, lets not overflow counter as it will display badly + if (seconds >= 100 * 60) { + stop(); + return; + } + } lv_label_set_text_fmt(time, "%02lu:%02lu", seconds / 60, seconds % 60); } } @@ -98,17 +133,12 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) { if (event == LV_EVENT_CLICKED) { if (obj == btnPlayPause) { if (timerController.IsRunning()) { - lv_label_set_text(txtPlayPause, Symbols::play); - uint32_t seconds = timerController.GetTimeRemaining() / 1000; - minutesToSet = seconds / 60; - secondsToSet = seconds % 60; - timerController.StopTimer(); - CreateButtons(); - + stop(); } else if (secondsToSet + minutesToSet > 0) { lv_label_set_text(txtPlayPause, Symbols::pause); timerController.StartTimer((secondsToSet + minutesToSet * 60) * 1000); + // inlined destroyButtons() lv_obj_del(btnSecondsDown); btnSecondsDown = nullptr; lv_obj_del(btnSecondsUp); @@ -158,9 +188,6 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) { } void Timer::SetDone() { - lv_label_set_text(time, "00:00"); - lv_label_set_text(txtPlayPause, Symbols::play); - secondsToSet = 0; - minutesToSet = 0; - CreateButtons(); + lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED); + lv_label_set_text(txtPlayPause, Symbols::stop); } diff --git a/src/displayapp/screens/Timer.h b/src/displayapp/screens/Timer.h index 93e84c8..1eee6d0 100644 --- a/src/displayapp/screens/Timer.h +++ b/src/displayapp/screens/Timer.h @@ -8,35 +8,31 @@ #include "components/timer/TimerController.h" namespace Pinetime::Applications::Screens { + class Timer : public Screen { public: enum class Modes { Normal, Done }; Timer(DisplayApp* app, Controllers::TimerController& timerController); + ~Timer() override; + void Refresh() override; void SetDone(); void OnButtonEvent(lv_obj_t* obj, lv_event_t event); private: - void CreateButtons(); bool running; uint8_t secondsToSet = 0; uint8_t minutesToSet = 0; Controllers::TimerController& timerController; + + void createButtons(); + void stop(); + lv_obj_t* backgroundLabel; - lv_obj_t* time; - lv_obj_t* msecTime; - lv_obj_t* btnPlayPause; - lv_obj_t* txtPlayPause; - lv_obj_t* btnMinutesUp; - lv_obj_t* btnMinutesDown; - lv_obj_t* btnSecondsUp; - lv_obj_t* btnSecondsDown; - lv_obj_t* txtMUp; - lv_obj_t* txtMDown; - lv_obj_t* txtSUp; - lv_obj_t* txtSDown; lv_task_t* taskRefresh; + lv_obj_t *time, *btnPlayPause, *txtPlayPause, *btnMinutesUp, *btnMinutesDown, *btnSecondsUp, *btnSecondsDown, *txtMUp, + *txtMDown, *txtSUp, *txtSDown; }; } diff --git a/src/displayapp/screens/WatchFaceAnalog24.cpp b/src/displayapp/screens/WatchFaceAnalog24.cpp index 29c1095..875c0f1 100644 --- a/src/displayapp/screens/WatchFaceAnalog24.cpp +++ b/src/displayapp/screens/WatchFaceAnalog24.cpp @@ -206,9 +206,8 @@ void WatchFaceAnalog24::Refresh() { } bleState = bleController.IsConnected(); - bleRadioEnabled = bleController.IsRadioEnabled(); - if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) { - lv_label_set_text(bleIcon, BleIcon::GetIcon(bleRadioEnabled.Get(), bleState.Get())); + if (bleState.IsUpdated()) { + lv_label_set_text(bleIcon, BleIcon::GetIcon(bleState.Get())); } notificationState = notificationManager.AreNewNotificationsAvailable(); diff --git a/src/displayapp/screens/WatchFaceAnalog24.h b/src/displayapp/screens/WatchFaceAnalog24.h index 0653bcf..5df8979 100644 --- a/src/displayapp/screens/WatchFaceAnalog24.h +++ b/src/displayapp/screens/WatchFaceAnalog24.h @@ -51,7 +51,6 @@ namespace Pinetime { DirtyValue<uint8_t> batteryPercentRemaining {0}; DirtyValue<bool> isCharging {}; DirtyValue<bool> bleState {}; - DirtyValue<bool> bleRadioEnabled {}; DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime; DirtyValue<bool> motionSensorOk {}; DirtyValue<uint32_t> stepCount {}; diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp index 6a91488..dc16f60 100644 --- a/src/displayapp/screens/WatchFaceDigital.cpp +++ b/src/displayapp/screens/WatchFaceDigital.cpp @@ -35,12 +35,12 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app, batteryIcon = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text_static(batteryIcon, Symbols::batteryFull); - lv_obj_align(batteryIcon, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0); + lv_obj_align(batteryIcon, nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 0); batteryPlug = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_color(batteryPlug, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFF0000)); lv_label_set_text_static(batteryPlug, Symbols::plug); - lv_obj_align(batteryPlug, batteryIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0); + lv_obj_align(batteryPlug, batteryIcon, LV_ALIGN_OUT_LEFT_MID, 0, 0); bleIcon = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x0082FC)); @@ -57,7 +57,7 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app, lv_obj_set_style_local_text_color(label_date, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999)); label_time = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_extrabold_compressed); + lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont2); lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 0, 0); diff --git a/src/displayapp/screens/settings/QuickSettings.cpp b/src/displayapp/screens/settings/QuickSettings.cpp index cd56c14..d2754ec 100644 --- a/src/displayapp/screens/settings/QuickSettings.cpp +++ b/src/displayapp/screens/settings/QuickSettings.cpp @@ -61,7 +61,7 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app, lv_obj_align(btn1, nullptr, LV_ALIGN_IN_TOP_LEFT, buttonXOffset, barHeight); btn1_lvl = lv_label_create(btn1, nullptr); - lv_obj_set_style_local_text_font(btn1_lvl, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48); + lv_obj_set_style_local_text_font(btn1_lvl, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont2); lv_label_set_text_static(btn1_lvl, brightness.GetIcon()); btn2 = lv_btn_create(lv_scr_act(), nullptr); @@ -73,7 +73,7 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app, lv_obj_t* lbl_btn; lbl_btn = lv_label_create(btn2, nullptr); - lv_obj_set_style_local_text_font(lbl_btn, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48); + lv_obj_set_style_local_text_font(lbl_btn, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont2); lv_label_set_text_static(lbl_btn, Symbols::highlight); btn3 = lv_btn_create(lv_scr_act(), nullptr); @@ -86,7 +86,7 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app, lv_obj_align(btn3, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, buttonXOffset, 0); btn3_lvl = lv_label_create(btn3, nullptr); - lv_obj_set_style_local_text_font(btn3_lvl, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48); + lv_obj_set_style_local_text_font(btn3_lvl, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont2); if (settingsController.GetNotificationStatus() == Controllers::Settings::Notification::ON) { lv_obj_add_state(btn3, LV_STATE_CHECKED); @@ -103,7 +103,7 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app, lv_obj_align(btn4, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, - buttonXOffset, 0); lbl_btn = lv_label_create(btn4, nullptr); - lv_obj_set_style_local_text_font(lbl_btn, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48); + lv_obj_set_style_local_text_font(lbl_btn, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont2); lv_label_set_text_static(lbl_btn, Symbols::settings); lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act(), nullptr); diff --git a/src/displayapp/screens/settings/SettingSetTime.cpp b/src/displayapp/screens/settings/SettingSetTime.cpp index 037611f..376790e 100644 --- a/src/displayapp/screens/settings/SettingSetTime.cpp +++ b/src/displayapp/screens/settings/SettingSetTime.cpp @@ -41,40 +41,40 @@ SettingSetTime::SettingSetTime(Pinetime::Applications::DisplayApp* app, hoursValue = static_cast<int>(dateTimeController.Hours()); lblHours = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(lblHours, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); + lv_obj_set_style_local_text_font(lblHours, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont2); lv_label_set_text_fmt(lblHours, "%02d", hoursValue); lv_label_set_align(lblHours, LV_LABEL_ALIGN_CENTER); lv_obj_align(lblHours, lv_scr_act(), LV_ALIGN_CENTER, POS_X_HOURS, POS_Y_TEXT); lv_obj_set_auto_realign(lblHours, true); lv_obj_t* lblColon1 = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(lblColon1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); + lv_obj_set_style_local_text_font(lblColon1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont2); lv_label_set_text_static(lblColon1, ":"); lv_label_set_align(lblColon1, LV_LABEL_ALIGN_CENTER); lv_obj_align(lblColon1, lv_scr_act(), LV_ALIGN_CENTER, (POS_X_HOURS + POS_X_MINUTES) / 2, POS_Y_TEXT + OFS_Y_COLON); minutesValue = static_cast<int>(dateTimeController.Minutes()); lblMinutes = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(lblMinutes, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); + lv_obj_set_style_local_text_font(lblMinutes, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont2); lv_label_set_text_fmt(lblMinutes, "%02d", minutesValue); lv_label_set_align(lblMinutes, LV_LABEL_ALIGN_CENTER); lv_obj_align(lblMinutes, lv_scr_act(), LV_ALIGN_CENTER, POS_X_MINUTES, POS_Y_TEXT); lv_obj_set_auto_realign(lblMinutes, true); lv_obj_t* lblColon2 = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(lblColon2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); + lv_obj_set_style_local_text_font(lblColon2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont2); lv_label_set_text_static(lblColon2, ":"); lv_label_set_align(lblColon2, LV_LABEL_ALIGN_CENTER); lv_obj_align(lblColon2, lv_scr_act(), LV_ALIGN_CENTER, (POS_X_MINUTES + POS_X_SECONDS) / 2, POS_Y_TEXT + OFS_Y_COLON); lv_obj_t* lblSeconds = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(lblSeconds, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); + lv_obj_set_style_local_text_font(lblSeconds, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont2); lv_label_set_text_static(lblSeconds, "00"); lv_label_set_align(lblSeconds, LV_LABEL_ALIGN_CENTER); lv_obj_align(lblSeconds, lv_scr_act(), LV_ALIGN_CENTER, POS_X_SECONDS, POS_Y_TEXT); lblampm = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(lblampm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_bold_20); + lv_obj_set_style_local_text_font(lblampm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont15); lv_label_set_text_static(lblampm, " "); lv_label_set_align(lblampm, LV_LABEL_ALIGN_CENTER); lv_obj_align(lblampm, lv_scr_act(), LV_ALIGN_CENTER, POS_X_SECONDS, POS_Y_PLUS); diff --git a/src/displayapp/screens/settings/SettingSteps.cpp b/src/displayapp/screens/settings/SettingSteps.cpp index 5ca3eec..da0f182 100644 --- a/src/displayapp/screens/settings/SettingSteps.cpp +++ b/src/displayapp/screens/settings/SettingSteps.cpp @@ -43,7 +43,7 @@ SettingSteps::SettingSteps( lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0); stepValue = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); + lv_obj_set_style_local_text_font(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont2); lv_label_set_text_fmt(stepValue, "%lu", settingsController.GetStepsGoal()); lv_label_set_align(stepValue, LV_LABEL_ALIGN_CENTER); lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -10); diff --git a/src/displayapp/screens/settings/SettingWakeUp.cpp b/src/displayapp/screens/settings/SettingWakeUp.cpp index e1b6e36..4fc0994 100644 --- a/src/displayapp/screens/settings/SettingWakeUp.cpp +++ b/src/displayapp/screens/settings/SettingWakeUp.cpp @@ -24,9 +24,9 @@ SettingWakeUp::SettingWakeUp(Pinetime::Applications::DisplayApp* app, Pinetime:: lv_obj_set_style_local_pad_inner(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 5); lv_obj_set_style_local_border_width(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0); - lv_obj_set_pos(container1, 10, 60); + lv_obj_set_pos(container1, 10, 35); lv_obj_set_width(container1, LV_HOR_RES - 20); - lv_obj_set_height(container1, LV_VER_RES - 50); + lv_obj_set_height(container1, LV_VER_RES - 20); lv_cont_set_layout(container1, LV_LAYOUT_COLUMN_LEFT); lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr); @@ -73,6 +73,14 @@ SettingWakeUp::SettingWakeUp(Pinetime::Applications::DisplayApp* app, Pinetime:: lv_checkbox_set_checked(cbOption[optionsTotal], true); } optionsTotal++; + cbOption[optionsTotal] = lv_checkbox_create(container1, nullptr); + lv_checkbox_set_text_static(cbOption[optionsTotal], " Lower Wrist"); + cbOption[optionsTotal]->user_data = this; + lv_obj_set_event_cb(cbOption[optionsTotal], event_handler); + if (settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::LowerWrist)) { + lv_checkbox_set_checked(cbOption[optionsTotal], true); + } + optionsTotal++; } SettingWakeUp::~SettingWakeUp() { diff --git a/src/libs/lv_conf.h b/src/libs/lv_conf.h index 73109c5..eece755 100644 --- a/src/libs/lv_conf.h +++ b/src/libs/lv_conf.h @@ -413,12 +413,11 @@ typedef void* lv_indev_drv_user_data_t; /*Type of user data in the in * LV_FONT_DECLARE(my_font_2) */ -#define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(jetbrains_mono_bold_20) \ - LV_FONT_DECLARE(jetbrains_mono_extrabold_compressed) \ - LV_FONT_DECLARE(jetbrains_mono_42) \ - LV_FONT_DECLARE(jetbrains_mono_76) \ - LV_FONT_DECLARE(open_sans_light) \ - LV_FONT_DECLARE(lv_font_sys_48) +#define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(neofont0) \ + LV_FONT_DECLARE(neofont1) \ + LV_FONT_DECLARE(neofont15) \ + LV_FONT_DECLARE(neofont2) \ + LV_FONT_DECLARE(neofont3) /* Enable it if you have fonts with a lot of characters. * The limit depends on the font size, font face and bpp @@ -478,10 +477,10 @@ typedef void* lv_font_user_data_t; #define LV_THEME_DEFAULT_COLOR_PRIMARY lv_color_hex(0xffffff) #define LV_THEME_DEFAULT_COLOR_SECONDARY lv_color_hex(0xaaaaaa) #define LV_THEME_DEFAULT_FLAG 0//LV_THEME_MATERIAL_FLAG_DARK -#define LV_THEME_DEFAULT_FONT_SMALL &jetbrains_mono_bold_20 -#define LV_THEME_DEFAULT_FONT_NORMAL &jetbrains_mono_bold_20 -#define LV_THEME_DEFAULT_FONT_SUBTITLE &jetbrains_mono_bold_20 -#define LV_THEME_DEFAULT_FONT_TITLE &jetbrains_mono_bold_20 +#define LV_THEME_DEFAULT_FONT_SMALL &neofont15 +#define LV_THEME_DEFAULT_FONT_NORMAL &neofont15 +#define LV_THEME_DEFAULT_FONT_SUBTITLE &neofont15 +#define LV_THEME_DEFAULT_FONT_TITLE &neofont15 /*================= * Text settings diff --git a/src/libs/lvgl b/src/libs/lvgl -Subproject e100d920f823e4308b8b43d7eb4130afa74f272 +Subproject 23430cf20e32294549fff9b2879a9466dacc19b diff --git a/src/libs/mynewt-nimble/porting/nimble/include/syscfg/syscfg.h b/src/libs/mynewt-nimble/porting/nimble/include/syscfg/syscfg.h index b3f2341..8fbd44a 100644 --- a/src/libs/mynewt-nimble/porting/nimble/include/syscfg/syscfg.h +++ b/src/libs/mynewt-nimble/porting/nimble/include/syscfg/syscfg.h @@ -702,6 +702,7 @@ #define MYNEWT_VAL_BLE_SM_BONDING (1) #endif +// The following macro appears not to be used in InfiniTime! #ifndef MYNEWT_VAL_BLE_SM_IO_CAP #define MYNEWT_VAL_BLE_SM_IO_CAP (BLE_HS_IO_DISPLAY_ONLY) #endif diff --git a/src/main.cpp b/src/main.cpp index fa492d0..b58c7ed 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -164,9 +164,9 @@ Pinetime::System::SystemTask systemTask(spi, */ extern uint32_t __start_noinit_data; extern uint32_t __stop_noinit_data; -static constexpr uint32_t NoInit_MagicValue = 0xDEAD0000; +static constexpr uint32_t NoInit_MagicValue = 0x3E470000; uint32_t NoInit_MagicWord __attribute__((section(".noinit"))); -std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> NoInit_BackUpTime __attribute__((section(".noinit"))); +std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds> NoInit_BackUpTime __attribute__((section(".noinit"))); void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) { diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 77cf411..0411cf2 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -306,7 +306,7 @@ void SystemTask::Work() { if (isSleeping && !isWakingUp) { GoToRunning(); } - motorController.RunForDuration(35); + motorController.StartRinging(); displayApp.PushMessage(Pinetime::Applications::Display::Messages::TimerDone); break; case Messages::SetOffAlarm: @@ -492,15 +492,17 @@ void SystemTask::UpdateMotion() { motionController.IsSensorOk(motionSensor.IsOk()); motionController.Update(motionValues.x, motionValues.y, motionValues.z, motionValues.steps); - - if (settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::RaiseWrist) && - motionController.Should_RaiseWake(isSleeping)) { + if (isSleeping && motionController.ShouldRaiseWake()) { GoToRunning(); } if (settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::Shake) && motionController.Should_ShakeWake(settingsController.GetShakeThreshold())) { GoToRunning(); } + if (settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::LowerWrist) && !isSleeping && + motionController.ShouldLowerSleep()) { + PushMessage(Messages::GoToSleep); + } } void SystemTask::HandleButtonAction(Controllers::ButtonActions action) { diff --git a/src/systemtask/SystemTask.h b/src/systemtask/SystemTask.h index c5b0379..704711c 100644 --- a/src/systemtask/SystemTask.h +++ b/src/systemtask/SystemTask.h @@ -35,7 +35,7 @@ #include "drivers/Watchdog.h" #include "systemtask/Messages.h" -extern std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> NoInit_BackUpTime; +extern std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds> NoInit_BackUpTime; namespace Pinetime { namespace Drivers { class Cst816S; |
