#![cfg(feature = "vtx")]
use {
sequential_storage::map::PostcardValue,
serde::{Deserialize, Serialize},
};
#[derive(Clone, Copy, Debug, PartialEq, Deserialize, Serialize)]
pub struct VtxConfig {
pub frequency_mhz: u16, pub pit_mode_frequency_mhz: u16, pub band: u8, pub channel: u8, pub power: u8, pub low_power_disarm: u8, pub softserial_alt: u8, }
impl VtxConfig {
pub const fn new() -> Self {
Self {
frequency_mhz: 5740,
pit_mode_frequency_mhz: 0,
band: 4,
channel: 1,
power: 1,
low_power_disarm: 1,
softserial_alt: 0,
}
}
}
impl PostcardValue<'_> for VtxConfig {}
impl Default for VtxConfig {
fn default() -> Self {
Self::new()
}
}
#[cfg(test)]
mod tests {
use super::*;
fn _is_normal<T: Sized + Send + Sync + Unpin>() {}
fn is_full<T: Sized + Send + Sync + Unpin + Copy + Clone + Default + PartialEq>() {}
fn is_config<T: Serialize + for<'a> Deserialize<'a> + for<'a> PostcardValue<'a>>() {}
#[test]
fn normal_types() {
is_full::<VtxConfig>();
is_config::<VtxConfig>();
}
#[test]
fn test_new() {
let config = VtxConfig::new();
assert_eq!(5740, config.frequency_mhz);
}
}