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!
This commit is contained in:
Ewoud
2022-12-16 14:07:30 +01:00
parent ffe52fcbf5
commit 27bbccc314
7 changed files with 33 additions and 17 deletions

4
package-lock.json generated
View File

@@ -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",

View File

@@ -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": {

View File

@@ -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"];

View File

@@ -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; i<SEGLEN-1; i++)
@@ -231,6 +244,9 @@ float ARTI::arti_external_function(uint8_t function, float par1, float par2, flo
case F_segcolor:
return par1;
case F_fftResult:
return par1;
case F_shift:
PRINT_ARTI("%s(%f)\n", "shift", par1);
return floatNull;
@@ -350,14 +366,14 @@ float ARTI::arti_get_external_variable(uint8_t variable, float par1, float par2,
return SEGMENT.custom2;
case F_custom3Slider:
return SEGMENT.custom3;
case F_sampleAvg:
case F_volume:
{
um_data_t *um_data;
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
// add support for no audio
um_data = simulateSound(SEGMENT.soundSim);
}
float volumeSmth = *(float*) um_data->u_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;

View File

@@ -100,7 +100,7 @@ function populateCEEditor(name, segID)
<button class="btn infobtn" onclick="saveCE('${name}.wled', ${segID})">Save and Run</button><br>
<button class="btn infobtn" onclick="downloadCEFile('${name}.wled')">Download ${name}.wled</button>
<button class="btn infobtn" onclick="loadCETemplate('${name}')">Load template</button><br>
<button class="btn infobtn" onclick="downloadCEFile('wledv032.json')">Download wled json</button>
<button class="btn infobtn" onclick="downloadCEFile('wledv033.json')">Download wled json</button>
<button class="btn infobtn" onclick="downloadCEFile('presets.json')">Download presets.json</button><br>
<a href="https://github.com/MoonModules/WLED-Effects/tree/master/CustomEffects/wled" target="_blank">Custom Effects Library</a><br>
<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) {
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);

View File

@@ -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:

View File

@@ -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