Skip to content

Commit

Permalink
Refactor to use led config - Part 5 (#10975)
Browse files Browse the repository at this point in the history
* Refactor to use led config

* Refactor to use led config

* Refactor to use led config
  • Loading branch information
zvecr authored Nov 21, 2020
1 parent 4368611 commit 2322262
Show file tree
Hide file tree
Showing 42 changed files with 81 additions and 671 deletions.
24 changes: 0 additions & 24 deletions keyboards/al1/al1.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,3 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "al1.h"

bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
return process_record_user(keycode, record);
}

void led_set_kb(uint8_t usb_led) {
CONFIG_LED_IO;
print_dec(usb_led);
if (usb_led & (1<<USB_LED_CAPS_LOCK))
PORTB &= ~(1<<7);
else
PORTB |= (1<<7);

if (usb_led & (1<<USB_LED_NUM_LOCK))
PORTD &= ~(1<<0);
else
PORTD |= (1<<0);

if (usb_led & (1<<USB_LED_SCROLL_LOCK))
PORTD &= ~(1<<1);
else
PORTD |= (1<<1);
led_set_user(usb_led);
}
5 changes: 0 additions & 5 deletions keyboards/al1/al1.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@

#include "quantum.h"

#define CONFIG_LED_IO \
DDRB |= (1<<7) | (1<<6); \
DDRD |= (1<<0) | (1<<1);


#define LAYOUT( \
K500, K000, K001, K002, K003, K004, K005, K006, K007, K008, K009, K010, K011, K012, K013, K014, K015, K415, K414,\
K501, K100, K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K111, K112, K113, K114, K115, K215, K413,\
Expand Down
5 changes: 5 additions & 0 deletions keyboards/al1/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* COL2ROW, ROW2COL*/
#define DIODE_DIRECTION COL2ROW

#define LED_NUM_LOCK_PIN D0
#define LED_CAPS_LOCK_PIN B7
#define LED_SCROLL_LOCK_PIN D1
#define LED_PIN_ON_STATE 0

#define BACKLIGHT_PIN B6
#define BACKLIGHT_BREATHING
#define BACKLIGHT_LEVELS 3
Expand Down
29 changes: 0 additions & 29 deletions keyboards/amj40/amj40.c
Original file line number Diff line number Diff line change
@@ -1,30 +1 @@
#include "amj40.h"
#include "led.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) {
// put your looping keyboard code here
// runs every cycle (a lot)
matrix_scan_user();
};

void led_init_ports(void) {
// * Set our LED pins as output
DDRB |= (1<<2);
}

void led_set_kb(uint8_t usb_led) {
if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
// Turn capslock on
PORTB &= ~(1<<2);
} else {
// Turn capslock off
PORTB |= (1<<2);
}
}
3 changes: 3 additions & 0 deletions keyboards/amj40/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MATRIX_COL_PINS { F1, F0, E6, C7, C6, B0, D4, B1, B7, B5, B4, D7}
#define UNUSED_PINS

#define LED_CAPS_LOCK_PIN B2
#define LED_PIN_ON_STATE 0

#define BACKLIGHT_PIN B6

/* COL2ROW or ROW2COL */
Expand Down
3 changes: 3 additions & 0 deletions keyboards/doro67/multi/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@

#define DIODE_DIRECTION COL2ROW

#define LED_CAPS_LOCK_PIN E6
#define LED_PIN_ON_STATE 0

#define BACKLIGHT_PIN B7
#define BACKLIGHT_LEVELS 7
34 changes: 0 additions & 34 deletions keyboards/doro67/multi/multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,3 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "multi.h"

void matrix_init_kb(void) {
// put your keyboard start-up code here
// runs once when the firmware starts up

setPinOutput(E6);
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

if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) {
writePinLow(E6);
} else {
writePinHigh(E6);
}

led_set_user(usb_led);
}
3 changes: 3 additions & 0 deletions keyboards/doro67/regular/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@
#define MATRIX_COL_PINS { B0, B1, B2, B3, D4, D6, D7, B4, B5, B6, C6, C7, F5, F6, F7 }

#define DIODE_DIRECTION COL2ROW

#define LED_CAPS_LOCK_PIN E6
#define LED_PIN_ON_STATE 0
31 changes: 0 additions & 31 deletions keyboards/doro67/regular/regular.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,3 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "regular.h"

void matrix_init_kb(void) {
// put your keyboard start-up code here
// runs once when the firmware starts up
setPinOutput(E6);
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
if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) {
writePinLow(E6);
} else {
writePinHigh(E6);
}
led_set_user(usb_led);
}
3 changes: 3 additions & 0 deletions keyboards/doro67/rgb/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* COL2ROW, ROW2COL*/
#define DIODE_DIRECTION COL2ROW

#define LED_CAPS_LOCK_PIN E6
#define LED_PIN_ON_STATE 0

// The pin connected to the data pin of the LEDs
#define RGB_DI_PIN B7
// The number of LEDs connected
Expand Down
37 changes: 0 additions & 37 deletions keyboards/doro67/rgb/rgb.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,6 @@
#include "rgb.h"
#include "rgb_matrix_types.h"

// Optional override functions below.
// You can leave any or all of these undefined.
// These are only required if you want to perform custom actions.



void matrix_init_kb(void) {
// put your keyboard start-up code here
// runs once when the firmware starts up
setPinOutput(E6);
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
if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) {
writePinLow(E6);
} else {
writePinHigh(E6);
}
led_set_user(usb_led);
}

led_config_t g_led_config = { {
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 },
{ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 },
Expand Down
5 changes: 5 additions & 0 deletions keyboards/espectro/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
/* COL2ROW or ROW2COL */
#define DIODE_DIRECTION COL2ROW

#define LED_NUM_LOCK_PIN B0
#define LED_CAPS_LOCK_PIN B2
#define LED_SCROLL_LOCK_PIN B1
#define LED_PIN_ON_STATE 0

/* number of backlight levels */
#define BACKLIGHT_PIN B6
#define BACKLIGHT_LEVELS 5
Expand Down
61 changes: 1 addition & 60 deletions keyboards/espectro/espectro.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,63 +14,4 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/


#include QMK_KEYBOARD_H
#include "quantum.h"


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);
}

__attribute__ ((weak))
void led_set_user(uint8_t usb_led) {

if (usb_led & (1 << USB_LED_NUM_LOCK)) {
DDRB |= (1 << 0); PORTB &= ~(1 << 0);
} else {
DDRB &= ~(1 << 0); PORTB &= ~(1 << 0);
}

if (usb_led & (1 << USB_LED_CAPS_LOCK)) {
DDRB |= (1 << 2); PORTB &= ~(1 << 2);
} else {
DDRB &= ~(1 << 2); PORTB &= ~(1 << 2);
}

if (usb_led & (1 << USB_LED_SCROLL_LOCK)) {
DDRB |= (1 << 1); PORTB &= ~(1 << 1);
} else {
DDRB &= ~(1 << 1); PORTB &= ~(1 << 1);
}

if (usb_led & (1 << USB_LED_COMPOSE)) {

} else {

}

if (usb_led & (1 << USB_LED_KANA)) {

} else {

}

}

#include "espectro.h"
9 changes: 5 additions & 4 deletions keyboards/evil80/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@
#define MATRIX_COL_PINS { B2, D0, D1, D2, D3, D5, D4, D6, D7, B4, B1, C6, C7, E6, F6, F7 }
#define UNUSED_PINS

#define BACKLIGHT_PIN B5
#define BACKLIGHT_BREATHING

/* COL2ROW or ROW2COL */
#define DIODE_DIRECTION COL2ROW

/* define if matrix has ghost */
//#define MATRIX_HAS_GHOST

/* number of backlight levels */
#define LED_CAPS_LOCK_PIN B6
#define LED_SCROLL_LOCK_PIN B7

#define BACKLIGHT_PIN B5
#define BACKLIGHT_BREATHING
#define BACKLIGHT_LEVELS 3

/* Set 0 if debouncing isn't needed */
Expand Down
46 changes: 0 additions & 46 deletions keyboards/evil80/evil80.c
Original file line number Diff line number Diff line change
@@ -1,47 +1 @@
#include "evil80.h"
void matrix_init_kb(void) {
// put your keyboard start-up code here
// runs once when the firmware starts up
led_init_ports();
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_init_ports(void) {
DDRB |= (1<<6) | (1<<7); // OUT
}

void led_set_kb(uint8_t usb_led) {
if (usb_led & (1<<USB_LED_CAPS_LOCK))
{
PORTB |= (1<<6); // HI
}
else
{
PORTB &= ~(1<<6); // LO
}

if (usb_led & (1<<USB_LED_SCROLL_LOCK))
{
PORTB |= (1<<7); // HI
}
else
{
PORTB &= ~(1<<7); // LO
}

led_set_user(usb_led);
}
3 changes: 3 additions & 0 deletions keyboards/fc660c/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* define if matrix has ghost */
//#define MATRIX_HAS_GHOST

#define LED_CAPS_LOCK_PIN B6
#define LED_PIN_ON_STATE 0

/* number of backlight levels */
// #define BACKLIGHT_LEVELS 1

Expand Down
Loading

0 comments on commit 2322262

Please sign in to comment.