Skip to content

Commit

Permalink
Merge branch 'mdev' into global-i2c
Browse files Browse the repository at this point in the history
  • Loading branch information
softhack007 committed Dec 10, 2023
2 parents 94c8961 + d2c9c9e commit c300493
Show file tree
Hide file tree
Showing 25 changed files with 3,012 additions and 2,531 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/wled-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:


build:
name: Build Environments
name: Builds
runs-on: ubuntu-latest
needs: get_default_envs
strategy:
Expand Down
74 changes: 62 additions & 12 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,16 @@ board_build.partitions = ${esp32.default_partitions}

; shared build flags and lib deps for minimum and maximum environment
[common_mm]

build_disable_sync_interfaces =
-D WLED_DISABLE_LOXONE
-D WLED_DISABLE_ALEXA
-D WLED_DISABLE_HUESYNC
-D WLED_DISABLE_MQTT
-D WLED_DISABLE_INFRARED
-D WLED_DISABLE_ADALIGHT ;; WLEDMM this board does not have a serial-to-USB chip. Better to disable serial protocols, to avoid crashes (see upstream #3128)
-D WLED_DISABLE_ESPNOW ;; ESP-NOW requires wifi, may crash with ethernet only

build_flags_S =
-Wall -Wformat -Woverflow -Wuninitialized -Winit-self -Warray-bounds ; enables more warnings
-Wno-attributes -Wno-unused-variable -Wno-unused-function -Wno-deprecated-declarations ;disables some stupid warnings
Expand All @@ -916,22 +926,17 @@ build_flags_S =
-D USERMOD_AUDIOREACTIVE
-D UM_AUDIOREACTIVE_USE_NEW_FFT ; use latest (upstream) FFTLib, instead of older library modified by blazoncek. Slightly faster, more accurate, needs 2KB RAM extra
; -D USERMOD_ARTIFX ;; WLEDMM usermod - temporarily moved into "_M", due to problems in "_S" when compiling with -O2
; -D WLEDMM_FASTPATH ;; WLEDMM experimental option. Reduces audio lag (latency), and allows for faster LED framerates. May break compatibility with previous versions.
-D WLEDMM_FASTPATH ;; WLEDMM experimental option. Reduces audio lag (latency), and allows for faster LED framerates. May break compatibility with previous versions.
; -D WLED_DEBUG_HEAP ;; WLEDMM enable heap debugging
; -D WLED_DISABLE_LOXONE
; -D WLED_DISABLE_ALEXA
; -D WLED_DISABLE_HUESYNC
; -D WLED_DISABLE_MQTT
; -D WLED_DISABLE_INFRARED
; -D WLED_ENABLE_DMX
${common_mm.build_disable_sync_interfaces}

lib_deps_S =
;; https://github.com/kosme/arduinoFFT#develop @ 1.9.2+sha.419d7b0 ;; used for USERMOD_AUDIOREACTIVE - using "known working" hash
https://github.com/softhack007/arduinoFFT.git#develop @ 1.9.2 ;; used for USERMOD_AUDIOREACTIVE - optimized version, 10% faster on -S2/-C3


animartrix_build_flags = -D USERMOD_ANIMARTRIX ;; WLEDMM usermod: CC BY-NC 3.0 licensed effects by Stefan Petrick
animartrix_lib_deps = https://github.com/netmindz/animartrix.git#8fd0df3e0b006244d53eaf480c2720daa5a697aa
animartrix_lib_deps = https://github.com/netmindz/animartrix.git#18bf17389e57c69f11bc8d04ebe1d215422c7fb7

build_flags_M =
-D USERMOD_ARTIFX ; WLEDMM usermod - temporarily moved into "_M", due to problems in "_S" when compiling with -O2
Expand Down Expand Up @@ -1017,12 +1022,14 @@ monitor_filters = esp32_exception_decoder
[esp32_4MB_M_base]
extends = esp32_4MB_S_base
build_flags = ${esp32_4MB_S_base.build_flags} ${common_mm.build_flags_M}
build_unflags = ${esp32_4MB_S_base.build_unflags} ${common_mm.build_disable_sync_interfaces}
lib_deps = ${esp32_4MB_S_base.lib_deps} ${common_mm.lib_deps_M}
; board_build.partitions = tools/WLED_ESP32-wrover_4MB.csv

[esp32_4MB_XL_base]
extends = esp32_4MB_M_base
build_flags = ${esp32_4MB_M_base.build_flags} ${common_mm.build_flags_XL}
build_unflags = ${esp32_4MB_M_base.build_unflags} ${common_mm.build_disable_sync_interfaces}
lib_deps = ${esp32_4MB_M_base.lib_deps} ${common_mm.lib_deps_XL}
; board_build.partitions = tools/WLED_ESP32-wrover_4MB.csv

Expand Down Expand Up @@ -1151,7 +1158,7 @@ build_flags = ${esp32_4MB_M_base.build_flags}
extends = esp32_4MB_XL_base
build_flags = ${esp32_4MB_XL_base.build_flags}
-D WLED_RELEASE_NAME=esp32_4MB_XL
build_unflags =
build_unflags = ${esp32_4MB_XL_base.build_unflags}
-D USERMOD_ANIMARTRIX ;; Tips our memory usage over the limit
; RAM: [== ] 24.4% (used 80060 bytes from 327680 bytes)
; Flash: [==========] 95.3% (used 1499037 bytes from 1572864 bytes)
Expand Down Expand Up @@ -1956,9 +1963,11 @@ monitor_filters = esp32_exception_decoder
# custom board environments
# ------------------------------------------------------------------------------

[wemos_shield_esp32_4MB_M_base]
extends = esp32_4MB_M_base
build_flags = ${esp32_4MB_M_base.build_flags}
;https://www.tindie.com/products/serg74/wled-shield-board-for-addressable-leds/
;https://www.tindie.com/products/moonmodules/shield-board-for-esp32-for-wled-addressable-leds/
[wemos_shield_esp32_4MB_S_base]
extends = esp32_4MB_S_base
build_flags = ${esp32_4MB_S_base.build_flags}
-D ABL_MILLIAMPS_DEFAULT=9500 ; Wemos max 10A
-D LEDPIN=16
-D RLYPIN=19
Expand All @@ -1974,11 +1983,21 @@ build_flags = ${esp32_4MB_M_base.build_flags}
-D PWM_PIN=-1
; -D WLED_USE_MY_CONFIG

[wemos_shield_esp32_4MB_M_base]
extends = wemos_shield_esp32_4MB_S_base
build_flags = ${wemos_shield_esp32_4MB_S_base.build_flags} ${common_mm.build_flags_M}
lib_deps = ${wemos_shield_esp32_4MB_S_base.lib_deps} ${common_mm.lib_deps_M}

[wemos_shield_esp32_4MB_XL_base]
extends = wemos_shield_esp32_4MB_M_base
build_flags = ${wemos_shield_esp32_4MB_M_base.build_flags} ${common_mm.build_flags_XL}
lib_deps = ${wemos_shield_esp32_4MB_M_base.lib_deps} ${common_mm.lib_deps_XL}

[env:wemos_shield_esp32_4MB_S]
extends = wemos_shield_esp32_4MB_S_base
build_flags = ${wemos_shield_esp32_4MB_S_base.build_flags}
-D WLED_RELEASE_NAME=wemos_shield_esp32_4MB_S

[env:wemos_shield_esp32_4MB_M]
extends = wemos_shield_esp32_4MB_M_base
build_flags = ${wemos_shield_esp32_4MB_M_base.build_flags}
Expand Down Expand Up @@ -2006,6 +2025,13 @@ build_unflags = ${common.build_unflags} ${Shield_LineIn.build_unflags}
build_flags = ${wemos_shield_esp32_4MB_M_base.build_flags} ${Shield_LineIn.build_flags}
-D WLED_RELEASE_NAME=wemos_shield_esp32_4MB_LineIn_M

[env:wemos_shield_esp32_16MB_S]
extends = wemos_shield_esp32_4MB_S_base
build_flags = ${wemos_shield_esp32_4MB_S_base.build_flags}
-D WLED_RELEASE_NAME=wemos_shield_esp32_16MB_S
board = esp32_16MB
board_build.partitions = tools/WLED_ESP32_16MB.csv ;; WLED standard for 16MB flash: 2MB firmware, 12 MB filesystem

[env:wemos_shield_esp32_16MB_M]
extends = wemos_shield_esp32_4MB_M_base
build_flags = ${wemos_shield_esp32_4MB_M_base.build_flags}
Expand Down Expand Up @@ -2065,6 +2091,7 @@ board = esp32_16MB
board_build.partitions = tools/WLED_ESP32_16MB.csv ;; WLED standard for 16MB flash: 2MB firmware, 12 MB filesystem
;board_build.partitions = tools/WLED_ESP32_16MB_9MB_FS.csv ;; WLED extended for 16MB flash: 3.2MB firmware, 9 MB filesystem

;https://www.athom.tech/blank-1/wled-esp32-music-addressable-led-strip-controller
[env:athom_music_esp32_4MB_M]
extends = esp32_4MB_M_base
build_flags = ${esp32_4MB_M_base.build_flags} ${Athom_PDMmic.build_flags}
Expand All @@ -2084,6 +2111,29 @@ build_flags = ${esp32_4MB_M_base.build_flags} ${Athom_PDMmic.build_flags}
; -D PWM_PIN=-1
; -D WLED_USE_MY_CONFIG

;https://shop.myhome-control.de/Elektronik/
[env:abc_wled_controller_v43_S]
extends = esp32_4MB_S_base
build_unflags = ${esp32_4MB_S_base.build_unflags} ${common_mm.build_disable_sync_interfaces}
build_flags = ${esp32_4MB_S_base.build_flags}
-D WLED_RELEASE_NAME=abc_wled_controller_v43_M

-D LEDPIN=16
-D ABL_MILLIAMPS_DEFAULT=5000 ; 5A default. Max 13A depending on the wires connected

-D WLED_USE_ETHERNET
-D WLED_ETH_DEFAULT=9 ; ABC! WLED V43 & compatible
-D RLYPIN=-1 -D BTNPIN=-1 ;; Prevent clash
-D WLED_DISABLE_ESPNOW ;; ESP-NOW requires wifi, may crash with ethernet only

-D AUDIOPIN=-1
-D FLD_PIN_SCL=-1 -D FLD_PIN_SDA=-1 ; use global!

; -D WLED_USE_MY_CONFIG
-D SR_DMTYPE=4 -D I2S_SDPIN=32 -D I2S_WSPIN=15 -D I2S_CKPIN=14 -D MCLK_PIN=0 ; generic i2s with mclk 0
-D SR_SQUELCH=1 -D SR_GAIN=60 ; increrase squelch if noise, in test 0 is okay, but only slightly
-D SR_FREQ_PROF=1 ; Generic line in

; ESP32 WLED pico board with builtin ICS-43432 microphpone
[env:esp32_pico_4MB_M]
extends = esp32_4MB_M_base
Expand Down
4 changes: 2 additions & 2 deletions usermods/Battery/battery_defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

// auto-off feature
#ifndef USERMOD_BATTERY_AUTO_OFF_ENABLED
#define USERMOD_BATTERY_AUTO_OFF_ENABLED true
#define USERMOD_BATTERY_AUTO_OFF_ENABLED false
#endif

#ifndef USERMOD_BATTERY_AUTO_OFF_THRESHOLD
Expand All @@ -78,4 +78,4 @@

#ifndef USERMOD_BATTERY_LOW_POWER_INDICATOR_DURATION
#define USERMOD_BATTERY_LOW_POWER_INDICATOR_DURATION 5
#endif
#endif
26 changes: 26 additions & 0 deletions usermods/LDR_Dusk_Dawn_v2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# LDR_Dusk_Dawn_v2
This usermod will obtain readings from a Light Dependent Resistor (LDR) and will turn on/off specific presets based on those readings. This is useful for exterior lighting situations where you want the lights to only be on when it is dark out.

# Installation
Add "-D USERMOD_LDR_DUSK_DAWN" to your platformio.ini [common] build_flags and build.

Example:
```
[common]
build_flags =
-D USERMOD_LDR_DUSK_DAWN # Enable LDR Dusk Dawn Usermod
```

# Usermod Settings
Setting | Description | Default
--- | --- | ---
Enabled | Enable/Disable the LDR functionality. | Disabled
LDR Pin | The analog capable pin your LDR is connected to. | 34
Threshold Minutes | The number of minutes of consistent readings above/below the on/off threshold before the LED state will change. | 5
Threshold | The analog read value threshold from the LDR. Readings lower than this number will count towards changing the LED state to off. You can see the current LDR reading by going into the info section when LDR functionality is enabled. | 1000
On Preset | The WLED preset to be used for the LED on state. | 1
Off Preset | The WLED preset to be used for the LED off state. | 2

## Author
[@jeffwdh](https://github.com/jeffwdh)
[email protected]
126 changes: 126 additions & 0 deletions usermods/LDR_Dusk_Dawn_v2/usermod_LDR_Dusk_Dawn_v2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#pragma once
#include "wled.h"

class LDR_Dusk_Dawn_v2 : public Usermod {
private:
// Defaults
bool ldrEnabled = false;
int ldrPin = 34; //A2 on Adafruit Huzzah32
int ldrThresholdMinutes = 5; // How many minutes of readings above/below threshold until it switches LED state
int ldrThreshold = 1000; // Readings higher than this number will turn off LED.
int ldrOnPreset = 1; // Default "On" Preset
int ldrOffPreset = 2; // Default "Off" Preset

// Variables
bool ldrEnabledPreviously = false; // Was LDR enabled for the previous check? First check is always no.
int ldrOffCount; // Number of readings above the threshold
int ldrOnCount; // Number of readings below the threshold
int ldrReading; // Last LDR reading
int ldrLEDState; // Current LED on/off state
unsigned long lastMillis = 0;
static const char _name[];

public:
void setup() {
}

void loop() {
// Only update every 10 seconds
if (millis() - lastMillis > 10000) {
if (ldrEnabled == true) {
// Default state is off
if (ldrEnabledPreviously == false) {
applyPreset(ldrOffPreset);
ldrEnabledPreviously = true;
ldrLEDState = 0;
}

// Get LDR reading and increment counter by number of seconds since last read
ldrReading = analogRead(ldrPin);
if (ldrReading <= ldrThreshold) {
ldrOnCount = ldrOnCount + 10;
ldrOffCount = 0;
} else {
ldrOffCount = ldrOffCount + 10;
ldrOnCount = 0;
}

if (ldrOnCount >= (ldrThresholdMinutes * 60)) {
ldrOnCount = 0;
// If LEDs were previously off, turn on
if (ldrLEDState == 0) {
applyPreset(ldrOnPreset);
ldrLEDState = 1;
}
}

if (ldrOffCount >= (ldrThresholdMinutes * 60)) {
ldrOffCount = 0;
// If LEDs were previously on, turn off
if (ldrLEDState == 1) {
applyPreset(ldrOffPreset);
ldrLEDState = 0;
}
}
} else {
// LDR is disabled, reset variables to default
ldrReading = 0;
ldrOnCount = 0;
ldrOffCount = 0;
ldrLEDState = 0;
ldrEnabledPreviously = false;
}
lastMillis = millis();
}
}

void addToConfig(JsonObject& root) {
JsonObject top = root.createNestedObject(FPSTR(_name));
top["Enabled"] = ldrEnabled;
top["LDR Pin"] = ldrPin;
top["Threshold Minutes"] = ldrThresholdMinutes;
top["Threshold"] = ldrThreshold;
top["On Preset"] = ldrOnPreset;
top["Off Preset"] = ldrOffPreset;
}

bool readFromConfig(JsonObject& root) {
JsonObject top = root[FPSTR(_name)];
bool configComplete = !top.isNull();
configComplete &= getJsonValue(top["Enabled"], ldrEnabled);
configComplete &= getJsonValue(top["LDR Pin"], ldrPin);
configComplete &= getJsonValue(top["Threshold Minutes"], ldrThresholdMinutes);
configComplete &= getJsonValue(top["Threshold"], ldrThreshold);
configComplete &= getJsonValue(top["On Preset"], ldrOnPreset);
configComplete &= getJsonValue(top["Off Preset"], ldrOffPreset);
return configComplete;
}

void addToJsonInfo(JsonObject& root) {
// If "u" object does not exist yet we need to create it
JsonObject user = root["u"];
if (user.isNull()) user = root.createNestedObject("u");

JsonArray LDR_Enabled = user.createNestedArray("LDR dusk/dawn enabled");
LDR_Enabled.add(ldrEnabled);

JsonArray LDR_Reading = user.createNestedArray("LDR reading");
LDR_Reading.add(ldrReading);

JsonArray LDR_State = user.createNestedArray("LDR turned LEDs on");
LDR_State.add(bool(ldrLEDState));

// Optional debug information:
//JsonArray LDR_On_Count = user.createNestedArray("LDR on count");
//LDR_On_Count.add(ldrOnCount);

//JsonArray LDR_Off_Count = user.createNestedArray("LDR off count");
//LDR_Off_Count.add(ldrOffCount);
}

uint16_t getId() {
return USERMOD_ID_LDR_DUSK_DAWN;
}
};

const char LDR_Dusk_Dawn_v2::_name[] PROGMEM = "LDR_Dusk_Dawn_v2";
Loading

0 comments on commit c300493

Please sign in to comment.