diff --git a/platformio.ini b/platformio.ini index 50f8a570..33944cbc 100644 --- a/platformio.ini +++ b/platformio.ini @@ -32,9 +32,9 @@ ; default_envs = esp8285_4CH_MagicHome ; default_envs = esp8285_H801 ; default_envs = d1_mini_5CH_Shojo_PCB -; default_envs = esp32mdev +default_envs = esp32mdev ; default_envs = esp8266mdev -default_envs = wemos_shield_esp32 +; default_envs = wemos_shield_esp32 ; default_envs = m5atom ; default_envs = esp32_eth ; default_envs = esp32dev_qio80 @@ -454,7 +454,7 @@ 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] diff --git a/usermods/customeffects/arti.h b/usermods/customeffects/arti.h index 8953134c..c7ccc3aa 100644 --- a/usermods/customeffects/arti.h +++ b/usermods/customeffects/arti.h @@ -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"]; diff --git a/usermods/customeffects/arti_wled.h b/usermods/customeffects/arti_wled.h index 6d11639e..2187f75a 100644 --- a/usermods/customeffects/arti_wled.h +++ b/usermods/customeffects/arti_wled.h @@ -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 #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) { diff --git a/usermods/customeffects/customeffects.js b/usermods/customeffects/customeffects.js index 6b622a42..2423cac5 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
@@ -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); diff --git a/usermods/customeffects/usermod_v2_customeffects.h b/usermods/customeffects/usermod_v2_customeffects.h index c70df15e..6664eab9 100644 --- a/usermods/customeffects/usermod_v2_customeffects.h +++ b/usermods/customeffects/usermod_v2_customeffects.h @@ -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: diff --git a/wled00/FX.h b/wled00/FX.h index c7f0d9b7..2c7a0e1d 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -596,6 +596,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); diff --git a/wled00/FX_2Dfcn.cpp b/wled00/FX_2Dfcn.cpp index e567e49f..fb581a24 100644 --- a/wled00/FX_2Dfcn.cpp +++ b/wled00/FX_2Dfcn.cpp @@ -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= 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" diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 9168965e..87ca94c0 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -466,15 +466,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); diff --git a/wled00/const.h b/wled00/const.h index 8ca505cf..663fab3b 100644 --- a/wled00/const.h +++ b/wled00/const.h @@ -80,7 +80,7 @@ #define USERMOD_ID_SI7021_MQTT_HA 29 //Usermod "usermod_si7021_mqtt_ha.h" #define USERMOD_ID_BME280 30 //Usermod "usermod_bme280.h #define USERMOD_ID_AUDIOREACTIVE 31 //Usermod "audioreactive.h" -#define USERMOD_ID_CUSTOMEFFECTS 32 //Usermod "usermod_v2_customeffects.h" +#define USERMOD_ID_CUSTOMEFFECTS 32 //Usermod "usermod_v2_customeffects.h" WLEDSR Custom Effects //Access point behavior #define AP_BEHAVIOR_BOOT_NO_CONN 0 //Open AP when no connection after boot diff --git a/wled00/data/index.htm b/wled00/data/index.htm index c9ddeaa3..083ceae4 100644 --- a/wled00/data/index.htm +++ b/wled00/data/index.htm @@ -51,7 +51,7 @@ setTimeout(()=>{h.appendChild(l)},100); - + @@ -386,6 +386,6 @@
- + diff --git a/wled00/data/index.js b/wled00/data/index.js index 09394232..8132f022 100644 --- a/wled00/data/index.js +++ b/wled00/data/index.js @@ -728,6 +728,7 @@ function populateSegments(s) `; + //WLEDSR Custom Effects let cusEff = `
`; cn += `