|
@@ -191,6 +191,22 @@ static void SysControlMainBeat(u_char OnOff)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+void displayDate(){
|
|
|
|
|
+ struct _tm gmt;
|
|
|
|
|
+ gmt = GetRTCTime();
|
|
|
|
|
+ char str[13];
|
|
|
|
|
+ sprintf(str, " %02d/%02d/%04d", gmt.tm_mday, gmt.tm_mon, gmt.tm_year+1900);
|
|
|
|
|
+ LcdArrayLineOne(str,13);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void displayTime(){
|
|
|
|
|
+ struct _tm gmt;
|
|
|
|
|
+ gmt = GetRTCTime();
|
|
|
|
|
+ char str[12];
|
|
|
|
|
+ sprintf(str, " %02d:%02d:%02d", gmt.tm_hour, gmt.tm_min, gmt.tm_sec);
|
|
|
|
|
+ LcdArrayLineTwo(str,12);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
int timer(time_t start){
|
|
int timer(time_t start){
|
|
|
time_t diff = time(0) - start;
|
|
time_t diff = time(0) - start;
|
|
|
return diff;
|
|
return diff;
|
|
@@ -225,7 +241,8 @@ int main(void)
|
|
|
* Kroeske: time struct uit nut/os time.h (http://www.ethernut.de/api/time_8h-source.html)
|
|
* Kroeske: time struct uit nut/os time.h (http://www.ethernut.de/api/time_8h-source.html)
|
|
|
*
|
|
*
|
|
|
*/
|
|
*/
|
|
|
- tm gmt;
|
|
|
|
|
|
|
+ struct _tm gmt;
|
|
|
|
|
+
|
|
|
/*
|
|
/*
|
|
|
* Kroeske: Ook kan 'struct _tm gmt' Zie bovenstaande link
|
|
* Kroeske: Ook kan 'struct _tm gmt' Zie bovenstaande link
|
|
|
*/
|
|
*/
|
|
@@ -236,7 +253,7 @@ int main(void)
|
|
|
WatchDogDisable();
|
|
WatchDogDisable();
|
|
|
|
|
|
|
|
NutDelay(100);
|
|
NutDelay(100);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
SysInitIO();
|
|
SysInitIO();
|
|
|
|
|
|
|
|
SPIinit();
|
|
SPIinit();
|
|
@@ -256,10 +273,9 @@ int main(void)
|
|
|
* Kroeske: sources in rtc.c en rtc.h
|
|
* Kroeske: sources in rtc.c en rtc.h
|
|
|
*/
|
|
*/
|
|
|
X12Init();
|
|
X12Init();
|
|
|
- if (X12RtcGetClock(&gmt) == 0)
|
|
|
|
|
- {
|
|
|
|
|
- LogMsg_P(LOG_INFO, PSTR("RTC time [%02d:%02d:%02d]"), gmt.tm_hour, gmt.tm_min, gmt.tm_sec );
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ gmt = GetRTCTime();
|
|
|
|
|
+ LogMsg_P(LOG_INFO, PSTR("RTC time [%02d:%02d:%02d]"), gmt.tm_hour, gmt.tm_min, gmt.tm_sec );
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
if (At45dbInit()==AT45DB041B)
|
|
if (At45dbInit()==AT45DB041B)
|
|
@@ -281,19 +297,24 @@ int main(void)
|
|
|
|
|
|
|
|
/* Enable global interrupts */
|
|
/* Enable global interrupts */
|
|
|
sei();
|
|
sei();
|
|
|
|
|
+
|
|
|
for (;;)
|
|
for (;;)
|
|
|
{
|
|
{
|
|
|
|
|
+ //Check if a button is pressed
|
|
|
if (checkOffPressed() == 1){
|
|
if (checkOffPressed() == 1){
|
|
|
start = time(0);
|
|
start = time(0);
|
|
|
running = 1;
|
|
running = 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ //Check if background LED is on, and compare to timer
|
|
|
if (running == 1){
|
|
if (running == 1){
|
|
|
if (timer(start) >= 10){
|
|
if (timer(start) >= 10){
|
|
|
running = 0;
|
|
running = 0;
|
|
|
LcdBackLight(LCD_BACKLIGHT_OFF);
|
|
LcdBackLight(LCD_BACKLIGHT_OFF);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ displayTime();
|
|
|
|
|
+ displayDate();
|
|
|
|
|
|
|
|
WatchDogRestart();
|
|
WatchDogRestart();
|
|
|
}
|
|
}
|