Flipper-XFW / Xtreme-Firmware

The Dom amongst the Flipper Zero Firmware. Give your Flipper the power and freedom it is really craving. Let it show you its true form. Dont delay, switch to the one and only true Master today!
https://flipper-xtre.me
GNU General Public License v3.0
9.39k stars 684 forks source link

Fixing random RGB flickering #567

Closed HaxSam closed 7 months ago

HaxSam commented 7 months ago

What's new

the behavior before was on sometimes on button clicks the RGB couldn't be fully update and flicker for a second to another color and looked really buggy


For the reviewer

Willy-JL commented 7 months ago

i see, yeah this could work. however, if the case you explain where it doesnt manage to update properly happens at boot, or when changing brightness, then it would remain glitched... i guess this is good enough for now, but would be ideal to find why it can bug out at all and fix that instead eventually

HaxSam commented 7 months ago

I could go more in depth what's happening there, but I think the main problem is that it tries to update the RGB settings on every single button press and sometimes some other workflow gets in the way and disturbs the RGB update in the bit stream.

Willy-JL commented 7 months ago

interesting... i see there is furi_kernel_lock() and unlock around the rgb backlight driver update... these functions are not used anywhere else, instead those highly sensitive usages tend to use FURI_CRITICAL_ENTER() and exit... can you try changing that?

HaxSam commented 7 months ago

I reverted my changes and tried it with FURI_CRITICAL_ENTER() but the bug still remains, for example when I use orgasmotron the RGB color will change but instead of flickering it stays at a solid color when I held a button pressed. On the other hand, the bug doesn't occur anymore on animation change. In the log trace I still see that it does an RGB update on every button press.

Willy-JL commented 7 months ago

interesting. i will merge this, but i also want to get to the bottom of this. what you say with the orgasmotron app makes me wonder if a mutex between rgb driver and vibro motor would solve it. but then again, notification service uses a event queue, so theoretically only one or the other should be happening / changing state at any given time... unless this is some hardware interrupt magic that goes way over my head...

HaxSam commented 7 months ago

I had the idea that I could try to debug with GDB when I get my dev board, but overall I would need a deeper understanding of the firmware to help to find a proper fix.

Willy-JL commented 7 months ago

I would do the same, but have no rgb backlight xD

(Yet)

HaxSam commented 7 months ago

Gonna get my dev board on Monday when I figure something out, we could discuss it on discord maybe.