Fix GUI update
This commit is contained in:
parent
66e6fd4ac2
commit
7fcef34f84
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -118,7 +118,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "amdguid"
|
||||
version = "1.0.11"
|
||||
version = "1.0.12"
|
||||
dependencies = [
|
||||
"amdgpu",
|
||||
"amdgpu-config",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "amdguid"
|
||||
version = "1.0.11"
|
||||
version = "1.0.12"
|
||||
edition = "2018"
|
||||
description = "AMDGPU fan control service"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
@ -72,7 +72,10 @@ impl Default for Page {
|
||||
|
||||
pub type FanConfig = Arc<Mutex<amdgpu_config::fan::Config>>;
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
static RELOAD_PID_LIST_DELAY: u8 = 18;
|
||||
#[cfg(debug_assertions)]
|
||||
static RELOAD_PID_LIST_DELAY: u8 = 80;
|
||||
|
||||
pub struct StatefulConfig {
|
||||
pub config: FanConfig,
|
||||
|
@ -11,11 +11,15 @@ use crate::{widgets, widgets::ConfigFile};
|
||||
pub struct ChangeFanSettings {
|
||||
config: FanConfig,
|
||||
selected: Option<usize>,
|
||||
matrix: Vec<MatrixPoint>,
|
||||
}
|
||||
|
||||
impl ChangeFanSettings {
|
||||
pub fn new(config: FanConfig) -> Self {
|
||||
let matrix = config.lock().speed_matrix().to_vec();
|
||||
|
||||
Self {
|
||||
matrix,
|
||||
config,
|
||||
selected: None,
|
||||
}
|
||||
@ -63,10 +67,12 @@ impl ChangeFanSettings {
|
||||
.allow_drag(true)
|
||||
.allow_zoom(false)
|
||||
.line(curve)
|
||||
.y_axis_name(String::from("Speed"))
|
||||
.x_axis_name(String::from("Temperature"))
|
||||
.hline(crate::items::HLine::new(100.0).color(Color32::TRANSPARENT))
|
||||
.vline(crate::items::VLine::new(100.0).color(Color32::TRANSPARENT))
|
||||
.y_axis_name("Speed")
|
||||
.x_axis_name("Temperature")
|
||||
.hline(crate::items::HLine::new(0.0).color(Color32::BLACK))
|
||||
.hline(crate::items::HLine::new(100.0).color(Color32::BLACK))
|
||||
.vline(crate::items::VLine::new(0.0).color(Color32::BLACK))
|
||||
.vline(crate::items::VLine::new(100.0).color(Color32::BLACK))
|
||||
.on_event(|msg| match msg {
|
||||
PlotMsg::Clicked(idx) => {
|
||||
self.selected = Some(idx);
|
||||
@ -83,6 +89,12 @@ impl ChangeFanSettings {
|
||||
.and_then(|i| config.speed_matrix().get(i).copied())
|
||||
.unwrap_or(MatrixPoint::MAX);
|
||||
let current = config.speed_matrix_mut().get_mut(idx);
|
||||
if let Some((cache, current)) =
|
||||
self.matrix.get_mut(idx).zip(current.as_deref())
|
||||
{
|
||||
cache.speed = current.speed;
|
||||
cache.temp = current.temp;
|
||||
}
|
||||
|
||||
if let Some(point) = current {
|
||||
point.speed = (point.speed + delta.y as f64)
|
||||
@ -111,7 +123,7 @@ impl ChangeFanSettings {
|
||||
Layout::left_to_right(),
|
||||
)
|
||||
.vertical(|ui| {
|
||||
ui.add(ConfigFile::new(self.config.clone()));
|
||||
ui.add(ConfigFile::new(self.config.clone(), &mut self.matrix));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -4,39 +4,39 @@ use amdgpu_config::fan::MatrixPoint;
|
||||
|
||||
use crate::app::FanConfig;
|
||||
|
||||
pub struct ConfigFile {
|
||||
pub struct ConfigFile<'l> {
|
||||
config: FanConfig,
|
||||
matrix: &'l mut [MatrixPoint],
|
||||
}
|
||||
|
||||
impl ConfigFile {
|
||||
pub fn new(config: FanConfig) -> Self {
|
||||
Self { config }
|
||||
impl<'l> ConfigFile<'l> {
|
||||
pub fn new(config: FanConfig, matrix: &'l mut [MatrixPoint]) -> Self {
|
||||
Self { config, matrix }
|
||||
}
|
||||
}
|
||||
|
||||
impl Widget for ConfigFile {
|
||||
impl<'l> Widget for ConfigFile<'l> {
|
||||
fn ui(self, ui: &mut Ui) -> Response {
|
||||
let config = self.config.clone();
|
||||
|
||||
ui.vertical(|ui| {
|
||||
let mut matrix = { self.config.lock().speed_matrix().to_vec() }
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.peekable();
|
||||
let mut matrix = self.matrix.iter_mut().enumerate().peekable();
|
||||
|
||||
let mut prev = None;
|
||||
let mut prev: Option<MatrixPoint> = None;
|
||||
|
||||
while let Some((idx, mut current)) = matrix.next() {
|
||||
let min = if current == MatrixPoint::MIN {
|
||||
while let Some((idx, current)) = matrix.next() {
|
||||
let min: MatrixPoint = if current == &MatrixPoint::MIN {
|
||||
MatrixPoint::MIN
|
||||
} else if let Some(prev) = prev {
|
||||
prev
|
||||
} else if let Some(prev) = &prev {
|
||||
prev.clone()
|
||||
} else {
|
||||
MatrixPoint::MIN
|
||||
};
|
||||
let next = matrix.peek();
|
||||
let max = if current == MatrixPoint::MAX {
|
||||
let max: MatrixPoint = if current == &MatrixPoint::MAX {
|
||||
MatrixPoint::MAX
|
||||
} else if let Some(next) = next.map(|(_, n)| n) {
|
||||
*next
|
||||
MatrixPoint::new(next.temp, next.speed)
|
||||
} else {
|
||||
MatrixPoint::MAX
|
||||
};
|
||||
@ -44,10 +44,10 @@ impl Widget for ConfigFile {
|
||||
{
|
||||
ui.label("Speed");
|
||||
if ui
|
||||
.add(egui::Slider::new(&mut current.temp, min.temp..=max.temp))
|
||||
.add(egui::Slider::new(&mut current.speed, min.speed..=max.speed))
|
||||
.changed()
|
||||
{
|
||||
if let Some(entry) = self.config.lock().speed_matrix_mut().get_mut(idx) {
|
||||
if let Some(entry) = config.lock().speed_matrix_mut().get_mut(idx) {
|
||||
entry.speed = current.speed;
|
||||
}
|
||||
}
|
||||
@ -55,10 +55,10 @@ impl Widget for ConfigFile {
|
||||
{
|
||||
ui.label("Temperature");
|
||||
if ui
|
||||
.add(egui::Slider::new(&mut current.speed, min.speed..=max.speed))
|
||||
.add(egui::Slider::new(&mut current.temp, min.temp..=max.temp))
|
||||
.changed()
|
||||
{
|
||||
if let Some(entry) = self.config.lock().speed_matrix_mut().get_mut(idx) {
|
||||
if let Some(entry) = config.lock().speed_matrix_mut().get_mut(idx) {
|
||||
entry.temp = current.temp;
|
||||
}
|
||||
}
|
||||
@ -70,7 +70,7 @@ impl Widget for ConfigFile {
|
||||
.add(egui::Button::new("Add in the middle"))
|
||||
.clicked_by(PointerButton::Primary)
|
||||
{
|
||||
self.config.lock().speed_matrix_vec_mut().insert(
|
||||
config.lock().speed_matrix_vec_mut().insert(
|
||||
idx + 1,
|
||||
MatrixPoint::new(
|
||||
min.speed + ((max.speed - min.speed) / 2.0),
|
||||
@ -79,12 +79,12 @@ impl Widget for ConfigFile {
|
||||
)
|
||||
}
|
||||
} else if next.is_none()
|
||||
&& current != MatrixPoint::MAX
|
||||
&& *current != MatrixPoint::MAX
|
||||
&& ui
|
||||
.add(egui::Button::new("Add"))
|
||||
.clicked_by(PointerButton::Primary)
|
||||
{
|
||||
self.config
|
||||
config
|
||||
.lock()
|
||||
.speed_matrix_vec_mut()
|
||||
.push(MatrixPoint::new(100.0, 100.0))
|
||||
@ -93,12 +93,12 @@ impl Widget for ConfigFile {
|
||||
.add(egui::Button::new("Remove"))
|
||||
.clicked_by(PointerButton::Primary)
|
||||
{
|
||||
self.config.lock().speed_matrix_vec_mut().remove(idx);
|
||||
config.lock().speed_matrix_vec_mut().remove(idx);
|
||||
}
|
||||
});
|
||||
|
||||
ui.separator();
|
||||
prev = Some(current);
|
||||
prev = Some(current.clone());
|
||||
}
|
||||
|
||||
ui.allocate_response(ui.available_size(), Sense::click())
|
||||
|
@ -80,14 +80,14 @@ where
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn x_axis_name(mut self, name: String) -> Self {
|
||||
self.axis_names[0] = name;
|
||||
pub fn x_axis_name<S: Into<String>>(mut self, name: S) -> Self {
|
||||
self.axis_names[0] = name.into();
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn y_axis_name(mut self, name: String) -> Self {
|
||||
self.axis_names[1] = name;
|
||||
pub fn y_axis_name<S: Into<String>>(mut self, name: S) -> Self {
|
||||
self.axis_names[1] = name.into();
|
||||
self
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ impl DragPlotPrepared {
|
||||
|
||||
let mut plot_ui = ui.child_ui(*transform.frame(), Layout::default());
|
||||
plot_ui.set_clip_rect(*transform.frame());
|
||||
|
||||
for item in &self.items {
|
||||
item.get_shapes(&mut plot_ui, transform, &mut shapes);
|
||||
}
|
||||
|
@ -1,6 +1,13 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
set -e +x
|
||||
|
||||
cd "$(git rev-parse --show-toplevel)"
|
||||
ROOT="$(git rev-parse --show-toplevel)"
|
||||
|
||||
cd ${ROOT}
|
||||
|
||||
rm -Rf ${ROOT}/tmp
|
||||
mkdir ${ROOT}/tmp
|
||||
|
||||
./scripts/compile.sh
|
||||
|
||||
@ -12,17 +19,20 @@ strip target/x86_64-unknown-linux-musl/release/amdmond
|
||||
#upx --best --lzma target/x86_64-unknown-linux-musl/release/amdvold
|
||||
#upx --best --lzma target/x86_64-unknown-linux-musl/release/amdmond
|
||||
|
||||
cargo build --release --target x86_64-unknown-linux-gnu --bin amdguid --no-default-features --features xorg-glium
|
||||
strip target/x86_64-unknown-linux-gnu/release/amdguid
|
||||
#upx --best --lzma target/x86_64-unknown-linux-gnu/release/amdguid
|
||||
zip ./target/amdguid-glium.zip ./target/x86_64-unknown-linux-gnu/release/amdguid
|
||||
function build_and_zip() {
|
||||
feature=$1
|
||||
zip_name=$2
|
||||
|
||||
cargo build --release --target x86_64-unknown-linux-gnu --bin amdguid --no-default-features --features xorg-glow
|
||||
strip target/x86_64-unknown-linux-gnu/release/amdguid
|
||||
#upx --best --lzma target/x86_64-unknown-linux-gnu/release/amdguid
|
||||
zip ./target/amdguid-glow.zip ./target/x86_64-unknown-linux-gnu/release/amdguid
|
||||
cd ${ROOT}
|
||||
cargo build --release --target x86_64-unknown-linux-gnu --bin amdguid --no-default-features --features ${feature}
|
||||
strip target/x86_64-unknown-linux-gnu/release/amdguid
|
||||
#upx --best --lzma target/x86_64-unknown-linux-gnu/release/amdguid
|
||||
cp ./target/x86_64-unknown-linux-gnu/release/amdguid ./tmp
|
||||
cd ${ROOT}/tmp
|
||||
zip ${zip_name}.zip ./amdguid
|
||||
cd ${ROOT}
|
||||
}
|
||||
|
||||
cargo build --release --target x86_64-unknown-linux-gnu --bin amdguid --no-default-features --features wayland
|
||||
strip target/x86_64-unknown-linux-gnu/release/amdguid
|
||||
#upx --best --lzma target/x86_64-unknown-linux-gnu/release/amdguid
|
||||
zip ./target/amdguid-wayland.zip ./target/x86_64-unknown-linux-gnu/release/amdguid
|
||||
build_and_zip xorg-glium amdguid-glium
|
||||
build_and_zip xorg-glow amdguid-glow
|
||||
build_and_zip wayland amdguid-wayland
|
||||
|
@ -1,17 +1,57 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
set -e +x
|
||||
|
||||
cd "$(git rev-parse --show-toplevel)"
|
||||
|
||||
ROOT="$(git rev-parse --show-toplevel)"
|
||||
|
||||
echo Building archlinux.zip
|
||||
|
||||
rm -Rf ./tmp/*.zip
|
||||
./scripts/build.sh
|
||||
|
||||
cp ./target/x86_64-unknown-linux-musl/release/amdfand ./tmp
|
||||
cp ./target/x86_64-unknown-linux-musl/release/amdmond ./tmp
|
||||
cp ./target/x86_64-unknown-linux-musl/release/amdvold ./tmp
|
||||
cp ./target/x86_64-unknown-linux-musl/release/amdgui-helper ./tmp
|
||||
cp ./target/amdguid-wayland.zip ./tmp
|
||||
cp ./target/amdguid-glium.zip ./tmp
|
||||
cp ./target/amdguid-glow.zip ./tmp
|
||||
build_tag_gz() {
|
||||
zip_name=$1
|
||||
cd ${ROOT}
|
||||
for name in $*; do
|
||||
cp ${ROOT}/target/x86_64-unknown-linux-musl/release/${name} ${ROOT}/tmp
|
||||
cp ${ROOT}/services/${name}.service ./tmp
|
||||
|
||||
cd ./tmp
|
||||
cd ${ROOT}/tmp
|
||||
tar -cvf ${zip_name}.tar.gz ${name}.service ${name}
|
||||
cd ${ROOT}
|
||||
done
|
||||
|
||||
zip -R archlinux.zip *
|
||||
cd ${ROOT}/tmp
|
||||
for name in $*; do
|
||||
rm ${name}.service ${name}
|
||||
done
|
||||
cd ${ROOT}
|
||||
}
|
||||
|
||||
tar_gui() {
|
||||
tar_name=$1
|
||||
|
||||
cd ${ROOT}/tmp
|
||||
unzip ${tar_name}.zip
|
||||
|
||||
cp ${ROOT}/target/x86_64-unknown-linux-musl/release/amdgui-helper ${ROOT}/tmp
|
||||
cp ${ROOT}/services/amdgui-helper.service ${ROOT}/tmp
|
||||
tar -cvf ${tar_name}.tar.gz amdgui-helper amdguid amdgui-helper.service
|
||||
}
|
||||
|
||||
build_tag_gz amdfand
|
||||
build_tag_gz amdmond
|
||||
build_tag_gz amdvold
|
||||
|
||||
tar_gui amdguid-wayland
|
||||
tar_gui amdguid-glium
|
||||
tar_gui amdguid-glow
|
||||
|
||||
cd ${ROOT}/tmp
|
||||
|
||||
for f in $(ls *.tar.gz); do
|
||||
md5sum $f
|
||||
done
|
||||
|
||||
zip -R archlinux.zip *.tar.gz
|
||||
|
Loading…
Reference in New Issue
Block a user