--TrafficNeXt --Written by cheapie --Copying and distribution of this file, with or without modification, --are permitted in any medium without royalty provided the copyright --notice and this notice are preserved. This file is offered as-is, --without any warranty. if (event.type=="on") then interrupt(0.1) end if (event.type=="program") then digiline_send("main","WARN") digiline_send("side","WARN") mem.state="menu" mem.parameter=0 mem.editing=false if not mem.param1 then mem.param1=5 end --All Red if not mem.param2 then mem.param2=10 end --Side Green if not mem.param3 then mem.param3=15 end --Min Cycle end if (mem.state=="menu") then if (event.type=="on" and event.pin.name=="B") then if (mem.parameter==0) then mem.state="run" interrupt(1,"phase1") else mem.editing=not mem.editing if mem.parameter==0 then mem.editing=false end --Disallow editing "exit" end end --Incrementation if (event.type=="on" and event.pin.name=="D") then if mem.editing then if (mem.parameter==1) then mem.param1=mem.param1+1 if mem.param1>99 then mem.param1=99 end end if (mem.parameter==2) then mem.param2=mem.param2+1 if mem.param2>99 then mem.param2=99 end end if (mem.parameter==3) then mem.param3=mem.param3+1 if mem.param3>99 then mem.param3=99 end end else mem.parameter=mem.parameter+1 if mem.parameter>3 then mem.parameter=0 end end end --Decrementation if (event.type=="on" and event.pin.name=="C") then if mem.editing then if (mem.parameter==1) then mem.param1=mem.param1-1 if mem.param1<0 then mem.param1=0 end end if (mem.parameter==2) then mem.param2=mem.param2-1 if mem.param2<0 then mem.param2=0 end end if (mem.parameter==3) then mem.param3=mem.param3-1 if mem.param3<0 then mem.param3=0 end end else mem.parameter=mem.parameter-1 if mem.parameter<0 then mem.parameter=3 end end end if (mem.parameter==0) then digiline_send("lcd","MENU | Exit Menu") end if (mem.parameter==1) then if mem.editing then digiline_send("lcd","MENU | All Red | ["..mem.param1.."] | Seconds") else digiline_send("lcd","MENU | All Red | "..mem.param1.." | Seconds") end end if (mem.parameter==2) then if mem.editing then digiline_send("lcd","MENU | Side Green | ["..mem.param2.."] | Seconds") else digiline_send("lcd","MENU | Side Green | "..mem.param2.." | Seconds") end end if (mem.parameter==3) then if mem.editing then digiline_send("lcd","MENU | Min Cycle | ["..mem.param3.."] | Seconds") else digiline_send("lcd","MENU | Min Cycle | "..mem.param3.." | Seconds") end end end if mem.state=="run" then if (event.type=="on" and event.pin.name=="C") then digiline_send("main","WARN") digiline_send("side","WARN") mem.state="menu" mem.parameter=0 mem.editing=false end if (event.type=="on" and (event.pin.name=="A" or event.pin.name=="D")) or (event.type=="interrupt" and event.iid=="phase1") then port.a=true digiline_send("main","RED") interrupt(mem.param1,"phase2") digiline_send("lcd","Timing... | M:R S:R | "..mem.param1.." Sec | | Down: Menu") end if (event.type=="interrupt" and event.iid=="phase2") then digiline_send("side","GREEN") interrupt(mem.param2,"phase3") digiline_send("lcd","Timing... | M:R S:G | "..mem.param2.." Sec | | Down: Menu") end if (event.type=="interrupt" and event.iid=="phase3") then digiline_send("side","RED") interrupt(mem.param1,"phase4") digiline_send("lcd","Timing... | M:R S:R | "..mem.param1.." Sec | | Down: Menu") end if (event.type=="interrupt" and event.iid=="phase4") then digiline_send("main","GREEN") interrupt(mem.param3,"phase5") digiline_send("lcd","Timing... | M:G S:R | "..mem.param3.." Sec | | Down: Menu") end if (event.type=="interrupt" and event.iid=="phase5") then digiline_send("lcd","Waiting... | M:G S:R | | Up: Man Cyc | Down: Menu") interrupt(1,"phase6") end if (event.type=="interrupt" and event.iid=="phase6") then port.a=false interrupt(1,"phase7") end if (event.type=="interrupt" and event.iid=="phase7") then if pin.a then interrupt(0.5,"phase1") end end end