Add Mapping 1D to 2D. Mapping12 and sound simulation effect independent
- add to segment: mapping 1D2D and Sound Simulation (WIP!) - Add sound simulation WeWillRockYou - All audio effects use segment soundSim - Redefine SEGLEN: strip.getMappingLength (depending on mapping12) - make setPixelColor aware of mapping12
This commit is contained in:
parent
f0992d56c1
commit
2f6adbd07c
@ -5970,8 +5970,9 @@ static const char *_data_FX_MODE_DRIFT_ROSE PROGMEM = "2D Drift Rose@Fade,Blur;;
|
||||
//Currently 3 types defined, to be finetuned and new types added
|
||||
typedef enum UM_SoundSimulations {
|
||||
UMS_BeatSin = 0,
|
||||
UMS_10_3,
|
||||
UMS_14_3
|
||||
UMS_WeWillRockYou = 1,
|
||||
UMS_10_3 = 2,
|
||||
UMS_14_3 = 3
|
||||
} um_soundSimulations_t;
|
||||
|
||||
static um_data_t* um_data = nullptr;
|
||||
@ -6048,6 +6049,38 @@ um_data_t* simulateSound(uint8_t simulationId)
|
||||
// fftResult[i] = (beatsin8(120, 0, 255) + (256/16 * i)) % 256;
|
||||
sampleAvg = fftResult[8];
|
||||
break;
|
||||
case UMS_WeWillRockYou:
|
||||
if (ms%2000 < 200) {
|
||||
sampleAvg = random8(255);
|
||||
for (int i = 0; i<5; i++)
|
||||
fftResult[i] = random8(255);
|
||||
}
|
||||
else if (ms%2000 < 400) {
|
||||
sampleAvg = 0;
|
||||
for (int i = 0; i<16; i++)
|
||||
fftResult[i] = 0;
|
||||
}
|
||||
else if (ms%2000 < 600) {
|
||||
sampleAvg = random8(255);
|
||||
for (int i = 5; i<11; i++)
|
||||
fftResult[i] = random8(255);
|
||||
}
|
||||
else if (ms%2000 < 800) {
|
||||
sampleAvg = 0;
|
||||
for (int i = 0; i<16; i++)
|
||||
fftResult[i] = 0;
|
||||
}
|
||||
else if (ms%2000 < 1000) {
|
||||
sampleAvg = random8(255);
|
||||
for (int i = 11; i<16; i++)
|
||||
fftResult[i] = random8(255);
|
||||
}
|
||||
else {
|
||||
sampleAvg = 0;
|
||||
for (int i = 0; i<16; i++)
|
||||
fftResult[i] = 0;
|
||||
}
|
||||
break;
|
||||
case UMS_10_3:
|
||||
for (int i = 0; i<16; i++)
|
||||
fftResult[i] = inoise8(beatsin8(90 / (i+1), 0, 200)*15 + (ms>>10), ms>>3);
|
||||
@ -6122,7 +6155,7 @@ uint16_t mode_ripplepeak(void) { // * Ripple peak. By Andrew Tuli
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
// add support for no audio data
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
uint8_t samplePeak = *(uint8_t*)um_data->u_data[5];
|
||||
float FFT_MajorPeak = *(float*) um_data->u_data[6];
|
||||
@ -6211,7 +6244,7 @@ uint16_t mode_2DSwirl(void) {
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
// add support for no audio data
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
float sampleAvg = *(float*) um_data->u_data[0];
|
||||
uint8_t soundAgc = *(uint8_t*)um_data->u_data[1];
|
||||
@ -6256,7 +6289,7 @@ uint16_t mode_2DWaverly(void) {
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
// add support for no audio data
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
float sampleAvg = *(float*) um_data->u_data[0];
|
||||
uint8_t soundAgc = *(uint8_t*)um_data->u_data[1];
|
||||
@ -6310,7 +6343,7 @@ uint16_t mode_gravcenter(void) { // Gravcenter. By Andrew Tuline.
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
// add support for no audio data
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
float sampleAvg = *(float*)um_data->u_data[0];
|
||||
uint8_t soundAgc = *(uint8_t*)um_data->u_data[1];
|
||||
@ -6361,7 +6394,7 @@ uint16_t mode_gravcentric(void) { // Gravcentric. By Andrew
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
// add support for no audio data
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
float sampleAvg = *(float*)um_data->u_data[0];
|
||||
uint8_t soundAgc = *(uint8_t*)um_data->u_data[1];
|
||||
@ -6416,7 +6449,7 @@ uint16_t mode_gravimeter(void) { // Gravmeter. By Andrew Tuline.
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
// add support for no audio data
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
float sampleAvg = *(float*)um_data->u_data[0];
|
||||
uint8_t soundAgc = *(uint8_t*)um_data->u_data[1];
|
||||
@ -6461,7 +6494,7 @@ uint16_t mode_gravimeter(void) { // Gravmeter. By Andrew Tuline.
|
||||
Gravity* gravcen = reinterpret_cast<Gravity*>(SEGENV.data);
|
||||
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
float sampleAvg = *(float*)um_data->u_data[0];
|
||||
uint8_t soundAgc = *(uint8_t*)um_data->u_data[1];
|
||||
@ -6527,7 +6560,7 @@ uint16_t mode_juggles(void) { // Juggles. By Andrew Tuline.
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
// add support for no audio data
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
float sampleAgc = *(float*)um_data->u_data[2];
|
||||
|
||||
@ -6550,7 +6583,7 @@ uint16_t mode_matripix(void) { // Matripix. By Andrew Tuline.
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
// add support for no audio data
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
uint8_t soundAgc = *(uint8_t*)um_data->u_data[1];
|
||||
int16_t sampleRaw = *(int16_t*)um_data->u_data[3];
|
||||
@ -6582,7 +6615,7 @@ uint16_t mode_midnoise(void) { // Midnoise. By Andrew Tuline.
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
// add support for no audio data
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
float sampleAvg = *(float*)um_data->u_data[0];
|
||||
uint8_t soundAgc = *(uint8_t*)um_data->u_data[1];
|
||||
@ -6624,7 +6657,7 @@ uint16_t mode_noisefire(void) { // Noisefire. By Andrew Tuline.
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
// add support for no audio data
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
float sampleAvg = *(float*)um_data->u_data[0];
|
||||
uint8_t soundAgc = *(uint8_t*)um_data->u_data[1];
|
||||
@ -6653,7 +6686,7 @@ uint16_t mode_noisemeter(void) { // Noisemeter. By Andrew Tuline.
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
// add support for no audio data
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
float sampleAvg = *(float*)um_data->u_data[0];
|
||||
uint8_t soundAgc = *(uint8_t*)um_data->u_data[1];
|
||||
@ -6692,7 +6725,7 @@ uint16_t mode_pixelwave(void) { // Pixelwave. By Andrew Tuline.
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
// add support for no audio data
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
uint8_t soundAgc = *(uint8_t*)um_data->u_data[1];
|
||||
int16_t sampleRaw = *(int16_t*)um_data->u_data[3];
|
||||
@ -6732,7 +6765,7 @@ uint16_t mode_plasmoid(void) { // Plasmoid. By Andrew Tuline.
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
// add support for no audio data
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
float sampleAvg = *(float*)um_data->u_data[0];
|
||||
uint8_t soundAgc = *(uint8_t*)um_data->u_data[1];
|
||||
@ -6773,7 +6806,7 @@ uint16_t mode_puddlepeak(void) { // Puddlepeak. By Andrew Tuline.
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
// add support for no audio data
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
float sampleAgc = *(float*)um_data->u_data[2];
|
||||
uint8_t samplePeak = *(uint8_t*)um_data->u_data[5];
|
||||
@ -6817,7 +6850,7 @@ uint16_t mode_puddles(void) { // Puddles. By Andrew Tuline.
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
// add support for no audio data
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
uint8_t soundAgc = *(uint8_t*)um_data->u_data[1];
|
||||
int16_t sampleRaw = *(int16_t*)um_data->u_data[3];
|
||||
@ -6851,7 +6884,7 @@ uint16_t mode_pixels(void) { // Pixels. By Andrew Tuline.
|
||||
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
float sampleAgc = *(float*)um_data->u_data[2];
|
||||
uint16_t *myVals = (uint16_t*)um_data->u_data[14];
|
||||
@ -6885,7 +6918,7 @@ uint16_t mode_binmap(void) {
|
||||
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
#ifdef SR_DEBUG
|
||||
uint8_t *maxVol = (uint8_t*)um_data->u_data[9];
|
||||
@ -6960,7 +6993,7 @@ uint16_t mode_blurz(void) { // Blurz. By Andrew Tuline.
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
// add support for no audio data
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
uint8_t *fftResult = (uint8_t*)um_data->u_data[8];
|
||||
if (!fftResult) return mode_static();
|
||||
@ -6997,7 +7030,7 @@ uint16_t mode_DJLight(void) { // Written by ??? Adapted by Wil
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
// add support for no audio data
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
uint8_t *fftResult = (uint8_t*)um_data->u_data[8];
|
||||
if (!fftResult) return mode_static();
|
||||
@ -7030,7 +7063,7 @@ uint16_t mode_freqmap(void) { // Map FFT_MajorPeak to SEGLEN.
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
// add support for no audio data
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
float sampleAvg = *(float*)um_data->u_data[0];
|
||||
uint8_t soundAgc = *(uint8_t*)um_data->u_data[1];
|
||||
@ -7064,7 +7097,7 @@ uint16_t mode_freqmatrix(void) { // Freqmatrix. By Andreas Plesch
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
// add support for no audio data
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
float sampleAgc = *(float*)um_data->u_data[2];
|
||||
float FFT_MajorPeak = *(float*)um_data->u_data[6];
|
||||
@ -7117,7 +7150,7 @@ static const char *_data_FX_MODE_FREQMATRIX PROGMEM = " ♫ Freqmatrix@Time dela
|
||||
uint16_t mode_freqpixels(void) { // Freqpixel. By Andrew Tuline.
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
// add support for no audio data
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
float sampleAvg = *(float*)um_data->u_data[0];
|
||||
uint8_t soundAgc = *(uint8_t*)um_data->u_data[1];
|
||||
@ -7162,7 +7195,7 @@ uint16_t mode_freqwave(void) { // Freqwave. By Andreas Pleschun
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
// add support for no audio data
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
float sampleAvg = *(float*)um_data->u_data[0];
|
||||
uint8_t soundAgc = *(uint8_t*)um_data->u_data[1];
|
||||
@ -7226,7 +7259,7 @@ uint16_t mode_gravfreq(void) { // Gravfreq. By Andrew Tuline.
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
// add support for no audio data
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
float sampleAvg = *(float*)um_data->u_data[0];
|
||||
uint8_t soundAgc = *(uint8_t*)um_data->u_data[1];
|
||||
@ -7274,7 +7307,7 @@ uint16_t mode_noisemove(void) { // Noisemove. By: Andrew Tuli
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
// add support for no audio data
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
uint8_t *fftResult = (uint8_t*)um_data->u_data[8];
|
||||
if (!fftResult) return mode_static();
|
||||
@ -7300,7 +7333,7 @@ uint16_t mode_rocktaves(void) { // Rocktaves. Same note from eac
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
// add support for no audio data
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
float sampleAvg = *(float*)um_data->u_data[0];
|
||||
uint8_t soundAgc = *(uint8_t*)um_data->u_data[1];
|
||||
@ -7347,7 +7380,7 @@ uint16_t mode_waterfall(void) { // Waterfall. By: Andrew Tulin
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
// add support for no audio data
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
float sampleAvg = *(float*)um_data->u_data[0];
|
||||
uint8_t soundAgc = *(uint8_t*)um_data->u_data[1];
|
||||
@ -7406,7 +7439,7 @@ uint16_t mode_2DGEQ(void) { // By Will Tatam. Code reduction by Ewoud Wijma.
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
// add support for no audio data
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
uint8_t *fftResult = (uint8_t*)um_data->u_data[8];
|
||||
if (!fftResult) return mode_static();
|
||||
@ -7470,7 +7503,7 @@ uint16_t mode_2DFunkyPlank(void) { // Written by ??? Adapted by Wil
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
// add support for no audio data
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
uint8_t *fftResult = (uint8_t*)um_data->u_data[8];
|
||||
if (!fftResult) return mode_static();
|
||||
@ -7562,7 +7595,7 @@ uint16_t mode_2DAkemi(void) {
|
||||
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
um_data = simulateSound(UMS_BeatSin);
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
}
|
||||
uint8_t *fftResult = (uint8_t*)um_data->u_data[8];
|
||||
float base = fftResult[0]/255.0f;
|
||||
|
14
wled00/FX.h
14
wled00/FX.h
@ -90,7 +90,7 @@ uint32_t color_add(uint32_t,uint32_t);
|
||||
#define SEGMENT strip.getSegment(strip.getCurrSegmentId())
|
||||
#define SEGENV strip.getSegmentRuntime(strip.getCurrSegmentId())
|
||||
#define SEGCOLOR(x) strip.segColor(x)
|
||||
#define SEGLEN strip.segLen()
|
||||
#define SEGLEN strip.getMappingLength()
|
||||
#define SPEED_FORMULA_L (5U + (50U*(255U - SEGMENT.speed))/SEGLEN)
|
||||
|
||||
// some common colors
|
||||
@ -381,6 +381,8 @@ typedef struct Segment { // 35 (36 in memory) bytes
|
||||
uint8_t custom1, custom2, custom3; // custom FX parameters
|
||||
uint16_t startY; // start Y coodrinate 2D (top)
|
||||
uint16_t stopY; // stop Y coordinate 2D (bottom)
|
||||
uint8_t soundSim;
|
||||
uint8_t mapping12;
|
||||
char *name;
|
||||
inline bool getOption(uint8_t n) { return ((options >> n) & 0x01); }
|
||||
inline bool isSelected() { return getOption(0); }
|
||||
@ -445,6 +447,12 @@ typedef struct ColorTransition { // 12 bytes
|
||||
}
|
||||
} color_transition;
|
||||
|
||||
typedef enum mapping1D2D {
|
||||
M12_Pixels = 0,
|
||||
M12_VerticalBar = 1,
|
||||
M12_CenterCircle = 2,
|
||||
M12_CenterBlock = 3
|
||||
} mapping1D2D_t;
|
||||
|
||||
// main "strip" class
|
||||
class WS2812FX {
|
||||
@ -559,7 +567,6 @@ class WS2812FX {
|
||||
inline uint16_t getFrameTime(void) { return _frametime; }
|
||||
inline uint16_t getMinShowDelay(void) { return MIN_SHOW_DELAY; }
|
||||
inline uint16_t getLengthTotal(void) { return _length; }
|
||||
inline uint16_t segLen(void) { return _virtualSegmentLength; }
|
||||
|
||||
uint32_t
|
||||
now,
|
||||
@ -644,7 +651,8 @@ class WS2812FX {
|
||||
|
||||
uint16_t
|
||||
XY(uint16_t, uint16_t),
|
||||
get2DPixelIndex(uint16_t x, uint16_t y, uint8_t seg=255);
|
||||
get2DPixelIndex(uint16_t x, uint16_t y, uint8_t seg=255),
|
||||
getMappingLength();
|
||||
|
||||
uint32_t
|
||||
getPixelColorXY(uint16_t, uint16_t);
|
||||
|
@ -35,13 +35,9 @@
|
||||
#ifdef SEGENV
|
||||
#undef SEGENV
|
||||
#endif
|
||||
#ifdef SEGLEN
|
||||
#undef SEGLEN
|
||||
#endif
|
||||
#define SEGMENT _segments[_segment_index]
|
||||
#define SEGCOLOR(x) _colors_t[x]
|
||||
#define SEGENV _segment_runtimes[_segment_index]
|
||||
#define SEGLEN _virtualSegmentLength
|
||||
|
||||
// setUpMatrix() - constructs ledmap array from matrix of panels with WxH pixels
|
||||
// this converts physical (possibly irregular) LED arrangement into well defined
|
||||
@ -251,10 +247,28 @@ void /*IRAM_ATTR*/ WS2812FX::setPixelColorXY(float x, float y, byte r, byte g, b
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t IRAM_ATTR WS2812FX::getMappingLength() {
|
||||
switch (SEGMENT.mapping12) {
|
||||
case M12_Pixels:
|
||||
return SEGMENT.virtualWidth() * SEGMENT.virtualHeight();
|
||||
break;
|
||||
case M12_VerticalBar:
|
||||
return SEGMENT.virtualWidth();
|
||||
break;
|
||||
case M12_CenterCircle:
|
||||
return (SEGMENT.virtualWidth() + SEGMENT.virtualHeight()) / 4; // take half of the average width
|
||||
break;
|
||||
case M12_CenterBlock:
|
||||
return (SEGMENT.virtualWidth() + SEGMENT.virtualHeight()) / 4; // take half of the average width
|
||||
break;
|
||||
}
|
||||
return SEGMENT.virtualWidth() * SEGMENT.virtualHeight();
|
||||
}
|
||||
|
||||
// returns RGBW values of pixel
|
||||
uint32_t WS2812FX::getPixelColorXY(uint16_t x, uint16_t y) {
|
||||
uint16_t index;
|
||||
if (SEGLEN) {
|
||||
if (_virtualSegmentLength) {
|
||||
if (SEGMENT.getOption(SEG_OPTION_REVERSED) ) x = SEGMENT.virtualWidth() - x - 1;
|
||||
if (SEGMENT.getOption(SEG_OPTION_REVERSED_Y)) y = SEGMENT.virtualHeight() - y - 1;
|
||||
if (SEGMENT.getOption(SEG_OPTION_TRANSPOSED)) { uint16_t t = x; x = y; y = t; } // swap X & Y if segment transposed
|
||||
|
@ -36,13 +36,9 @@
|
||||
#ifdef SEGENV
|
||||
#undef SEGENV
|
||||
#endif
|
||||
#ifdef SEGLEN
|
||||
#undef SEGLEN
|
||||
#endif
|
||||
#define SEGMENT _segments[_segment_index]
|
||||
#define SEGCOLOR(x) _colors_t[x]
|
||||
#define SEGENV _segment_runtimes[_segment_index]
|
||||
#define SEGLEN _virtualSegmentLength
|
||||
|
||||
/*
|
||||
Custom per-LED mapping has moved!
|
||||
@ -482,14 +478,44 @@ void IRAM_ATTR WS2812FX::setPixelColor(int i, byte r, byte g, byte b, byte w)
|
||||
{
|
||||
uint8_t segIdx = _virtualSegmentLength ? _segment_index : _mainSegment;
|
||||
if (isMatrix && _virtualSegmentLength) {
|
||||
// map linear pixel into 2D segment area (even for 1D segments, expanding vertically)
|
||||
|
||||
uint16_t h = _segments[segIdx].virtualHeight(); // segment height in logical pixels
|
||||
for (uint16_t y = 0; y < h; y++) { // expand 1D effect vertically
|
||||
setPixelColorXY(i, y * _segments[segIdx].groupLength(), r, g, b, w);
|
||||
switch (SEGMENT.mapping12) {
|
||||
case M12_Pixels:
|
||||
setPixelColorXY(i%SEGMENT.virtualWidth(), i/SEGMENT.virtualWidth(), r, g, b, w);
|
||||
break;
|
||||
case M12_VerticalBar:
|
||||
// map linear pixel into 2D segment area (even for 1D segments, expanding vertically)
|
||||
for (uint16_t y = 0; y < h; y++) { // expand 1D effect vertically
|
||||
setPixelColorXY(i, y * _segments[segIdx].groupLength(), r, g, b, w);
|
||||
}
|
||||
// strip.setPixelColor(i%SEGMENT.virtualWidth(), r, g, b, w);
|
||||
break;
|
||||
case M12_CenterCircle:
|
||||
for (int degrees = 0; degrees <= 360; degrees += 180 / (i+1)) {
|
||||
// int x = sinf(degrees*DEG_TO_RAD * i);
|
||||
// int y = cosf(degrees*DEG_TO_RAD * i);
|
||||
// strip.setPixelColorXY(x + SEGMENT.virtualWidth() / 2 - 1, y + SEGMENT.virtualHeight() / 2 - 1, r, g, b, w);
|
||||
int x = roundf(roundf((sinf(degrees*DEG_TO_RAD) * i + SEGMENT.virtualWidth() / 2) * 10)/10);
|
||||
int y = roundf(roundf((cosf(degrees*DEG_TO_RAD) * i + SEGMENT.virtualHeight() / 2) * 10)/10);
|
||||
setPixelColorXY(x, y, r, g, b, w);
|
||||
}
|
||||
break;
|
||||
case M12_CenterBlock:
|
||||
for (int x = SEGMENT.virtualWidth() / 2 - i - 1; x <= SEGMENT.virtualWidth() / 2 + i; x++) {
|
||||
setPixelColorXY(x, SEGMENT.virtualHeight() / 2 - i - 1, r, g, b, w);
|
||||
setPixelColorXY(x, SEGMENT.virtualHeight() / 2 + i , r, g, b, w);
|
||||
}
|
||||
for (int y = SEGMENT.virtualHeight() / 2 - i - 1 + 1; y <= SEGMENT.virtualHeight() / 2 + i - 1; y++) {
|
||||
setPixelColorXY(SEGMENT.virtualWidth() / 2 - i - 1, y, r, g, b, w);
|
||||
setPixelColorXY(SEGMENT.virtualWidth() / 2 + i , y, r, g, b, w);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (_virtualSegmentLength || (realtimeMode && useMainSegmentOnly)) {
|
||||
//color_blend(getpixel, col, _bri_t); (pseudocode for future blending of segments)
|
||||
if (_virtualSegmentLength && _bri_t < 255) { // _virtualSegmentLength!=0 -> from segment/FX
|
||||
|
@ -746,6 +746,24 @@ function populateSegments(s)
|
||||
<input type="checkbox" id="seg${i}${isM?'tp':'mi'}" onchange="${(isM?'setTp(':'setMi(')+i})" ${isM?(inst.tp?"checked":""):(inst.mi?"checked":"")}>
|
||||
<span class="checkmark schk"></span>
|
||||
</label>
|
||||
<label class="check revchkl">
|
||||
1D2D Mapping
|
||||
<select id="seg${i}mp12" onchange="setMp12(${i})">
|
||||
<option value="0" ${inst.mp12==0?' selected':''}>Pixel</option>
|
||||
<option value="1" ${inst.mp12==1?' selected':''}>Vertical Bar</option>
|
||||
<option value="2" ${inst.mp12==2?' selected':''}>Centre Circle</option>
|
||||
<option value="3" ${inst.mp12==3?' selected':''}>Center block</option>
|
||||
</select><br>
|
||||
</label>
|
||||
<label class="check revchkl">
|
||||
Sound simulation
|
||||
<select id="seg${i}ssim" onchange="setSSim(${i})">
|
||||
<option value="0" ${inst.ssim==0?' selected':''}>BeatSin</option>
|
||||
<option value="1" ${inst.ssim==1?' selected':''}>WeWillRockYou</option>
|
||||
<option value="2" ${inst.ssim==2?' selected':''}>U10_3</option>
|
||||
<option value="3" ${inst.ssim==3?' selected':''}>U14_3</option>
|
||||
</select><br>
|
||||
</label>
|
||||
<div class="del">
|
||||
<button class="btn btn-xs" id="segr${i}" title="Repeat until end" onclick="rptSeg(${i})"><i class="icons btn-icon"></i></button>
|
||||
<button class="btn btn-xs" id="segd${i}" title="Delete" onclick="delSeg(${i})"><i class="icons btn-icon"></i></button>
|
||||
@ -1952,6 +1970,20 @@ function setMiY(s)
|
||||
requestJson(obj);
|
||||
}
|
||||
|
||||
function setMp12(s)
|
||||
{
|
||||
var value = gId(`seg${s}mp12`).selectedIndex;
|
||||
var obj = {"seg": {"id": s, "mp12": value}};
|
||||
requestJson(obj);
|
||||
}
|
||||
|
||||
function setSSim(s)
|
||||
{
|
||||
var value = gId(`seg${s}ssim`).selectedIndex;
|
||||
var obj = {"seg": {"id": s, "ssim": value}};
|
||||
requestJson(obj);
|
||||
}
|
||||
|
||||
function setTp(s)
|
||||
{
|
||||
var tp = gId(`seg${s}tp`).checked;
|
||||
|
3565
wled00/html_ui.h
3565
wled00/html_ui.h
File diff suppressed because it is too large
Load Diff
@ -170,6 +170,9 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
|
||||
getVal(elem[F("c1")], &seg.custom1);
|
||||
getVal(elem[F("c2")], &seg.custom2);
|
||||
getVal(elem[F("c3")], &seg.custom3);
|
||||
|
||||
getVal(elem[F("ssim")], &seg.soundSim);
|
||||
getVal(elem[F("mp12")], &seg.mapping12);
|
||||
|
||||
JsonArray iarr = elem[F("i")]; //set individual LEDs
|
||||
if (!iarr.isNull()) {
|
||||
@ -452,6 +455,8 @@ void serializeSegment(JsonObject& root, Segment& seg, byte id, bool forPreset, b
|
||||
root[F("mY")] = seg.getOption(SEG_OPTION_MIRROR_Y);
|
||||
root[F("tp")] = seg.getOption(SEG_OPTION_TRANSPOSED);
|
||||
}
|
||||
root[F("ssim")] = seg.soundSim;
|
||||
root[F("mp12")] = seg.mapping12;
|
||||
}
|
||||
|
||||
void serializeState(JsonObject root, bool forPreset, bool includeBri, bool segmentBounds)
|
||||
|
Loading…
Reference in New Issue
Block a user