Automated car preheating timer.
Posted: Tue Jan 19, 2016 11:01 am
I made myself timer for preheating car during these freezing winter days. Code is anything but optimized at this point and it lacks feature to schedule heating but it's coming in future update. Also i'm planning to add 0.96" OLED display in to the case for viewing remaining time.
I made blogpost with more detailed information and pictures and here is the code for version 0.3. (Will most likely rewrite whole thing when the language evolves and gets more commands.
Blogpost you can read Here!
-Jokke
I made blogpost with more detailed information and pictures and here is the code for version 0.3. (Will most likely rewrite whole thing when the language evolves and gets more commands.
Blogpost you can read Here!
Code: Select all
cls
state = Off
po 13, 0
po 14, 0
heatingTime = 0
heatingTimeMin = 0
humanTime = 0
interrupt 12, [phyButton]
timer 1000, [timerSec]
css ulkoasu.css
wprint |<meta name="viewport" content="width=device-width, initial-scale=1" />|
wprint |<meta http-equiv='refresh' content='5;URL=/input?'></head>|
wprint |<center><b>|
wprint "Heater: "
wprint htmlvar(state)
wprint "<br> Heating time left: "
wprint htmlvar(humanTime)
wprint "<br><br>"
button "On for 2H" [onTwoH]
wprint "<br><br>"
button "On for 1H 30min" [onOneHalf]
wprint "<br><br>"
button "On for 1H" [onOneH]
wprint "<br><br>"
button "On for 30min" [onHalf]
wprint "<br><br>"
button "Off" [turnOff]
wprint "<br><br>"
wait
[onTwoH]
heatingTime = 7200
goto [turnOn]
wait
[onOneHalf]
heatingTime = 5400
goto [turnOn]
wait
[onOneH]
heatingTime = 3600
goto [turnOn]
wait
[onHalf]
heatingTime = 1800
goto [turnOn]
wait
[turnOn]
po 13, 1
po 14, 1
state = On
wait
[turnOff]
po 13, 0
po 14, 0
state = Off
heatingTime = 0
interrupt 12, [phyButton]
wait
[phyButton]
interrupt 12
plusheatingTime = heatingTime + 1800
if plusheatingTime < 7200 then goto [addTime]
if plusheatingTime > 7200 then goto [turnOff]
wait
[addTime]
heatingTime = heatingTime + 1800
goto [blinkLed]
wait
[blinkLed]
blinkTimes = heatingTime / 1800
blinkTimes = left(blinkTimes,1)
for x = 1 to blinkTimes
po 14, 0
delay 100
po 14, 1
next x
interrupt 12, [phyButton]
goto [turnOn]
wait
[timerSec]
plusheatingTime = 0
heatingTime = heatingTime - 1
heatingTimeMin = heatingTime / 60
if heatingTime > 3600 then heatingTimeMin = heatingTimeMin - 60
let heatingTimeMin = left(heatingTimeMin,2)
let heatingTimeMin = replace(heatingTimeMin,".","")
if heatingTime > 3600 then humanTime = "1h "
if heatingTime > 3600 then humanTime = humanTime & heatingTimeMin
if heatingTime > 3600 then humanTime = humanTime & "min"
if heatingTimeMin <= 0 then heatingTimeMin = 0
if heatingTime < 3600 then humanTime = heatingTimeMin & "min"
if heatingTime <= 0 then goto [turnOff]
wait
-Jokke