KMKfw / kmk_firmware

Clackety Keyboards Powered by Python
https://kmkfw.zulipchat.com
Other
1.45k stars 485 forks source link

rgb_2d: 2D RGB effects extension. #985

Open Gadgetoid opened 5 months ago

Gadgetoid commented 5 months ago

Add a 2D RGB effects extensions which allows for effects like Larson scanning or rainbow cycling to span the whole width/height of a board.

After making RGB fast on the Keybow 2040 I wanted some nice effects to run on it.

This is a very early prototype of a 2D RGB effects extension.

Features:

Limitations:

  1. Supports only one PixelBuf or compatible, use an extension instance for each PixelBuf
  2. All key binding and customisation functionality has been removed until the core is finished
  3. Effects are functions which return an animate closure, they can set up some basic variables to store state, or accept config arguments but mostly only take a "t" variable from which RGB effects are algorithmically derived
  4. Only tested on a 4x4 matrix powered by an RP2040

TODO:

Gadgetoid commented 5 months ago

I should probably also pay attention to the mentioned issues here: https://kmkfw.zulipchat.com/#narrow/stream/384078-KMK-development/topic/RGB.20Feature.3F

I don't believe animations really need start and stop methods, they should be as close to stateless - think pixel shader - as possible. They serve only to answer the question: "what colour should this LED be at this time."

rgb_2d is not trying to refactor rgb but there are probably few reasons why it couldn't replace it.

Key awareness is something I looked into but I don't know enough about the codebase to tackle it yet. I wanted animation effects that would respond to a keypress but without an LED->Key map and a position aware keypress handler that's a non starter.

xs5871 commented 5 months ago

Matrix animations, or even some kind of positional awareness of addressable LEDs would be a sensible addition. What I don't want to happen is yet another LED extension that shares 80% of the funcionality with the other 4.

Gadgetoid commented 5 months ago

I couldn’t even find the other four. Did I miss a link somewhere?

But- yes - agreed.

xs5871 commented 5 months ago

rgb, peg_rgb_matrix, led, statusled all share at least some kind of functionality. The "other 4" was more of a "O(4)" estimate.

Gadgetoid commented 5 months ago

Haha!

I’m already planning out another rewrite since I do a lot of Things With LEDs and have some Ideas. Regrettably I have few actual boards to test with so I’m probably going to have to make one first 🤣