Read RPM each 100 cycles

This commit is contained in:
Ollo 2024-12-06 20:33:24 +01:00
parent 7ee090043a
commit f761d3349e

View File

@ -22,6 +22,7 @@
#define INVALID_TEMP (MAX_TEMP+MAX_TEMP) /**< Invalid temperature (on sensor failures)*/
#define TEMP_SENSOR_MEASURE_SERIES 5 /**< Maximum resets */
#define FAN_RPM_READLEVEL 100
/******************************************************************************
* LOCAL VARIABLES
@ -136,12 +137,14 @@ float readTemperature(void)
*/
void loop()
{
static int i = 0;
static int actualFanSpeedRpm = -1;
float temp = readTemperature();
Serial.print(temp);
Serial.print(";");
int fanSpeedPercent, actualFanSpeedRpm = 0;
int fanSpeedPercent;
if (temp < MIN_TEMP) {
fanSpeedPercent = 0;
@ -152,7 +155,21 @@ void loop()
}
#ifdef FAN_ENABLED
actualFanSpeedRpm = getFanSpeedRpm();
if (actualFanSpeedRpm == 0)
{
if (i > FAN_RPM_READLEVEL)
{
actualFanSpeedRpm = getFanSpeedRpm();
i = 0;
}
i++;
}
else
{
actualFanSpeedRpm = getFanSpeedRpm();
i = 0;
}
pixels->fill(Color(255, 0,0));
pixels->setBrightness(actualFanSpeedRpm);
pixels->show();
@ -175,9 +192,5 @@ void loop()
singleLed->fill(Color(0,128,128));
singleLed->setBrightness(fanSpeedPercent);
singleLed->show();
#ifdef FAN_ENABLED
delay(DELAY_TIME);
#endif
singleLed->show();
}