Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of DS3231 by
Revision 3:1af2ff7cfe26, committed 2018-07-23
- Comitter:
- JackB
- Date:
- Mon Jul 23 12:25:27 2018 +0000
- Parent:
- 2:6718c4fabf95
- Commit message:
- RTC
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ARM_RTC.cpp Mon Jul 23 12:25:27 2018 +0000
@@ -0,0 +1,360 @@
+#include "ARM_RTC.h"
+
+ARM_RTC::ARM_RTC()
+{
+ setTimeZone(1);
+ dayLightSaving = true;
+}
+
+bool ARM_RTC::checkTimeLost(void)
+{
+ return (atoi(getFormatedDateTime("%Y")) <= 2015) ? true : false;
+}
+
+// BCD to decimal conversion
+int ARM_RTC::bcd2dec(int bcd)
+{
+ return(((bcd & 0xF0) >> 4) * 10 + (bcd & 0x0F));
+}
+
+// decimal to BCD conversion
+int ARM_RTC::dec2bcd(int dec)
+{
+ return((dec / 10) * 16 + (dec % 10));
+}
+
+void ARM_RTC::setTimeZone(double TZ)
+{
+ timeZoneOffset = (uint32_t) (TZ * 3600.0f);
+}
+
+double ARM_RTC::getTimeZone(void)
+{
+ return (double)timeZoneOffset / 3600.0f;
+}
+
+void ARM_RTC::setDate(int day, int month, int year)
+{
+ printf("%d-%d-%d\n", day, month, year);
+ // First read
+ time_t rawtime;
+ struct tm t;
+ struct tm * t2;
+
+ time(&rawtime);
+ t2 = localtime(&rawtime);
+
+ if (year<100) {
+ year+=2000;
+ }
+ if (year > 1900)
+ t.tm_year = year - 1900; // adjust for tm structure required values
+ else
+ t.tm_year = year;
+ t.tm_mon = month - 1; // adjust for tm structure required values
+ t.tm_mday = day;
+ t.tm_hour = t2->tm_hour;
+ t.tm_min = t2->tm_min;
+ t.tm_sec = t2->tm_sec;
+
+ // Set system date and time
+ rawtime = mktime(&t); // seconds since the Epoch
+ set_time(rawtime);
+
+// time_t t_seconds = time(NULL);
+// char buffer[32];
+// strftime(buffer, 32, "%A %d-%m-%Y %H:%M:%S", localtime(&t_seconds));
+// printf("%s\n", buffer);
+}
+
+// set time register
+void ARM_RTC::setTime(int hours, int minutes, int seconds)
+{
+ // First read
+ time_t rawtime;
+ struct tm t;
+ struct tm * t2;
+
+ time(&rawtime);
+ t2 = localtime(&rawtime);
+
+ t.tm_hour = hours;
+ t.tm_min = minutes;
+ t.tm_sec = seconds;
+ t.tm_year = t2->tm_year;
+// t.tm_year = 2016-1900;
+ t.tm_mon = t2->tm_mon;
+ t.tm_mday = t2->tm_mday;
+// t.tm_wday = t2->tm_wday;
+// printf("%d-%d-%d %d:%d:%d\n", t.tm_year, t.tm_mon+1, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec);
+
+ // Set system date and time
+ rawtime = mktime(&t); // seconds since the Epoch
+ set_time(rawtime);
+
+// time_t t_seconds = time(NULL);
+// char buffer[32];
+// strftime(buffer, 32, "%A %d-%m-%Y %H:%M:%S", localtime(&t_seconds));
+// printf("%s\n", buffer);
+}
+
+void ARM_RTC::setDateTime(int day, int month, int year, int hours, int minutes, int seconds)
+{
+ // First read
+ time_t rawtime;
+ struct tm t;
+ struct tm * t2;
+
+ time(&rawtime);
+ t2 = localtime(&rawtime);
+
+ if (year<100) {
+ year+=2000;
+ }
+ if (year > 1900)
+ t.tm_year = year - 1900; // adjust for tm structure required values
+ else
+ t.tm_year = year;
+ t.tm_mon = month - 1; // adjust for tm structure required values
+ t.tm_mday = day;
+
+ t.tm_hour = hours;
+ t.tm_min = minutes;
+ t.tm_sec = seconds;
+
+ // Set system date and time
+ rawtime = mktime(&t); // seconds since the Epoch
+ set_time(rawtime);
+
+// time_t t_seconds = time(NULL);
+// char buffer[32];
+// strftime(buffer, 32, "%A %d-%m-%Y %H:%M:%S", localtime(&t_seconds));
+// printf("%s\n", buffer);
+}
+
+
+// read the date and time registers and set system clock
+void ARM_RTC::setSystemClock(void)
+{
+// int dayOfWeek, day, month, year, hours, minutes, seconds;
+// readDateTime(&dayOfWeek, &day, &month, &year, &hours, &minutes, &seconds);
+
+// getDateTime(&t);
+
+// time_t secondsEpoch = mktime(&t); // seconds since the Epoch
+ // Get weekday
+// t = *localtime(&secondsEpoch);
+// set_time(secondsEpoch);
+}
+
+void ARM_RTC::readDateTime(void)
+{
+ // First read
+ time_t rawtime;
+ struct tm t;
+ struct tm * t2;
+ time(&rawtime);
+ t2 = localtime(&rawtime);
+
+// time(&secondsEpoch);
+// t = localtime(&secondsEpoch);
+}
+
+void ARM_RTC::getDateTime(struct tm *t)
+{
+ time(&secondsEpoch);
+ t = localtime(&secondsEpoch);
+}
+
+void ARM_RTC::setDateTime(struct tm *time)
+{
+ secondsEpoch = mktime(time); // seconds since the Epoch
+ set_time(secondsEpoch);
+}
+
+void ARM_RTC::setDateTimeSecsSince1900(uint32_t secsSince1900)
+{
+ setDateTimeSecsSince1970(secsSince1900 - NTP_OFFSET);
+}
+
+void ARM_RTC::setDateTimeSecsSince1970(uint32_t secsSince1970)
+{
+ set_time(secsSince1970);
+}
+
+// read the date and time registers and return secondsEpoch
+uint32_t ARM_RTC::getDateTimeSecsSince1970(void)
+{
+ return (mktime(&t) - timeZoneOffset); // seconds since the Epoch
+}
+
+// read the date and time registers and return secondsEpoch
+time_t ARM_RTC::getDateTimeSecsSince1970TZ(void)
+{
+ return mktime(&t); // seconds since the Epoch
+}
+
+int ARM_RTC::getDayOfWeek(int mday, int month, int year) // y > 1752, 1 <= m <= 12
+{
+ t.tm_year = year - 1900; // adjust for tm structure required values
+ t.tm_mon = month - 1; // adjust for tm structure required values
+ t.tm_mday = mday;
+ t.tm_hour = 0;
+ t.tm_min = 0;
+ t.tm_sec = 0;
+ time_t secondsEpoch = mktime(&t); // seconds since the Epoch
+ t = *localtime(&secondsEpoch);
+ return t.tm_wday; // (0=Sunday, 6=Saturday)
+
+// static int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
+// year -= month < 3;
+// return ((year + year/4 - year/100 + year/400 + t[month-1] + mday) % 7) + 1; // 01 - 07, 01 = Sunday
+}
+
+char * ARM_RTC::getDayOfWeekName(void) // y > 1752, 1 <= m <= 12
+{
+ time_t secondsEpoch = mktime(&t); // seconds since the Epoch
+ t = *localtime(&secondsEpoch);
+ strftime(buffer, 32, "%a", localtime(&secondsEpoch));
+ return buffer;
+}
+
+// char *buffer;
+// buffer = ARM_RTC.getFormatedDateTime("%A %d-%m-%Y %H:%M:%S");
+// TFT.gotoxy(0,7);
+// TFT.printf("Date: %s\n", buffer);
+char * ARM_RTC::getFormatedDateTime(char *format)
+{
+ time_t t_seconds = time(NULL);
+ strftime(buffer, 40, format, localtime(&t_seconds));
+ return buffer;
+}
+
+bool ARM_RTC::getSummerTime(void)
+{
+ getDateTime(&t);
+
+ time_t secondsEpoch = mktime(&t); // seconds since the Epoch
+ t = *localtime(&secondsEpoch);
+ strftime(buffer, 32, "%j", localtime(&secondsEpoch));
+ int dayOfYearC = atoi(buffer);
+
+ strftime(buffer, 32, "%Y", localtime(&secondsEpoch));
+ int year = atoi(buffer);
+
+ int index = (year - 2011) * 5;
+ if (index < 0)
+ index = 0;
+ if (index > 440) // (2099 - 2011) * 5 = 440
+ index = 440;
+
+ int monthS = atoi(SummerTime[index+1]);
+ int dayS = atoi(SummerTime[index+2]);
+
+ t.tm_mon = monthS - 1; // adjust for tm structure required values
+ t.tm_mday = dayS;
+ secondsEpoch = mktime(&t); // seconds since the Epoch
+ t = *localtime(&secondsEpoch);
+ strftime(buffer, 32, "%j", localtime(&secondsEpoch));
+ int dayOfYearS = atoi(buffer);
+
+ int monthE = atoi(SummerTime[index+3]);
+ int dayE = atoi(SummerTime[index+4]);
+
+ t.tm_mon = monthE - 1; // adjust for tm structure required values
+ t.tm_mday = dayE;
+ secondsEpoch = mktime(&t); // seconds since the Epoch
+ t = *localtime(&secondsEpoch);
+ strftime(buffer, 32, "%j", localtime(&secondsEpoch));
+ int dayOfYearE = atoi(buffer);
+
+ return ((dayOfYearC >= dayOfYearS) && (dayOfYearC < dayOfYearE)) ? true : false;
+}
+
+int ARM_RTC::dayOfYearC(void)
+{
+ getDateTime(&t);
+
+ time_t secondsEpoch = mktime(&t); // seconds since the Epoch
+ strftime(buffer, 32, "%j", localtime(&secondsEpoch));
+ return atoi(buffer);
+}
+
+char * ARM_RTC::getSunRise(void)
+{
+ return (char*) SunRise[dayOfYearC()];
+}
+
+char * ARM_RTC::getSunSet(void)
+{
+ return (char*) SunSet[dayOfYearC()];
+}
+
+char * ARM_RTC::getDayLength(void)
+{
+ return (char*) DayLength[dayOfYearC()];
+}
+
+int ARM_RTC::getSunRiseMinute(void)
+{
+ int doy = dayOfYearC();
+ int h = atoi(substr((char*)SunRise[doy], 0, 2));
+ int m = atoi(substr((char*)SunRise[doy], 3, 2));
+ return h * 60 + m;
+}
+
+int ARM_RTC::getSunSetMinute(void)
+{
+ int doy = dayOfYearC();
+ int h = atoi(substr((char*)SunSet[doy], 0, 2));
+ int m = atoi(substr((char*)SunSet[doy], 3, 2));
+ return h * 60 + m;
+}
+
+bool ARM_RTC::checkSunRise(void)
+{
+ int dayOfWeek, mday, month, year, hours, minutes, seconds;
+// readDateTime(&dayOfWeek, &mday, &month, &year, &hours, &minutes, &seconds);
+
+// t.tm_year = year - 1900; // adjust for tm structure required values
+// t.tm_mon = month - 1; // adjust for tm structure required values
+// t.tm_mday = mday;
+// t.tm_hour = 0;
+// t.tm_min = 0;
+// t.tm_sec = 0;
+
+ int absMinute = t.tm_hour * 60 + t.tm_min;
+ int SunRiseMinute = getSunRiseMinute();
+ int SunSetMinute = getSunSetMinute();
+
+ return ((absMinute >= SunRiseMinute) && (absMinute < SunSetMinute)) ? true : false;
+}
+
+void ARM_RTC::substr(char *s, char *d, int pos, int len)
+{
+ char *t;
+ s = s+pos;
+ t = s+len;
+ while (s != t) {
+ *d=*s;
+ s++;
+ d++;
+ }
+ *d='\0';
+}
+
+char * ARM_RTC::substr(char *s, int pos, int len)
+{
+ char *t;
+ char *d;
+ d = buffer;
+ s = s+pos;
+ t = s+len;
+ while (s != t) {
+ *d=*s;
+ s++;
+ d++;
+ }
+ *d='\0';
+ return buffer;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ARM_RTC.h Mon Jul 23 12:25:27 2018 +0000
@@ -0,0 +1,415 @@
+/** mbded library for driving the PMAXIM ARM_RTC Real Time Clock
+* datasheet link : http://datasheets.maximintegrated.com/en/ds/ARM_RTC.pdf
+* breakout : MACETECH ChronoDot V2.1 High Precision RTC
+* remi cormier 2012
+* WARNING : sda and sdl should be pulled up with 2.2k resistor
+*/
+
+/** Example code
+* @code
+// ARM_RTC Library test program
+// remi cormier 2012
+
+#include "mbed.h"
+#include "ARM_RTC.h"
+
+Serial pc(USBTX, USBRX);
+
+int hour;
+int minute;
+int second;
+
+int dayOfWeek;
+int date;
+int month;
+int year;
+
+ARM_RTC RTC(p28,p27);
+
+
+int main()
+ {printf("\r\n\nARM_RTC Library test program\r\nremi cormier 2012\r\n\n");
+
+ RTC.setI2Cfrequency(400000);
+
+ //RTC.writeRegister(ARM_RTC_Aging_Offset,0); // uncomment to set Aging Offset 1LSB = approx. 0.1 ppm according from datasheet = 0.05 ppm @ 21 °C from my measurments
+
+ RTC.convertTemperature();
+
+ int reg=RTC.readRegister(ARM_RTC_Aging_Offset);
+ if (reg>127)
+ {reg=reg-256;}
+ pc.printf("Aging offset : %i\r\n",reg);
+
+ pc.printf("OSF flag : %i",RTC.OSF());
+ pc.printf("\r\n");
+
+ RTC.readDate(&date,&month,&year);
+ pc.printf("date : %02i-%02i-%02i",date,month,year);
+ pc.printf("\r\n");
+
+ //RTC.setTime(19,48,45); // uncomment to set time
+
+ RTC.readTime(&hour,&minute,&second);
+ pc.printf("time : %02i:%02i:%02i",hour,minute,second);
+ pc.printf("\r\n");
+
+ //RTC.setDate(6,22,12,2012); // uncomment to set date
+
+ RTC.readDateTime(&dayOfWeek,&date,&month,&year,&hour,&minute,&second);
+ pc.printf("date time : %i / %02i-%02i-%02i %02i:%02i:%02i",dayOfWeek,date,month,year,hour,minute,second);
+ pc.printf("\r\n");
+
+ pc.printf("temperature :%6.2f",RTC.readTemp());
+ pc.printf("\r\n");
+ }
+* @endcode
+*/
+
+/*
+http://www.cplusplus.com/reference/ctime/strftime/
+%a Abbreviated weekday name * Thu
+%A Full weekday name * Thursday
+%b Abbreviated month name * Aug
+%B Full month name * August
+%d Day of the month, zero-padded (01-31) 23
+%e Day of the month, space-padded ( 1-31) 23
+%F Short YYYY-MM-DD date, equivalent to %Y-%m-%d 2001-08-23
+%H Hour in 24h format (00-23) 14
+%j Day of the year (001-366) 235
+%m Month as a decimal number (01-12) 08
+%M Minute (00-59) 55
+%R 24-hour HH:MM time, equivalent to %H:%M 14:55
+%S Second (00-61) 02
+%T ISO 8601 time format (HH:MM:SS), equivalent to %H:%M:%S 14:55:02
+%u ISO 8601 weekday as number with Monday as 1 (1-7) 4
+%V ISO 8601 week number (00-53) 34
+%w Weekday as a decimal number with Sunday as 0 (0-6) 4
+%W Week number with the first Monday as the first day of week one (00-53) 34
+%X Time representation * 14:55:02
+%y Year, last two digits (00-99) 01
+%Y Year 2001
+
+http://www.cplusplus.com/reference/ctime/tm/
+Member Type Meaning Range
+tm_sec int seconds after the minute 0-61*
+tm_min int minutes after the hour 0-59
+tm_hour int hours since midnight 0-23
+tm_mday int day of the month 1-31
+tm_mon int months since January 0-11
+tm_year int years since 1900
+tm_wday int days since Sunday 0-6 (0 = Sunday)
+tm_yday int days since January 1 0-365
+tm_isdst int Daylight Saving Time flag
+The Daylight Saving Time flag (tm_isdst) is greater than zero if Daylight Saving Time is in effect,
+zero if Daylight Saving Time is not in effect, and less than zero if the information is not available.
+* tm_sec is generally 0-59. The extra range is to accommodate for leap seconds in certain systems.
+
+Member Type Meaning Range
+tm_sec int seconds after the minute 0-61*
+tm_min int minutes after the hour 0-59
+tm_hour int hours since midnight 0-23
+tm_mday int day of the month 1-31
+tm_mon int months since January 0-11
+tm_year int years since 1900
+tm_wday int days since Sunday 0-6
+tm_yday int days since January 1 0-365
+tm_isdst int Daylight Saving Time flag
+
+http://www.epochconverter.com/programming/c
+Convert from epoch to human readable date
+ time_t now;
+ struct tm ts;
+ char buf[80];
+ // Get current time
+ time(&now);
+ // Format time, "ddd yyyy-mm-dd hh:mm:ss zzz"
+ ts = *localtime(&now);
+ strftime(buf, sizeof(buf), "%a %Y-%m-%d %H:%M:%S %Z", &ts);
+ printf("%s\n", buf);
+
+Convert from human readable date to epoch
+ struct tm t;
+ time_t t_of_day;
+ t.tm_year = 2011-1900;
+ t.tm_mon = 7; // Month, 0 - jan
+ t.tm_mday = 8; // Day of the month
+ t.tm_hour = 16;
+ t.tm_min = 11;
+ t.tm_sec = 42;
+ t.tm_isdst = -1; // Is DST on? 1 = yes, 0 = no, -1 = unknown
+ t_of_day = mktime(&t);
+ printf("seconds since the Epoch: %ld\n", (long) t_of_day)
+
+Convert to struct tm
+ time_t rawtime;
+ struct tm * t;
+ time(&rawtime);
+ t = localtime(&rawtime);
+ printf("%d\n", t->tm_sec);
+
+
+https://github.com/raburton/esp8266/blob/master/drivers/ARM_RTC.c
+https://github.com/raburton/esp8266/blob/master/drivers/ARM_RTC.h
+
+*/
+#include <mbed.h>
+#include "TableSummerTime.h"
+#include "TableDayLight.h"
+
+#ifndef MBED_ARM_RTC_H
+#define MBED_ARM_RTC_H
+
+//ARM_RTC 8 bit adress
+#define ARM_RTC_ADDR 0x68 // 0x68 << 1 = 0xD0
+
+#define ARM_RTC_STAT_OSCILLATOR 0x80
+#define ARM_RTC_STAT_32KHZ 0x08
+#define ARM_RTC_STAT_BUSY 0x04
+#define ARM_RTC_STAT_ALARM_2 0x02
+#define ARM_RTC_STAT_ALARM_1 0x01
+
+//ARM_RTC registers
+#define ARM_RTC_Seconds 0x00
+#define ARM_RTC_Minutes 0x01
+#define ARM_RTC_Hours 0x02
+// ARM_RTC Hours bits
+#define ARM_RTC_bit_AM_PM 0x20
+#define ARM_RTC_bit_12_24 0x40
+
+#define ARM_RTC_Day 0x03
+#define ARM_RTC_Date 0x04
+#define ARM_RTC_Month_Century 0x05
+#define ARM_RTC_Year 0x06
+
+#define ARM_RTC_Alarm1_Seconds 0x07
+#define ARM_RTC_Alarm1_Minutes 0x08
+#define ARM_RTC_Alarm1_Hours 0x09
+#define ARM_RTC_Alarm1_Day_Date 0x0A
+
+#define ARM_RTC_Alarm2_Minutes 0x0B
+#define ARM_RTC_Alarm2_Hours 0x0C
+#define ARM_RTC_Alarm_2_Day_Date 0x0D
+
+#define ARM_RTC_Control 0x0E
+
+// ARM_RTC Control bits
+#define ARM_RTC_bit_A1IE 0x01
+#define ARM_RTC_bit_A2IE 0x02
+#define ARM_RTC_bit_INTCN 0x04
+#define ARM_RTC_bit_SQW_1Hz 0x00
+#define ARM_RTC_bit_SQW_1024Hz 0x08
+#define ARM_RTC_bit_SQW_4096Hz 0x10
+#define ARM_RTC_bit_SQW_8192Hz 0x18
+#define ARM_RTC_bit_CONV 0x20
+#define ARM_RTC_bit_BBSQW 0x40
+#define ARM_RTC_bit_EOSCb 0x80
+
+#define ARM_RTC_CTRL_ALARM1_INT 0x01
+#define ARM_RTC_CTRL_ALARM2_INT 0x02
+#define ARM_RTC_CTRL_ALARM_INTS 0x04
+#define ARM_RTC_CTRL_SQWAVE_1HZ 0x00
+#define ARM_RTC_CTRL_SQWAVE_1024HZ 0x08
+#define ARM_RTC_CTRL_SQWAVE_4096HZ 0x10
+#define ARM_RTC_CTRL_SQWAVE_8192HZ 0x18
+#define ARM_RTC_CTRL_TEMPCONV 0x20
+#define ARM_RTC_CTRL_SQUAREWAVE_BB 0x40
+#define ARM_RTC_CTRL_OSCILLATOR 0x80
+
+#define ARM_RTC_ALARM_NONE 0
+#define ARM_RTC_ALARM_1 1
+#define ARM_RTC_ALARM_2 2
+#define ARM_RTC_ALARM_BOTH 3
+
+#define ARM_RTC_ALARM1_EVERY_SECOND 0
+#define ARM_RTC_ALARM1_MATCH_SEC 1
+#define ARM_RTC_ALARM1_MATCH_SECMIN 2
+#define ARM_RTC_ALARM1_MATCH_SECMINHOUR 3
+#define ARM_RTC_ALARM1_MATCH_SECMINHOURDAY 4
+#define ARM_RTC_ALARM1_MATCH_SECMINHOURDATE 5
+
+#define ARM_RTC_ALARM2_EVERY_MIN 0
+#define ARM_RTC_ALARM2_MATCH_MIN 1
+#define ARM_RTC_ALARM2_MATCH_MINHOUR 2
+#define ARM_RTC_ALARM2_MATCH_MINHOURDAY 3
+#define ARM_RTC_ALARM2_MATCH_MINHOURDATE 4
+
+#define ARM_RTC_ALARM_WDAY 0x40
+#define ARM_RTC_ALARM_NOTSET 0x80
+
+#define ARM_RTC_ADDR_TIME 0x00
+#define ARM_RTC_ADDR_ALARM1 0x07
+#define ARM_RTC_ADDR_ALARM2 0x0b
+#define ARM_RTC_ADDR_CONTROL 0x0e
+#define ARM_RTC_ADDR_STATUS 0x0f
+#define ARM_RTC_ADDR_AGING 0x10
+#define ARM_RTC_ADDR_TEMP 0x11
+
+#define ARM_RTC_SET 0
+#define ARM_RTC_CLEAR 1
+#define ARM_RTC_REPLACE 2
+
+#define ARM_RTC_12HOUR_FLAG 0x40
+#define ARM_RTC_12HOUR_MASK 0x1f
+#define ARM_RTC_PM_FLAG 0x20
+#define ARM_RTC_MONTH_MASK 0x1f
+
+#define ARM_RTC_Control_Status 0x0F
+
+// ARM_RTC Control/Status bits
+#define ARM_RTC_bit_BSY 0x04
+#define ARM_RTC_bit_EN32kHz 0x08
+#define ARM_RTC_bit_OSF 0x80
+
+#define ARM_RTC_Aging_Offset 0x10
+#define ARM_RTC_MSB_Temp 0x11
+#define ARM_RTC_LSB_Temp 0x12
+
+#define NTP_OFFSET 2208988800ULL
+
+/* Interface to MAXIM ARM_RTC RTC */
+class ARM_RTC
+{
+public :
+ /** Create an instance of the ARM_RTC connected to specfied I2C pins
+ *
+ * @param sda The I2C data pin
+ * @param scl The I2C clock pin
+ */
+ ARM_RTC();
+
+ bool checkTimeLost(void);
+
+ /** Set the time registers
+ * @param seconds since 1900
+ */
+ void setDateTimeSecsSince1900(uint32_t secsSince1900);
+
+ /** Set the time registers
+ * @param seconds since 1970
+ */
+ void setDateTimeSecsSince1970(uint32_t secsSince1970);
+
+ /** Set the time registers
+ * @return seconds since 1970
+ */
+ uint32_t getDateTimeSecsSince1970(void);
+ time_t getDateTimeSecsSince1970TZ(void);
+
+ /** Set the time zone
+ * @param hours offset
+ * @return void
+ */
+ void setTimeZone(double TZ);
+
+ /** Get the time zone
+ * @param void
+ * @return hours offset
+ */
+ double getTimeZone(void);
+
+ /** Set the date registers
+ * // @param dayOfWeek : day of week
+ * @param date
+ * @param month
+ * @param year
+ */
+ void setDate(int date, int month, int year);
+
+ /** Set the time registers
+ * @param hours
+ * @param minutes
+ * @param seconds
+ */
+ void setTime(int hours, int minutes, int seconds);
+
+ /** Read the date and time and set system clock
+ */
+ void setSystemClock(void);
+
+ void readDateTime(void);
+
+ /** Set the time
+ * @param hours
+ * @param minutes
+ * @param seconds
+ * @param day
+ * @param month
+ * @param year
+ */
+ void setDateTime(int day, int month, int year, int hours, int minutes, int seconds);
+
+ /** Set the time registers
+ * @param struct tm *time
+ */
+ void setDateTime(struct tm *time);
+
+ /** Get the time registers
+ * @return struct tm *time
+ */
+ void getDateTime(struct tm *time);
+ struct tm *getDateTime(void);
+
+ int getDayOfWeek(int date, int month, int year);
+
+ char * getDayOfWeekName(void);
+
+ char * getFormatedDateTime(char *format);
+
+ bool error;
+
+ bool getSummerTime(void);
+
+ int dayOfYearC(void);
+ char * getSunRise(void);
+ char * getSunSet(void);
+ char * getDayLength(void);
+ int getSunRiseMinute(void);
+ int getSunSetMinute(void);
+ bool checkSunRise(void);
+
+ void substr(char *s, char *d, int pos, int len);
+ char * substr(char *s, int pos, int len);
+
+ int bcd2dec(int k); // bcd to decimal conversion
+ int dec2bcd(int k); // decimal to bcd conversion
+
+private :
+// I2C i2c;
+// char ARM_RTC_Address;
+// void decodeTime(int regHours, int regMinutes, int regSeconds,int *Hours, int *Minutes, int *Seconds);
+// void decodeDate(int regDate,int regMonth, int regYear, int *date, int *month, int *year);
+
+ char buffer[40];
+
+ uint32_t timeZoneOffset;
+ char timeZoneName[32];
+ bool dayLightSaving;
+
+ struct tm t;
+// t.tm_sec = -1;
+// t.tm_min = -1;
+// t.tm_hour = -1;
+// t.tm_mday = -1;
+// t.tm_wday = -1;
+// t.tm_yday = -1;
+// t.tm_mon = -1;
+// t.tm_year = -1;
+
+ time_t secondsEpoch;
+
+ struct DateTime{
+ int year;
+ int mon;
+ int mday;
+ int wday;
+ int yday;
+ int hour;
+ int min;
+ int sec;
+ };
+
+
+};
+
+#endif
\ No newline at end of file
--- a/DS3231.cpp Sat Dec 22 19:58:42 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,138 +0,0 @@
-#include "DS3231.h"
-
-DS3231::DS3231(PinName sda, PinName scl) : i2c(sda, scl)
- {
- }
-
-
-// BCD to decimal conversion
-int DS3231::bcd2dec(int k)
- {return(((k&0xF0)>>4)*10+(k&0x0F));}
-
-
-// decimal to BCD conversion
-int DS3231::dec2bcd(int k)
- {return((k/10)*16+(k%10));}
-
-void DS3231::setI2Cfrequency(int frequency)
- {i2c.frequency(frequency);
- }
-
-// read temperature from DS3231
-float DS3231::readTemp()
- {char buf[2];
- buf[0]=DS3231_MSB_Temp;
- int w=i2c.write(DS3231_Address,buf,1);
- int r=i2c.read(DS3231_Address,buf,2);
- error=((w!=0)||(r!=0));
- return(buf[0]+buf[1]/256.0);}
-
-// force temperatue conversion
-void DS3231::convertTemperature()
- {int Control=readRegister(DS3231_Control)|DS3231_bit_CONV;
- writeRegister(DS3231_Control,Control);
- }
-
-// decode time registers
-void DS3231::decodeTime(int regHours, int regMinutes, int regSeconds,int *Hours, int *Minutes, int *Seconds)
- {*Hours=bcd2dec(regHours);
- *Minutes=bcd2dec(regMinutes);
- *Seconds=bcd2dec(regSeconds);
- }
-
-
-// read time registers dand decode them to decimal
-void DS3231::readTime(int *hours, int *minutes, int *seconds)
- {char buf[3];
- buf[0]=DS3231_Seconds;
- int w=i2c.write(DS3231_Address,buf,1);
- int r=i2c.read(DS3231_Address,buf,3);
- decodeTime(buf[2],buf[1],buf[0],hours,minutes,seconds);
- error=((w!=0)||(r!=0));
- }
-
-// set time register
-void DS3231::setTime(int hours, int minutes, int seconds)
- {writeRegister(DS3231_Seconds,dec2bcd(seconds));
- writeRegister(DS3231_Minutes,dec2bcd(minutes));
- writeRegister(DS3231_Hours,dec2bcd(hours));
- }
-
-// decode date registers
-void DS3231::decodeDate(int regDate,int regMonth, int regYear, int *date, int *month, int *year)
- {*date=bcd2dec(regDate);
- int century=regMonth&128;
- *month=bcd2dec(regMonth&127);
- *year=bcd2dec(regYear);
- if (century==0) // only XXth and XXIst centuries allowed
- {*year=*year+1900;}
- else
- {*year=*year+2000;}
- }
-
-// read date registers
-void DS3231::readDate(int *date, int *month, int *year)
- {char buf[3];
- buf[0]=DS3231_Date;
- int w=i2c.write(DS3231_Address,buf,1);
- int r=i2c.read(DS3231_Address,buf,3);
- decodeDate(buf[0],buf[1],buf[2],date,month,year);
- error=((w!=0)||(r!=0));
- }
-
-// set the date registers
-void DS3231::setDate(int dayOfWeek, int date, int month, int year)
- {writeRegister(DS3231_Date,dec2bcd(date));
- writeRegister(DS3231_Day,dayOfWeek);
- int century=0; // only XXth and XXIst centuries allowed
- if (year<1900){year=1900;}
- if (year>2099){year=2099;}
- if (year<2000)
- {year=year-1900;}
- else
- {year=year-2000;century=1;}
- writeRegister(DS3231_Month_Century,dec2bcd(month)+128*century);
- writeRegister(DS3231_Year,dec2bcd(year));
- }
-
-// read date and time registers
-void DS3231::readDateTime(int *dayOfWeek, int *date, int *month, int *year, int *hours, int *minutes, int *seconds)
- {char buf[7];
- buf[0]=DS3231_Seconds;
- int w=i2c.write(DS3231_Address,buf,1);
- int r=i2c.read(DS3231_Address,buf,7);
- decodeTime(buf[2],buf[1],buf[0],hours,minutes,seconds);
- *dayOfWeek=buf[3];
- decodeDate(buf[4],buf[5],buf[6],date,month,year);
- error=((w!=0)||(r!=0));
- }
-
-// read a register
-int DS3231::readRegister(char reg)
- {char buf[1];
- buf[0]=reg;
- int w=i2c.write(DS3231_Address,buf,1);
- int r=i2c.read(DS3231_Address,buf,1);
- error=((w!=0)||(r!=0));
- return(buf[0]);
- }
-
-// write a register
-void DS3231::writeRegister(int reg,char byte)
- {char buf[2];
- buf[0]=reg;
- buf[1]=byte;
- int w=i2c.write(DS3231_Address,buf,2);
- error=(w!=0);
- }
-
-void DS3231::eraseOSF()
- {int reg=readRegister(DS3231_Control_Status);
- reg=reg&0x7F;
- writeRegister(DS3231_Control_Status,reg);
- }
-
-bool DS3231::OSF()
- {int reg=readRegister(DS3231_Control_Status);
- return(reg&DS3231_bit_OSF);
- }
\ No newline at end of file
--- a/DS3231.h Sat Dec 22 19:58:42 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,222 +0,0 @@
-/** mbded library for driving the PMAXIM DS3231 Real Time Clock
-* datasheet link : http://datasheets.maximintegrated.com/en/ds/DS3231.pdf
-* breakout : MACETECH ChronoDot V2.1 High Precision RTC
-* remi cormier 2012
-* WARNING : sda and sdl should be pulled up with 2.2k resistor
-*/
-
-/** Example code
-* @code
-// DS3231 Library test program
-// remi cormier 2012
-
-#include "mbed.h"
-#include "DS3231.h"
-
-Serial pc(USBTX, USBRX);
-
-int hour;
-int minute;
-int second;
-
-int dayOfWeek;
-int date;
-int month;
-int year;
-
-DS3231 RTC(p28,p27);
-
-
-int main()
- {printf("\r\n\nDS3231 Library test program\r\nremi cormier 2012\r\n\n");
-
- RTC.setI2Cfrequency(400000);
-
- //RTC.writeRegister(DS3231_Aging_Offset,0); // uncomment to set Aging Offset 1LSB = approx. 0.1 ppm according from datasheet = 0.05 ppm @ 21 °C from my measurments
-
- RTC.convertTemperature();
-
- int reg=RTC.readRegister(DS3231_Aging_Offset);
- if (reg>127)
- {reg=reg-256;}
- pc.printf("Aging offset : %i\r\n",reg);
-
- pc.printf("OSF flag : %i",RTC.OSF());
- pc.printf("\r\n");
-
- RTC.readDate(&date,&month,&year);
- pc.printf("date : %02i-%02i-%02i",date,month,year);
- pc.printf("\r\n");
-
- //RTC.setTime(19,48,45); // uncomment to set time
-
- RTC.readTime(&hour,&minute,&second);
- pc.printf("time : %02i:%02i:%02i",hour,minute,second);
- pc.printf("\r\n");
-
- //RTC.setDate(6,22,12,2012); // uncomment to set date
-
- RTC.readDateTime(&dayOfWeek,&date,&month,&year,&hour,&minute,&second);
- pc.printf("date time : %i / %02i-%02i-%02i %02i:%02i:%02i",dayOfWeek,date,month,year,hour,minute,second);
- pc.printf("\r\n");
-
- pc.printf("temperature :%6.2f",RTC.readTemp());
- pc.printf("\r\n");
- }
-* @endcode
-*/
-
-
-#include "mbed.h"
-
-#ifndef MBED_DS3231_H
-#define MBED_DS3231_H
-
-//DS3231 8 bit adress
-#define DS3231_Address 0xD0
-
-//DS3231 registers
-#define DS3231_Seconds 0x00
-#define DS3231_Minutes 0x01
-#define DS3231_Hours 0x02
-// DS3231 Hours bits
-#define DS3231_bit_AM_PM 0x20
-#define DS3231_bit_12_24 0x40
-
-#define DS3231_Day 0x03
-#define DS3231_Date 0x04
-#define DS3231_Month_Century 0x05
-#define DS3231_Year 0x06
-#define DS3231_Alarm1_Seconds 0x07
-#define DS3231_Alarm1_Minutes 0x08
-#define DS3231_Alarm1_Hours 0x09
-#define DS3231_Alarm1_Day_Date 0x0A
-#define DS3231_Alarm2_Minutes 0x0B
-#define DS3231_Alarm2_Hours 0x0C
-#define DS3231_Alarm_2_Day_Date 0x0D
-
-#define DS3231_Control 0x0E
-// DS3231 Control bits
-#define DS3231_bit_A1IE 1
-#define DS3231_bit_A2IE 2
-#define DS3231_bit_INTCN 4
-#define DS3231_bit_SQW_1Hz 0
-#define DS3231_bit_SQW_1024Hz 8
-#define DS3231_bit_SQW_4096Hz 16
-#define DS3231_bit_SQW_8192Hz 24
-#define DS3231_bit_CONV 32
-#define DS3231_bit_BBSQW 64
-#define DS3231_bit_EOSCb 128
-
-
-#define DS3231_Control_Status 0x0F
-// DS3231 Control/Status bits
-#define DS3231_bit_BSY 0x04
-#define DS3231_bit_EN32kHz 0x08
-#define DS3231_bit_OSF 0x80
-
-#define DS3231_Aging_Offset 0x10
-#define DS3231_MSB_Temp 0x11
-#define DS3231_LSB_Temp 0x12
-
-/* Interface to MAXIM DS3231 RTC */
-class DS3231
- {public :
- /** Create an instance of the DS3231 connected to specfied I2C pins
- *
- * @param sda The I2C data pin
- * @param scl The I2C clock pin
- */
- DS3231(PinName sda, PinName scl);
-
- /** set I2C bus speed
- * @param frequency : I2C clocl frequenct (Hz)
- */
- void setI2Cfrequency(int frequency);
-
- /** Read the temperature
- *
- * @return The temperature
- */
- float readTemp();
-
- /** Read the time registers
- * @param hours
- * @param minutes
- * @param seconds
- */
- void readTime(int *hours, int *minutes, int *seconds);
-
- /** force temperature conversion
- *
- */
- void convertTemperature();
-
- /** Set the time registers
- * @param hours
- * @param minutes
- * @param seconds
- */
- void setTime(int hours, int minutes, int seconds);
-
- /** Read the date registers
- * @param date
- * @param month
- * @param year
- */
- void readDate(int *date, int *month, int *year);
-
- /** Set the date registers
- * @param dayOfWeek : day of week
- * @param date
- * @param month
- * @param year
- */
- void setDate(int dayOfWeek, int date, int month, int year);
-
- /** Read the date and time registers
- * @param dayOfWeek : day of week
- * @param date
- * @param month
- * @param year
- * @param hours
- * @param minutes
- * @param seconds
- */
- void readDateTime(int *dayOfWeek, int *date, int *month, int *year, int *hours, int *minutes, int *seconds);
-
- /** Read a register
- * @param reg : register address
- * @return The register content
- */
- int readRegister(char reg);
-
- /** Write to a register
- * @param reg : register address
- * @param The register content
- */
- void writeRegister(int reg,char byte);
-
- /** set OSF (Oscillator Stop Flag) bit to 0 in Control Status register
- * should be done just after power up DS3231
- * OSF bit is automaticaly set to 1 when on power up or when the DS3231 oscillator stops
- */
- void eraseOSF();
-
- /** Return OSF bit. If true the oscillator stopped or the DS3231 just powered up
- * @return The OSF bit
- */
- bool OSF();
-
- bool error;
-
- private :
- I2C i2c;
- int bcd2dec(int k); // bcd to decimal conversion
- int dec2bcd(int k); // decimal to bcd conversion
- void decodeTime(int regHours, int regMinutes, int regSeconds,int *Hours, int *Minutes, int *Seconds);
- void decodeDate(int regDate,int regMonth, int regYear, int *date, int *month, int *year);
- };
-
-
-#endif
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/TableDayLight.h Mon Jul 23 12:25:27 2018 +0000
@@ -0,0 +1,149 @@
+ const char * const SunRise[] = {
+// const string SunRise[] = {
+ "08:50", "08:50", "08:49", "08:49", "08:49", "08:48", "08:48", "08:47",
+ "08:47", "08:46", "08:45", "08:44", "08:44", "08:43", "08:42", "08:41",
+ "08:40", "08:39", "08:38", "08:37", "08:35", "08:34", "08:33", "08:32",
+ "08:30", "08:29", "08:27", "08:26", "08:24", "08:23", "08:21", "08:20",
+ "08:18", "08:16", "08:15", "08:13", "08:11", "08:09", "08:08", "08:06",
+ "08:04", "08:02", "08:00", "07:58", "07:56", "07:54", "07:52", "07:50",
+ "07:48", "07:46", "07:44", "07:42", "07:40", "07:37", "07:35", "07:33",
+ "07:31", "07:29", "07:27", "07:24", "07:22", "07:20", "07:18", "07:15",
+ "07:13", "07:11", "07:08", "07:06", "07:04", "07:02", "06:59", "06:57",
+ "06:55", "06:52", "06:50", "06:48", "06:45", "06:43", "06:41", "06:38",
+ "06:36", "06:34", "06:31", "06:29", "06:26", "06:24", "06:22", "06:19",
+ "06:17", "07:15", "07:12", "07:10", "07:08", "07:05", "07:03", "07:01",
+ "06:59", "06:56", "06:54", "06:52", "06:49", "06:47", "06:45", "06:43",
+ "06:41", "06:38", "06:36", "06:34", "06:32", "06:30", "06:28", "06:25",
+ "06:23", "06:21", "06:19", "06:17", "06:15", "06:13", "06:11", "06:09",
+ "06:07", "06:05", "06:03", "06:02", "06:00", "05:58", "05:56", "05:54",
+ "05:53", "05:51", "05:49", "05:48", "05:46", "05:45", "05:43", "05:41",
+ "05:40", "05:39", "05:37", "05:36", "05:35", "05:33", "05:32", "05:31",
+ "05:30", "05:29", "05:28", "05:27", "05:26", "05:25", "05:24", "05:23",
+ "05:22", "05:22", "05:21", "05:20", "05:20", "05:19", "05:19", "05:18",
+ "05:18", "05:18", "05:17", "05:17", "05:17", "05:17", "05:17", "05:17",
+ "05:17", "05:17", "05:17", "05:18", "05:18", "05:18", "05:19", "05:19",
+ "05:20", "05:20", "05:21", "05:21", "05:22", "05:23", "05:23", "05:24",
+ "05:25", "05:26", "05:27", "05:28", "05:29", "05:30", "05:31", "05:32",
+ "05:33", "05:35", "05:36", "05:37", "05:38", "05:40", "05:41", "05:42",
+ "05:44", "05:45", "05:46", "05:48", "05:49", "05:51", "05:52", "05:54",
+ "05:55", "05:57", "05:58", "06:00", "06:01", "06:03", "06:05", "06:06",
+ "06:08", "06:09", "06:11", "06:13", "06:14", "06:16", "06:18", "06:19",
+ "06:21", "06:23", "06:24", "06:26", "06:27", "06:29", "06:31", "06:32",
+ "06:34", "06:36", "06:37", "06:39", "06:41", "06:42", "06:44", "06:46",
+ "06:47", "06:49", "06:51", "06:52", "06:54", "06:56", "06:57", "06:59",
+ "07:01", "07:02", "07:04", "07:06", "07:07", "07:09", "07:11", "07:12",
+ "07:14", "07:15", "07:17", "07:19", "07:20", "07:22", "07:24", "07:25",
+ "07:27", "07:29", "07:30", "07:32", "07:34", "07:35", "07:37", "07:39",
+ "07:41", "07:42", "07:44", "07:46", "07:47", "07:49", "07:51", "07:53",
+ "07:54", "07:56", "07:58", "07:59", "08:01", "08:03", "08:05", "08:06",
+ "08:08", "08:10", "08:12", "08:14", "08:15", "08:17", "08:19", "08:21",
+ "08:23", "08:24", "08:26", "07:28", "07:30", "07:32", "07:33", "07:35",
+ "07:37", "07:39", "07:41", "07:43", "07:44", "07:46", "07:48", "07:50",
+ "07:52", "07:54", "07:55", "07:57", "07:59", "08:01", "08:02", "08:04",
+ "08:06", "08:08", "08:09", "08:11", "08:13", "08:14", "08:16", "08:18",
+ "08:19", "08:21", "08:22", "08:24", "08:25", "08:27", "08:28", "08:30",
+ "08:31", "08:32", "08:34", "08:35", "08:36", "08:37", "08:38", "08:39",
+ "08:40", "08:41", "08:42", "08:43", "08:44", "08:45", "08:46", "08:46",
+ "08:47", "08:47", "08:48", "08:48", "08:49", "08:49", "08:49", "08:50",
+ "08:50", "08:50", "08:50", "08:50", "08:50", "08:50"
+ };
+
+ const char * const SunSet[] = {
+// const string SunSet[] = {
+ "16:38", "16:39", "16:40", "16:41", "16:43", "16:44", "16:45", "16:47",
+ "16:48", "16:50", "16:51", "16:53", "16:54", "16:56", "16:57", "16:59",
+ "17:01", "17:02", "17:04", "17:06", "17:07", "17:09", "17:11", "17:13",
+ "17:15", "17:16", "17:18", "17:20", "17:22", "17:24", "17:26", "17:28",
+ "17:29", "17:31", "17:33", "17:35", "17:37", "17:39", "17:41", "17:43",
+ "17:44", "17:46", "17:48", "17:50", "17:52", "17:54", "17:56", "17:58",
+ "18:00", "18:01", "18:03", "18:05", "18:07", "18:09", "18:11", "18:13",
+ "18:14", "18:16", "18:18", "18:20", "18:22", "18:24", "18:25", "18:27",
+ "18:29", "18:31", "18:33", "18:34", "18:36", "18:38", "18:40", "18:42",
+ "18:43", "18:45", "18:47", "18:49", "18:50", "18:52", "18:54", "18:56",
+ "18:57", "18:59", "19:01", "19:03", "19:04", "19:06", "19:08", "19:10",
+ "19:11", "20:13", "20:15", "20:17", "20:18", "20:20", "20:22", "20:23",
+ "20:25", "20:27", "20:29", "20:30", "20:32", "20:34", "20:36", "20:37",
+ "20:39", "20:41", "20:43", "20:44", "20:46", "20:48", "20:49", "20:51",
+ "20:53", "20:55", "20:56", "20:58", "21:00", "21:02", "21:03", "21:05",
+ "21:07", "21:08", "21:10", "21:12", "21:13", "21:15", "21:17", "21:18",
+ "21:20", "21:22", "21:23", "21:25", "21:26", "21:28", "21:30", "21:31",
+ "21:33", "21:34", "21:36", "21:37", "21:39", "21:40", "21:41", "21:43",
+ "21:44", "21:45", "21:47", "21:48", "21:49", "21:50", "21:52", "21:53",
+ "21:54", "21:55", "21:56", "21:57", "21:58", "21:59", "22:00", "22:00",
+ "22:01", "22:02", "22:02", "22:03", "22:04", "22:04", "22:05", "22:05",
+ "22:05", "22:06", "22:06", "22:06", "22:06", "22:06", "22:06", "22:06",
+ "22:06", "22:06", "22:06", "22:06", "22:06", "22:05", "22:05", "22:04",
+ "22:04", "22:03", "22:03", "22:02", "22:01", "22:01", "22:00", "21:59",
+ "21:58", "21:57", "21:56", "21:55", "21:54", "21:53", "21:52", "21:50",
+ "21:49", "21:48", "21:46", "21:45", "21:44", "21:42", "21:41", "21:39",
+ "21:38", "21:36", "21:34", "21:33", "21:31", "21:29", "21:27", "21:26",
+ "21:24", "21:22", "21:20", "21:18", "21:16", "21:14", "21:12", "21:10",
+ "21:08", "21:06", "21:04", "21:02", "21:00", "20:58", "20:56", "20:54",
+ "20:52", "20:50", "20:47", "20:45", "20:43", "20:41", "20:38", "20:36",
+ "20:34", "20:32", "20:29", "20:27", "20:25", "20:23", "20:20", "20:18",
+ "20:16", "20:13", "20:11", "20:09", "20:06", "20:04", "20:01", "19:59",
+ "19:57", "19:54", "19:52", "19:50", "19:47", "19:45", "19:42", "19:40",
+ "19:38", "19:35", "19:33", "19:31", "19:28", "19:26", "19:24", "19:21",
+ "19:19", "19:17", "19:14", "19:12", "19:10", "19:07", "19:05", "19:03",
+ "19:00", "18:58", "18:56", "18:54", "18:51", "18:49", "18:47", "18:45",
+ "18:42", "18:40", "18:38", "18:36", "18:34", "18:32", "18:30", "18:28",
+ "18:26", "18:23", "18:21", "17:19", "17:18", "17:16", "17:14", "17:12",
+ "17:10", "17:08", "17:06", "17:04", "17:03", "17:01", "16:59", "16:58",
+ "16:56", "16:54", "16:53", "16:51", "16:50", "16:48", "16:47", "16:46",
+ "16:44", "16:43", "16:42", "16:40", "16:39", "16:38", "16:37", "16:36",
+ "16:35", "16:34", "16:33", "16:32", "16:32", "16:31", "16:30", "16:30",
+ "16:29", "16:29", "16:28", "16:28", "16:27", "16:27", "16:27", "16:27",
+ "16:27", "16:27", "16:27", "16:27", "16:27", "16:27", "16:27", "16:27",
+ "16:28", "16:28", "16:29", "16:29", "16:30", "16:31", "16:31", "16:32",
+ "16:33", "16:34", "16:35", "16:36", "16:37", "16:37"
+ };
+
+ const char * const DayLength[] = {
+// const string DayLength[] = {
+ "07:48", "07:49", "07:51", "07:52", "07:54", "07:55", "07:57", "07:59",
+ "08:01", "08:03", "08:05", "08:08", "08:10", "08:13", "08:15", "08:18",
+ "08:20", "08:23", "08:26", "08:29", "08:32", "08:35", "08:38", "08:41",
+ "08:44", "08:47", "08:50", "08:54", "08:57", "09:00", "09:04", "09:07",
+ "09:11", "09:14", "09:18", "09:22", "09:25", "09:29", "09:33", "09:36",
+ "09:40", "09:44", "09:48", "09:52", "09:55", "09:59", "10:03", "10:07",
+ "10:11", "10:15", "10:19", "10:23", "10:27", "10:31", "10:35", "10:39",
+ "10:43", "10:47", "10:51", "10:55", "10:59", "11:03", "11:07", "11:11",
+ "11:15", "11:20", "11:24", "11:28", "11:32", "11:36", "11:40", "11:44",
+ "11:48", "11:52", "11:56", "12:01", "12:05", "12:09", "12:13", "12:17",
+ "12:21", "12:25", "12:29", "12:33", "12:37", "12:42", "12:46", "12:50",
+ "12:54", "12:58", "13:02", "13:06", "13:10", "13:14", "13:18", "13:22",
+ "13:26", "13:30", "13:34", "13:38", "13:42", "13:46", "13:50", "13:54",
+ "13:58", "14:02", "14:06", "14:10", "14:14", "14:18", "14:21", "14:25",
+ "14:29", "14:33", "14:37", "14:40", "14:44", "14:48", "14:52", "14:55",
+ "14:59", "15:03", "15:06", "15:10", "15:13", "15:17", "15:20", "15:23",
+ "15:27", "15:30", "15:33", "15:37", "15:40", "15:43", "15:46", "15:49",
+ "15:52", "15:55", "15:58", "16:01", "16:04", "16:06", "16:09", "16:11",
+ "16:14", "16:16", "16:19", "16:21", "16:23", "16:25", "16:27", "16:29",
+ "16:31", "16:33", "16:34", "16:36", "16:38", "16:39", "16:40", "16:41",
+ "16:43", "16:44", "16:45", "16:45", "16:46", "16:47", "16:47", "16:48",
+ "16:48", "16:48", "16:48", "16:48", "16:48", "16:48", "16:47", "16:47",
+ "16:46", "16:46", "16:45", "16:44", "16:43", "16:42", "16:41", "16:40",
+ "16:38", "16:37", "16:35", "16:34", "16:32", "16:30", "16:28", "16:26",
+ "16:24", "16:22", "16:20", "16:17", "16:15", "16:13", "16:10", "16:08",
+ "16:05", "16:02", "16:00", "15:57", "15:54", "15:51", "15:48", "15:45",
+ "15:42", "15:39", "15:35", "15:32", "15:29", "15:26", "15:22", "15:19",
+ "15:16", "15:12", "15:09", "15:05", "15:02", "14:58", "14:54", "14:51",
+ "14:47", "14:43", "14:40", "14:36", "14:32", "14:28", "14:25", "14:21",
+ "14:17", "14:13", "14:09", "14:06", "14:02", "13:58", "13:54", "13:50",
+ "13:46", "13:42", "13:38", "13:34", "13:30", "13:26", "13:22", "13:18",
+ "13:14", "13:10", "13:06", "13:02", "12:58", "12:54", "12:50", "12:46",
+ "12:42", "12:38", "12:34", "12:30", "12:26", "12:22", "12:18", "12:14",
+ "12:10", "12:06", "12:02", "11:58", "11:54", "11:50", "11:46", "11:42",
+ "11:38", "11:34", "11:30", "11:26", "11:22", "11:18", "11:14", "11:10",
+ "11:06", "11:02", "10:58", "10:54", "10:50", "10:46", "10:42", "10:38",
+ "10:34", "10:30", "10:26", "10:22", "10:18", "10:14", "10:10", "10:06",
+ "10:02", "09:59", "09:55", "09:51", "09:47", "09:43", "09:40", "09:36",
+ "09:32", "09:29", "09:25", "09:21", "09:18", "09:14", "09:11", "09:07",
+ "09:04", "09:00", "08:57", "08:54", "08:50", "08:47", "08:44", "08:41",
+ "08:38", "08:35", "08:32", "08:29", "08:26", "08:23", "08:21", "08:18",
+ "08:15", "08:13", "08:10", "08:08", "08:06", "08:04", "08:01", "07:59",
+ "07:58", "07:56", "07:54", "07:52", "07:51", "07:49", "07:48", "07:47",
+ "07:46", "07:45", "07:44", "07:43", "07:42", "07:42", "07:41", "07:41",
+ "07:41", "07:40", "07:40", "07:40", "07:41", "07:41", "07:41", "07:42",
+ "07:43", "07:43", "07:44", "07:45", "07:46", "07:46"
+ };
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/TableSummerTime.h Mon Jul 23 12:25:27 2018 +0000
@@ -0,0 +1,67 @@
+/*
+http://hemel.waarnemen.com/aarde/zomertijd.html#2016
+De zomertijd (of zomeruur) begint in de EU op de laatste zondag van maart en eindigt op de laatste zondag van oktober.
+Dit gebeurt in alle lidstaten op hetzelfde moment.
+In België en Nederland is dat 's nachts om 2 uur wintertijd (of winteruur; MET).
+In het voorjaar betekent dat dat de klok van 2 uur MET wordt omgezet naar 3 uur MEZT,
+zodat de nacht een uur korter duurt.
+In het najaar wordt de klok om 3 uur MEZT teruggezet naar 2 uur MET,
+zodat we een uur langer kunnen slapen (de tijdspanne tussen 2 en 3 uur komt immers tweemaal voor).
+*/
+
+ const char * const SummerTime[] = {
+ "2011", "03", "27", "10", "30",
+ "2012", "03", "25", "10", "28",
+ "2013", "03", "31", "10", "27",
+ "2014", "03", "30", "10", "26",
+ "2015", "03", "29", "10", "25",
+ "2016", "03", "27", "10", "30",
+ "2017", "03", "26", "10", "29",
+ "2018", "03", "25", "10", "28",
+ "2019", "03", "31", "10", "27",
+ "2020", "03", "29", "10", "25",
+
+ "2021", "03", "28", "10", "31",
+ "2022", "03", "27", "10", "30",
+ "2023", "03", "26", "10", "29",
+ "2024", "03", "31", "10", "27",
+ "2025", "03", "30", "10", "26",
+ "2026", "03", "29", "10", "25",
+ "2027", "03", "28", "10", "31",
+ "2028", "03", "26", "10", "29",
+ "2029", "03", "25", "10", "28",
+ "2030", "03", "31", "10", "27",
+
+ "2031", "03", "30", "10", "26",
+ "2032", "03", "28", "10", "31",
+ "2033", "03", "27", "10", "30",
+ "2034", "03", "26", "10", "29",
+ "2035", "03", "25", "10", "28",
+ "2036", "03", "30", "10", "26",
+ "2037", "03", "29", "10", "25",
+ "2038", "03", "28", "10", "31",
+ "2039", "03", "27", "10", "30",
+ "2040", "03", "25", "10", "28",
+
+ "2041", "03", "31", "10", "27",
+ "2042", "03", "30", "10", "26",
+ "2043", "03", "29", "10", "25",
+ "2044", "03", "27", "10", "30",
+ "2045", "03", "26", "10", "29",
+ "2046", "03", "25", "10", "28",
+ "2047", "03", "31", "10", "27",
+ "2048", "03", "29", "10", "25",
+ "2049", "03", "28", "10", "31",
+ "2050", "03", "27", "10", "30",
+
+ "2051", "03", "26", "10", "29",
+ "2052", "03", "31", "10", "27",
+ "2053", "03", "30", "10", "26",
+ "2054", "03", "29", "10", "25",
+ "2055", "03", "28", "10", "31",
+ "2056", "03", "26", "10", "29",
+ "2057", "03", "25", "10", "28",
+ "2058", "03", "31", "10", "27",
+ "2059", "03", "30", "10", "26",
+ "2060", "03", "28", "10", "31"
+ };
