forked from NG-SD-Plugins/PowerTools
Fix clock speeds defaulting too low at wakeup when not set
This commit is contained in:
parent
ba021c8f93
commit
6878897784
8 changed files with 18 additions and 9 deletions
2
backend/Cargo.lock
generated
2
backend/Cargo.lock
generated
|
@ -567,7 +567,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "powertools-rs"
|
name = "powertools-rs"
|
||||||
version = "1.0.3"
|
version = "1.0.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"serde",
|
"serde",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "powertools-rs"
|
name = "powertools-rs"
|
||||||
version = "1.0.3"
|
version = "1.0.4"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
|
@ -4,12 +4,13 @@ use std::time::{Duration, Instant};
|
||||||
use crate::settings::{OnResume, Settings};
|
use crate::settings::{OnResume, Settings};
|
||||||
use crate::utility::unwrap_maybe_fatal;
|
use crate::utility::unwrap_maybe_fatal;
|
||||||
|
|
||||||
const ALLOWED_ERROR: f64 = 0.001;
|
const ALLOWED_ERROR: f64 = 100.0; // period of 10ms with 100x means sleep has to be >= 1s to be detected
|
||||||
|
|
||||||
pub fn spawn(settings: Settings) -> JoinHandle<()> {
|
pub fn spawn(settings: Settings) -> JoinHandle<()> {
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
log::info!("resume_worker starting...");
|
log::info!("resume_worker starting...");
|
||||||
let duration = Duration::from_millis(5000);
|
let duration = Duration::from_millis(10); // very low so it detects before Steam client does
|
||||||
|
// this allows PowerTools to set some values at wakeup and Steam to override them before user notices
|
||||||
let mut start = Instant::now();
|
let mut start = Instant::now();
|
||||||
loop {
|
loop {
|
||||||
let old_start = start.elapsed();
|
let old_start = start.elapsed();
|
||||||
|
|
|
@ -90,7 +90,7 @@ impl Cpu {
|
||||||
setting: super::SettingVariant::Cpu,
|
setting: super::SettingVariant::Cpu,
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
} else if self.state.clock_limits_set {
|
} else if self.state.clock_limits_set || self.state.is_resuming {
|
||||||
self.state.clock_limits_set = false;
|
self.state.clock_limits_set = false;
|
||||||
// disable manual clock limits
|
// disable manual clock limits
|
||||||
log::debug!("Setting CPU {} to default clockspeed", self.index);
|
log::debug!("Setting CPU {} to default clockspeed", self.index);
|
||||||
|
@ -209,7 +209,9 @@ impl OnSet for Cpu {
|
||||||
|
|
||||||
impl OnResume for Cpu {
|
impl OnResume for Cpu {
|
||||||
fn on_resume(&self) -> Result<(), SettingError> {
|
fn on_resume(&self) -> Result<(), SettingError> {
|
||||||
self.clone().set_all()
|
let mut copy = self.clone();
|
||||||
|
copy.state.is_resuming = true;
|
||||||
|
copy.set_all()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@ impl Gpu {
|
||||||
setting: super::SettingVariant::Gpu,
|
setting: super::SettingVariant::Gpu,
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
} else if self.state.clock_limits_set {
|
} else if self.state.clock_limits_set || self.state.is_resuming {
|
||||||
self.state.clock_limits_set = false;
|
self.state.clock_limits_set = false;
|
||||||
// disable manual clock limits
|
// disable manual clock limits
|
||||||
// max clock
|
// max clock
|
||||||
|
@ -206,7 +206,9 @@ impl OnSet for Gpu {
|
||||||
|
|
||||||
impl OnResume for Gpu {
|
impl OnResume for Gpu {
|
||||||
fn on_resume(&self) -> Result<(), SettingError> {
|
fn on_resume(&self) -> Result<(), SettingError> {
|
||||||
self.clone().set_all()
|
let mut copy = self.clone();
|
||||||
|
copy.state.is_resuming = true;
|
||||||
|
copy.set_all()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Cpu {
|
pub struct Cpu {
|
||||||
pub clock_limits_set: bool,
|
pub clock_limits_set: bool,
|
||||||
|
pub is_resuming: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::default::Default for Cpu {
|
impl std::default::Default for Cpu {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
clock_limits_set: false,
|
clock_limits_set: false,
|
||||||
|
is_resuming: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Gpu {
|
pub struct Gpu {
|
||||||
pub clock_limits_set: bool,
|
pub clock_limits_set: bool,
|
||||||
|
pub is_resuming: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::default::Default for Gpu {
|
impl std::default::Default for Gpu {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
clock_limits_set: false,
|
clock_limits_set: false,
|
||||||
|
is_resuming: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "PowerTools",
|
"name": "PowerTools",
|
||||||
"version": "1.0.3",
|
"version": "1.0.4",
|
||||||
"description": "Power tweaks for power users",
|
"description": "Power tweaks for power users",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "shx rm -rf dist && rollup -c",
|
"build": "shx rm -rf dist && rollup -c",
|
||||||
|
|
Loading…
Reference in a new issue