Sub Process_Globals
Public Serial1 As Serial
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
RunNative("vw_start", Null)
SendMessage("hello!")
End Sub
Private Sub SendMessage(msg() As Byte)
RunNative("vw_send", msg)
End Sub
#if c
#include <VirtualWire.h>
void vw_start(B4R::Object* o) {
vw_set_ptt_inverted(true); // Required by the RF module
vw_setup(2000); // bps connection speed
vw_set_tx_pin(3); // Arduino pin to connect the receiver data pin
}
void vw_send(B4R::Object* msg) {
B4R::Array* arr = (B4R::Array*)msg->data.PointerField;
vw_send((Byte*)arr->data, arr->length);
vw_wait_tx();
}
#end if