Sub Process_Globals
Public Serial1 As Serial
Private timer1 As Timer
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
timer1.Initialize("timer1_Tick", 100)
timer1.Enabled = True
End Sub
Sub Timer1_Tick
Dim jx As Int = RunNative("readJoystickX", Null)
Dim jy As Int = RunNative("readJoystickY", Null)
Log("jx: ", jx, ", jy: ", jy)
End Sub
#if C
#include <Esplora.h>
B4R::Object res;
B4R::Object* readJoystickX(B4R::Object* o) {
return res.wrapNumber(Esplora.readJoystickX());
}
B4R::Object* readJoystickY(B4R::Object* o) {
return res.wrapNumber(Esplora.readJoystickY());
}
B4R::Object* readButton(B4R::Object* channel) {
return res.wrapNumber(Esplora.readButton(channel->toULong()));
}
#end if