import qualified Data.Map as DM
import mTask
+import Devices.mTaskDevice
import iTasks._Framework.Serialization
-derive class iTask UserLED, Main, ByteCode, Stmt, BC, BCState
+count :: Main (ByteCode () Stmt)
+count = sds \x=0 In {main = x =. x +. lit 1 :. pub x :. noOp}
countAndLed :: Main (ByteCode () Stmt)
countAndLed = sds \x=1 In sds \pinnetje=1 In {main =
noOp
) :.
IF (pinnetje ==. lit 1) (
- ledOn LED1
+ ledOn (lit LED1)
) (
IF (pinnetje ==. lit 2) (
- ledOn LED2
+ ledOn (lit LED2)
) (
- ledOn LED3
+ ledOn (lit LED3)
)
)}
-blink :: UserLED -> Main (ByteCode () Stmt)
-blink led = sds \x=1 In {main =
+blinkShare :: Main (ByteCode () Stmt)
+blinkShare = sds \x=1 In sds \led=LED1 In {main =
IF (x ==. lit 1) (
ledOn led ) (
ledOff led ) :.
x =. lit 1 -. x :. noOp
}
+blink :: UserLED -> Main (ByteCode () Stmt)
+blink l = sds \x=1 In {main =
+ IF (x ==. lit 1) (
+ ledOn (lit l) ) (
+ ledOff (lit l) ) :.
+ x =. lit 1 -. x :. noOp
+ }
+
ledtOn :: UserLED -> Main (ByteCode () Stmt)
-ledtOn d = {main = ledOn d}
+ledtOn d = {main = ledOn (lit d) :. noOp}
ledtOff :: UserLED -> Main (ByteCode () Stmt)
-ledtOff d = {main = ledOff d}
+ledtOff d = {main = ledOff (lit d) :. noOp}
+
+readDPin :: DigitalPin -> Main (ByteCode () Stmt)
+readDPin d = sds \pin=False In {main=pin =. digitalRead d :. noOp}
ledSelection :: Task UserLED
ledSelection = enterInformation "Select LED" []
+pinSelection :: Task DigitalPin
+pinSelection = enterInformation "Select digital pin" []
+
allmTasks :: Map String (Task (Main (ByteCode () Stmt)))
-allmTasks = 'DM'.fromList [
- ("countAndLed", treturn countAndLed),
- ("ledOn", ledSelection @ ledtOn),
- ("ledOff", ledSelection @ ledtOff),
- ("blink", ledSelection @ blink)]
+allmTasks = 'DM'.fromList
+ [("countAndLed", treturn countAndLed)
+ ,("ledOn", ledSelection @ ledtOn)
+ ,("ledOff", ledSelection @ ledtOff)
+ ,("readDPin", pinSelection @ readDPin)
+ ,("blink", ledSelection @ blink)
+ ,("blinkShare", treturn blinkShare)
+ ,("count", treturn count)
+ ]