diff options
author | Ralf Schmitt <ralf@bunkertor.net> | 2014-04-08 21:02:46 +0200 |
---|---|---|
committer | Ralf Schmitt <ralf@bunkertor.net> | 2014-04-08 21:02:46 +0200 |
commit | 589d99b448e6085513799fbb183f6389d4df408d (patch) | |
tree | 3d6f83a71ffe03a2855046de58ba7ae9095f0733 /common | |
parent | 5c63751790bca2d7e0c6f368bd446db8fe671848 (diff) | |
download | qmk_firmware-589d99b448e6085513799fbb183f6389d4df408d.tar.gz qmk_firmware-589d99b448e6085513799fbb183f6389d4df408d.zip |
New macro: ACTION_BACKLIGHT_LEVEL(level)
To have full control of the backlight level.
Diffstat (limited to 'common')
-rw-r--r-- | common/action.c | 5 | ||||
-rw-r--r-- | common/action_code.h | 18 | ||||
-rw-r--r-- | common/backlight.c | 8 | ||||
-rw-r--r-- | common/backlight.h | 7 |
4 files changed, 26 insertions, 12 deletions
diff --git a/common/action.c b/common/action.c index e6938f5a2..fddb97c50 100644 --- a/common/action.c +++ b/common/action.c | |||
@@ -294,7 +294,7 @@ void process_action(keyrecord_t *record) | |||
294 | #ifdef BACKLIGHT_ENABLE | 294 | #ifdef BACKLIGHT_ENABLE |
295 | case ACT_BACKLIGHT: | 295 | case ACT_BACKLIGHT: |
296 | if (!event.pressed) { | 296 | if (!event.pressed) { |
297 | switch (action.backlight.id) { | 297 | switch (action.backlight.opt) { |
298 | case BACKLIGHT_INCREASE: | 298 | case BACKLIGHT_INCREASE: |
299 | backlight_increase(); | 299 | backlight_increase(); |
300 | break; | 300 | break; |
@@ -307,6 +307,9 @@ void process_action(keyrecord_t *record) | |||
307 | case BACKLIGHT_STEP: | 307 | case BACKLIGHT_STEP: |
308 | backlight_step(); | 308 | backlight_step(); |
309 | break; | 309 | break; |
310 | case BACKLIGHT_LEVEL: | ||
311 | backlight_level(action.backlight.level); | ||
312 | break; | ||
310 | } | 313 | } |
311 | } | 314 | } |
312 | break; | 315 | break; |
diff --git a/common/action_code.h b/common/action_code.h index 8df86b119..50112d4d2 100644 --- a/common/action_code.h +++ b/common/action_code.h | |||
@@ -87,7 +87,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
87 | * 1100|1111| id(8) Macro record? | 87 | * 1100|1111| id(8) Macro record? |
88 | * | 88 | * |
89 | * ACT_BACKLIGHT(1101): | 89 | * ACT_BACKLIGHT(1101): |
90 | * 1101|xxxx| id(8) Backlight commands | 90 | * 1101|opt |level(8) Backlight commands |
91 | * | 91 | * |
92 | * ACT_COMMAND(1110): | 92 | * ACT_COMMAND(1110): |
93 | * 1110|opt | id(8) Built-in Command exec | 93 | * 1110|opt | id(8) Built-in Command exec |
@@ -163,7 +163,9 @@ typedef union { | |||
163 | uint8_t kind :4; | 163 | uint8_t kind :4; |
164 | } usage; | 164 | } usage; |
165 | struct action_backlight { | 165 | struct action_backlight { |
166 | uint8_t id :8; | 166 | uint8_t level :8; |
167 | uint8_t opt :4; | ||
168 | uint8_t kind :4; | ||
167 | } backlight; | 169 | } backlight; |
168 | struct action_command { | 170 | struct action_command { |
169 | uint8_t id :8; | 171 | uint8_t id :8; |
@@ -282,21 +284,23 @@ enum layer_pram_tap_op { | |||
282 | /* | 284 | /* |
283 | * Extensions | 285 | * Extensions |
284 | */ | 286 | */ |
285 | enum backlight_id { | 287 | enum backlight_opt { |
286 | BACKLIGHT_INCREASE = 0, | 288 | BACKLIGHT_INCREASE = 0, |
287 | BACKLIGHT_DECREASE = 1, | 289 | BACKLIGHT_DECREASE = 1, |
288 | BACKLIGHT_TOGGLE = 2, | 290 | BACKLIGHT_TOGGLE = 2, |
289 | BACKLIGHT_STEP = 3, | 291 | BACKLIGHT_STEP = 3, |
292 | BACKLIGHT_LEVEL = 4, | ||
290 | }; | 293 | }; |
291 | /* Macro */ | 294 | /* Macro */ |
292 | #define ACTION_MACRO(id) ACTION(ACT_MACRO, (id)) | 295 | #define ACTION_MACRO(id) ACTION(ACT_MACRO, (id)) |
293 | #define ACTION_MACRO_TAP(id) ACTION(ACT_MACRO, FUNC_TAP<<8 | (id)) | 296 | #define ACTION_MACRO_TAP(id) ACTION(ACT_MACRO, FUNC_TAP<<8 | (id)) |
294 | #define ACTION_MACRO_OPT(id, opt) ACTION(ACT_MACRO, (opt)<<8 | (id)) | 297 | #define ACTION_MACRO_OPT(id, opt) ACTION(ACT_MACRO, (opt)<<8 | (id)) |
295 | /* Backlight */ | 298 | /* Backlight */ |
296 | #define ACTION_BACKLIGHT_INCREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_INCREASE) | 299 | #define ACTION_BACKLIGHT_INCREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_INCREASE << 8) |
297 | #define ACTION_BACKLIGHT_DECREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_DECREASE) | 300 | #define ACTION_BACKLIGHT_DECREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_DECREASE << 8) |
298 | #define ACTION_BACKLIGHT_TOGGLE() ACTION(ACT_BACKLIGHT, BACKLIGHT_TOGGLE) | 301 | #define ACTION_BACKLIGHT_TOGGLE() ACTION(ACT_BACKLIGHT, BACKLIGHT_TOGGLE << 8) |
299 | #define ACTION_BACKLIGHT_STEP() ACTION(ACT_BACKLIGHT, BACKLIGHT_STEP) | 302 | #define ACTION_BACKLIGHT_STEP() ACTION(ACT_BACKLIGHT, BACKLIGHT_STEP << 8) |
303 | #define ACTION_BACKLIGHT_LEVEL(level) ACTION(ACT_BACKLIGHT, BACKLIGHT_LEVEL << 8 | level) | ||
300 | /* Command */ | 304 | /* Command */ |
301 | #define ACTION_COMMAND(id, opt) ACTION(ACT_COMMAND, (opt)<<8 | (addr)) | 305 | #define ACTION_COMMAND(id, opt) ACTION(ACT_COMMAND, (opt)<<8 | (addr)) |
302 | /* Function */ | 306 | /* Function */ |
diff --git a/common/backlight.c b/common/backlight.c index 00dc04a07..558ad9b01 100644 --- a/common/backlight.c +++ b/common/backlight.c | |||
@@ -75,3 +75,11 @@ void backlight_step(void) | |||
75 | dprintf("backlight step: %u\n", backlight_config.level); | 75 | dprintf("backlight step: %u\n", backlight_config.level); |
76 | backlight_set(backlight_config.level); | 76 | backlight_set(backlight_config.level); |
77 | } | 77 | } |
78 | |||
79 | void backlight_level(uint8_t level) | ||
80 | { | ||
81 | backlight_config.level ^= level; | ||
82 | backlight_config.enable = !!backlight_config.level; | ||
83 | eeconfig_write_backlight(backlight_config.raw); | ||
84 | backlight_set(backlight_config.level); | ||
85 | } | ||
diff --git a/common/backlight.h b/common/backlight.h index 685c422ae..525ec8bbe 100644 --- a/common/backlight.h +++ b/common/backlight.h | |||
@@ -24,18 +24,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
24 | typedef union { | 24 | typedef union { |
25 | uint8_t raw; | 25 | uint8_t raw; |
26 | struct { | 26 | struct { |
27 | bool enable:1; | 27 | bool enable :1; |
28 | uint8_t level:7; | 28 | uint8_t level :7; |
29 | }; | 29 | }; |
30 | } backlight_config_t; | 30 | } backlight_config_t; |
31 | 31 | ||
32 | void backlight_init(void); | 32 | void backlight_init(void); |
33 | |||
34 | void backlight_increase(void); | 33 | void backlight_increase(void); |
35 | void backlight_decrease(void); | 34 | void backlight_decrease(void); |
36 | void backlight_toggle(void); | 35 | void backlight_toggle(void); |
37 | void backlight_step(void); | 36 | void backlight_step(void); |
38 | |||
39 | void backlight_set(uint8_t level); | 37 | void backlight_set(uint8_t level); |
38 | void backlight_level(uint8_t level); | ||
40 | 39 | ||
41 | #endif | 40 | #endif |