Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto Apto para principiantes
#5,891 7 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@DedeHai ya está trabajando en esto.

Desde el 8/10/2026.

  • #5893 de @DedeHai — abierto

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

bug confirmed
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

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de wled/WLED

Todos los issues de wled/WLED

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.