summaryrefslogtreecommitdiffstats
path: root/tmk_core
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/common/action.c7
-rw-r--r--tmk_core/common/action_code.h6
-rw-r--r--tmk_core/common/backlight.c6
3 files changed, 14 insertions, 5 deletions
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c
index b39aa4cbc4..dd3a5b3ee2 100644
--- a/tmk_core/common/action.c
+++ b/tmk_core/common/action.c
@@ -512,8 +512,11 @@ void process_action(keyrecord_t *record, action_t action)
case BACKLIGHT_STEP:
backlight_step();
break;
- case BACKLIGHT_LEVEL:
- backlight_level(action.backlight.level);
+ case BACKLIGHT_ON:
+ backlight_level(BACKLIGHT_LEVELS);
+ break;
+ case BACKLIGHT_OFF:
+ backlight_level(0);
break;
}
}
diff --git a/tmk_core/common/action_code.h b/tmk_core/common/action_code.h
index b15aaa0eb3..05bc845732 100644
--- a/tmk_core/common/action_code.h
+++ b/tmk_core/common/action_code.h
@@ -304,7 +304,8 @@ enum backlight_opt {
BACKLIGHT_DECREASE = 1,
BACKLIGHT_TOGGLE = 2,
BACKLIGHT_STEP = 3,
- BACKLIGHT_LEVEL = 4,
+ BACKLIGHT_ON = 4,
+ BACKLIGHT_OFF = 5,
};
/* Macro */
@@ -316,7 +317,8 @@ enum backlight_opt {
#define ACTION_BACKLIGHT_DECREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_DECREASE << 8)
#define ACTION_BACKLIGHT_TOGGLE() ACTION(ACT_BACKLIGHT, BACKLIGHT_TOGGLE << 8)
#define ACTION_BACKLIGHT_STEP() ACTION(ACT_BACKLIGHT, BACKLIGHT_STEP << 8)
-#define ACTION_BACKLIGHT_LEVEL(level) ACTION(ACT_BACKLIGHT, BACKLIGHT_LEVEL << 8 | (level))
+#define ACTION_BACKLIGHT_ON() ACTION(ACT_BACKLIGHT, BACKLIGHT_ON << 8)
+#define ACTION_BACKLIGHT_OFF() ACTION(ACT_BACKLIGHT, BACKLIGHT_OFF << 8)
/* Command */
#define ACTION_COMMAND(id, opt) ACTION(ACT_COMMAND, (opt)<<8 | (id))
/* Function */
diff --git a/tmk_core/common/backlight.c b/tmk_core/common/backlight.c
index d03bfe931b..4d2491b988 100644
--- a/tmk_core/common/backlight.c
+++ b/tmk_core/common/backlight.c
@@ -61,6 +61,8 @@ void backlight_decrease(void)
void backlight_toggle(void)
{
backlight_config.enable ^= 1;
+ if (backlight_config.raw == 1) // enabled but level = 0
+ backlight_config.level = 1;
eeconfig_update_backlight(backlight_config.raw);
dprintf("backlight toggle: %u\n", backlight_config.enable);
backlight_set(backlight_config.enable ? backlight_config.level : 0);
@@ -81,7 +83,9 @@ void backlight_step(void)
void backlight_level(uint8_t level)
{
- backlight_config.level ^= level;
+ if (level > BACKLIGHT_LEVELS)
+ level = BACKLIGHT_LEVELS;
+ backlight_config.level = level;
backlight_config.enable = !!backlight_config.level;
eeconfig_update_backlight(backlight_config.raw);
backlight_set(backlight_config.level);