aboutsummaryrefslogtreecommitdiff
path: root/keyboards/jj50
diff options
context:
space:
mode:
authorfauxpark <fauxpark@gmail.com>2020-01-02 17:45:41 +1100
committerGitHub <noreply@github.com>2020-01-02 17:45:41 +1100
commit2557bc8e6f6e61352fa5875646d861126c42a3b0 (patch)
tree40ef2cb1a51c31a2eaa9d43414a7e88c83181dd2 /keyboards/jj50
parentb83e3ae556239b4aa6f2c4db20535c536692eb3b (diff)
downloadqmk_firmware-2557bc8e6f6e61352fa5875646d861126c42a3b0.tar.gz
qmk_firmware-2557bc8e6f6e61352fa5875646d861126c42a3b0.zip
Remove custom matrix from PS2AVRGB boards (#7396)
* Remove custom matrix from PS2AVRGB boards * Add custom backlight.c to SRC for bminiex, for now * Add missing DIODE_DIRECTIONs
Diffstat (limited to 'keyboards/jj50')
-rw-r--r--keyboards/jj50/config.h8
-rw-r--r--keyboards/jj50/jj50.c10
-rw-r--r--keyboards/jj50/jj50.h2
-rw-r--r--keyboards/jj50/matrix.c107
-rw-r--r--keyboards/jj50/rules.mk4
5 files changed, 6 insertions, 125 deletions
diff --git a/keyboards/jj50/config.h b/keyboards/jj50/config.h
index dfd8a4a8f..884a28d50 100644
--- a/keyboards/jj50/config.h
+++ b/keyboards/jj50/config.h
@@ -32,9 +32,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
32#define DESCRIPTION Preonic-like clone 32#define DESCRIPTION Preonic-like clone
33 33
34/* matrix size */ 34/* matrix size */
35#define MATRIX_ROWS 8 35#define MATRIX_ROWS 5
36#define MATRIX_COLS 15 36#define MATRIX_COLS 12
37#define DIODE_DIRECTION ROW2COL 37#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4 }
38#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4 }
39#define DIODE_DIRECTION COL2ROW
38 40
39//#define BACKLIGHT_PIN D4 41//#define BACKLIGHT_PIN D4
40#define BACKLIGHT_LEVELS 12 42#define BACKLIGHT_LEVELS 12
diff --git a/keyboards/jj50/jj50.c b/keyboards/jj50/jj50.c
index 7c3cee95d..a302adf40 100644
--- a/keyboards/jj50/jj50.c
+++ b/keyboards/jj50/jj50.c
@@ -20,16 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
20#include "backlight.h" 20#include "backlight.h"
21#include "backlight_custom.h" 21#include "backlight_custom.h"
22 22
23void matrix_init_kb(void) { matrix_init_user(); }
24
25__attribute__ ((weak))
26void matrix_init_user(void) {}
27
28void matrix_scan_kb(void) { matrix_scan_user(); }
29
30__attribute__ ((weak))
31void matrix_scan_user(void) {}
32
33#ifdef BACKLIGHT_ENABLE 23#ifdef BACKLIGHT_ENABLE
34void backlight_init_ports(void) { 24void backlight_init_ports(void) {
35 b_led_init_ports(); 25 b_led_init_ports();
diff --git a/keyboards/jj50/jj50.h b/keyboards/jj50/jj50.h
index 8a904897e..6b1c7eacf 100644
--- a/keyboards/jj50/jj50.h
+++ b/keyboards/jj50/jj50.h
@@ -25,8 +25,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
25#include "keycode.h" 25#include "keycode.h"
26#include "action.h" 26#include "action.h"
27 27
28void matrix_init_user(void);
29
30#define LAYOUT_ortho_5x12( \ 28#define LAYOUT_ortho_5x12( \
31 K011, K010, K009, K008, K004, K005, K006, K007, K003, K002, K201, K000, \ 29 K011, K010, K009, K008, K004, K005, K006, K007, K003, K002, K201, K000, \
32 K111, K110, K109, K108, K104, K105, K106, K107, K103, K102, K001, K100, \ 30 K111, K110, K109, K108, K104, K105, K106, K107, K103, K102, K001, K100, \
diff --git a/keyboards/jj50/matrix.c b/keyboards/jj50/matrix.c
deleted file mode 100644
index 95c6057e7..000000000
--- a/keyboards/jj50/matrix.c
+++ /dev/null
@@ -1,107 +0,0 @@
1/*
2Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
3Modified 2018 by Wayne K Jones <github.com/WarmCatUK>
4
5This program is free software: you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by
7the Free Software Foundation, either version 2 of the License, or
8(at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#include <avr/io.h>
20#include <util/delay.h>
21
22#include "matrix.h"
23
24#ifndef DEBOUNCE
25# define DEBOUNCE 5
26#endif
27
28static uint8_t debouncing = DEBOUNCE;
29
30static matrix_row_t matrix[MATRIX_ROWS];
31static matrix_row_t matrix_debouncing[MATRIX_ROWS];
32
33void matrix_init(void) {
34 // all outputs for rows high
35 DDRB = 0xFF;
36 PORTB = 0xFF;
37 // all inputs for columns
38 DDRA = 0x00;
39 DDRC &= ~(0x111111<<2);
40 //----> DDRD &= ~(1<<PIND7);
41 // Port D not used on this keyboard
42 // all columns are pulled-up
43 PORTA = 0xFF;
44 PORTC |= (0b111111<<2);
45 //PORTD |= (1<<PIND7);
46 // Port D not used on this keyboard
47
48 // initialize matrix state: all keys off
49 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
50 matrix[row] = 0x00;
51 matrix_debouncing[row] = 0x00;
52 }
53 matrix_init_quantum(); // missing from original port by Luiz
54}
55
56void matrix_set_row_status(uint8_t row) {
57 DDRB = (1 << row);
58 PORTB = ~(1 << row);
59}
60
61uint8_t bit_reverse(uint8_t x) {
62 x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa);
63 x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
64 x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0);
65 return x;
66}
67
68uint8_t matrix_scan(void) {
69 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
70 matrix_set_row_status(row);
71 _delay_us(5);
72
73 matrix_row_t cols = (
74 // cols 0..7, PORTA 0 -> 7
75 (~PINA) & 0xFF
76 ) | (
77 // cols 8..13, PORTC 7 -> 0
78 bit_reverse((~PINC) & 0xFF) << 8
79 );
80
81 if (matrix_debouncing[row] != cols) {
82 matrix_debouncing[row] = cols;
83 debouncing = DEBOUNCE;
84 }
85 }
86
87 if (debouncing) {
88 if (--debouncing) {
89 _delay_ms(1);
90 } else {
91 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
92 matrix[i] = matrix_debouncing[i];
93 }
94 }
95 }
96 matrix_scan_quantum(); // also missing in original PS2AVRGB implementation
97 //matrix_scan_user();
98
99 return 1;
100}
101
102inline matrix_row_t matrix_get_row(uint8_t row) {
103 return matrix[row];
104}
105
106void matrix_print(void) {
107}
diff --git a/keyboards/jj50/rules.mk b/keyboards/jj50/rules.mk
index 40473e6ec..62b21e4df 100644
--- a/keyboards/jj50/rules.mk
+++ b/keyboards/jj50/rules.mk
@@ -29,8 +29,6 @@ SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
29 29
30#OPT_DEFS = -DDEBUG_LEVEL=0 30#OPT_DEFS = -DDEBUG_LEVEL=0
31 31
32# custom matrix setup 32SRC = backlight.c
33CUSTOM_MATRIX = yes
34SRC = matrix.c backlight.c
35 33
36LAYOUTS = ortho_5x12 34LAYOUTS = ortho_5x12