From: b Date: Thu, 9 Apr 2015 09:51:06 +0000 (+0200) Subject: ONG at 4:33 X-Git-Tag: v1.1 X-Git-Url: http://bicyclesonthemoon.info/git-projects/?a=commitdiff_plain;h=654d39d93ff0034459374fc2e8106e19f90dd917;p=staf%2Fstaf ONG at 4:33 --- diff --git a/definitions.h b/definitions.h index bc5b5b4..1f5f1b8 100644 --- a/definitions.h +++ b/definitions.h @@ -1,68 +1,68 @@ -//RTC commands: -#define RTC_EEREAD 0x03 -#define RTC_EEWRITE 0x02 -#define RTC_EEWRDI 0x04 -#define RTC_EEWREN 0x06 -#define RTC_SRREAD 0x05 -#define RTC_SRWRITE 0x01 -#define RTC_READ 0x13 -#define RTC_WRITE 0x12 -#define RTC_UNLOCK 0x14 -#define RTC_IDWRITE 0x32 -#define RTC_IDREAD 0x33 -#define RTC_CLRRAM 0x54 - -//SPI function flags: -#define ADDRFLAG 0x01 -#define WRITEFLAG 0x02 -#define READFLAG 0x04 - -//7 segment display - -#define SEG_A 0xdf -#define SEG_B 0xef // aaaa -#define SEG_C 0xbf // f b -#define SEG_D 0x7f // f b -#define SEG_E 0xfd //hh gggg -#define SEG_F 0xfb // e c -#define SEG_G 0xf7 // e c -#define SEG_H 0xfe // dddd - -#define SYMB_0 (SEG_A & SEG_B & SEG_C & SEG_D & SEG_E & SEG_F ) -#define SYMB_1 ( SEG_B & SEG_C ) -#define SYMB_2 (SEG_A & SEG_B & SEG_D & SEG_E & SEG_G) -#define SYMB_3 (SEG_A & SEG_B & SEG_C & SEG_D & SEG_G) -#define SYMB_4 ( SEG_B & SEG_C & SEG_F & SEG_G) -#define SYMB_5 (SEG_A & SEG_C & SEG_D & SEG_F & SEG_G) -#define SYMB_6 (SEG_A & SEG_C & SEG_D & SEG_E & SEG_F & SEG_G) -#define SYMB_7 (SEG_A & SEG_B & SEG_C ) -#define SYMB_8 (SEG_A & SEG_B & SEG_C & SEG_D & SEG_E & SEG_F & SEG_G) -#define SYMB_9 (SEG_A & SEG_B & SEG_C & SEG_F & SEG_G) -#define SYMB_A (SEG_A & SEG_B & SEG_C & SEG_E & SEG_F & SEG_G) -#define SYMB_B ( SEG_C & SEG_D & SEG_E & SEG_F & SEG_G) -#define SYMB_C ( SEG_D & SEG_E & SEG_G) -#define SYMB_D ( SEG_B & SEG_C & SEG_D & SEG_E & SEG_G) -#define SYMB_E (SEG_A & SEG_D & SEG_E & SEG_F & SEG_G) -#define SYMB_F (SEG_A & SEG_E & SEG_F & SEG_G) -#define SYMB_NUL (0xFF) -#define SYMB_o (SEG_A & SEG_B & SEG_F & SEG_G) -#define SYMB_n (SEG_A & SEG_B & SEG_F ) -#define SYMB_g (SEG_A & SEG_B & SEG_C & SEG_D & SEG_F & SEG_G) -#define SYMB_MIN ( SEG_G) -#define SYMB_DOT (SEG_H) - -//operation modes -#define MODE_INIT 0 -#define MODE_TIME 1 -#define MODE_SETTIME 2 -#define MODE_SETALARM 3 -#define MODE_ALARM 4 -#define MODE_DATE 5 -#define MODE_SETDATE 6 -#define MODE_SETYEAR 7 -#define MODE_COUNTUP 8 -#define MODE_SETCOUNTDOWN 9 -#define MODE_COUNTDOWN 10 -#define MODE_CALIBRATE 11 - +//RTC commands: +#define RTC_EEREAD 0x03 +#define RTC_EEWRITE 0x02 +#define RTC_EEWRDI 0x04 +#define RTC_EEWREN 0x06 +#define RTC_SRREAD 0x05 +#define RTC_SRWRITE 0x01 +#define RTC_READ 0x13 +#define RTC_WRITE 0x12 +#define RTC_UNLOCK 0x14 +#define RTC_IDWRITE 0x32 +#define RTC_IDREAD 0x33 +#define RTC_CLRRAM 0x54 + +//SPI function flags: +#define ADDRFLAG 0x01 +#define WRITEFLAG 0x02 +#define READFLAG 0x04 + +//7 segment display + +#define SEG_A 0xdf +#define SEG_B 0xef // aaaa +#define SEG_C 0xbf // f b +#define SEG_D 0x7f // f b +#define SEG_E 0xfd //hh gggg +#define SEG_F 0xfb // e c +#define SEG_G 0xf7 // e c +#define SEG_H 0xfe // dddd + +#define SYMB_0 (SEG_A & SEG_B & SEG_C & SEG_D & SEG_E & SEG_F ) +#define SYMB_1 ( SEG_B & SEG_C ) +#define SYMB_2 (SEG_A & SEG_B & SEG_D & SEG_E & SEG_G) +#define SYMB_3 (SEG_A & SEG_B & SEG_C & SEG_D & SEG_G) +#define SYMB_4 ( SEG_B & SEG_C & SEG_F & SEG_G) +#define SYMB_5 (SEG_A & SEG_C & SEG_D & SEG_F & SEG_G) +#define SYMB_6 (SEG_A & SEG_C & SEG_D & SEG_E & SEG_F & SEG_G) +#define SYMB_7 (SEG_A & SEG_B & SEG_C ) +#define SYMB_8 (SEG_A & SEG_B & SEG_C & SEG_D & SEG_E & SEG_F & SEG_G) +#define SYMB_9 (SEG_A & SEG_B & SEG_C & SEG_F & SEG_G) +#define SYMB_A (SEG_A & SEG_B & SEG_C & SEG_E & SEG_F & SEG_G) +#define SYMB_B ( SEG_C & SEG_D & SEG_E & SEG_F & SEG_G) +#define SYMB_C ( SEG_D & SEG_E & SEG_G) +#define SYMB_D ( SEG_B & SEG_C & SEG_D & SEG_E & SEG_G) +#define SYMB_E (SEG_A & SEG_D & SEG_E & SEG_F & SEG_G) +#define SYMB_F (SEG_A & SEG_E & SEG_F & SEG_G) +#define SYMB_NUL (0xFF) +#define SYMB_o (SEG_A & SEG_B & SEG_F & SEG_G) +#define SYMB_n (SEG_A & SEG_B & SEG_F ) +#define SYMB_g (SEG_A & SEG_B & SEG_C & SEG_D & SEG_F & SEG_G) +#define SYMB_MIN ( SEG_G) +#define SYMB_DOT (SEG_H) + +//operation modes +#define MODE_INIT 0 +#define MODE_TIME 1 +#define MODE_SETTIME 2 +#define MODE_SETALARM 3 +#define MODE_ALARM 4 +#define MODE_DATE 5 +#define MODE_SETDATE 6 +#define MODE_SETYEAR 7 +#define MODE_COUNTUP 8 +#define MODE_SETCOUNTDOWN 9 +#define MODE_COUNTDOWN 10 +#define MODE_CALIBRATE 11 + #define ALARMVALUE 0xa5 \ No newline at end of file diff --git a/main.c b/main.c index a15d25c..4869f29 100644 --- a/main.c +++ b/main.c @@ -560,7 +560,8 @@ __interrupt void P2_ISR() dispvalue[3]=((settime[2]&0xf0)?symbol[(settime[2]&0xf0)>>4]:SYMB_NUL)&(alarm[0]?SYMB_DOT:SYMB_NUL); break; case MODE_ALARM: - if(time[1]&0x01) + case MODE_TIME: + if(((time[1]&0x01) && mode==MODE_ALARM) || (time[3]==0x04 && time[2]==0x33 && time[1]==0x00)) { dispvalue[0]=SYMB_g; dispvalue[1]=SYMB_n; @@ -568,7 +569,6 @@ __interrupt void P2_ISR() dispvalue[3]=SYMB_DOT; break; } - case MODE_TIME: default: dispvalue[0]=symbol[time[2]&0x0f]&((time[1]&0x01)?SYMB_NUL:SYMB_DOT); dispvalue[1]=symbol[(time[2]&0xf0)>>4]&((time[1]&0x01)?SYMB_NUL:SYMB_DOT);