Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Gravimeter: bars turn black at full volume (uint8_t(segmentSampleAvg*8) overflows)

Aperta Adatta ai principianti
#5,891 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@DedeHai ci sta già lavorando.

Dal 8/10/2026.

  • #5893 di @DedeHai — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp
Ambito
embedded-iot

Direzione di ricerca

Inizia in wled00/FX.cpp, in mode_gravcenter_base(), e individua l’espressione di fusione di Gravimeter indicata nell’issue; confrontala con la riga corrispondente di Gravcenter. Riproduci il problema con l’effetto Gravimeter ad alta intensità e controlla la quantità di fusione quando la barra raggiunge l’altezza massima. Il lavoro è completato quando le barre rimangono accese al volume massimo senza modificare il comportamento delle altre modalità.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
What happened?

With the AudioReactive Gravimeter effect, the meter tracks volume normally until it reaches the top. At that point every bar goes (almost) black and only the peak/gravity pixel stays lit. At full volume the whole segment is dark except that one pixel.

Versions

16.0.1 (ESP32 release build)
Same code on main @ d2c00c57f8

To Reproduce Bug

Setup
ESP32-PICO-D4 (M5Stack Atom Echo), built-in PDM mic (SPM1423), AGC on. SK6812 RGBW. Seen on an 8×8 matrix with 1D→2D "Bar" mapping, but the cause doesn't depend on the mapping, so 1D strips are affected too.

Steps to reproduce

Select Gravimeter with default intensity (128) and a black secondary colour (the default).
Play loud audio so the meter reaches the top of the segment.
The bars disappear, and only the peak pixel remains.

Cause
In mode_gravcenter_base(), Gravimeter mode (FX.cpp#L6856 @ v16.0.1):

SEGMENT.setPixelColor(i, color_blend(SEGCOLOR(1), SEGMENT.color_from_palette(index, false, PALETTE_SOLID_WRAP, 0), uint8_t(segmentSampleAvg*8)));

For Gravimeter, segmentSampleAvg = volumeSmth * intensity / 255 * 0.25, which can reach about 63.75. The bar height mapf(segmentSampleAvg2, 0, 64, 0, SEGLEN-1) reaches full height at segmentSampleAvg == 32, which is exactly where segmentSampleAvg8 passes 255. Casting that out-of-range float to uint8_t wraps on ESP32 (it's undefined behaviour in C++). The blend amount drops to near 0, so every bar becomes SEGCOLOR(1) (black by default). The peak pixel is drawn straight from the palette, so it stays lit.

Gravcenter, Gravcentric and Gravfreq use the same expression but scale by 0.125, which tops out at about 31.9, so they don't overflow.

Suggested fix
Clamp before the cast:

uint8_t(fminf(segmentSampleAvg * 8.0f, 255.0f))

The same clamp could go on the Gravcenter line (#L6878–6879) for safety.

Workaround
Noisemeter has no such overflow, or keep Gravimeter's intensity below 128 (but then it never reaches the top row).

Expected Behavior

At max intensity, all lights should be lit, rather than the top row of the matrix only.

Install Method

Self-Compiled

What version of WLED?

16.0.1 (ESP32 release build)

Which microcontroller/board are you seeing the problem on?

ESP32

Relevant log/trace output

Anything else?

No response

Code of Conduct
  • I agree to follow this project's Code of Conduct
Lingua principale
C++
Stelle
18.8k
Fork
4.4k
Merge medio
4g 6h
PR unite (30g)
12

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di wled/WLED

Tutte le issue di wled/WLED

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.