Skip to content

Commit

Permalink
Support Betaflight 4.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wetheredge committed Apr 28, 2024
1 parent 966a6a1 commit 4b8f6b3
Show file tree
Hide file tree
Showing 17 changed files with 920 additions and 293 deletions.
312 changes: 236 additions & 76 deletions src/generated/debug_mode.rs

Large diffs are not rendered by default.

58 changes: 34 additions & 24 deletions src/generated/disabled_fields.rs
Expand Up @@ -78,6 +78,8 @@ pub enum FieldGroup {
Gps,
/// `GYRO`
Gyro,
/// `GYROUNFILT`
GyroUnfiltered,
/// `MAG`
Mag,
/// `MOTOR`
Expand All @@ -86,6 +88,8 @@ pub enum FieldGroup {
Pid,
/// `RC_COMMANDS`
RcCommands,
/// `RPM`
Rpm,
/// `RSSI`
Rssi,
/// `SETPOINT`
Expand All @@ -101,10 +105,12 @@ impl crate::units::Flag for FieldGroup {
Self::DebugLog => "DEBUG_LOG",
Self::Gps => "GPS",
Self::Gyro => "GYRO",
Self::GyroUnfiltered => "GYROUNFILT",
Self::Mag => "MAG",
Self::Motor => "MOTOR",
Self::Pid => "PID",
Self::RcCommands => "RC_COMMANDS",
Self::Rpm => "RPM",
Self::Rssi => "RSSI",
Self::Setpoint => "SETPOINT",
}
Expand All @@ -127,37 +133,41 @@ impl FieldGroup {
const fn from_bit(bit: u32, fw: crate::headers::InternalFirmware) -> Option<Self> {
use crate::headers::InternalFirmware::*;
match (bit, fw) {
(0u32, Betaflight4_3 | Betaflight4_4) => Some(Self::Pid),
(1u32, Betaflight4_3 | Betaflight4_4) => Some(Self::RcCommands),
(2u32, Betaflight4_3 | Betaflight4_4) => Some(Self::Setpoint),
(3u32, Betaflight4_3 | Betaflight4_4) => Some(Self::Battery),
(4u32, Betaflight4_3 | Betaflight4_4) => Some(Self::Mag),
(5u32, Betaflight4_3 | Betaflight4_4) => Some(Self::Altitude),
(6u32, Betaflight4_3 | Betaflight4_4) => Some(Self::Rssi),
(7u32, Betaflight4_3 | Betaflight4_4) => Some(Self::Gyro),
(8u32, Betaflight4_3 | Betaflight4_4) => Some(Self::Acc),
(9u32, Betaflight4_3 | Betaflight4_4) => Some(Self::DebugLog),
(10u32, Betaflight4_3 | Betaflight4_4) => Some(Self::Motor),
(11u32, Betaflight4_3 | Betaflight4_4) => Some(Self::Gps),
(0u32, Betaflight4_3 | Betaflight4_4 | Betaflight4_5) => Some(Self::Pid),
(1u32, Betaflight4_3 | Betaflight4_4 | Betaflight4_5) => Some(Self::RcCommands),
(2u32, Betaflight4_3 | Betaflight4_4 | Betaflight4_5) => Some(Self::Setpoint),
(3u32, Betaflight4_3 | Betaflight4_4 | Betaflight4_5) => Some(Self::Battery),
(4u32, Betaflight4_3 | Betaflight4_4 | Betaflight4_5) => Some(Self::Mag),
(5u32, Betaflight4_3 | Betaflight4_4 | Betaflight4_5) => Some(Self::Altitude),
(6u32, Betaflight4_3 | Betaflight4_4 | Betaflight4_5) => Some(Self::Rssi),
(7u32, Betaflight4_3 | Betaflight4_4 | Betaflight4_5) => Some(Self::Gyro),
(8u32, Betaflight4_3 | Betaflight4_4 | Betaflight4_5) => Some(Self::Acc),
(9u32, Betaflight4_3 | Betaflight4_4 | Betaflight4_5) => Some(Self::DebugLog),
(10u32, Betaflight4_3 | Betaflight4_4 | Betaflight4_5) => Some(Self::Motor),
(11u32, Betaflight4_3 | Betaflight4_4 | Betaflight4_5) => Some(Self::Gps),
(12u32, Betaflight4_5) => Some(Self::Rpm),
(13u32, Betaflight4_5) => Some(Self::GyroUnfiltered),
_ => None,
}
}

const fn to_bit(self, fw: crate::headers::InternalFirmware) -> Option<u32> {
use crate::headers::InternalFirmware::*;
match (self, fw) {
(Self::Pid, Betaflight4_3 | Betaflight4_4) => Some(0u32),
(Self::RcCommands, Betaflight4_3 | Betaflight4_4) => Some(1u32),
(Self::Setpoint, Betaflight4_3 | Betaflight4_4) => Some(2u32),
(Self::Battery, Betaflight4_3 | Betaflight4_4) => Some(3u32),
(Self::Mag, Betaflight4_3 | Betaflight4_4) => Some(4u32),
(Self::Altitude, Betaflight4_3 | Betaflight4_4) => Some(5u32),
(Self::Rssi, Betaflight4_3 | Betaflight4_4) => Some(6u32),
(Self::Gyro, Betaflight4_3 | Betaflight4_4) => Some(7u32),
(Self::Acc, Betaflight4_3 | Betaflight4_4) => Some(8u32),
(Self::DebugLog, Betaflight4_3 | Betaflight4_4) => Some(9u32),
(Self::Motor, Betaflight4_3 | Betaflight4_4) => Some(10u32),
(Self::Gps, Betaflight4_3 | Betaflight4_4) => Some(11u32),
(Self::Pid, Betaflight4_3 | Betaflight4_4 | Betaflight4_5) => Some(0u32),
(Self::RcCommands, Betaflight4_3 | Betaflight4_4 | Betaflight4_5) => Some(1u32),
(Self::Setpoint, Betaflight4_3 | Betaflight4_4 | Betaflight4_5) => Some(2u32),
(Self::Battery, Betaflight4_3 | Betaflight4_4 | Betaflight4_5) => Some(3u32),
(Self::Mag, Betaflight4_3 | Betaflight4_4 | Betaflight4_5) => Some(4u32),
(Self::Altitude, Betaflight4_3 | Betaflight4_4 | Betaflight4_5) => Some(5u32),
(Self::Rssi, Betaflight4_3 | Betaflight4_4 | Betaflight4_5) => Some(6u32),
(Self::Gyro, Betaflight4_3 | Betaflight4_4 | Betaflight4_5) => Some(7u32),
(Self::Acc, Betaflight4_3 | Betaflight4_4 | Betaflight4_5) => Some(8u32),
(Self::DebugLog, Betaflight4_3 | Betaflight4_4 | Betaflight4_5) => Some(9u32),
(Self::Motor, Betaflight4_3 | Betaflight4_4 | Betaflight4_5) => Some(10u32),
(Self::Gps, Betaflight4_3 | Betaflight4_4 | Betaflight4_5) => Some(11u32),
(Self::Rpm, Betaflight4_5) => Some(12u32),
(Self::GyroUnfiltered, Betaflight4_5) => Some(13u32),
_ => None,
}
}
Expand Down
32 changes: 21 additions & 11 deletions src/generated/failsafe_phase.rs
Expand Up @@ -57,21 +57,31 @@ impl FailsafePhase {
pub(crate) fn new(raw: u32, fw: crate::headers::InternalFirmware) -> Self {
use crate::headers::InternalFirmware::*;
match (raw, fw) {
(0u32, Betaflight4_2 | Betaflight4_3 | Betaflight4_4 | Inav5 | Inav6 | Inav7) => {
Self::Idle
}
(1u32, Betaflight4_2 | Betaflight4_3 | Betaflight4_4 | Inav5 | Inav6 | Inav7) => {
Self::RxLossDetected
}
(2u32, Betaflight4_2 | Betaflight4_3 | Betaflight4_4) => Self::Landing,
(
0u32,
Betaflight4_2 | Betaflight4_3 | Betaflight4_4 | Betaflight4_5 | Inav5 | Inav6
| Inav7,
) => Self::Idle,
(
1u32,
Betaflight4_2 | Betaflight4_3 | Betaflight4_4 | Betaflight4_5 | Inav5 | Inav6
| Inav7,
) => Self::RxLossDetected,
(2u32, Betaflight4_2 | Betaflight4_3 | Betaflight4_4 | Betaflight4_5) => Self::Landing,
(2u32, Inav5 | Inav6 | Inav7) => Self::RxLossIdle,
(3u32, Betaflight4_2 | Betaflight4_3 | Betaflight4_4) => Self::Landed,
(3u32, Betaflight4_2 | Betaflight4_3 | Betaflight4_4 | Betaflight4_5) => Self::Landed,
(3u32, Inav5 | Inav6 | Inav7) => Self::ReturnToHome,
(4u32, Betaflight4_2 | Betaflight4_3 | Betaflight4_4) => Self::RxLossMonitoring,
(4u32, Betaflight4_2 | Betaflight4_3 | Betaflight4_4 | Betaflight4_5) => {
Self::RxLossMonitoring
}
(4u32, Inav5 | Inav6 | Inav7) => Self::Landing,
(5u32, Betaflight4_2 | Betaflight4_3 | Betaflight4_4) => Self::RxLossRecovered,
(5u32, Betaflight4_2 | Betaflight4_3 | Betaflight4_4 | Betaflight4_5) => {
Self::RxLossRecovered
}
(5u32, Inav5 | Inav6 | Inav7) => Self::Landed,
(6u32, Betaflight4_2 | Betaflight4_3 | Betaflight4_4) => Self::GpsRescue,
(6u32, Betaflight4_2 | Betaflight4_3 | Betaflight4_4 | Betaflight4_5) => {
Self::GpsRescue
}
(6u32, Inav5 | Inav6 | Inav7) => Self::RxLossMonitoring,
(7u32, Inav5 | Inav6 | Inav7) => Self::RxLossRecovered,
_ => {
Expand Down

0 comments on commit 4b8f6b3

Please sign in to comment.