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