From 1f613b91bc07f2d070a328d5bba1d417ef293ac9 Mon Sep 17 00:00:00 2001 From: L_DelOff Date: Sun, 3 Mar 2024 13:44:07 +0300 Subject: [PATCH] fix --- pwmfan.cpp | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/pwmfan.cpp b/pwmfan.cpp index 53a12d3..b09509b 100644 --- a/pwmfan.cpp +++ b/pwmfan.cpp @@ -46,27 +46,6 @@ volatile sig_atomic_t flag = 1; // ---====*--------*---------------> // 0 | T_MIN T_MAX max[TEMP], celsius -int main(void) -{ - signal(SIGINT, sig_handler); - std::cout << "!!!Control fan connected to RockPi4 pin " << PWM_PORT << " according to CPU&HDD temperature!!!\n"; - initPWM(); - checkControlCurve(); - - float power = 0.0f; - int temperature = 0; - - while (flag) { - temperature = readTemp(); - power = calcPower(temperature); - std::cout << "T:" << t << "С power:"<< value << "%\n"; - pwm.write(value); - usleep(2000000); - } - - return EXIT_SUCCESS; -} - float calcPower(int temperature) { if (temperature < T_MIN) { value = 0.0f; @@ -175,4 +154,23 @@ void sig_handler(int signum) } } +int main(void) +{ + signal(SIGINT, sig_handler); + std::cout << "!!!Control fan connected to RockPi4 pin " << PWM_PORT << " according to CPU&HDD temperature!!!\n"; + initPWM(); + checkControlCurve(); + + float power = 0.0f; + int temperature = 0; + while (flag) { + temperature = readTemp(); + power = calcPower(temperature); + std::cout << "T:" << t << "С power:"<< value << "%\n"; + pwm.write(value); + usleep(2000000); + } + + return EXIT_SUCCESS; +}