Will LED_COUNT
be 0
or ROWS*COLS
for non-LED keyboards? I ask because I’m writing some code where I need to divide by it. Thanks!
It will be 0 for non-led boards.
OK then I guess for (int i=0; i < LED_COUNT; ++i
will immediately fail.
A related question, is it guaranteed to be equal to ROWS*COLS
for keyboards with LEDs?
Yeah, that should work. A few plugins are using similar constructs.
For now, yes, because the only board with per-key LEDs Kaleidoscope supports is the Model01, which has the same amount of LEDs as ROWS*COLS
. This is not necessarily true for other boards: the Dygma Raise has fewer LEDs (because there are unused parts of the matrix), and so does the ErgoDox EZ Glow.
I notice some recent code:
if (!Kaleidoscope.has_leds)
return;
If I use this I can confidently divide by LED_COUNT
in subsequent code? Kaleidoscope.has_leds
is guaranteed to be equal to LED_COUNT != 0
?
static constexpr bool has_leds = (KeyboardHardware.led_count > 0);
So yes, if you use if (!Kaleidoscope.has_leds) return;
, you can be sure that anything past that will see LED_COUNT
being higher than zero.