aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2019-10-17 17:48:58 +0100
committerGitHub <noreply@github.com>2019-10-17 17:48:58 +0100
commitabfd6ed9613013d3c9f15da8b575a902d9bcf274 (patch)
tree8f2a4601586a7bc67f5f684e0d07b41e9608f3b3
parente3a21348c3879c11072c7c42d3b4d04b022f4fe2 (diff)
downloadqmk_firmware-abfd6ed9613013d3c9f15da8b575a902d9bcf274.tar.gz
qmk_firmware-abfd6ed9613013d3c9f15da8b575a902d9bcf274.zip
Move tmk_core/common/backlight to quantum/backlight (#6710)
* Move tmk_core/common/backlight to quantum/backlight * Add guards to backlight inclusion * Add guards to backlight inclusion * Update backlight guards on clueboard/60 * Use full paths to avoid vpath issues
-rw-r--r--common_features.mk5
-rw-r--r--keyboards/clueboard/60/led.c10
-rw-r--r--quantum/backlight/backlight.c194
-rw-r--r--quantum/backlight/backlight.h (renamed from tmk_core/common/backlight.h)0
-rw-r--r--quantum/keymap_common.c5
-rw-r--r--quantum/quantum.c6
-rw-r--r--tmk_core/common.mk5
-rw-r--r--tmk_core/common/action.c5
-rw-r--r--tmk_core/common/avr/suspend.c5
-rw-r--r--tmk_core/common/backlight.c193
-rw-r--r--tmk_core/common/chibios/suspend.c5
-rw-r--r--tmk_core/common/command.c5
-rw-r--r--tmk_core/common/keyboard.c4
13 files changed, 230 insertions, 212 deletions
diff --git a/common_features.mk b/common_features.mk
index 05a99fc63..83b2b51ae 100644
--- a/common_features.mk
+++ b/common_features.mk
@@ -246,6 +246,11 @@ ifneq ($(strip $(BACKLIGHT_ENABLE)), no)
246 CIE1931_CURVE = yes 246 CIE1931_CURVE = yes
247 endif 247 endif
248 248
249
250 COMMON_VPATH += $(QUANTUM_DIR)/backlight
251 SRC += $(QUANTUM_DIR)/backlight/backlight.c
252 OPT_DEFS += -DBACKLIGHT_ENABLE
253
249 ifeq ($(strip $(BACKLIGHT_ENABLE)), custom) 254 ifeq ($(strip $(BACKLIGHT_ENABLE)), custom)
250 OPT_DEFS += -DBACKLIGHT_CUSTOM_DRIVER 255 OPT_DEFS += -DBACKLIGHT_CUSTOM_DRIVER
251 endif 256 endif
diff --git a/keyboards/clueboard/60/led.c b/keyboards/clueboard/60/led.c
index 350696736..91a2c537d 100644
--- a/keyboards/clueboard/60/led.c
+++ b/keyboards/clueboard/60/led.c
@@ -16,21 +16,21 @@
16*/ 16*/
17 17
18#include "hal.h" 18#include "hal.h"
19#include "backlight.h"
20#include "led.h" 19#include "led.h"
21#include "printf.h" 20#include "printf.h"
22 21
22#ifdef BACKLIGHT_ENABLE
23#include "backlight.h"
24
23void backlight_init_ports(void) { 25void backlight_init_ports(void) {
24 printf("backlight_init_ports()\n"); 26 printf("backlight_init_ports()\n");
25 #ifdef BACKLIGHT_ENABLE 27
26 palSetPadMode(GPIOB, 8, PAL_MODE_OUTPUT_PUSHPULL); 28 palSetPadMode(GPIOB, 8, PAL_MODE_OUTPUT_PUSHPULL);
27 palSetPad(GPIOB, 8); 29 palSetPad(GPIOB, 8);
28 #endif
29} 30}
30 31
31void backlight_set(uint8_t level) { 32void backlight_set(uint8_t level) {
32 printf("backlight_set(%d)\n", level); 33 printf("backlight_set(%d)\n", level);
33 #ifdef BACKLIGHT_ENABLE
34 if (level == 0) { 34 if (level == 0) {
35 // Turn backlight off 35 // Turn backlight off
36 palSetPad(GPIOB, 8); 36 palSetPad(GPIOB, 8);
@@ -38,8 +38,8 @@ void backlight_set(uint8_t level) {
38 // Turn backlight on 38 // Turn backlight on
39 palClearPad(GPIOB, 8); 39 palClearPad(GPIOB, 8);
40 } 40 }
41 #endif
42} 41}
42#endif
43 43
44void led_set_kb(uint8_t usb_led) { 44void led_set_kb(uint8_t usb_led) {
45 printf("led_set_kb(%d)\n", usb_led); 45 printf("led_set_kb(%d)\n", usb_led);
diff --git a/quantum/backlight/backlight.c b/quantum/backlight/backlight.c
index e26de86bf..708022f68 100644
--- a/quantum/backlight/backlight.c
+++ b/quantum/backlight/backlight.c
@@ -1 +1,193 @@
1// TODO: Add common code here, for example cie_lightness implementation 1/*
2Copyright 2013 Mathias Andersson <wraul@dbox.se>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include "backlight.h"
19#include "eeconfig.h"
20#include "debug.h"
21
22backlight_config_t backlight_config;
23
24/** \brief Backlight initialization
25 *
26 * FIXME: needs doc
27 */
28void backlight_init(void) {
29 /* check signature */
30 if (!eeconfig_is_enabled()) {
31 eeconfig_init();
32 }
33 backlight_config.raw = eeconfig_read_backlight();
34 if (backlight_config.level > BACKLIGHT_LEVELS) {
35 backlight_config.level = BACKLIGHT_LEVELS;
36 }
37 backlight_set(backlight_config.enable ? backlight_config.level : 0);
38}
39
40/** \brief Backlight increase
41 *
42 * FIXME: needs doc
43 */
44void backlight_increase(void) {
45 if (backlight_config.level < BACKLIGHT_LEVELS) {
46 backlight_config.level++;
47 }
48 backlight_config.enable = 1;
49 eeconfig_update_backlight(backlight_config.raw);
50 dprintf("backlight increase: %u\n", backlight_config.level);
51 backlight_set(backlight_config.level);
52}
53
54/** \brief Backlight decrease
55 *
56 * FIXME: needs doc
57 */
58void backlight_decrease(void) {
59 if (backlight_config.level > 0) {
60 backlight_config.level--;
61 backlight_config.enable = !!backlight_config.level;
62 eeconfig_update_backlight(backlight_config.raw);
63 }
64 dprintf("backlight decrease: %u\n", backlight_config.level);
65 backlight_set(backlight_config.level);
66}
67
68/** \brief Backlight toggle
69 *
70 * FIXME: needs doc
71 */
72void backlight_toggle(void) {
73 bool enabled = backlight_config.enable;
74 dprintf("backlight toggle: %u\n", enabled);
75 if (enabled)
76 backlight_disable();
77 else
78 backlight_enable();
79}
80
81/** \brief Enable backlight
82 *
83 * FIXME: needs doc
84 */
85void backlight_enable(void) {
86 if (backlight_config.enable) return; // do nothing if backlight is already on
87
88 backlight_config.enable = true;
89 if (backlight_config.raw == 1) // enabled but level == 0
90 backlight_config.level = 1;
91 eeconfig_update_backlight(backlight_config.raw);
92 dprintf("backlight enable\n");
93 backlight_set(backlight_config.level);
94}
95
96/** \brief Disable backlight
97 *
98 * FIXME: needs doc
99 */
100void backlight_disable(void) {
101 if (!backlight_config.enable) return; // do nothing if backlight is already off
102
103 backlight_config.enable = false;
104 eeconfig_update_backlight(backlight_config.raw);
105 dprintf("backlight disable\n");
106 backlight_set(0);
107}
108
109/** /brief Get the backlight status
110 *
111 * FIXME: needs doc
112 */
113bool is_backlight_enabled(void) { return backlight_config.enable; }
114
115/** \brief Backlight step through levels
116 *
117 * FIXME: needs doc
118 */
119void backlight_step(void) {
120 backlight_config.level++;
121 if (backlight_config.level > BACKLIGHT_LEVELS) {
122 backlight_config.level = 0;
123 }
124 backlight_config.enable = !!backlight_config.level;
125 eeconfig_update_backlight(backlight_config.raw);
126 dprintf("backlight step: %u\n", backlight_config.level);
127 backlight_set(backlight_config.level);
128}
129
130/** \brief Backlight set level
131 *
132 * FIXME: needs doc
133 */
134void backlight_level(uint8_t level) {
135 if (level > BACKLIGHT_LEVELS) level = BACKLIGHT_LEVELS;
136 backlight_config.level = level;
137 backlight_config.enable = !!backlight_config.level;
138 eeconfig_update_backlight(backlight_config.raw);
139 backlight_set(backlight_config.level);
140}
141
142/** \brief Get backlight level
143 *
144 * FIXME: needs doc
145 */
146uint8_t get_backlight_level(void) { return backlight_config.level; }
147
148#ifdef BACKLIGHT_BREATHING
149/** \brief Backlight breathing toggle
150 *
151 * FIXME: needs doc
152 */
153void backlight_toggle_breathing(void) {
154 bool breathing = backlight_config.breathing;
155 dprintf("backlight breathing toggle: %u\n", breathing);
156 if (breathing)
157 backlight_disable_breathing();
158 else
159 backlight_enable_breathing();
160}
161
162/** \brief Enable backlight breathing
163 *
164 * FIXME: needs doc
165 */
166void backlight_enable_breathing(void) {
167 if (backlight_config.breathing) return; // do nothing if breathing is already on
168
169 backlight_config.breathing = true;
170 eeconfig_update_backlight(backlight_config.raw);
171 dprintf("backlight breathing enable\n");
172 breathing_enable();
173}
174
175/** \brief Disable backlight breathing
176 *
177 * FIXME: needs doc
178 */
179void backlight_disable_breathing(void) {
180 if (!backlight_config.breathing) return; // do nothing if breathing is already off
181
182 backlight_config.breathing = false;
183 eeconfig_update_backlight(backlight_config.raw);
184 dprintf("backlight breathing disable\n");
185 breathing_disable();
186}
187
188/** \brief Get the backlight breathing status
189 *
190 * FIXME: needs doc
191 */
192bool is_backlight_breathing(void) { return backlight_config.breathing; }
193#endif
diff --git a/tmk_core/common/backlight.h b/quantum/backlight/backlight.h
index 1e581055d..1e581055d 100644
--- a/tmk_core/common/backlight.h
+++ b/quantum/backlight/backlight.h
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c
index 9af951008..4fa45ac37 100644
--- a/quantum/keymap_common.c
+++ b/quantum/keymap_common.c
@@ -26,9 +26,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
26#include "action.h" 26#include "action.h"
27#include "action_macro.h" 27#include "action_macro.h"
28#include "debug.h" 28#include "debug.h"
29#include "backlight.h"
30#include "quantum.h" 29#include "quantum.h"
31 30
31#ifdef BACKLIGHT_ENABLE
32# include "backlight.h"
33#endif
34
32#ifdef MIDI_ENABLE 35#ifdef MIDI_ENABLE
33# include "process_midi.h" 36# include "process_midi.h"
34#endif 37#endif
diff --git a/quantum/quantum.c b/quantum/quantum.c
index e615cfc0f..2020770ea 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -24,8 +24,10 @@
24# include "outputselect.h" 24# include "outputselect.h"
25#endif 25#endif
26 26
27#include "backlight.h" 27#ifdef BACKLIGHT_ENABLE
28extern backlight_config_t backlight_config; 28# include "backlight.h"
29 extern backlight_config_t backlight_config;
30#endif
29 31
30#ifdef FAUXCLICKY_ENABLE 32#ifdef FAUXCLICKY_ENABLE
31# include "fauxclicky.h" 33# include "fauxclicky.h"
diff --git a/tmk_core/common.mk b/tmk_core/common.mk
index 221688755..db5535346 100644
--- a/tmk_core/common.mk
+++ b/tmk_core/common.mk
@@ -153,11 +153,6 @@ ifeq ($(strip $(NO_SUSPEND_POWER_DOWN)), yes)
153 TMK_COMMON_DEFS += -DNO_SUSPEND_POWER_DOWN 153 TMK_COMMON_DEFS += -DNO_SUSPEND_POWER_DOWN
154endif 154endif
155 155
156ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
157 TMK_COMMON_SRC += $(COMMON_DIR)/backlight.c
158 TMK_COMMON_DEFS += -DBACKLIGHT_ENABLE
159endif
160
161ifeq ($(strip $(BLUETOOTH_ENABLE)), yes) 156ifeq ($(strip $(BLUETOOTH_ENABLE)), yes)
162 TMK_COMMON_DEFS += -DBLUETOOTH_ENABLE 157 TMK_COMMON_DEFS += -DBLUETOOTH_ENABLE
163 TMK_COMMON_DEFS += -DNO_USB_STARTUP_CHECK 158 TMK_COMMON_DEFS += -DNO_USB_STARTUP_CHECK
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c
index 44b19d368..bd6aeba4f 100644
--- a/tmk_core/common/action.c
+++ b/tmk_core/common/action.c
@@ -20,7 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
20#include "mousekey.h" 20#include "mousekey.h"
21#include "command.h" 21#include "command.h"
22#include "led.h" 22#include "led.h"
23#include "backlight.h"
24#include "action_layer.h" 23#include "action_layer.h"
25#include "action_tapping.h" 24#include "action_tapping.h"
26#include "action_macro.h" 25#include "action_macro.h"
@@ -28,6 +27,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
28#include "action.h" 27#include "action.h"
29#include "wait.h" 28#include "wait.h"
30 29
30#ifdef BACKLIGHT_ENABLE
31# include "backlight.h"
32#endif
33
31#ifdef DEBUG_ACTION 34#ifdef DEBUG_ACTION
32# include "debug.h" 35# include "debug.h"
33#else 36#else
diff --git a/tmk_core/common/avr/suspend.c b/tmk_core/common/avr/suspend.c
index 574000fcd..c59c19688 100644
--- a/tmk_core/common/avr/suspend.c
+++ b/tmk_core/common/avr/suspend.c
@@ -4,7 +4,6 @@
4#include <avr/interrupt.h> 4#include <avr/interrupt.h>
5#include "matrix.h" 5#include "matrix.h"
6#include "action.h" 6#include "action.h"
7#include "backlight.h"
8#include "suspend_avr.h" 7#include "suspend_avr.h"
9#include "suspend.h" 8#include "suspend.h"
10#include "timer.h" 9#include "timer.h"
@@ -16,6 +15,10 @@
16# include "lufa.h" 15# include "lufa.h"
17#endif 16#endif
18 17
18#ifdef BACKLIGHT_ENABLE
19# include "backlight.h"
20#endif
21
19#ifdef AUDIO_ENABLE 22#ifdef AUDIO_ENABLE
20# include "audio.h" 23# include "audio.h"
21#endif /* AUDIO_ENABLE */ 24#endif /* AUDIO_ENABLE */
diff --git a/tmk_core/common/backlight.c b/tmk_core/common/backlight.c
deleted file mode 100644
index 708022f68..000000000
--- a/tmk_core/common/backlight.c
+++ /dev/null
@@ -1,193 +0,0 @@
1/*
2Copyright 2013 Mathias Andersson <wraul@dbox.se>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include "backlight.h"
19#include "eeconfig.h"
20#include "debug.h"
21
22backlight_config_t backlight_config;
23
24/** \brief Backlight initialization
25 *
26 * FIXME: needs doc
27 */
28void backlight_init(void) {
29 /* check signature */
30 if (!eeconfig_is_enabled()) {
31 eeconfig_init();
32 }
33 backlight_config.raw = eeconfig_read_backlight();
34 if (backlight_config.level > BACKLIGHT_LEVELS) {
35 backlight_config.level = BACKLIGHT_LEVELS;
36 }
37 backlight_set(backlight_config.enable ? backlight_config.level : 0);
38}
39
40/** \brief Backlight increase
41 *
42 * FIXME: needs doc
43 */
44void backlight_increase(void) {
45 if (backlight_config.level < BACKLIGHT_LEVELS) {
46 backlight_config.level++;
47 }
48 backlight_config.enable = 1;
49 eeconfig_update_backlight(backlight_config.raw);
50 dprintf("backlight increase: %u\n", backlight_config.level);
51 backlight_set(backlight_config.level);
52}
53
54/** \brief Backlight decrease
55 *
56 * FIXME: needs doc
57 */
58void backlight_decrease(void) {
59 if (backlight_config.level > 0) {
60 backlight_config.level--;
61 backlight_config.enable = !!backlight_config.level;
62 eeconfig_update_backlight(backlight_config.raw);
63 }
64 dprintf("backlight decrease: %u\n", backlight_config.level);
65 backlight_set(backlight_config.level);
66}
67
68/** \brief Backlight toggle
69 *
70 * FIXME: needs doc
71 */
72void backlight_toggle(void) {
73 bool enabled = backlight_config.enable;
74 dprintf("backlight toggle: %u\n", enabled);
75 if (enabled)
76 backlight_disable();
77 else
78 backlight_enable();
79}
80
81/** \brief Enable backlight
82 *
83 * FIXME: needs doc
84 */
85void backlight_enable(void) {
86 if (backlight_config.enable) return; // do nothing if backlight is already on
87
88 backlight_config.enable = true;
89 if (backlight_config.raw == 1) // enabled but level == 0
90 backlight_config.level = 1;
91 eeconfig_update_backlight(backlight_config.raw);
92 dprintf("backlight enable\n");
93 backlight_set(backlight_config.level);
94}
95
96/** \brief Disable backlight
97 *
98 * FIXME: needs doc
99 */
100void backlight_disable(void) {
101 if (!backlight_config.enable) return; // do nothing if backlight is already off
102
103 backlight_config.enable = false;
104 eeconfig_update_backlight(backlight_config.raw);
105 dprintf("backlight disable\n");
106 backlight_set(0);
107}
108
109/** /brief Get the backlight status
110 *
111 * FIXME: needs doc
112 */
113bool is_backlight_enabled(void) { return backlight_config.enable; }
114
115/** \brief Backlight step through levels
116 *
117 * FIXME: needs doc
118 */
119void backlight_step(void) {
120 backlight_config.level++;
121 if (backlight_config.level > BACKLIGHT_LEVELS) {
122 backlight_config.level = 0;
123 }
124 backlight_config.enable = !!backlight_config.level;
125 eeconfig_update_backlight(backlight_config.raw);
126 dprintf("backlight step: %u\n", backlight_config.level);
127 backlight_set(backlight_config.level);
128}
129
130/** \brief Backlight set level
131 *
132 * FIXME: needs doc
133 */
134void backlight_level(uint8_t level) {
135 if (level > BACKLIGHT_LEVELS) level = BACKLIGHT_LEVELS;
136 backlight_config.level = level;
137 backlight_config.enable = !!backlight_config.level;
138 eeconfig_update_backlight(backlight_config.raw);
139 backlight_set(backlight_config.level);
140}
141
142/** \brief Get backlight level
143 *
144 * FIXME: needs doc
145 */
146uint8_t get_backlight_level(void) { return backlight_config.level; }
147
148#ifdef BACKLIGHT_BREATHING
149/** \brief Backlight breathing toggle
150 *
151 * FIXME: needs doc
152 */
153void backlight_toggle_breathing(void) {
154 bool breathing = backlight_config.breathing;
155 dprintf("backlight breathing toggle: %u\n", breathing);
156 if (breathing)
157 backlight_disable_breathing();
158 else
159 backlight_enable_breathing();
160}
161
162/** \brief Enable backlight breathing
163 *
164 * FIXME: needs doc
165 */
166void backlight_enable_breathing(void) {
167 if (backlight_config.breathing) return; // do nothing if breathing is already on
168
169 backlight_config.breathing = true;
170 eeconfig_update_backlight(backlight_config.raw);
171 dprintf("backlight breathing enable\n");
172 breathing_enable();
173}
174
175/** \brief Disable backlight breathing
176 *
177 * FIXME: needs doc
178 */
179void backlight_disable_breathing(void) {
180 if (!backlight_config.breathing) return; // do nothing if breathing is already off
181
182 backlight_config.breathing = false;
183 eeconfig_update_backlight(backlight_config.raw);
184 dprintf("backlight breathing disable\n");
185 breathing_disable();
186}
187
188/** \brief Get the backlight breathing status
189 *
190 * FIXME: needs doc
191 */
192bool is_backlight_breathing(void) { return backlight_config.breathing; }
193#endif
diff --git a/tmk_core/common/chibios/suspend.c b/tmk_core/common/chibios/suspend.c
index ae1c6f53e..c0f9c28d4 100644
--- a/tmk_core/common/chibios/suspend.c
+++ b/tmk_core/common/chibios/suspend.c
@@ -8,10 +8,13 @@
8#include "action_util.h" 8#include "action_util.h"
9#include "mousekey.h" 9#include "mousekey.h"
10#include "host.h" 10#include "host.h"
11#include "backlight.h"
12#include "suspend.h" 11#include "suspend.h"
13#include "wait.h" 12#include "wait.h"
14 13
14#ifdef BACKLIGHT_ENABLE
15# include "backlight.h"
16#endif
17
15/** \brief suspend idle 18/** \brief suspend idle
16 * 19 *
17 * FIXME: needs doc 20 * FIXME: needs doc
diff --git a/tmk_core/common/command.c b/tmk_core/common/command.c
index 8bf72ef25..82cd80609 100644
--- a/tmk_core/common/command.c
+++ b/tmk_core/common/command.c
@@ -32,10 +32,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
32#include "sleep_led.h" 32#include "sleep_led.h"
33#include "led.h" 33#include "led.h"
34#include "command.h" 34#include "command.h"
35#include "backlight.h"
36#include "quantum.h" 35#include "quantum.h"
37#include "version.h" 36#include "version.h"
38 37
38#ifdef BACKLIGHT_ENABLE
39# include "backlight.h"
40#endif
41
39#ifdef MOUSEKEY_ENABLE 42#ifdef MOUSEKEY_ENABLE
40# include "mousekey.h" 43# include "mousekey.h"
41#endif 44#endif
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c
index 9806b5015..63ace9793 100644
--- a/tmk_core/common/keyboard.c
+++ b/tmk_core/common/keyboard.c
@@ -29,8 +29,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
29#include "util.h" 29#include "util.h"
30#include "sendchar.h" 30#include "sendchar.h"
31#include "eeconfig.h" 31#include "eeconfig.h"
32#include "backlight.h"
33#include "action_layer.h" 32#include "action_layer.h"
33#ifdef BACKLIGHT_ENABLE
34# include "backlight.h"
35#endif
34#ifdef BOOTMAGIC_ENABLE 36#ifdef BOOTMAGIC_ENABLE
35# include "bootmagic.h" 37# include "bootmagic.h"
36#else 38#else