Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support more than 256 leds #24675

Open
mateuszdrwal opened this issue Dec 4, 2024 · 4 comments
Open

Support more than 256 leds #24675

mateuszdrwal opened this issue Dec 4, 2024 · 4 comments

Comments

@mateuszdrwal
Copy link

I made a split keyboard with 4 leds under each key (10 for the 2 2U keys) and the results are pretty spectacular. This sums up to 162 leds per half, or 324 leds on both. QMK currently uses a uint_8 in most places to iterate over leds, so this required some patches which I want to polish up and contribute back.

I'm not intimately familiar with the codebase or nuances of QMK, so it would be great with some guidance on the best way to implement it for this project. I assume RAM is enough of a concern for the AVR platform that replacing all relevant uint_8 with uint_16 would be problematic? Would a typedef uintX_t num_leds_t then be best setting the type to uint16_t if RGB_MATRIX_LED_COUNT > 255, and using that type everywhere instead? Anything else I should know before putting time into implementing this properly?

@drashna
Copy link
Member

drashna commented Dec 6, 2024

In general, yeah, AVR ram limitations are usually an issue.

I'm not sure of the best solution, but a typedef sounds like probably the best option here. There is a similar thing for the layer state bitmask, for instance.

Also, damn, that board looks spectacular

@getreuer
Copy link
Contributor

getreuer commented Dec 6, 2024

That board is gorgeous!

Maybe the LED index type can be defined conditionally based on RGB_MATRIX_LED_COUNT? It would be nice if it works automatically without needing an additional configuration. Perhaps:

#if (RGB_MATRIX_LED_COUNT) <= 255
typedef uint8_t led_index_t;  // Continue using uint8_t by default.
#else
typedef uint_fast16_t led_index_t;  // If there are more than 255 LEDs.
#endif

bool SOME_EFFECT(effect_params_t* params) {
    LED_MATRIX_USE_LIMITS(led_min, led_max);
    for (led_index_t i = led_min; i < led_max; i++) {
       ...

@mateuszdrwal
Copy link
Author

Yep, that's what I'm thinking. led_index_t is probably a better type name than what I came up with.

@christrotter
Copy link

I ran into this on my last board, but dang, your implementation of 'maxing out led count' is far more wondrous.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants