Skip to content

Conversation

@nhutchison
Copy link

Updated the channel parser to support the newer AFHDS 3 protocol. AFHDS 2A doesn't set the additional bytes, so the new routine is backwards compatible.

Adding support for SAMD21 based boards, to use the HW timer.

The channel parsing routine is updated to enable the ADHFS 3 protocol
supporting up to 18 channels.  This is done by interleaving channels
15-18 in the unused bits between channels 1-12.

In AFHDS 2A the extra bytes are always 0 so it is safe to replace the
old parser with this new parser.

The SAMD21 ISR timer is added to enable support for SAMD21 architectures
such as the MKR Wifi 1010 or the Arduino Zero.
@ssube
Copy link

ssube commented Sep 20, 2021

Hi, I have been testing this branch using an FS-RX2A Pro v1 with I6X and Seeeduino XIAO, which is not an officially supported combination, but it all seems to work correctly with one small change to the HardwareSerial declaration.

The inclusion of || defined(__SAMD21G18A__) before the #define HardwareSerial arduino::HardwareSerial (ln32/33) causes a compilation error for me:

In file included from /home/ssube/Arduino/sketch_sep20a/sketch_sep20a.ino:1:0:
/home/ssube/Documents/arduino-1.8.15/libraries/IBusBM/src/IBusBM.h:36:24: error: 'arduino' has not been declared
 #define HardwareSerial arduino::HardwareSerial
                        ^
/home/ssube/Documents/arduino-1.8.15/libraries/IBusBM/src/IBusBM.h:55:14: note: in expansion of macro 'HardwareSerial'
   void begin(HardwareSerial &serial, int8_t timerid=0, int8_t rxPin=-1, int8_t txPin=-1);
              ^~~~~~~~~~~~~~
/home/ssube/Documents/arduino-1.8.15/libraries/IBusBM/src/IBusBM.h:55:29: error: expected ',' or '...' before '&' token
   void begin(HardwareSerial &serial, int8_t timerid=0, int8_t rxPin=-1, int8_t txPin=-1);
                             ^
/home/ssube/Documents/arduino-1.8.15/libraries/IBusBM/src/IBusBM.h:36:24: error: 'arduino' does not name a type; did you mean 'Arduino_h'?
 #define HardwareSerial arduino::HardwareSerial
                        ^
/home/ssube/Documents/arduino-1.8.15/libraries/IBusBM/src/IBusBM.h:81:3: note: in expansion of macro 'HardwareSerial'
   HardwareSerial *stream;           // serial port
   ^~~~~~~~~~~~~~
Multiple libraries were found for "IBusBM.h"
 Used: /home/ssube/Documents/arduino-1.8.15/libraries/IBusBM
 Not used: /home/ssube/Arduino/libraries/IBusBM
 Not used: /home/ssube/Arduino/libraries/IBusBM-master
exit status 1
Error compiling for board Seeeduino XIAO.

Referring to:

#if defined(ARDUINO_ARCH_MBED) || defined(__SAMD21G18A__)
#define HardwareSerial arduino::HardwareSerial
#else
  #if !defined(ARDUINO_ARCH_MEGAAVR)
class HardwareSerial;
  #endif
#endif

Removing the || defined(__SAMD21G18A__) clause makes it work again, builds and reads at least 6 channels:

09:16:43.033 -> channel 0: 1500
09:16:43.033 -> channel 1: 1500
09:16:43.033 -> channel 2: 1014
09:16:43.033 -> channel 3: 1500
09:16:43.033 -> channel 4: 2000
09:16:43.033 -> channel 5: 2000
09:16:43.033 -> channel 6: 1500
09:16:43.033 -> channel 7: 1500

This may be board-specific? I have some other M0 boards, and will test them later.

@bjoerngiesler
Copy link

Hi @labomat, could this be merged please? There are folks running Arduino MKR Wifis on a specific sort of Star Wars droid (D-O) that would like to use IBus. Since this PR seems to solve the issue, it would be great if it could be integrated.

@labomat
Copy link

labomat commented Apr 21, 2024

Hi @labomat, could this be merged please? There are folks running Arduino MKR Wifis on a specific sort of Star Wars droid (D-O) that would like to use IBus. Since this PR seems to solve the issue, it would be great if it could be integrated.

Sorry, I am not the owner of this repo. I cannot merge anything here. I just forked it to apply the changes - look here: https://github.com/labomat/IBusBM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants