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*/
58 unsigned short trdelay = 0;
68 * B0..2 = Pulse sensor
87 * D3 = NTC Op-amp (INT1)
97 unsigned char bindisp(unsigned char num)
121 void display(char num)
123 dsp[0] = font[(num / 10) % 10];
124 dsp[1] = font[num % 10];
127 void disphex(unsigned char num)
129 dsp[0] = font[(num & 0xf0) >> 4];
130 dsp[1] = font[num & 0x0f];
133 unsigned long getticks(void)
135 return(TCNT1 + (((unsigned long)oticks) << 16));
140 static uint16_t last = 0;
143 if(TCNT1 - last > 500) {
150 if(dsp[ledc] & (1 << leda)) {
156 d = 0x10 << (leda - 6);
163 PORTD = (PORTD & 0x0f) | d;
170 if((PIND & 8) && (tlock == 0)) {
175 } else if(tstate == 1) {
176 if(mnow - tstart > 1000) {
188 ttimea = ((ttimea * 15) + ttime) >> 4;
193 void triaccycle(void)
196 if(tron && zok && (mnow > ztime + trdelay)) {
201 } else if(trstate == 1) {
227 dsp[0] = bindisp((ttimea & 0xff00) >> 8);
228 dsp[1] = bindisp(ttimea & 0x00ff);
231 disphex((ttimea & 0xff000) >> 12);
238 display((ttimea / 100) % 100);
243 display(ttimea / 1000);
248 Pulse counter display
284 ttime = now - tstart;
299 if((sstate == 0) & ((PINB & 1) == 0)) {
303 if((sstate == 1) & ((PINB & 1) == 1)) {
304 stime = oticks - stime;
308 if((PINB & 2) == 0) {
310 } else if((PINB & 4) == 0) {
313 } else if(pstate == 1) {
314 if((PINB & 4) == 0) {
320 } else if(pstate == 2) {
321 if((PINB & 2) == 0) {
328 if((PINB & 2) && (PINB & 4))