aboutsummaryrefslogtreecommitdiffstats
path: root/src/DisplayApp/DisplayApp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/DisplayApp/DisplayApp.cpp')
-rw-r--r--src/DisplayApp/DisplayApp.cpp56
1 files changed, 50 insertions, 6 deletions
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 <libraries/log/nrf_log.h>
#include <boards.h>
#include <nrf_font.h>
+#include <hal/nrf_rtc.h>
#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];
+ }
+
}