2 #ifdef HAS_7SEG_SUPPORT
4 #include <util/delay.h>
5 #include <avr/interrupt.h>
6 #include <avr/pgmspace.h>
11 L7SEG_CLK_DDR
|= _BV(L7SEG_CLK_PIN
);
12 L7SEG_DATA_DDR
|= _BV(L7SEG_DATA_PIN
);
13 L7SEG_DIGIT1_DDR
|= _BV(L7SEG_DIGIT1_PIN
);
14 L7SEG_DIGIT2_DDR
|= _BV(L7SEG_DIGIT2_PIN
);
17 inline void l7seg_pulse_clk(void){
18 L7SEG_CLK_PORT
|= _BV(L7SEG_CLK_PIN
);
19 L7SEG_CLK_PORT
&= ~_BV(L7SEG_CLK_PIN
);
22 inline void l7seg_data_out(uint8_t val
){
23 L7SEG_DATA_PORT
&= ~_BV(L7SEG_DATA_PIN
);
25 L7SEG_DATA_PORT
|= _BV(L7SEG_DATA_PIN
);
29 inline void l7seg_select_digit(uint8_t digit
){
30 L7SEG_DIGIT1_PORT
&= ~_BV(L7SEG_DIGIT1_PIN
);
31 L7SEG_DIGIT2_PORT
&= ~_BV(L7SEG_DIGIT2_PIN
);
33 L7SEG_DIGIT1_PORT
|= _BV(L7SEG_DIGIT1_PIN
);
36 L7SEG_DIGIT2_PORT
|= _BV(L7SEG_DIGIT2_PIN
);
42 int l7seg_digit1
[] = {
61 int l7seg_digit2
[] = {
80 int l7seg_get_digit(uint8_t b
, uint8_t a
){
92 out
= l7seg_digit1
[a
];
93 return out
| l7seg_digit2
[b
];
96 void l7seg_loop(){ //one frame
98 static uint8_t pos
= 0;
100 l7seg_cycle
= l7seg_get_digit(l7seg_buf
[2],l7seg_buf
[3]);
101 l7seg_select_digit(0);
102 for(uint8_t i
= 0; i
<16; i
++){
103 l7seg_data_out(l7seg_cycle
&1);
108 l7seg_select_digit(1);
110 l7seg_cycle
= l7seg_get_digit(l7seg_buf
[0],l7seg_buf
[1]);
111 l7seg_select_digit(0);
112 for(uint8_t i
= 0; i
<16; i
++){
113 l7seg_data_out(l7seg_cycle
&1);
118 l7seg_select_digit(2);
123 uint8_t _l7seg_buf
[4] = {'1','3','3','7'};
124 uint8_t* l7seg_buf
= _l7seg_buf
;
126 #else//HAS_7SEG_SUPPORT
128 void l7seg_setup(void){}
129 void l7seg_loop(void){}
131 #endif//HAS_7SEG_SUPPORT