Gravimeter: bars turn black at full volume (uint8_t(segmentSampleAvg*8) overflows)
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- cpp
- Área
- embedded-iot
Línea de trabajo
Empieza en wled00/FX.cpp, en mode_gravcenter_base(), y busca la expresión de mezcla de Gravimeter señalada en el issue; compárala con la línea correspondiente de Gravcenter. Reproduce el problema con el efecto Gravimeter a alta intensidad e inspecciona la cantidad de mezcla cuando la barra alcanza su altura máxima. El trabajo estará terminado cuando las barras permanezcan encendidas al volumen máximo sin cambiar el comportamiento de los demás modos.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- C++
- Estrellas
- 18.8k
- Forks
- 4.4k
- Merge medio
- 4 d 6 h
- PR fusionados (30 d)
- 12
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de wled/WLED
-
bug cannot reproduce
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
wled/WLED#5840 · 12 comentarios ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
wled/WLED#5836 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
backburner enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
wled/WLED#4132 · 5 comentarios · 2 reacciones ·
Los mantenedores suelen responder en 1 día
-
discussion enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
wled/WLED#3478 · 13 comentarios ·
Los mantenedores suelen responder en 1 día
-
Add all possible timezonesAbiertoenhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
wled/WLED#2193 · 15 comentarios ·
Los mantenedores suelen responder en 1 día
Issues similares
-
bug product: very_good_flutter_plugin
Dificultad 1/5 1-3 horas Aptitud para principiantes 78/100
VeryGoodOpenSource/very_good_templates#654 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
bug C/C++ code
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
webarkit/WebARKitLib#84 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
rr-debugger/rr#4111 ·
Los mantenedores suelen responder en 3 días