diff --git a/fan-controller/src/fan.rs b/fan-controller/src/fan.rs index 8e4b741..25f8437 100644 --- a/fan-controller/src/fan.rs +++ b/fan-controller/src/fan.rs @@ -44,35 +44,41 @@ impl Setting { Err(error) => panic!("Invalid value"), }; + pub(crate) const fn new(set_point: u16) -> Result { + if set_point > MAX_SET_POINT { + return Err(SetPointOutOfBoundsError); + } + + Ok(Self(set_point)) + } + + const fn get(&self) -> u16 { + self.0 + } +} + +/// Settings specific to our use case for these fans. They are custom tuned to the house. +/// For example, we don't run the fans at full speed to reduce wear on them +pub(crate) mod user_setting { + use crate::fan; + /// Max speed 64000 / 3.3 - pub(crate) const LOW: Self = match Self::new(19_393) { + pub(crate) const LOW: fan::Setting = match fan::Setting::new(19_393) { Ok(setting) => setting, Err(error) => panic!("Invalid value"), }; /// Max speed 64000 / 2.4 - pub(crate) const MEDIUM: Self = match Self::new(26_666) { + pub(crate) const MEDIUM: fan::Setting = match fan::Setting::new(26_666) { Ok(setting) => setting, Err(error) => panic!("Invalid value"), }; /// Max speed 50% /// Not set to full speed to not wear out the fans - pub(crate) const HIGH: Self = match Self::new(MAX_SET_POINT / 2) { + pub(crate) const HIGH: fan::Setting = match fan::Setting::new(fan::MAX_SET_POINT / 2) { Ok(setting) => setting, Err(error) => panic!("Invalid value"), }; - - pub(crate) const fn new(set_point: u16) -> Result { - if set_point > MAX_SET_POINT { - return Err(SetPointOutOfBoundsError); - } - - Ok(Self(set_point)) - } - - const fn get(&self) -> u16 { - self.0 - } } #[derive(Default, Format, Debug)] diff --git a/fan-controller/src/main.rs b/fan-controller/src/main.rs index 118c751..b95e8dd 100644 --- a/fan-controller/src/main.rs +++ b/fan-controller/src/main.rs @@ -1073,11 +1073,11 @@ async fn input_task(pin_18: PIN_18) { } // Setting speeds based // 64000 / 3.3 - fan::State::Low => fan::Setting::LOW, + fan::State::Low => fan::user_setting::LOW, // 64000 / 2.4 = - fan::State::Medium => fan::Setting::MEDIUM, + fan::State::Medium => fan::user_setting::MEDIUM, // 50% - fan::State::High => fan::Setting::HIGH, + fan::State::High => fan::user_setting::HIGH, }; // Optimistically update setting