mirror of
https://github.com/wled/WLED.git
synced 2025-07-18 08:16:32 +00:00
Fixes to feature update for Internal Temperature usermod
Applied various fixes as advised by @blazoncek Thankyou for the advice! - Updated float: 95.0 > 95.0f - Updated type: const > constexpr - Comments clarified - Preset setting: `-1` > `0`
This commit is contained in:
parent
f825cab54a
commit
bc4a6138b1
@ -1,13 +1,8 @@
|
|||||||
# Internal Temperature Usermod
|
# Internal Temperature Usermod
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
<p align="left">
|

|
||||||
<img width="700" src="assets/screenshot-info.png">
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p align="left">
|
|
||||||
<img width="700" src="assets/screenshot-settings.png">
|
|
||||||
</p>
|
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
- 🌡️ Adds the internal temperature readout of the chip to the `Info` tab
|
- 🌡️ Adds the internal temperature readout of the chip to the `Info` tab
|
||||||
|
@ -6,13 +6,13 @@ class InternalTemperatureUsermod : public Usermod
|
|||||||
{
|
{
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const unsigned long minLoopInterval = 1000; // minimum allowable interval (ms)
|
static constexpr unsigned long minLoopInterval = 1000; // minimum allowable interval (ms)
|
||||||
unsigned long loopInterval = 10000;
|
unsigned long loopInterval = 10000;
|
||||||
unsigned long lastTime = 0;
|
unsigned long lastTime = 0;
|
||||||
bool isEnabled = false;
|
bool isEnabled = false;
|
||||||
float temperature = 0;
|
float temperature = 0;
|
||||||
int presetToActivate = -1; // Preset to activate when temp goes above threshold (-1 = disabled)
|
int presetToActivate = 0; // Preset to activate when temp goes above threshold (0 = disabled)
|
||||||
float activationThreshold = 95.0; // Temperature threshold to trigger high-temperature actions
|
float activationThreshold = 95.0f; // Temperature threshold to trigger high-temperature actions
|
||||||
float resetMargin = 2.0; // Margin below the activation threshold (Prevents frequent toggling when close to threshold)
|
float resetMargin = 2.0; // Margin below the activation threshold (Prevents frequent toggling when close to threshold)
|
||||||
bool isAboveThreshold = false; // Flag to track if the high temperature preset is currently active
|
bool isAboveThreshold = false; // Flag to track if the high temperature preset is currently active
|
||||||
|
|
||||||
@ -33,7 +33,6 @@ private:
|
|||||||
public:
|
public:
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
setSafeLoopInterval(loopInterval); // Initialize with a safe loop interval
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
@ -62,8 +61,8 @@ public:
|
|||||||
isAboveThreshold = true;
|
isAboveThreshold = true;
|
||||||
}
|
}
|
||||||
// Activate the 'over-threshold' preset if it's not already active
|
// Activate the 'over-threshold' preset if it's not already active
|
||||||
if (presetToActivate != -1 && currentPreset != presetToActivate) {
|
if (presetToActivate != 0 && currentPreset != presetToActivate) {
|
||||||
saveTemporaryPreset(); // Save the current preset to allow re-activation later
|
saveTemporaryPreset(); // Save current state to a temporary preset to allow re-activation later
|
||||||
applyPreset(presetToActivate);
|
applyPreset(presetToActivate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,7 +74,7 @@ public:
|
|||||||
}
|
}
|
||||||
// Revert back to the original preset
|
// Revert back to the original preset
|
||||||
if (currentPreset == presetToActivate){
|
if (currentPreset == presetToActivate){
|
||||||
applyTemporaryPreset(); // Restore the previously stored active preset
|
applyTemporaryPreset(); // Restore the previous state which was stored to the temporary preset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,8 +128,8 @@ public:
|
|||||||
oappend(SET_F("addInfo('Internal Temperature:Loop Interval', 1, 'ms');"));
|
oappend(SET_F("addInfo('Internal Temperature:Loop Interval', 1, 'ms');"));
|
||||||
// Display '°C' next to the 'Activation Threshold' setting
|
// Display '°C' next to the 'Activation Threshold' setting
|
||||||
oappend(SET_F("addInfo('Internal Temperature:Activation Threshold', 1, '°C');"));
|
oappend(SET_F("addInfo('Internal Temperature:Activation Threshold', 1, '°C');"));
|
||||||
// Display '-1 = Disabled' next to the 'Preset To Activate' setting
|
// Display '0 = Disabled' next to the 'Preset To Activate' setting
|
||||||
oappend(SET_F("addInfo('Internal Temperature:Preset To Activate', 1, '-1 = disabled');"));
|
oappend(SET_F("addInfo('Internal Temperature:Preset To Activate', 1, '0 = unused');"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool readFromConfig(JsonObject &root)
|
bool readFromConfig(JsonObject &root)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user