-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(library): Add full telemetry support #47
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 tasks
ZZ-Cat
added
✨️ Enhancement ✨️
New feature or request
...in progress 🚧
Development on this is in progress
labels
Oct 31, 2023
…telemetry EG 1526 = 152.6 degrees
…y.ino` example firmware
You can now tailor CRSF for Arduino to suit your individual projects' needs.
Gods, this is an outdated way to manage syntax highlighting. Why you do this, Arduino?! This is one of the many reasons why I prefer VS Code over the Arduino IDE these days.
You can now assign a Flight Mode per channel and specify the minimum and maximum ranges for that Flight Mode.
Your selected Flight Mode is now available on your controller as Telemetry.
This does away with a minor glitch upon initial startup, where Acro flight mode is selected _before_ the Disarm flag.
…TMODES_ENABLED` and `CRSF_RC_ENABLED` are both set to zero.
When enabled, this will initialise the Aux1 Channel to its minimum value. This is intended for use with ExpressLRS receivers.
…abled, but the Telemetry API itself is enabled.
…NABLED` and `CRSF_RC_ENABLED` options The Flight Modes API relies on the RC API to determine the correct flight mode.
…etry by default You will need to _enable_ this if you want to use it in your porjects.
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
I am finally getting around to adding full telemetry feedback.
Instead of putting each telemetric category into its own Issue-and-Pull-Request combo (which is more time consuming and harder to keep track of), I have decided to put all of the outstanding telemetry categories into this Pull Request to make it easier for myself to track the development progress.
Here is a list of what's being implemented:
Also, I am documenting all telemetry here, so that it's easier for you to refer back to this Pull Request any time you need to.
This is also a reminder to myself to update the documentation, and I am thinking of shutting down my ReadTheDocs link to the project in favour of a better documentation host platform.Configuration
The file you are looking for is
CFA_Config.hpp
.This is where you can tailor CRSF for Arduino to suit your individual needs.
Options
Here is a run-down of the configuration options that this Pull Request brings...
CRSF_RC_ENABLED
1
CRSF_RC_MAX_CHANNELS
16
CRSF_RC_CHANNEL_MIN
172
CRSF_RC_CHANNEL_MAX
1811
CRSF_RC_CHANNEL_CENTER
992
CRSF_RC_INITIALISE_CHANNELS
CRSF_RC_CHANNEL_CENTER
value.1
CRSF_RC_INITIALISE_THROTTLECHANNEL
CRSF_RC_CHANNEL_MIN
value. Otherwise, it will be initialised with the value determined byCRSF_RC_INITIALISE_CHANNELS
option.1
CRSF_FLIGHTMODES_ENABLED
0
CRSF_TELEMETRY_ENABLED
1
CRSF_TELEMETRY_ATTITUDE_ENABLED
1
CRSF_TELEMETRY_BAROALTITUDE_ENABLED
1
CRSF_TELEMETRY_BATTERY_ENABLED
1
CRSF_TELEMETRY_FLIGHTMODE_ENABLED
0
CRSF_TELEMETRY_GPS_ENABLED
1
CRSF_DEBUG_ENABLED
0
CRSF_DEBUG_SERIAL_PORT
Serial
Limitations
CRSF_RC_ENABLED
andCRSF_TELEMETRY_ENABLED
are both set to0
.CRSF_RC_ENABLED
to0
turns off the ability to receive and parse RC channels.CRSF_TELEMETRY_ENABLED
to0
and the ability to send telemetry back to your controller.CRSF_RC_INITIALISE_THROTTLECHANNEL
will only work ifCRSF_RC_ENABLED
andCRSF_RC_INITIALISE_CHANNELS
are set to1
- IE Enabled.CRSF_RC_MAX_CHANNELS
any higher than what the number of RC channels that the CRSF Protocol provides. This is limited to 16 channels.CFA_Config.hpp
will successfully compile and flash with impunity. But, when their configuration is disabled, these API functions will "silently fail". This is by design.Flight Modes API
While I was working on adding Flight Modes Telemetry, I took the liberty of giving this category its own bespoke API.
This is disabled by default and you must enable it by setting both
CRSF_RC_ENABLED
andCRSF_FLIGHTMODES_ENABLED
to1
inCFA_Config.hpp
.This is because the Flight Modes API depends on the RC Channels to determine the actual mode.
Functions
CRSFforArduino::setFlightMode(serialReceiver::flightModeId_t flightMode, uint8_t channel, uint16_t min, uint16_t max)
This function registers your chosen Flight Mode with your selected channel.
The
min
andmax
parameters determine the channel range that is considered to be your chosen mode.CRSFforArduino::setFlightModeCallback(void (*callback)(serialReceiver::flightModeId_t flightMode))
This function registers an event callback where you write your Flight Modes implementation.
Telemetry
Attitude Telemetry
This is your roll, pitch, and yaw values. It is often fed into an artificial horizon indicator on your controller (if you're using a "glass cockpit" Lua script on your controller).
Each value is in decidegrees and are 16-bit unsigned values.
The table below shows how the decidegree input values per axis translate to the Degree SI Unit:
int16_t
int16_t
int16_t
To use Attitude Telemetry in your code, use this function:
CRSFforArduino::telemetryWriteAttitude(int16_t roll, int16_t pitch, int16_t yaw)
Barometric Altitude and Variometer Telemetry
There isn't a lot of objective and unbiased knowledge for this telemetric category.
From what I understand of it, you feed data into this from your barometric pressure sensor.
Altitude data is in decimetres and Variometer data is in centimetres per second.
The table below shows how the input values translate to their SI Unit equivalent:
uint16_t
int16_t
To use Barometric Altitude Telemetry in your code, use this function:
CRSFforArduino::telemetryWriteBaroAltitude(uint16_t altitude, int16_t vario)
Battery Telemetry
This is one of the main categories that you use.
Here, you have access to your battery's voltage, current, and energy consumption. Plus, how much percentage of that energy is left in your battery.
The table below shows how each value translate to its SI Unit equivalent:
float
float
uint32_t
uint8_t
To use Battery Telemetry in your code, use this function:
CRSFforArduino::telemetryWriteBattery(float voltage, float current, uint32_t fuel, uint8_t percent)
Flight Modes
These are text-based and are usually fed into your "glass cockpit" Lua script to give both visual and audible alerts to the state of your drone.
Flight Modes telemetry is crucial for some flight controllers and ground stations to work effectively, as this is used to provide a deterministic way of knowing what state your drone is in at all times.
Here is a list of the current supported Flight Modes:
*
and appended to the end of one of the modes below)These are the same modes used in Betaflight.
The initial support only adds in Betaflight's Flight Modes. I may add in others either as time marches on, or if someone requests it by opening an Issue.
To use the Flight Mode Telemetry in your code, use this function:
CRSFforArduino::telemetryWriteFlightMode(serialReceiver::flightModeId_t flightMode)
GPS
Better known as GNSS, because GPS has been obsolete for quite some time.
This provides you with location and altitude data.
The table below shows how each value translate to its SI Unit equivalent:
float
float
float
float
float
uint8_t
To use GPS Telemetry in your code, use this function:
CRSFforArduino::telemetryWriteGPS(float latitude, float longitude, float altitude, float speed, float groundCourse, uint8_t satellites)
Additional
telemetry.hpp
to a separate configuration header and make it easily accessible to the Sketch Layer.By the time I am finished with this Pull Request, you can use CRSF for Arduino with scripts such as iNav's telemetry widget in your controller.
You're welcome. =^/.~=