Add verbose output for fan-curve detection. Add mocking to GUI.

asusd: Verbose output of fan-curves on startup
ROGCC: Try to mock more of GUI state
This commit is contained in:
Luke D. Jones
2022-07-26 09:11:58 +12:00
parent 2584d69930
commit 38be25174a
18 changed files with 526 additions and 187 deletions

View File

@@ -33,13 +33,3 @@ dirs = "3.0.1"
version = "^4.3"
default-features = false
features = ["z"]
[profile.release]
lto = true
debug = false
opt-level = 3
panic = "abort"
[profile.bench]
debug = false
opt-level = 3

View File

@@ -8,10 +8,12 @@ use std::{
};
use egui::{Button, RichText};
use rog_dbus::RogDbusClientBlocking;
use rog_supported::SupportedFunctions;
use crate::{config::Config, get_ipc_file, page_states::PageDataStates, Page, SHOWING_GUI};
use crate::{
config::Config, error::Result, get_ipc_file, page_states::PageDataStates, Page,
RogDbusClientBlocking, SHOWING_GUI,
};
pub struct RogApp<'a> {
pub page: Page,
@@ -34,11 +36,11 @@ impl<'a> RogApp<'a> {
show_gui: Arc<AtomicBool>,
states: PageDataStates,
_cc: &eframe::CreationContext<'_>,
) -> Self {
let (dbus, _) = RogDbusClientBlocking::new().unwrap();
let supported = dbus.proxies().supported().supported_functions().unwrap();
) -> Result<Self> {
let (dbus, _) = RogDbusClientBlocking::new()?;
let supported = dbus.proxies().supported().supported_functions()?;
Self {
Ok(Self {
supported,
states,
page: Page::System,
@@ -46,7 +48,7 @@ impl<'a> RogApp<'a> {
running_in_bg: start_closed,
config,
asus_dbus: dbus,
}
})
}
}
@@ -70,9 +72,15 @@ impl<'a> eframe::App for RogApp<'a> {
states,
..
} = self;
if states.refresh_if_notfied(supported, dbus) {
ctx.request_repaint();
}
states
.refresh_if_notfied(supported, dbus)
.map(|repaint| {
if repaint {
ctx.request_repaint();
}
})
.map_err(|e| self.states.error = Some(e.to_string()))
.ok();
let page = self.page;

View File

@@ -1,5 +1,7 @@
use std::fmt;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug)]
pub enum Error {
Io(std::io::Error),
@@ -7,6 +9,7 @@ pub enum Error {
ConfigLoadFail,
ConfigLockFail,
XdgVars,
Zbus(zbus::Error),
}
impl fmt::Display for Error {
@@ -18,6 +21,7 @@ impl fmt::Display for Error {
Error::ConfigLoadFail => write!(f, "Failed to load user config"),
Error::ConfigLockFail => write!(f, "Failed to lock user config"),
Error::XdgVars => write!(f, "XDG environment vars appear unset"),
Error::Zbus(err) => write!(f, "Error: {}", err),
}
}
}
@@ -30,14 +34,14 @@ impl From<std::io::Error> for Error {
}
}
impl From<Error> for zbus::fdo::Error {
fn from(err: Error) -> Self {
zbus::fdo::Error::Failed(format!("Anime zbus error: {}", err))
}
}
impl From<nix::Error> for Error {
fn from(err: nix::Error) -> Self {
Error::Nix(err)
}
}
impl From<zbus::Error> for Error {
fn from(err: zbus::Error) -> Self {
Error::Zbus(err)
}
}

View File

@@ -11,10 +11,17 @@ pub use app::RogApp;
pub mod config;
pub mod error;
#[cfg(feature = "mocking")]
pub mod mocking;
pub mod notify;
pub mod page_states;
pub mod widgets;
#[cfg(feature = "mocking")]
pub use mocking::RogDbusClientBlocking;
#[cfg(not(feature = "mocking"))]
pub use rog_dbus::RogDbusClientBlocking;
use nix::{sys::stat, unistd};
use tempfile::TempDir;
//use log::{error, info, warn};

View File

@@ -1,8 +1,8 @@
use rog_control_center::{
config::Config, get_ipc_file, notify::start_notifications, on_tmp_dir_exists,
page_states::PageDataStates, RogApp, SHOW_GUI,
page_states::PageDataStates, RogApp, RogDbusClientBlocking, SHOW_GUI,
};
use rog_dbus::RogDbusClientBlocking;
use std::{
io::Read,
sync::{
@@ -23,8 +23,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
config.save()?;
}
let (dbus, _) = RogDbusClientBlocking::new().unwrap();
let supported = dbus.proxies().supported().supported_functions().unwrap();
// Cheap method to alert to notifications rather than spinning a thread for each
// This is quite different when done in a retained mode app
let charge_notified = Arc::new(AtomicBool::new(false));
@@ -34,19 +32,22 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let profiles_notified = Arc::new(AtomicBool::new(false));
let fans_notified = Arc::new(AtomicBool::new(false));
let notifs_enabled = Arc::new(AtomicBool::new(config.enable_notifications));
// TODO: change this to an error instead of the nested unwraps, then use to
// display a bare box app with error message.
let states = PageDataStates::new(
notifs_enabled.clone(),
charge_notified.clone(),
bios_notified.clone(),
aura_notified.clone(),
anime_notified.clone(),
profiles_notified.clone(),
fans_notified.clone(),
&supported,
&dbus,
);
let states = {
let (dbus, _) = RogDbusClientBlocking::new()?;
let supported = dbus.proxies().supported().supported_functions().unwrap();
PageDataStates::new(
notifs_enabled.clone(),
charge_notified.clone(),
bios_notified.clone(),
aura_notified.clone(),
anime_notified.clone(),
profiles_notified.clone(),
fans_notified.clone(),
&supported,
&dbus,
)? // TODO: if error, show alt GUI containing the error message
};
if config.enable_notifications {
start_notifications(
@@ -92,6 +93,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
eframe::run_native(
"ROG Control Center",
native_options,
Box::new(move |cc| Box::new(RogApp::new(start_closed, config, should, states, cc))),
Box::new(move |cc| {
Box::new(RogApp::new(start_closed, config, should, states, cc).unwrap())
}),
);
}

View File

@@ -0,0 +1,225 @@
use std::collections::BTreeMap;
use rog_aura::{
usb::{AuraDev19b6, AuraDevice, AuraPowerDev},
AuraEffect, AuraModeNum, AuraZone,
};
use rog_profiles::fan_curve_set::{CurveData, FanCurveSet};
use rog_supported::{
AnimeSupportedFunctions, ChargeSupportedFunctions, LedSupportedFunctions,
PlatformProfileFunctions, RogBiosSupportedFunctions, SupportedFunctions,
};
use crate::error::Result;
const NOPE: &'static str = "";
pub struct RogDbusClientBlocking<'a> {
_phantom: &'a str,
}
impl<'a> Default for RogDbusClientBlocking<'a> {
fn default() -> Self {
Self {
_phantom: Default::default(),
}
}
}
impl<'a> RogDbusClientBlocking<'a> {
pub fn new() -> Result<(Self, bool)> {
Ok((Self { _phantom: NOPE }, true))
}
pub fn proxies(&self) -> Proxies {
Proxies
}
}
pub struct Proxies;
impl Proxies {
pub fn rog_bios(&self) -> Bios {
Bios
}
pub fn profile(&self) -> Profile {
Profile
}
pub fn led(&self) -> Led {
Led
}
pub fn anime(&self) -> Anime {
Anime
}
pub fn charge(&self) -> Profile {
Profile
}
pub fn supported(&self) -> Supported {
Supported
}
}
pub struct Bios;
impl Bios {
pub fn post_boot_sound(&self) -> Result<i16> {
Ok(1)
}
pub fn dedicated_graphic_mode(&self) -> Result<i16> {
Ok(1)
}
pub fn panel_overdrive(&self) -> Result<i16> {
Ok(1)
}
pub fn set_post_boot_sound(&self, _b: bool) -> Result<()> {
Ok(())
}
pub fn set_dedicated_graphic_mode(&self, _b: bool) -> Result<()> {
Ok(())
}
pub fn set_panel_overdrive(&self, _b: bool) -> Result<()> {
Ok(())
}
}
pub struct Profile;
impl Profile {
pub fn profiles(&self) -> Result<Vec<rog_profiles::Profile>> {
Ok(vec![
rog_profiles::Profile::Balanced,
rog_profiles::Profile::Performance,
rog_profiles::Profile::Quiet,
])
}
pub fn active_profile(&self) -> Result<rog_profiles::Profile> {
Ok(rog_profiles::Profile::Performance)
}
pub fn enabled_fan_profiles(&self) -> Result<Vec<rog_profiles::Profile>> {
Ok(vec![
rog_profiles::Profile::Performance,
rog_profiles::Profile::Balanced,
])
}
pub fn fan_curve_data(&self, _p: rog_profiles::Profile) -> Result<FanCurveSet> {
let mut curve = FanCurveSet::default();
curve.cpu.pwm = [30, 40, 60, 100, 140, 180, 200, 250];
curve.cpu.temp = [20, 30, 40, 50, 70, 80, 90, 100];
curve.gpu.pwm = [40, 80, 100, 140, 170, 200, 230, 250];
curve.gpu.temp = [20, 30, 40, 50, 70, 80, 90, 100];
Ok(curve)
}
pub fn set_fan_curve(&self, _p: rog_profiles::Profile, _c: CurveData) -> Result<()> {
Ok(())
}
pub fn set_fan_curve_enabled(&self, _p: rog_profiles::Profile, _b: bool) -> Result<()> {
Ok(())
}
pub fn limit(&self) -> Result<i16> {
Ok(66)
}
pub fn set_limit(&self, _l: u8) -> Result<()> {
Ok(())
}
pub fn set_active_profile(&self, _p: rog_profiles::Profile) -> Result<()> {
Ok(())
}
}
pub struct Led;
impl Led {
pub fn led_modes(&self) -> Result<BTreeMap<AuraModeNum, AuraEffect>> {
let mut data = BTreeMap::new();
data.insert(AuraModeNum::Static, AuraEffect::default());
data.insert(AuraModeNum::Star, AuraEffect::default());
data.insert(AuraModeNum::Strobe, AuraEffect::default());
data.insert(AuraModeNum::Rain, AuraEffect::default());
data.insert(AuraModeNum::Rainbow, AuraEffect::default());
data.insert(AuraModeNum::Ripple, AuraEffect::default());
data.insert(AuraModeNum::Breathe, AuraEffect::default());
data.insert(AuraModeNum::Comet, AuraEffect::default());
data.insert(AuraModeNum::Flash, AuraEffect::default());
data.insert(AuraModeNum::Laser, AuraEffect::default());
data.insert(AuraModeNum::Pulse, AuraEffect::default());
Ok(data)
}
pub fn led_mode(&self) -> Result<AuraModeNum> {
Ok(AuraModeNum::Rainbow)
}
pub fn led_brightness(&self) -> Result<i16> {
Ok(1)
}
pub fn leds_enabled(&self) -> Result<AuraPowerDev> {
Ok(AuraPowerDev {
x1866: vec![],
x19b6: vec![
AuraDev19b6::BootKeyb,
AuraDev19b6::AwakeKeyb,
AuraDev19b6::SleepLogo,
AuraDev19b6::AwakeLogo,
],
})
}
pub fn set_leds_power(&self, _a: AuraPowerDev, _b: bool) -> Result<()> {
Ok(())
}
pub fn set_led_mode(&self, _a: &AuraEffect) -> Result<()> {
Ok(())
}
}
pub struct Anime;
impl Anime {
pub fn boot_enabled(&self) -> Result<bool> {
Ok(true)
}
pub fn awake_enabled(&self) -> Result<bool> {
Ok(true)
}
pub fn set_on_off(&self, _b: bool) -> Result<()> {
Ok(())
}
pub fn set_boot_on_off(&self, _b: bool) -> Result<()> {
Ok(())
}
}
pub struct Supported;
impl Supported {
pub fn supported_functions(&self) -> Result<SupportedFunctions> {
Ok(SupportedFunctions {
anime_ctrl: AnimeSupportedFunctions(true),
charge_ctrl: ChargeSupportedFunctions {
charge_level_set: true,
},
platform_profile: PlatformProfileFunctions {
platform_profile: true,
fan_curves: true,
},
keyboard_led: LedSupportedFunctions {
prod_id: AuraDevice::X19B6,
brightness_set: true,
stock_led_modes: vec![
AuraModeNum::Rain,
AuraModeNum::Rainbow,
AuraModeNum::Star,
AuraModeNum::Static,
AuraModeNum::Strobe,
],
multizone_led_mode: vec![
AuraZone::Key1,
AuraZone::Key2,
AuraZone::Key3,
AuraZone::Key4,
AuraZone::BarLeft,
AuraZone::BarRight,
AuraZone::Logo,
],
per_key_led_mode: true,
},
rog_bios_ctrl: RogBiosSupportedFunctions {
post_sound: true,
dedicated_gfx: true,
panel_overdrive: true,
dgpu_disable: true,
egpu_enable: true,
},
})
}
}

View File

@@ -8,10 +8,11 @@ use std::{
use egui::Vec2;
use rog_aura::{usb::AuraPowerDev, AuraEffect, AuraModeNum};
use rog_dbus::RogDbusClientBlocking;
use rog_profiles::{fan_curve_set::FanCurveSet, FanCurvePU, Profile};
use rog_supported::SupportedFunctions;
use crate::{error::Result, RogDbusClientBlocking};
#[derive(Clone, Debug)]
pub struct BiosState {
/// To be shared to a thread that checks notifications.
@@ -30,28 +31,28 @@ impl BiosState {
was_notified: Arc<AtomicBool>,
supported: &SupportedFunctions,
dbus: &RogDbusClientBlocking,
) -> Self {
Self {
) -> Result<Self> {
Ok(Self {
was_notified,
post_sound: if supported.rog_bios_ctrl.post_sound {
dbus.proxies().rog_bios().post_boot_sound().unwrap() != 0
dbus.proxies().rog_bios().post_boot_sound()? != 0
} else {
false
},
dedicated_gfx: if supported.rog_bios_ctrl.dedicated_gfx {
dbus.proxies().rog_bios().dedicated_graphic_mode().unwrap() != 0
dbus.proxies().rog_bios().dedicated_graphic_mode()? != 0
} else {
false
},
panel_overdrive: if supported.rog_bios_ctrl.panel_overdrive {
dbus.proxies().rog_bios().panel_overdrive().unwrap() != 0
dbus.proxies().rog_bios().panel_overdrive()? != 0
} else {
false
},
// TODO: needs supergfx
dgpu_disable: supported.rog_bios_ctrl.dgpu_disable,
egpu_enable: supported.rog_bios_ctrl.egpu_enable,
}
})
}
}
@@ -67,20 +68,20 @@ impl ProfilesState {
was_notified: Arc<AtomicBool>,
supported: &SupportedFunctions,
dbus: &RogDbusClientBlocking,
) -> Self {
Self {
) -> Result<Self> {
Ok(Self {
was_notified,
list: if supported.platform_profile.platform_profile {
dbus.proxies().profile().profiles().unwrap()
dbus.proxies().profile().profiles()?
} else {
vec![]
},
current: if supported.platform_profile.platform_profile {
dbus.proxies().profile().active_profile().unwrap()
dbus.proxies().profile().active_profile()?
} else {
Profile::Balanced
},
}
})
}
}
@@ -99,9 +100,9 @@ impl FanCurvesState {
was_notified: Arc<AtomicBool>,
supported: &SupportedFunctions,
dbus: &RogDbusClientBlocking,
) -> Self {
) -> Result<Self> {
let profiles = if supported.platform_profile.platform_profile {
dbus.proxies().profile().profiles().unwrap()
dbus.proxies().profile().profiles()?
} else {
vec![Profile::Balanced, Profile::Quiet, Profile::Performance]
};
@@ -109,8 +110,7 @@ impl FanCurvesState {
HashSet::from_iter(
dbus.proxies()
.profile()
.enabled_fan_profiles()
.unwrap()
.enabled_fan_profiles()?
.iter()
.cloned(),
)
@@ -121,8 +121,9 @@ impl FanCurvesState {
let mut curves: HashMap<Profile, FanCurveSet> = HashMap::new();
profiles.iter().for_each(|p| {
if supported.platform_profile.fan_curves {
let curve = dbus.proxies().profile().fan_curve_data(*p).unwrap();
curves.insert(*p, curve);
if let Ok(curve) = dbus.proxies().profile().fan_curve_data(*p) {
curves.insert(*p, curve);
}
} else {
let mut curve = FanCurveSet::default();
curve.cpu.pwm = [30, 40, 60, 100, 140, 180, 200, 250];
@@ -134,19 +135,19 @@ impl FanCurvesState {
});
let show_curve = if supported.platform_profile.fan_curves {
dbus.proxies().profile().active_profile().unwrap()
dbus.proxies().profile().active_profile()?
} else {
Profile::Balanced
};
Self {
Ok(Self {
was_notified,
show_curve,
show_graph: FanCurvePU::CPU,
enabled,
curves,
drag_delta: Vec2::default(),
}
})
}
}
@@ -165,27 +166,27 @@ impl AuraState {
was_notified: Arc<AtomicBool>,
supported: &SupportedFunctions,
dbus: &RogDbusClientBlocking,
) -> Self {
Self {
) -> Result<Self> {
Ok(Self {
was_notified,
current_mode: if !supported.keyboard_led.stock_led_modes.is_empty() {
dbus.proxies().led().led_mode().unwrap()
dbus.proxies().led().led_mode()?
} else {
AuraModeNum::Static
},
modes: if !supported.keyboard_led.stock_led_modes.is_empty() {
dbus.proxies().led().led_modes().unwrap()
dbus.proxies().led().led_modes()?
} else {
BTreeMap::new()
},
enabled: dbus.proxies().led().leds_enabled().unwrap(),
enabled: dbus.proxies().led().leds_enabled()?,
bright: if !supported.keyboard_led.brightness_set {
dbus.proxies().led().led_brightness().unwrap()
dbus.proxies().led().led_brightness()?
} else {
2
},
}
})
}
}
@@ -203,23 +204,23 @@ impl AnimeState {
was_notified: Arc<AtomicBool>,
supported: &SupportedFunctions,
dbus: &RogDbusClientBlocking,
) -> Self {
Self {
) -> Result<Self> {
Ok(Self {
was_notified,
boot: if supported.anime_ctrl.0 {
dbus.proxies().anime().boot_enabled().unwrap()
dbus.proxies().anime().boot_enabled()?
} else {
false
},
awake: if supported.anime_ctrl.0 {
dbus.proxies().anime().awake_enabled().unwrap()
dbus.proxies().anime().awake_enabled()?
} else {
false
},
// TODO:
sleep: false,
bright: 200,
}
})
}
}
@@ -249,56 +250,106 @@ impl PageDataStates {
fans_notified: Arc<AtomicBool>,
supported: &SupportedFunctions,
dbus: &RogDbusClientBlocking,
) -> Self {
Self {
) -> Result<Self> {
Ok(Self {
notifs_enabled,
was_notified: charge_notified,
charge_limit: dbus.proxies().charge().limit().unwrap(),
bios: BiosState::new(bios_notified, supported, dbus),
aura: AuraState::new(aura_notified, supported, dbus),
anime: AnimeState::new(anime_notified, supported, dbus),
profiles: ProfilesState::new(profiles_notified, supported, dbus),
fan_curves: FanCurvesState::new(fans_notified, supported, dbus),
charge_limit: dbus.proxies().charge().limit()?,
bios: BiosState::new(bios_notified, supported, dbus)?,
aura: AuraState::new(aura_notified, supported, dbus)?,
anime: AnimeState::new(anime_notified, supported, dbus)?,
profiles: ProfilesState::new(profiles_notified, supported, dbus)?,
fan_curves: FanCurvesState::new(fans_notified, supported, dbus)?,
error: None,
}
})
}
pub fn refresh_if_notfied(
&mut self,
supported: &SupportedFunctions,
dbus: &RogDbusClientBlocking,
) -> bool {
) -> Result<bool> {
let mut notified = false;
if self.was_notified.load(Ordering::SeqCst) {
self.charge_limit = dbus.proxies().charge().limit().unwrap();
self.charge_limit = dbus.proxies().charge().limit()?;
self.was_notified.store(false, Ordering::SeqCst);
notified = true;
}
if self.aura.was_notified.load(Ordering::SeqCst) {
self.aura = AuraState::new(self.aura.was_notified.clone(), supported, dbus);
self.aura = AuraState::new(self.aura.was_notified.clone(), supported, dbus)?;
self.aura.was_notified.store(false, Ordering::SeqCst);
notified = true;
}
if self.bios.was_notified.load(Ordering::SeqCst) {
self.bios = BiosState::new(self.bios.was_notified.clone(), supported, dbus);
self.bios = BiosState::new(self.bios.was_notified.clone(), supported, dbus)?;
self.bios.was_notified.store(false, Ordering::SeqCst);
notified = true;
}
if self.profiles.was_notified.load(Ordering::SeqCst) {
self.profiles = ProfilesState::new(self.profiles.was_notified.clone(), supported, dbus);
self.profiles =
ProfilesState::new(self.profiles.was_notified.clone(), supported, dbus)?;
self.profiles.was_notified.store(false, Ordering::SeqCst);
notified = true;
}
if self.fan_curves.was_notified.load(Ordering::SeqCst) {
self.fan_curves =
FanCurvesState::new(self.fan_curves.was_notified.clone(), supported, dbus);
FanCurvesState::new(self.fan_curves.was_notified.clone(), supported, dbus)?;
self.fan_curves.was_notified.store(false, Ordering::SeqCst);
notified = true;
}
notified
Ok(notified)
}
}
impl Default for PageDataStates {
fn default() -> Self {
Self {
notifs_enabled: Default::default(),
was_notified: Default::default(),
bios: BiosState {
was_notified: Default::default(),
post_sound: Default::default(),
dedicated_gfx: Default::default(),
panel_overdrive: Default::default(),
dgpu_disable: Default::default(),
egpu_enable: Default::default(),
},
aura: AuraState {
was_notified: Default::default(),
current_mode: AuraModeNum::Static,
modes: Default::default(),
enabled: AuraPowerDev {
x1866: vec![],
x19b6: vec![],
},
bright: Default::default(),
},
anime: AnimeState {
was_notified: Default::default(),
bright: Default::default(),
boot: Default::default(),
awake: Default::default(),
sleep: Default::default(),
},
profiles: ProfilesState {
was_notified: Default::default(),
list: Default::default(),
current: Default::default(),
},
fan_curves: FanCurvesState {
was_notified: Default::default(),
show_curve: Default::default(),
show_graph: Default::default(),
enabled: Default::default(),
curves: Default::default(),
drag_delta: Default::default(),
},
charge_limit: Default::default(),
error: Default::default(),
}
}
}

View File

@@ -3,12 +3,11 @@ use rog_aura::{
usb::{AuraDev1866, AuraDev19b6, AuraDevice, AuraPowerDev},
AuraModeNum, AuraZone, Colour, Speed,
};
use rog_dbus::RogDbusClientBlocking;
use rog_supported::SupportedFunctions;
use crate::{
page_states::{AuraState, PageDataStates},
RogApp,
RogApp, RogDbusClientBlocking,
};
impl<'a> RogApp<'a> {
@@ -442,7 +441,10 @@ impl<'a> RogApp<'a> {
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
if ui.add(egui::Button::new("Cancel")).clicked() {
let notif = states.aura.was_notified.clone();
states.aura.modes = AuraState::new(notif, supported, dbus).modes;
match AuraState::new(notif, supported, dbus) {
Ok(a) => states.aura.modes = a.modes,
Err(e) => states.error = Some(e.to_string()),
}
}
if ui.add(egui::Button::new("Apply")).clicked() {

View File

@@ -1,9 +1,8 @@
use crate::{
page_states::{FanCurvesState, ProfilesState},
RogApp,
RogApp, RogDbusClientBlocking,
};
use egui::{plot::Points, Ui};
use rog_dbus::RogDbusClientBlocking;
use rog_profiles::{FanCurvePU, Profile};
use rog_supported::SupportedFunctions;
@@ -44,7 +43,7 @@ impl<'a> RogApp<'a> {
let mut changed = false;
ui.horizontal(|ui| {
let mut item = |p: Profile, _curves: &mut FanCurvesState, mut checked: bool| {
let mut item = |p: Profile, curves: &mut FanCurvesState, mut checked: bool| {
if ui
.add(egui::Checkbox::new(&mut checked, format!("{:?}", p)))
.changed()
@@ -57,11 +56,10 @@ impl<'a> RogApp<'a> {
})
.ok();
#[cfg(feature = "mocking")]
if !checked {
_curves.enabled.remove(&p);
curves.enabled.remove(&p);
} else {
_curves.enabled.insert(p);
curves.enabled.insert(p);
}
changed = true;
}
@@ -73,11 +71,10 @@ impl<'a> RogApp<'a> {
});
if changed {
// Need to update app data if change made
#[cfg(not(feature = "mocking"))]
{
let notif = curves.was_notified.clone();
*curves = FanCurvesState::new(notif, supported, dbus);
let notif = curves.was_notified.clone();
match FanCurvesState::new(notif, supported, dbus) {
Ok(f) => *curves = f,
Err(e) => *do_error = Some(e.to_string()),
}
}
}
@@ -132,13 +129,13 @@ impl<'a> RogApp<'a> {
let points = Points::new(PlotPoints::from_iter(points)).radius(3.0);
Plot::new("my_plot")
.view_aspect(2.0)
.view_aspect(1.666)
// .center_x_axis(true)
// .center_y_axis(true)
.include_x(0.0)
.include_x(110.0)
.include_x(104.0)
.include_y(0.0)
.include_y(110.0)
.include_y(106.0)
.allow_scroll(false)
.allow_drag(false)
.allow_boxed_zoom(false)
@@ -183,7 +180,6 @@ impl<'a> RogApp<'a> {
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
if ui.add(egui::Button::new("Apply Fan-curve")).clicked() {
#[cfg(not(feature = "mocking"))]
dbus.proxies()
.profile()
.set_fan_curve(profiles.current, data.clone())
@@ -191,8 +187,6 @@ impl<'a> RogApp<'a> {
*do_error = Some(err.to_string());
})
.ok();
#[cfg(feature = "mocking")]
dbg!("Applied");
}
});
}

View File

@@ -18,7 +18,7 @@ impl<'a> RogApp<'a> {
*page = Page::System;
}
if self.supported.platform_profile.fan_curves || cfg!(feature = "mocking") {
if self.supported.platform_profile.fan_curves {
ui.separator();
if ui
.selectable_value(page, Page::FanCurves, "Fan Curves")
@@ -28,9 +28,7 @@ impl<'a> RogApp<'a> {
}
}
if !self.supported.keyboard_led.stock_led_modes.is_empty()
|| cfg!(feature = "mocking")
{
if !self.supported.keyboard_led.stock_led_modes.is_empty() {
ui.separator();
if ui
.selectable_value(page, Page::AuraEffects, "Keyboard Aura")
@@ -40,7 +38,7 @@ impl<'a> RogApp<'a> {
}
}
if self.supported.anime_ctrl.0 || cfg!(feature = "mocking") {
if self.supported.anime_ctrl.0 {
ui.separator();
if ui
.selectable_value(page, Page::AnimeMatrix, "AniMe Matrix")

View File

@@ -1,6 +1,5 @@
use crate::{page_states::PageDataStates, RogApp};
use crate::{page_states::PageDataStates, RogApp, RogDbusClientBlocking};
use egui::Ui;
use rog_dbus::RogDbusClientBlocking;
use rog_profiles::Profile;
impl<'a> RogApp<'a> {