X-Git-Url: http://dolda2000.com/gitweb/?p=kokare.git;a=blobdiff_plain;f=kokare.c;h=3bc4c4bf8ece55ab8010bfade48ca315ce537b44;hp=81aab664d1add08dbe265619a4028d3efed41ff5;hb=495bea0626dfc90021733b8c8224c8e5d6a00103;hpb=ab02b3d0f757c4b03a28b5d7937d1923d0209ea9 diff --git a/kokare.c b/kokare.c index 81aab66..3bc4c4b 100644 --- a/kokare.c +++ b/kokare.c @@ -55,6 +55,7 @@ unsigned long ztime; /* Triac */ char trstate = 0; char tron = 0; +unsigned long trtime; unsigned short trdelay = 0; void init(void) @@ -197,10 +198,13 @@ void triaccycle(void) PORTD |= 1; zok = 0; trstate = 1; + trtime = mnow; } } else if(trstate == 1) { - PORTD &= ~1; - trstate = 0; + if(mnow > trtime + 500) { + PORTD &= ~1; + trstate = 0; + } } } @@ -213,9 +217,6 @@ int main(void) sei(); display(0); - tron = 1; - trdelay = 5000; - while(1) { mnow = getticks(); ledcycle(); @@ -230,7 +231,7 @@ int main(void) /* disphex((ttimea & 0xff000) >> 12); */ -#if 1 +#if 0 /* Temp display */ @@ -243,6 +244,25 @@ int main(void) display(ttimea / 1000); } #endif +#if 1 + /* + Phony Triac control + */ + if(pval != 0) { + cur += pval; + if(cur < 0) + cur = 0; + if(cur > 99) + cur = 99; + display(cur); + trdelay = 10000 - ((unsigned short)cur * 100); + pval = 0; + } + if(sstate == 2) { + tron = !tron; + sstate = 0; + } +#endif #if 0 /* Pulse counter display