diff --git a/examples/rp2040/ibus_basic/.arduino-ci.yml b/examples/rp2040/ibus_basic/.arduino-ci.yml new file mode 100644 index 0000000..f08632d --- /dev/null +++ b/examples/rp2040/ibus_basic/.arduino-ci.yml @@ -0,0 +1,18 @@ +platforms: + rpipico: + board: rp2040:rp2040:rpipico + package: rp2040:rp2040 + gcc: + features: + defines: + - ARDUINO_ARCH_RP2040 + warnings: + flags: + +packages: + rp2040:rp2040: + url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json + +compile: + platforms: + - rpipico diff --git a/examples/rp2040/ibus_basic/ibus_basic.ino b/examples/rp2040/ibus_basic/ibus_basic.ino new file mode 100644 index 0000000..931e9b4 --- /dev/null +++ b/examples/rp2040/ibus_basic/ibus_basic.ino @@ -0,0 +1,54 @@ +/*! + * @file ibus_basic.ino + */ +/* + +# Sample platformio.ini file: +# --------------------------- +[platformio] +default_envs = ws-rp2040-zero + +[env:ws-rp2040-zero] +platform = https://github.com/maxgerhardt/platform-raspberrypi.git +board = waveshare_rp2040_pizero +framework = arduino +board_build.core = earlephilhower +monitor_speed = 115200 + +lib_deps = + https://github.com/Witty-Wizard/SerialIO +*/ + +#include + +#define SBUS_TX_PIN 0 +#define SBUS_RX_PIN 1 + +rc_channels_t rcdata; +ibus receiver(&Serial1, SBUS_RX_PIN, SBUS_TX_PIN, + true); // RP2040 requires the TX_PIN so to not hang up the mcu + +void setup() { + // setup sbus receiver + receiver.begin(); + + Serial.begin(115200); +} + +void loop() { + static unsigned long last_millis = millis(); + + receiver.processIncoming(); + receiver.getChannel(&rcdata); + + if (millis() > last_millis + 100) { + Serial.printf("RC: %4d %4d %4d %4d %4d %4d %4d %4d %4d %4d %4d %4d %4d %4d", + rcdata.channel1, rcdata.channel2, rcdata.channel3, + rcdata.channel4, rcdata.channel5, rcdata.channel6, + rcdata.channel7, rcdata.channel8, rcdata.channel9, + rcdata.channel10, rcdata.channel11, rcdata.channel12, + rcdata.channel13, rcdata.channel14); + Serial.println(); + last_millis = millis(); + } +}