This is a very inefficient way of doing it, plus visually speaking, it looks confusing af.
The New Way
In the CRSFforArduino::update() function, this is how I roll, now...
// Read the RC channels.
memcpy(&_crsfRcChannelsPackedFrame, &_crsfFrame, CRSF_FRAME_SIZE_MAX);
Notice how it's much more concise?
Programmatically, it is more efficient because all I am doing here is double-buffering the incoming RC channel data.
I have also moved the RC channel data unpacking out of the CRSFforArduino::update() function & put it into the CRSFforArduino::getChannel() function.
Here you can see how straightforward this looks. I know what RC channel is going where.
Additional
I have removed the caveat regarding the SERCOM UART data order.
Since using packed RC channels, there is no need for me to the low-level hardware UART driver to set its data order to Most Significant Bit First.
This opens up the door for more hardware compatibility.
In the readme I have also clarified what CRSF for Arduino's minimum requirements are, & what you can do if your devboard meets the minimum requirements & yet, you're still having compatibility issues.
Overview
This Pull Request re-factors the way RC channels data is handled.
What's changed
The Old Way
In the
CRSFforArduino::update()
function, this is how I used to unpack RC channels data...This is a very inefficient way of doing it, plus visually speaking, it looks confusing af.
The New Way
In the
CRSFforArduino::update()
function, this is how I roll, now...Notice how it's much more concise? Programmatically, it is more efficient because all I am doing here is double-buffering the incoming RC channel data. I have also moved the RC channel data unpacking out of the
CRSFforArduino::update()
function & put it into theCRSFforArduino::getChannel()
function.Here you can see how straightforward this looks. I know what RC channel is going where.
Additional
I have removed the caveat regarding the SERCOM UART data order. Since using packed RC channels, there is no need for me to the low-level hardware UART driver to set its data order to Most Significant Bit First. This opens up the door for more hardware compatibility.
In the readme I have also clarified what CRSF for Arduino's minimum requirements are, & what you can do if your devboard meets the minimum requirements & yet, you're still having compatibility issues.