From 528fc5661679feeef91e76d633c94c945bb0a3df Mon Sep 17 00:00:00 2001 From: JF Date: Sat, 7 Dec 2019 19:15:33 +0100 Subject: The font is now fixed width. HUGE performance improvement of the display driver. --- src/DisplayApp/DisplayApp.cpp | 56 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 6 deletions(-) (limited to 'src/DisplayApp/DisplayApp.cpp') diff --git a/src/DisplayApp/DisplayApp.cpp b/src/DisplayApp/DisplayApp.cpp index 6dc31bc0..abaef825 100644 --- a/src/DisplayApp/DisplayApp.cpp +++ b/src/DisplayApp/DisplayApp.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "Components/Gfx/Gfx.h" using namespace Pinetime::Applications; @@ -21,6 +22,9 @@ void DisplayApp::Process(void *instance) { while (1) { NRF_LOG_INFO("BlinkApp task running!"); + + app->Refresh(); + vTaskDelay(1000); } } @@ -48,17 +52,57 @@ void DisplayApp::InitHw() { gfx->ClearScreen(); uint8_t x = 7; - gfx->DrawChar(&largeFont , '0', &x, 78, 0x0); + gfx->DrawChar(&largeFont , '0', &x, 78, 0xffff); x = 61; - gfx->DrawChar(&largeFont, '1', &x, 78, 0x0); + gfx->DrawChar(&largeFont, '0', &x, 78, 0xffff); + + x = 94; + gfx->DrawChar(&largeFont, ':', &x, 78, 0xffff); + + x = 127; + gfx->DrawChar(&largeFont, '0', &x, 78, 0xffff); + + x = 181; + gfx->DrawChar(&largeFont, '0', &x, 78, 0xffff); +} + +void DisplayApp::Refresh() { + uint32_t systick_counter = nrf_rtc_counter_get(portNRF_RTC_REG); + auto raw = systick_counter / 1000; + + // TODO make this better! + minutes = raw / 60; + seconds = raw - (minutes*60); - x = 115; - gfx->DrawChar(&largeFont, ':', &x, 78, 0x0); + char secondChar[3]; + sprintf(secondChar, "%02d", seconds); + + char minutesChar[3]; + sprintf(minutesChar, "%02d", minutes); + + uint8_t x = 7; + if(minutesChar[0] != currentChar[0]) { + gfx->DrawChar(&largeFont, minutesChar[0], &x, 78, 0xffff); + currentChar[0] = minutesChar[0]; + } + + x = 61; + if(minutesChar[1] != currentChar[1]) { + gfx->DrawChar(&largeFont, minutesChar[1], &x, 78, 0xffff); + currentChar[1] = minutesChar[1]; + } x = 127; - gfx->DrawChar(&largeFont, '2', &x, 78, 0x0); + if(secondChar[0] != currentChar[2]) { + gfx->DrawChar(&largeFont, secondChar[0], &x, 78, 0xffff); + currentChar[2] = secondChar[0]; + } x = 181; - gfx->DrawChar(&largeFont, '3', &x, 78, 0x0); + if(secondChar[1] != currentChar[3]) { + gfx->DrawChar(&largeFont, secondChar[1], &x, 78, 0xffff); + currentChar[3] = secondChar[1]; + } + } -- cgit v1.2.3-70-g09d2