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 | |
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')
-rw-r--r-- | keyboards/clueboard/17/17.c | 10 | ||||
-rw-r--r-- | keyboards/clueboard/2x1800/2018/2018.c | 41 | ||||
-rw-r--r-- | keyboards/clueboard/2x1800/2018/config.h | 4 | ||||
-rw-r--r-- | keyboards/clueboard/60/config.h | 4 | ||||
-rw-r--r-- | keyboards/clueboard/60/led.c | 12 | ||||
-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 | ||||
-rw-r--r-- | keyboards/clueboard/66_hotswap/prototype/config.h | 2 | ||||
-rw-r--r-- | keyboards/clueboard/66_hotswap/prototype/prototype.c | 30 | ||||
-rw-r--r-- | keyboards/clueboard/card/card.c | 28 |
15 files changed, 36 insertions, 230 deletions
diff --git a/keyboards/clueboard/17/17.c b/keyboards/clueboard/17/17.c index 9e8ca644ec..44b55a323b 100644 --- a/keyboards/clueboard/17/17.c +++ b/keyboards/clueboard/17/17.c @@ -2,16 +2,6 @@ int pwm_level; -void matrix_init_kb(void) { - // put your keyboard start-up code here - // runs once when the firmware starts up - matrix_init_user(); -}; - -void led_set_kb(uint8_t usb_led) { - print("led_set\n"); -} - void backlight_init_ports(void) { // Set C7 to output DDRC |= (1<<7); diff --git a/keyboards/clueboard/2x1800/2018/2018.c b/keyboards/clueboard/2x1800/2018/2018.c index 1745309ff2..dee0c01b5b 100644 --- a/keyboards/clueboard/2x1800/2018/2018.c +++ b/keyboards/clueboard/2x1800/2018/2018.c @@ -14,44 +14,3 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "2018.h" - -void matrix_init_kb(void) { - // Set our LED pins as output - DDRB |= (1<<4); // Numlock - DDRB |= (1<<5); // Capslock - DDRB |= (1<<6); // Scroll Lock - - // Run the keymap level init - matrix_init_user(); -} - -void matrix_scan_kb(void) { - matrix_scan_user(); -} - -bool process_record_kb(uint16_t keycode, keyrecord_t *record) { - return process_record_user(keycode, record); -} - -void led_set_kb(uint8_t usb_led) { - // Toggle numlock as needed - if (usb_led & (1<<USB_LED_NUM_LOCK)) { - PORTB |= (1<<4); - } else { - PORTB &= ~(1<<4); - } - - // Toggle capslock as needed - if (usb_led & (1<<USB_LED_CAPS_LOCK)) { - PORTB |= (1<<5); - } else { - PORTB &= ~(1<<5); - } - - // Toggle scrolllock as needed - if (usb_led & (1<<USB_LED_SCROLL_LOCK)) { - PORTB |= (1<<6); - } else { - PORTB &= ~(1<<6); - } -} diff --git a/keyboards/clueboard/2x1800/2018/config.h b/keyboards/clueboard/2x1800/2018/config.h index af67b15b26..0c57b43248 100644 --- a/keyboards/clueboard/2x1800/2018/config.h +++ b/keyboards/clueboard/2x1800/2018/config.h @@ -60,6 +60,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define C4_AUDIO #define AUDIO_CLICKY +#define LED_NUM_LOCK_PIN B4 +#define LED_CAPS_LOCK_PIN B5 +#define LED_SCROLL_LOCK_PIN B6 + /* number of backlight levels */ // #define BACKLIGHT_PIN B7 // #define BACKLIGHT_BREATHING diff --git a/keyboards/clueboard/60/config.h b/keyboards/clueboard/60/config.h index f0e157ff14..3f54d0a9da 100644 --- a/keyboards/clueboard/60/config.h +++ b/keyboards/clueboard/60/config.h @@ -121,6 +121,8 @@ /* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */ //#define MIDI_TONE_KEYCODE_OCTAVES 1 - /* Backlight configuration +#define LED_CAPS_LOCK_PIN B7 + +/* Backlight configuration */ #define BACKLIGHT_LEVELS 1 diff --git a/keyboards/clueboard/60/led.c b/keyboards/clueboard/60/led.c index 91a2c537dc..20756f1e7a 100644 --- a/keyboards/clueboard/60/led.c +++ b/keyboards/clueboard/60/led.c @@ -16,7 +16,6 @@ */ #include "hal.h" -#include "led.h" #include "printf.h" #ifdef BACKLIGHT_ENABLE @@ -40,14 +39,3 @@ void backlight_set(uint8_t level) { } } #endif - -void led_set_kb(uint8_t usb_led) { - printf("led_set_kb(%d)\n", usb_led); - if (usb_led & (1<<USB_LED_CAPS_LOCK)) { - // Turn capslock on - palSetPad(GPIOB, 7); - } else { - // Turn capslock off - palClearPad(GPIOB, 7); - } -} diff --git a/keyboards/clueboard/66/rev1/config.h b/keyboards/clueboard/66/rev1/config.h index 9db64fbd49..6b61ca4d14 100644 --- a/keyboards/clueboard/66/rev1/config.h +++ b/keyboards/clueboard/66/rev1/config.h @@ -50,6 +50,8 @@ //#define NO_ACTION_MACRO //#define NO_ACTION_FUNCTION +#define LED_CAPS_LOCK_PIN F0 + /* Underlight configuration */ #define RGB_DI_PIN B2 diff --git a/keyboards/clueboard/66/rev1/rev1.c b/keyboards/clueboard/66/rev1/rev1.c index 90fc6956c9..520a869e57 100644 --- a/keyboards/clueboard/66/rev1/rev1.c +++ b/keyboards/clueboard/66/rev1/rev1.c @@ -1,17 +1 @@ #include "rev1.h" - -void led_init_ports() { - // * Set our LED pins as output - DDRF |= (1<<0); -} - -void led_set_kb(uint8_t usb_led) { - DDRF |= (1<<0); - if (usb_led & (1<<USB_LED_CAPS_LOCK)) { - // Turn capslock on - PORTF |= (1<<0); - } else { - // Turn capslock off - PORTF &= ~(1<<0); - } -} diff --git a/keyboards/clueboard/66/rev2/config.h b/keyboards/clueboard/66/rev2/config.h index f11cfe82f7..a1e4804cad 100644 --- a/keyboards/clueboard/66/rev2/config.h +++ b/keyboards/clueboard/66/rev2/config.h @@ -49,7 +49,9 @@ //#define NO_ACTION_MACRO //#define NO_ACTION_FUNCTION - /* Backlight configuration +#define LED_CAPS_LOCK_PIN B4 + +/* Backlight configuration */ #define BACKLIGHT_LEVELS 1 diff --git a/keyboards/clueboard/66/rev2/rev2.c b/keyboards/clueboard/66/rev2/rev2.c index d676b6d5fb..a533c550aa 100644 --- a/keyboards/clueboard/66/rev2/rev2.c +++ b/keyboards/clueboard/66/rev2/rev2.c @@ -1,20 +1,6 @@ #include "rev2.h" -#include <avr/io.h> -#include "backlight.h" #include "print.h" -void matrix_init_kb(void) { - // put your keyboard start-up code here - // runs once when the firmware starts up - matrix_init_user(); - led_init_ports(); -} - - -void matrix_scan_kb(void) { - matrix_scan_user(); -} - void backlight_init_ports(void) { print("init_backlight_pin()\n"); // Set our LED pins as output @@ -41,19 +27,3 @@ void backlight_set(uint8_t level) { PORTD &= ~(1<<4); // Arrows } } - -void led_init_ports() { - // * Set our LED pins as output - DDRB |= (1<<4); -} - -void led_set_kb(uint8_t usb_led) { - DDRB |= (1<<4); - if (usb_led & (1<<USB_LED_CAPS_LOCK)) { - // Turn capslock on - PORTB |= (1<<4); - } else { - // Turn capslock off - PORTB &= ~(1<<4); - } -} diff --git a/keyboards/clueboard/66/rev3/config.h b/keyboards/clueboard/66/rev3/config.h index bbbd82a1c0..2d063d4e61 100644 --- a/keyboards/clueboard/66/rev3/config.h +++ b/keyboards/clueboard/66/rev3/config.h @@ -49,7 +49,9 @@ //#define NO_ACTION_MACRO //#define NO_ACTION_FUNCTION - /* Backlight configuration +#define LED_CAPS_LOCK_PIN B4 + +/* Backlight configuration */ #define BACKLIGHT_LEVELS 1 diff --git a/keyboards/clueboard/66/rev3/rev3.c b/keyboards/clueboard/66/rev3/rev3.c index 195a21a9e8..7ec8dcb681 100644 --- a/keyboards/clueboard/66/rev3/rev3.c +++ b/keyboards/clueboard/66/rev3/rev3.c @@ -1,20 +1,6 @@ #include "rev3.h" -#include <avr/io.h> -#include "backlight.h" #include "print.h" -void matrix_init_kb(void) { - // put your keyboard start-up code here - // runs once when the firmware starts up - matrix_init_user(); - led_init_ports(); -} - - -void matrix_scan_kb(void) { - matrix_scan_user(); -} - void backlight_init_ports(void) { print("init_backlight_pin()\n"); // Set our LED pins as output @@ -41,19 +27,3 @@ void backlight_set(uint8_t level) { PORTD &= ~(1<<4); // Arrows } } - -void led_init_ports() { - // * Set our LED pins as output - DDRB |= (1<<4); -} - -void led_set_kb(uint8_t usb_led) { - DDRB |= (1<<4); - if (usb_led & (1<<USB_LED_CAPS_LOCK)) { - // Turn capslock on - PORTB |= (1<<4); - } else { - // Turn capslock off - PORTB &= ~(1<<4); - } -} diff --git a/keyboards/clueboard/66/rev4/rev4.c b/keyboards/clueboard/66/rev4/rev4.c index 69eb48183e..00d4f325e5 100644 --- a/keyboards/clueboard/66/rev4/rev4.c +++ b/keyboards/clueboard/66/rev4/rev4.c @@ -1,43 +1,30 @@ #include "rev4.h" -//#include "backlight.h" void matrix_init_kb(void) { - // put your keyboard start-up code here - // runs once when the firmware starts up - matrix_init_user(); led_init_ports(); + + matrix_init_user(); } void led_init_ports() { // Set our LED pins as output - palSetPadMode(GPIOB, 13, PAL_MODE_OUTPUT_PUSHPULL); // LED1 - palClearPad(GPIOB, 13); - palSetPadMode(GPIOB, 14, PAL_MODE_OUTPUT_PUSHPULL); // LED2 - palClearPad(GPIOB, 14); - palSetPadMode(GPIOA, 8, PAL_MODE_OUTPUT_PUSHPULL); // LED3 - palClearPad(GPIOA, 8); - palSetPadMode(GPIOA, 0, PAL_MODE_OUTPUT_PUSHPULL); // Capslock LED - palClearPad(GPIOA, 0); + setPinOutput(B13); // LED1 + writePinLow(B13); + setPinOutput(B14); // LED2 + writePinLow(B14); + setPinOutput(A8); // LED3 + writePinLow(A8); + setPinOutput(A0); // Capslock LED + writePinLow(A0); } -void led_set_kb(uint8_t usb_led) { - if (usb_led & (1<<USB_LED_NUM_LOCK)) { - palSetPad(GPIOB, 13); // LED1 - } else { - palClearPad(GPIOB, 13); // LED1 - } - - if (usb_led & (1<<USB_LED_CAPS_LOCK)) { - palSetPad(GPIOA, 0); // Capslock LED - palSetPad(GPIOB, 14); // LED2 - } else { - palClearPad(GPIOA, 0); // Capslock LED - palClearPad(GPIOB, 14); // LED2 - } - - if (usb_led & (1<<USB_LED_SCROLL_LOCK)) { - palSetPad(GPIOA, 8); // LED3 - } else { - palClearPad(GPIOA, 8); // LED3 +bool led_update_kb(led_t led_state) { + bool res = led_update_user(led_state); + if(res) { + writePin(B13, led_state.num_lock); + writePin(A0, led_state.caps_lock); + writePin(B14, led_state.caps_lock); + writePin(A8, led_state.scroll_lock); } + return res; } diff --git a/keyboards/clueboard/66_hotswap/prototype/config.h b/keyboards/clueboard/66_hotswap/prototype/config.h index 7679d08e52..f6ab6ba535 100644 --- a/keyboards/clueboard/66_hotswap/prototype/config.h +++ b/keyboards/clueboard/66_hotswap/prototype/config.h @@ -32,6 +32,8 @@ */ #define NO_ACTION_TAPPING +#define LED_CAPS_LOCK_PIN B4 + /* Backlight configuration */ #define BACKLIGHT_LEVELS 1 diff --git a/keyboards/clueboard/66_hotswap/prototype/prototype.c b/keyboards/clueboard/66_hotswap/prototype/prototype.c index 7c307be61a..4ce3dd65f7 100644 --- a/keyboards/clueboard/66_hotswap/prototype/prototype.c +++ b/keyboards/clueboard/66_hotswap/prototype/prototype.c @@ -1,20 +1,6 @@ #include "prototype.h" -#include <avr/io.h> -#include "backlight.h" #include "print.h" -void matrix_init_kb(void) { - // put your keyboard start-up code here - // runs once when the firmware starts up - matrix_init_user(); - led_init_ports(); -} - - -void matrix_scan_kb(void) { - matrix_scan_user(); -} - void backlight_init_ports(void) { print("init_backlight_pin()\n"); // Set our LED pins as output @@ -41,19 +27,3 @@ void backlight_set(uint8_t level) { PORTD &= ~(1<<1); // Arrows } } - -void led_init_ports() { - // * Set our LED pins as output - DDRB |= (1<<4); -} - -void led_set_kb(uint8_t usb_led) { - DDRB |= (1<<4); - if (usb_led & (1<<USB_LED_CAPS_LOCK)) { - // Turn capslock on - PORTB |= (1<<4); - } else { - // Turn capslock off - PORTB &= ~(1<<4); - } -} diff --git a/keyboards/clueboard/card/card.c b/keyboards/clueboard/card/card.c index 9b4b397d92..33a4cc3cdc 100644 --- a/keyboards/clueboard/card/card.c +++ b/keyboards/clueboard/card/card.c @@ -1,35 +1,9 @@ #include "card.h" + #define BL_RED OCR1B #define BL_GREEN OCR1A #define BL_BLUE OCR1C -void matrix_init_kb(void) { - // put your keyboard start-up code here - // runs once when the firmware starts up - - matrix_init_user(); -} - -void matrix_scan_kb(void) { - // put your looping keyboard code here - // runs every cycle (a lot) - - matrix_scan_user(); -} - -bool process_record_kb(uint16_t keycode, keyrecord_t *record) { - // put your per-action keyboard code here - // runs for every action, just before processing by the firmware - - return process_record_user(keycode, record); -} - -void led_set_kb(uint8_t usb_led) { - // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here - - led_set_user(usb_led); -} - void backlight_init_ports(void) { // Set B5, B6, and B7 as output |