make everything more robust
[mTask.git] / Tasks / Examples.icl
index 103862c..78b0d67 100644 (file)
@@ -6,6 +6,16 @@ import mTask
 import Devices.mTaskDevice
 import iTasks._Framework.Serialization
 
+countTo5 :: Main (ByteCode () Stmt)
+countTo5 = sds \x=0 In {main =
+       x =. x +. lit 1 :.
+       pub x :.
+       IF ( x >. lit 5) (
+               retrn x
+       ) (
+               noOp
+       )}
+
 count :: Main (ByteCode () Stmt)
 count = sds \x=0 In {main = x =. x +. lit 1 :. pub x :. noOp}
 
@@ -50,7 +60,7 @@ ledtOff :: UserLED -> Main (ByteCode () Stmt)
 ledtOff d = {main = ledOff (lit d) :. noOp}
 
 readDPin :: DigitalPin -> Main (ByteCode () Stmt)
-readDPin d = sds \pin=False In {main=pin =. digitalRead d :. noOp}
+readDPin d = sds \pin=False In {main=pin =. digitalRead d :. pub pin :. noOp}
 
 ledSelection :: Task UserLED
 ledSelection = enterInformation "Select LED" []
@@ -67,4 +77,5 @@ allmTasks = 'DM'.fromList
        ,("blink", ledSelection @ blink)
        ,("blinkShare", treturn blinkShare)
        ,("count", treturn count)
+       ,("countTo5", treturn countTo5)
        ]