|
|
| version 1.1, 2003/10/16 17:57:06 | version 1.5, 2004/07/26 18:52:55 |
|---|---|
| Line 8 | Line 8 |
| _CALENDAR cal; | _CALENDAR cal; |
| static const BYTE days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; | static const UINT8 days[12] = { 31, 28, 31, 30, 31, 30, |
| 31, 31, 30, 31, 30, 31}; | |
| static void secinc(_SYSTIME *dt) { | static void secinc(_SYSTIME *dt) { |
| Line 25 static void secinc(_SYSTIME *dt) { | Line 26 static void secinc(_SYSTIME *dt) { |
| goto secinc_exit; | goto secinc_exit; |
| } | } |
| dt->minute = 0; | dt->minute = 0; |
| dt->hour = 0; | dt->hour++; |
| if (dt->hour < 24) { | if (dt->hour < 24) { |
| goto secinc_exit; | goto secinc_exit; |
| } | } |
| Line 34 static void secinc(_SYSTIME *dt) { | Line 35 static void secinc(_SYSTIME *dt) { |
| month = dt->month - 1; | month = dt->month - 1; |
| if (month < 12) { | if (month < 12) { |
| daylimit = days[month]; | daylimit = days[month]; |
| if ((daylimit == 28) && (!(cal.dt.year & 3))) { | if ((daylimit == 28) && (!(dt->year & 3))) { |
| daylimit++; // = 29; | daylimit++; // = 29; |
| } | } |
| } | } |
| Line 58 secinc_exit: | Line 59 secinc_exit: |
| return; | return; |
| } | } |
| static void date2deg(_SYSTIME *t, const BYTE *bcd) { | static void date2deg(_SYSTIME *t, const UINT8 *bcd) { |
| UINT16 year; | UINT16 year; |
| Line 75 static void date2deg(_SYSTIME *t, const | Line 76 static void date2deg(_SYSTIME *t, const |
| t->second = (UINT16)AdjustBeforeDivision(bcd[5]); | t->second = (UINT16)AdjustBeforeDivision(bcd[5]); |
| } | } |
| static void date2bcd(BYTE *bcd, const _SYSTIME *t) { | static void date2bcd(UINT8 *bcd, const _SYSTIME *t) { |
| bcd[0] = AdjustAfterMultiply((BYTE)((t->year) % 100)); | bcd[0] = AdjustAfterMultiply((UINT8)(t->year % 100)); |
| bcd[1] = (BYTE)(((t->month) << 4) + (t->week)); | bcd[1] = (UINT8)((t->month << 4) + t->week); |
| bcd[2] = AdjustAfterMultiply((BYTE)t->day); | bcd[2] = AdjustAfterMultiply((UINT8)t->day); |
| bcd[3] = AdjustAfterMultiply((BYTE)t->hour); | bcd[3] = AdjustAfterMultiply((UINT8)t->hour); |
| bcd[4] = AdjustAfterMultiply((BYTE)t->minute); | bcd[4] = AdjustAfterMultiply((UINT8)t->minute); |
| bcd[5] = AdjustAfterMultiply((BYTE)t->second); | bcd[5] = AdjustAfterMultiply((UINT8)t->second); |
| } | } |
| // ----- | // ----- |
| void calendar_init(void) { | void calendar_initialize(void) { |
| timemng_gettime(&cal.dt); | timemng_gettime(&cal.dt); |
| cal.steps = 0; | cal.steps = 0; |
| Line 108 void calendar_inc(void) { | Line 109 void calendar_inc(void) { |
| secinc(&cal.dt); | secinc(&cal.dt); |
| } | } |
| void calendar_set(const BYTE *bcd) { | void calendar_set(const UINT8 *bcd) { |
| date2deg(&cal.dt, bcd); | date2deg(&cal.dt, bcd); |
| } | } |
| void calendar_getvir(BYTE *bcd) { | void calendar_getvir(UINT8 *bcd) { |
| date2bcd(bcd, &cal.dt); | date2bcd(bcd, &cal.dt); |
| } | } |
| void calendar_getreal(BYTE *bcd) { | void calendar_getreal(UINT8 *bcd) { |
| timemng_gettime(&cal.realc); | timemng_gettime(&cal.realc); |
| date2bcd(bcd, &cal.realc); | date2bcd(bcd, &cal.realc); |
| } | } |
| void calendar_get(BYTE *bcd) { | void calendar_get(UINT8 *bcd) { |
| if (!np2cfg.calendar) { | if (!np2cfg.calendar) { |
| date2bcd(bcd, &cal.dt); | date2bcd(bcd, &cal.dt); |