diff options
| author | Kenneth Aloysius <krusli@users.noreply.github.com> | 2018-06-01 01:32:05 +1000 |
|---|---|---|
| committer | Drashna Jaelre <drashna@live.com> | 2018-05-31 08:32:05 -0700 |
| commit | d27855665a349f9afe5c1b457461078f85cf6ffb (patch) | |
| tree | dfa82603c5ed7fea9227e9f6370644aa3003044a /keyboards/mechmini | |
| parent | ee9a7aba396160929604aca54a23ad5534d59940 (diff) | |
| download | qmk_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
Diffstat (limited to 'keyboards/mechmini')
| -rw-r--r-- | keyboards/mechmini/v1/matrix.c | 30 | ||||
| -rw-r--r-- | keyboards/mechmini/v1/v1.c | 52 |
2 files changed, 60 insertions, 22 deletions
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; | |||
| 29 | static matrix_row_t matrix[MATRIX_ROWS]; | 29 | static matrix_row_t matrix[MATRIX_ROWS]; |
| 30 | static matrix_row_t matrix_debouncing[MATRIX_ROWS]; | 30 | static matrix_row_t matrix_debouncing[MATRIX_ROWS]; |
| 31 | 31 | ||
| 32 | void matrix_set_row_status(uint8_t row); | ||
| 33 | uint8_t bit_reverse(uint8_t x); | ||
| 34 | |||
| 32 | void matrix_init(void) { | 35 | void 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 | |||
| 52 | void matrix_set_row_status(uint8_t row) { | ||
| 53 | DDRB = (1 << row); | ||
| 54 | PORTB = ~(1 << row); | ||
| 55 | } | ||
| 56 | 53 | ||
| 57 | uint8_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 | ||
| 64 | uint8_t matrix_scan(void) { | 57 | uint8_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 | ||
| 95 | void matrix_set_row_status(uint8_t row) { | ||
| 96 | DDRB = (1 << row); | ||
| 97 | PORTB = ~(1 << row); | ||
| 98 | } | ||
| 99 | |||
| 100 | uint8_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 | |||
| 101 | inline matrix_row_t matrix_get_row(uint8_t row) { | 107 | inline 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 | ||
| 27 | void matrix_init_kb(void) { | ||
| 28 | // call user level keymaps, if any | ||
| 29 | matrix_init_user(); | ||
| 30 | } | ||
| 31 | |||
| 32 | #ifdef RGBLIGHT_ENABLE | ||
| 26 | extern rgblight_config_t rgblight_config; | 33 | extern rgblight_config_t rgblight_config; |
| 34 | |||
| 35 | // custom RGB driver | ||
| 27 | void rgblight_set(void) { | 36 | void 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 | ||
| 49 | bool rgb_init = false; | ||
| 50 | |||
| 51 | void 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 | ||
| 61 | void 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 |
| 68 | void matrix_init_user(void) { | ||
| 69 | |||
| 70 | } | ||
| 71 | |||
| 72 | |||
| 73 | __attribute__((weak)) // overridable | ||
| 41 | void matrix_scan_user(void) { | 74 | void matrix_scan_user(void) { |
| 42 | rgblight_task(); | 75 | |
| 43 | /* add other tasks to be done on each matrix scan */ | ||
| 44 | } | 76 | } |
