Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bus-level global buffering #3280

Merged
merged 36 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
498dd76
Decouple segment led buffer from global led buffer
Aircoookie Jun 26, 2023
f6e86bf
First global buffer iteration
Aircoookie Jun 26, 2023
61ba16b
Global buffer and ABL fixes
Aircoookie Jun 26, 2023
fa9b151
Slightly more efficient buffer copy to busses
Aircoookie Jun 26, 2023
272f96b
Double buffering at bus level.
blazoncek Jun 30, 2023
858b57d
Return of local leds[]
blazoncek Jul 1, 2023
c9ef034
Build bump/fix
blazoncek Jul 2, 2023
66616e1
Some timings added.
blazoncek Jul 3, 2023
8831c76
restoreColorLossy small optimization
softhack007 Jul 4, 2023
45a0061
reverting _restaurationBri change
softhack007 Jul 5, 2023
ad825b8
Added a few debug timings.
blazoncek Jul 5, 2023
59a144b
Disable global buffer on ESP8266 by default
blazoncek Jul 5, 2023
f437fd6
Code readability.
blazoncek Jul 6, 2023
2ad3ab7
Correct scaling for peek.
blazoncek Jul 6, 2023
822298a
Merge branch 'main' into alt-buffer
Aircoookie Jul 9, 2023
6267d11
Fix compilation and ABL scaling
Aircoookie Jul 9, 2023
fa6070c
Multiple updates:
blazoncek Jul 12, 2023
4766666
Static queued segment bounds
Aircoookie Jul 13, 2023
72a72db
proper rounding of FPS
softhack007 Jul 13, 2023
5e20abd
Move segment bounds queuing to WS2812FX
Aircoookie Jul 13, 2023
57d3585
Merge branch 'main' into alt-buffer
blazoncek Jul 14, 2023
f1e1bd4
Slight optimisation in BusDigial::getPixelColor()
blazoncek Jul 14, 2023
82e01f7
Fixed ABL calculation.
blazoncek Jul 17, 2023
abfb8bb
Fix (almost good) for unbuffered ABL calculations.
blazoncek Jul 17, 2023
ebb4628
Minor correction (slider names)
softhack007 Jul 17, 2023
5ef7cd7
blur bugfix
softhack007 Jul 18, 2023
7dcbb40
Trying to solve ABL bug.
blazoncek Jul 18, 2023
5b9630c
Repaint NPB buffer on brightness updates
Aircoookie Jul 19, 2023
0cf50e8
FX Fireworks optimisation
blazoncek Jul 19, 2023
2fce15d
Restore brightness immediately after show()
Aircoookie Jul 19, 2023
8ccf349
Always repaint NPB buffer on brightness change
Aircoookie Jul 19, 2023
aa54d65
upgrade -S3/-S2/-C3 to platform 5.3.0
softhack007 Jul 20, 2023
2db966b
Improvements for -S3 with PSRAM
softhack007 Jul 20, 2023
050489d
allow Lolin Wifi Fix on -S3
softhack007 Jul 20, 2023
f8e766f
add -S3 PSRAM (qio_opi) to nightly builds
softhack007 Jul 20, 2023
c8fdf37
upgrade to FastLED 3.6.0
softhack007 Jul 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 10 additions & 46 deletions wled00/FX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ uint16_t mode_dynamic(void) {
if (!SEGENV.allocateData(SEGLEN)) return mode_static(); //allocation failed

if(SEGENV.call == 0) {
//SEGMENT.setUpLeds(); //lossless getPixelColor()
//SEGMENT.fill(BLACK);
for (int i = 0; i < SEGLEN; i++) SEGENV.data[i] = random8();
}
Expand Down Expand Up @@ -607,7 +606,6 @@ static const char _data_FX_MODE_TWINKLE[] PROGMEM = "Twinkle@!,!;!,!;!;;m12=0";
uint16_t dissolve(uint32_t color) {
//bool wa = (SEGCOLOR(1) != 0 && strip.getBrightness() < 255); //workaround, can't compare getPixel to color if not full brightness
if (SEGENV.call == 0) {
SEGMENT.setUpLeds(); //lossless getPixelColor()
SEGMENT.fill(SEGCOLOR(1));
}

Expand Down Expand Up @@ -1206,7 +1204,6 @@ uint16_t mode_fireworks() {
const uint16_t height = SEGMENT.virtualHeight();

if (SEGENV.call == 0) {
SEGMENT.setUpLeds(); //lossless getPixelColor()
SEGMENT.fill(SEGCOLOR(1));
SEGENV.aux0 = UINT16_MAX;
SEGENV.aux1 = UINT16_MAX;
Expand Down Expand Up @@ -1905,7 +1902,6 @@ static const char _data_FX_MODE_PRIDE_2015[] PROGMEM = "Pride 2015@!;;";
uint16_t mode_juggle(void) {
if (SEGLEN == 1) return mode_static();
if (SEGENV.call == 0) {
SEGMENT.setUpLeds(); //lossless getPixelColor()
SEGMENT.fill(BLACK);
}

Expand Down Expand Up @@ -4586,7 +4582,6 @@ uint16_t mode_2DBlackHole(void) { // By: Stepko https://editor.soulma

// initialize on first call
if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
}

Expand All @@ -4596,22 +4591,22 @@ uint16_t mode_2DBlackHole(void) { // By: Stepko https://editor.soulma
for (size_t i = 0; i < 8; i++) {
x = beatsin8(SEGMENT.custom1>>3, 0, cols - 1, 0, ((i % 2) ? 128 : 0) + t * i);
y = beatsin8(SEGMENT.intensity>>3, 0, rows - 1, 0, ((i % 2) ? 192 : 64) + t * i);
SEGMENT.addPixelColorXY(x, y, CHSV(i*32, 255, 255));
SEGMENT.addPixelColorXY(x, y, SEGMENT.color_from_palette(i*32, false, PALETTE_SOLID_WRAP, SEGMENT.check1?0:255));
}
// inner stars
for (size_t i = 0; i < 4; i++) {
x = beatsin8(SEGMENT.custom2>>3, cols/4, cols - 1 - cols/4, 0, ((i % 2) ? 128 : 0) + t * i);
y = beatsin8(SEGMENT.custom3 , rows/4, rows - 1 - rows/4, 0, ((i % 2) ? 192 : 64) + t * i);
SEGMENT.addPixelColorXY(x, y, CHSV(i*32, 255, 255));
SEGMENT.addPixelColorXY(x, y, SEGMENT.color_from_palette(255-i*64, false, PALETTE_SOLID_WRAP, SEGMENT.check1?0:255));
}
// central white dot
SEGMENT.setPixelColorXY(cols/2, rows/2, CHSV(0, 0, 255));
SEGMENT.setPixelColorXY(cols/2, rows/2, WHITE);
// blur everything a bit
SEGMENT.blur(16);

return FRAMETIME;
} // mode_2DBlackHole()
static const char _data_FX_MODE_2DBLACKHOLE[] PROGMEM = "Black Hole@Fade rate,Outer Y freq.,Outer X freq.,Inner X freq.,Inner Y freq.;;;2";
static const char _data_FX_MODE_2DBLACKHOLE[] PROGMEM = "Black Hole@Fade rate,Outer Y freq.,Outer X freq.,Inner X freq.,Inner Y freq.,Solid;!;!;2;pal=11";


////////////////////////////
Expand All @@ -4624,7 +4619,6 @@ uint16_t mode_2DColoredBursts() { // By: ldirko https://editor.so
const uint16_t rows = SEGMENT.virtualHeight();

if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
SEGENV.aux0 = 0; // start with red hue
}
Expand Down Expand Up @@ -4678,7 +4672,6 @@ uint16_t mode_2Ddna(void) { // dna originally by by ldirko at https://pa
const uint16_t rows = SEGMENT.virtualHeight();

if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
}

Expand All @@ -4705,7 +4698,6 @@ uint16_t mode_2DDNASpiral() { // By: ldirko https://editor.soulma
const uint16_t rows = SEGMENT.virtualHeight();

if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
}

Expand Down Expand Up @@ -4751,7 +4743,6 @@ uint16_t mode_2DDrift() { // By: Stepko https://editor.soulmateli
const uint16_t rows = SEGMENT.virtualHeight();

if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
}

Expand Down Expand Up @@ -4782,7 +4773,6 @@ uint16_t mode_2Dfirenoise(void) { // firenoise2d. By Andrew Tuline
const uint16_t rows = SEGMENT.virtualHeight();

if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
}

Expand Down Expand Up @@ -4817,7 +4807,6 @@ uint16_t mode_2DFrizzles(void) { // By: Stepko https://editor.so
const uint16_t rows = SEGMENT.virtualHeight();

if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
}

Expand Down Expand Up @@ -4856,8 +4845,6 @@ uint16_t mode_2Dgameoflife(void) { // Written by Ewoud Wijma, inspired by https:

CRGB backgroundColor = SEGCOLOR(1);

if (SEGENV.call == 0) SEGMENT.setUpLeds();

if (SEGENV.call == 0 || strip.now - SEGMENT.step > 3000) {
SEGENV.step = strip.now;
SEGENV.aux0 = 0;
Expand Down Expand Up @@ -5123,7 +5110,6 @@ uint16_t mode_2Dmatrix(void) { // Matrix2D. By Jeremy Williams.
const uint16_t rows = SEGMENT.virtualHeight();

if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
}

Expand Down Expand Up @@ -5268,7 +5254,6 @@ uint16_t mode_2DPlasmaball(void) { // By: Stepko https://edito
const uint16_t rows = SEGMENT.virtualHeight();

if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
}

Expand Down Expand Up @@ -5316,7 +5301,6 @@ uint16_t mode_2DPolarLights(void) { // By: Kostyantyn Matviyevskyy https
CRGBPalette16 auroraPalette = {0x000000, 0x003300, 0x006600, 0x009900, 0x00cc00, 0x00ff00, 0x33ff00, 0x66ff00, 0x99ff00, 0xccff00, 0xffff00, 0xffcc00, 0xff9900, 0xff6600, 0xff3300, 0xff0000};

if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
SEGENV.step = 0;
}
Expand Down Expand Up @@ -5366,7 +5350,6 @@ uint16_t mode_2DPulser(void) { // By: ldirko https://edi
const uint16_t rows = SEGMENT.virtualHeight();

if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
}

Expand Down Expand Up @@ -5394,7 +5377,6 @@ uint16_t mode_2DSindots(void) { // By: ldirko http
const uint16_t rows = SEGMENT.virtualHeight();

if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
}

Expand Down Expand Up @@ -5426,7 +5408,6 @@ uint16_t mode_2Dsquaredswirl(void) { // By: Mark Kriegsman. https://g
const uint16_t rows = SEGMENT.virtualHeight();

if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
}

Expand Down Expand Up @@ -5469,7 +5450,6 @@ uint16_t mode_2DSunradiation(void) { // By: ldirko https://edi
byte *bump = reinterpret_cast<byte*>(SEGENV.data);

if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
}

Expand Down Expand Up @@ -5517,7 +5497,6 @@ uint16_t mode_2Dtartan(void) { // By: Elliott Kember https://editor.so
const uint16_t rows = SEGMENT.virtualHeight();

if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
}

Expand Down Expand Up @@ -5557,7 +5536,6 @@ uint16_t mode_2Dspaceships(void) { //// Space ships by stepko (c)05.02.21 [ht
const uint16_t rows = SEGMENT.virtualHeight();

if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
}

Expand Down Expand Up @@ -5626,7 +5604,6 @@ uint16_t mode_2Dcrazybees(void) {
bee_t *bee = reinterpret_cast<bee_t*>(SEGENV.data);

if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
for (size_t i = 0; i < n; i++) {
bee[i].posX = random8(0, cols);
Expand Down Expand Up @@ -5696,7 +5673,6 @@ uint16_t mode_2Dghostrider(void) {

const size_t maxLighters = min(cols + rows, LIGHTERS_AM);

if (SEGENV.call == 0) SEGMENT.setUpLeds();
if (SEGENV.aux0 != cols || SEGENV.aux1 != rows) {
SEGENV.aux0 = cols;
SEGENV.aux1 = rows;
Expand Down Expand Up @@ -5781,7 +5757,6 @@ uint16_t mode_2Dfloatingblobs(void) {
if (!SEGENV.allocateData(sizeof(blob_t))) return mode_static(); //allocation failed
blob_t *blob = reinterpret_cast<blob_t*>(SEGENV.data);

if (SEGENV.call == 0) SEGMENT.setUpLeds();
if (SEGENV.aux0 != cols || SEGENV.aux1 != rows) {
SEGENV.aux0 = cols; // re-initialise if virtual size changes
SEGENV.aux1 = rows;
Expand Down Expand Up @@ -5947,7 +5922,6 @@ uint16_t mode_2Ddriftrose(void) {
const float L = min(cols, rows) / 2.f;

if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
}

Expand Down Expand Up @@ -6102,7 +6076,6 @@ uint16_t mode_2DSwirl(void) {
const uint16_t rows = SEGMENT.virtualHeight();

if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
}

Expand Down Expand Up @@ -6149,7 +6122,6 @@ uint16_t mode_2DWaverly(void) {
const uint16_t rows = SEGMENT.virtualHeight();

if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
}

Expand Down Expand Up @@ -6378,7 +6350,6 @@ uint16_t mode_matripix(void) { // Matripix. By Andrew Tuline.
int16_t volumeRaw = *(int16_t*)um_data->u_data[1];

if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
}

Expand Down Expand Up @@ -6506,7 +6477,6 @@ uint16_t mode_pixelwave(void) { // Pixelwave. By Andrew Tuline.
// even with 1D effect we have to take logic for 2D segments for allocation as fill_solid() fills whole segment

if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
}

Expand Down Expand Up @@ -6732,7 +6702,6 @@ uint16_t mode_DJLight(void) { // Written by ??? Adapted by Wil
uint8_t *fftResult = (uint8_t*)um_data->u_data[2];

if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
}

Expand Down Expand Up @@ -6801,7 +6770,6 @@ uint16_t mode_freqmatrix(void) { // Freqmatrix. By Andreas Plesch
float volumeSmth = *(float*)um_data->u_data[0];

if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
}

Expand Down Expand Up @@ -6840,7 +6808,7 @@ uint16_t mode_freqmatrix(void) { // Freqmatrix. By Andreas Plesch

return FRAMETIME;
} // mode_freqmatrix()
static const char _data_FX_MODE_FREQMATRIX[] PROGMEM = "Freqmatrix@Time delay,Sound effect,Low bin,High bin,Sensivity;;;1f;m12=3,si=0"; // Corner, Beatsin
static const char _data_FX_MODE_FREQMATRIX[] PROGMEM = "Freqmatrix@Speed,Sound effect,Low bin,High bin,Sensivity;;;1f;m12=3,si=0"; // Corner, Beatsin


//////////////////////
Expand Down Expand Up @@ -6903,7 +6871,6 @@ uint16_t mode_freqwave(void) { // Freqwave. By Andreas Pleschun
float volumeSmth = *(float*)um_data->u_data[0];

if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
}

Expand Down Expand Up @@ -6944,7 +6911,7 @@ uint16_t mode_freqwave(void) { // Freqwave. By Andreas Pleschun

return FRAMETIME;
} // mode_freqwave()
static const char _data_FX_MODE_FREQWAVE[] PROGMEM = "Freqwave@Time delay,Sound effect,Low bin,High bin,Pre-amp;;;1f;m12=2,si=0"; // Circle, Beatsin
static const char _data_FX_MODE_FREQWAVE[] PROGMEM = "Freqwave@Speed,Sound effect,Low bin,High bin,Pre-amp;;;1f;m12=2,si=0"; // Circle, Beatsin


///////////////////////
Expand Down Expand Up @@ -7088,7 +7055,6 @@ uint16_t mode_waterfall(void) { // Waterfall. By: Andrew Tulin
if (FFT_MajorPeak < 1) FFT_MajorPeak = 1; // log10(0) is "forbidden" (throws exception)

if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
SEGENV.aux0 = 255;
SEGMENT.custom1 = *binNum;
Expand Down Expand Up @@ -7205,7 +7171,6 @@ uint16_t mode_2DFunkyPlank(void) { // Written by ??? Adapted by Wil
uint8_t *fftResult = (uint8_t*)um_data->u_data[2];

if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
}

Expand Down Expand Up @@ -7418,7 +7383,6 @@ uint16_t mode_2Dsoap() {

// init
if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
*noise32_x = random16();
*noise32_y = random16();
*noise32_z = random16();
Expand Down Expand Up @@ -7536,12 +7500,12 @@ uint16_t mode_2Doctopus() {
SEGENV.aux1 = rows;
*offsX = SEGMENT.custom1;
*offsY = SEGMENT.custom2;
const uint8_t C_X = cols / 2 + (SEGMENT.custom1 - 128)*cols/255;
const uint8_t C_Y = rows / 2 + (SEGMENT.custom2 - 128)*rows/255;
const int C_X = (cols / 2) + ((SEGMENT.custom1 - 128)*cols)/255;
const int C_Y = (rows / 2) + ((SEGMENT.custom2 - 128)*rows)/255;
for (int x = 0; x < cols; x++) {
for (int y = 0; y < rows; y++) {
rMap[XY(x, y)].angle = 40.7436f * atan2f(y - C_Y, x - C_X); // avoid 128*atan2()/PI
rMap[XY(x, y)].radius = hypotf(x - C_X, y - C_Y) * mapp; //thanks Sutaburosu
rMap[XY(x, y)].angle = 40.7436f * atan2f((y - C_Y), (x - C_X)); // avoid 128*atan2()/PI
rMap[XY(x, y)].radius = hypotf((x - C_X), (y - C_Y)) * mapp; //thanks Sutaburosu
}
}
}
Expand Down
Loading
Loading