Merge branch 'MoonModules:mdev' into mdev

This commit is contained in:
tonyxforce
2023-08-24 23:50:11 +02:00
committed by GitHub
3 changed files with 45 additions and 10 deletions

View File

@@ -1247,6 +1247,8 @@ build_flags = ${common.build_flags_esp8266}
;; -D WLED_DISABLE_INFRARED ;RAM 136 bytes; FLASH 24492 bytes
; -D WLED_DISABLE_2D
; -UWLED_USE_MY_CONFIG
-D WLED_DEBUG_HOST='"192.168.x.x"' ;; to send debug messages over network to host 192.168.x.y - FQDN is also possible
-D WLED_DEBUG_PORT=1768 ;; port for network debugging. default = 7868
; -D WLED_DEBUG
; monitor_filters = esp8266_exception_decoder
;; lib_ignore = IRremoteESP8266 ; use with WLED_DISABLE_INFRARED for faster compilation
@@ -1267,6 +1269,8 @@ build_flags = ${common.build_flags_esp8266}
;; -D WLED_DISABLE_INFRARED ;RAM 136 bytes; FLASH 24492 bytes
; -D WLED_DISABLE_2D
; -UWLED_USE_MY_CONFIG
-D WLED_DEBUG_HOST='"192.168.x.x"' ;; to send debug messages over network to host 192.168.x.y - FQDN is also possible
-D WLED_DEBUG_PORT=1768 ;; port for network debugging. default = 7868
; -D WLED_DEBUG
; monitor_filters = esp8266_exception_decoder
;; lib_ignore = IRremoteESP8266 ; use with WLED_DISABLE_INFRARED for faster compilation
@@ -1350,6 +1354,8 @@ build_flags = ${common.build_flags_esp8266}
-D WLED_DISABLE_ALEXA
-D WLED_DISABLE_HUESYNC
; -D WLED_DEBUG ${common.debug_flags} ;; un-comment for debug messages
-D WLED_DEBUG_HOST='"192.168.x.x"' ;; to send debug messages over network to host 192.168.x.y - FQDN is also possible
-D WLED_DEBUG_PORT=1768 ;; port for network debugging. default = 7868
;; -D WLED_DISABLE_ESPNOW ;; might help in case of WiFi connectivity problems
; -D WLED_DISABLE_LOXONE ; FLASH 1272 bytes
; -D WLED_DISABLE_MQTT ; RAM 216 bytes; FLASH 16496 bytes
@@ -1389,6 +1395,8 @@ build_flags = ${common.build_flags_esp8266}
-D USERMOD_FOUR_LINE_DISPLAY
-D USERMOD_MPU6050_IMU ; gyro/accelero for USERMOD_GAMES (ONLY WORKS IF USERMOD_FOUR_LINE_DISPLAY NOT INCLUDED - I2C SHARING BUG)
-D USERMOD_GAMES ; WLEDMM usermod
-D WLED_DEBUG_HOST='"192.168.x.x"' ;; to send debug messages over network to host 192.168.x.y - FQDN is also possible
-D WLED_DEBUG_PORT=1768 ;; port for network debugging. default = 7868
; -D WLED_DEBUG
monitor_filters = esp8266_exception_decoder
lib_deps = ${esp8266.lib_deps}

View File

@@ -37,7 +37,7 @@
#endif
// high-resolution type for input filters
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
#if defined(ARDUINO_ARCH_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
#define SR_HIRES_TYPE double // ESP32 and ESP32-S3 (with FPU) are fast enough to use "double"
#else
#define SR_HIRES_TYPE float // prefer faster type on slower boards (-S2, -C3)
@@ -987,11 +987,11 @@ class AudioReactive : public Usermod {
const uint16_t delayMs = 10; // I don't want to sample too often and overload WLED
uint16_t audioSyncPort= 11988;// default port for UDP sound sync
#ifdef ARDUINO_ARCH_ESP32
// used for AGC
int last_soundAgc = -1; // used to detect AGC mode change (for resetting AGC internal error buffers)
double control_integrated = 0.0; // persistent across calls to agcAvg(); "integrator control" = accumulated error
#ifdef ARDUINO_ARCH_ESP32
// variables used by getSample() and agcAvg()
int16_t micIn = 0; // Current sample starts with negative values and large values, which is why it's 16 bit signed
double sampleMax = 0.0; // Max sample over a few seconds. Needed for AGC controler.
@@ -1018,7 +1018,7 @@ class AudioReactive : public Usermod {
static const char _name[];
static const char _enabled[];
static const char _inputLvl[];
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3)
#if defined(ARDUINO_ARCH_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3)
static const char _analogmic[];
#endif
static const char _digitalmic[];
@@ -1724,11 +1724,11 @@ class AudioReactive : public Usermod {
delay(250); // give microphone enough time to initialise
if (!audioSource) enabled = false; // audio failed to initialise
if (FFT_Task == nullptr) enabled = false; // FFT task creation failed
#endif
if (enabled) onUpdateBegin(false); // create FFT task
if (enabled) disableSoundProcessing = false; // all good - enable audio processing
if (enabled) onUpdateBegin(false); // create FFT task, and initailize network
#ifdef ARDUINO_ARCH_ESP32
if (FFT_Task == nullptr) enabled = false; // FFT task creation failed
if((!audioSource) || (!audioSource->isInitialized())) { // audio source failed to initialize. Still stay "enabled", as there might be input arriving via UDP Sound Sync
#ifdef WLED_DEBUG
DEBUG_PRINTLN(F("AR: Failed to initialize sound input driver. Please check input PIN settings."));
@@ -1740,12 +1740,16 @@ class AudioReactive : public Usermod {
USER_PRINTLN(F("AR: sound input driver initialized successfully."));
}
#endif
if (enabled) disableSoundProcessing = false; // all good - enable audio processing
// try to start UDP
last_UDPTime = 0;
receivedFormat = 0;
delay(100);
if (enabled) connectUDPSoundSync();
initDone = true;
DEBUGSR_PRINT(F("AR: init done, enabled = "));
DEBUGSR_PRINTLN(enabled ? F("true.") : F("false."));
USER_FLUSH();
}
@@ -1995,7 +1999,7 @@ class AudioReactive : public Usermod {
memset(fftAvg, 0, sizeof(fftAvg));
memset(fftResult, 0, sizeof(fftResult));
for(int i=(init?0:1); i<NUM_GEQ_CHANNELS; i+=2) fftResult[i] = 16; // make a tiny pattern
inputLevel = 128; // resset level slider to default
inputLevel = 128; // reset level slider to default
autoResetPeak();
if (init && FFT_Task) {
@@ -2029,7 +2033,30 @@ class AudioReactive : public Usermod {
if (enabled) disableSoundProcessing = false;
}
#else // reduced function for 8266
void onUpdateBegin(bool init)
{
// gracefully suspend audio (if running)
disableSoundProcessing = true;
// reset sound data
volumeRaw = 0; volumeSmth = 0;
for(int i=(init?0:1); i<NUM_GEQ_CHANNELS; i+=2) fftResult[i] = 16; // make a tiny pattern
autoResetPeak();
if (init) {
if (udpSyncConnected) { // close UDP sync connection (if open)
udpSyncConnected = false;
fftUdp.stop();
DEBUGSR_PRINTLN(F("AR onUpdateBegin(true): UDP connection closed."));
receivedFormat = 0;
}
}
yield(); // to make sure that Wifi stays alive
if (enabled) disableSoundProcessing = false;
}
#endif
#ifdef ARDUINO_ARCH_ESP32
/**
* handleButton() can be used to override default button behaviour. Returning true
* will prevent button working in a default way.
@@ -2318,7 +2345,7 @@ class AudioReactive : public Usermod {
poweruser[F("micLev")] = micLevelMethod;
poweruser[F("freqDist")] = freqDist;
poweruser[F("freqRMS")] = averageByRMS;
JsonObject freqScale = top.createNestedObject("frequency");
freqScale[F("scale")] = FFTScalingMode;
freqScale[F("profile")] = pinkIndex; //WLEDMM
@@ -2642,7 +2669,7 @@ class AudioReactive : public Usermod {
const char AudioReactive::_name[] PROGMEM = "AudioReactive";
const char AudioReactive::_enabled[] PROGMEM = "enabled";
const char AudioReactive::_inputLvl[] PROGMEM = "inputLevel";
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3)
#if defined(ARDUINO_ARCH_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3)
const char AudioReactive::_analogmic[] PROGMEM = "analogmic";
#endif
const char AudioReactive::_digitalmic[] PROGMEM = "digitalmic";

View File

@@ -8,7 +8,7 @@
*/
// version code in format yymmddb (b = daily build)
#define VERSION 2308220
#define VERSION 2308240
//uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG