Commit Graph

540 Commits

Author SHA1 Message Date
Frank
1350a4111d Arc optimization: symmety at 45degress
If the segment is wider than 20 pixels, we optimize calculations due to symmetry - for smaller arcs the result looks better without optimization.

As a side-effect, we have enough computing power left to go through the complete circumference, avoiding holes.
2024-02-25 22:02:51 +01:00
Frank
8a0b97e0a8 ARC mapping optimization
The biggest optimization was to avoid sin_t / cos_t.
Now let's try to help the compiler optimize the drawing loop.
2024-02-25 19:46:53 +01:00
Frank
e0f08864a2 remove slow and inaccurate math from time critical code
as it turns out, the "_t" functions (from wled_math.cpp) are about 3 times (!!!) slower than the standard functions.

* mapping modes : Arc and Circle
* effects: 2D Drift, 2D Drift Rose
2024-02-25 19:36:29 +01:00
Frank
ff56cf0ee9 Pinwheel speed optimizations
* use "float" math only - sinf(), cosf(), roundf()
* use fewer "rays" for medium-sized matrix (<=32 pixels wide/high)
* ray drawing optimized to use fixed point

up to 80% faster on esp32 and esp32-S3; -S2/-C3 should also see benefits, as these do not have floating point support in hardware.
2024-02-25 18:00:19 +01:00
Frank
96d275e2b9 minor optimization for PinWheel mapping
use "float" math functions. These are slightly faster. By avoiding to pull in "double" math we also save some flash space.
2024-02-23 12:34:14 +01:00
Brandon502
017b572897 Expand1D PinWheel changes 2024-02-21 17:44:08 -05:00
Brandon502
3e131014b2 Added PinWheel Expand1D Effect 2024-02-20 17:26:36 -05:00
Frank
86b0eeafb7 Ledmaps loading bugfix (wrong size, memory corruption)
* File.readbytesuntil does not terminate strings. So the string buffer needs to be filled with zero's before reading.
* fix crashes (mem corruption) when ledmap file has too many / too few entries.
* initialize unused map places with "identity" (same led) mapping

before fix:
> Reading LED map from /ledmap1.json
> ("width": 60edmap1.json)  ("height": 90edmap1.json)
> resetSegments 1 60x90
> allocLeds (0,0 to 60,90), 16200 from 0
> allocLeds (0,0 to 60,90), 16200 from 6
> deserializeMap 60 x 90 customMappingTable alloc 5400 from 0

after:
> Reading LED map from /ledmap1.json
> ("width": 60)  ("height": 9)
> resetSegments 1 60x9
> allocLeds (0,0 to 60,9), 1620 from 0
> allocLeds (0,0 to 60,9), 1620 from 6
> deserializeMap 60 x 9
> deserializemap customMappingTable alloc 540 from 0
2024-02-20 15:10:25 +01:00
Frank
c9b416a4fe prevent flickering during OTA
I've almost toasted my wiring due to uncontrolled LED flickering during OTA.
So here is the fix - it prevents any strip updates when OTA is ongoing.
2024-02-12 21:53:59 +01:00
Frank
302f18fbfe small speedup
* currentBri() is called for any setpixelColor(), so we can speed up everything (a bit) by allowing the compiler to inline which saves a few cycles of call/return overhead.
* aligned the function with upstream, and added another optimization by only calling progress() when a transition is active.
2024-01-26 17:08:37 +01:00
Frank
01c187f8aa bugfix for #104
this avoids heap corruption, by double-checking that "use global leds" is not configured, before trying to free ledsrgb[].

It is still a mystery why Segment::_globalLeds == nullptr.
2024-01-02 15:52:00 +01:00
Blaz Kristan
f7bfaf02a8 Possible bugfix for #3609 #3616 2023-12-29 17:46:24 +01:00
Frank
684bf0bd8b random palette bugfix
if random palette was used in the startup preset, all LEDs were orange until the first palette cycling happened.
This fix ensures that there is no all-orange palette initially.
2023-12-16 18:44:54 +01:00
Frank
8905992a89 code spell checking - part4 (MM specific) 2023-12-15 00:14:57 +01:00
Frank
ced03f1f08 code spell checking - part1 (core)
I've found a code spellchecker, so this is what can be corrected easily. Changes are only affecting comments, readme and a few user-visible strings. So no functional impact expected.
2023-12-14 22:05:55 +01:00
Blaz Kristan
3eb360dfe1 Fix for #3403 2023-10-06 17:19:25 +02:00
Ewoud
342f99ca27 Effects to Instances: effects non-deterministic: now instead of millis
index.js
- genPresets: Temporary for deterministic effects test: Set to 11/Raibow instead of 1/Random smooth palette

FX.cpp
- replace all millis() by strip.now
2023-09-30 12:23:53 +02:00
Frank
e6e30abfeb 8266: improve accuracy of FPS calculation
based on a similar correction I made in upstream recently.
2023-08-25 16:51:07 +02:00
Frank
eecb0e700b quickfix for effect "double startup" problem
temporary workaround until fixed in upstream.

--> Please disable "Crossfade" in LEDs settings.
2023-08-10 13:58:57 +02:00
Frank
4984c578cc minor speedups
* added IRAM_ATTR_YN to some frequently used color functions
* small optimization for fade_out: pixel already has "target color"
2023-07-21 15:59:32 +02:00
Frank
9a3a97eff1 pre-merge
cleanup:
- version increase
- clean up debug messages
- minor fixes in platformio.ini
- fix compilation with -D WLED_DISABLE_2D

helping the compiler to optimize:
- a few more __attribute__((pure))
- fx.cpp marked a few local functions as "static"
2023-07-13 19:58:48 +02:00
Frank
0fb5edc4a2 robustness improvements from upstream
(from upstream alt-buffer branch)
* prevent drawing into inactive segments
* robustness improvements for transitions
2023-07-13 18:34:46 +02:00
Frank
c64f74a611 fix for random crashes on changing presets (UI)
Segments are created/deleted on-the-fly; it seems that "local leds" buffers did not follow properly.
* revise segment copy/move constructors
* de-optimize use of local leds (as they need to be re-allocated when segment size changes)
* minor stability improvements
2023-07-08 22:40:43 +02:00
Frank
a45306b141 blur speedup
it seems that SEGMENT.blur() is the main bottleneck for many 2D effects.

This change optimizes performance of the function:
* avoid to re-write unchanged pixels
* early exit when blur_amount == 0 (=nothing to do)
* use _fast_ types where possible

I've seen up to 20% speedup with this change.
2023-07-08 20:06:52 +02:00
Frank
5fe12eef5a Merge branch 'mdev' into audio_fastpath 2023-07-08 19:23:36 +02:00
Frank
2562f308ca fix power calculation for NeoPixelBusLg
power estimation results from estimateCurrentAndLimitBri() were too low (example: estimated 1.3Amp, measured 1.6Amp). This change corrects the power calculation. Due to the changed behavior of getPixelColor, powerSum must be used as-is, not scaled down again by brightness.
2023-07-08 19:13:20 +02:00
Frank
7e34781212 ABL optimization
this optimization avoids to apply brightness two times .

NeoPixelBusLg has already applied global brightness at sPC. Due to internal working of the Lg bus, its sufficient to only post-apply scaling, and set the new (scaled) brightness for the next frame.
2023-07-03 19:41:51 +02:00
Frank
a71be02b89 de-optimization
first version still cased some flickering.
This de-optimization makes LEDs more stable.
2023-07-03 19:41:51 +02:00
Frank
358f37b7ca optimization for ABL hotfix
* adding an optional parameter to setBrightness(). ApplyPostAdjustments() will only be called if `immediate=true`. Only ABL will use immediate=true, to ensure electrical safety of equipment.

This allows some optimizations of performance, as ApplyPostAdjustments() is time consuming.

* busses.setBrightness(bri) --> applied to all future pixels (fast, lossless)
* busses.setBrightness(bri, true) --> applied directly to all previously set pixels (slower, lossy)
2023-07-03 19:41:50 +02:00
Frank
29644ccf79 ABL optimization
this optimization avoids to apply brightness two times .

NeoPixelBusLg has already applied global brightness at sPC. Due to internal working of the Lg bus, its sufficient to only post-apply scaling, and set the new (scaled) brightness for the next frame.
2023-07-03 19:26:02 +02:00
Frank
ecf331792b de-optimization
first version still cased some flickering.
This de-optimization makes LEDs more stable.
2023-07-03 19:26:02 +02:00
Frank
3cc1d30090 optimization for ABL hotfix
* adding an optional parameter to setBrightness(). ApplyPostAdjustments() will only be called if `immediate=true`. Only ABL will use immediate=true, to ensure electrical safety of equipment.

This allows some optimizations of performance, as ApplyPostAdjustments() is time consuming.

* busses.setBrightness(bri) --> applied to all future pixels (fast, lossless)
* busses.setBrightness(bri, true) --> applied directly to all previously set pixels (slower, lossy)
2023-07-01 20:23:39 +02:00
Frank
582b96f846 robustness improvements
* handling of stop = 0 when calculating sizes (avoid unsigned underflow)
* make sure groupLength() is never zero (to avoid div/0)
* gapmaps: check for "(gapSize > 0)" added.

not sure if all the checks are 100% needed, but they will improve robustness in corner cases.
2023-06-21 13:30:40 +02:00
Frank
310daa61a8 improve segment code robustness
* Avoid uint16 underflow in width() and height(): stop > start is possible, and means "inactive segment".

* use size_t for ledsrgbSize, _dataLen and _usedSegmentData -  uint16_t could overflow in some situations.

* try to catch attempts to allocate zero bytes (inactive segment => size 0)
2023-06-21 01:43:26 +02:00
Frank
3127c60b41 Merge branch 'mdev' into audio_fastpath 2023-06-15 20:54:57 +02:00
Ewoud
a450334e46 Part 3 2023-06-15 11:51:22 +02:00
Ewoud
3195606ca8 Part 2 2023-06-15 11:41:19 +02:00
Ewoud
117dd52ce4 Ledmap 1D / no width/height 2023-06-15 11:29:41 +02:00
Ewoud
07fdeb3ab7 Ledmaps without width and height specified 2023-06-13 17:58:00 +02:00
Frank
d4a37ecaea clean up ledmap names when directly reading from file 2023-06-09 17:26:44 +02:00
Frank
64139efc13 clean up ledmap names when directly reading from file 2023-06-09 17:03:04 +02:00
Frank
7dcc8f1d1f enumerateLedmaps improvements
improve reading on ledmap names
* remove trailing " " "," "\r"
* clear buffer between reads
* fix for a 1-byte buffer overflow
2023-06-08 22:31:39 +02:00
Frank
23ea201b43 enumerateLedmaps improvements
improve reading on ledmap names
* remove trailing " " "," "\r"
* clear buffer between reads
* fix for a 1-byte buffer overflow
2023-06-08 22:26:55 +02:00
Ewoud
b473a40037 Tiny things 2023-06-08 19:25:38 +02:00
Ewoud
5c7937507b Bug fix segment view, use ledmapMaxSize (TroyHack) 2023-06-08 19:24:37 +02:00
Ewoud
3560b27dc1 Tiny things 2023-06-08 18:47:56 +02:00
Ewoud
8d43af6acc Bug fix segment view, use ledmapMaxSize (TroyHack) 2023-06-08 18:34:10 +02:00
Ewoud
b95ff2d74f Merge remote-tracking branch 'upstream/main' into mdev 2023-06-07 20:54:04 +02:00
Frank
af6091b493 fixing some memory leaks
* audio_reactive.h: catch memory errors from WiFiUDP
* udp: explicitly flush unused receive buffers.
* wled.cpp: additional debug info about "largest available block"
* FX_fcn.cpp: free _globalLeds before running purgeSegments().
2023-06-07 17:10:32 +02:00
TroyHacks
143f84238f WLED_DEBUG_MAPS flag added 2023-06-06 19:44:02 -04:00