diff options
Diffstat (limited to 'quantum/backlight/backlight.c')
| -rw-r--r-- | quantum/backlight/backlight.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/quantum/backlight/backlight.c b/quantum/backlight/backlight.c index 113beb832..dfb98419e 100644 --- a/quantum/backlight/backlight.c +++ b/quantum/backlight/backlight.c | |||
| @@ -17,11 +17,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 17 | 17 | ||
| 18 | #include "quantum.h" | 18 | #include "quantum.h" |
| 19 | #include "backlight.h" | 19 | #include "backlight.h" |
| 20 | #include "eeprom.h" | ||
| 20 | #include "eeconfig.h" | 21 | #include "eeconfig.h" |
| 21 | #include "debug.h" | 22 | #include "debug.h" |
| 22 | 23 | ||
| 23 | backlight_config_t backlight_config; | 24 | backlight_config_t backlight_config; |
| 24 | 25 | ||
| 26 | #ifndef BACKLIGHT_DEFAULT_LEVEL | ||
| 27 | # define BACKLIGHT_DEFAULT_LEVEL BACKLIGHT_LEVELS | ||
| 28 | #endif | ||
| 29 | |||
| 25 | #ifdef BACKLIGHT_BREATHING | 30 | #ifdef BACKLIGHT_BREATHING |
| 26 | // TODO: migrate to backlight_config_t | 31 | // TODO: migrate to backlight_config_t |
| 27 | static uint8_t breathing_period = BREATHING_PERIOD; | 32 | static uint8_t breathing_period = BREATHING_PERIOD; |
| @@ -35,6 +40,7 @@ void backlight_init(void) { | |||
| 35 | /* check signature */ | 40 | /* check signature */ |
| 36 | if (!eeconfig_is_enabled()) { | 41 | if (!eeconfig_is_enabled()) { |
| 37 | eeconfig_init(); | 42 | eeconfig_init(); |
| 43 | eeconfig_update_backlight_default(); | ||
| 38 | } | 44 | } |
| 39 | backlight_config.raw = eeconfig_read_backlight(); | 45 | backlight_config.raw = eeconfig_read_backlight(); |
| 40 | if (backlight_config.level > BACKLIGHT_LEVELS) { | 46 | if (backlight_config.level > BACKLIGHT_LEVELS) { |
| @@ -152,11 +158,23 @@ void backlight_level(uint8_t level) { | |||
| 152 | eeconfig_update_backlight(backlight_config.raw); | 158 | eeconfig_update_backlight(backlight_config.raw); |
| 153 | } | 159 | } |
| 154 | 160 | ||
| 155 | /** \brief Update current backlight state to EEPROM | 161 | uint8_t eeconfig_read_backlight(void) { return eeprom_read_byte(EECONFIG_BACKLIGHT); } |
| 156 | * | 162 | |
| 157 | */ | 163 | void eeconfig_update_backlight(uint8_t val) { eeprom_update_byte(EECONFIG_BACKLIGHT, val); } |
| 164 | |||
| 158 | void eeconfig_update_backlight_current(void) { eeconfig_update_backlight(backlight_config.raw); } | 165 | void eeconfig_update_backlight_current(void) { eeconfig_update_backlight(backlight_config.raw); } |
| 159 | 166 | ||
| 167 | void eeconfig_update_backlight_default(void) { | ||
| 168 | backlight_config.enable = 1; | ||
| 169 | #ifdef BACKLIGHT_DEFAULT_BREATHING | ||
| 170 | backlight_config.breathing = 1; | ||
| 171 | #else | ||
| 172 | backlight_config.breathing = 0; | ||
| 173 | #endif | ||
| 174 | backlight_config.level = BACKLIGHT_DEFAULT_LEVEL; | ||
| 175 | eeconfig_update_backlight(backlight_config.raw); | ||
| 176 | } | ||
| 177 | |||
| 160 | /** \brief Get backlight level | 178 | /** \brief Get backlight level |
| 161 | * | 179 | * |
| 162 | * FIXME: needs doc | 180 | * FIXME: needs doc |
