Improve logic to handle fans stopping

This commit is contained in:
2022-10-10 00:25:09 +02:00
parent 0f91960ef9
commit 596a30b76a
7 changed files with 30 additions and 12 deletions

View File

@@ -44,9 +44,7 @@ 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);
f->AdjustPWMLimits();
} else {
f->PWM(targetFanPower);
}

View File

@@ -1,11 +1,12 @@
#include <chrono>
#include <iostream>
#include <ostream>
#include <thread>
#include "pwm/PWMControl.h"
#include <boost/json/object.hpp>
#include <boost/log/attributes/named_scope.hpp>
#include <boost/log/trivial.hpp>
#include <fan/HwmonFan.h>
#include <pwm/PWMControl.h>
#define TIMEOUT 10
#define STEP 2
@@ -34,10 +35,10 @@ void HwmonFan::MinPWM(int value) { mMinPWM = value; }
int HwmonFan::MinPWM() { return mMinPWM; }
int HwmonFan::StartPWM() { return mStartPWM; }
void HwmonFan::StartPWM(int value) { mStartPWM = value; }
int HwmonFan::StartPWM() { return mStartPWM; }
void HwmonFan::FindPWMLimits() {
cout << "Looking for minimal PWM" << endl;
int minPWM = 0;
@@ -78,6 +79,20 @@ void HwmonFan::FindPWMLimits() {
}
}
void HwmonFan::AdjustPWMLimits() {
BOOST_LOG_FUNCTION()
chrono::time_point now = chrono::steady_clock::now();
if ((now - mLastAdjustmentTime) >
chrono::duration(chrono::seconds(TIMEOUT))) {
BOOST_LOG_TRIVIAL(info) << "Increasing minimal fan speed";
mLastAdjustmentTime = now;
mMinPWM += 2;
}
}
json HwmonFan::toJson() const {
json obj;
obj = {mPWMControl->toJson(),