code cleanup
- removed commented-out code - reduced blank lines
This commit is contained in:
@@ -8388,13 +8388,15 @@ uint16_t mode_2Dwavingcell() {
|
||||
}
|
||||
static const char _data_FX_MODE_2DWAVINGCELL[] PROGMEM = "Waving Cell@!,,Amplitude 1,Amplitude 2,Amplitude 3;;!;2";
|
||||
|
||||
/////////////////////////
|
||||
// ** 3D GEQ //
|
||||
/////////////////////////
|
||||
uint16_t mode_GEQLASER(void) {
|
||||
|
||||
// Author: @TroyHacks
|
||||
|
||||
const size_t dataSize = sizeof(uint16_t);
|
||||
if (!SEGENV.allocateData(dataSize * 2)) return mode_static(); //allocation failed
|
||||
|
||||
uint16_t *projector = reinterpret_cast<uint16_t*>(SEGENV.data);
|
||||
uint16_t *projector_dir = reinterpret_cast<uint16_t*>(SEGENV.data + dataSize);
|
||||
|
||||
@@ -8411,11 +8413,13 @@ uint16_t mode_GEQLASER(void) {
|
||||
|
||||
SEGMENT.fill(BLACK);
|
||||
|
||||
const int NUM_BANDS = map(SEGMENT.custom3, 0, 31, 1, 16); // custom3 is 0..31
|
||||
uint32_t ledColorTemp;
|
||||
const int cols = SEGMENT.virtualWidth();
|
||||
const int rows = SEGMENT.virtualHeight();
|
||||
uint32_t ledColorTemp;
|
||||
uint_fast8_t split = map(*projector,0,SEGMENT.virtualWidth(),0,(NUM_BANDS - 1));
|
||||
const int NUM_BANDS = map(SEGMENT.custom3, 0, 31, 1, 16); // custom3 is 0..31
|
||||
uint_fast8_t split = map(*projector,0,SEGMENT.virtualWidth(),0,(NUM_BANDS - 1));
|
||||
uint16_t horizon = map(SEGMENT.custom1,0,255,rows-1,0);
|
||||
uint8_t depth = SEGMENT.custom2; // depth of perspective. 255 = infinite ("laser")
|
||||
|
||||
um_data_t *um_data;
|
||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
@@ -8429,108 +8433,78 @@ uint16_t mode_GEQLASER(void) {
|
||||
heights[i] = map8(fftResult[i],0,rows*0.85); // cache fftResult[] as data might be updated in parallel by the audioreactive core
|
||||
}
|
||||
|
||||
uint16_t horizon = map(SEGMENT.custom1,0,255,rows-1,0);
|
||||
uint8_t depth = SEGMENT.custom2; // depth of perspective. 255 = infinite ("laser")
|
||||
|
||||
for (int i=0; i<=split; i++) { // paint right vertical faces and top - LEFT to RIGHT
|
||||
|
||||
uint16_t colorIndex = map(cols/NUM_BANDS*i, 0, cols-1, 0, 255);
|
||||
uint32_t ledColor = SEGMENT.color_from_palette(colorIndex, false, PALETTE_SOLID_WRAP, 0);
|
||||
|
||||
int linex = i*(cols/NUM_BANDS);
|
||||
|
||||
if (heights[i] > 1) {
|
||||
|
||||
ledColorTemp = color_fade(ledColor,32,true);
|
||||
int pPos = linex+(cols/NUM_BANDS)-1;
|
||||
|
||||
for (int y = (i<NUM_BANDS-1) ? heights[i+1] : 0; y <= heights[i]; y++) { // don't bother drawing what we'll hide anyway
|
||||
SEGMENT.drawLine(pPos,rows-y-1,*projector,horizon,ledColorTemp,false,depth); // right side perspective
|
||||
}
|
||||
|
||||
ledColorTemp = color_fade(ledColor,128,true);
|
||||
|
||||
if (heights[i] < rows-horizon && (*projector <=linex || *projector >= pPos)) { // draw if above horizon AND not directly under projector (special case later)
|
||||
|
||||
for (uint_fast8_t x=linex; x<=pPos;x++) {
|
||||
bool doSoft = SEGMENT.check2 && ((x==linex) || (x==pPos)); // only first and last line need AA
|
||||
SEGMENT.drawLine(x,rows-heights[i]-2,*projector,horizon,ledColorTemp,doSoft,depth); // top perspective
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (int i=(NUM_BANDS - 1); i>split; i--) { // paint left vertical faces and top - RIGHT to LEFT
|
||||
|
||||
for (int i=(NUM_BANDS - 1); i>split; i--) { // paint left vertical faces and top - RIGHT to LEFT
|
||||
uint16_t colorIndex = map(cols/NUM_BANDS*i, 0, cols-1, 0, 255);
|
||||
uint32_t ledColor = SEGMENT.color_from_palette(colorIndex, false, PALETTE_SOLID_WRAP, 0);
|
||||
|
||||
int linex = i*(cols/NUM_BANDS);
|
||||
int pPos = linex+(cols/NUM_BANDS)-1;
|
||||
|
||||
if (heights[i] > 1) {
|
||||
|
||||
ledColorTemp = color_fade(ledColor,32,true);
|
||||
|
||||
for (uint_fast8_t y = (i>0) ? heights[i-1] : 0; y <= heights[i]; y++) { // don't bother drawing what we'll hide anyway
|
||||
SEGMENT.drawLine(linex,rows-y-1,*projector,horizon,ledColorTemp,false,depth); // left side perspective
|
||||
}
|
||||
|
||||
|
||||
ledColorTemp = color_fade(ledColor,128,true);
|
||||
|
||||
if (heights[i] < rows-horizon && (*projector <=linex || *projector >= pPos)) { // draw if above horizon AND not directly under projector (special case later)
|
||||
|
||||
for (uint_fast8_t x=linex; x<=pPos;x++) {
|
||||
bool doSoft = SEGMENT.check2 && ((x==linex) || (x==pPos)); // only first and last line need AA
|
||||
SEGMENT.drawLine(x,rows-heights[i]-2,*projector,horizon,ledColorTemp,doSoft,depth); // top perspective
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (int i=0; i<NUM_BANDS; i++) {
|
||||
|
||||
for (int i=0; i<NUM_BANDS; i++) {
|
||||
uint16_t colorIndex = map(cols/NUM_BANDS*i, 0, cols-1, 0, 255);
|
||||
uint32_t ledColor = SEGMENT.color_from_palette(colorIndex, false, PALETTE_SOLID_WRAP, 0);
|
||||
|
||||
int linex = i*(cols/NUM_BANDS);
|
||||
int pPos = linex+(cols/NUM_BANDS)-1;
|
||||
int pPos1 = linex+(cols/NUM_BANDS);
|
||||
|
||||
if (*projector >=linex && *projector <= pPos) { // special case when top perspective is directly under the projector
|
||||
|
||||
if (heights[i] > 1 && heights[i] < rows-horizon) {
|
||||
|
||||
ledColorTemp = color_fade(ledColor,128,true);
|
||||
|
||||
for (uint_fast8_t x=linex; x<=pPos;x++) {
|
||||
SEGMENT.drawLine(x,rows-heights[i]-2,*projector,horizon,ledColorTemp,false,depth); // top perspective
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (heights[i] > 1) {
|
||||
|
||||
ledColorTemp = color_fade(ledColor,SEGMENT.intensity,true);
|
||||
|
||||
for (uint_fast8_t x=linex; x<pPos1;x++) {
|
||||
SEGMENT.drawLine(x,rows-1,x,rows-heights[i]-1,ledColorTemp); // front fill
|
||||
}
|
||||
|
||||
if (!SEGMENT.check1 && heights[i] > rows-horizon) {
|
||||
|
||||
if (SEGMENT.intensity == 0) ledColorTemp = color_fade(ledColor,32,true); // match side fill if we're in blackout mode
|
||||
|
||||
SEGMENT.drawLine(linex,rows-heights[i]-1,linex+(cols/NUM_BANDS)-1,rows-heights[i]-1,ledColorTemp); // top line to simulate hidden top fill
|
||||
|
||||
}
|
||||
|
||||
if (SEGMENT.check1) {
|
||||
@@ -8538,14 +8512,10 @@ uint16_t mode_GEQLASER(void) {
|
||||
SEGMENT.drawLine(linex+(cols/NUM_BANDS)-1,rows-1,linex+(cols/NUM_BANDS)-1,rows-heights[i]-1,ledColor); // right side line
|
||||
SEGMENT.drawLine(linex, rows-heights[i]-2,linex+(cols/NUM_BANDS)-1,rows-heights[i]-2,ledColor); // top line
|
||||
SEGMENT.drawLine(linex, rows-1,linex+(cols/NUM_BANDS)-1,rows-1,ledColor); // bottom line
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return FRAMETIME;
|
||||
|
||||
}
|
||||
static const char _data_FX_MODE_GEQLASER[] PROGMEM = "GEQ 3D ☾@Speed,Front Fill,Horizon,Depth,Num Bands,Borders,Soft,;!,,Peaks;!;2f;sx=255,ix=255,c1=255,c2=255,c3=255,pal=11";
|
||||
|
||||
|
||||
@@ -225,28 +225,14 @@ uint32_t WS2812FX::getPixelColorXY(uint16_t x, uint16_t y) {
|
||||
// * expects scaled color (final brightness) as additional input parameter, plus segment virtualWidth() and virtualHeight()
|
||||
void IRAM_ATTR Segment::setPixelColorXY_fast(int x, int y, uint32_t col, uint32_t scaled_col, int cols, int rows) //WLEDMM
|
||||
{
|
||||
// if (Segment::maxHeight==1) return; // not a matrix set-up
|
||||
// const int_fast16_t cols = virtualWidth(); // WLEDMM optimization
|
||||
// const int_fast16_t rows = virtualHeight();
|
||||
// if (x<0 || y<0 || x >= cols || y >= rows) return; // if pixel would fall out of virtual segment just exit
|
||||
unsigned i = UINT_MAX;
|
||||
bool sameColor = false;
|
||||
if (ledsrgb) { // WLEDMM small optimization
|
||||
//i = XY(x,y);
|
||||
//i = (x%cols) + (y%rows) * cols; // avoid error checking done in XY()
|
||||
i = x + y*cols; // avoid error checking done by XY() - be optimistic about ranges of x and y
|
||||
CRGB fastled_col = CRGB(col);
|
||||
if (ledsrgb[i] == fastled_col) sameColor = true;
|
||||
else ledsrgb[i] = fastled_col;
|
||||
}
|
||||
#if 0
|
||||
// we are NOT doing brightness here - must be done by the calling function!
|
||||
//uint32_t scaled_col = col;
|
||||
uint8_t _bri_t = currentBri(on ? opacity : 0);
|
||||
if (!_bri_t && !transitional) return;
|
||||
if (_bri_t < 255) scaled_col = color_fade(col, _bri_t);
|
||||
else scaled_col = col;
|
||||
#endif
|
||||
|
||||
#if 0 // this is still a dangerous optimization
|
||||
if ((i < UINT_MAX) && sameColor && (call > 0) && (!transitional) && (ledsrgb[i] == CRGB(scaled_col))) return; // WLEDMM looks like nothing to do
|
||||
@@ -265,7 +251,6 @@ void IRAM_ATTR Segment::setPixelColorXY_fast(int x, int y, uint32_t col, uint32_
|
||||
// handle mirroring
|
||||
const int_fast16_t wid_ = stop - start;
|
||||
const int_fast16_t hei_ = stopY - startY;
|
||||
//if (x >= wid_ || y >= hei_) return; // if pixel would fall out of segment just exit - should never happen, because width() >= virtualWidth()
|
||||
if (mirror) { //set the corresponding horizontally mirrored pixel
|
||||
if (transpose) strip.setPixelColorXY_fast(start + x, startY + hei_ - y - 1, scaled_col);
|
||||
else strip.setPixelColorXY_fast(start + wid_ - x - 1, startY + y, scaled_col);
|
||||
|
||||
Reference in New Issue
Block a user