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;
53 /* Zero-cross detector*/
60 unsigned short trdelay = 0;
70 * B0..2 = Pulse sensor
89 * D3 = NTC Op-amp (INT1)
99 unsigned char bindisp(unsigned char num)
123 void display(char num)
125 dsp[0] = font[(num / 10) % 10];
126 dsp[1] = font[num % 10];
129 void disphex(unsigned char num)
131 dsp[0] = font[(num & 0xf0) >> 4];
132 dsp[1] = font[num & 0x0f];
135 unsigned long getticks(void)
137 return(TCNT1 + (((unsigned long)oticks) << 16));
142 static uint16_t last = 0;
145 if(TCNT1 - last > 500) {
152 if(dsp[ledc] & (1 << leda)) {
158 d = 0x10 << (leda - 6);
165 PORTD = (PORTD & 0x0f) | d;
172 if((PIND & 8) && (tlock == 0)) {
177 } else if(tstate == 1) {
178 if(mnow - tstart > 1000) {
190 ttimea = ((ttimea * 15) + ttime) >> 4;
196 void triaccycle(void)
199 if(tron && zok && (mnow > ztime + trdelay)) {
205 } else if(trstate == 1) {
206 if(mnow > trtime + 500) {
236 /* Display temperature */
240 display((ttimea / 100) % 100);
245 display(ttimea / 1000);
252 } else if(state == 1) {
262 trdelay = 10000 - ((unsigned short)cur * 100);
265 if(mnow - utime > 1000000) {
275 dsp[0] = bindisp((ttimea & 0xff00) >> 8);
276 dsp[1] = bindisp(ttimea & 0x00ff);
279 disphex((ttimea & 0xff000) >> 12);
286 display((ttimea / 100) % 100);
291 display(ttimea / 1000);
316 trdelay = 10000 - ((unsigned short)cur * 100);
326 Pulse counter display
362 ttime = now - tstart;
377 if((sstate == 0) & ((PINB & 1) == 0)) {
381 if((sstate == 1) & ((PINB & 1) == 1)) {
382 stime = oticks - stime;
386 if((PINB & 2) == 0) {
388 } else if((PINB & 4) == 0) {
391 } else if(pstate == 1) {
392 if((PINB & 4) == 0) {
398 } else if(pstate == 2) {
399 if((PINB & 2) == 0) {
406 if((PINB & 2) && (PINB & 4))