Skip to content

Commit

Permalink
playing with Fire2012
Browse files Browse the repository at this point in the history
* speedup: add functions to only blur rows or columns (50% faster)

* fire2012: tinkering with bur options. Vertical blur only when slider < 64 (faster); extra blur for  slider values >192 (bush burn)
  • Loading branch information
softhack007 committed Aug 9, 2024
1 parent 89412b9 commit a44aa92
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 4 additions & 2 deletions wled00/FX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2148,7 +2148,7 @@ uint16_t mode_fire_2012() {

// Step 4. Map from heat cells to LED colors
for (int j = 0; j < SEGLEN; j++) {
SEGMENT.setPixelColor(indexToVStrip(j, stripNr), ColorFromPalette(SEGPALETTE, min(heat[j],byte(240)), 255, NOBLEND));
SEGMENT.setPixelColor(indexToVStrip(j, stripNr), ColorFromPalette(SEGPALETTE, min(heat[j], byte(240)), 255, NOBLEND));
}
}
};
Expand All @@ -2158,7 +2158,9 @@ uint16_t mode_fire_2012() {

if (SEGMENT.is2D()) {
uint8_t blurAmount = SEGMENT.custom2 >> 2;
SEGMENT.blur(blurAmount);
if (blurAmount > 48) blurAmount += blurAmount-48; // extra blur when slider > 192 (bush burn)
if (blurAmount < 16) SEGMENT.blurCols(SEGMENT.custom2 >> 1); // no side-burn when slider < 64 (faster)
else SEGMENT.blur(blurAmount);
}

if (it != SEGENV.step)
Expand Down
10 changes: 10 additions & 0 deletions wled00/FX.h
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,16 @@ typedef struct Segment {
uint32_t __attribute__((pure)) color_from_palette(uint_fast16_t, bool mapping, bool wrap, uint8_t mcol, uint8_t pbri = 255);
uint32_t __attribute__((pure)) color_wheel(uint8_t pos);

// 2D Blur: shortcuts for bluring columns or rows only (50% faster than full 2D blur)
inline void blurCols(fract8 blur_amount, bool smear = false) { // blur all columns
const unsigned cols = virtualWidth();
for (unsigned k = 0; k < cols; k++) blurCol(k, blur_amount, smear);
}
inline void blurRows(fract8 blur_amount, bool smear = false) { // blur all rows
const unsigned rows = virtualHeight();
for ( unsigned i = 0; i < rows; i++) blurRow(i, blur_amount, smear);
}

// 2D matrix
#ifndef WLEDMM_FASTPATH
inline uint16_t virtualWidth() const { // WLEDMM use fast types, and make function inline
Expand Down

0 comments on commit a44aa92

Please sign in to comment.