mirror of
https://github.com/wled/WLED.git
synced 2025-07-15 14:56:32 +00:00
connect the seven segment reloaded usermod to BH1750 usermod (#4503)
This commit is contained in:
parent
a421a90e0a
commit
01a71132d5
@ -9,7 +9,7 @@ Very loosely based on the existing usermod "seven segment display".
|
|||||||
|
|
||||||
Add the compile-time option `-D USERMOD_SSDR` to your `platformio.ini` (or `platformio_override.ini`) or use `#define USERMOD_SSDR` in `my_config.h`.
|
Add the compile-time option `-D USERMOD_SSDR` to your `platformio.ini` (or `platformio_override.ini`) or use `#define USERMOD_SSDR` in `my_config.h`.
|
||||||
|
|
||||||
For the auto brightness option, the usermod SN_Photoresistor has to be installed as well. See SN_Photoresistor/readme.md for instructions.
|
For the auto brightness option, the usermod SN_Photoresistor or BH1750_V2 has to be installed as well. See SN_Photoresistor/readme.md or BH1750_V2/readme.md for instructions.
|
||||||
|
|
||||||
## Settings
|
## Settings
|
||||||
All settings can be controlled via the usermod settings page.
|
All settings can be controlled via the usermod settings page.
|
||||||
@ -28,10 +28,10 @@ Enables the blinking colon(s) if they are defined
|
|||||||
Shows the leading zero of the hour if it exists (i.e. shows `07` instead of `7`)
|
Shows the leading zero of the hour if it exists (i.e. shows `07` instead of `7`)
|
||||||
|
|
||||||
### enable-auto-brightness
|
### enable-auto-brightness
|
||||||
Enables the auto brightness feature. Can be used only when the usermod SN_Photoresistor is installed.
|
Enables the auto brightness feature. Can be used only when the usermods SN_Photoresistor or BH1750_V2 are installed.
|
||||||
|
|
||||||
### auto-brightness-min / auto-brightness-max
|
### auto-brightness-min / auto-brightness-max
|
||||||
The lux value calculated from usermod SN_Photoresistor will be mapped to the values defined here.
|
The lux value calculated from usermod SN_Photoresistor or BH1750_V2 will be mapped to the values defined here.
|
||||||
The mapping, 0 - 1000 lux, will be mapped to auto-brightness-min and auto-brightness-max
|
The mapping, 0 - 1000 lux, will be mapped to auto-brightness-min and auto-brightness-max
|
||||||
|
|
||||||
WLED current protection will override the calculated value if it is too high.
|
WLED current protection will override the calculated value if it is too high.
|
||||||
|
@ -97,6 +97,11 @@ private:
|
|||||||
#else
|
#else
|
||||||
void* ptr = nullptr;
|
void* ptr = nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef USERMOD_BH1750
|
||||||
|
Usermod_BH1750* bh1750 = nullptr;
|
||||||
|
#else
|
||||||
|
void* bh1750 = nullptr;
|
||||||
|
#endif
|
||||||
|
|
||||||
void _overlaySevenSegmentDraw() {
|
void _overlaySevenSegmentDraw() {
|
||||||
int displayMaskLen = static_cast<int>(umSSDRDisplayMask.length());
|
int displayMaskLen = static_cast<int>(umSSDRDisplayMask.length());
|
||||||
@ -387,6 +392,9 @@ public:
|
|||||||
#ifdef USERMOD_SN_PHOTORESISTOR
|
#ifdef USERMOD_SN_PHOTORESISTOR
|
||||||
ptr = (Usermod_SN_Photoresistor*) UsermodManager::lookup(USERMOD_ID_SN_PHOTORESISTOR);
|
ptr = (Usermod_SN_Photoresistor*) UsermodManager::lookup(USERMOD_ID_SN_PHOTORESISTOR);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef USERMOD_BH1750
|
||||||
|
bh1750 = (Usermod_BH1750*) UsermodManager::lookup(USERMOD_ID_BH1750);
|
||||||
|
#endif
|
||||||
DEBUG_PRINTLN(F("Setup done"));
|
DEBUG_PRINTLN(F("Setup done"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -410,6 +418,20 @@ public:
|
|||||||
umSSDRLastRefresh = millis();
|
umSSDRLastRefresh = millis();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef USERMOD_BH1750
|
||||||
|
if(bri != 0 && umSSDREnableLDR && (millis() - umSSDRLastRefresh > umSSDRResfreshTime)) {
|
||||||
|
if (bh1750 != nullptr) {
|
||||||
|
float lux = bh1750->getIlluminance();
|
||||||
|
uint16_t brightness = map(lux, 0, 1000, umSSDRBrightnessMin, umSSDRBrightnessMax);
|
||||||
|
if (bri != brightness) {
|
||||||
|
DEBUG_PRINTF("Adjusting brightness based on lux value: %.2f lx, new brightness: %d\n", lux, brightness);
|
||||||
|
bri = brightness;
|
||||||
|
stateUpdated(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
umSSDRLastRefresh = millis();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleOverlayDraw() {
|
void handleOverlayDraw() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user