pub mod decoder;
pub mod encoder;
mod apple;
mod nec16;
mod raw;
mod samsung;
mod standard;
#[cfg(test)]
mod tests;
use core::marker::PhantomData;
pub use apple::AppleNecCommand;
pub use nec16::Nec16Command;
pub use raw::NecDebugCmd;
pub use samsung::SamsungNecCommand;
pub use standard::NecCommand;
use crate::protocol::Protocol;
pub struct Nec<C: NecCommandVariant = NecCommand> {
pub(crate) cmd: PhantomData<C>,
}
impl<C: NecCommandVariant> Protocol for Nec<C> {
type Cmd = C;
}
pub type SamsungNec = Nec<SamsungNecCommand>;
pub type Nec16 = Nec<Nec16Command>;
pub type AppleNec = Nec<AppleNecCommand>;
pub type NecDebug = Nec<NecDebugCmd>;
pub trait NecCommandVariant: Sized {
const PULSE_DISTANCE: &'static NecPulseLen;
fn validate(bits: u32) -> bool;
fn unpack(bits: u32, repeat: bool) -> Option<Self>;
fn pack(&self) -> u32;
}
const NEC_STANDARD_TIMING: &NecPulseLen = &NecPulseLen {
header_high: 9000,
header_low: 4500,
repeat_low: 2250,
data_high: 560,
data_zero_low: 560,
data_one_low: 1690,
};
const NEC_SAMSUNG_TIMING: &NecPulseLen = &NecPulseLen {
header_high: 4500,
header_low: 4500,
repeat_low: 2250,
data_zero_low: 560,
data_high: 560,
data_one_low: 1690,
};
#[derive(Copy, Clone)]
pub struct NecPulseLen {
header_high: u32,
header_low: u32,
repeat_low: u32,
data_high: u32,
data_zero_low: u32,
data_one_low: u32,
}