Spark Core Interface

new BookmarkLockedFalling
jamie
New Member
*

jamie Avatar

Posts: 2Male

Post by jamie on Oct 20, 2014 14:52:36 GMT -5

I have programed a Run Basic interface for the Spark Core (arduino-like controller) Example Remote Spark Web App. It works using cURL though the Shell$ command but is SLOOOW. Here is an ajax example for Spark Core. Is their a faster way with Runbasic to talk to the controller? Sorry for the sloppy coding, only programing classes I've had were on Apple II in the early 1980's. :)

P.S.- I'll have the board running for the next few days if anyone want to play with the code.


cssid #Section0, "{
color: gray;
background-color:#E5C69F;
width:900px;
height:230px;
font-size:60pt;
Border-Style: double;
Border-Width:30px;
border-color:#E1BF93;
}"

CSSID #Section1, "{
background-color:#E5C69F;
color: red;
width:900px;
height:230px;
font-size:60pt;
Border-Style: double;
Border-Width: 30px;
border-color:#E1BF93;
}"

CSSID #Section2, "{
Color: GREEN;
width:900px;
height:230px;
font-size:60pt;
background-color:#E5C69F;
Border-Style: double;
Border-Width: 30px;
border-color:#E1BF93;
}"

cssid #Section3, "{
color: BurlyWood;
Text-Align: Center;
-moz-background-size: cover;
background-color:BurlyWood ;

}"

gosub [start read]
gosub [trunk read]
gosub [lock read]

goto [draw screen]


[main loop]
wait
goto [main loop]


[start read]
b$= shell$("curl -G https://api.spark.io/v1/devices/48ff6a065067555046521187/startstate\ -d access_token=f6baff2e1bd207605fc412947857e377ac984ea3")
gosub [get results]
if val(g$)=0 then
h$="CAR ON"
i$="Section2"
else
h$="CAR OFF"
i$="Section1"
end if
return


[trunk read]
b$= shell$("curl -G https://api.spark.io/v1/devices/48ff6a065067555046521187/trunkstate\ -d access_token=f6baff2e1bd207605fc412947857e377ac984ea3")
gosub [get results]
if val(g$)=0 then
j$="TRUNK LOCKED"
k$="Section2"
else
j$="TRUNK UNLOCKED"
k$="Section1"
end if
return

[lock read]
b$= shell$("curl -G https://api.spark.io/v1/devices/48ff6a065067555046521187/lockstate\ -d access_token=f6baff2e1bd207605fc412947857e377ac984ea3")
gosub [get results]
if val(g$)=0 then
l$="Section0"
m$="Section2"
else
l$="Section2"
m$="Section0"
end if
return


[start pressed]
a$= shell$("curl -k https://api.spark.io/v1/devices/48ff6a065067555046521187/start -d access_token=f6baff2e1bd207605fc412947857e377ac984ea3")
gosub [start read]
goto [draw screen]

[trunk pressed]
a$= shell$("curl -k https://api.spark.io/v1/devices/48ff6a065067555046521187/trunk -d access_token=f6baff2e1bd207605fc412947857e377ac984ea3")
gosub [trunk read]
goto [draw screen]


[lock pressed]
a$= shell$("curl -k https://api.spark.io/v1/devices/48ff6a065067555046521187/lock -d access_token=f6baff2e1bd207605fc412947857e377ac984ea3")
gosub [lock read]
goto [draw screen]


[unlock pressed]
a$= shell$("curl -k https://api.spark.io/v1/devices/48ff6a065067555046521187/unlock -d access_token=f6baff2e1bd207605fc412947857e377ac984ea3")
gosub [lock read]
goto [draw screen]


[draw screen]
cls
DIV Section3
print""
print""
print""
print""
button #a, h,ドル [start pressed]
#a setid(i$)
print""
print""
print ""
print ""
button #b, j,ドル [trunk pressed]
#b setid(k$)
print""
print""
print""
print""
button #n, "LOCK DOOR", [lock pressed]
#n setid(m$)
print""
print""
print""
print""
button #o, "UNLOCK DOOR", [unlock pressed]
#o setid(l$)
print""
print""
print""
print""
print""
END DIV
goto [main loop]


[get results]
c= INSTR(b,ドル "result")
d=c+9
e= INSTR(b,ドル ",", c)
f=e-d
g$=MID$(b,ドル d , f)
return


jamie
New Member
*

jamie Avatar

Posts: 2Male