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.

85 lines
2.3 KiB

  1. /* Copyright 2021
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #pragma once
  17. #include <stdint.h>
  18. #include <stdbool.h>
  19. #include "util.h"
  20. #if defined(LED_MATRIX_KEYPRESSES) || defined(LED_MATRIX_KEYRELEASES)
  21. # define LED_MATRIX_KEYREACTIVE_ENABLED
  22. #endif
  23. // Last led hit
  24. #ifndef LED_HITS_TO_REMEMBER
  25. # define LED_HITS_TO_REMEMBER 8
  26. #endif // LED_HITS_TO_REMEMBER
  27. #ifdef LED_MATRIX_KEYREACTIVE_ENABLED
  28. typedef struct PACKED {
  29. uint8_t count;
  30. uint8_t x[LED_HITS_TO_REMEMBER];
  31. uint8_t y[LED_HITS_TO_REMEMBER];
  32. uint8_t index[LED_HITS_TO_REMEMBER];
  33. uint16_t tick[LED_HITS_TO_REMEMBER];
  34. } last_hit_t;
  35. #endif // LED_MATRIX_KEYREACTIVE_ENABLED
  36. typedef enum led_task_states { STARTING, RENDERING, FLUSHING, SYNCING } led_task_states;
  37. typedef uint8_t led_flags_t;
  38. typedef struct PACKED {
  39. uint8_t iter;
  40. led_flags_t flags;
  41. bool init;
  42. } effect_params_t;
  43. typedef struct PACKED {
  44. uint8_t x;
  45. uint8_t y;
  46. } led_point_t;
  47. #define HAS_FLAGS(bits, flags) ((bits & flags) == flags)
  48. #define HAS_ANY_FLAGS(bits, flags) ((bits & flags) != 0x00)
  49. #define LED_FLAG_ALL 0xFF
  50. #define LED_FLAG_NONE 0x00
  51. #define LED_FLAG_MODIFIER 0x01
  52. #define LED_FLAG_KEYLIGHT 0x04
  53. #define LED_FLAG_INDICATOR 0x08
  54. #define NO_LED 255
  55. typedef struct PACKED {
  56. uint8_t matrix_co[MATRIX_ROWS][MATRIX_COLS];
  57. led_point_t point[LED_MATRIX_LED_COUNT];
  58. uint8_t flags[LED_MATRIX_LED_COUNT];
  59. } led_config_t;
  60. typedef union {
  61. uint32_t raw;
  62. struct PACKED {
  63. uint8_t enable : 2;
  64. uint8_t mode : 6;
  65. uint8_t val;
  66. uint8_t speed;
  67. led_flags_t flags;
  68. };
  69. } led_eeconfig_t;
  70. _Static_assert(sizeof(led_eeconfig_t) == sizeof(uint32_t), "LED Matrix EECONFIG out of spec.");