2 Copyright (C) 2012 jaseg <s@jaseg.de>
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 version 3 as published by the Free Software Foundation.
10 #include <avr/pgmspace.h>
15 inline void l7seg_pulse_clk(void){
16 L7SEG_CLK_PORT |= _BV(L7SEG_CLK_PIN);
17 L7SEG_CLK_PORT &= ~_BV(L7SEG_CLK_PIN);
20 inline void l7seg_data_out(uint8_t val){
21 L7SEG_DATA_PORT &= ~_BV(L7SEG_DATA_PIN);
23 L7SEG_DATA_PORT |= _BV(L7SEG_DATA_PIN);
27 inline void l7seg_select_digit(uint8_t digit){
28 L7SEG_DIGIT1_PORT &= ~_BV(L7SEG_DIGIT1_PIN);
29 L7SEG_DIGIT2_PORT &= ~_BV(L7SEG_DIGIT2_PIN);
31 L7SEG_DIGIT1_PORT |= _BV(L7SEG_DIGIT1_PIN);
34 L7SEG_DIGIT2_PORT |= _BV(L7SEG_DIGIT2_PIN);
38 int l7seg_digit1[] = {
57 int l7seg_digit2[] = {
76 int l7seg_get_digit(uint8_t b, uint8_t a){
88 out = l7seg_digit1[a];
89 return out | l7seg_digit2[b];
92 typedef char l7seg_buftype[4];
96 void ${init_function} (){
97 L7SEG_CLK_DDR |= _BV(L7SEG_CLK_PIN);
98 L7SEG_DATA_DDR |= _BV(L7SEG_DATA_PIN);
99 L7SEG_DIGIT1_DDR |= _BV(L7SEG_DIGIT1_PIN);
100 L7SEG_DIGIT2_DDR |= _BV(L7SEG_DIGIT2_PIN);
103 void ${loop_function} (){
104 static int l7seg_cycle=1;
105 static uint8_t pos = 0;
108 l7seg_cycle = l7seg_get_digit(${modulevar("buf")}[2], ${modulevar("buf")}[3]);
109 l7seg_select_digit(0);
110 for(uint8_t i = 0; i<16; i++){
111 l7seg_data_out(l7seg_cycle&1);
116 l7seg_select_digit(1);
118 l7seg_cycle = l7seg_get_digit(${modulevar("buf")}[0], ${modulevar("buf")}[1]);
119 l7seg_select_digit(0);
120 for(uint8_t i = 0; i<16; i++){
121 l7seg_data_out(l7seg_cycle&1);
126 l7seg_select_digit(2);
131 ${modulevar("buf", "l7seg_buftype", "4c")} = {'1','3','3','7'};