1 implementation module Tasks.Examples
3 import qualified Data.Map as DM
6 import Devices.mTaskDevice
7 import iTasks._Framework.Serialization
9 pinShare :: Main (ByteCode () Stmt)
10 pinShare = sds \p=True In {main =
14 faculty :: Int -> Main (ByteCode () Stmt)
15 faculty i = sds \y=i In sds \x=1 In {main =
23 count :: Main (ByteCode () Stmt)
24 count = sds \x=0 In {main = x =. x +. lit 1 :. pub x :. noOp}
26 countAndLed :: Main (ByteCode () Stmt)
27 countAndLed = sds \x=1 In sds \pinnetje=1 In {main =
34 IF (pinnetje ==. lit 1) (
37 IF (pinnetje ==. lit 2) (
44 blinkShare :: Main (ByteCode () Stmt)
45 blinkShare = sds \x=1 In sds \led=LED1 In {main =
49 x =. lit 1 -. x :. noOp
52 blink :: UserLED -> Main (ByteCode () Stmt)
53 blink l = sds \x=1 In {main =
57 x =. lit 1 -. x :. noOp
60 ledtOn :: UserLED -> Main (ByteCode () Stmt)
61 ledtOn d = {main = ledOn (lit d) :. noOp}
63 ledtOff :: UserLED -> Main (ByteCode () Stmt)
64 ledtOff d = {main = ledOff (lit d) :. noOp}
66 readDPin :: DigitalPin -> Main (ByteCode () Stmt)
67 readDPin d = sds \pin=False In {main=pin =. digitalRead d :. pub pin :. noOp}
69 ledSelection :: Task UserLED
70 ledSelection = enterInformation "Select LED" []
72 pinSelection :: Task DigitalPin
73 pinSelection = enterInformation "Select digital pin" []
75 allmTasks :: Map String (Task (Main (ByteCode () Stmt)))
76 allmTasks = 'DM'.fromList
77 [("countAndLed", treturn countAndLed)
78 ,("ledOn", ledSelection @ ledtOn)
79 ,("ledOff", ledSelection @ ledtOff)
80 ,("readDPin", pinSelection @ readDPin)
81 ,("blink", ledSelection @ blink)
82 ,("blinkShare", treturn blinkShare)
83 ,("count", treturn count)
84 ,("faculty", enterInformation "Faculty" [] @ faculty)
85 ,("pinShare", treturn pinShare)