diff options
author | Chris Lee <clee@mg8.org> | 2017-12-02 11:26:49 +0100 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2018-02-02 06:58:26 +0100 |
commit | 9584db055b73937dfba7b9878a8b61af6aa96710 (patch) | |
tree | 75a2dc324a0e7b3178dfce22783646af104f86a0 | |
parent | 38ab86e8f2b6731557f28902509a011715ed5d29 (diff) | |
download | qmk_firmware-9584db055b73937dfba7b9878a8b61af6aa96710.tar.gz qmk_firmware-9584db055b73937dfba7b9878a8b61af6aa96710.tar.xz |
Add support for key backlighting to bfake
If BACKLIGHT_ENABLE is set to `yes` in `rules.mk`, then the user
can use the `BL_*` keycodes to adjust the backlight. At the moment,
only on/off is supported.
-rw-r--r-- | keyboards/bfake/bfake.c | 23 | ||||
-rw-r--r-- | keyboards/bfake/config.h | 3 | ||||
-rw-r--r-- | keyboards/bfake/rules.mk | 4 |
3 files changed, 26 insertions, 4 deletions
diff --git a/keyboards/bfake/bfake.c b/keyboards/bfake/bfake.c index 33d0a60c2..2160706fe 100644 --- a/keyboards/bfake/bfake.c +++ b/keyboards/bfake/bfake.c @@ -16,7 +16,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "bfake.h" +#ifdef BACKLIGHT_ENABLE +#include "backlight.h" +#endif +#ifdef RGBLIGHT_ENABLE #include "rgblight.h" +#endif #include <avr/pgmspace.h> @@ -24,6 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "i2c.h" #include "quantum.h" +#ifdef RGBLIGHT_ENABLE extern rgblight_config_t rgblight_config; void rgblight_set(void) { @@ -38,8 +44,23 @@ void rgblight_set(void) { i2c_init(); i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM); } +#endif __attribute__ ((weak)) void matrix_scan_user(void) { - rgblight_task(); +} + +void backlight_init_ports(void) { + DDRD |= (1<<0 | 1<<1 | 1<<4 | 1<<6); + PORTD &= ~(1<<0 | 1<<1 | 1<<4 | 1<<6); +} + +void backlight_set(uint8_t level) { + if (level == 0) { + // Turn out the lights + PORTD &= ~(1<<0 | 1<<1 | 1<<4 | 1<<6); + } else { + // Turn on the lights + PORTD |= (1<<0 | 1<<1 | 1<<4 | 1<<6); + } } diff --git a/keyboards/bfake/config.h b/keyboards/bfake/config.h index c0e0face5..de8c4b5df 100644 --- a/keyboards/bfake/config.h +++ b/keyboards/bfake/config.h @@ -37,7 +37,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define DIODE_DIRECTION COL2ROW #define DEBOUNCING_DELAY 5 - +#define NO_BACKLIGHT_CLOCK +#define BACKLIGHT_LEVELS 1 #define RGBLIGHT_ANIMATIONS #define NO_UART 1 diff --git a/keyboards/bfake/rules.mk b/keyboards/bfake/rules.mk index 9165de424..6577ea193 100644 --- a/keyboards/bfake/rules.mk +++ b/keyboards/bfake/rules.mk @@ -37,7 +37,7 @@ EXTRAKEY_ENABLE = yes CONSOLE_ENABLE = yes COMMAND_ENABLE = yes BACKLIGHT_ENABLE = no -RGBLIGHT_ENABLE = yes +RGBLIGHT_ENABLE = no RGBLIGHT_CUSTOM_DRIVER = yes OPT_DEFS = -DDEBUG_LEVEL=0 @@ -47,4 +47,4 @@ CUSTOM_MATRIX = yes SRC = matrix.c i2c.c # programming options -PROGRAM_CMD = ./util/atmega32a_program.py $(TARGET).hex
\ No newline at end of file +PROGRAM_CMD = ./util/atmega32a_program.py $(TARGET).hex |