1 implementation module Tasks.Examples
3 import qualified Data.Map as DM
6 import Devices.mTaskDevice
7 import iTasks._Framework.Serialization
9 countTo5 :: Main (ByteCode () Stmt)
10 countTo5 = sds \x=0 In {main =
19 count :: Main (ByteCode () Stmt)
20 count = sds \x=0 In {main = x =. x +. lit 1 :. pub x :. noOp}
22 countAndLed :: Main (ByteCode () Stmt)
23 countAndLed = sds \x=1 In sds \pinnetje=1 In {main =
30 IF (pinnetje ==. lit 1) (
33 IF (pinnetje ==. lit 2) (
40 blinkShare :: Main (ByteCode () Stmt)
41 blinkShare = sds \x=1 In sds \led=LED1 In {main =
45 x =. lit 1 -. x :. noOp
48 blink :: UserLED -> Main (ByteCode () Stmt)
49 blink l = sds \x=1 In {main =
53 x =. lit 1 -. x :. noOp
56 ledtOn :: UserLED -> Main (ByteCode () Stmt)
57 ledtOn d = {main = ledOn (lit d) :. noOp}
59 ledtOff :: UserLED -> Main (ByteCode () Stmt)
60 ledtOff d = {main = ledOff (lit d) :. noOp}
62 readDPin :: DigitalPin -> Main (ByteCode () Stmt)
63 readDPin d = sds \pin=False In {main=pin =. digitalRead d :. pub pin :. noOp}
65 ledSelection :: Task UserLED
66 ledSelection = enterInformation "Select LED" []
68 pinSelection :: Task DigitalPin
69 pinSelection = enterInformation "Select digital pin" []
71 allmTasks :: Map String (Task (Main (ByteCode () Stmt)))
72 allmTasks = 'DM'.fromList
73 [("countAndLed", treturn countAndLed)
74 ,("ledOn", ledSelection @ ledtOn)
75 ,("ledOff", ledSelection @ ledtOff)
76 ,("readDPin", pinSelection @ readDPin)
77 ,("blink", ledSelection @ blink)
78 ,("blinkShare", treturn blinkShare)
79 ,("count", treturn count)
80 ,("countTo5", treturn countTo5)