servicepoint-binding-uniffi/src/command_codes.rs

55 lines
1.3 KiB
Rust
Raw Normal View History

2024-05-10 18:33:51 +02:00
use num::{FromPrimitive, ToPrimitive};
use num_derive::{FromPrimitive, ToPrimitive};
#[repr(u16)]
2024-05-11 22:21:27 +02:00
#[derive(Debug, FromPrimitive, ToPrimitive, Copy, Clone)]
2024-05-10 19:55:18 +02:00
pub enum CommandCode {
2024-05-10 18:33:51 +02:00
Clear = 0x0002,
2024-05-10 19:55:18 +02:00
Cp437Data = 0x0003,
2024-05-10 18:33:51 +02:00
CharBrightness = 0x0005,
Brightness = 0x0007,
HardReset = 0x000b,
FadeOut = 0x000d,
2024-05-10 21:27:34 +02:00
#[deprecated]
2024-05-10 18:33:51 +02:00
BitmapLegacy = 0x0010,
BitmapLinear = 0x0012,
BitmapLinearWin = 0x0013,
BitmapLinearAnd = 0x0014,
BitmapLinearOr = 0x0015,
BitmapLinearXor = 0x0016,
}
2024-05-10 19:55:18 +02:00
impl CommandCode {
2024-05-10 18:33:51 +02:00
pub fn from_primitive(value: u16) -> Option<Self> {
FromPrimitive::from_u16(value)
}
pub fn to_primitive(&self) -> u16 {
ToPrimitive::to_u16(self).unwrap()
}
2024-05-11 21:14:20 +02:00
}
#[repr(u16)]
2024-05-11 22:21:27 +02:00
#[derive(Debug, FromPrimitive, ToPrimitive, Clone, Copy)]
2024-05-11 21:14:20 +02:00
pub enum CompressionCode {
None = 0x0,
2024-05-11 23:16:41 +02:00
#[cfg(feature = "compression-gz")]
2024-05-11 21:14:20 +02:00
Gz = 0x677a,
2024-05-11 23:16:41 +02:00
#[cfg(feature = "compression-bz")]
2024-05-11 21:14:20 +02:00
Bz = 0x627a,
2024-05-11 23:16:41 +02:00
#[cfg(feature = "compression-lz")]
2024-05-11 21:14:20 +02:00
Lz = 0x6c7a,
2024-05-11 23:16:41 +02:00
#[cfg(feature = "compression-zs")]
2024-05-11 21:14:20 +02:00
Zs = 0x7a73,
}
impl CompressionCode {
pub fn from_primitive(value: u16) -> Option<Self> {
FromPrimitive::from_u16(value)
}
pub fn to_primitive(&self) -> u16 {
ToPrimitive::to_u16(self).unwrap()
}
}