ARTIFX add support for pixelart + small changes

arti_wled.h:
- add jsonToPixels and frameTime
- change printf to print

usermod_v2_artifx
- return MAX(frameTime,FRAMETIME); 

FX.h and FX_2Dfcn.cpp
- add jsonToPixels

audioreactive.h
- ES8388 allow for default and add moon
This commit is contained in:
Ewoud
2023-04-05 13:22:50 +02:00
parent e4243c4d36
commit cae1c00467
7 changed files with 70 additions and 6 deletions

View File

@@ -86,12 +86,15 @@ enum Externals
F_square,
F_clamp,
F_printf
F_print,
F_jsonToPixels, //reorder only when creating new wledvxyz.json
F_frameTime
};
#if ARTI_PLATFORM != ARTI_ARDUINO
#define PI 3.141592654
#endif
uint32_t frameTime = 0;
float ARTI::arti_external_function(uint8_t function, float par1, float par2, float par3, float par4, float par5)
{
@@ -209,6 +212,10 @@ float ARTI::arti_external_function(uint8_t function, float par1, float par2, flo
case F_millis:
return millis();
case F_jsonToPixels:
SEGMENT.jsonToPixels(SEGMENT.name,(uint8_t)par1);
return floatNull;
default: {}
}
#else // not arduino
@@ -273,6 +280,9 @@ float ARTI::arti_external_function(uint8_t function, float par1, float par2, flo
case F_millis:
return 1000;
case F_jsonToPixels:
return par1;
}
#endif
@@ -315,7 +325,7 @@ float ARTI::arti_external_function(uint8_t function, float par1, float par2, flo
return t > par3 ? par3 : t;
}
case F_printf: {
case F_print: {
if (par3 == floatNull) {
if (par2 == floatNull) {
PRINT_ARTI("%f\n", par1);
@@ -454,6 +464,9 @@ void ARTI::arti_set_external_variable(float value, uint8_t variable, float par1,
SEGMENT.setPixelColorXY((uint16_t)par1%SEGMENT.virtualWidth(), (uint16_t)par2%SEGMENT.virtualHeight(), value); //2D value!!
return;
case F_frameTime:
frameTime = (uint16_t)value;
return;
}
#else
switch (variable)
@@ -470,6 +483,9 @@ void ARTI::arti_set_external_variable(float value, uint8_t variable, float par1,
RUNLOG_ARTI("arti_set_external_variable: leds(%f, %f) := %f\n", par1, par2, value);
return;
case F_frameTime:
frameTime = (uint16_t)value;
return;
}
#endif

View File

@@ -96,7 +96,7 @@ uint16_t mode_ARTIFX(void) {
}
}
return FRAMETIME;
return MAX(frameTime,FRAMETIME);
}
static const char _data_FX_MODE_ARTIFX[] PROGMEM = "⚙️ ARTI-FX ☾@Speed,Intensity,Custom 1, Custom 2, Custom 3;!;!;1;mp12=0";

View File

@@ -2188,7 +2188,11 @@ class AudioReactive : public Usermod {
oappend(SET_F("addOption(dd,'.Legacy I2S PDM ☾',51);"));
#endif
#endif
oappend(SET_F("addOption(dd,'ES8388',6);"));
#if SR_DMTYPE==6
oappend(SET_F("addOption(dd,'ES8388 ☾ (⎌)',6);"));
#else
oappend(SET_F("addOption(dd,'ES8388 ☾',6);"));
#endif
#ifdef SR_SQUELCH
oappend(SET_F("addInfo('AudioReactive:config:squelch',1,'<i>&#9100; ")); oappendi(SR_SQUELCH); oappend("</i>');"); // 0 is field type, 1 is actual field

View File

@@ -2,11 +2,12 @@
#include "wled.h"
//WLEDMM usermod: CC BY-NC 3.0 licensed effects by Stefan Petrick, only include this usermod only if you accept the terms!
#warning WLEDMM usermod: CC BY-NC 3.0 licensed effects by Stefan Petrick, include this usermod only if you accept the terms!
//========================================================================================================================
//========================================================================================================================
//========================================================================================================================
// Polar basics demo for the
// FastLED Podcast #2
// https://www.youtube.com/watch?v=KKjFRZFBUrQ

View File

@@ -616,6 +616,7 @@ typedef struct Segment {
void blur2d(fract8 blur_amount) { blur(blur_amount); }
void fill_solid(CRGB c) { fill(RGBW32(c.r,c.g,c.b,0)); }
void nscale8(uint8_t scale);
bool jsonToPixels(char *name, uint8_t fileNr);
#else
uint16_t XY(uint16_t x, uint16_t y) { return x; }
void setPixelColorXY(int x, int y, uint32_t c) { setPixelColor(x, c); }

View File

@@ -552,6 +552,48 @@ void Segment::drawArc(uint16_t x0, uint16_t y0, uint16_t radius, uint32_t color,
}
}
bool Segment::jsonToPixels(char * name, uint8_t fileNr) {
char fileName[32];
//WLEDMM: als support segment name ledmaps
bool isFile = false;;
// strcpy_P(fileName, PSTR("/mario"));
sprintf(fileName, "/%s%d.json", name, fileNr); //WLEDMM: trick to not include 0 in ledmap.json
// strcat(fileName, ".json");
isFile = WLED_FS.exists(fileName);
if (!isFile) {
return false;
}
if (!requestJSONBufferLock(23)) return false;
USER_PRINTF("file %s %d", fileName, isFile);
if (!readObjectFromFile(fileName, nullptr, &doc)) {
releaseJSONBufferLock();
return false; //if file does not exist just exit
}
JsonArray map = doc[F("seg")][F("i")];
// serializeJson(map, Serial);
if (!map.isNull() && map.size()) { // not an empty map
for (uint16_t i=0; i<map.size(); i+=3) {
// USER_PRINTF("%s %s %s", map[i].as<String>().c_str(), map[i+1].as<String>().c_str(), map[i+2].as<String>().c_str());
CRGB color = CRGB(map[i+2][0], map[i+2][1], map[i+2][2]);
for (uint16_t j=map[i]; j<=map[i+1]; j++) {
setPixelColor(j, color);
}
}
}
USER_PRINTLN();
releaseJSONBufferLock();
return true;
}
#include "src/font/console_font_4x6.h"
#include "src/font/console_font_5x8.h"
#include "src/font/console_font_5x12.h"

View File

@@ -8,7 +8,7 @@
*/
// version code in format yymmddb (b = daily build)
#define VERSION 2304040
#define VERSION 2304050
//uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG