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