Skip to content

Commit

Permalink
Fix YMDK NP21 keyboard to use proper keyboard level functions (#3042)
Browse files Browse the repository at this point in the history
* Use proper function levels

* Add matrix init functions

* Convert KEYMAP to LAYOUT

Or @mechmerlin is going to hunt me down and harm me... probably :)

* Fix conflict issues
  • Loading branch information
drashna authored and jackhumbert committed Oct 1, 2018
1 parent 9d94938 commit 3907ed0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
7 changes: 3 additions & 4 deletions keyboards/ymdk_np21/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "ymdk_np21.h"
#include "action_layer.h"
#include QMK_KEYBOARD_H

#define _NP 0
#define _BL 1
Expand All @@ -21,7 +20,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* | Enter| Enter| + | + | - | FN |
* `-----------------------------------------'
*/
[_NP] = KEYMAP( \
[_NP] = LAYOUT( \
KC_KP_0, KC_KP_1, KC_KP_4, KC_KP_7, KC_NUMLOCK, KC_ESC, \
KC_DOT, KC_KP_2, KC_KP_5, KC_KP_8, KC_KP_SLASH, KC_TAB, \
KC_KP_DOT, KC_KP_3, KC_KP_6, KC_KP_9, KC_KP_ASTERISK, KC_BSPACE, \
Expand All @@ -38,7 +37,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* | BL_DEC | BL_DEC | BL_INC | BL_INC | | |
* `---------------------------------------------'
*/
[_BL] = KEYMAP( \
[_BL] = LAYOUT( \
BL_BRTG, _______, _______, _______, _______, _______, \
_______, BL_OFF, BL_TOGG, BL_ON, _______, _______, \
_______, _______, _______, _______, _______, _______, \
Expand Down
11 changes: 11 additions & 0 deletions keyboards/ymdk_np21/matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,23 @@ uint8_t matrix_scan(void) {
return 1;
}

__attribute__ ((weak))
void matrix_scan_user(void) {};

__attribute__ ((weak))
void matrix_scan_kb(void) {
// Looping keyboard code goes here
// This runs every cycle (a lot)
matrix_scan_user();
};

__attribute__ ((weak))
void matrix_init_user(void) {};

__attribute__ ((weak))
void matrix_init_kb(void) {
matrix_init_user();
}
// declarations
void matrix_set_row_status(uint8_t row) {
DDRB = (1 << row);
Expand Down
6 changes: 4 additions & 2 deletions keyboards/ymdk_np21/ymdk_np21.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extern rgblight_config_t rgblight_config;
// @Override
void matrix_init_kb(void) {
// call user level keymaps, if any
// matrix_init_user();
matrix_init_user();
}

#ifdef BACKLIGHT_ENABLE
Expand Down Expand Up @@ -67,7 +67,7 @@ void rgblight_set(void) {
}

bool rgb_init = false;
void matrix_scan_user(void) {
void matrix_scan_kb(void) {
// if LEDs were previously on before poweroff, turn them back on
if (rgb_init == false && rgblight_config.enable) {
i2c_init();
Expand All @@ -77,4 +77,6 @@ void matrix_scan_user(void) {

rgblight_task();
/* Nothing else for now. */

matrix_scan_user();
}
4 changes: 1 addition & 3 deletions keyboards/ymdk_np21/ymdk_np21.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

void matrix_init_user(void); // TODO port this to other PS2AVRGB boards

#define KEYMAP_GRID( \
#define LAYOUT( \
K01, K02, K03, K04, K05, K06, \
K11, K12, K13, K14, K15, K16, \
K21, K22, K23, K24, K25, K26, \
Expand All @@ -38,6 +38,4 @@ void matrix_init_user(void); // TODO port this to other PS2AVRGB boards
{ K36, K35, K34, K33, K32, K31 } \
}

#define KEYMAP KEYMAP_GRID

#endif

0 comments on commit 3907ed0

Please sign in to comment.