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
118void 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
6863void printFrame () {
@@ -99,7 +94,6 @@ void printFrame() {
9994
10095 myToday .pushCanvas (0 , 0 , UPDATE_MODE_GC16 );
10196 myToday .deleteCanvas ();
102-
10397}
10498
10599void 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+ }
0 commit comments