2 #include <avr/interrupt.h>
15 SEGA | SEGB | SEGC | SEGD | SEGE | SEGF,
17 SEGA | SEGB | SEGD | SEGE | SEGG,
18 SEGA | SEGB | SEGC | SEGD | SEGG,
19 SEGB | SEGC | SEGF | SEGG,
20 SEGA | SEGC | SEGD | SEGF | SEGG,
21 SEGA | SEGC | SEGD | SEGE | SEGF | SEGG,
23 SEGA | SEGB | SEGC | SEGD | SEGE | SEGF | SEGG,
24 SEGA | SEGB | SEGC | SEGD | SEGF | SEGG,
25 SEGA | SEGB | SEGC | SEGE | SEGF | SEGG,
26 SEGC | SEGD | SEGE | SEGF | SEGG,
27 SEGA | SEGD | SEGE | SEGF,
28 SEGB | SEGC | SEGD | SEGE | SEGG,
29 SEGA | SEGD | SEGE | SEGF | SEGG,
30 SEGA | SEGE | SEGF | SEGG,
33 uint8_t dsp[2] = {0, 0};
51 unsigned long ttimea = 10000;
52 /* Zero-cross detector*/
59 unsigned short trdelay = 0;
69 * B0..2 = Pulse sensor
88 * D3 = NTC Op-amp (INT1)
98 unsigned char bindisp(unsigned char num)
122 void display(char num)
124 dsp[0] = font[(num / 10) % 10];
125 dsp[1] = font[num % 10];
128 void disphex(unsigned char num)
130 dsp[0] = font[(num & 0xf0) >> 4];
131 dsp[1] = font[num & 0x0f];
134 unsigned long getticks(void)
136 return(TCNT1 + (((unsigned long)oticks) << 16));
141 static uint16_t last = 0;
144 if(TCNT1 - last > 500) {
151 if(dsp[ledc] & (1 << leda)) {
157 d = 0x10 << (leda - 6);
164 PORTD = (PORTD & 0x0f) | d;
171 if((PIND & 8) && (tlock == 0)) {
176 } else if(tstate == 1) {
177 if(mnow - tstart > 1000) {
189 ttimea = ((ttimea * 15) + ttime) >> 4;
194 void triaccycle(void)
197 if(tron && zok && (mnow > ztime + trdelay)) {
203 } else if(trstate == 1) {
204 if(mnow > trtime + 500) {
228 dsp[0] = bindisp((ttimea & 0xff00) >> 8);
229 dsp[1] = bindisp(ttimea & 0x00ff);
232 disphex((ttimea & 0xff000) >> 12);
239 display((ttimea / 100) % 100);
244 display(ttimea / 1000);
258 trdelay = 10000 - ((unsigned short)cur * 100);
268 Pulse counter display
304 ttime = now - tstart;
319 if((sstate == 0) & ((PINB & 1) == 0)) {
323 if((sstate == 1) & ((PINB & 1) == 1)) {
324 stime = oticks - stime;
328 if((PINB & 2) == 0) {
330 } else if((PINB & 4) == 0) {
333 } else if(pstate == 1) {
334 if((PINB & 4) == 0) {
340 } else if(pstate == 2) {
341 if((PINB & 2) == 0) {
348 if((PINB & 2) && (PINB & 4))