From 71ec13fa9fef2dfee77baa7cf4474de8ab092838 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Mon, 25 Jul 2022 21:21:32 +1200 Subject: [PATCH] ROGCC: Attempt to add LED brightness --- rog-control-center/src/notify.rs | 17 ++++++++++++- rog-control-center/src/page_states.rs | 7 ++++++ rog-control-center/src/widgets/aura_page.rs | 27 ++++++++++++++++++++- 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/rog-control-center/src/notify.rs b/rog-control-center/src/notify.rs index 29203908..e46a5898 100644 --- a/rog-control-center/src/notify.rs +++ b/rog-control-center/src/notify.rs @@ -169,11 +169,26 @@ pub fn start_notifications( }) .detach(); + let aura_notif = aura_notified.clone(); executor .spawn(async move { let conn = zbus::Connection::system().await.unwrap(); let proxy = LedProxy::new(&conn).await.unwrap(); - if let Ok(p) = proxy.receive_notify_power_states().await { + if let Ok(p) = proxy.receive_notify_led().await { + p.for_each(|_| { + aura_notif.store(true, Ordering::SeqCst); + future::ready(()) + }) + .await; + }; + }) + .detach(); + + executor + .spawn(async move { + let conn = zbus::Connection::system().await.unwrap(); + let proxy = LedProxy::new(&conn).await.unwrap(); + if let Ok(p) = proxy.receive_all_signals().await { p.for_each(|_| { aura_notified.store(true, Ordering::SeqCst); future::ready(()) diff --git a/rog-control-center/src/page_states.rs b/rog-control-center/src/page_states.rs index 74d4ec11..bc5c3fa8 100644 --- a/rog-control-center/src/page_states.rs +++ b/rog-control-center/src/page_states.rs @@ -156,6 +156,8 @@ pub struct AuraState { pub current_mode: AuraModeNum, pub modes: BTreeMap, pub enabled: AuraPowerDev, + /// Brightness from 0-3 + pub bright: i16, } impl AuraState { @@ -178,6 +180,11 @@ impl AuraState { BTreeMap::new() }, enabled: dbus.proxies().led().leds_enabled().unwrap(), + bright: if !supported.keyboard_led.brightness_set { + dbus.proxies().led().led_brightness().unwrap() + } else { + 2 + }, } } } diff --git a/rog-control-center/src/widgets/aura_page.rs b/rog-control-center/src/widgets/aura_page.rs index 90e85fc0..3d29f476 100644 --- a/rog-control-center/src/widgets/aura_page.rs +++ b/rog-control-center/src/widgets/aura_page.rs @@ -1,7 +1,7 @@ use egui::{RichText, Ui}; use rog_aura::{ usb::{AuraDev1866, AuraDev19b6, AuraDevice, AuraPowerDev}, - AuraModeNum, AuraZone, Colour, Speed, + AuraModeNum, AuraZone, Colour, LedBrightness, Speed, }; use rog_dbus::RogDbusClientBlocking; use rog_supported::SupportedFunctions; @@ -72,6 +72,11 @@ impl<'a> RogApp<'a> { ui.horizontal_wrapped(|ui| { ui.label(RichText::new("Sleep").size(h)); }); + // if supported.keyboard_led.brightness_set { + // ui.horizontal_wrapped(|ui| { + // ui.label(RichText::new("Brightness").size(h)); + // }); + // } }); ui.vertical(|ui| { ui.set_row_height(22.0); @@ -95,6 +100,26 @@ impl<'a> RogApp<'a> { changed = true; } }); + + // We currently don't have a watch for system changes here + // if supported.keyboard_led.brightness_set { + // if ui + // .add(egui::Slider::new( + // &mut states.aura.bright, + // 0..=3, + // )) + // .changed() + // { + // let bright = LedBrightness::from(states.aura.bright as u32); + // dbus.proxies() + // .led() + // .set_brightness(bright) + // .map_err(|err| { + // states.error = Some(err.to_string()); + // }) + // .ok(); + // } + // } }); });