From 74e1d5bdc4b8e2eba26f51a420321f3d718a17c7 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Mon, 6 Jun 2022 18:24:08 +1200 Subject: [PATCH] Add brightness to anime zbus notif --- daemon/src/ctrl_anime/zbus.rs | 6 ++++-- rog-anime/src/data.rs | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/daemon/src/ctrl_anime/zbus.rs b/daemon/src/ctrl_anime/zbus.rs index da8e2767..0778e37d 100644 --- a/daemon/src/ctrl_anime/zbus.rs +++ b/daemon/src/ctrl_anime/zbus.rs @@ -69,7 +69,7 @@ impl CtrlAnimeZbus { /// Set whether the AniMe is displaying images/data async fn set_on_off(&self, #[zbus(signal_context)] ctxt: SignalContext<'_>, status: bool) { - let mut states = None; + let states; 'outer: loop { if let Ok(mut lock) = self.0.try_lock() { lock.write_bytes(&pkt_for_set_on(status)); @@ -77,6 +77,7 @@ impl CtrlAnimeZbus { lock.config.write(); states = Some(AnimePowerStates { + brightness: lock.config.brightness.floor() as u8, enabled: lock.config.awake_enabled, boot_anim_enabled: lock.config.boot_anim_enabled, }); @@ -90,7 +91,7 @@ impl CtrlAnimeZbus { /// Set whether the AniMe will show boot, suspend, or off animations async fn set_boot_on_off(&self, #[zbus(signal_context)] ctxt: SignalContext<'_>, on: bool) { - let mut states = None; + let states; 'outer: loop { if let Ok(mut lock) = self.0.try_lock() { lock.write_bytes(&pkt_for_set_boot(on)); @@ -99,6 +100,7 @@ impl CtrlAnimeZbus { lock.config.write(); states = Some(AnimePowerStates { + brightness: lock.config.brightness.floor() as u8, enabled: lock.config.awake_enabled, boot_anim_enabled: lock.config.boot_anim_enabled, }); diff --git a/rog-anime/src/data.rs b/rog-anime/src/data.rs index 9c068d7d..1a68f4fe 100644 --- a/rog-anime/src/data.rs +++ b/rog-anime/src/data.rs @@ -28,6 +28,7 @@ const USB_PREFIX2: [u8; 7] = [0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02]; #[cfg_attr(feature = "dbus", derive(Type))] #[derive(Debug, PartialEq, Copy, Clone, Deserialize, Serialize)] pub struct AnimePowerStates { + pub brightness: u8, pub enabled: bool, pub boot_anim_enabled: bool, }