diff options
| author | Joel Challis <git@zvecr.com> | 2020-11-21 19:11:50 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-21 19:11:50 +0000 |
| commit | 95fd2ce81a394d972d922b7be34a99752aed9e31 (patch) | |
| tree | f09ac6312037356da157ccd1304a0552c2bffadf /keyboards/clueboard/66 | |
| parent | 23222625c201cd960a5b4a99ee52e74d4c13bba9 (diff) | |
| download | qmk_firmware-95fd2ce81a394d972d922b7be34a99752aed9e31.tar.gz qmk_firmware-95fd2ce81a394d972d922b7be34a99752aed9e31.zip | |
Refactor to use led config - Part 4 (#10967)
* Refactor to use led config
* Refactor to use led_update_kb
Diffstat (limited to 'keyboards/clueboard/66')
| -rw-r--r-- | keyboards/clueboard/66/rev1/config.h | 2 | ||||
| -rw-r--r-- | keyboards/clueboard/66/rev1/rev1.c | 16 | ||||
| -rw-r--r-- | keyboards/clueboard/66/rev2/config.h | 4 | ||||
| -rw-r--r-- | keyboards/clueboard/66/rev2/rev2.c | 30 | ||||
| -rw-r--r-- | keyboards/clueboard/66/rev3/config.h | 4 | ||||
| -rw-r--r-- | keyboards/clueboard/66/rev3/rev3.c | 30 | ||||
| -rw-r--r-- | keyboards/clueboard/66/rev4/rev4.c | 49 |
7 files changed, 26 insertions, 109 deletions
diff --git a/keyboards/clueboard/66/rev1/config.h b/keyboards/clueboard/66/rev1/config.h index 9db64fbd4..6b61ca4d1 100644 --- a/keyboards/clueboard/66/rev1/config.h +++ b/keyboards/clueboard/66/rev1/config.h | |||
| @@ -50,6 +50,8 @@ | |||
| 50 | //#define NO_ACTION_MACRO | 50 | //#define NO_ACTION_MACRO |
| 51 | //#define NO_ACTION_FUNCTION | 51 | //#define NO_ACTION_FUNCTION |
| 52 | 52 | ||
| 53 | #define LED_CAPS_LOCK_PIN F0 | ||
| 54 | |||
| 53 | /* Underlight configuration | 55 | /* Underlight configuration |
| 54 | */ | 56 | */ |
| 55 | #define RGB_DI_PIN B2 | 57 | #define RGB_DI_PIN B2 |
diff --git a/keyboards/clueboard/66/rev1/rev1.c b/keyboards/clueboard/66/rev1/rev1.c index 90fc6956c..520a869e5 100644 --- a/keyboards/clueboard/66/rev1/rev1.c +++ b/keyboards/clueboard/66/rev1/rev1.c | |||
| @@ -1,17 +1 @@ | |||
| 1 | #include "rev1.h" | #include "rev1.h" | |
| 2 | |||
| 3 | void led_init_ports() { | ||
| 4 | // * Set our LED pins as output | ||
| 5 | DDRF |= (1<<0); | ||
| 6 | } | ||
| 7 | |||
| 8 | void led_set_kb(uint8_t usb_led) { | ||
| 9 | DDRF |= (1<<0); | ||
| 10 | if (usb_led & (1<<USB_LED_CAPS_LOCK)) { | ||
| 11 | // Turn capslock on | ||
| 12 | PORTF |= (1<<0); | ||
| 13 | } else { | ||
| 14 | // Turn capslock off | ||
| 15 | PORTF &= ~(1<<0); | ||
| 16 | } | ||
| 17 | } | ||
diff --git a/keyboards/clueboard/66/rev2/config.h b/keyboards/clueboard/66/rev2/config.h index f11cfe82f..a1e4804ca 100644 --- a/keyboards/clueboard/66/rev2/config.h +++ b/keyboards/clueboard/66/rev2/config.h | |||
| @@ -49,7 +49,9 @@ | |||
| 49 | //#define NO_ACTION_MACRO | 49 | //#define NO_ACTION_MACRO |
| 50 | //#define NO_ACTION_FUNCTION | 50 | //#define NO_ACTION_FUNCTION |
| 51 | 51 | ||
| 52 | /* Backlight configuration | 52 | #define LED_CAPS_LOCK_PIN B4 |
| 53 | |||
| 54 | /* Backlight configuration | ||
| 53 | */ | 55 | */ |
| 54 | #define BACKLIGHT_LEVELS 1 | 56 | #define BACKLIGHT_LEVELS 1 |
| 55 | 57 | ||
diff --git a/keyboards/clueboard/66/rev2/rev2.c b/keyboards/clueboard/66/rev2/rev2.c index d676b6d5f..a533c550a 100644 --- a/keyboards/clueboard/66/rev2/rev2.c +++ b/keyboards/clueboard/66/rev2/rev2.c | |||
| @@ -1,20 +1,6 @@ | |||
| 1 | #include "rev2.h" | 1 | #include "rev2.h" |
| 2 | #include <avr/io.h> | ||
| 3 | #include "backlight.h" | ||
| 4 | #include "print.h" | 2 | #include "print.h" |
| 5 | 3 | ||
| 6 | void matrix_init_kb(void) { | ||
| 7 | // put your keyboard start-up code here | ||
| 8 | // runs once when the firmware starts up | ||
| 9 | matrix_init_user(); | ||
| 10 | led_init_ports(); | ||
| 11 | } | ||
| 12 | |||
| 13 | |||
| 14 | void matrix_scan_kb(void) { | ||
| 15 | matrix_scan_user(); | ||
| 16 | } | ||
| 17 | |||
| 18 | void backlight_init_ports(void) { | 4 | void backlight_init_ports(void) { |
| 19 | print("init_backlight_pin()\n"); | 5 | print("init_backlight_pin()\n"); |
| 20 | // Set our LED pins as output | 6 | // Set our LED pins as output |
| @@ -41,19 +27,3 @@ void backlight_set(uint8_t level) { | |||
| 41 | PORTD &= ~(1<<4); // Arrows | 27 | PORTD &= ~(1<<4); // Arrows |
| 42 | } | 28 | } |
| 43 | } | 29 | } |
| 44 | |||
| 45 | void led_init_ports() { | ||
| 46 | // * Set our LED pins as output | ||
| 47 | DDRB |= (1<<4); | ||
| 48 | } | ||
| 49 | |||
| 50 | void led_set_kb(uint8_t usb_led) { | ||
| 51 | DDRB |= (1<<4); | ||
| 52 | if (usb_led & (1<<USB_LED_CAPS_LOCK)) { | ||
| 53 | // Turn capslock on | ||
| 54 | PORTB |= (1<<4); | ||
| 55 | } else { | ||
| 56 | // Turn capslock off | ||
| 57 | PORTB &= ~(1<<4); | ||
| 58 | } | ||
| 59 | } | ||
diff --git a/keyboards/clueboard/66/rev3/config.h b/keyboards/clueboard/66/rev3/config.h index bbbd82a1c..2d063d4e6 100644 --- a/keyboards/clueboard/66/rev3/config.h +++ b/keyboards/clueboard/66/rev3/config.h | |||
| @@ -49,7 +49,9 @@ | |||
| 49 | //#define NO_ACTION_MACRO | 49 | //#define NO_ACTION_MACRO |
| 50 | //#define NO_ACTION_FUNCTION | 50 | //#define NO_ACTION_FUNCTION |
| 51 | 51 | ||
| 52 | /* Backlight configuration | 52 | #define LED_CAPS_LOCK_PIN B4 |
| 53 | |||
| 54 | /* Backlight configuration | ||
| 53 | */ | 55 | */ |
| 54 | #define BACKLIGHT_LEVELS 1 | 56 | #define BACKLIGHT_LEVELS 1 |
| 55 | 57 | ||
diff --git a/keyboards/clueboard/66/rev3/rev3.c b/keyboards/clueboard/66/rev3/rev3.c index 195a21a9e..7ec8dcb68 100644 --- a/keyboards/clueboard/66/rev3/rev3.c +++ b/keyboards/clueboard/66/rev3/rev3.c | |||
| @@ -1,20 +1,6 @@ | |||
| 1 | #include "rev3.h" | 1 | #include "rev3.h" |
| 2 | #include <avr/io.h> | ||
| 3 | #include "backlight.h" | ||
| 4 | #include "print.h" | 2 | #include "print.h" |
| 5 | 3 | ||
| 6 | void matrix_init_kb(void) { | ||
| 7 | // put your keyboard start-up code here | ||
| 8 | // runs once when the firmware starts up | ||
| 9 | matrix_init_user(); | ||
| 10 | led_init_ports(); | ||
| 11 | } | ||
| 12 | |||
| 13 | |||
| 14 | void matrix_scan_kb(void) { | ||
| 15 | matrix_scan_user(); | ||
| 16 | } | ||
| 17 | |||
| 18 | void backlight_init_ports(void) { | 4 | void backlight_init_ports(void) { |
| 19 | print("init_backlight_pin()\n"); | 5 | print("init_backlight_pin()\n"); |
| 20 | // Set our LED pins as output | 6 | // Set our LED pins as output |
| @@ -41,19 +27,3 @@ void backlight_set(uint8_t level) { | |||
| 41 | PORTD &= ~(1<<4); // Arrows | 27 | PORTD &= ~(1<<4); // Arrows |
| 42 | } | 28 | } |
| 43 | } | 29 | } |
| 44 | |||
| 45 | void led_init_ports() { | ||
| 46 | // * Set our LED pins as output | ||
| 47 | DDRB |= (1<<4); | ||
| 48 | } | ||
| 49 | |||
| 50 | void led_set_kb(uint8_t usb_led) { | ||
| 51 | DDRB |= (1<<4); | ||
| 52 | if (usb_led & (1<<USB_LED_CAPS_LOCK)) { | ||
| 53 | // Turn capslock on | ||
| 54 | PORTB |= (1<<4); | ||
| 55 | } else { | ||
| 56 | // Turn capslock off | ||
| 57 | PORTB &= ~(1<<4); | ||
| 58 | } | ||
| 59 | } | ||
diff --git a/keyboards/clueboard/66/rev4/rev4.c b/keyboards/clueboard/66/rev4/rev4.c index 69eb48183..00d4f325e 100644 --- a/keyboards/clueboard/66/rev4/rev4.c +++ b/keyboards/clueboard/66/rev4/rev4.c | |||
| @@ -1,43 +1,30 @@ | |||
| 1 | #include "rev4.h" | 1 | #include "rev4.h" |
| 2 | //#include "backlight.h" | ||
| 3 | 2 | ||
| 4 | void matrix_init_kb(void) { | 3 | void matrix_init_kb(void) { |
| 5 | // put your keyboard start-up code here | ||
| 6 | // runs once when the firmware starts up | ||
| 7 | matrix_init_user(); | ||
| 8 | led_init_ports(); | 4 | led_init_ports(); |
| 5 | |||
| 6 | matrix_init_user(); | ||
| 9 | } | 7 | } |
| 10 | 8 | ||
| 11 | void led_init_ports() { | 9 | void led_init_ports() { |
| 12 | // Set our LED pins as output | 10 | // Set our LED pins as output |
| 13 | palSetPadMode(GPIOB, 13, PAL_MODE_OUTPUT_PUSHPULL); // LED1 | 11 | setPinOutput(B13); // LED1 |
| 14 | palClearPad(GPIOB, 13); | 12 | writePinLow(B13); |
| 15 | palSetPadMode(GPIOB, 14, PAL_MODE_OUTPUT_PUSHPULL); // LED2 | 13 | setPinOutput(B14); // LED2 |
| 16 | palClearPad(GPIOB, 14); | 14 | writePinLow(B14); |
| 17 | palSetPadMode(GPIOA, 8, PAL_MODE_OUTPUT_PUSHPULL); // LED3 | 15 | setPinOutput(A8); // LED3 |
| 18 | palClearPad(GPIOA, 8); | 16 | writePinLow(A8); |
| 19 | palSetPadMode(GPIOA, 0, PAL_MODE_OUTPUT_PUSHPULL); // Capslock LED | 17 | setPinOutput(A0); // Capslock LED |
| 20 | palClearPad(GPIOA, 0); | 18 | writePinLow(A0); |
| 21 | } | 19 | } |
| 22 | 20 | ||
| 23 | void led_set_kb(uint8_t usb_led) { | 21 | bool led_update_kb(led_t led_state) { |
| 24 | if (usb_led & (1<<USB_LED_NUM_LOCK)) { | 22 | bool res = led_update_user(led_state); |
| 25 | palSetPad(GPIOB, 13); // LED1 | 23 | if(res) { |
| 26 | } else { | 24 | writePin(B13, led_state.num_lock); |
| 27 | palClearPad(GPIOB, 13); // LED1 | 25 | writePin(A0, led_state.caps_lock); |
| 28 | } | 26 | writePin(B14, led_state.caps_lock); |
| 29 | 27 | writePin(A8, led_state.scroll_lock); | |
| 30 | if (usb_led & (1<<USB_LED_CAPS_LOCK)) { | ||
| 31 | palSetPad(GPIOA, 0); // Capslock LED | ||
| 32 | palSetPad(GPIOB, 14); // LED2 | ||
| 33 | } else { | ||
| 34 | palClearPad(GPIOA, 0); // Capslock LED | ||
| 35 | palClearPad(GPIOB, 14); // LED2 | ||
| 36 | } | ||
| 37 | |||
| 38 | if (usb_led & (1<<USB_LED_SCROLL_LOCK)) { | ||
| 39 | palSetPad(GPIOA, 8); // LED3 | ||
| 40 | } else { | ||
| 41 | palClearPad(GPIOA, 8); // LED3 | ||
| 42 | } | 28 | } |
| 29 | return res; | ||
| 43 | } | 30 | } |
