diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ac5f8ef..bf4f4699 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] + +### Added +- Support for G513RW LED modes + +### Changed +- rog-control-center: ensure brightness slider works correctly +- Update `smithay-client-toolkit` for fix to issue #407 + ## [v4.7.2] ### Added - Support for G733PZ LED modes diff --git a/rog-control-center/src/system_state.rs b/rog-control-center/src/system_state.rs index 99cb5efa..383695f8 100644 --- a/rog-control-center/src/system_state.rs +++ b/rog-control-center/src/system_state.rs @@ -5,8 +5,7 @@ use std::time::SystemTime; use egui::Vec2; use log::error; -use rog_anime::usb::Brightness; -use rog_anime::Animations; +use rog_anime::{Animations, DeviceState}; use rog_aura::layouts::KeyLayout; use rog_aura::usb::AuraPowerDev; use rog_aura::{AuraEffect, AuraModeNum}; @@ -193,7 +192,7 @@ impl AuraState { #[derive(Clone, Debug, Default)] pub struct AnimeState { pub display_enabled: bool, - pub display_brightness: Brightness, + pub display_brightness: u8, pub builtin_anims_enabled: bool, pub builtin_anims: Animations, } @@ -204,7 +203,7 @@ impl AnimeState { let device_state = dbus.proxies().anime().device_state()?; Ok(Self { display_enabled: device_state.display_enabled, - display_brightness: device_state.display_brightness, + display_brightness: device_state.display_brightness as u8, builtin_anims_enabled: device_state.builtin_anims_enabled, builtin_anims: device_state.builtin_anims, }) @@ -214,6 +213,17 @@ impl AnimeState { } } +impl From for AnimeState { + fn from(dev: DeviceState) -> Self { + Self { + display_enabled: dev.display_enabled, + display_brightness: dev.display_brightness as u8, + builtin_anims_enabled: dev.builtin_anims_enabled, + builtin_anims: dev.builtin_anims, + } + } +} + #[derive(Clone, Debug)] pub struct GfxState { pub has_supergfx: bool, diff --git a/rog-control-center/src/update_and_notify.rs b/rog-control-center/src/update_and_notify.rs index cfa0f6ed..ec136aec 100644 --- a/rog-control-center/src/update_and_notify.rs +++ b/rog-control-center/src/update_and_notify.rs @@ -23,7 +23,7 @@ use supergfxctl::actions::UserActionRequired as GfxUserAction; use supergfxctl::pci_device::{GfxMode, GfxPower}; use supergfxctl::zbus_proxy::DaemonProxy as SuperProxy; use tokio::time::sleep; -use zbus::export::futures_util::{future, StreamExt}; +use zbus::export::futures_util::StreamExt; use crate::config::Config; use crate::error::Result; @@ -314,15 +314,15 @@ pub fn start_notifications( e }) .unwrap(); - if let Ok(p) = proxy.receive_device_state().await { + if let Ok(mut p) = proxy.receive_device_state().await { info!("Started zbus signal thread: receive_device_state"); - p.for_each(|_| { - if let Ok(_lock) = page_states1.lock() { - // TODO: lock.anime. + while let Some(e) = p.next().await { + if let Ok(out) = e.args() { + if let Ok(mut lock) = page_states1.lock() { + lock.anime = out.data.into(); + } } - future::ready(()) - }) - .await; + } }; }); diff --git a/rog-control-center/src/widgets/anime_power.rs b/rog-control-center/src/widgets/anime_power.rs index 6f1b0f27..c414ed39 100644 --- a/rog-control-center/src/widgets/anime_power.rs +++ b/rog-control-center/src/widgets/anime_power.rs @@ -8,8 +8,6 @@ pub fn anime_power_group(_supported: &SupportedFunctions, states: &mut SystemSta ui.heading("AniMe Matrix Settings"); ui.label("Options are incomplete. Awake + Boot should work"); - let mut brightness = states.anime.display_brightness as u8; - ui.horizontal_wrapped(|ui| { ui.vertical(|ui| { let h = 16.0; @@ -30,12 +28,14 @@ pub fn anime_power_group(_supported: &SupportedFunctions, states: &mut SystemSta ui.vertical(|ui| { ui.set_row_height(22.0); ui.horizontal_wrapped(|ui| { - if ui.add(egui::Slider::new(&mut brightness, 0..=3)).changed() { + let slider = + egui::Slider::new(&mut states.anime.display_brightness, 0..=3).step_by(1.0); + if ui.add(slider).drag_released() { states .asus_dbus .proxies() .anime() - .set_brightness(Brightness::from(brightness)) + .set_brightness(Brightness::from(states.anime.display_brightness)) .map_err(|err| { states.error = Some(err.to_string()); }) diff --git a/rog-platform/src/lib.rs b/rog-platform/src/lib.rs index a214e8c6..354a8265 100644 --- a/rog-platform/src/lib.rs +++ b/rog-platform/src/lib.rs @@ -75,11 +75,14 @@ pub fn read_attr_u8_array(device: &Device, attr_name: &str) -> Result> { } pub fn write_attr_u8_array(device: &mut Device, attr: &str, values: &[u8]) -> Result<()> { - #[allow(clippy::format_collect)] - let tmp: String = values.iter().map(|v| format!("{} ", v)).collect(); - let tmp = tmp.trim(); + let mut tmp = String::new(); + for n in values { + tmp.push_str(&n.to_string()); + tmp.push(' '); // space padding required + } + tmp.pop(); device - .set_attribute_value(attr, tmp) + .set_attribute_value(attr, tmp.trim()) .map_err(|e| PlatformError::IoPath(attr.into(), e)) } @@ -103,9 +106,12 @@ mod tests { #[test] fn check() { let data = [1, 2, 3, 4, 5]; - #[allow(clippy::format_collect)] - let tmp: String = data.iter().map(|v| format!("{} ", v)).collect(); - let tmp = tmp.trim(); + let mut tmp = String::new(); + for n in data { + tmp.push_str(&n.to_string()); + tmp.push(' '); // space padding required + } + tmp.pop(); assert_eq!(tmp, "1 2 3 4 5"); let tmp: Vec = tmp