aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Aloysius <krusli@users.noreply.github.com>2018-06-01 01:32:05 +1000
committerDrashna Jaelre <drashna@live.com>2018-05-31 08:32:05 -0700
commitd27855665a349f9afe5c1b457461078f85cf6ffb (patch)
treedfa82603c5ed7fea9227e9f6370644aa3003044a
parentee9a7aba396160929604aca54a23ad5534d59940 (diff)
downloadqmk_firmware-d27855665a349f9afe5c1b457461078f85cf6ffb.tar.gz
qmk_firmware-d27855665a349f9afe5c1b457461078f85cf6ffb.zip
Updated matrix.c for some PS2AVRGB boards and templates for new_project script (#2992)
* Add M6-A keymap * Update XD60 keymap * Update XD60 keymap readme * Update JJ40 and Let's Split keymaps * Add readme for M6-A * Fix typo, update JJ40 README * Update jj40 readme * Cleanup jj40 keymap * Revert Let's Split QWERTY layer to default before #2010 * Update numpad layers * Fix: Let's Split keymap getting stuck mods due to having keycodes assigned on the Raise layer * Keep ASCII art consistent with keymap * Staryu: initial port * Add personal keymap * Added and updated READMEs * Fix: default keymap for staryu * Rudimentary backlight support. * Enabled mousekeys for default keymap * use QMK_KEYBOARD_H and LAYOUT * Update readme.md for NIU mini: flash using avrdude * Fix missing linebreaks for Staryu README * Update readme.md * Update PS2AVRGB boards with new matrix.c * Update canoe matrix.c; untested * Fix canoe.c for building (needs matrix_scan_user and matrix_init_user) * Add personal Iris keymap * Update keymap * Update keymap * Update keymap, disable backlighting and underglow * Move PrintScreen button * Add README
-rw-r--r--keyboards/canoe/canoe.c49
-rw-r--r--keyboards/canoe/matrix.c32
-rw-r--r--keyboards/iris/keymaps/krusli/README.md2
-rw-r--r--keyboards/iris/keymaps/krusli/config.h43
-rw-r--r--keyboards/iris/keymaps/krusli/keymap.c98
-rw-r--r--keyboards/iris/keymaps/krusli/rules.mk6
-rw-r--r--keyboards/jj40/matrix.c4
-rw-r--r--keyboards/mechmini/v1/matrix.c30
-rw-r--r--keyboards/mechmini/v1/v1.c52
-rw-r--r--keyboards/ps2avrGB/matrix.c32
-rw-r--r--keyboards/ps2avrGB/ps2avrGB.c49
-rw-r--r--quantum/template/ps2avrgb/matrix.c32
12 files changed, 349 insertions, 80 deletions
diff --git a/keyboards/canoe/canoe.c b/keyboards/canoe/canoe.c
index bc69df2e5..a7427e152 100644
--- a/keyboards/canoe/canoe.c
+++ b/keyboards/canoe/canoe.c
@@ -42,24 +42,55 @@ void backlight_init_ports(void) {
42 42
43#endif 43#endif
44 44
45// for keyboard subdirectory level init functions
46// @Override
47void matrix_init_kb(void) {
48 // call user level keymaps, if any
49 matrix_init_user();
50}
51
45#ifdef RGBLIGHT_ENABLE 52#ifdef RGBLIGHT_ENABLE
46extern rgblight_config_t rgblight_config; 53extern rgblight_config_t rgblight_config;
47 54
55// custom RGB driver
48void rgblight_set(void) { 56void rgblight_set(void) {
49 if (!rgblight_config.enable) { 57 if (!rgblight_config.enable) {
50 for (uint8_t i = 0; i < RGBLED_NUM; i++) { 58 for (uint8_t i=0; i<RGBLED_NUM; i++) {
51 led[i].r = 0; 59 led[i].r = 0;
52 led[i].g = 0; 60 led[i].g = 0;
53 led[i].b = 0; 61 led[i].b = 0;
54 }
55 } 62 }
63 }
64
65 i2c_init();
66 i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
67}
56 68
69bool rgb_init = false;
70
71void matrix_scan_kb(void) {
72 // if LEDs were previously on before poweroff, turn them back on
73 if (rgb_init == false && rgblight_config.enable) {
57 i2c_init(); 74 i2c_init();
58 i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM); 75 i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
76 rgb_init = true;
77 }
78
79 rgblight_task();
80#else
81void matrix_scan_kb(void) {
82#endif
83 matrix_scan_user();
84 /* Nothing else for now. */
59} 85}
60 86
61__attribute__ ((weak)) 87__attribute__((weak)) // overridable
88void matrix_init_user(void) {
89
90}
91
92
93__attribute__((weak)) // overridable
62void matrix_scan_user(void) { 94void matrix_scan_user(void) {
63 rgblight_task(); 95
64} 96}
65#endif
diff --git a/keyboards/canoe/matrix.c b/keyboards/canoe/matrix.c
index 57aa36b5f..245813dfd 100644
--- a/keyboards/canoe/matrix.c
+++ b/keyboards/canoe/matrix.c
@@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
21#include "matrix.h" 21#include "matrix.h"
22 22
23#ifndef DEBOUNCE 23#ifndef DEBOUNCE
24#define DEBOUNCE 5 24# define DEBOUNCE 5
25#endif 25#endif
26 26
27static uint8_t debouncing = DEBOUNCE; 27static uint8_t debouncing = DEBOUNCE;
@@ -29,6 +29,9 @@ static uint8_t debouncing = DEBOUNCE;
29static matrix_row_t matrix[MATRIX_ROWS]; 29static matrix_row_t matrix[MATRIX_ROWS];
30static matrix_row_t matrix_debouncing[MATRIX_ROWS]; 30static matrix_row_t matrix_debouncing[MATRIX_ROWS];
31 31
32void matrix_set_row_status(uint8_t row);
33uint8_t bit_reverse(uint8_t x);
34
32void matrix_init(void) { 35void matrix_init(void) {
33 // all outputs for rows high 36 // all outputs for rows high
34 DDRB = 0xFF; 37 DDRB = 0xFF;
@@ -47,18 +50,8 @@ void matrix_init(void) {
47 matrix[row] = 0x00; 50 matrix[row] = 0x00;
48 matrix_debouncing[row] = 0x00; 51 matrix_debouncing[row] = 0x00;
49 } 52 }
50}
51
52void matrix_set_row_status(uint8_t row) {
53 DDRB = (1 << row);
54 PORTB = ~(1 << row);
55}
56 53
57uint8_t bit_reverse(uint8_t x) { 54 matrix_init_quantum();
58 x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa);
59 x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
60 x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0);
61 return x;
62} 55}
63 56
64uint8_t matrix_scan(void) { 57uint8_t matrix_scan(void) {
@@ -93,11 +86,24 @@ uint8_t matrix_scan(void) {
93 } 86 }
94 } 87 }
95 88
96 matrix_scan_user(); 89 matrix_scan_quantum();
97 90
98 return 1; 91 return 1;
99} 92}
100 93
94// declarations
95void matrix_set_row_status(uint8_t row) {
96 DDRB = (1 << row);
97 PORTB = ~(1 << row);
98}
99
100uint8_t bit_reverse(uint8_t x) {
101 x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa);
102 x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
103 x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0);
104 return x;
105}
106
101inline matrix_row_t matrix_get_row(uint8_t row) { 107inline matrix_row_t matrix_get_row(uint8_t row) {
102 return matrix[row]; 108 return matrix[row];
103} 109}
diff --git a/keyboards/iris/keymaps/krusli/README.md b/keyboards/iris/keymaps/krusli/README.md
new file mode 100644
index 000000000..fc02aa01c
--- /dev/null
+++ b/keyboards/iris/keymaps/krusli/README.md
@@ -0,0 +1,2 @@
1# krusli's Iris keymap
2Based off the default and Planck keymaps.
diff --git a/keyboards/iris/keymaps/krusli/config.h b/keyboards/iris/keymaps/krusli/config.h
new file mode 100644
index 000000000..a53c746ad
--- /dev/null
+++ b/keyboards/iris/keymaps/krusli/config.h
@@ -0,0 +1,43 @@
1/*
2Copyright 2017 Danny Nguyen <danny@keeb.io>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#ifndef CONFIG_USER_H
19#define CONFIG_USER_H
20
21#include "config_common.h"
22
23// #define PREVENT_STUCK_MODIFIERS
24
25/* Use I2C or Serial, not both */
26
27#define USE_SERIAL
28// #define USE_I2C
29
30/* Select hand configuration */
31
32#define MASTER_LEFT
33// #define MASTER_RIGHT
34// #define EE_HANDS
35
36#undef RGBLED_NUM
37#define RGBLIGHT_ANIMATIONS
38#define RGBLED_NUM 12
39#define RGBLIGHT_HUE_STEP 8
40#define RGBLIGHT_SAT_STEP 8
41#define RGBLIGHT_VAL_STEP 8
42
43#endif
diff --git a/keyboards/iris/keymaps/krusli/keymap.c b/keyboards/iris/keymaps/krusli/keymap.c
new file mode 100644
index 000000000..4aa076ab1
--- /dev/null
+++ b/keyboards/iris/keymaps/krusli/keymap.c
@@ -0,0 +1,98 @@
1#include "iris.h"
2#include "action_layer.h"
3#include "eeconfig.h"
4
5extern keymap_config_t keymap_config;
6
7#define _QWERTY 0
8#define _LOWER 1
9#define _RAISE 2
10#define _ADJUST 16
11
12enum custom_keycodes {
13 QWERTY = SAFE_RANGE,
14 LOWER,
15 RAISE,
16 ADJUST,
17};
18
19#define _______ KC_TRNS
20
21const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
22 [_QWERTY] = LAYOUT(
23 KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSLS,
24 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
25 KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
26 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_HOME, KC_END, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT,
27 KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LALT
28 ),
29
30 [_LOWER] = LAYOUT(
31 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_PSCR,
32 KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC,
33 _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE,
34 _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, _______, _______, KC_F12, _______, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT,
35 _______, _______, _______, _______, _______, _______
36 ),
37
38 [_RAISE] = LAYOUT(
39 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_PSCR,
40 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC,
41 _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS,
42 _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, _______, _______, KC_F12, _______, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT,
43 _______, _______, _______, _______, _______, _______
44 ),
45
46 [_ADJUST] = LAYOUT(
47 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
48 RGB_TOG, RGB_MOD, RGB_HUI, RGB_SAI, RGB_VAI, _______, _______, _______, _______, _______, _______, _______,
49 _______, _______, RGB_HUD, RGB_SAD, RGB_SAD, RGB_VAD, _______, _______, _______, _______, _______, _______,
50 BL_STEP, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
51 _______, _______, _______, _______, _______, _______
52 ),
53};
54
55void persistent_default_layer_set(uint16_t default_layer) {
56 eeconfig_update_default_layer(default_layer);
57 default_layer_set(default_layer);
58}
59
60bool process_record_user(uint16_t keycode, keyrecord_t *record) {
61 switch (keycode) {
62 case QWERTY:
63 if (record->event.pressed) {
64 persistent_default_layer_set(1UL<<_QWERTY);
65 }
66 return false;
67 break;
68 case LOWER:
69 if (record->event.pressed) {
70 layer_on(_LOWER);
71 update_tri_layer(_LOWER, _RAISE, _ADJUST);
72 } else {
73 layer_off(_LOWER);
74 update_tri_layer(_LOWER, _RAISE, _ADJUST);
75 }
76 return false;
77 break;
78 case RAISE:
79 if (record->event.pressed) {
80 layer_on(_RAISE);
81 update_tri_layer(_LOWER, _RAISE, _ADJUST);
82 } else {
83 layer_off(_RAISE);
84 update_tri_layer(_LOWER, _RAISE, _ADJUST);
85 }
86 return false;
87 break;
88 case ADJUST:
89 if (record->event.pressed) {
90 layer_on(_ADJUST);
91 } else {
92 layer_off(_ADJUST);
93 }
94 return false;
95 break;
96 }
97 return true;
98}
diff --git a/keyboards/iris/keymaps/krusli/rules.mk b/keyboards/iris/keymaps/krusli/rules.mk
new file mode 100644
index 000000000..c5e16f136
--- /dev/null
+++ b/keyboards/iris/keymaps/krusli/rules.mk
@@ -0,0 +1,6 @@
1RGBLIGHT_ENABLE = no
2BACKLIGHT_ENABLE = no
3
4ifndef QUANTUM_DIR
5 include ../../../../Makefile
6endif
diff --git a/keyboards/jj40/matrix.c b/keyboards/jj40/matrix.c
index 2932976dd..245813dfd 100644
--- a/keyboards/jj40/matrix.c
+++ b/keyboards/jj40/matrix.c
@@ -51,7 +51,7 @@ void matrix_init(void) {
51 matrix_debouncing[row] = 0x00; 51 matrix_debouncing[row] = 0x00;
52 } 52 }
53 53
54 matrix_init_quantum(); // missing from original port by Luiz 54 matrix_init_quantum();
55} 55}
56 56
57uint8_t matrix_scan(void) { 57uint8_t matrix_scan(void) {
@@ -86,7 +86,7 @@ uint8_t matrix_scan(void) {
86 } 86 }
87 } 87 }
88 88
89 matrix_scan_quantum(); // also missing in original PS2AVRGB implementation 89 matrix_scan_quantum();
90 90
91 return 1; 91 return 1;
92} 92}
diff --git a/keyboards/mechmini/v1/matrix.c b/keyboards/mechmini/v1/matrix.c
index 140026013..245813dfd 100644
--- a/keyboards/mechmini/v1/matrix.c
+++ b/keyboards/mechmini/v1/matrix.c
@@ -29,6 +29,9 @@ static uint8_t debouncing = DEBOUNCE;
29static matrix_row_t matrix[MATRIX_ROWS]; 29static matrix_row_t matrix[MATRIX_ROWS];
30static matrix_row_t matrix_debouncing[MATRIX_ROWS]; 30static matrix_row_t matrix_debouncing[MATRIX_ROWS];
31 31
32void matrix_set_row_status(uint8_t row);
33uint8_t bit_reverse(uint8_t x);
34
32void matrix_init(void) { 35void matrix_init(void) {
33 // all outputs for rows high 36 // all outputs for rows high
34 DDRB = 0xFF; 37 DDRB = 0xFF;
@@ -47,18 +50,8 @@ void matrix_init(void) {
47 matrix[row] = 0x00; 50 matrix[row] = 0x00;
48 matrix_debouncing[row] = 0x00; 51 matrix_debouncing[row] = 0x00;
49 } 52 }
50}
51
52void matrix_set_row_status(uint8_t row) {
53 DDRB = (1 << row);
54 PORTB = ~(1 << row);
55}
56 53
57uint8_t bit_reverse(uint8_t x) { 54 matrix_init_quantum();
58 x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa);
59 x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
60 x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0);
61 return x;
62} 55}
63 56
64uint8_t matrix_scan(void) { 57uint8_t matrix_scan(void) {
@@ -93,11 +86,24 @@ uint8_t matrix_scan(void) {
93 } 86 }
94 } 87 }
95 88
96 matrix_scan_user(); 89 matrix_scan_quantum();
97 90
98 return 1; 91 return 1;
99} 92}
100 93
94// declarations
95void matrix_set_row_status(uint8_t row) {
96 DDRB = (1 << row);
97 PORTB = ~(1 << row);
98}
99
100uint8_t bit_reverse(uint8_t x) {
101 x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa);
102 x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
103 x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0);
104 return x;
105}
106
101inline matrix_row_t matrix_get_row(uint8_t row) { 107inline matrix_row_t matrix_get_row(uint8_t row) {
102 return matrix[row]; 108 return matrix[row];
103} 109}
diff --git a/keyboards/mechmini/v1/v1.c b/keyboards/mechmini/v1/v1.c
index 24c74c6cf..508d60c78 100644
--- a/keyboards/mechmini/v1/v1.c
+++ b/keyboards/mechmini/v1/v1.c
@@ -22,23 +22,55 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
22#include "quantum.h" 22#include "quantum.h"
23#include "rgblight.h" 23#include "rgblight.h"
24 24
25// custom RGB driver 25// for keyboard subdirectory level init functions
26// @Override
27void matrix_init_kb(void) {
28 // call user level keymaps, if any
29 matrix_init_user();
30}
31
32#ifdef RGBLIGHT_ENABLE
26extern rgblight_config_t rgblight_config; 33extern rgblight_config_t rgblight_config;
34
35// custom RGB driver
27void rgblight_set(void) { 36void rgblight_set(void) {
28 if (!rgblight_config.enable) { 37 if (!rgblight_config.enable) {
29 for (uint8_t i = 0; i < RGBLED_NUM; i++) { 38 for (uint8_t i=0; i<RGBLED_NUM; i++) {
30 led[i].r = 0; 39 led[i].r = 0;
31 led[i].g = 0; 40 led[i].g = 0;
32 led[i].b = 0; 41 led[i].b = 0;
33 }
34 } 42 }
43 }
44
45 i2c_init();
46 i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
47}
35 48
49bool rgb_init = false;
50
51void matrix_scan_kb(void) {
52 // if LEDs were previously on before poweroff, turn them back on
53 if (rgb_init == false && rgblight_config.enable) {
36 i2c_init(); 54 i2c_init();
37 i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM); 55 i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
56 rgb_init = true;
57 }
58
59 rgblight_task();
60#else
61void matrix_scan_kb(void) {
62#endif
63 matrix_scan_user();
64 /* Nothing else for now. */
38} 65}
39 66
40__attribute__ ((weak)) 67__attribute__((weak)) // overridable
68void matrix_init_user(void) {
69
70}
71
72
73__attribute__((weak)) // overridable
41void matrix_scan_user(void) { 74void matrix_scan_user(void) {
42 rgblight_task(); 75
43 /* add other tasks to be done on each matrix scan */
44} 76}
diff --git a/keyboards/ps2avrGB/matrix.c b/keyboards/ps2avrGB/matrix.c
index 57aa36b5f..245813dfd 100644
--- a/keyboards/ps2avrGB/matrix.c
+++ b/keyboards/ps2avrGB/matrix.c
@@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
21#include "matrix.h" 21#include "matrix.h"
22 22
23#ifndef DEBOUNCE 23#ifndef DEBOUNCE
24#define DEBOUNCE 5 24# define DEBOUNCE 5
25#endif 25#endif
26 26
27static uint8_t debouncing = DEBOUNCE; 27static uint8_t debouncing = DEBOUNCE;
@@ -29,6 +29,9 @@ static uint8_t debouncing = DEBOUNCE;
29static matrix_row_t matrix[MATRIX_ROWS]; 29static matrix_row_t matrix[MATRIX_ROWS];
30static matrix_row_t matrix_debouncing[MATRIX_ROWS]; 30static matrix_row_t matrix_debouncing[MATRIX_ROWS];
31 31
32void matrix_set_row_status(uint8_t row);
33uint8_t bit_reverse(uint8_t x);
34
32void matrix_init(void) { 35void matrix_init(void) {
33 // all outputs for rows high 36 // all outputs for rows high
34 DDRB = 0xFF; 37 DDRB = 0xFF;
@@ -47,18 +50,8 @@ void matrix_init(void) {
47 matrix[row] = 0x00; 50 matrix[row] = 0x00;
48 matrix_debouncing[row] = 0x00; 51 matrix_debouncing[row] = 0x00;
49 } 52 }
50}
51
52void matrix_set_row_status(uint8_t row) {
53 DDRB = (1 << row);
54 PORTB = ~(1 << row);
55}
56 53
57uint8_t bit_reverse(uint8_t x) { 54 matrix_init_quantum();
58 x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa);
59 x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
60 x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0);
61 return x;
62} 55}
63 56
64uint8_t matrix_scan(void) { 57uint8_t matrix_scan(void) {
@@ -93,11 +86,24 @@ uint8_t matrix_scan(void) {
93 } 86 }
94 } 87 }
95 88
96 matrix_scan_user(); 89 matrix_scan_quantum();
97 90
98 return 1; 91 return 1;
99} 92}
100 93
94// declarations
95void matrix_set_row_status(uint8_t row) {
96 DDRB = (1 << row);
97 PORTB = ~(1 << row);
98}
99
100uint8_t bit_reverse(uint8_t x) {
101 x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa);
102 x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
103 x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0);
104 return x;
105}
106
101inline matrix_row_t matrix_get_row(uint8_t row) { 107inline matrix_row_t matrix_get_row(uint8_t row) {
102 return matrix[row]; 108 return matrix[row];
103} 109}
diff --git a/keyboards/ps2avrGB/ps2avrGB.c b/keyboards/ps2avrGB/ps2avrGB.c
index 701c5847f..45ba37bff 100644
--- a/keyboards/ps2avrGB/ps2avrGB.c
+++ b/keyboards/ps2avrGB/ps2avrGB.c
@@ -24,22 +24,55 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
24#include "i2c.h" 24#include "i2c.h"
25#include "quantum.h" 25#include "quantum.h"
26 26
27// for keyboard subdirectory level init functions
28// @Override
29void matrix_init_kb(void) {
30 // call user level keymaps, if any
31 matrix_init_user();
32}
33
34#ifdef RGBLIGHT_ENABLE
27extern rgblight_config_t rgblight_config; 35extern rgblight_config_t rgblight_config;
28 36
37// custom RGB driver
29void rgblight_set(void) { 38void rgblight_set(void) {
30 if (!rgblight_config.enable) { 39 if (!rgblight_config.enable) {
31 for (uint8_t i = 0; i < RGBLED_NUM; i++) { 40 for (uint8_t i=0; i<RGBLED_NUM; i++) {
32 led[i].r = 0; 41 led[i].r = 0;
33 led[i].g = 0; 42 led[i].g = 0;
34 led[i].b = 0; 43 led[i].b = 0;
35 }
36 } 44 }
45 }
46
47 i2c_init();
48 i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
49}
50
51bool rgb_init = false;
37 52
53void matrix_scan_kb(void) {
54 // if LEDs were previously on before poweroff, turn them back on
55 if (rgb_init == false && rgblight_config.enable) {
38 i2c_init(); 56 i2c_init();
39 i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM); 57 i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
58 rgb_init = true;
59 }
60
61 rgblight_task();
62#else
63void matrix_scan_kb(void) {
64#endif
65 matrix_scan_user();
66 /* Nothing else for now. */
40} 67}
41 68
42__attribute__ ((weak)) 69__attribute__((weak)) // overridable
70void matrix_init_user(void) {
71
72}
73
74
75__attribute__((weak)) // overridable
43void matrix_scan_user(void) { 76void matrix_scan_user(void) {
44 rgblight_task(); 77
45} 78}
diff --git a/quantum/template/ps2avrgb/matrix.c b/quantum/template/ps2avrgb/matrix.c
index 57aa36b5f..245813dfd 100644
--- a/quantum/template/ps2avrgb/matrix.c
+++ b/quantum/template/ps2avrgb/matrix.c
@@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
21#include "matrix.h" 21#include "matrix.h"
22 22
23#ifndef DEBOUNCE 23#ifndef DEBOUNCE
24#define DEBOUNCE 5 24# define DEBOUNCE 5
25#endif 25#endif
26 26
27static uint8_t debouncing = DEBOUNCE; 27static uint8_t debouncing = DEBOUNCE;
@@ -29,6 +29,9 @@ static uint8_t debouncing = DEBOUNCE;
29static matrix_row_t matrix[MATRIX_ROWS]; 29static matrix_row_t matrix[MATRIX_ROWS];
30static matrix_row_t matrix_debouncing[MATRIX_ROWS]; 30static matrix_row_t matrix_debouncing[MATRIX_ROWS];
31 31
32void matrix_set_row_status(uint8_t row);
33uint8_t bit_reverse(uint8_t x);
34
32void matrix_init(void) { 35void matrix_init(void) {
33 // all outputs for rows high 36 // all outputs for rows high
34 DDRB = 0xFF; 37 DDRB = 0xFF;
@@ -47,18 +50,8 @@ void matrix_init(void) {
47 matrix[row] = 0x00; 50 matrix[row] = 0x00;
48 matrix_debouncing[row] = 0x00; 51 matrix_debouncing[row] = 0x00;
49 } 52 }
50}
51
52void matrix_set_row_status(uint8_t row) {
53 DDRB = (1 << row);
54 PORTB = ~(1 << row);
55}
56 53
57uint8_t bit_reverse(uint8_t x) { 54 matrix_init_quantum();
58 x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa);
59 x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
60 x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0);
61 return x;
62} 55}
63 56
64uint8_t matrix_scan(void) { 57uint8_t matrix_scan(void) {
@@ -93,11 +86,24 @@ uint8_t matrix_scan(void) {
93 } 86 }
94 } 87 }
95 88
96 matrix_scan_user(); 89 matrix_scan_quantum();
97 90
98 return 1; 91 return 1;
99} 92}
100 93
94// declarations
95void matrix_set_row_status(uint8_t row) {
96 DDRB = (1 << row);
97 PORTB = ~(1 << row);
98}
99
100uint8_t bit_reverse(uint8_t x) {
101 x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa);
102 x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
103 x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0);
104 return x;
105}
106
101inline matrix_row_t matrix_get_row(uint8_t row) { 107inline matrix_row_t matrix_get_row(uint8_t row) {
102 return matrix[row]; 108 return matrix[row];
103} 109}