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

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