From c60b82e2f8632f25dd10425f137b84c0592d1361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Deckert?= Date: Sat, 31 Oct 2020 17:55:35 +0100 Subject: [PATCH] display battery voltage --- FamilyPlanner.ino | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/FamilyPlanner.ino b/FamilyPlanner.ino index 8b4f350..2242acc 100644 --- a/FamilyPlanner.ino +++ b/FamilyPlanner.ino @@ -74,6 +74,7 @@ RTC_DATA_ATTR int timeDigits[4] = { 9, 5, 0, 0 }; // start time: 23:59 RTC_DATA_ATTR char calName[5][31]; RTC_DATA_ATTR char calStart[5][26]; RTC_DATA_ATTR char calTitle[5][81]; +RTC_DATA_ATTR double voltage; Inkplate display(INKPLATE_1BIT); //Create an object on Inkplate library and also set library into 1 Bit mode Network network; //Our networking functions, see Network.cpp for info @@ -83,6 +84,7 @@ void drawTime(); void drawCal(); void drawCalLine1(int entry); void drawCalLine2(int entry); +void drawBat(); void setup() { bool networking = false; @@ -95,11 +97,14 @@ void setup() { //restore old bitmap (before the deep sleep) drawTime(); drawCal(); + drawBat(); display.load1b(); //Update data - if ((timeDigits[1] == 5) && (timeDigits[0] == 9)) { - network.begin(); // every hour set the time from internet + if ((timeDigits[1] == 5) && (timeDigits[0] == 9)) { // every hour read the battery voltage and set the time from internet + adc_power_on(); + voltage = display.readBattery(); + network.begin(); network.off(); networking = true; } @@ -109,6 +114,7 @@ void setup() { display.clearDisplay(); drawTime(); drawCal(); + drawBat(); //Actually display all data if (timeDigits[0]+timeDigits[1] == 0 || networking) { @@ -215,3 +221,12 @@ void drawCalLine2(int entry) display.setTextWrap(false); display.print(calTitle[entry]); } + +void drawBat() +{ + display.setFont(NULL); + display.setTextSize(2); + display.setCursor(275, 10); + display.print(voltage); + display.print("V"); +}