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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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_LAYER(x) (x)
  37. #define LEDMAP_DEFAULT_LAYER(x) (32 + x)
  38. void ledmap_init(void);
  39. #ifdef LEDMAP_ENABLE
  40. uint8_t ledmap_get_code(uint8_t index);
  41. void ledmap_led_init(void);
  42. void ledmap_led_on(uint8_t index);
  43. void ledmap_led_off(uint8_t index);
  44. #else
  45. #define ledmaps
  46. #define ledmap_get()
  47. #define ledmap_led_init()
  48. #define ledmap_led_on()
  49. #define ledmap_led_off()
  50. #endif
  51. #endif