Add ability to use SHT temp. sensor in PWM fan
This commit is contained in:
parent
e2215ced34
commit
f2459ea904
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef USERMOD_DALLASTEMPERATURE
|
||||
#error The "PWM fan" usermod requires "Dallas Temeprature" usermod to function properly.
|
||||
#if !defined(USERMOD_DALLASTEMPERATURE) && !defined(USERMOD_SHT)
|
||||
#error The "PWM fan" usermod requires "Dallas Temeprature" or "SHT" usermod to function properly.
|
||||
#endif
|
||||
|
||||
#include "wled.h"
|
||||
@ -42,6 +42,8 @@ class PWMFanUsermod : public Usermod {
|
||||
|
||||
#ifdef USERMOD_DALLASTEMPERATURE
|
||||
UsermodTemperature* tempUM;
|
||||
#elif defined(USERMOD_SHT)
|
||||
ShtUsermod* tempUM;
|
||||
#endif
|
||||
|
||||
// configurable parameters
|
||||
@ -145,7 +147,7 @@ class PWMFanUsermod : public Usermod {
|
||||
}
|
||||
|
||||
float getActualTemperature(void) {
|
||||
#ifdef USERMOD_DALLASTEMPERATURE
|
||||
#if defined(USERMOD_DALLASTEMPERATURE) || defined(USERMOD_SHT)
|
||||
if (tempUM != nullptr)
|
||||
return tempUM->getTemperatureC();
|
||||
#endif
|
||||
@ -189,6 +191,8 @@ class PWMFanUsermod : public Usermod {
|
||||
#ifdef USERMOD_DALLASTEMPERATURE
|
||||
// This Usermod requires Temperature usermod
|
||||
tempUM = (UsermodTemperature*) usermods.lookup(USERMOD_ID_TEMPERATURE);
|
||||
#elif defined(USERMOD_SHT)
|
||||
tempUM = (ShtUsermod*) usermods.lookup(USERMOD_ID_SHT);
|
||||
#endif
|
||||
initTacho();
|
||||
initPWMfan();
|
||||
|
@ -62,9 +62,9 @@ class ShtUsermod : public Usermod
|
||||
bool isEnabled() { return enabled; }
|
||||
|
||||
float getTemperature();
|
||||
float getTemperatureC() { return shtCurrentTempC; }
|
||||
float getTemperatureF() { return (shtCurrentTempC * 1.8f) + 32.0f; }
|
||||
float getHumidity() { return shtCurrentHumidity; }
|
||||
float getTemperatureC() { return roundf(shtCurrentTempC * 10.0f) / 10.0f; }
|
||||
float getTemperatureF() { return (getTemperatureC() * 1.8f) + 32.0f; }
|
||||
float getHumidity() { return roundf(shtCurrentHumidity * 10.0f) / 10.0f; }
|
||||
const char* getUnitString();
|
||||
|
||||
uint16_t getId() { return USERMOD_ID_SHT; }
|
||||
|
@ -19,11 +19,16 @@
|
||||
#include "../usermods/Temperature/usermod_temperature.h"
|
||||
#endif
|
||||
|
||||
#ifdef USERMOD_SHT
|
||||
#include "../usermods/sht/usermod_sht.h"
|
||||
#endif
|
||||
|
||||
#ifdef USERMOD_SN_PHOTORESISTOR
|
||||
#include "../usermods/SN_Photoresistor/usermod_sn_photoresistor.h"
|
||||
#endif
|
||||
|
||||
#ifdef USERMOD_PWM_FAN
|
||||
// requires DALLASTEMPERATURE or SHT included before it
|
||||
#include "../usermods/PWM_fan/usermod_PWM_fan.h"
|
||||
#endif
|
||||
|
||||
@ -180,10 +185,6 @@
|
||||
#include "../usermods/pwm_outputs/usermod_pwm_outputs.h"
|
||||
#endif
|
||||
|
||||
#ifdef USERMOD_SHT
|
||||
#include "../usermods/sht/usermod_sht.h"
|
||||
#endif
|
||||
|
||||
|
||||
void registerUsermods()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user