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

hardware: ROWS, COLS, LED_COUNT and a bit of int8_t #432

Merged
merged 4 commits into from Oct 19, 2018
Merged

Conversation

algernon
Copy link
Contributor

The ultimate goal of this pull request was to eliminate the warnings emitted for boards with no LEDs. To achieve this, we changed the led index type from uint8_t to int8_t. But while there, the code has been cleaned up a little, by moving ROWS, COLS and LED_COUNT into the hardware classes, with the #define'd names referencing those.

Furthermore, to make sure that the LED code does not cause any issues when included into boards with no LEDs, the code has been augmented with if (!Kaleidoscope.has_leds) return; -like constructs, so that they bail out early on led-less keyboards.

This fixed #385.

In an attempt to move away from magic, global defines, move the `ROWS`, `COLS`,
and `LED_COUNT` defines to the hardware class. Backwards-compatible defines are
provided by `<Kaleidoscope.h>`.

This is just a first step, no users are updated just yet.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
Intended to make it easier for LED-using code to bail out early, this simple
constant will tell us whether the board has LEDs or if it does not.

Because this will be used regularly, by code not close to the hardware,
`Kaleidoscope.has_leds` is an alias to `KeyboardHardware.has_leds`.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
LED related functions should be as close to no-op on LED-less hardware as
possible. For this reason, guard all relevant points with an early exit in the
LED-less case.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
This allows us to do `i < LED_COUNT` comparisons on boards with no LEDs. All
places that did this comparison have been updated to use `int8_t`, as were all
places that use a LED index.

Together with the previous commits, fixes #385.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
@algernon algernon added bug Something isn't working leds Issues related to LEDs labels Oct 19, 2018
@obra obra merged commit edee6bf into master Oct 19, 2018
@algernon algernon deleted the f/led_count/int8_t branch October 20, 2018 04:51
@algernon algernon mentioned this pull request Oct 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working leds Issues related to LEDs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LEDControl: Turn to no-op when LED_COUNT == 0?
2 participants