diff --git a/app/include/App.h b/app/include/App.h index 5e656d9..edc526f 100644 --- a/app/include/App.h +++ b/app/include/App.h @@ -27,6 +27,8 @@ private: FanGenerator mFanGenerator; std::unique_ptr mController; + + std::vector> mFans; }; #endif // APP_H_ diff --git a/app/src/App.cxx b/app/src/App.cxx index e08bbe9..23ee316 100644 --- a/app/src/App.cxx +++ b/app/src/App.cxx @@ -5,10 +5,10 @@ using namespace std; void App::Init() { - auto fans = mSerializer.DeserializeFans(mSensorManager.RPMSensors()); + mFans = mSerializer.DeserializeFans(mSensorManager.RPMSensors()); auto fanCurves = mSerializer.DeserializeFanCurves( - mSensorManager.TemperatureSensors(), fans); + mSensorManager.TemperatureSensors(), mFans); mController = make_unique(fanCurves); } @@ -23,6 +23,8 @@ void App::InitialSetup() { mFanLabeler.RunFanLabelInteraction(fans); mSerializer.SerializeFans(fans); + + mFans = fans; } void App::NormalOperation() { @@ -30,4 +32,7 @@ void App::NormalOperation() { mController->StartFanControlLoop(); } -void App::Shutdown() { mController.reset(); } +void App::Shutdown() { + mController.reset(); + mSerializer.SerializeFans(mFans); +} diff --git a/app/src/fan/FanCurve.cxx b/app/src/fan/FanCurve.cxx index 1fcf61c..03dd1f0 100644 --- a/app/src/fan/FanCurve.cxx +++ b/app/src/fan/FanCurve.cxx @@ -16,6 +16,7 @@ FanCurve::FanCurve(std::vector steps, void FanCurve::DoFanControl() { BOOST_LOG_FUNCTION(); + int temp = AggregateTemperature(); int t0, t1, p0, p1; @@ -43,8 +44,12 @@ void FanCurve::DoFanControl() { if (f->RPM() <= 0) { BOOST_LOG_TRIVIAL(warning) << "Fan stopped completely!"; f->PWM(f->StartPWM()); + + BOOST_LOG_TRIVIAL(info) << "Adjusting minPWM of fan " << f->toString(); + f->MinPWM(f->MinPWM() + 2); + } else { + f->PWM(targetFanPower); } - f->PWM(targetFanPower); } } diff --git a/app/src/fan/HwmonFan.cxx b/app/src/fan/HwmonFan.cxx index eb46866..eb7a7f7 100644 --- a/app/src/fan/HwmonFan.cxx +++ b/app/src/fan/HwmonFan.cxx @@ -47,9 +47,7 @@ void HwmonFan::FindPWMLimits() { PWM(curPWM); this_thread::sleep_for(chrono::seconds(TIMEOUT)); - int curRPM = RPM(); - - if (curRPM <= 0) { + if (RPM() <= 0) { minPWM = curPWM + 5; break; } @@ -68,9 +66,7 @@ void HwmonFan::FindPWMLimits() { PWM(curPWM); this_thread::sleep_for(chrono::seconds(TIMEOUT)); - int curRPM = RPM(); - - if (curRPM > 0) { + if (RPM() > 0) { cout << "Setting start PWM: " << startPWM << endl; startPWM = curPWM; break;