Skip to content

Commit faf7de0

Browse files
author
Thomas Arlitt
committed
Rel V0.7
1 parent 9a94593 commit faf7de0

7 files changed

Lines changed: 81 additions & 18 deletions

File tree

‎M5PaperCalendar.ino‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
Digital Calendar on M5Paper
44
The M5PAPER is equipped with an e-ink screen with a resolution of 540*960 @ 4.7" and supports 16 levels of grayscale display.
5-
Btn P/R/
5+
Btn L/P/R
66
|
77
+-----------------------------°-------------------+
88
| 0/0 ePaper 960 x 540 |
@@ -46,6 +46,7 @@
4646
V0.4 05.12.2021: Small bug fixes, show "+" if read data was ok
4747
V0.5 18.12.2021: Tuned the mini calendar, renamed "pure clock" to "today", some bug fixes
4848
V0.6 22.12.2021: Worked on the today page
49+
V0.7 23.12.2021: Added the next event to today page
4950
5051
5152
Important note:
@@ -58,7 +59,7 @@
5859
5960
*********************************************************************/
6061

61-
#define FIRMWARE "0.6 - 2021-12-22"
62+
#define FIRMWARE "0.7 - 2021-12-23"
6263

6364
/**************************************************************************************
6465
** Libraries
@@ -116,7 +117,9 @@ int sht30Humidity; // SHT30 humidity
116117
const int calEntryCount = 10;
117118
const int calEntryMuellCount = 10;
118119
bool rC = false;
120+
bool rTC = false;
119121
String calendarOK = "x";
122+
String calendarTOK = "x";
120123

121124
struct calendarEntries {
122125
String calStartDate;
@@ -286,6 +289,7 @@ void loop() {
286289
printTime();
287290
printDate();
288291
printWeather();
292+
printNextEvent();
289293
Serial.println(page);
290294
}
291295
if (M5.BtnP.wasPressed()) {
@@ -327,7 +331,10 @@ void loop() {
327331

328332
if (currentTime.hour != oldHour) {
329333
oldHour = currentTime.hour;
330-
if (page == 1) printWeather();
334+
if (page == 1) {
335+
printWeather();
336+
printNextEvent();
337+
}
331338
if (page == 2) eventList();
332339
if (page == 3) {
333340
getSHT30Values();

‎M5PaperCalendar.vcxproj‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎__vm/Compile.vmps.xml‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎__vm/Upload.vmps.xml‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎myCalendar.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// the functions to draw the calendar
44

55
#pragma once
6-
//#include "myUtils.h"
76

87
// calendar helper: leap year?
98
bool isLeapYear(int year) {

‎myToday.h‎

Lines changed: 68 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
// myToday.h
22

33
// functions for the pure clock page
4-
// tbd: shows time, date, the next event, the current weather
4+
// shows time, date, the next event, the current weather
55

66
#pragma once
7-
//#include "Icons.h"
8-
//#include "myWeather.h"
9-
107

118
void printTime() {
129
char timeString[16];
@@ -61,8 +58,6 @@ void printDate() {
6158
myToday.drawString(buf1, 5, 75);
6259
myToday.pushCanvas(5, 390, UPDATE_MODE_GC16);
6360
myToday.deleteCanvas();
64-
65-
6661
}
6762

6863
void printFrame() {
@@ -99,7 +94,6 @@ void printFrame() {
9994

10095
myToday.pushCanvas(0, 0, UPDATE_MODE_GC16);
10196
myToday.deleteCanvas();
102-
10397
}
10498

10599
void printWeather() {
@@ -109,7 +103,7 @@ void printWeather() {
109103

110104
Serial.println("weather OK? " + String(rTW));
111105
if (rTW) getLocalTime(&weatherTime);
112-
106+
113107
myToday.createCanvas(330, 135);
114108

115109
String icon = weather.hourlyIcon[0];
@@ -151,3 +145,69 @@ void printWeather() {
151145
myToday.deleteCanvas();
152146

153147
}
148+
149+
void printNextEvent() {
150+
byte p = 0;
151+
int checkDay;
152+
int checkMonth;
153+
int checkYear;
154+
int checkMin;
155+
int checkHour;
156+
157+
158+
rTC = readCalendar();
159+
160+
Serial.println("Calendar OK? " + String(rTC));
161+
162+
M5.RTC.getTime(&currentTime);
163+
M5.RTC.getDate(&currentDate);
164+
165+
tmElements_t currentNow = { 0, currentTime.min, currentTime.hour, 0, currentDate.day, currentDate.mon, currentDate.year - 1970 };
166+
time_t currentNowTime = makeTime(currentNow);
167+
168+
//Serial.println("CurrentNow: " + String(currentNowTime));
169+
170+
for (byte r = 0; r < 11; r++) {
171+
checkDay = calEnt[r].calStartDate.substring(0, 2).toInt();
172+
checkMonth = calEnt[r].calStartDate.substring(3, 5).toInt();
173+
checkYear = calEnt[r].calStartDate.substring(6, 10).toInt();
174+
checkHour = calEnt[r].calStartTime.substring(0, 2).toInt();
175+
checkMin = calEnt[r].calStartTime.substring(3, 5).toInt();
176+
177+
//Serial.println(String(checkMin) + " " + String(checkHour) + " " + String(checkDay) + " " + String(checkMonth) + " " + String(checkYear));
178+
179+
tmElements_t calEvent = { 0, checkMin, checkHour, 0, checkDay, checkMonth, checkYear - 1970 };
180+
time_t calEventTime = makeTime(calEvent);
181+
182+
//Serial.println("calEventTime: " + String(calEventTime));
183+
184+
if (currentNowTime <= calEventTime && calEnt[r].calAllDay == "false") {
185+
p = r;
186+
break;
187+
}
188+
if (calEnt[r].calStartDate == "") break;
189+
}
190+
191+
//Serial.println("p = " + String(p));
192+
193+
myToday.createCanvas(600, 135);
194+
195+
myToday.setTextSize(36);
196+
myToday.setTextDatum(TL_DATUM);
197+
if (!rTC) {
198+
myToday.drawString("Fehler beim Holen der Daten", 5, 20);
199+
}
200+
else {
201+
myToday.drawString(calEnt[p].calTitle, 5, 10);
202+
myToday.setTextSize(24);
203+
int x = 5, y = 50, s = 25;
204+
myToday.fillCircle(x + s / 2, y + s / 3, s / 3, MYBLACK);
205+
myToday.fillTriangle(x + s / 2, y + s, (x + s / 2) - s / 3.75, y + s / 2, (x + s / 2) + s / 3.5, y + s / 2, MYBLACK);
206+
myToday.fillCircle(x + s / 2, y + s / 3, s / 6, MYWHITE);
207+
myToday.drawString(calEnt[p].calLocation, 35, 50);
208+
myToday.drawString(calEnt[p].calStartDate + " / " + calEnt[p].calStartTime, 5, 80);
209+
}
210+
211+
myToday.pushCanvas(355, 210, UPDATE_MODE_GC16);
212+
myToday.deleteCanvas();
213+
}

‎myWeather.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
// all the functions for weather
44

55
#pragma once
6-
//#include "Icons.h"
7-
//#include "myUtils.h"
8-
96

107
/* Convert UTC time to local time */
118
time_t LocalTime(time_t time) {

0 commit comments

Comments
 (0)