Add const to set hwmon index

This commit is contained in:
NGnius (Graham) 2023-02-23 21:43:00 -05:00
parent 95dab80171
commit b52441f1ad

View file

@ -1,7 +1,9 @@
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> {
@ -9,9 +11,9 @@ pub fn read_thermal_zone(index: u8) -> Option<u64> {
}
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)
}