Merge branch 'custom-effects' into mdev

This commit is contained in:
Ewowi
2022-08-31 20:58:44 +02:00
12 changed files with 2026 additions and 1976 deletions

View File

@@ -33,6 +33,7 @@
; default_envs = esp8285_H801
; default_envs = d1_mini_5CH_Shojo_PCB
default_envs = esp32mdev
; default_envs = esp8266mdev
; default_envs = wemos_shield_esp32
; default_envs = m5atom
; default_envs = esp32_eth
@@ -454,14 +455,27 @@ build_flags = ${common.build_flags_esp32}
-D USERMOD_CUSTOMEFFECTS
lib_deps = ${esp32.lib_deps}
https://github.com/blazoncek/arduinoFFT.git ; arduinoFFT @ 1.5.6
; monitor_filters = esp32_exception_decoder
monitor_filters = esp32_exception_decoder
board_build.partitions = ${esp32.default_partitions}
[env:esp8266mdev]
extends = env:d1_mini
upload_speed = 460800 ;115200
build_flags = ${common.build_flags_esp8266}
-D WLED_DEBUG
-D WLED_DISABLE_ALEXA
-D WLED_DISABLE_BLYNK
-D WLED_DISABLE_HUESYNC
; -D WLED_DISABLE_2D
; -D WLED_DISABLE_AUDIO
; -D USERMOD_AUDIOREACTIVE
-UWLED_USE_MY_CONFIG
; monitor_filters = esp32_exception_decoder
[env:wemos_shield_esp32]
board = esp32dev
platform = espressif32@3.2
upload_speed = 460800
upload_speed = 460800 ; or 921600
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags_esp32}
-D LEDPIN=16
@@ -469,13 +483,20 @@ build_flags = ${common.build_flags_esp32}
-D BTNPIN=17
-D IRPIN=18
-D UWLED_USE_MY_CONFIG
-D USERMOD_DALLASTEMPERATURE
-D USERMOD_FOUR_LINE_DISPLAY
-D TEMPERATURE_PIN=23
-D USERMOD_DALLASTEMPERATURE -D TEMPERATURE_PIN=23
-D USE_ALT_DISPlAY
-D USERMOD_FOUR_LINE_DISPLAY -D FLD_PIN_SCL=22 -D FLD_PIN_SDA=21
-D USERMOD_ROTARY_ENCODER_UI -D ENCODER_DT_PIN=18 -D ENCODER_CLK_PIN=5 -D ENCODER_SW_PIN=19
-D USERMOD_AUDIOREACTIVE -D AUDIOPIN=-1 -D DMTYPE=1 -D I2S_SDPIN=32 -D I2S_WSPIN=15 -D I2S_CKPIN=14
-D USERMOD_CUSTOMEFFECTS
; -D WLED_DEBUG
-D USERMOD_AUTO_SAVE
lib_deps = ${esp32.lib_deps}
OneWire@~2.3.5
olikraus/U8g2 @ ^2.28.8
https://github.com/blazoncek/arduinoFFT.git ; arduinoFFT @ 1.5.6
board_build.partitions = ${esp32.default_partitions}
; board_build.partitions = tools/SoundReactive_ESP32_16MB.csv ; ESP32 16MB
[env:m5atom]
board = esp32dev

View File

@@ -1,7 +1,6 @@
/*
@title Arduino Real Time Interpreter (ARTI)
@file arti.h
@version 0.3.1
@date 20220818
@author Ewoud Wijma
@repo https://github.com/ewoudwijma/ARTI
@@ -2474,7 +2473,7 @@ public:
if (!definitionFile)
{
ERROR_ARTI("Definition file %s not found. Press Download wled.json\n", definitionName);
ERROR_ARTI("Definition file %s not found. Press Download wled json\n", definitionName);
return false;
}
@@ -2504,9 +2503,9 @@ public:
JsonObject::iterator objectIterator = definitionJson.begin();
JsonObject metaData = objectIterator->value();
const char * version = metaData["version"];
if (strcmp(version, "0.3.1") != 0)
if (strcmp(version, "v032") != 0)
{
ERROR_ARTI("Version of definition.json file (%s) should be 0.3.1.\nPress Download wled.json\n", version);
ERROR_ARTI("Version of definition.json file (%s) should be v032.\nPress Download wled json\n", version);
return false;
}
const char * startNode = metaData["start"];

View File

@@ -1,7 +1,6 @@
/*
@title Arduino Real Time Interpreter (ARTI)
@file arti_wled_plugin.h
@version 0.3.1
@date 20220818
@author Ewoud Wijma
@repo https://github.com/ewoudwijma/ARTI
@@ -28,15 +27,14 @@
#include <stdio.h>
#endif
//make sure the numbers here correspond to the order in which these functions are defined in wled.json!!
//make sure the numbers here correspond to the order in which these functions are defined in wled000.json!!
enum Externals
{
F_ledCount,
F_matrixWidth,
F_matrixHeight,
F_width,
F_height,
F_setPixelColor,
F_leds,
F_setPixels,
F_hsv,
F_rgbw,
@@ -61,6 +59,8 @@ enum Externals
F_shift,
F_circle2D,
F_drawLine,
F_drawArc,
F_constrain,
F_map,
@@ -103,14 +103,11 @@ float ARTI::arti_external_function(uint8_t function, float par1, float par2, flo
SEGMENT.setPixelColorXY((uint16_t)par1, (uint16_t)par2, (uint32_t)par3);
return floatNull;
}
case F_setPixels:
// setPixels(leds); No action needed as allready stored via sPC
return floatNull;
case F_hsv:
{
{
CRGB color = CHSV((uint8_t)par1, (uint8_t)par2, (uint8_t)par3);
return RGBW32(color.r, color.g, color.b, 0);
}
}
case F_rgbw:
return RGBW32((uint8_t)par1, (uint8_t)par2, (uint8_t)par3, (uint8_t)par4);
@@ -174,7 +171,15 @@ float ARTI::arti_external_function(uint8_t function, float par1, float par2, flo
int y = round(round((halfLength - cos(radians(par1)) * halfLength) * 10)/10) + deltaHeight;
return SEGMENT.XY(x,y);
}
case F_drawLine:
SEGMENT.drawLine(par1, par2, par3, par4, par5);
return floatNull;
case F_drawArc:
if (par5 == floatNull)
SEGMENT.drawArc(par1, par2, par3, par4);
else
SEGMENT.drawArc(par1, par2, par3, par4, par5); //fillColor
return floatNull;
case F_constrain:
return constrain(par1, par2, par3);
case F_map:
@@ -196,9 +201,6 @@ float ARTI::arti_external_function(uint8_t function, float par1, float par2, flo
case F_setPixelColor:
PRINT_ARTI("%s(%f, %f, %f)\n", "setPixelColor", par1, par2, par3);
return floatNull;
case F_setPixels:
PRINT_ARTI("%s\n", "setPixels(leds)");
return floatNull;
case F_hsv:
PRINT_ARTI("%s(%f, %f, %f)\n", "hsv", par1, par2, par3);
return par1 + par2 + par3;
@@ -235,6 +237,10 @@ float ARTI::arti_external_function(uint8_t function, float par1, float par2, flo
case F_circle2D:
PRINT_ARTI("%s(%f)\n", "circle2D", par1);
return par1 / 2;
case F_drawLine:
return par1 + par2 + par3 + par4 + par5;
case F_drawArc:
return par1 + par2 + par3 + par4 + par5;
case F_constrain:
return par1 + par2 + par3;
@@ -317,10 +323,10 @@ float ARTI::arti_get_external_variable(uint8_t variable, float par1, float par2,
{
case F_ledCount:
return SEGLEN;
case F_matrixWidth:
return strip.matrixWidth;
case F_matrixHeight:
return strip.matrixHeight;
case F_width:
return SEGMENT.virtualWidth();
case F_height:
return SEGMENT.virtualHeight();
case F_leds:
if (par1 == floatNull) {
ERROR_ARTI("arti_get_external_variable leds without indices not supported yet (get leds)\n");
@@ -367,9 +373,9 @@ float ARTI::arti_get_external_variable(uint8_t variable, float par1, float par2,
{
case F_ledCount:
return 3; // used in testing e.g. for i = 1 to ledCount
case F_matrixWidth:
case F_width:
return 2;
case F_matrixHeight:
case F_height:
return 4;
case F_leds:
if (par1 == floatNull) {

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('wled.json')">Download wled.json</button>
<button class="btn infobtn" onclick="downloadCEFile('wledv032.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://github.com/atuline/WLED/wiki/WLED-Custom-effects" target="_blank">Custom Effects Help</a><br>
@@ -122,7 +122,7 @@ function downloadCEFile(name) {
fetchAndExecute(url, name, function(text) {
console.log(text);
if (name == "wled.json" || name == "presets.json") {
if (name == "wledv032.json" || name == "presets.json") {
if (!confirm('Are you sure to download/overwrite ' + name + '?'))
return;
uploadFileWithText("/" + name, text);
@@ -138,7 +138,7 @@ function downloadCEFile(name) {
var request = new XMLHttpRequest();
request.onload = function() {
if (name == "wled.json" || name == "presets.json") {
if (name == "wledv032.json" || name == "presets.json") {
if (!confirm('Are you sure to download ' + name + '?'))
return;
uploadFileWithText("/" + name, request.response);

View File

@@ -41,7 +41,7 @@ uint16_t mode_customEffect(void) {
strcat(programFileName, currentEffect);
strcat(programFileName, ".wled");
succesful = arti->setup("/wled.json", programFileName);
succesful = arti->setup("/wledv032.json", programFileName);
if (!succesful)
ERROR_ARTI("Setup not succesful\n");
@@ -89,7 +89,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;!;!";
static const char _data_FX_MODE_CUSTOMEFFECT[] PROGMEM = "⚙️ Custom Effect@Speed,Intensity,Custom 1, Custom 2, Custom 3;!;!;mp12=0,1d";
class CustomEffectsUserMod : public Usermod {
private:

View File

@@ -593,6 +593,8 @@ typedef struct Segment {
void fill_circle(uint16_t cx, uint16_t cy, uint8_t radius, CRGB c);
void drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint32_t c);
void drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, CRGB c) { drawLine(x0, y0, x1, y1, RGBW32(c.r,c.g,c.b,0)); } // automatic inline
void drawArc(uint16_t x0, uint16_t y0, uint16_t radius, uint32_t color, uint32_t fillColor = 0);
void drawArc(uint16_t x0, uint16_t y0, uint16_t radius, CRGB color, CRGB fillColor = BLACK) { drawArc(x0, y0, radius, RGBW32(color.r,color.g,color.b,0), RGBW32(fillColor.r,fillColor.g,fillColor.b,0)); } // automatic inline
void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, uint32_t color);
void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, CRGB c) { drawCharacter(chr, x, y, w, h, RGBW32(c.r,c.g,c.b,0)); } // automatic inline
void wu_pixel(uint32_t x, uint32_t y, CRGB c);

View File

@@ -459,6 +459,29 @@ void Segment::drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint3
}
}
void Segment::drawArc(uint16_t x0, uint16_t y0, uint16_t radius, uint32_t color, uint32_t fillColor) {
// float step = degrees / (2.85f*MAX(radius,1));
// for (float rad = 0.0f; rad <= degrees+step/2; rad += step) {
// // may want to try float version as well (with or without antialiasing)
// int x = roundf(sin_t(rad) * radius);
// int y = roundf(cos_t(rad) * radius);
// setPixelColorXY(x+x0, y+y0, c);
// }
float minradius = radius - .5;
float maxradius = radius + .5;
for (int x=0; x<virtualWidth(); x++) for (int y=0; y<virtualHeight(); y++) {
int newX = x - x0;
int newY = y - y0;
if (newX*newX + newY*newY >= minradius * minradius && newX*newX + newY*newY <= maxradius * maxradius)
setPixelColorXY(x, y, color);
if (fillColor != 0)
if (newX*newX + newY*newY < minradius * minradius)
setPixelColorXY(x, y, fillColor);
}
}
#include "console_font_5x8.h"
#include "console_font_5x12.h"
#include "console_font_6x8.h"

View File

@@ -470,15 +470,8 @@ void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col)
// expand in circular fashion from center
if (i==0)
setPixelColorXY(0, 0, col);
else {
float step = HALF_PI / (2.85f*i);
for (float rad = 0.0f; rad <= HALF_PI+step/2; rad += step) {
// may want to try float version as well (with or without antialiasing)
int x = roundf(sin_t(rad) * i);
int y = roundf(cos_t(rad) * i);
setPixelColorXY(x, y, col);
}
}
else
drawArc(0, 0, i, col);
break;
case M12_pCorner:
for (int x = 0; x <= i; x++) setPixelColorXY(x, i, col);

View File

@@ -51,7 +51,7 @@
setTimeout(()=>{h.appendChild(l)},100);
</script>
<link rel="stylesheet" href="index.css">
<link rel="stylesheet" href="../../usermods/customeffects/customeffects.css">
<link rel="stylesheet" href="../../usermods/customeffects/customeffects.css"> <!--WLEDSR Custom Effects -->
</head>
<body>
@@ -386,6 +386,6 @@
</div>
<i id="roverstar" class="icons huge" onclick="setLor(0)">&#xe410;</i><br>
<script src="index.js"></script>
<script src="../../usermods/customeffects/customeffects.js"></script>
<script src="../../usermods/customeffects/customeffects.js"></script> <!--WLEDSR Custom Effects-->
</body>
</html>

View File

@@ -728,6 +728,8 @@ function populateSegments(s)
<option value="3" ${inst.ssim==3?' selected':''}>U14_3</option>
</select></div>
</div>`;
//WLEDSR Custom Effects
let fxName = eJson.find((o)=>{return o.id==selectedFx}).name;
let cusEff = `<button class="btn" onclick="toggleCEEditor('${inst.n?inst.n:"default"}', ${i})">Custom Effect Editor</button><br>`;
cn += `<div class="seg lstI ${i==s.mainseg ? 'selected' : ''} ${exp ? "expanded":""}" id="seg${i}">
<label class="check schkl">
@@ -775,7 +777,7 @@ function populateSegments(s)
${!isM?rvXck:''}
${isM&&stoY-staY>1&&stoX-staX>1?map2D:''}
${s.AudioReactive && s.AudioReactive.on ? "" : sndSim}
${s.CustomEffects && s.CustomEffects.on ? cusEff : ""}
${s.CustomEffects && s.CustomEffects.on && fxName.includes("Custom Effect") ? cusEff : ""}
<label class="check revchkl" id="seg${i}lbtm">
${isM?'Transpose':'Mirror effect'}
<input type="checkbox" id="seg${i}${isM?'tp':'mi'}" onchange="${(isM?'setTp(':'setMi(')+i})" ${isM?(inst.tp?"checked":""):(inst.mi?"checked":"")}>

File diff suppressed because it is too large Load Diff

View File

@@ -139,6 +139,7 @@
#include "../usermods/audioreactive/audio_reactive.h"
#endif
//WLEDSR Custom Effects
#ifdef USERMOD_CUSTOMEFFECTS
#include "../usermods/customeffects/usermod_v2_customeffects.h"
#endif
@@ -274,6 +275,7 @@ void registerUsermods()
usermods.add(new AudioReactive());
#endif
//WLEDSR Custom Effects
#ifdef USERMOD_CUSTOMEFFECTS
usermods.add(new CustomEffectsUserMod());
#endif