You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

ledmap.c 642B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include <avr/pgmspace.h>
  2. #include "ledmap.h"
  3. #include "debug.h"
  4. #ifdef LEDMAP_ENABLE
  5. static const uint16_t ledmaps[LED_COUNT] PROGMEM = {
  6. [0] = LEDMAP_NUM_LOCK,
  7. [1] = LEDMAP_CAPS_LOCK,
  8. [2] = LEDMAP_SCROLL_LOCK
  9. };
  10. static uint8_t usb_led;
  11. void kbd_led_set(uint8_t usb_led);
  12. ledmap_t ledmap_get_code(uint8_t index)
  13. {
  14. return (ledmap_t) { .code = pgm_read_word(&ledmaps[index]) };
  15. }
  16. void ledmap_led_init(void)
  17. {
  18. usb_led = 0;
  19. }
  20. void ledmap_led_on(uint8_t index)
  21. {
  22. usb_led |= (1<<index);
  23. kbd_led_set(usb_led);
  24. }
  25. void ledmap_led_off(uint8_t index)
  26. {
  27. usb_led &= ~(1<<index);
  28. kbd_led_set(usb_led);
  29. }
  30. #endif