summaryrefslogtreecommitdiffstats
path: root/quantum/backlight
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2021-05-27 15:21:15 +1000
committerGitHub <noreply@github.com>2021-05-26 22:21:15 -0700
commit06aea834c420d5c11bbcf64d37596cb0cee9af98 (patch)
treee76319f1d5a4ba22c38d8d899f74a348f37caae3 /quantum/backlight
parente128d454206a2d0622b96d7793758ad7e6965f3d (diff)
Backlight: add defines for default level and breathing state (#12560)
Diffstat (limited to 'quantum/backlight')
-rw-r--r--quantum/backlight/backlight.c23
-rw-r--r--quantum/backlight/backlight.h4
2 files changed, 24 insertions, 3 deletions
diff --git a/quantum/backlight/backlight.c b/quantum/backlight/backlight.c
index 113beb832f..1bc276899c 100644
--- a/quantum/backlight/backlight.c
+++ b/quantum/backlight/backlight.c
@@ -22,6 +22,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
backlight_config_t backlight_config;
+#ifndef BACKLIGHT_DEFAULT_LEVEL
+# define BACKLIGHT_DEFAULT_LEVEL BACKLIGHT_LEVELS
+#endif
+
#ifdef BACKLIGHT_BREATHING
// TODO: migrate to backlight_config_t
static uint8_t breathing_period = BREATHING_PERIOD;
@@ -35,6 +39,7 @@ void backlight_init(void) {
/* check signature */
if (!eeconfig_is_enabled()) {
eeconfig_init();
+ eeconfig_update_backlight_default();
}
backlight_config.raw = eeconfig_read_backlight();
if (backlight_config.level > BACKLIGHT_LEVELS) {
@@ -152,11 +157,23 @@ void backlight_level(uint8_t level) {
eeconfig_update_backlight(backlight_config.raw);
}
-/** \brief Update current backlight state to EEPROM
- *
- */
+uint8_t eeconfig_read_backlight(void) { return eeprom_read_byte(EECONFIG_BACKLIGHT); }
+
+void eeconfig_update_backlight(uint8_t val) { eeprom_update_byte(EECONFIG_BACKLIGHT, val); }
+
void eeconfig_update_backlight_current(void) { eeconfig_update_backlight(backlight_config.raw); }
+void eeconfig_update_backlight_default(void) {
+ backlight_config.enable = 1;
+#ifdef BACKLIGHT_DEFAULT_BREATHING
+ backlight_config.breathing = 1;
+#else
+ backlight_config.breathing = 0;
+#endif
+ backlight_config.level = BACKLIGHT_DEFAULT_LEVEL;
+ eeconfig_update_backlight(backlight_config.raw);
+}
+
/** \brief Get backlight level
*
* FIXME: needs doc
diff --git a/quantum/backlight/backlight.h b/quantum/backlight/backlight.h
index 3e506737d4..c30c70fd62 100644
--- a/quantum/backlight/backlight.h
+++ b/quantum/backlight/backlight.h
@@ -55,7 +55,11 @@ void backlight_decrease(void);
void backlight_level_noeeprom(uint8_t level);
void backlight_level(uint8_t level);
uint8_t get_backlight_level(void);
+
+uint8_t eeconfig_read_backlight(void);
+void eeconfig_update_backlight(uint8_t val);
void eeconfig_update_backlight_current(void);
+void eeconfig_update_backlight_default(void);
// implementation specific
void backlight_init_ports(void);