mxss_frontled.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* Copyright 2018 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. #ifndef MXSS_FRONTLED_H
  19. #define MXSS_FRONTLED_H
  20. #include "quantum_keycodes.h"
  21. // RGBLED index for front LEDs
  22. #define RGBLIGHT_FLED1 14
  23. #define RGBLIGHT_FLED2 15
  24. // Brightness increase step for front LEDs
  25. #define FLED_VAL_STEP 8
  26. // QMK never uses more then 32bytes of EEPROM, so our region starts there
  27. // Magic value to verify the state of the EEPROM
  28. #define EEPROM_MAGIC 0xC3E7
  29. #define EEPROM_MAGIC_ADDR ((void*)32)
  30. // Front LED settings
  31. #define EEPROM_FRONTLED_ADDR ((void*)34)
  32. // Modes for front LEDs
  33. #define FLED_OFF 0b00
  34. #define FLED_INDI 0b01
  35. #define FLED_RGB 0b10
  36. #define FLED_UNDEF 0b11
  37. // Hard-coded color for capslock indicator in FLED_INDI mode, H:0% S:100% = Red
  38. #define FLED_CAPS_H 0
  39. #define FLED_CAPS_S 255
  40. // Config storage format for EEPROM
  41. typedef union {
  42. uint8_t raw;
  43. struct {
  44. uint8_t mode :2;
  45. uint8_t val :6;
  46. };
  47. } fled_config;
  48. // Structure to store hue and saturation values
  49. typedef struct _hs_set {
  50. uint16_t hue;
  51. uint8_t sat;
  52. } hs_set;
  53. // Custom keycodes for front LED control
  54. enum fled_keycodes {
  55. FLED_MOD = SAFE_RANGE,
  56. FLED_VAI,
  57. FLED_VAD,
  58. NEW_SAFE_RANGE // define a new safe range
  59. };
  60. bool eeprom_is_valid(void); // Check if EEPROM has been set up
  61. void eeprom_set_valid(bool valid); // Change validity state of EEPROM
  62. void eeprom_update_conf(void); // Store current front LED config to EEPROM
  63. void fled_mode_cycle(void); // Cycle between the 3 modes for the front LEDs
  64. void fled_val_increase(void); // Increase the brightness of the front LEDs
  65. void fled_val_decrease(void); // Decrease the brightness of the front LEDs
  66. #endif //MXSS_FRONTLED_H