From 27bbccc31448027ce9091fb3287301461a4fd6a9 Mon Sep 17 00:00:00 2001 From: Ewoud Date: Fri, 16 Dec 2022 14:07:30 +0100 Subject: [PATCH] Custom Effects: add fftResult Version 0.14.0.11 Custom Effects - Update to wledv033.json - change sampleAvg to volume - custom effects is 1d effect (to enable expand function), however 2D just possible! --- package-lock.json | 4 +-- package.json | 2 +- usermods/customeffects/arti.h | 4 +-- usermods/customeffects/arti_wled.h | 28 +++++++++++++++---- usermods/customeffects/customeffects.js | 6 ++-- .../customeffects/usermod_v2_customeffects.h | 4 +-- wled00/wled.h | 2 +- 7 files changed, 33 insertions(+), 17 deletions(-) diff --git a/package-lock.json b/package-lock.json index bb7e63ce..0fc32533 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "wled", - "version": "0.14.0.10", + "version": "0.14.0.11", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "wled", - "version": "0.14.0.10", + "version": "0.14.0.11", "license": "ISC", "dependencies": { "clean-css": "^4.2.3", diff --git a/package.json b/package.json index 467e49c0..81f5a07c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wled", - "version": "0.14.0.10", + "version": "0.14.0.11", "description": "Tools for WLED project", "main": "tools/cdata.js", "directories": { diff --git a/usermods/customeffects/arti.h b/usermods/customeffects/arti.h index 4822ee63..80a823f5 100644 --- a/usermods/customeffects/arti.h +++ b/usermods/customeffects/arti.h @@ -2506,9 +2506,9 @@ public: JsonObject::iterator objectIterator = definitionJson.begin(); JsonObject metaData = objectIterator->value(); const char * version = metaData["version"]; - if (strcmp(version, "v032") != 0) + if (strcmp(version, "v033") != 0) { - ERROR_ARTI("Version of definition.json file (%s) should be v032.\nPress Download wled json\n", version); + ERROR_ARTI("Version of definition.json file (%s) should be v033.\nPress Download wled json\n", version); return false; } const char * startNode = metaData["start"]; diff --git a/usermods/customeffects/arti_wled.h b/usermods/customeffects/arti_wled.h index acff001e..f8dea622 100644 --- a/usermods/customeffects/arti_wled.h +++ b/usermods/customeffects/arti_wled.h @@ -1,6 +1,6 @@ /* @title Arduino Real Time Interpreter (ARTI) - @file arti_wled_plugin.h + @file arti_wled.h @date 20220818 @author Ewoud Wijma @repo https://github.com/ewoudwijma/ARTI @@ -55,7 +55,8 @@ enum Externals F_custom1Slider, F_custom2Slider, F_custom3Slider, - F_sampleAvg, + F_volume, + F_fftResult, F_shift, F_circle2D, @@ -146,6 +147,18 @@ float ARTI::arti_external_function(uint8_t function, float par1, float par2, flo case F_segcolor: return SEGCOLOR((uint8_t)par1); + case F_fftResult: + { + um_data_t *um_data; + if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) { + // add support for no audio + um_data = simulateSound(SEGMENT.soundSim); + } + uint8_t *fftResult = (uint8_t*)um_data->u_data[2]; + + return fftResult[(uint8_t)par1%16]; + } + case F_shift: { uint32_t saveFirstPixel = SEGMENT.getPixelColor(0); for (uint16_t i=0; iu_data[0]; //ewowi: use instead of sampleAvg??? + float volumeSmth = *(float*) um_data->u_data[0]; return volumeSmth; } @@ -400,8 +416,8 @@ float ARTI::arti_get_external_variable(uint8_t variable, float par1, float par2, return F_custom2Slider; case F_custom3Slider: return F_custom3Slider; - case F_sampleAvg: - return F_sampleAvg; + case F_volume: + return F_volume; case F_hour: return F_hour; diff --git a/usermods/customeffects/customeffects.js b/usermods/customeffects/customeffects.js index 23aa162c..2e31e44b 100644 --- a/usermods/customeffects/customeffects.js +++ b/usermods/customeffects/customeffects.js @@ -100,7 +100,7 @@ function populateCEEditor(name, segID)

- +
Custom Effects Library
Custom Effects Help
@@ -121,7 +121,7 @@ function downloadCEFile(name) { var url = "https://raw.githubusercontent.com/MoonModules/WLED-Effects/master/CustomEffects/wled/"; fetchAndExecute(url, name, function(text) { - if (name == "wledv032.json" || name == "presets.json") { + if (name == "wledv033.json" || name == "presets.json") { if (!confirm('Are you sure to download/overwrite ' + name + '?')) return; uploadFileWithText("/" + name, text); @@ -137,7 +137,7 @@ function downloadCEFile(name) { var request = new XMLHttpRequest(); request.onload = function() { - if (name == "wledv032.json" || name == "presets.json") { + if (name == "wledv033.json" || name == "presets.json") { if (!confirm('Are you sure to download ' + name + '?')) return; uploadFileWithText("/" + name, request.response); diff --git a/usermods/customeffects/usermod_v2_customeffects.h b/usermods/customeffects/usermod_v2_customeffects.h index 5a53b9e5..5332c1b0 100644 --- a/usermods/customeffects/usermod_v2_customeffects.h +++ b/usermods/customeffects/usermod_v2_customeffects.h @@ -42,7 +42,7 @@ uint16_t mode_customEffect(void) { strcat(programFileName, currentEffect); strcat(programFileName, ".wled"); - succesful = arti->setup("/wledv032.json", programFileName); + succesful = arti->setup("/wledv033.json", programFileName); if (!succesful) ERROR_ARTI("Setup not succesful\n"); @@ -90,7 +90,7 @@ uint16_t mode_customEffect(void) { return FRAMETIME; } -static const char _data_FX_MODE_CUSTOMEFFECT[] PROGMEM = "⚙️ Custom Effect@Speed,Intensity,Custom 1, Custom 2, Custom 3;!;!;mp12=0,1d"; +static const char _data_FX_MODE_CUSTOMEFFECT[] PROGMEM = "⚙️ Custom Effect@Speed,Intensity,Custom 1, Custom 2, Custom 3;!;!;1d;mp12=0"; class CustomEffectsUserMod : public Usermod { private: diff --git a/wled00/wled.h b/wled00/wled.h index 8272ab62..1fbf39a0 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2212130 +#define VERSION 2212160 //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG