Add brightness to anime zbus notif

This commit is contained in:
Luke D. Jones
2022-06-06 18:24:08 +12:00
parent 5c0ad3e590
commit 74e1d5bdc4
2 changed files with 5 additions and 2 deletions

View File

@@ -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,
});

View File

@@ -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,
}