+ /*
+ * Set Triac to match temperature
+ */
+ if(run) {
+ delta = cur - (tempk - 273);
+ if(rstate == 0) {
+ if(delta > 0) {
+ tron = 1;
+ if(delta > 8) {
+ /* For some reason, the Triac currently doesn't
+ * trigger on one of the AC half-cycles below 0.7
+ * ms. */
+ trdelay = 7;
+ } else {
+ trdelay = 79 - (delta * 9);
+ }
+ } else {
+ tron = 0;
+ rstate = 1;
+ }
+ } else if(rstate == 1) {
+ tron = 0;
+ if(delta >= 2)
+ rstate = 0;
+ }
+ } else {
+ tron = 0;
+ }