aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIBNobody <protospherex@gmail.com>2016-03-15 23:52:51 -0500
committerIBNobody <protospherex@gmail.com>2016-03-15 23:52:51 -0500
commiteba9a7d74db0be548cddc107f0370dabf43b017f (patch)
tree30320f53b83f944c5c038e19ae5cb2aa34423cfd
parent35393fa9dc3d14ea80ce72f27c13b1759600b245 (diff)
downloadqmk_firmware-eba9a7d74db0be548cddc107f0370dabf43b017f.tar.gz
qmk_firmware-eba9a7d74db0be548cddc107f0370dabf43b017f.zip
Adding LED function pointers
-rw-r--r--quantum/led.c12
-rw-r--r--quantum/template/template.c29
-rw-r--r--quantum/template/template.h1
-rw-r--r--tmk_core/common/led.h2
4 files changed, 38 insertions, 6 deletions
diff --git a/quantum/led.c b/quantum/led.c
index 2c0574660..a53e94043 100644
--- a/quantum/led.c
+++ b/quantum/led.c
@@ -16,9 +16,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/ 16*/
17 17
18#include <avr/io.h> 18#include <avr/io.h>
19#include "stdint.h" 19#include <stddef.h>
20#include "led.h" 20#include "led.h"
21 21
22__attribute__ ((weak))
23void * led_set_kb(uint8_t usb_led) {
24 return NULL;
25};
22 26
23void led_set(uint8_t usb_led) 27void led_set(uint8_t usb_led)
24{ 28{
@@ -35,4 +39,10 @@ void led_set(uint8_t usb_led)
35 // DDRE &= ~(1<<6); 39 // DDRE &= ~(1<<6);
36 // PORTE &= ~(1<<6); 40 // PORTE &= ~(1<<6);
37 // } 41 // }
42
43 if (led_set_kb) {
44 (*led_set_kb)(usb_led);
45 }
46
47 return;
38} 48}
diff --git a/quantum/template/template.c b/quantum/template/template.c
index 7be7dfc3d..016e11300 100644
--- a/quantum/template/template.c
+++ b/quantum/template/template.c
@@ -2,28 +2,47 @@
2 2
3__attribute__ ((weak)) 3__attribute__ ((weak))
4void * matrix_init_user(void) { 4void * matrix_init_user(void) {
5 // leave these blank 5 // leave this function blank - it can be defined in a keymap file
6 return NULL;
6}; 7};
7 8
8__attribute__ ((weak)) 9__attribute__ ((weak))
9void * matrix_scan_user(void) { 10void * matrix_scan_user(void) {
10 // leave these blank 11 // leave this function blank - it can be defined in a keymap file
12 return NULL;
13};
14
15__attribute__ ((weak))
16void * led_set_user(uint8_t usb_led) {
17 // leave this function blank - it can be defined in a keymap file
18 return NULL;
11}; 19};
12 20
13void * matrix_init_kb(void) { 21void * matrix_init_kb(void) {
14 // put your keyboard start-up code here 22 // put your keyboard start-up code here
15 // runs once when the firmware starts up 23 // runs once when the firmware starts up
16 24
17 if (matrix_init_user) { 25 if (matrix_init_user) {
18 (*matrix_init_user)(); 26 (*matrix_init_user)();
19 } 27 }
28 return NULL;
20}; 29};
21 30
22void * matrix_scan_kb(void) { 31void * matrix_scan_kb(void) {
23 // put your looping keyboard code here 32 // put your looping keyboard code here
24 // runs every cycle (a lot) 33 // runs every cycle (a lot)
25 34
26 if (matrix_scan_user) { 35 if (matrix_scan_user) {
27 (*matrix_scan_user)(); 36 (*matrix_scan_user)();
28 } 37 }
38 return NULL;
39};
40
41void * led_set_kb(uint8_t usb_led) {
42 // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
43
44 if (led_set_user) {
45 (*led_set_user)(usb_led);
46 }
47 return NULL;
29}; \ No newline at end of file 48}; \ No newline at end of file
diff --git a/quantum/template/template.h b/quantum/template/template.h
index a15061b26..ed17ca001 100644
--- a/quantum/template/template.h
+++ b/quantum/template/template.h
@@ -21,5 +21,6 @@
21 21
22void * matrix_init_user(void); 22void * matrix_init_user(void);
23void * matrix_scan_user(void); 23void * matrix_scan_user(void);
24void * led_set_user(uint8_t usb_led);
24 25
25#endif \ No newline at end of file 26#endif \ No newline at end of file
diff --git a/tmk_core/common/led.h b/tmk_core/common/led.h
index d5fc051bf..4b9632d3a 100644
--- a/tmk_core/common/led.h
+++ b/tmk_core/common/led.h
@@ -33,6 +33,8 @@ extern "C" {
33#endif 33#endif
34 34
35void led_set(uint8_t usb_led); 35void led_set(uint8_t usb_led);
36void * led_set_kb(uint8_t usb_led);
37
36 38
37#ifdef __cplusplus 39#ifdef __cplusplus
38} 40}