process many comments
[phd-thesis.git] / intro / lst / blink.icl
1 module blink
2
3 import mTask.Interpret
4 import mTask.Interpret.Device.TCP
5 import iTasks.Extensions.DateTime
6 import StdEnv, iTasks
7
8 Start w = doTasks interactiveBlink w
9
10 interactiveBlink :: Task ()
11 interactiveBlink = enterDevice/*\label{lst:intro_enterDevice}*/
12 >>? \spec->withShared 500 \iInterval-> /*\label{lst:intro_withshared}*/
13 withDevice spec \dev-> /*\label{lst:intro_withdevice}*/
14 liftmTask (intBlink iInterval) dev/*\label{lst:intro_liftmtask}*/
15 -|| (Hint "Interval (ms)" @>> updateSharedInformation [] iInterval)/*\label{lst:intro_editor}*/
16 >>* [OnAction (Action "Stop") (always (return ()))]
17
18 enterDevice :: Task TCPSettings
19 enterDevice = enterInformation [] <<@ Hint "Enter connection info"
20
21 intBlink :: (Shared sds Int) -> Main (MTask v Int)
22 | mtask, lowerSds v & RWShared sds & TC sds () Int Int
23 /*
24 intBlink :: (Shared sds Int) -> Main (MTask v Int) | mtask v & ...
25 */
26 intBlink iInterval =
27 declarePin D2 PMOutput \ledPin-> /*\label{lst:intro:declarePin}*/
28 lowerSds \mInterval = iInterval/*\label{lst:intro:liftsds}*/
29 In fun \blink = (\st-> /*\label{lst:intro:blink_fro}*/
30 getSds mInterval
31 >>=. \i->delay i
32 >>|. writeD ledPin st
33 >>|. blink (Not st))/*\label{lst:intro:blink_to}*/
34 In {main = blink true}/*\label{lst:intro:mtask_to}*/