From f714cacefc9a04fbae7249cc4b707a27cedabc36 Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Tue, 10 Apr 2012 23:56:27 +0200 Subject: Decode and display flags --- clock.c | 32 ++++++++++++++++++++++++-------- clock.h | 8 ++++++++ dcf77.c | 18 +++++++----------- main.c | 18 +++++++++++------- timebase.c | 2 +- 5 files changed, 51 insertions(+), 27 deletions(-) diff --git a/clock.c b/clock.c index 3068816..270edff 100644 --- a/clock.c +++ b/clock.c @@ -15,31 +15,42 @@ struct time data time; -u8 code MDAYS[] = { +const u8 code MDAYS[] = { 29, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; +u8 is_cet(void) +{ + return ((time.flags & FLAG_CET) && !(time.flags & FLAG_CEST)); +} + +u8 is_cest(void) +{ + return ((time.flags & FLAG_CEST) && !(time.flags & FLAG_CET)); +} void clock(void) { u8 i; time.second++; - if( time.second == 60 ){ + if( time.second >= 60 ){ + if (time.flags & FLAG_LEAP_SECOND && time.second == 60) { + return; + } time.second = 0; timeflags = 1<= sizeof( BITNO )) // only bit 21 ... 58 return; parity ^= pulse; // calculate parity i = LPM(&BITNO[i]); - if( i == 0xFF ){ // test parity - if( parity ) + if( i & 0x08 ){ // test parity + if( (i & 0x80) && parity ) dcf77error = 1; parity = 0; return; @@ -81,13 +82,8 @@ void scan_dcf77( void ) if( dcf77error == 0 && newtime.second == 59 ){ synchronize = 0xFF; sync_sec(); + time = newtime; time.second = 0; - time.minute = newtime.minute; - time.hour = newtime.hour; - time.wday = newtime.wday; - time.day = newtime.day; - time.month = newtime.month; - time.year = newtime.year; } newtime.second = 0; dcf77error = 0; diff --git a/main.c b/main.c index cd9666a..c5e4bd2 100644 --- a/main.c +++ b/main.c @@ -37,7 +37,8 @@ enum stepstate { } stepstate = STEP_INACTIVE; const char PROGMEM disp[2] = {'_', '+'}; -const char PROGMEM status[24] = "normalsync adj + adj - "; +const char PROGMEM status[8] = "oksya+a-"; +const char PROGMEM zone[4] = "?12?"; const char PROGMEM cksumfail[] = "cksum fail"; static void puttwo(uint8_t arg) @@ -63,15 +64,18 @@ static void puttime(void) puttwo(time.second); lcd_line2(); + lcd_put(time.flags & FLAG_SUMMERTIME_PENDING ? '!' : ' '); + lcd_put(zone[is_cet() + (is_cest() << 1)]); + lcd_put(time.flags & FLAG_LEAP_SECOND ? '!' : ' '); + msg = &status[0]; if (time.year <= 10) - msg = &status[6]; + msg = &status[2]; if (~PINB & (1 << B_SW_FRWD)) - msg = &status[12]; + msg = &status[4]; if (~PINB & (1 << B_SW_BACK)) - msg = &status[18]; - - lcd_puts(msg, 6); + msg = &status[6]; + lcd_puts(msg, 2); lcd_put(__LPM(&disp[stepstate])); puttwo(ext_hour); puttwo(ext_minute); @@ -182,7 +186,7 @@ static void perform(void) extern void __vectors(void) __attribute__((noreturn)); __attribute__ ((noreturn)) -SIGNAL (SIG_ANA_COMP) +SIGNAL (ANA_COMP_vect) { PORTA = 0xff; diff --git a/timebase.c b/timebase.c index ee58bf1..ea8f8b9 100644 --- a/timebase.c +++ b/timebase.c @@ -26,7 +26,7 @@ void timebase_init( void ) extern uint8_t waitctr; -SIGNAL (SIG_OVERFLOW0) +SIGNAL (TIMER0_OVF0_vect) { static u8 dcf77_time, old_dcf77; // DCF77 receive -- cgit v1.2.1