add legacy defines for compatibility, reverted test changes in rotozoomer

This commit is contained in:
Damian Schneider 2025-03-14 06:48:18 +01:00
parent 494b72c287
commit d2b7e474d6
2 changed files with 16 additions and 9 deletions

View File

@ -6221,12 +6221,22 @@ uint16_t mode_2Dplasmarotozoom() {
const int cols = SEG_W;
const int rows = SEG_H;
unsigned dataSize = sizeof(float);
unsigned dataSize = SEGMENT.length() + sizeof(float);
if (!SEGENV.allocateData(dataSize)) return mode_static(); //allocation failed
float *a = reinterpret_cast<float*>(SEGENV.data);
byte *plasma = reinterpret_cast<byte*>(SEGENV.data+sizeof(float));
unsigned ms = strip.now/15;
// plasma
for (int j = 0; j < rows; j++) {
int index = j*cols;
for (int i = 0; i < cols; i++) {
if (SEGMENT.check1) plasma[index+i] = (i * 4 ^ j * 4) + ms / 6;
else plasma[index+i] = inoise8(i * 40, j * 40, ms);
}
}
// rotozoom
float f = (sin_t(*a/2)+((128-SEGMENT.intensity)/128.0f)+1.1f)/1.5f; // scale factor
float kosinus = cos_t(*a) * f;
@ -6235,14 +6245,9 @@ uint16_t mode_2Dplasmarotozoom() {
float u1 = i * kosinus;
float v1 = i * sinus;
for (int j = 0; j < rows; j++) {
unsigned u = abs8(u1 - j * sinus) % cols;
unsigned v = abs8(v1 + j * kosinus) % rows;
byte plasma;
if (SEGMENT.check1) plasma = (u * 4 ^ v * 4) + ms / 6;
else plasma = perlin8(u * 40, v * 40, ms);
//else plasma = inoise8(u * SEGMENT.intensity, v * SEGMENT.intensity, ms);
//SEGMENT.setPixelColorXY(i, j, SEGMENT.color_from_palette(plasma[v*cols+u], false, PALETTE_SOLID_WRAP, 255));
SEGMENT.setPixelColorXY(i, j, SEGMENT.color_from_palette(plasma, false, PALETTE_SOLID_WRAP, 255));
byte u = abs8(u1 - j * sinus) % cols;
byte v = abs8(v1 + j * kosinus) % rows;
SEGMENT.setPixelColorXY(i, j, SEGMENT.color_from_palette(plasma[v*cols+u], false, PALETTE_SOLID_WRAP, 255));
}
}
*a -= 0.03f + float(SEGENV.speed-128)*0.0002f; // rotation speed

View File

@ -486,6 +486,8 @@ void userLoop();
#include "soc/wdev_reg.h"
#define HW_RND_REGISTER REG_READ(WDEV_RND_REG)
#endif
#define inoise8 perlin8 // fastled legacy alias
#define inoise16 perlin16 // fastled legacy alias
#define hex2int(a) (((a)>='0' && (a)<='9') ? (a)-'0' : ((a)>='A' && (a)<='F') ? (a)-'A'+10 : ((a)>='a' && (a)<='f') ? (a)-'a'+10 : 0)
[[gnu::pure]] int getNumVal(const String* req, uint16_t pos);
void parseNumber(const char* str, byte* val, byte minv=0, byte maxv=255);