Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

Commit

Permalink
Add const to set hwmon index
Browse files Browse the repository at this point in the history
  • Loading branch information
NGnius committed Feb 24, 2023
1 parent 95dab80 commit b52441f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions backend-rs/src/sys.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
use usdpl_back::api::files::*;

const HWMON_INDEX: usize = 5;

pub fn read_fan() -> Option<u64> {
read_single("/sys/class/hwmon/hwmon5/fan1_input").ok()
read_single(format!("/sys/class/hwmon/hwmon{}/fan1_input", HWMON_INDEX)).ok()
}

pub fn read_thermal_zone(index: u8) -> Option<u64> {
read_single(format!("/sys/class/thermal/thermal_zone{}/temp", index)).ok()
}

pub fn write_fan_recalc(enabled: bool) -> Result<(), std::io::Error> {
write_single("/sys/class/hwmon/hwmon5/recalculate", enabled as u8)
write_single(format!("/sys/class/hwmon/hwmon{}/recalculate", HWMON_INDEX), enabled as u8)
}

pub fn write_fan_target(rpm: u64) -> Result<(), std::io::Error> {
write_single("/sys/class/hwmon/hwmon5/fan1_target", rpm)
write_single(format!("/sys/class/hwmon/hwmon{}/fan1_target", HWMON_INDEX), rpm)
}

0 comments on commit b52441f

Please sign in to comment.