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.h 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef LEDMAP_H
  2. #define LEDMAP_H
  3. #include "stdint.h"
  4. #if (LED_COUNT <= 8)
  5. typedef uint8_t led_pack_t;
  6. #elif (LED_COUNT <= 16)
  7. typedef uint16_t led_pack_t;
  8. #elif (LED_COUNT <= 32)
  9. typedef uint32_t led_pack_t;
  10. #else
  11. #error "LED_COUNT: invalid value"
  12. #endif
  13. typedef led_pack_t led_state_t;
  14. #if (LED_COUNT <= 16)
  15. #define LED_BIT(i) (1U<<(i))
  16. #elif (LED_COUNT <= 32)
  17. #define LED_BIT(i) (1UL<<(i))
  18. #else
  19. #error "LED_COUNT: invalid value"
  20. #endif
  21. #define LED_BIT_ON(state, i) ((state) |= LED_BIT(i))
  22. #define LED_BIT_OFF(state, i) ((state) &= ~LED_BIT(i))
  23. typedef enum {
  24. LEDMAP_DEFAULT_LAYER_0 = 0,
  25. LEDMAP_DEFAULT_LAYER_31 = 31,
  26. LEDMAP_LAYER_0 = 32,
  27. LEDMAP_LAYER_31 = 63,
  28. LEDMAP_NUM_LOCK = 64,
  29. LEDMAP_CAPS_LOCK,
  30. LEDMAP_SCROLL_LOCK,
  31. LEDMAP_COMPOSE,
  32. LEDMAP_KANA,
  33. LEDMAP_BACKLIGHT = 0x80,
  34. LEDMAP_UNCONFIGURED = 0xFF
  35. } ledmap_code_t;
  36. #define LEDMAP_DEFAULT_LAYER(x) (LEDMAP_DEFAULT_LAYER_0 + x)
  37. #define LEDMAP_LAYER(x) (LEDMAP_LAYER_0 + x)
  38. #ifdef LEDMAP_ENABLE
  39. uint8_t ledmap_get_code(uint8_t index);
  40. void ledmap_led_init(void);
  41. void ledmap_led_on(uint8_t index);
  42. void ledmap_led_off(uint8_t index);
  43. #else
  44. #define ledmaps
  45. #define ledmap_get()
  46. #define ledmap_led_init()
  47. #define ledmap_led_on()
  48. #define ledmap_led_off()
  49. #endif
  50. #endif