1 implementation module Tasks.Examples
3 import qualified Data.Map as DM
6 import Devices.mTaskDevice
7 import iTasks._Framework.Serialization
9 count :: Main (ByteCode () Stmt)
10 count = sds \x=0 In {main = x =. x +. lit 1 :. pub x :. noOp}
12 countAndLed :: Main (ByteCode () Stmt)
13 countAndLed = sds \x=1 In sds \pinnetje=1 In {main =
20 IF (pinnetje ==. lit 1) (
23 IF (pinnetje ==. lit 2) (
30 blinkShare :: Main (ByteCode () Stmt)
31 blinkShare = sds \x=1 In sds \led=LED1 In {main =
35 x =. lit 1 -. x :. noOp
38 blink :: UserLED -> Main (ByteCode () Stmt)
39 blink l = sds \x=1 In {main =
43 x =. lit 1 -. x :. noOp
46 ledtOn :: UserLED -> Main (ByteCode () Stmt)
47 ledtOn d = {main = ledOn (lit d) :. noOp}
49 ledtOff :: UserLED -> Main (ByteCode () Stmt)
50 ledtOff d = {main = ledOff (lit d) :. noOp}
52 readDPin :: DigitalPin -> Main (ByteCode () Stmt)
53 readDPin d = sds \pin=False In {main=pin =. digitalRead d :. pub pin :. noOp}
55 ledSelection :: Task UserLED
56 ledSelection = enterInformation "Select LED" []
58 pinSelection :: Task DigitalPin
59 pinSelection = enterInformation "Select digital pin" []
61 allmTasks :: Map String (Task (Main (ByteCode () Stmt)))
62 allmTasks = 'DM'.fromList
63 [("countAndLed", treturn countAndLed)
64 ,("ledOn", ledSelection @ ledtOn)
65 ,("ledOff", ledSelection @ ledtOff)
66 ,("readDPin", pinSelection @ readDPin)
67 ,("blink", ledSelection @ blink)
68 ,("blinkShare", treturn blinkShare)
69 ,("count", treturn count)