Re-enable ROGCC fan curves

This commit is contained in:
Luke D. Jones
2023-12-24 10:30:33 +13:00
parent f421b8ee3b
commit a867496f13
10 changed files with 340 additions and 250 deletions

View File

@@ -6,9 +6,9 @@ use std::sync::{Arc, Mutex};
use std::thread;
use std::time::Duration;
use eframe::IconData;
use eframe::HardwareAcceleration;
use gumdrop::Options;
use log::{debug, error, info, warn, LevelFilter};
use log::{debug, error, warn, LevelFilter};
use rog_aura::aura_detection::{LaptopLedData, LedSupportFile};
use rog_aura::layouts::KeyLayout;
use rog_control_center::cli_options::CliStart;
@@ -29,7 +29,8 @@ const DATA_DIR: &str = "/usr/share/rog-gui/";
#[cfg(feature = "mocking")]
const DATA_DIR: &str = env!("CARGO_MANIFEST_DIR");
const BOARD_NAME: &str = "/sys/class/dmi/id/board_name";
const APP_ICON_PATH: &str = "/usr/share/icons/hicolor/512x512/apps/rog-control-center.png";
// const APP_ICON_PATH: &str =
// "/usr/share/icons/hicolor/512x512/apps/rog-control-center.png";
fn main() -> Result<()> {
let args: Vec<String> = args().skip(1).collect();
@@ -60,12 +61,10 @@ fn main() -> Result<()> {
let native_options = eframe::NativeOptions {
vsync: true,
decorated: true,
transparent: false,
min_window_size: Some(egui::vec2(960.0, 670.0)),
max_window_size: Some(egui::vec2(960.0, 670.0)),
hardware_acceleration: HardwareAcceleration::Preferred,
// min_window_size: Some(egui::vec2(960.0, 670.0)),
// max_window_size: Some(egui::vec2(960.0, 670.0)),
run_and_return: true,
icon_data: Some(load_icon()),
..Default::default()
};
@@ -263,37 +262,38 @@ fn setup_page_state_and_notifs(
}
/// Bah.. the icon dosn't work on wayland anyway, but we'll leave it in for now.
fn load_icon() -> IconData {
let path = PathBuf::from(APP_ICON_PATH);
let mut rgba = Vec::new();
let mut height = 512;
let mut width = 512;
if path.exists() {
if let Ok(data) = std::fs::read(path)
.map_err(|e| error!("Error reading app icon: {e:?}"))
.map_err(|e| error!("Error opening app icon: {e:?}"))
{
let data = std::io::Cursor::new(data);
let decoder = png_pong::Decoder::new(data).unwrap().into_steps();
let png_pong::Step { raster, delay: _ } = decoder.last().unwrap().unwrap();
// fn load_icon() -> IconData {
// let path = PathBuf::from(APP_ICON_PATH);
// let mut rgba = Vec::new();
// let mut height = 512;
// let mut width = 512;
// if path.exists() {
// if let Ok(data) = std::fs::read(path)
// .map_err(|e| error!("Error reading app icon: {e:?}"))
// .map_err(|e| error!("Error opening app icon: {e:?}"))
// {
// let data = std::io::Cursor::new(data);
// let decoder = png_pong::Decoder::new(data).unwrap().into_steps();
// let png_pong::Step { raster, delay: _ } =
// decoder.last().unwrap().unwrap();
if let png_pong::PngRaster::Rgba8(ras) = raster {
rgba = ras.as_u8_slice().to_vec();
width = ras.width();
height = ras.height();
info!("Loaded app icon. Not actually supported in Wayland yet");
}
}
} else {
error!("Missing {APP_ICON_PATH}");
}
// if let png_pong::PngRaster::Rgba8(ras) = raster {
// rgba = ras.as_u8_slice().to_vec();
// width = ras.width();
// height = ras.height();
// info!("Loaded app icon. Not actually supported in Wayland
// yet"); }
// }
// } else {
// error!("Missing {APP_ICON_PATH}");
// }
IconData {
height,
width,
rgba,
}
}
// IconData {
// height,
// width,
// rgba,
// }
// }
fn do_cli_help(parsed: &CliStart) -> bool {
if parsed.help {

View File

@@ -43,31 +43,6 @@ impl RogApp {
ui.label(RichText::new(format!("{}", current)).strong());
});
// ui.horizontal(|ui| {
// ui.label("Enabled fan-curves: ");
// let mut fan_curve_enable = |profile: Profile, fan: FanCurvePU, mut
// checked: bool| { if ui
// .add(egui::Checkbox::new(&mut checked, format!("{:?}", fan)))
// .changed()
// {
// dbus.proxies()
// .profile()
// .set_fan_curves_enabled(profile, checked)
// .map_err(|err| {
// *do_error = Some(err.to_string());
// })
// .ok();
// changed = true;
// }
// };
// if let Some(curves) = curves.curves.get_mut(&current) {
// for curve in curves.iter_mut() {
// fan_curve_enable(current, curve.fan, curve.enabled);
// }
// }
// });
ui.horizontal(|ui| {
ui.label("Enabled fan-curves: ");
let mut checked = false;

View File

@@ -1,4 +1,4 @@
use egui::{Button, RichText};
use egui::RichText;
pub struct AppErrorShow {
error: String,
@@ -11,7 +11,7 @@ impl AppErrorShow {
}
impl eframe::App for AppErrorShow {
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("ROG ERROR");
@@ -19,18 +19,20 @@ impl eframe::App for AppErrorShow {
ui.label(RichText::new(format!("The error was: {:?}", self.error)).size(22.0));
});
egui::TopBottomPanel::bottom("error_bar_2")
.default_height(26.0)
.show(ctx, |ui| {
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
if ui
.add(Button::new(RichText::new("Okay").size(20.0)))
.clicked()
{
frame.close();
}
});
});
// egui::TopBottomPanel::bottom("error_bar_2")
// .default_height(26.0)
// .show(ctx, |ui| {
// ui.
// with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
// if ui
// .add(Button::new(RichText::new("Okay").size(20.0)))
// .clicked()
// {
// // frame.close();
// // ui.close_menu();
// }
// });
// });
});
}
}

View File

@@ -80,20 +80,21 @@ impl FanCurvesState {
PlatformPolicy::Performance,
];
let mut available_fans = HashSet::new();
let mut curves: BTreeMap<PlatformPolicy, Vec<CurveData>> = BTreeMap::new();
for p in &profiles {
if let Ok(curve) = dbus.proxies().fan_curves().fan_curve_data(*p) {
if available_fans.is_empty() {
for fan in &curve {
available_fans.insert(fan.fan);
}
}
curves.insert(*p, curve);
} else {
curves.insert(*p, Default::default());
}
}
let available_fans = HashSet::new();
// for fan in supported.platform_profile.fans.iter() {
// available_fans.insert(*fan);
// }
let show_curve = dbus.proxies().platform().throttle_thermal_policy()?;
Ok(Self {

View File

@@ -1,5 +1,5 @@
use egui::plot::Points;
use egui::Ui;
use egui_plot::Points;
use rog_platform::platform::PlatformPolicy;
use rog_profiles::fan_curve_set::CurveData;
use rog_profiles::FanCurvePU;
@@ -60,7 +60,7 @@ pub fn fan_graphs(
let curve = curves.curves.get_mut(&curves.show_curve).unwrap();
use egui::plot::{Line, Plot};
use egui_plot::{Line, Plot};
let mut data = &mut CurveData::default();
for c in curve {
@@ -116,8 +116,8 @@ pub fn fan_graphs(
.allow_scroll(false)
.allow_drag(false)
.allow_boxed_zoom(false)
.x_axis_formatter(|d, _r| format!("{}", d))
.y_axis_formatter(|d, _r| format!("{:.*}%", 1, d))
// .x_axis_formatter(|d, _r| format!("{}", d))
// .y_axis_formatter(|d, _r| format!("{:.*}%", 1, d))
.label_formatter(|name, value| {
if !name.is_empty() {
format!("{}: {:.*}%", name, 1, value.y)
@@ -126,7 +126,7 @@ pub fn fan_graphs(
}
})
.show(ui, |plot_ui| {
if plot_ui.plot_hovered() {
if plot_ui.response().hovered() {
let mut idx = 0;
if let Some(point) = plot_ui.pointer_coordinate() {
@@ -139,7 +139,7 @@ pub fn fan_graphs(
}
}
if plot_ui.plot_clicked() {
if plot_ui.response().clicked() {
data.temp[idx] = point.x as u8;
data.pwm[idx] = (point.y * 255.0 / 100.0) as u8;
} else {

View File

@@ -1,4 +1,4 @@
use egui::{vec2, Align2, FontId, Id, Sense};
use egui::{vec2, Align2, FontId};
use crate::system_state::SystemState;
use crate::{RogApp, VERSION};
@@ -6,9 +6,9 @@ use crate::{RogApp, VERSION};
impl RogApp {
pub fn top_bar(
&mut self,
states: &mut SystemState,
_states: &mut SystemState,
ctx: &egui::Context,
frame: &mut eframe::Frame,
_frame: &mut eframe::Frame,
) {
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
// The top panel is often a good place for a menu bar:
@@ -16,22 +16,18 @@ impl RogApp {
ui.horizontal(|ui| {
self.dark_light_mode_buttons(ui);
egui::warn_if_debug_build(ui);
if ui.button("Quit app").clicked() {
states.run_in_bg = false;
frame.close();
}
});
// Drag area
let text_color = ctx.style().visuals.text_color();
let mut titlebar_rect = ui.available_rect_before_wrap();
titlebar_rect.max.x -= titlebar_rect.height();
if ui
.interact(titlebar_rect, Id::new("title_bar"), Sense::drag())
.drag_started()
{
frame.drag_window();
}
// if ui
// .interact(titlebar_rect, Id::new("title_bar"), Sense::drag())
// .drag_started()
// {
// frame.drag_window();
// }
let height = titlebar_rect.height();