diff --git a/usermods/audioreactive/audio_reactive.h b/usermods/audioreactive/audio_reactive.h index 709a59600e..1c46e33abf 100644 --- a/usermods/audioreactive/audio_reactive.h +++ b/usermods/audioreactive/audio_reactive.h @@ -2352,6 +2352,11 @@ class AudioReactive : public Usermod { #endif } +#if defined(_MoonModules_WLED_) && defined(WLEDMM_FASTPATH) + void loop2(void) { + loop(); + } +#endif bool getUMData(um_data_t **data) { diff --git a/wled00/fcn_declare.h b/wled00/fcn_declare.h index 09f9724b4f..31b82293ff 100644 --- a/wled00/fcn_declare.h +++ b/wled00/fcn_declare.h @@ -299,6 +299,7 @@ class Usermod { virtual ~Usermod() { if (um_data) delete um_data; } virtual void setup() = 0; // pure virtual, has to be overriden virtual void loop() = 0; // pure virtual, has to be overriden + virtual void loop2() {} // WLEDMM called just before effects will be processed virtual void handleOverlayDraw() {} // called after all effects have been processed, just before strip.show() virtual bool handleButton(uint8_t b) { return false; } // button overrides are possible here virtual bool getUMData(um_data_t **data) { if (data) *data = nullptr; return false; }; // usermod data exchange [see examples for audio effects] @@ -329,6 +330,7 @@ class UsermodManager { public: void loop(); + void loop2(); // WLEDMM loop just before drawing effects (presets and everything already handled) void handleOverlayDraw(); bool handleButton(uint8_t b); bool getUMData(um_data_t **um_data, uint8_t mod_id = USERMOD_ID_RESERVED); // USERMOD_ID_RESERVED will poll all usermods diff --git a/wled00/um_manager.cpp b/wled00/um_manager.cpp index 2fe44db96a..45647d607e 100644 --- a/wled00/um_manager.cpp +++ b/wled00/um_manager.cpp @@ -9,6 +9,7 @@ void UsermodManager::connected() { for (byte i = 0; i < numMods; i++) um void UsermodManager::loop() { for (byte i = 0; i < numMods; i++) ums[i]->loop(); } void UsermodManager::handleOverlayDraw() { for (byte i = 0; i < numMods; i++) ums[i]->handleOverlayDraw(); } // void UsermodManager::appendConfigData() { for (byte i = 0; i < numMods; i++) ums[i]->appendConfigData(); } //WLEDMM not used +void UsermodManager::loop2() { for (unsigned i = 0; i < numMods; i++) ums[i]->loop2(); } bool UsermodManager::handleButton(uint8_t b) { bool overrideIO = false; for (byte i = 0; i < numMods; i++) { diff --git a/wled00/wled.cpp b/wled00/wled.cpp index 52eb569a6d..41e04d1ad3 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -213,6 +213,19 @@ void WLED::loop() handlePresets(); yield(); +#if defined(_MoonModules_WLED_) && defined(WLEDMM_FASTPATH) + #ifdef WLED_DEBUG + unsigned long usermod2Millis = millis(); + #endif + usermods.loop2(); + #ifdef WLED_DEBUG + usermod2Millis = millis() - usermod2Millis; + avgUsermodMillis += usermod2Millis; + if (usermod2Millis > maxUsermodMillis) maxUsermodMillis = usermod2Millis; + #endif + yield(); +#endif + #ifdef WLED_DEBUG unsigned long stripMillis = millis(); #endif diff --git a/wled00/wled.h b/wled00/wled.h index 9bfd7dd1cb..82116ee6b9 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2409060 +#define VERSION 2409210 // WLEDMM - you can check for this define in usermods, to only enabled WLEDMM specific code in the "right" fork. Its not defined in AC WLED. #define _MoonModules_WLED_