Skip to content

Commit 27bbccc

Browse files
committed
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!
1 parent ffe52fc commit 27bbccc

File tree

7 files changed

+33
-17
lines changed

7 files changed

+33
-17
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wled",
3-
"version": "0.14.0.10",
3+
"version": "0.14.0.11",
44
"description": "Tools for WLED project",
55
"main": "tools/cdata.js",
66
"directories": {

usermods/customeffects/arti.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2506,9 +2506,9 @@ class ARTI {
25062506
JsonObject::iterator objectIterator = definitionJson.begin();
25072507
JsonObject metaData = objectIterator->value();
25082508
const char * version = metaData["version"];
2509-
if (strcmp(version, "v032") != 0)
2509+
if (strcmp(version, "v033") != 0)
25102510
{
2511-
ERROR_ARTI("Version of definition.json file (%s) should be v032.\nPress Download wled json\n", version);
2511+
ERROR_ARTI("Version of definition.json file (%s) should be v033.\nPress Download wled json\n", version);
25122512
return false;
25132513
}
25142514
const char * startNode = metaData["start"];

usermods/customeffects/arti_wled.h

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
@title Arduino Real Time Interpreter (ARTI)
3-
@file arti_wled_plugin.h
3+
@file arti_wled.h
44
@date 20220818
55
@author Ewoud Wijma
66
@repo https://github.com/ewoudwijma/ARTI
@@ -55,7 +55,8 @@ enum Externals
5555
F_custom1Slider,
5656
F_custom2Slider,
5757
F_custom3Slider,
58-
F_sampleAvg,
58+
F_volume,
59+
F_fftResult,
5960

6061
F_shift,
6162
F_circle2D,
@@ -146,6 +147,18 @@ float ARTI::arti_external_function(uint8_t function, float par1, float par2, flo
146147
case F_segcolor:
147148
return SEGCOLOR((uint8_t)par1);
148149

150+
case F_fftResult:
151+
{
152+
um_data_t *um_data;
153+
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
154+
// add support for no audio
155+
um_data = simulateSound(SEGMENT.soundSim);
156+
}
157+
uint8_t *fftResult = (uint8_t*)um_data->u_data[2];
158+
159+
return fftResult[(uint8_t)par1%16];
160+
}
161+
149162
case F_shift: {
150163
uint32_t saveFirstPixel = SEGMENT.getPixelColor(0);
151164
for (uint16_t i=0; i<SEGLEN-1; i++)
@@ -231,6 +244,9 @@ float ARTI::arti_external_function(uint8_t function, float par1, float par2, flo
231244
case F_segcolor:
232245
return par1;
233246

247+
case F_fftResult:
248+
return par1;
249+
234250
case F_shift:
235251
PRINT_ARTI("%s(%f)\n", "shift", par1);
236252
return floatNull;
@@ -350,14 +366,14 @@ float ARTI::arti_get_external_variable(uint8_t variable, float par1, float par2,
350366
return SEGMENT.custom2;
351367
case F_custom3Slider:
352368
return SEGMENT.custom3;
353-
case F_sampleAvg:
369+
case F_volume:
354370
{
355371
um_data_t *um_data;
356372
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
357373
// add support for no audio
358374
um_data = simulateSound(SEGMENT.soundSim);
359375
}
360-
float volumeSmth = *(float*) um_data->u_data[0]; //ewowi: use instead of sampleAvg???
376+
float volumeSmth = *(float*) um_data->u_data[0];
361377

362378
return volumeSmth;
363379
}
@@ -400,8 +416,8 @@ float ARTI::arti_get_external_variable(uint8_t variable, float par1, float par2,
400416
return F_custom2Slider;
401417
case F_custom3Slider:
402418
return F_custom3Slider;
403-
case F_sampleAvg:
404-
return F_sampleAvg;
419+
case F_volume:
420+
return F_volume;
405421

406422
case F_hour:
407423
return F_hour;

usermods/customeffects/customeffects.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ function populateCEEditor(name, segID)
100100
<button class="btn infobtn" onclick="saveCE('${name}.wled', ${segID})">Save and Run</button><br>
101101
<button class="btn infobtn" onclick="downloadCEFile('${name}.wled')">Download ${name}.wled</button>
102102
<button class="btn infobtn" onclick="loadCETemplate('${name}')">Load template</button><br>
103-
<button class="btn infobtn" onclick="downloadCEFile('wledv032.json')">Download wled json</button>
103+
<button class="btn infobtn" onclick="downloadCEFile('wledv033.json')">Download wled json</button>
104104
<button class="btn infobtn" onclick="downloadCEFile('presets.json')">Download presets.json</button><br>
105105
<a href="https://github.com/MoonModules/WLED-Effects/tree/master/CustomEffects/wled" target="_blank">Custom Effects Library</a><br>
106106
<a href="https://moonmodules.github.io/WLED-Docs/moonmodules/custom-effects" target="_blank">Custom Effects Help</a><br>
@@ -121,7 +121,7 @@ function downloadCEFile(name) {
121121
var url = "https://raw.githubusercontent.com/MoonModules/WLED-Effects/master/CustomEffects/wled/";
122122

123123
fetchAndExecute(url, name, function(text) {
124-
if (name == "wledv032.json" || name == "presets.json") {
124+
if (name == "wledv033.json" || name == "presets.json") {
125125
if (!confirm('Are you sure to download/overwrite ' + name + '?'))
126126
return;
127127
uploadFileWithText("/" + name, text);
@@ -137,7 +137,7 @@ function downloadCEFile(name) {
137137

138138
var request = new XMLHttpRequest();
139139
request.onload = function() {
140-
if (name == "wledv032.json" || name == "presets.json") {
140+
if (name == "wledv033.json" || name == "presets.json") {
141141
if (!confirm('Are you sure to download ' + name + '?'))
142142
return;
143143
uploadFileWithText("/" + name, request.response);

usermods/customeffects/usermod_v2_customeffects.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ uint16_t mode_customEffect(void) {
4242
strcat(programFileName, currentEffect);
4343
strcat(programFileName, ".wled");
4444

45-
succesful = arti->setup("/wledv032.json", programFileName);
45+
succesful = arti->setup("/wledv033.json", programFileName);
4646

4747
if (!succesful)
4848
ERROR_ARTI("Setup not succesful\n");
@@ -90,7 +90,7 @@ uint16_t mode_customEffect(void) {
9090
return FRAMETIME;
9191
}
9292

93-
static const char _data_FX_MODE_CUSTOMEFFECT[] PROGMEM = "⚙️ Custom Effect@Speed,Intensity,Custom 1, Custom 2, Custom 3;!;!;mp12=0,1d";
93+
static const char _data_FX_MODE_CUSTOMEFFECT[] PROGMEM = "⚙️ Custom Effect@Speed,Intensity,Custom 1, Custom 2, Custom 3;!;!;1d;mp12=0";
9494

9595
class CustomEffectsUserMod : public Usermod {
9696
private:

wled00/wled.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
// version code in format yymmddb (b = daily build)
11-
#define VERSION 2212130
11+
#define VERSION 2212160
1212

1313
//uncomment this if you have a "my_config.h" file you'd like to use
1414
//#define WLED_USE_MY_CONFIG

0 commit comments

Comments
 (0)