From ddcb1794fa83e62e5e48536f4bc02ada63da411a Mon Sep 17 00:00:00 2001
From: Joel Challis <git@zvecr.com>
Date: Tue, 17 Nov 2020 17:06:30 +0000
Subject: [PATCH] Refactor to use led config - Part 1 (#10905)

* Refactor to use led config

* Refactor to use led config

* Refactor to use led config

* Refactor to use led config

* Refactor to use led config
---
 keyboards/1upkeyboards/1up60hte/1up60hte.c | 16 ------
 keyboards/1upkeyboards/1up60hte/config.h   |  3 +
 keyboards/alf/dc60/config.h                |  3 +
 keyboards/alf/dc60/dc60.c                  | 33 -----------
 keyboards/alf/x11/config.h                 |  8 +--
 keyboards/alf/x11/x11.c                    | 48 ----------------
 keyboards/amj60/amj60.c                    | 29 ----------
 keyboards/amj60/config.h                   |  8 ++-
 keyboards/cutie_club/wraith/config.h       |  6 +-
 keyboards/cutie_club/wraith/wraith.c       | 25 +--------
 keyboards/dz60/config.h                    |  3 +
 keyboards/dz60/dz60.c                      | 20 -------
 keyboards/jd40/jd40.c                      | 25 ---------
 keyboards/mechkeys/mk60/config.h           |  3 +
 keyboards/mechkeys/mk60/mk60.c             | 34 ------------
 keyboards/moon/config.h                    |  3 +
 keyboards/moon/moon.c                      | 53 ------------------
 keyboards/mt980/config.h                   |  5 ++
 keyboards/mt980/mt980.c                    | 64 ----------------------
 keyboards/omnikeyish/config.h              |  6 +-
 keyboards/omnikeyish/omnikeyish.c          | 25 ---------
 keyboards/tkc/m0lly/config.h               |  4 ++
 keyboards/tkc/m0lly/m0lly.c                | 62 ++-------------------
 keyboards/tkc/tkc1800/config.h             |  4 ++
 keyboards/tkc/tkc1800/tkc1800.c            | 62 ++-------------------
 keyboards/xd84/config.h                    |  3 +
 keyboards/xd84/xd84.c                      | 16 ------
 keyboards/xd84pro/config.h                 |  3 +
 keyboards/xd84pro/xd84pro.c                | 14 -----
 keyboards/xd96/config.h                    |  4 ++
 keyboards/xd96/xd96.c                      | 26 ---------
 keyboards/yd68/config.h                    |  3 +
 keyboards/yd68/yd68.c                      | 57 ++++---------------
 keyboards/z150_bh/config.h                 |  4 ++
 keyboards/z150_bh/z150_bh.c                | 31 -----------
 35 files changed, 84 insertions(+), 629 deletions(-)

diff --git a/keyboards/1upkeyboards/1up60hte/1up60hte.c b/keyboards/1upkeyboards/1up60hte/1up60hte.c
index 3af0e9d400..460e42a0e5 100644
--- a/keyboards/1upkeyboards/1up60hte/1up60hte.c
+++ b/keyboards/1upkeyboards/1up60hte/1up60hte.c
@@ -16,19 +16,3 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "1up60hte.h"
-
-void keyboard_pre_init_kb(void) {
-	// put your keyboard start-up code here
-	// runs once when the firmware starts up
-    setPinOutput(B6);
-    keyboard_pre_init_user();
-}
-
-void led_set_kb(uint8_t usb_led) {
-	if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) {
-		writePinLow(B6);
-	} else {
-		writePinHigh(B6);
-	}
-    led_set_user(usb_led);
-}
\ No newline at end of file
diff --git a/keyboards/1upkeyboards/1up60hte/config.h b/keyboards/1upkeyboards/1up60hte/config.h
index 8c4d2fc308..c3ba030de9 100644
--- a/keyboards/1upkeyboards/1up60hte/config.h
+++ b/keyboards/1upkeyboards/1up60hte/config.h
@@ -40,6 +40,9 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 /* COL2ROW or ROW2COL */
 #define DIODE_DIRECTION COL2ROW
 
+#define LED_CAPS_LOCK_PIN B6
+#define LED_PIN_ON_STATE 0
+
 /* number of backlight levels */
 #define BACKLIGHT_PIN B7
 #ifdef BACKLIGHT_PIN
diff --git a/keyboards/alf/dc60/config.h b/keyboards/alf/dc60/config.h
index b4cff82d41..098891eee0 100644
--- a/keyboards/alf/dc60/config.h
+++ b/keyboards/alf/dc60/config.h
@@ -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 B7
+#define LED_PIN_ON_STATE 0
+
 #define BACKLIGHT_PIN B6
 #define BACKLIGHT_BREATHING
 #define BACKLIGHT_LEVELS 5
diff --git a/keyboards/alf/dc60/dc60.c b/keyboards/alf/dc60/dc60.c
index 70979adf4e..4096d10a64 100644
--- a/keyboards/alf/dc60/dc60.c
+++ b/keyboards/alf/dc60/dc60.c
@@ -14,36 +14,3 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 #include "dc60.h"
-
-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) {
-	if (usb_led & (1 << USB_LED_CAPS_LOCK)) {
-		DDRB |= (1 << 7);
-		PORTB &= ~(1 << 7);
-	} else {
-		DDRB &= ~(1 << 7);
-		PORTB &= ~(1 << 7);
-	}
-
-	led_set_user(usb_led);
-}
diff --git a/keyboards/alf/x11/config.h b/keyboards/alf/x11/config.h
index fcf4e85a9f..cd98935090 100644
--- a/keyboards/alf/x11/config.h
+++ b/keyboards/alf/x11/config.h
@@ -48,10 +48,10 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 /* COL2ROW, ROW2COL*/
 #define DIODE_DIRECTION COL2ROW
 
-/*
- * Split Keyboard specific options, make sure you have 'SPLIT_KEYBOARD = yes' in your rules.mk, and define SOFT_SERIAL_PIN.
- */
-#define SOFT_SERIAL_PIN D0 // or D1, D2, D3, E6
+#define LED_NUM_LOCK_PIN E6
+#define LED_CAPS_LOCK_PIN C6
+#define LED_SCROLL_LOCK_PIN C7
+#define LED_PIN_ON_STATE 0
 
 #define BACKLIGHT_PIN B7
 #define BACKLIGHT_BREATHING
diff --git a/keyboards/alf/x11/x11.c b/keyboards/alf/x11/x11.c
index 9699918d5b..28e77ecd3f 100644
--- a/keyboards/alf/x11/x11.c
+++ b/keyboards/alf/x11/x11.c
@@ -14,51 +14,3 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 #include "x11.h"
-
-void matrix_init_kb(void) {
-    // put your keyboard start-up code here
-    // runs once when the firmware starts up
-
-    setPinOutput(C6);
-    setPinOutput(E6);
-    setPinOutput(C7);
-    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(C6);
-    } else {
-        writePinHigh(C6);
-    }
-
-    if (IS_LED_ON(usb_led, USB_LED_NUM_LOCK)) {
-        writePinLow(E6);
-    } else {
-        writePinHigh(E6);
-    }
-
-    if (IS_LED_ON(usb_led, USB_LED_SCROLL_LOCK)) {
-        writePinLow(C7);
-    } else {
-        writePinHigh(C7);
-    }
-
-    led_set_user(usb_led);
-}
diff --git a/keyboards/amj60/amj60.c b/keyboards/amj60/amj60.c
index 993a5917db..02aa116d54 100644
--- a/keyboards/amj60/amj60.c
+++ b/keyboards/amj60/amj60.c
@@ -1,30 +1 @@
 #include "amj60.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);
-    }
-}
diff --git a/keyboards/amj60/config.h b/keyboards/amj60/config.h
index 81b70111b1..79cfbe59e4 100644
--- a/keyboards/amj60/config.h
+++ b/keyboards/amj60/config.h
@@ -38,11 +38,15 @@ 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, D6, B3}
 #define UNUSED_PINS
 
-#define BACKLIGHT_PIN B6
-
 /* COL2ROW or ROW2COL */
 #define DIODE_DIRECTION COL2ROW
 
+#define LED_CAPS_LOCK_PIN B2
+#define LED_PIN_ON_STATE 0
+
+#define BACKLIGHT_PIN B6
+
+
 /* define if matrix has ghost */
 //#define MATRIX_HAS_GHOST
 
diff --git a/keyboards/cutie_club/wraith/config.h b/keyboards/cutie_club/wraith/config.h
index a5d3f0ebc6..e1d2d51d6e 100644
--- a/keyboards/cutie_club/wraith/config.h
+++ b/keyboards/cutie_club/wraith/config.h
@@ -48,10 +48,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 /* COL2ROW, ROW2COL*/
 #define DIODE_DIRECTION COL2ROW
 
-/*
- * Split Keyboard specific options, make sure you have 'SPLIT_KEYBOARD = yes' in your rules.mk, and define SOFT_SERIAL_PIN.
- */
-#define SOFT_SERIAL_PIN D0 // or D1, D2, D3, E6
+#define LED_CAPS_LOCK_PIN B3
+#define LED_PIN_ON_STATE 0
 
 // #define BACKLIGHT_PIN B7
 // #define BACKLIGHT_BREATHING
diff --git a/keyboards/cutie_club/wraith/wraith.c b/keyboards/cutie_club/wraith/wraith.c
index 95265384ee..cb2d1911c7 100644
--- a/keyboards/cutie_club/wraith/wraith.c
+++ b/keyboards/cutie_club/wraith/wraith.c
@@ -15,29 +15,8 @@
  */
 #include "wraith.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) {
-  setPinOutput(B3);
-  setPinOutput(B0);
-  matrix_init_user();
-}
+    setPinOutput(B0);
 
-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) {
-  if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) {
-        writePinLow(B3);
-    } else {
-        writePinHigh(B3);
-    }
-  led_set_user(usb_led);
+    matrix_init_user();
 }
diff --git a/keyboards/dz60/config.h b/keyboards/dz60/config.h
index 3699ef7552..24fd63836d 100644
--- a/keyboards/dz60/config.h
+++ b/keyboards/dz60/config.h
@@ -30,6 +30,9 @@
 /* COL2ROW, ROW2COL*/
 #define DIODE_DIRECTION COL2ROW
 
+#define LED_CAPS_LOCK_PIN B2
+#define LED_PIN_ON_STATE 0
+
 #define BACKLIGHT_PIN B6
 #define BACKLIGHT_LEVELS 5
 
diff --git a/keyboards/dz60/dz60.c b/keyboards/dz60/dz60.c
index 936d027a31..23db2e4d75 100644
--- a/keyboards/dz60/dz60.c
+++ b/keyboards/dz60/dz60.c
@@ -1,21 +1 @@
 #include "dz60.h"
-
-void matrix_init_kb(void) {
-    matrix_init_user();
-    led_init_ports();
-};
-
-void led_init_ports(void) {
-    setPinOutput(B2);
-    writePinHigh(B2);
-}
-
-void led_set_kb(uint8_t usb_led) {
-    if (usb_led & (1 << USB_LED_CAPS_LOCK)) {
-        writePinLow(B2);
-    } else {
-        writePinHigh(B2);
-    }
-
-    led_set_user(usb_led);
-}
diff --git a/keyboards/jd40/jd40.c b/keyboards/jd40/jd40.c
index fa06356d97..1b68ddd4f3 100644
--- a/keyboards/jd40/jd40.c
+++ b/keyboards/jd40/jd40.c
@@ -1,26 +1 @@
 #include "jd40.h"
-
-void led_set_kb(uint8_t usb_led) {
-	// put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
-	
-
-  //  if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
-	//	gh60_caps_led_on();
-	//	} else {
-	//	gh60_caps_led_off(); 
-  //  }
-	
-    // if (usb_led & (1<<USB_LED_NUM_LOCK)) {
-		// gh60_esc_led_on();
-		// } else {
-		// gh60_esc_led_off(); 
-    // }
-	
-    // if (usb_led & (1<<USB_LED_SCROLL_LOCK)) {
-		// gh60_fn_led_on();
-		// } else {
-		// gh60_fn_led_off(); 	
-    // }
-
-	led_set_user(usb_led);	
-}
diff --git a/keyboards/mechkeys/mk60/config.h b/keyboards/mechkeys/mk60/config.h
index 9fccd8a8b0..b408625f25 100644
--- a/keyboards/mechkeys/mk60/config.h
+++ b/keyboards/mechkeys/mk60/config.h
@@ -53,6 +53,9 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 #define SOFT_SERIAL_PIN D0 // or D1, D2, D3, E6
 
+#define LED_CAPS_LOCK_PIN B7
+#define LED_PIN_ON_STATE 0
+
 #define BACKLIGHT_PIN B6
 #define BACKLIGHT_BREATHING
 #define BACKLIGHT_LEVELS 6
diff --git a/keyboards/mechkeys/mk60/mk60.c b/keyboards/mechkeys/mk60/mk60.c
index 4c6a059f4c..7ec8bff22b 100644
--- a/keyboards/mechkeys/mk60/mk60.c
+++ b/keyboards/mechkeys/mk60/mk60.c
@@ -14,37 +14,3 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 #include "mk60.h"
-
-void matrix_init_kb(void) {
-	// put your keyboard start-up code here
-	// runs once when the firmware starts up
-	setPinOutput(B7);
-
-	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(B7);
-	}else {
-		writePinHigh(B7);
-	}
-
-	led_set_user(usb_led);
-}
diff --git a/keyboards/moon/config.h b/keyboards/moon/config.h
index a02cfdba16..12a949a076 100644
--- a/keyboards/moon/config.h
+++ b/keyboards/moon/config.h
@@ -31,6 +31,9 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define MATRIX_ROWS 8
 #define MATRIX_COLS 11
 
+#define LED_CAPS_LOCK_PIN B5
+#define LED_SCROLL_LOCK_PIN B6
+
 /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
 #define DEBOUNCE 5
 
diff --git a/keyboards/moon/moon.c b/keyboards/moon/moon.c
index c218bf5ef1..95ce007e2b 100644
--- a/keyboards/moon/moon.c
+++ b/keyboards/moon/moon.c
@@ -14,56 +14,3 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 #include "moon.h"
-
-#define CAPS_PIN B5
-#define SCROLL_PIN B6
-
-// 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(CAPS_PIN);
-  setPinOutput(SCROLL_PIN);
-
-  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)) {
-    writePinHigh(CAPS_PIN);
-  } else {
-    writePinLow(CAPS_PIN);
-  }
-
-  if (IS_LED_ON(usb_led, USB_LED_SCROLL_LOCK)) {
-    writePinHigh(SCROLL_PIN);
-  } else {
-    writePinLow(SCROLL_PIN);
-  }
-
-  led_set_user(usb_led);
-}
diff --git a/keyboards/mt980/config.h b/keyboards/mt980/config.h
index 6b8b952952..56927be705 100644
--- a/keyboards/mt980/config.h
+++ b/keyboards/mt980/config.h
@@ -22,6 +22,11 @@
 /* COL2ROW or ROW2COL */
 #define DIODE_DIRECTION ROW2COL
 
+#define LED_NUM_LOCK_PIN C6
+#define LED_CAPS_LOCK_PIN C7
+#define LED_SCROLL_LOCK_PIN B5
+#define LED_PIN_ON_STATE 0
+
 /* number of backlight levels */
 #define BACKLIGHT_PIN B6
 #ifdef BACKLIGHT_PIN
diff --git a/keyboards/mt980/mt980.c b/keyboards/mt980/mt980.c
index 5461a3b21f..69f7cc491a 100644
--- a/keyboards/mt980/mt980.c
+++ b/keyboards/mt980/mt980.c
@@ -1,65 +1 @@
 #include "mt980.h"
-
-__attribute__ ((weak))
-void matrix_init_keymap(void) {}
-
-__attribute__ ((weak))
-void matrix_scan_keymap(void) {}
-
-__attribute__ ((weak))
-bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
-  return true;
-}
-__attribute__ ((weak))
-uint32_t layer_state_set_keymap (uint32_t state) {
-  return state;
-}
-__attribute__ ((weak))
-void led_set_keymap(uint8_t usb_led) {}
-
-void matrix_init_user(void) {
-  matrix_init_keymap();
-}
-
-void matrix_scan_user(void) {
-  matrix_scan_keymap();
-}
-
-void keyboard_pre_init_user(void) {
-  /* Set NUMLOCK indicator pin as output */
-  setPinOutput(C6);
-  /* Set CAPSLOCK indicator pin as output */
-  setPinOutput(C7);
-  /* Set SCROLLOCK indicator pin as output */
-  setPinOutput(B5);
-}
-
-bool process_record_user(uint16_t keycode, keyrecord_t *record) {
-  return process_record_keymap(keycode, record);
-}
-
-void led_set_user(uint8_t usb_led) {
-
-  if (IS_LED_ON(usb_led, USB_LED_NUM_LOCK)) {
-    writePinLow(C6);
-  }
-  else {
-    writePinHigh(C6);
-  }
-
-  if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) {
-    writePinLow(C7);
-  }
-  else {
-    writePinHigh(C7);
-  }
-
-  if (IS_LED_ON(usb_led, USB_LED_SCROLL_LOCK)) {
-    writePinLow(B5);
-  }
-  else {
-    writePinHigh(B5);
-  }
-
-  led_set_keymap(usb_led);
-}
diff --git a/keyboards/omnikeyish/config.h b/keyboards/omnikeyish/config.h
index d510c64c9b..1bce90526f 100644
--- a/keyboards/omnikeyish/config.h
+++ b/keyboards/omnikeyish/config.h
@@ -24,9 +24,9 @@
 #endif 
 #define MATRIX_COL_PINS { F0, F1, F2, F3, F4, F5, F6, F7, C7, C6, C5, C4, C3, C2, C1, C0, B0, B1, B2, B3, B4, B5, B6 }
 
-#define NUMLOCKLEDPIN E0
-#define CAPSLOCKLEDPIN E1
-#define SCROLLLOCKLEDPIN B7
+#define LED_NUM_LOCK_PIN E0
+#define LED_CAPS_LOCK_PIN E1
+#define LED_SCROLL_LOCK_PIN B7
 
 /* COL2ROW or ROW2COL */
 #define DIODE_DIRECTION ROW2COL
diff --git a/keyboards/omnikeyish/omnikeyish.c b/keyboards/omnikeyish/omnikeyish.c
index d7b68d41ab..9b8ce7b972 100644
--- a/keyboards/omnikeyish/omnikeyish.c
+++ b/keyboards/omnikeyish/omnikeyish.c
@@ -1,11 +1,6 @@
 #include "omnikeyish.h"
 
 void keyboard_pre_init_user(void) {
-  /* Configure LED driving pins as output pins */
-  setPinOutput(NUMLOCKLEDPIN);
-  setPinOutput(CAPSLOCKLEDPIN);
-  setPinOutput(SCROLLLOCKLEDPIN);
-
   dynamic_macro_init();
 }
 
@@ -33,23 +28,3 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
 
   return true;
 }
-
-void led_set_user(uint8_t usb_led) {
-  if (IS_LED_ON(usb_led, USB_LED_NUM_LOCK)) {
-    writePinHigh(NUMLOCKLEDPIN);
-  } else {
-    writePinLow(NUMLOCKLEDPIN);
-  }
-
-  if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) {
-    writePinHigh(CAPSLOCKLEDPIN);
-  } else {
-    writePinLow(CAPSLOCKLEDPIN);
-  }
-
-  if (IS_LED_ON(usb_led, USB_LED_SCROLL_LOCK)) {
-    writePinHigh(SCROLLLOCKLEDPIN);
-  } else {
-    writePinLow(SCROLLLOCKLEDPIN);
-  }
-}
\ No newline at end of file
diff --git a/keyboards/tkc/m0lly/config.h b/keyboards/tkc/m0lly/config.h
index 29bd8411e3..77480995c8 100644
--- a/keyboards/tkc/m0lly/config.h
+++ b/keyboards/tkc/m0lly/config.h
@@ -43,6 +43,10 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 /* COL2ROW or ROW2COL */
 #define DIODE_DIRECTION COL2ROW
 
+#define LED_NUM_LOCK_PIN D2
+#define LED_CAPS_LOCK_PIN D3
+#define LED_SCROLL_LOCK_PIN D4
+
 #define BACKLIGHT_PIN B6
 #define BACKLIGHT_BREATHING
 #define BACKLIGHT_LEVELS 3
diff --git a/keyboards/tkc/m0lly/m0lly.c b/keyboards/tkc/m0lly/m0lly.c
index e47f9531e1..e04407a35b 100644
--- a/keyboards/tkc/m0lly/m0lly.c
+++ b/keyboards/tkc/m0lly/m0lly.c
@@ -14,63 +14,13 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 #include "m0lly.h"
-#include "led.h"
 
 void keyboard_pre_init_kb(void) {
-  setPinInputHigh(D0);
-  setPinInputHigh(D1);
+    setPinInputHigh(D0);
+    setPinInputHigh(D1);
 
-  keyboard_pre_init_user();
+    setPinOutput(B7);
+    writePinHigh(B7);
+
+    keyboard_pre_init_user();
 }
-
-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) {
-	DDRD |= (1<<2) | (1<<3) | (1<<4); // OUT
-	DDRB |= (1<<7); // OUT
-	PORTB |= (1<<7);
-}
-
-void led_set_kb(uint8_t usb_led) {
-//    led_set_user(usb_led);
-	if (usb_led & (1<<USB_LED_NUM_LOCK)) {
-        // Turn numlock on
-		PORTD |= (1<<2);
-    } else {
-        // Turn numlock off
-	    PORTD &= ~(1<<2);
-    }
-	if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
-        // Turn capslock on
-		PORTD |= (1<<3);
-    } else {
-        // Turn capslock off
-		PORTD &= ~(1<<3);
-    }
-	if (usb_led & (1<<USB_LED_SCROLL_LOCK)) {
-        // Turn scrolllock on
-	    PORTD |= (1<<4);
-    } else {
-        // Turn scrolllock off
-		PORTD &= ~(1<<4);
-    }
-}
\ No newline at end of file
diff --git a/keyboards/tkc/tkc1800/config.h b/keyboards/tkc/tkc1800/config.h
index 9c35699c92..f54583c2b1 100644
--- a/keyboards/tkc/tkc1800/config.h
+++ b/keyboards/tkc/tkc1800/config.h
@@ -43,6 +43,10 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 /* COL2ROW or ROW2COL */
 #define DIODE_DIRECTION COL2ROW
 
+#define LED_NUM_LOCK_PIN D2
+#define LED_CAPS_LOCK_PIN D3
+#define LED_SCROLL_LOCK_PIN D4
+
 #define BACKLIGHT_PIN B6
 #define BACKLIGHT_BREATHING
 #define BACKLIGHT_LEVELS 3
diff --git a/keyboards/tkc/tkc1800/tkc1800.c b/keyboards/tkc/tkc1800/tkc1800.c
index 4232c97d54..08e4e0bb3b 100644
--- a/keyboards/tkc/tkc1800/tkc1800.c
+++ b/keyboards/tkc/tkc1800/tkc1800.c
@@ -14,63 +14,13 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 #include "tkc1800.h"
-#include "led.h"
 
 void keyboard_pre_init_kb(void) {
-  setPinInputHigh(D0);
-  setPinInputHigh(D1);
+    setPinInputHigh(D0);
+    setPinInputHigh(D1);
 
-  keyboard_pre_init_user();
+    setPinOutput(B7);
+    writePinHigh(B7);
+
+    keyboard_pre_init_user();
 }
-
-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) {
-	DDRD |= (1<<2) | (1<<3) | (1<<4); // OUT
-	DDRB |= (1<<7); // OUT
-	PORTB |= (1<<7);
-}
-
-void led_set_kb(uint8_t usb_led) {
-//    led_set_user(usb_led);
-	if (usb_led & (1<<USB_LED_NUM_LOCK)) {
-        // Turn numlock on
-		PORTD |= (1<<2);
-    } else {
-        // Turn numlock off
-	    PORTD &= ~(1<<2);
-    }
-	if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
-        // Turn capslock on
-		PORTD |= (1<<3);
-    } else {
-        // Turn capslock off
-		PORTD &= ~(1<<3);
-    }
-	if (usb_led & (1<<USB_LED_SCROLL_LOCK)) {
-        // Turn scrolllock on
-	    PORTD |= (1<<4);
-    } else {
-        // Turn scrolllock off
-		PORTD &= ~(1<<4);
-    }
-}
\ No newline at end of file
diff --git a/keyboards/xd84/config.h b/keyboards/xd84/config.h
index 2a77db68a4..503cba3187 100644
--- a/keyboards/xd84/config.h
+++ b/keyboards/xd84/config.h
@@ -47,6 +47,9 @@
 /* COL2ROW, ROW2COL */
 //#define DIODE_DIRECTION COL2ROW
 
+#define LED_CAPS_LOCK_PIN B6
+#define LED_PIN_ON_STATE 0
+
 #define BACKLIGHT_PIN B5
 #define BACKLIGHT_LEVELS 10
 // #define BACKLIGHT_BREATHING
diff --git a/keyboards/xd84/xd84.c b/keyboards/xd84/xd84.c
index eaf531421b..dec4ef95e2 100644
--- a/keyboards/xd84/xd84.c
+++ b/keyboards/xd84/xd84.c
@@ -14,19 +14,3 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 #include "xd84.h"
-
-void keyboard_pre_init_kb(void) {
-  setPinOutput(B6);
-
-  keyboard_pre_init_user();
-}
-
-void led_set_kb(uint8_t usb_led) {
-  if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) {
-    writePinLow(B6);
-  } else {
-    writePinHigh(B6);
-  }
-
-  led_set_user(usb_led);
-}
diff --git a/keyboards/xd84pro/config.h b/keyboards/xd84pro/config.h
index 7fd4496fe3..01f410ea6b 100644
--- a/keyboards/xd84pro/config.h
+++ b/keyboards/xd84pro/config.h
@@ -35,6 +35,9 @@
 
 #define DIODE_DIRECTION COL2ROW
 
+#define LED_CAPS_LOCK_PIN B2
+#define LED_PIN_ON_STATE 0
+
 #define RGB_DI_PIN F6
 #ifdef RGB_DI_PIN
     #define RGBLED_NUM 12
diff --git a/keyboards/xd84pro/xd84pro.c b/keyboards/xd84pro/xd84pro.c
index cba8a57f26..0eb52fda0f 100644
--- a/keyboards/xd84pro/xd84pro.c
+++ b/keyboards/xd84pro/xd84pro.c
@@ -14,17 +14,3 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 #include "xd84pro.h"
-
-void keyboard_pre_init_kb(void) {
-    led_init_ports();
-    keyboard_pre_init_user();
-}
-void led_init_ports(void) {
-    setPinOutput(B2);
-}
-bool led_update_kb(led_t led_state) {
-    if (led_update_user(led_state)) {
-        writePin(B2, !led_state.caps_lock);
-    }
-    return false;
-}
\ No newline at end of file
diff --git a/keyboards/xd96/config.h b/keyboards/xd96/config.h
index 799b835df0..cf6fec1b96 100644
--- a/keyboards/xd96/config.h
+++ b/keyboards/xd96/config.h
@@ -47,6 +47,10 @@
 /* COL2ROW, ROW2COL */
 //#define DIODE_DIRECTION COL2ROW
 
+#define LED_NUM_LOCK_PIN C6
+#define LED_CAPS_LOCK_PIN B6
+#define LED_PIN_ON_STATE 0
+
 #define BACKLIGHT_PIN B5
 #define BACKLIGHT_LEVELS 10
 // #define BACKLIGHT_BREATHING
diff --git a/keyboards/xd96/xd96.c b/keyboards/xd96/xd96.c
index e2af9f1004..2c67ee3d7c 100644
--- a/keyboards/xd96/xd96.c
+++ b/keyboards/xd96/xd96.c
@@ -14,29 +14,3 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 #include "xd96.h"
-
-#define CAPS_PIN B6
-#define NUMLOCK_PIN C6
-
-void keyboard_pre_init_kb(void) {
-  setPinOutput(CAPS_PIN);
-  setPinOutput(NUMLOCK_PIN);
-
-  keyboard_pre_init_user();
-}
-
-void led_set_kb(uint8_t usb_led) {
-  if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) {
-    writePinLow(CAPS_PIN);
-  } else {
-    writePinHigh(CAPS_PIN);
-  }
-  
-  if (IS_LED_ON(usb_led, USB_LED_NUM_LOCK)) {
-    writePinLow(NUMLOCK_PIN);
-  } else {
-    writePinHigh(NUMLOCK_PIN);
-  }
-
-  led_set_user(usb_led);
-}
diff --git a/keyboards/yd68/config.h b/keyboards/yd68/config.h
index 17461c5dc3..7b4a43bfde 100644
--- a/keyboards/yd68/config.h
+++ b/keyboards/yd68/config.h
@@ -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 D4
+#define LED_PIN_ON_STATE 0
+
 // #define BACKLIGHT_PIN B7
 // #define BACKLIGHT_BREATHING
 // #define BACKLIGHT_LEVELS 3
diff --git a/keyboards/yd68/yd68.c b/keyboards/yd68/yd68.c
index f34661dd37..22f75f7f81 100644
--- a/keyboards/yd68/yd68.c
+++ b/keyboards/yd68/yd68.c
@@ -15,59 +15,22 @@
  */
 #include "yd68.h"
 
-void matrix_init_kb(void) {
-	// put your keyboard start-up code here
-	// runs once when the firmware starts up
-	
-	//Capslock LED Output Low
-	DDRD |= (1<<4);
-    PORTD &= ~(1<<4);
-	
+void keyboard_pre_init_kb(void) {
 	//Backlight LEDs Output Low
-	DDRD |= (1<<6);
-    PORTD &= ~(1<<6);
+	setPinOutput(D6);
+	writePinLow(D6);
 	
 	//RGB power output low
-	DDRE |= (1<<2);
-    PORTE &= ~(1<<2);
+	setPinOutput(E2);
+	writePinLow(E2);
 	
 	//Bluetooth power output high
-	DDRB |= (1<<2);
-    PORTB |= (1<<2);
+	setPinOutput(B2);
+	writePinLow(B2);
 	
 	//RGB data output low
-	DDRB |= (1<<3);
-	PORTB &= ~(1<<3);
+	setPinOutput(B3);
+	writePinLow(B3);
 	
-	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 (usb_led & (1<<USB_LED_CAPS_LOCK)) {
-        // output low
-        DDRD |= (1<<4);
-        PORTD &= ~(1<<4);
-    } else {
-        // output high
-        DDRD |= (1<<4);
-        PORTD |= (1<<4);
-    }
-
-	led_set_user(usb_led);
+	keyboard_pre_init_user();
 }
diff --git a/keyboards/z150_bh/config.h b/keyboards/z150_bh/config.h
index fc33021ffc..9fa1f0c527 100644
--- a/keyboards/z150_bh/config.h
+++ b/keyboards/z150_bh/config.h
@@ -22,6 +22,10 @@
 /* COL2ROW or ROW2COL */
 #define DIODE_DIRECTION COL2ROW
 
+#define LED_NUM_LOCK_PIN E7
+#define LED_CAPS_LOCK_PIN B0
+#define LED_SCROLL_LOCK_PIN E6
+
 /* Set 0 if debouncing isn't needed */
 #define DEBOUNCE 5
 
diff --git a/keyboards/z150_bh/z150_bh.c b/keyboards/z150_bh/z150_bh.c
index 6db784b56e..b75a1ff198 100644
--- a/keyboards/z150_bh/z150_bh.c
+++ b/keyboards/z150_bh/z150_bh.c
@@ -1,32 +1 @@
 #include "z150_bh.h"
-
-void matrix_init_kb(void) {
-    setPinOutput(B0);
-    setPinOutput(E6);
-    setPinOutput(E7);
-
-    matrix_init_user();
-};
-
-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_NUM_LOCK)) {
-        writePinHigh(E7);
-    } else {
-        writePinLow(E7);
-    }
-
-    if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) {
-        writePinHigh(B0);
-    } else {
-        writePinLow(B0);
-    }
-
-    if (IS_LED_ON(usb_led, USB_LED_SCROLL_LOCK)) {
-        writePinHigh(E6);
-    } else {
-        writePinLow(E6);
-    }
-
-    led_set_user(usb_led);
-}