Skip to content

Commit

Permalink
ARTIFX add support for pixelart + small changes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ewoudwijma committed Apr 5, 2023
1 parent e4243c4 commit cae1c00
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 6 deletions.
20 changes: 18 additions & 2 deletions usermods/artifx/arti_wled.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion usermods/artifx/usermod_v2_artifx.h
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
6 changes: 5 additions & 1 deletion usermods/audioreactive/audio_reactive.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion usermods/usermod_v2_fastled/usermod_v2_fastled.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions wled00/FX.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
Expand Down
42 changes: 42 additions & 0 deletions wled00/FX_2Dfcn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion wled00/wled.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cae1c00

Please sign in to comment.