00001
00002
00003
00004
00005
00006 #ifndef _UTIL_H
00007 #define _UTIL_H
00008
00009 #define PORTDIGIT PORTC
00010 #define DDRDIGIT DDRC
00011
00012 #define PORTBUTTON PORTC
00013 #define DDRBUTTON DDRC
00014
00015 #define PORTSA234 PORTD
00016 #define DDRSA234 DDRD
00017 #define PORTSA1 PORTB
00018 #define DDRSA1 DDRB
00019
00020 #define PORTDOT PORTD
00021 #define DDRDOT DDRD
00022 #define DOT 3
00023
00024 #define PORTHVPUMP PORTB
00025 #define DDRHVPUMP DDRB
00026
00027
00028 #define BV2(a,b) (_BV(a)|_BV(b))
00029 #define BV3(a,b,c) (_BV(a)|_BV(b)|_BV(c))
00030 #define BV4(a,b,c,d) (_BV(a)|_BV(b)|_BV(c)|_BV(d))
00031 #define BV5(a,b,c,d,e) (_BV(a)|_BV(b)|_BV(c)|_BV(d)|_BV(e))
00032 #define BV6(a,b,c,d,e,f) (_BV(a)|_BV(b)|_BV(c)|_BV(d)|_BV(e)|_BV(f))
00033 #define BV7(a,b,c,d,e,f,g) (_BV(a)|_BV(b)|_BV(c)|_BV(d)|_BV(e)|_BV(f)|_BV(g))
00034
00035
00036 enum _sa_values {
00037 SA1 = 0,
00038 SA2,
00039 SA3,
00040 SA4,
00041 SAX = 0377
00042 };
00043
00045 #define maketime(hh,mm) (((hh) << 8) + (mm))
00046
00049 #define _frombcd(x) ((x & 017) + (((x) & 0160)>>4) * 10)
00050
00053 uint8_t frombcd(uint8_t);
00054
00055 uint16_t tobcd16(uint16_t);
00056
00059 uint8_t days_in_month_bcd(uint8_t year, uint8_t month);
00060
00062 uint8_t bcd_increment(uint8_t x);
00063
00065 uint8_t day_of_week(uint8_t y, uint8_t m, uint8_t d);
00066
00068 void blinkmode_set(uint8_t mode);
00069
00071 uint8_t blinkmode_get();
00072
00074 void (*blinkhandler)(uint8_t);
00075
00078 void fade_set(uint8_t mode);
00079
00080 void fadeto(uint16_t t);
00081
00082 uint16_t get_display_value();
00083
00086 void mode_next();
00087
00090 uint8_t mode_get();
00091
00092 void savingmode_set(uint8_t s);
00093 uint8_t savingmode_get();
00094 void savingmode_next();
00095
00096
00097
00098 void dotmode_set(uint8_t mode);
00099
00100
00101 #endif