Skip to content
Snippets Groups Projects

Interrupts example

Merged Ghost User requested to merge interrupts into master
1 file
+ 26
0
Compare changes
  • Side-by-side
  • Inline
switch.icl 0 → 100644
+ 26
0
module switch
import StdEnv, iTasks
import mTask.Interpret
import mTask.Interpret.Devices
Start w = doTasks main w
main :: Task Bool
main = enterInformation []
>>? \spec=:{TCPSettings|host,port}->withDevice spec
\dev->liftmTask switch dev
switch :: Main (MTask v Bool) | mtask v
switch
= declarePin D1 PMInput \d1->
declarePin D4 PMOutput \d4->
fun \switch=(\x->
(writeD d4 x)
>>|. delay (lit 50) // Debounce
>>|. interrupt Falling d1
>>=. (\_. (switch (Not x)))
)
In {main=switch (lit False)}
Loading