Open p3lim opened 8 years ago
It makes sense. I like to change LED api it self later but this would be useful until then.
Only adding the attribute 'weak' is enough for this pupose? don't you need default implementation somewhere?
It's enough, in my tests it built without errors/warnings.
I just tested, it can compiled as you said but it stops working or run away when pressing Capslock.
From my understanding with weak attribute symbols are compiled as 0(EDIT: when no implementation is given). So if you don't have any implementation of led_set()
the weak reference 0 is used when it is called. In the end it jumps into address 0 and go away.
I guess we have two solutions;
__attribute__((weak))
void led_set(uint8_t usb_led)
{
}
or use alias like: __attribute__((weak, alias("_led_set")))
?
led_set()
is called.diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c
index eb7b096..bfca3e7 100644
--- a/tmk_core/common/keyboard.c
+++ b/tmk_core/common/keyboard.c
@@ -173,5 +173,5 @@ MATRIX_LOOP_END:
void keyboard_set_leds(uint8_t leds)
{
if (debug_keyboard) { debug("keyboard_set_led: "); debug_hex8(leds); debug("\n"); }
- led_set(leds);
+ if (led_set) led_set(leds);
}
http://www.cs.virginia.edu/~wh5a/blog/The%20weak%20attribute%20of%20gcc.html
This makes LEDs optional, lots of boards don't have any.