mxss_frontled.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* Copyright 2020 Jumail Mundekkat / MxBlue
  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. // EEPROM management code taken from Wilba6582
  17. // https://github.com/Wilba6582/qmk_firmware/blob/zeal60/keyboards/zeal60/zeal_eeprom.h
  18. #pragma once
  19. #include "quantum.h"
  20. #include "quantum_keycodes.h"
  21. #include "via.h"
  22. // RGBLED index for front LEDs
  23. #define RGBLIGHT_FLED1 14
  24. #define RGBLIGHT_FLED2 15
  25. // Brightness increase step for front LEDs
  26. #define FLED_VAL_STEP 8
  27. // Front LED settings
  28. #define FRONTLED_CONF_ADDR ((uint8_t*) VIA_EEPROM_CUSTOM_CONFIG_ADDR)
  29. #define FRONTLED_COLOR_CNT_ADDR (FRONTLED_CONF_ADDR + 1)
  30. #define FRONTLED_COLOR_ADDR ((uint16_t*)(FRONTLED_COLOR_CNT_ADDR + 1))
  31. // No point persisting more 4, VIA only allows editing of 3 + 1 for caps
  32. #define FRONTLED_COLOR_MAXCNT 4
  33. // Modes for front LEDs
  34. #define FLED_OFF 0b00
  35. #define FLED_INDI 0b01
  36. #define FLED_RGB 0b10
  37. #define FLED_UNDEF 0b11
  38. // Config storage format for EEPROM
  39. typedef union {
  40. uint8_t raw;
  41. struct {
  42. uint8_t mode :2;
  43. uint8_t val :6;
  44. };
  45. } fled_config;
  46. // Structure to store hue and saturation values
  47. typedef union {
  48. uint16_t raw;
  49. struct {
  50. uint8_t hue;
  51. uint8_t sat;
  52. };
  53. } hs_set;
  54. // Custom keycodes for front LED control
  55. enum fled_keycodes {
  56. FLED_MOD = USER00, // USER00 = VIA custom keycode start
  57. FLED_VAI,
  58. FLED_VAD,
  59. NEW_SAFE_RANGE // define a new safe range
  60. };
  61. void fled_init(void); // Run init functions for front LEDs
  62. void process_record_fled(uint16_t keycode, keyrecord_t* record); // Process keycodes for front LEDs
  63. void fled_load_conf(void); // Load front LED config from EEPROM
  64. void fled_update_conf(void); // Store current front LED config to EEPROM
  65. void fled_mode_cycle(void); // Cycle between the 3 modes for the front LEDs
  66. void fled_val_increase(void); // Increase the brightness of the front LEDs
  67. void fled_val_decrease(void); // Decrease the brightness of the front LEDs
  68. void fled_layer_update(layer_state_t state); // Process layer update for front LEDs
  69. void fled_lock_update(led_t led_state); // Process lock update for front LEDs
  70. void set_fled_layer_color(uint8_t layer, hs_set hs); // Set color for a given layer
  71. void set_fled_caps_color(hs_set hs); // Set color for the capslock indicator
  72. hs_set get_fled_caps_color(void); // Get color for the capslock indicator
  73. hs_set get_fled_layer_color(uint8_t layer); // Get color for a given layer