From 511cb2362a43f81b3ce135f11159e2ccab265381 Mon Sep 17 00:00:00 2001 From: Ewoud Date: Tue, 15 Aug 2023 16:02:14 +0200 Subject: [PATCH] Post merge AppEffects: - add 1D/2D to name (temporary) - GEQ 2D rename check1/check2 - rename parameters to controls UserModWLEDAudio - default not ebabled - use onOffChanged --- src/App/AppEffects.h | 22 +++++++++++----------- src/App/AppModLeds.h | 8 ++++---- src/User/UserModWLEDAudio.h | 19 +++++++++++++------ 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/App/AppEffects.h b/src/App/AppEffects.h index 323c53db..d11eadbc 100644 --- a/src/App/AppEffects.h +++ b/src/App/AppEffects.h @@ -467,7 +467,7 @@ class RingEffect:public Effect { class RingRandomFlow:public RingEffect { public: const char * name() { - return "RingRandomFlow"; + return "RingRandomFlow 1D"; } void setup() {} void loop() { @@ -490,7 +490,7 @@ class GEQEffect:public Effect { byte previousBarHeight[1024]; const char * name() { - return "GEQ"; + return "GEQ 2D"; } void setup() { @@ -512,8 +512,8 @@ class GEQEffect:public Effect { uint8_t speed = mdl->getValue("speed"); uint8_t intensity = mdl->getValue("intensity"); - bool check1 = mdl->getValue("check1"); - bool check2 = mdl->getValue("check2"); + bool colorBars = mdl->getValue("colorBars"); + bool smoothBars = mdl->getValue("smoothBars"); bool rippleTime = false; if (millis() - step >= (256U - intensity)) { @@ -542,7 +542,7 @@ class GEQEffect:public Effect { uint16_t bandHeight = fftResult[frBand]; // WLEDMM we use the original ffResult, to preserve accuracy // WLEDMM begin - smooth out bars - if ((x > 0) && (x < (cols-1)) && (check2)) { + if ((x > 0) && (x < (cols-1)) && (smoothBars)) { // get height of next (right side) bar uint8_t nextband = (remaining < 1)? band +1: band; nextband = constrain(nextband, 0, 15); // just to be sure @@ -562,7 +562,7 @@ class GEQEffect:public Effect { CRGB ledColor = CRGB::Black; for (int y=0; y < barHeight; y++) { - if (check1) //color_vertical / color bars toggle + if (colorBars) //color_vertical / color bars toggle colorIndex = map(y, 0, rows-1, 0, 255); CRGBPalette16 palette = PartyColors_p; @@ -579,11 +579,11 @@ class GEQEffect:public Effect { } } - bool parameters(JsonObject parentVar) { + bool controls(JsonObject parentVar) { ui->initNumber(parentVar, "speed", 255, false); ui->initNumber(parentVar, "intensity", 255, false); - ui->initCheckBox(parentVar, "check1", false, false); - ui->initCheckBox(parentVar, "check2", false, false); + ui->initCheckBox(parentVar, "colorBars", false, false); // + ui->initCheckBox(parentVar, "smoothBars", false, false); // Nice an effect can register it's own DMX channel, but not a fan of repeating the range and type of the param @@ -600,7 +600,7 @@ class AudioRings:public RingEffect { public: const char * name() { - return "AudioRings"; + return "AudioRings 1D"; } void setup() {} @@ -614,7 +614,7 @@ class AudioRings:public RingEffect { void loop() { - for (int i = 0; i < 7; i++) { + for (int i = 0; i < 7; i++) { // 7 rings uint8_t val; if(INWARD) { diff --git a/src/App/AppModLeds.h b/src/App/AppModLeds.h index ddbeaadc..02199424 100644 --- a/src/App/AppModLeds.h +++ b/src/App/AppModLeds.h @@ -202,11 +202,11 @@ class AppModLeds:public Module { #endif #ifdef USERMOD_E131 - e131mod->addWatch(1, "bri", 256); - e131mod->addWatch(2, "fx", effects.size()); + e131mod->patchChannel(1, "bri", 255); //should be 256?? + e131mod->patchChannel(2, "fx", effects.size()); // //add these temporary to test remote changing of this values do not crash the system - // e131mod->addWatch(3, "projection", Projections::count); - // e131mod->addWatch(4, "ledFix", 5); //assuming 5!!! + // e131mod->patchChannel(3, "projection", Projections::count); + // e131mod->patchChannel(4, "ledFix", 5); //assuming 5!!! #endif print->print("%s %s %s\n", __PRETTY_FUNCTION__, name, success?"success":"failed"); diff --git a/src/User/UserModWLEDAudio.h b/src/User/UserModWLEDAudio.h index 5ae4bc42..df428976 100644 --- a/src/User/UserModWLEDAudio.h +++ b/src/User/UserModWLEDAudio.h @@ -1,9 +1,9 @@ /* @title StarMod - @file UserModExample.h - @date 20230730 - @repo https://github.com/ewoudwijma/StarMod - @Authors https://github.com/ewoudwijma/StarMod/commits/main + @file UserModWLEDAudio.h + @date 20230810 + @repo https://github.com/ewowi/StarMod + @Authors https://github.com/ewowi/StarMod/commits/main @Copyright (c) 2023 Github StarMod Commit Authors @license GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 */ @@ -21,6 +21,8 @@ class UserModWLEDAudio:public Module { UserModWLEDAudio() :Module("WLED Audio Sync Receiver") { print->print("%s %s\n", __PRETTY_FUNCTION__, name); + isEnabled = false; //default off + print->print("%s %s %s\n", __PRETTY_FUNCTION__, name, success?"success":"failed"); }; @@ -32,8 +34,13 @@ class UserModWLEDAudio:public Module { print->print("%s %s %s\n", __PRETTY_FUNCTION__, name, success?"success":"failed"); } - void connected() { - sync.begin(); + void onOffChanged() { + if (SysModModules::isConnected && isEnabled) { + print->print("%s %s\n", __PRETTY_FUNCTION__, name); + sync.begin(); + } else { + // sync.end();??? + } } void loop(){