From: Mart Lubbers Date: Tue, 21 Mar 2017 19:52:39 +0000 (+0100) Subject: add example X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=6afdda16550a6e1d034650abc22effe17573c840;p=mTask.git add example --- diff --git a/Tasks/Examples.icl b/Tasks/Examples.icl index 103862c..b0ae530 100644 --- a/Tasks/Examples.icl +++ b/Tasks/Examples.icl @@ -50,7 +50,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" [] diff --git a/client/interface.c b/client/interface.c index 8afac28..432671c 100644 --- a/client/interface.c +++ b/client/interface.c @@ -31,6 +31,7 @@ uint64_t dpins[] = {LINE_ARD_D0, LINE_ARD_D1, LINE_ARD_D2, LINE_ARD_D3, LINE_ARD_D4, LINE_ARD_D5, LINE_ARD_D6, LINE_ARD_D7, LINE_ARD_D8, LINE_ARD_D9, LINE_ARD_D10, LINE_ARD_D11, LINE_ARD_D12, LINE_ARD_D13, LINE_ARD_D14, LINE_ARD_D15}; + void write_dpin(uint8_t i, bool b) { palWriteLine(dpins[i], b ? PAL_HIGH : PAL_LOW); @@ -38,6 +39,7 @@ void write_dpin(uint8_t i, bool b) bool read_dpin(uint8_t i) { + debug("readpin: %d", i); return palReadLine(dpins[i]) == PAL_HIGH; } diff --git a/client/sds.c b/client/sds.c index 66bcb16..e6bf3b5 100644 --- a/client/sds.c +++ b/client/sds.c @@ -85,7 +85,21 @@ void sds_publish(int id) write_byte('p'); write16(sdss[cs].id); write_byte(sdss[cs].type); - write16(sdss[cs].value); + + switch(sdss[cs].type){ + //Long + case 'l': + //Int + case 'i': + write16(sdss[cs].value); + break; + case 'b': //Bool + case 'c': //Character + case 'B': //Button + case 'L': //UserLED + write_byte(sdss[cs].value); + break; + } write_byte('\n'); return; }