aboutsummaryrefslogtreecommitdiff
path: root/keyboards
diff options
context:
space:
mode:
authorChris Lee <clee@mg8.org>2017-12-02 03:26:49 -0700
committerJack Humbert <jack.humb@gmail.com>2018-02-02 00:58:26 -0500
commit9584db055b73937dfba7b9878a8b61af6aa96710 (patch)
tree75a2dc324a0e7b3178dfce22783646af104f86a0 /keyboards
parent38ab86e8f2b6731557f28902509a011715ed5d29 (diff)
downloadqmk_firmware-9584db055b73937dfba7b9878a8b61af6aa96710.tar.gz
qmk_firmware-9584db055b73937dfba7b9878a8b61af6aa96710.zip
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.
Diffstat (limited to 'keyboards')
-rw-r--r--keyboards/bfake/bfake.c23
-rw-r--r--keyboards/bfake/config.h3
-rw-r--r--keyboards/bfake/rules.mk4
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/>.
16*/ 16*/
17 17
18#include "bfake.h" 18#include "bfake.h"
19#ifdef BACKLIGHT_ENABLE
20#include "backlight.h"
21#endif
22#ifdef RGBLIGHT_ENABLE
19#include "rgblight.h" 23#include "rgblight.h"
24#endif
20 25
21#include <avr/pgmspace.h> 26#include <avr/pgmspace.h>
22 27
@@ -24,6 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
24#include "i2c.h" 29#include "i2c.h"
25#include "quantum.h" 30#include "quantum.h"
26 31
32#ifdef RGBLIGHT_ENABLE
27extern rgblight_config_t rgblight_config; 33extern rgblight_config_t rgblight_config;
28 34
29void rgblight_set(void) { 35void rgblight_set(void) {
@@ -38,8 +44,23 @@ void rgblight_set(void) {
38 i2c_init(); 44 i2c_init();
39 i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM); 45 i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
40} 46}
47#endif
41 48
42__attribute__ ((weak)) 49__attribute__ ((weak))
43void matrix_scan_user(void) { 50void matrix_scan_user(void) {
44 rgblight_task(); 51}
52
53void backlight_init_ports(void) {
54 DDRD |= (1<<0 | 1<<1 | 1<<4 | 1<<6);
55 PORTD &= ~(1<<0 | 1<<1 | 1<<4 | 1<<6);
56}
57
58void backlight_set(uint8_t level) {
59 if (level == 0) {
60 // Turn out the lights
61 PORTD &= ~(1<<0 | 1<<1 | 1<<4 | 1<<6);
62 } else {
63 // Turn on the lights
64 PORTD |= (1<<0 | 1<<1 | 1<<4 | 1<<6);
65 }
45} 66}
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/>.
37#define DIODE_DIRECTION COL2ROW 37#define DIODE_DIRECTION COL2ROW
38#define DEBOUNCING_DELAY 5 38#define DEBOUNCING_DELAY 5
39 39
40 40#define NO_BACKLIGHT_CLOCK
41#define BACKLIGHT_LEVELS 1
41#define RGBLIGHT_ANIMATIONS 42#define RGBLIGHT_ANIMATIONS
42 43
43#define NO_UART 1 44#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
37CONSOLE_ENABLE = yes 37CONSOLE_ENABLE = yes
38COMMAND_ENABLE = yes 38COMMAND_ENABLE = yes
39BACKLIGHT_ENABLE = no 39BACKLIGHT_ENABLE = no
40RGBLIGHT_ENABLE = yes 40RGBLIGHT_ENABLE = no
41RGBLIGHT_CUSTOM_DRIVER = yes 41RGBLIGHT_CUSTOM_DRIVER = yes
42 42
43OPT_DEFS = -DDEBUG_LEVEL=0 43OPT_DEFS = -DDEBUG_LEVEL=0
@@ -47,4 +47,4 @@ CUSTOM_MATRIX = yes
47SRC = matrix.c i2c.c 47SRC = matrix.c i2c.c
48 48
49# programming options 49# programming options
50PROGRAM_CMD = ./util/atmega32a_program.py $(TARGET).hex \ No newline at end of file 50PROGRAM_CMD = ./util/atmega32a_program.py $(TARGET).hex