instance toString MTaskMSGRecv where
toString (MTPub i v) = "Publish id: " +++ toString i
+++ " value " +++ safePrint v
instance toString MTaskMSGRecv where
toString (MTPub i v) = "Publish id: " +++ toString i
+++ " value " +++ safePrint v
-bclength (BCSdsStore _) = 2
-bclength (BCSdsFetch _) = 2
-bclength (BCSdsPublish _) = 2
+bclength (BCSdsStore _) = 3
+bclength (BCSdsFetch _) = 3
+bclength (BCSdsPublish _) = 3
bclength (BCAnalogRead _) = 2
bclength (BCAnalogWrite _) = 2
bclength (BCDigitalRead _) = 2
bclength (BCDigitalWrite _) = 2
bclength (BCAnalogRead _) = 2
bclength (BCAnalogWrite _) = 2
bclength (BCDigitalRead _) = 2
bclength (BCDigitalWrite _) = 2
- (BCSdsStore i) = [toChar i]
- (BCSdsFetch i) = [toChar i]
- (BCSdsPublish i) = [toChar i]
+ (BCSdsStore i) = [c\\c<-:to16bit i]
+ (BCSdsFetch i) = [c\\c<-:to16bit i]
+ (BCSdsPublish i) = [c\\c<-:to16bit i]
(BCAnalogRead i) = [toChar i]
(BCAnalogWrite i) = [toChar i]
(BCDigitalRead i) = [toChar i]
(BCDigitalWrite i) = [toChar i]
(BCAnalogRead i) = [toChar i]
(BCAnalogWrite i) = [toChar i]
(BCDigitalRead i) = [toChar i]
(BCDigitalWrite i) = [toChar i]
fmp f b = BC \s->let (bc, s`) = runBC b s in (f bc, s`)
instance toByteCode Bool where
fmp f b = BC \s->let (bc, s`) = runBC b s in (f bc, s`)
instance toByteCode Bool where
- toByteCode True = [toChar 1]
- toByteCode False = [toChar 0]
+ toByteCode True = [toChar 0, toChar 1]
+ toByteCode False = [toChar 0, toChar 0]
instance toByteCode Int where toByteCode n = map toChar [n/256,n rem 256]
instance toByteCode Long where toByteCode (L n) = toByteCode n
instance toByteCode Char where toByteCode c = [c]
instance toByteCode String where toByteCode s = undef
instance toByteCode Button where toByteCode s = [toChar $ consIndex{|*|} s]
instance toByteCode Int where toByteCode n = map toChar [n/256,n rem 256]
instance toByteCode Long where toByteCode (L n) = toByteCode n
instance toByteCode Char where toByteCode c = [c]
instance toByteCode String where toByteCode s = undef
instance toByteCode Button where toByteCode s = [toChar $ consIndex{|*|} s]
derive gPrint BC, AnalogPin, Pin, DigitalPin
derive gPrint BC, AnalogPin, Pin, DigitalPin
derive consName BC, Pin, Button
instance arith ByteCode where
derive consName BC, Pin, Button
instance arith ByteCode where
b <++> retrn [BCJmpF else] <++> t
<++> retrn [BCJmp endif,BCLab else] <++> e <++> retrn [BCLab endif]
b <++> retrn [BCJmpF else] <++> t
<++> retrn [BCJmp endif,BCLab else] <++> e <++> retrn [BCLab endif]
instance zero BCState where
zero = {freshl=[1..], freshs=[1..], sdss=[]}
instance zero BCState where
zero = {freshl=[1..], freshs=[1..], sdss=[]}
# (bc, gtmap) = computeGotos bc 0
= (join "\n" $ map readable (map (implGotos gtmap) bc), st)
# (bc, gtmap) = computeGotos bc 0
= (join "\n" $ map readable (map (implGotos gtmap) bc), st)
toMessages :: Int (String, BCState) -> ([MTaskMSGSend], BCState)
toMessages interval (bytes, st=:{sdss}) = ([MTSds i (toString b)\\(i,b)<-sdss] ++ [MTTask interval bytes], st)
toMessages :: Int (String, BCState) -> ([MTaskMSGSend], BCState)
toMessages interval (bytes, st=:{sdss}) = ([MTSds i (toString b)\\(i,b)<-sdss] ++ [MTTask interval bytes], st)