2024-05-10 18:33:51 +02:00
|
|
|
use num::{FromPrimitive, ToPrimitive};
|
|
|
|
use num_derive::{FromPrimitive, ToPrimitive};
|
|
|
|
|
|
|
|
#[repr(u16)]
|
|
|
|
#[derive(Debug, FromPrimitive, ToPrimitive)]
|
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()
|
|
|
|
}
|
|
|
|
}
|