ridiculous refactor to allow enums to be dbus strings for better TS generation

This commit is contained in:
Luke D. Jones
2023-06-27 21:16:13 +12:00
parent fca7d23a31
commit 7b17a13ce7
43 changed files with 1516 additions and 267 deletions

View File

@@ -267,7 +267,11 @@ mod tests {
let mut config = AuraConfig::create_default(AuraDevice::X19b6, &LaptopLedData::default());
let effect = AuraEffect {
colour1: Colour(0xff, 0x00, 0xff),
colour1: Colour {
r: 0xff,
g: 0x00,
b: 0xff,
},
zone: AuraZone::Key1,
..Default::default()
};
@@ -276,21 +280,33 @@ mod tests {
assert!(config.multizone.is_some());
let effect = AuraEffect {
colour1: Colour(0x00, 0xff, 0xff),
colour1: Colour {
r: 0x00,
g: 0xff,
b: 0xff,
},
zone: AuraZone::Key2,
..Default::default()
};
config.set_builtin(effect);
let effect = AuraEffect {
colour1: Colour(0xff, 0xff, 0x00),
colour1: Colour {
r: 0xff,
g: 0xff,
b: 0x00,
},
zone: AuraZone::Key3,
..Default::default()
};
config.set_builtin(effect);
let effect = AuraEffect {
colour1: Colour(0x00, 0xff, 0x00),
colour1: Colour {
r: 0x00,
g: 0xff,
b: 0x00,
},
zone: AuraZone::Key4,
..Default::default()
};
@@ -302,10 +318,38 @@ mod tests {
let res = config.multizone.unwrap();
let sta = res.get(&AuraModeNum::Static).unwrap();
assert_eq!(sta.len(), 4);
assert_eq!(sta[0].colour1, Colour(0xff, 0x00, 0xff));
assert_eq!(sta[1].colour1, Colour(0x00, 0xff, 0xff));
assert_eq!(sta[2].colour1, Colour(0xff, 0xff, 0x00));
assert_eq!(sta[3].colour1, Colour(0x00, 0xff, 0x00));
assert_eq!(
sta[0].colour1,
Colour {
r: 0xff,
g: 0x00,
b: 0xff
}
);
assert_eq!(
sta[1].colour1,
Colour {
r: 0x00,
g: 0xff,
b: 0xff
}
);
assert_eq!(
sta[2].colour1,
Colour {
r: 0xff,
g: 0xff,
b: 0x00
}
);
assert_eq!(
sta[3].colour1,
Colour {
r: 0x00,
g: 0xff,
b: 0x00
}
);
}
#[test]

View File

@@ -49,7 +49,7 @@ impl GetSupported for CtrlKbdLed {
}
}
#[derive(Debug, PartialEq, Eq, PartialOrd)]
#[derive(Debug, PartialEq, Eq)]
pub enum LEDNode {
KbdLed(KeyboardLed),
Rog(HidRaw),
@@ -317,9 +317,9 @@ impl CtrlKbdLed {
let buf = [
1,
mode.mode as u8,
mode.colour1.0,
mode.colour1.1,
mode.colour1.2,
mode.colour1.r,
mode.colour1.g,
mode.colour1.b,
mode.speed as u8,
];
platform.set_kbd_rgb_mode(&buf)?;
@@ -435,7 +435,11 @@ mod tests {
};
let mut effect = AuraEffect {
colour1: Colour(0xff, 0x00, 0xff),
colour1: Colour {
r: 0xff,
g: 0x00,
b: 0xff,
},
zone: AuraZone::None,
..Default::default()
};

View File

@@ -55,33 +55,44 @@ impl CtrlKbdLedZbus {
///
/// ```text
/// pub struct AuraPowerDev {
/// pub x1866: Vec<AuraDev1866>,
/// pub x19b6: Vec<AuraDev19b6>,
/// tuf: Vec<AuraDevTuf>,
/// x1866: Vec<AuraDevRog1>,
/// x19b6: Vec<AuraDevRog2>,
/// }
/// pub enum AuraDev1866 {
/// Awake,
/// Keyboard,
/// Lightbar,
/// pub enum AuraDevTuf {
/// Boot,
/// Awake,
/// Sleep,
/// Keyboard,
/// }
/// enum AuraDev19b6 {
/// BootLogo,
/// BootKeyb,
/// AwakeLogo,
/// AwakeKeyb,
/// SleepLogo,
/// SleepKeyb,
/// ShutdownLogo,
/// ShutdownKeyb,
/// AwakeBar,
/// BootBar,
/// SleepBar,
/// ShutdownBar,
/// BootRearBar,
/// AwakeRearBar,
/// SleepRearBar,
/// ShutdownRearBar,
/// pub enum AuraDevRog1 {
/// Awake = 0x000002,
/// Keyboard = 0x080000,
/// Lightbar = 0x040500,
/// Boot = 0xc31209,
/// Sleep = 0x300804,
/// }
/// pub enum AuraDevRog2 {
/// BootLogo = 1,
/// BootKeyb = 1 << 1,
/// AwakeLogo = 1 << 2,
/// AwakeKeyb = 1 << 3,
/// SleepLogo = 1 << 4,
/// SleepKeyb = 1 << 5,
/// ShutdownLogo = 1 << 6,
/// ShutdownKeyb = 1 << 7,
/// BootBar = 1 << (7 + 2),
/// AwakeBar = 1 << (7 + 3),
/// SleepBar = 1 << (7 + 4),
/// ShutdownBar = 1 << (7 + 5),
/// BootLid = 1 << (15 + 1),
/// AwakeLid = 1 << (15 + 2),
/// SleepLid = 1 << (15 + 3),
/// ShutdownLid = 1 << (15 + 4),
/// BootRearGlow = 1 << (23 + 1),
/// AwakeRearGlow = 1 << (23 + 2),
/// SleepRearGlow = 1 << (23 + 3),
/// ShutdownRearGlow = 1 << (23 + 4),
/// }
/// ```
async fn set_leds_power(
@@ -260,7 +271,6 @@ impl CtrlTask for CtrlKbdLedZbus {
.map_err(|e| error!("CtrlKbdLedTask: {e}"))
.ok();
} else if start {
info!("CtrlKbdLedTask saving last brightness");
Self::update_config(&mut lock)
.map_err(|e| error!("CtrlKbdLedTask: {e}"))
.ok();