Spectrum analyzer with LVGL?

Hi, guys.

I’m trying to implement spectrum analyzer on stm32f303 + ili9341 + freertos. (So one task runs lvgl and the logic is in other tasks). I want to implement an audio spectrum analyzer like in this video Teensy 4.0 and LittlevGL - YouTube (where he plays music). How to do it with LVGL? I tried doing it with Line Widget, so each bar is a line and it is super slow even if I have only 40 bars. Is there other way?

Little bump

Not a widget, it’s basic lv_obj, you need handle the bar draw by your self.

You can refer here: lv_example_music

And I just made a demo with microphone input, using the above code.

twitter

Hi,
I made some upgrade. Link

I want make this as a widgets, is it possible? @kisvegabor (sorry to bother you :smile: ) if possible, where is a good start point, i don’t know how to write customer widgets :slight_smile:

Very nice! Not bothering, thanks for tagging :slightly_smiling_face:

We don’t have a dedicated docs for custom widgets yet but you can take a look at e.g. lv_win which is a quite simple one. I believe the same pattern can be used here too.

Thanks for reply.
I will try, but for now I made a very simple demo for use :slight_smile:

One approach that worked well for me was updating the chart/bar values at a fixed refresh rate (around 20–30 FPS) and keeping the FFT processing separate from the UI thread. That usually keeps LVGL responsive even with a decent number of bands.
If anyone is looking for ideas on scaling and smoothing the spectrum data, I found the examples on Sound Spectrum Analyzer Online useful for understanding how different analyzers present the FFT output. Not LVGL-specific, but it helped me tune the visual side of the display.