1 implementation module Tasks.Examples
3 import qualified Data.Map as DM
6 import Devices.mTaskDevice
7 import iTasks._Framework.Serialization
9 faculty :: Int -> Main (ByteCode () Stmt)
10 faculty i = sds \y=i In sds \x=1 In {main =
18 countTo5 :: Main (ByteCode () Stmt)
19 countTo5 = sds \x=0 In {main =
28 count :: Main (ByteCode () Stmt)
29 count = sds \x=0 In {main = x =. x +. lit 1 :. pub x :. noOp}
31 countAndLed :: Main (ByteCode () Stmt)
32 countAndLed = sds \x=1 In sds \pinnetje=1 In {main =
39 IF (pinnetje ==. lit 1) (
42 IF (pinnetje ==. lit 2) (
49 blinkShare :: Main (ByteCode () Stmt)
50 blinkShare = sds \x=1 In sds \led=LED1 In {main =
54 x =. lit 1 -. x :. noOp
57 blink :: UserLED -> Main (ByteCode () Stmt)
58 blink l = sds \x=1 In {main =
62 x =. lit 1 -. x :. noOp
65 ledtOn :: UserLED -> Main (ByteCode () Stmt)
66 ledtOn d = {main = ledOn (lit d) :. noOp}
68 ledtOff :: UserLED -> Main (ByteCode () Stmt)
69 ledtOff d = {main = ledOff (lit d) :. noOp}
71 readDPin :: DigitalPin -> Main (ByteCode () Stmt)
72 readDPin d = sds \pin=False In {main=pin =. digitalRead d :. pub pin :. noOp}
74 ledSelection :: Task UserLED
75 ledSelection = enterInformation "Select LED" []
77 pinSelection :: Task DigitalPin
78 pinSelection = enterInformation "Select digital pin" []
80 allmTasks :: Map String (Task (Main (ByteCode () Stmt)))
81 allmTasks = 'DM'.fromList
82 [("countAndLed", treturn countAndLed)
83 ,("ledOn", ledSelection @ ledtOn)
84 ,("ledOff", ledSelection @ ledtOff)
85 ,("readDPin", pinSelection @ readDPin)
86 ,("blink", ledSelection @ blink)
87 ,("blinkShare", treturn blinkShare)
88 ,("count", treturn count)
89 ,("countTo5", treturn countTo5)
90 ,("faculty", enterInformation "Faculty" [] @ faculty)