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