This Pull Request splits CRSF for Arduino up into the following layers:
Sketch Layer
This is the surface layer. It exposes minimal API functions to your sketch in favour of simplicity.
Serial Receiver
The next layer down. This is a generic API that I have created to serve as a conduit for interfacing with your chosen TBS Crossfire or ExpressLRS receiver. Serial Receiver processes incoming RC frames from your receiver as well as sending out telemetry to your controller.
Additionally, the Serial Receiver layer can act as a nexus for future expansion with any other RC receivers that have a serial protocol.
Hardware
Also known as the Hardware Abstraction Layer (abbreviated to HAL). This is where all the nitty-gritty, persnickety, "bare-metal" code that is specific to a particular chipset is housed. The Hardware Abstraction Layer is the lowest level of all three primary abstraction layers.
By splitting the source code up like this, it only encapsulates code that is relevant to each layer & nothing else. This enhances readability, making the code appear less daunting, & making it easier to debug.
Problems with encapsulation
Previous iterations of CRSF for Arduino were encapsulated in only two files: CRSFforArduino.h & CRSFforArduino.cpp.
As my project expanded, I found that I was spending the bulk of my time scrolling through 1,000+ lines of code, before I could get to where I needed to be.
With abstraction, I can easily get to any part of CRSF for Arduino without the need to feel like I am doomscrolling.
This benefits you too
Arduino IDE & PlatformIO users, this means you!
When you open up the sketch layer, this is all you see...
By abstracting away all of the stuff that intimidates newcomers to coding, I can dick around with stuff in the background without me even needing to touch the sketch layer.
Any changes I make in the future, unless I explicitly state otherwise, you don't need to make any changes to your existing code in order to accommodate newer iterations of CRSF for Arduino.
This brings me to my next point...
This breaks compatibility with previous versions
This is because I am using a different file-&-folder structure, & I have done my level best to help make the transition to the upcoming release of Version 0.4.0 as smooth & painless for you as possible.
But, keep in mind that not all things are dead-set perfect. If you are having issues, please don't hesitate with either submitting an Issue or opening a Discussion thread.
Overview
This Pull Request splits CRSF for Arduino up into the following layers:
By splitting the source code up like this, it only encapsulates code that is relevant to each layer & nothing else. This enhances readability, making the code appear less daunting, & making it easier to debug.
Problems with encapsulation
Previous iterations of CRSF for Arduino were encapsulated in only two files:
CRSFforArduino.h
&CRSFforArduino.cpp
. As my project expanded, I found that I was spending the bulk of my time scrolling through 1,000+ lines of code, before I could get to where I needed to be.With abstraction, I can easily get to any part of CRSF for Arduino without the need to feel like I am doomscrolling.
This benefits you too
Arduino IDE & PlatformIO users, this means you!
When you open up the sketch layer, this is all you see...
As for the examples, they are largely unchanged.
By abstracting away all of the stuff that intimidates newcomers to coding, I can dick around with stuff in the background without me even needing to touch the sketch layer.
Any changes I make in the future, unless I explicitly state otherwise, you don't need to make any changes to your existing code in order to accommodate newer iterations of CRSF for Arduino.
This brings me to my next point...
This breaks compatibility with previous versions
This is because I am using a different file-&-folder structure, & I have done my level best to help make the transition to the upcoming release of Version 0.4.0 as smooth & painless for you as possible.
But, keep in mind that not all things are dead-set perfect. If you are having issues, please don't hesitate with either submitting an Issue or opening a Discussion thread.