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
This commit is contained in:
parent
b83e3ae556
commit
2557bc8e6f
69 changed files with 81 additions and 1782 deletions
|
@ -17,9 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "bfake.h"
|
#include "bfake.h"
|
||||||
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void matrix_scan_user(void) {}
|
|
||||||
|
|
||||||
void backlight_init_ports(void) {
|
void backlight_init_ports(void) {
|
||||||
setPinOutput(D0);
|
setPinOutput(D0);
|
||||||
setPinOutput(D1);
|
setPinOutput(D1);
|
||||||
|
|
|
@ -32,7 +32,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#define MATRIX_COLS 11
|
#define MATRIX_COLS 11
|
||||||
|
|
||||||
#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 }
|
#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 }
|
||||||
#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6}
|
#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5 }
|
||||||
#define UNUSED_PINS
|
#define UNUSED_PINS
|
||||||
|
|
||||||
#define DIODE_DIRECTION COL2ROW
|
#define DIODE_DIRECTION COL2ROW
|
||||||
|
|
|
@ -1,106 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <avr/io.h>
|
|
||||||
#include <util/delay.h>
|
|
||||||
|
|
||||||
#include "matrix.h"
|
|
||||||
|
|
||||||
#ifndef DEBOUNCE
|
|
||||||
#define DEBOUNCE 5
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static uint8_t debouncing = DEBOUNCE;
|
|
||||||
|
|
||||||
static matrix_row_t matrix[MATRIX_ROWS];
|
|
||||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
|
||||||
|
|
||||||
void matrix_init(void) {
|
|
||||||
// all outputs for rows high
|
|
||||||
DDRB = 0xFF;
|
|
||||||
PORTB = 0xFF;
|
|
||||||
// all inputs for columns
|
|
||||||
DDRA = 0x00;
|
|
||||||
DDRC &= ~(0x111111<<2);
|
|
||||||
DDRD &= ~(1<<PIND7);
|
|
||||||
// all columns are pulled-up
|
|
||||||
PORTA = 0xFF;
|
|
||||||
PORTC |= (0b111111<<2);
|
|
||||||
PORTD |= (1<<PIND7);
|
|
||||||
|
|
||||||
// initialize matrix state: all keys off
|
|
||||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
|
||||||
matrix[row] = 0x00;
|
|
||||||
matrix_debouncing[row] = 0x00;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_set_row_status(uint8_t row) {
|
|
||||||
DDRB = (1 << row);
|
|
||||||
PORTB = ~(1 << row);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t bit_reverse(uint8_t x) {
|
|
||||||
x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa);
|
|
||||||
x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
|
|
||||||
x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0);
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t matrix_scan(void) {
|
|
||||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
|
||||||
matrix_set_row_status(row);
|
|
||||||
_delay_us(5);
|
|
||||||
|
|
||||||
matrix_row_t cols = (
|
|
||||||
// cols 0..7, PORTA 0 -> 7
|
|
||||||
(~PINA) & 0xFF
|
|
||||||
) | (
|
|
||||||
// cols 8..13, PORTC 7 -> 0
|
|
||||||
bit_reverse((~PINC) & 0xFF) << 8
|
|
||||||
) | (
|
|
||||||
// col 14, PORTD 7
|
|
||||||
((~PIND) & (1 << PIND7)) << 7
|
|
||||||
);
|
|
||||||
|
|
||||||
if (matrix_debouncing[row] != cols) {
|
|
||||||
matrix_debouncing[row] = cols;
|
|
||||||
debouncing = DEBOUNCE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (debouncing) {
|
|
||||||
if (--debouncing) {
|
|
||||||
_delay_ms(1);
|
|
||||||
} else {
|
|
||||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
|
||||||
matrix[i] = matrix_debouncing[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
matrix_scan_user();
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline matrix_row_t matrix_get_row(uint8_t row) {
|
|
||||||
return matrix[row];
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_print(void) {
|
|
||||||
}
|
|
|
@ -22,7 +22,3 @@ RGBLIGHT_ENABLE = no
|
||||||
WS2812_DRIVER = i2c
|
WS2812_DRIVER = i2c
|
||||||
|
|
||||||
OPT_DEFS = -DDEBUG_LEVEL=0
|
OPT_DEFS = -DDEBUG_LEVEL=0
|
||||||
|
|
||||||
# custom matrix setup
|
|
||||||
CUSTOM_MATRIX = yes
|
|
||||||
SRC = matrix.c
|
|
||||||
|
|
|
@ -14,11 +14,3 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "discipad.h"
|
#include "discipad.h"
|
||||||
|
|
||||||
|
|
||||||
void matrix_init_kb(void) {
|
|
||||||
// put your keyboard start-up code here
|
|
||||||
// runs once when the firmware starts up
|
|
||||||
|
|
||||||
matrix_init_user();
|
|
||||||
}
|
|
||||||
|
|
|
@ -14,11 +14,3 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "discipline.h"
|
#include "discipline.h"
|
||||||
|
|
||||||
|
|
||||||
void matrix_init_kb(void) {
|
|
||||||
// put your keyboard start-up code here
|
|
||||||
// runs once when the firmware starts up
|
|
||||||
|
|
||||||
matrix_init_user();
|
|
||||||
}
|
|
||||||
|
|
|
@ -60,15 +60,3 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void matrix_init_user(void) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_scan_user(void) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void led_set_user(uint8_t usb_led) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -60,15 +60,3 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void matrix_init_user(void) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_scan_user(void) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void led_set_user(uint8_t usb_led) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -61,15 +61,3 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void matrix_init_user(void) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_scan_user(void) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void led_set_user(uint8_t usb_led) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -26,8 +26,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#define PRODUCT JC65 PS2AVRGB
|
#define PRODUCT JC65 PS2AVRGB
|
||||||
|
|
||||||
/* matrix size */
|
/* matrix size */
|
||||||
#define MATRIX_ROWS 8
|
#define MATRIX_ROWS 7
|
||||||
#define MATRIX_COLS 16
|
#define MATRIX_COLS 15
|
||||||
|
#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B6, B7 }
|
||||||
|
#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7 }
|
||||||
|
#define DIODE_DIRECTION COL2ROW
|
||||||
|
|
||||||
#define BACKLIGHT_LEVELS 1
|
#define BACKLIGHT_LEVELS 1
|
||||||
#define RGBLED_NUM 16
|
#define RGBLED_NUM 16
|
||||||
|
|
|
@ -1,106 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <avr/io.h>
|
|
||||||
#include <util/delay.h>
|
|
||||||
|
|
||||||
#include "matrix.h"
|
|
||||||
|
|
||||||
#ifndef DEBOUNCE
|
|
||||||
#define DEBOUNCE 5
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static uint8_t debouncing = DEBOUNCE;
|
|
||||||
|
|
||||||
static matrix_row_t matrix[MATRIX_ROWS];
|
|
||||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
|
||||||
|
|
||||||
void matrix_init(void) {
|
|
||||||
// all outputs for rows high
|
|
||||||
DDRB = 0xFF;
|
|
||||||
PORTB = 0xFF;
|
|
||||||
// all inputs for columns
|
|
||||||
DDRA = 0x00;
|
|
||||||
DDRC &= ~(0x111111<<2);
|
|
||||||
DDRD &= ~(1<<PIND7);
|
|
||||||
// all columns are pulled-up
|
|
||||||
PORTA = 0xFF;
|
|
||||||
PORTC |= (0b111111<<2);
|
|
||||||
PORTD |= (1<<PIND7);
|
|
||||||
|
|
||||||
// initialize matrix state: all keys off
|
|
||||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
|
||||||
matrix[row] = 0x00;
|
|
||||||
matrix_debouncing[row] = 0x00;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_set_row_status(uint8_t row) {
|
|
||||||
DDRB = (1 << row);
|
|
||||||
PORTB = ~(1 << row);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t bit_reverse(uint8_t x) {
|
|
||||||
x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa);
|
|
||||||
x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
|
|
||||||
x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0);
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t matrix_scan(void) {
|
|
||||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
|
||||||
matrix_set_row_status(row);
|
|
||||||
_delay_us(5);
|
|
||||||
|
|
||||||
matrix_row_t cols = (
|
|
||||||
// cols 0..7, PORTA 0 -> 7
|
|
||||||
(~PINA) & 0xFF
|
|
||||||
) | (
|
|
||||||
// cols 8..13, PORTC 7 -> 0
|
|
||||||
bit_reverse((~PINC) & 0xFF) << 8
|
|
||||||
) | (
|
|
||||||
// col 14, PORTD 7
|
|
||||||
((~PIND) & (1 << PIND7)) << 7
|
|
||||||
);
|
|
||||||
|
|
||||||
if (matrix_debouncing[row] != cols) {
|
|
||||||
matrix_debouncing[row] = cols;
|
|
||||||
debouncing = DEBOUNCE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (debouncing) {
|
|
||||||
if (--debouncing) {
|
|
||||||
_delay_ms(1);
|
|
||||||
} else {
|
|
||||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
|
||||||
matrix[i] = matrix_debouncing[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
matrix_scan_user();
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline matrix_row_t matrix_get_row(uint8_t row) {
|
|
||||||
return matrix[row];
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_print(void) {
|
|
||||||
}
|
|
|
@ -22,7 +22,3 @@ RGBLIGHT_ENABLE = yes
|
||||||
WS2812_DRIVER = i2c
|
WS2812_DRIVER = i2c
|
||||||
|
|
||||||
OPT_DEFS = -DDEBUG_LEVEL=0
|
OPT_DEFS = -DDEBUG_LEVEL=0
|
||||||
|
|
||||||
# custom matrix setup
|
|
||||||
CUSTOM_MATRIX = yes
|
|
||||||
SRC = matrix.c
|
|
||||||
|
|
|
@ -17,9 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "v32a.h"
|
#include "v32a.h"
|
||||||
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void matrix_scan_user(void) {}
|
|
||||||
|
|
||||||
#ifdef BACKLIGHT_ENABLE
|
#ifdef BACKLIGHT_ENABLE
|
||||||
void backlight_init_ports(void) {
|
void backlight_init_ports(void) {
|
||||||
setPinOutput(D0);
|
setPinOutput(D0);
|
||||||
|
|
|
@ -27,14 +27,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
K01,K30,K11,K21,K31,K41,K51,K46,KE6,KE7,K47,KA1, KB1,K86,K77, \
|
K01,K30,K11,K21,K31,K41,K51,K46,KE6,KE7,K47,KA1, KB1,K86,K77, \
|
||||||
K00,K10,K20, K40,K56,K50, K57,KB0,KC0,K96,K76,K66 \
|
K00,K10,K20, K40,K56,K50, K57,KB0,KC0,K96,K76,K66 \
|
||||||
){ \
|
){ \
|
||||||
{ K00, K10, K20, K30, K40, K50,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO, KB0, KC0, KD0,KC_NO,KC_NO }, \
|
{ K00, K10, K20, K30, K40, K50,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO, KB0, KC0, KD0,KC_NO }, \
|
||||||
{ K01, K11, K21, K31, K41, K51,KC_NO,KC_NO,KC_NO,KC_NO, KA1, KB1,KC_NO,KC_NO,KC_NO,KC_NO }, \
|
{ K01, K11, K21, K31, K41, K51,KC_NO,KC_NO,KC_NO,KC_NO, KA1, KB1,KC_NO,KC_NO,KC_NO }, \
|
||||||
{ K02, K12, K22, K32, K42, K52,KC_NO,KC_NO,KC_NO,KC_NO, KA2, KB2, KC2, KD2,KC_NO,KC_NO }, \
|
{ K02, K12, K22, K32, K42, K52,KC_NO,KC_NO,KC_NO,KC_NO, KA2, KB2, KC2, KD2,KC_NO }, \
|
||||||
{ K03, K13, K23, K33, K43, K53,KC_NO,KC_NO,KC_NO,KC_NO, KA3, KB3, KC3, KD3,KC_NO,KC_NO }, \
|
{ K03, K13, K23, K33, K43, K53,KC_NO,KC_NO,KC_NO,KC_NO, KA3, KB3, KC3, KD3,KC_NO }, \
|
||||||
{ K04, K14, K24, K34, K44, K54,KC_NO,KC_NO,KC_NO,KC_NO, KA4, KB4, KC4, KD4, KE4,KC_NO }, \
|
{ K04, K14, K24, K34, K44, K54,KC_NO,KC_NO,KC_NO,KC_NO, KA4, KB4, KC4, KD4, KE4 }, \
|
||||||
{ KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO }, \
|
{ KC_NO, K16, K26, K36, K46, K56, K66, K76, K86, K96,KC_NO, KB6, KC6, KD6, KE6 }, \
|
||||||
{ KC_NO, K16, K26, K36, K46, K56, K66, K76, K86, K96,KC_NO, KB6, KC6, KD6, KE6,KC_NO }, \
|
{ KC_NO, K17, K27, K37, K47, K57, K67, K77, K87,KC_NO,KC_NO, KB7, KC7, KD7, KE7 } \
|
||||||
{ KC_NO, K17, K27, K37, K47, K57, K67, K77, K87,KC_NO,KC_NO, KB7, KC7, KD7, KE7,KC_NO } \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define LAYOUT_kc( \
|
#define LAYOUT_kc( \
|
||||||
|
@ -45,14 +44,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
K00,K10,K20, K40,K56,K50, K57,KB0,KC0,K96,K76,K66 \
|
K00,K10,K20, K40,K56,K50, K57,KB0,KC0,K96,K76,K66 \
|
||||||
) \
|
) \
|
||||||
{ \
|
{ \
|
||||||
{ KC_##K00,KC_##K10,KC_##K20,KC_##K30,KC_##K40,KC_##K50, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,KC_##KB0,KC_##KC0,KC_##KD0, KC_NO,KC_NO }, \
|
{ KC_##K00,KC_##K10,KC_##K20,KC_##K30,KC_##K40,KC_##K50, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,KC_##KB0,KC_##KC0,KC_##KD0, KC_NO }, \
|
||||||
{ KC_##K01,KC_##K11,KC_##K21,KC_##K31,KC_##K41,KC_##K51, KC_NO, KC_NO, KC_NO, KC_NO,KC_##KA1,KC_##KB1, KC_NO, KC_NO, KC_NO,KC_NO }, \
|
{ KC_##K01,KC_##K11,KC_##K21,KC_##K31,KC_##K41,KC_##K51, KC_NO, KC_NO, KC_NO, KC_NO,KC_##KA1,KC_##KB1, KC_NO, KC_NO, KC_NO }, \
|
||||||
{ KC_##K02,KC_##K12,KC_##K22,KC_##K32,KC_##K42,KC_##K52, KC_NO, KC_NO, KC_NO, KC_NO,KC_##KA2,KC_##KB2,KC_##KC2,KC_##KD2, KC_NO,KC_NO }, \
|
{ KC_##K02,KC_##K12,KC_##K22,KC_##K32,KC_##K42,KC_##K52, KC_NO, KC_NO, KC_NO, KC_NO,KC_##KA2,KC_##KB2,KC_##KC2,KC_##KD2, KC_NO }, \
|
||||||
{ KC_##K03,KC_##K13,KC_##K23,KC_##K33,KC_##K43,KC_##K53, KC_NO, KC_NO, KC_NO, KC_NO,KC_##KA3,KC_##KB3,KC_##KC3,KC_##KD3, KC_NO,KC_NO }, \
|
{ KC_##K03,KC_##K13,KC_##K23,KC_##K33,KC_##K43,KC_##K53, KC_NO, KC_NO, KC_NO, KC_NO,KC_##KA3,KC_##KB3,KC_##KC3,KC_##KD3, KC_NO }, \
|
||||||
{ KC_##K04,KC_##K14,KC_##K24,KC_##K34,KC_##K44,KC_##K54, KC_NO, KC_NO, KC_NO, KC_NO,KC_##KA4,KC_##KB4,KC_##KC4,KC_##KD4,KC_##KE4,KC_NO }, \
|
{ KC_##K04,KC_##K14,KC_##K24,KC_##K34,KC_##K44,KC_##K54, KC_NO, KC_NO, KC_NO, KC_NO,KC_##KA4,KC_##KB4,KC_##KC4,KC_##KD4,KC_##KE4 }, \
|
||||||
{ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,KC_NO }, \
|
{ KC_NO,KC_##K16,KC_##K26,KC_##K36,KC_##K46,KC_##K56,KC_##K66,KC_##K76,KC_##K86,KC_##K96, KC_NO,KC_##KB6,KC_##KC6,KC_##KD6,KC_##KE6 }, \
|
||||||
{ KC_NO,KC_##K16,KC_##K26,KC_##K36,KC_##K46,KC_##K56,KC_##K66,KC_##K76,KC_##K86,KC_##K96, KC_NO,KC_##KB6,KC_##KC6,KC_##KD6,KC_##KE6,KC_NO }, \
|
{ KC_NO,KC_##K17,KC_##K27,KC_##K37,KC_##K47,KC_##K57,KC_##K67,KC_##K77,KC_##K87, KC_NO, KC_NO,KC_##KB7,KC_##KC7,KC_##KD7,KC_##KE7 } \
|
||||||
{ KC_NO,KC_##K17,KC_##K27,KC_##K37,KC_##K47,KC_##K57,KC_##K67,KC_##K77,KC_##K87, KC_NO, KC_NO,KC_##KB7,KC_##KC7,KC_##KD7,KC_##KE7,KC_NO } \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,18 +1,3 @@
|
||||||
# Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
# MCU name
|
# MCU name
|
||||||
MCU = atmega32a
|
MCU = atmega32a
|
||||||
|
|
||||||
|
|
|
@ -32,9 +32,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#define DESCRIPTION Preonic-like clone
|
#define DESCRIPTION Preonic-like clone
|
||||||
|
|
||||||
/* matrix size */
|
/* matrix size */
|
||||||
#define MATRIX_ROWS 8
|
#define MATRIX_ROWS 5
|
||||||
#define MATRIX_COLS 15
|
#define MATRIX_COLS 12
|
||||||
#define DIODE_DIRECTION ROW2COL
|
#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4 }
|
||||||
|
#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4 }
|
||||||
|
#define DIODE_DIRECTION COL2ROW
|
||||||
|
|
||||||
//#define BACKLIGHT_PIN D4
|
//#define BACKLIGHT_PIN D4
|
||||||
#define BACKLIGHT_LEVELS 12
|
#define BACKLIGHT_LEVELS 12
|
||||||
|
|
|
@ -20,16 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "backlight.h"
|
#include "backlight.h"
|
||||||
#include "backlight_custom.h"
|
#include "backlight_custom.h"
|
||||||
|
|
||||||
void matrix_init_kb(void) { matrix_init_user(); }
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void matrix_init_user(void) {}
|
|
||||||
|
|
||||||
void matrix_scan_kb(void) { matrix_scan_user(); }
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void matrix_scan_user(void) {}
|
|
||||||
|
|
||||||
#ifdef BACKLIGHT_ENABLE
|
#ifdef BACKLIGHT_ENABLE
|
||||||
void backlight_init_ports(void) {
|
void backlight_init_ports(void) {
|
||||||
b_led_init_ports();
|
b_led_init_ports();
|
||||||
|
|
|
@ -25,8 +25,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "keycode.h"
|
#include "keycode.h"
|
||||||
#include "action.h"
|
#include "action.h"
|
||||||
|
|
||||||
void matrix_init_user(void);
|
|
||||||
|
|
||||||
#define LAYOUT_ortho_5x12( \
|
#define LAYOUT_ortho_5x12( \
|
||||||
K011, K010, K009, K008, K004, K005, K006, K007, K003, K002, K201, K000, \
|
K011, K010, K009, K008, K004, K005, K006, K007, K003, K002, K201, K000, \
|
||||||
K111, K110, K109, K108, K104, K105, K106, K107, K103, K102, K001, K100, \
|
K111, K110, K109, K108, K104, K105, K106, K107, K103, K102, K001, K100, \
|
||||||
|
|
|
@ -1,107 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
|
|
||||||
Modified 2018 by Wayne K Jones <github.com/WarmCatUK>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <avr/io.h>
|
|
||||||
#include <util/delay.h>
|
|
||||||
|
|
||||||
#include "matrix.h"
|
|
||||||
|
|
||||||
#ifndef DEBOUNCE
|
|
||||||
# define DEBOUNCE 5
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static uint8_t debouncing = DEBOUNCE;
|
|
||||||
|
|
||||||
static matrix_row_t matrix[MATRIX_ROWS];
|
|
||||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
|
||||||
|
|
||||||
void matrix_init(void) {
|
|
||||||
// all outputs for rows high
|
|
||||||
DDRB = 0xFF;
|
|
||||||
PORTB = 0xFF;
|
|
||||||
// all inputs for columns
|
|
||||||
DDRA = 0x00;
|
|
||||||
DDRC &= ~(0x111111<<2);
|
|
||||||
//----> DDRD &= ~(1<<PIND7);
|
|
||||||
// Port D not used on this keyboard
|
|
||||||
// all columns are pulled-up
|
|
||||||
PORTA = 0xFF;
|
|
||||||
PORTC |= (0b111111<<2);
|
|
||||||
//PORTD |= (1<<PIND7);
|
|
||||||
// Port D not used on this keyboard
|
|
||||||
|
|
||||||
// initialize matrix state: all keys off
|
|
||||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
|
||||||
matrix[row] = 0x00;
|
|
||||||
matrix_debouncing[row] = 0x00;
|
|
||||||
}
|
|
||||||
matrix_init_quantum(); // missing from original port by Luiz
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_set_row_status(uint8_t row) {
|
|
||||||
DDRB = (1 << row);
|
|
||||||
PORTB = ~(1 << row);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t bit_reverse(uint8_t x) {
|
|
||||||
x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa);
|
|
||||||
x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
|
|
||||||
x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0);
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t matrix_scan(void) {
|
|
||||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
|
||||||
matrix_set_row_status(row);
|
|
||||||
_delay_us(5);
|
|
||||||
|
|
||||||
matrix_row_t cols = (
|
|
||||||
// cols 0..7, PORTA 0 -> 7
|
|
||||||
(~PINA) & 0xFF
|
|
||||||
) | (
|
|
||||||
// cols 8..13, PORTC 7 -> 0
|
|
||||||
bit_reverse((~PINC) & 0xFF) << 8
|
|
||||||
);
|
|
||||||
|
|
||||||
if (matrix_debouncing[row] != cols) {
|
|
||||||
matrix_debouncing[row] = cols;
|
|
||||||
debouncing = DEBOUNCE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (debouncing) {
|
|
||||||
if (--debouncing) {
|
|
||||||
_delay_ms(1);
|
|
||||||
} else {
|
|
||||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
|
||||||
matrix[i] = matrix_debouncing[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
matrix_scan_quantum(); // also missing in original PS2AVRGB implementation
|
|
||||||
//matrix_scan_user();
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline matrix_row_t matrix_get_row(uint8_t row) {
|
|
||||||
return matrix[row];
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_print(void) {
|
|
||||||
}
|
|
|
@ -29,8 +29,6 @@ SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
|
||||||
|
|
||||||
#OPT_DEFS = -DDEBUG_LEVEL=0
|
#OPT_DEFS = -DDEBUG_LEVEL=0
|
||||||
|
|
||||||
# custom matrix setup
|
SRC = backlight.c
|
||||||
CUSTOM_MATRIX = yes
|
|
||||||
SRC = matrix.c backlight.c
|
|
||||||
|
|
||||||
LAYOUTS = ortho_5x12
|
LAYOUTS = ortho_5x12
|
||||||
|
|
|
@ -37,6 +37,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#define MATRIX_ROW_PINS { C3, C4, C5, C6, C7 }
|
#define MATRIX_ROW_PINS { C3, C4, C5, C6, C7 }
|
||||||
#define UNUSED_PINS
|
#define UNUSED_PINS
|
||||||
|
|
||||||
|
#define DIODE_DIRECTION COL2ROW
|
||||||
|
|
||||||
/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
|
/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
|
||||||
#define DEBOUNCE 5
|
#define DEBOUNCE 5
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#define DESCRIPTION 40% modular keyboard
|
#define DESCRIPTION 40% modular keyboard
|
||||||
|
|
||||||
/* matrix size */
|
/* matrix size */
|
||||||
#define MATRIX_ROWS 8
|
#define MATRIX_ROWS 4
|
||||||
#define MATRIX_COLS 15
|
#define MATRIX_COLS 12
|
||||||
|
#define MATRIX_ROW_PINS { B0, B1, B2, B3 }
|
||||||
|
#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4 }
|
||||||
|
#define DIODE_DIRECTION COL2ROW
|
||||||
|
|
||||||
#define NO_UART 1
|
#define NO_UART 1
|
||||||
|
|
||||||
|
|
|
@ -1,112 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <avr/io.h>
|
|
||||||
#include <util/delay.h>
|
|
||||||
|
|
||||||
#include "matrix.h"
|
|
||||||
|
|
||||||
#ifndef DEBOUNCE
|
|
||||||
# define DEBOUNCE 5
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static uint8_t debouncing = DEBOUNCE;
|
|
||||||
|
|
||||||
static matrix_row_t matrix[MATRIX_ROWS];
|
|
||||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
|
||||||
|
|
||||||
void matrix_set_row_status(uint8_t row);
|
|
||||||
uint8_t bit_reverse(uint8_t x);
|
|
||||||
|
|
||||||
void matrix_init(void) {
|
|
||||||
// all outputs for rows high
|
|
||||||
DDRB = 0xFF;
|
|
||||||
PORTB = 0xFF;
|
|
||||||
// all inputs for columns
|
|
||||||
DDRA = 0x00;
|
|
||||||
DDRC &= ~(0x111111<<2);
|
|
||||||
DDRD &= ~(1<<PIND7);
|
|
||||||
// all columns are pulled-up
|
|
||||||
PORTA = 0xFF;
|
|
||||||
PORTC |= (0b111111<<2);
|
|
||||||
PORTD |= (1<<PIND7);
|
|
||||||
|
|
||||||
// initialize matrix state: all keys off
|
|
||||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
|
||||||
matrix[row] = 0x00;
|
|
||||||
matrix_debouncing[row] = 0x00;
|
|
||||||
}
|
|
||||||
|
|
||||||
matrix_init_quantum();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t matrix_scan(void) {
|
|
||||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
|
||||||
matrix_set_row_status(row);
|
|
||||||
_delay_us(5);
|
|
||||||
|
|
||||||
matrix_row_t cols = (
|
|
||||||
// cols 0..7, PORTA 0 -> 7
|
|
||||||
(~PINA) & 0xFF
|
|
||||||
) | (
|
|
||||||
// cols 8..13, PORTC 7 -> 0
|
|
||||||
bit_reverse((~PINC) & 0xFF) << 8
|
|
||||||
) | (
|
|
||||||
// col 14, PORTD 7
|
|
||||||
((~PIND) & (1 << PIND7)) << 7
|
|
||||||
);
|
|
||||||
|
|
||||||
if (matrix_debouncing[row] != cols) {
|
|
||||||
matrix_debouncing[row] = cols;
|
|
||||||
debouncing = DEBOUNCE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (debouncing) {
|
|
||||||
if (--debouncing) {
|
|
||||||
_delay_ms(1);
|
|
||||||
} else {
|
|
||||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
|
||||||
matrix[i] = matrix_debouncing[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
matrix_scan_quantum();
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// declarations
|
|
||||||
void matrix_set_row_status(uint8_t row) {
|
|
||||||
DDRB = (1 << row);
|
|
||||||
PORTB = ~(1 << row);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t bit_reverse(uint8_t x) {
|
|
||||||
x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa);
|
|
||||||
x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
|
|
||||||
x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0);
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline matrix_row_t matrix_get_row(uint8_t row) {
|
|
||||||
return matrix[row];
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_print(void) {
|
|
||||||
}
|
|
|
@ -22,7 +22,3 @@ RGBLIGHT_ENABLE = yes
|
||||||
WS2812_DRIVER = i2c
|
WS2812_DRIVER = i2c
|
||||||
|
|
||||||
OPT_DEFS = -DDEBUG_LEVEL=0
|
OPT_DEFS = -DDEBUG_LEVEL=0
|
||||||
|
|
||||||
# custom matrix setup
|
|
||||||
CUSTOM_MATRIX = yes
|
|
||||||
SRC = matrix.c
|
|
||||||
|
|
|
@ -16,13 +16,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "v1.h"
|
#include "v1.h"
|
||||||
|
|
||||||
void matrix_init_kb(void) { matrix_init_user(); }
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void matrix_init_user(void) {}
|
|
||||||
|
|
||||||
void matrix_scan_kb(void) { matrix_scan_user(); }
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void matrix_scan_user(void) {}
|
|
||||||
|
|
|
@ -30,14 +30,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
K00, K10, K20, K56, K57, KB0, KC0, K66 \
|
K00, K10, K20, K56, K57, KB0, KC0, K66 \
|
||||||
) \
|
) \
|
||||||
{ \
|
{ \
|
||||||
{ K00, K10, K20, K56, KC_NO, K57, KC_NO, KC_NO, KB0, KC0, K66, KC_NO, KC_NO, KC_NO, KC_NO }, \
|
{ K00, K10, K20, K56, KC_NO, K57, KC_NO, KC_NO, KB0, KC0, K66, KC_NO }, \
|
||||||
{ K01, K11, K21, K31, K41, K51, K46, KE6, KE7, K47, KA1, KC_NO, KC_NO, KC_NO, KC_NO }, \
|
{ K01, K11, K21, K31, K41, K51, K46, KE6, KE7, K47, KA1, KC_NO }, \
|
||||||
{ K02, K12, K22, K32, K42, K52, K36, KD6, KD7, K37, KA2, KC_NO, KC_NO, KC_NO, KC_NO }, \
|
{ K02, K12, K22, K32, K42, K52, K36, KD6, KD7, K37, KA2, KC_NO }, \
|
||||||
{ K03, K13, K23, K33, K43, K53, K26, KC6, KC7, K27, KA3, KB3, KC_NO, KC_NO, KC_NO }, \
|
{ K03, K13, K23, K33, K43, K53, K26, KC6, KC7, K27, KA3, KB3 } \
|
||||||
{ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
|
|
||||||
{ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
|
|
||||||
{ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
|
|
||||||
{ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO } \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define LAYOUT_split_space( \
|
#define LAYOUT_split_space( \
|
||||||
|
@ -47,14 +43,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
K00, K10, K20, K56, K57, KB0, KC0, K66 \
|
K00, K10, K20, K56, K57, KB0, KC0, K66 \
|
||||||
) \
|
) \
|
||||||
{ \
|
{ \
|
||||||
{ K00, K10, K20, K56, KC_NO, KC_NO, K57, KC_NO, KB0, KC0, K66, KC_NO, KC_NO, KC_NO, KC_NO }, \
|
{ K00, K10, K20, K56, KC_NO, KC_NO, K57, KC_NO, KB0, KC0, K66, KC_NO }, \
|
||||||
{ K01, K11, K21, K31, K41, K51, K46, KE6, KE7, K47, KA1, KC_NO, KC_NO, KC_NO, KC_NO }, \
|
{ K01, K11, K21, K31, K41, K51, K46, KE6, KE7, K47, KA1, KC_NO }, \
|
||||||
{ K02, K12, K22, K32, K42, K52, K36, KD6, KD7, K37, KA2, KC_NO, KC_NO, KC_NO, KC_NO }, \
|
{ K02, K12, K22, K32, K42, K52, K36, KD6, KD7, K37, KA2, KC_NO }, \
|
||||||
{ K03, K13, K23, K33, K43, K53, K26, KC6, KC7, K27, KA3, KB3, KC_NO, KC_NO, KC_NO }, \
|
{ K03, K13, K23, K33, K43, K53, K26, KC6, KC7, K27, KA3, KB3 } \
|
||||||
{ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
|
|
||||||
{ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
|
|
||||||
{ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
|
|
||||||
{ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO } \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -12,6 +12,9 @@
|
||||||
/* matrix size */
|
/* matrix size */
|
||||||
#define MATRIX_ROWS 8
|
#define MATRIX_ROWS 8
|
||||||
#define MATRIX_COLS 15
|
#define MATRIX_COLS 15
|
||||||
|
#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 }
|
||||||
|
#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7 }
|
||||||
|
#define DIODE_DIRECTION COL2ROW
|
||||||
|
|
||||||
#define RGBLED_NUM 16
|
#define RGBLED_NUM 16
|
||||||
#define RGBLIGHT_ANIMATIONS
|
#define RGBLIGHT_ANIMATIONS
|
||||||
|
|
|
@ -68,13 +68,3 @@ BL_TOGG, BL_DEC, BL_INC changes the in-switch LEDs
|
||||||
_______ , _______, _______, BL_DEC, BL_TOGG, BL_INC, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
_______ , _______, _______, BL_DEC, BL_TOGG, BL_INC, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______),
|
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______),
|
||||||
};
|
};
|
||||||
|
|
||||||
void matrix_init_user(void) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_scan_user(void) {
|
|
||||||
}
|
|
||||||
|
|
||||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,130 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <avr/io.h>
|
|
||||||
#include <util/delay.h>
|
|
||||||
|
|
||||||
#include "matrix.h"
|
|
||||||
|
|
||||||
#ifndef DEBOUNCE
|
|
||||||
# define DEBOUNCE 5
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static uint8_t debouncing = DEBOUNCE;
|
|
||||||
|
|
||||||
static matrix_row_t matrix[MATRIX_ROWS];
|
|
||||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
|
||||||
|
|
||||||
void matrix_set_row_status(uint8_t row);
|
|
||||||
uint8_t bit_reverse(uint8_t x);
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void matrix_init_kb(void) {
|
|
||||||
matrix_init_user();
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void matrix_scan_kb(void) {
|
|
||||||
matrix_scan_user();
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void matrix_init_user(void) {
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void matrix_scan_user(void) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_init(void) {
|
|
||||||
// all outputs for rows high
|
|
||||||
DDRB = 0xFF;
|
|
||||||
PORTB = 0xFF;
|
|
||||||
// all inputs for columns
|
|
||||||
DDRA = 0x00;
|
|
||||||
DDRC &= ~(0x111111<<2);
|
|
||||||
DDRD &= ~(1<<PIND7);
|
|
||||||
// all columns are pulled-up
|
|
||||||
PORTA = 0xFF;
|
|
||||||
PORTC |= (0b111111<<2);
|
|
||||||
PORTD |= (1<<PIND7);
|
|
||||||
|
|
||||||
// initialize matrix state: all keys off
|
|
||||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
|
||||||
matrix[row] = 0x00;
|
|
||||||
matrix_debouncing[row] = 0x00;
|
|
||||||
}
|
|
||||||
|
|
||||||
matrix_init_quantum();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t matrix_scan(void) {
|
|
||||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
|
||||||
matrix_set_row_status(row);
|
|
||||||
_delay_us(5);
|
|
||||||
|
|
||||||
matrix_row_t cols = (
|
|
||||||
// cols 0..7, PORTA 0 -> 7
|
|
||||||
(~PINA) & 0xFF
|
|
||||||
) | (
|
|
||||||
// cols 8..13, PORTC 7 -> 0
|
|
||||||
bit_reverse((~PINC) & 0xFF) << 8
|
|
||||||
) | (
|
|
||||||
// col 14, PORTD 7
|
|
||||||
((~PIND) & (1 << PIND7)) << 7
|
|
||||||
);
|
|
||||||
|
|
||||||
if (matrix_debouncing[row] != cols) {
|
|
||||||
matrix_debouncing[row] = cols;
|
|
||||||
debouncing = DEBOUNCE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (debouncing) {
|
|
||||||
if (--debouncing) {
|
|
||||||
_delay_ms(1);
|
|
||||||
} else {
|
|
||||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
|
||||||
matrix[i] = matrix_debouncing[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
matrix_scan_quantum();
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// declarations
|
|
||||||
void matrix_set_row_status(uint8_t row) {
|
|
||||||
DDRB = (1 << row);
|
|
||||||
PORTB = ~(1 << row);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t bit_reverse(uint8_t x) {
|
|
||||||
x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa);
|
|
||||||
x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
|
|
||||||
x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0);
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline matrix_row_t matrix_get_row(uint8_t row) {
|
|
||||||
return matrix[row];
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_print(void) {
|
|
||||||
}
|
|
|
@ -16,13 +16,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mehkee96.h"
|
#include "mehkee96.h"
|
||||||
|
|
||||||
void matrix_init_kb(void) { matrix_init_user(); }
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void matrix_init_user(void) {}
|
|
||||||
|
|
||||||
void matrix_scan_kb(void) { matrix_scan_user(); }
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void matrix_scan_user(void) {}
|
|
||||||
|
|
|
@ -24,7 +24,3 @@ RGBLIGHT_ENABLE = yes
|
||||||
WS2812_DRIVER = i2c
|
WS2812_DRIVER = i2c
|
||||||
|
|
||||||
OPT_DEFS = -DDEBUG_LEVEL=0
|
OPT_DEFS = -DDEBUG_LEVEL=0
|
||||||
|
|
||||||
# custom matrix setup
|
|
||||||
CUSTOM_MATRIX = yes
|
|
||||||
SRC = matrix.c
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#define DESCRIPTION A Planck clone
|
#define DESCRIPTION A Planck clone
|
||||||
|
|
||||||
/* key matrix size */
|
/* key matrix size */
|
||||||
#define MATRIX_ROWS 8
|
#define MATRIX_ROWS 7
|
||||||
#define MATRIX_COLS 15
|
#define MATRIX_COLS 15
|
||||||
|
|
||||||
#define NO_UART 1
|
#define NO_UART 1
|
||||||
|
@ -55,12 +55,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
/* #define CB6 0x37 // B7 */
|
/* #define CB6 0x37 // B7 */
|
||||||
/* #define CC7 0x62 // C2 */
|
/* #define CC7 0x62 // C2 */
|
||||||
|
|
||||||
#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 }
|
#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B6, B7 }
|
||||||
#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C2, C3, C4, C5, C6, C7, D7 }
|
#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7 }
|
||||||
/* #define UNUSED_PINS */
|
/* #define UNUSED_PINS */
|
||||||
|
|
||||||
/* COL2ROW, ROW2COL*/
|
/* COL2ROW, ROW2COL*/
|
||||||
/* #define DIODE_DIRECTION COL2ROW */
|
#define DIODE_DIRECTION COL2ROW
|
||||||
|
|
||||||
#define BACKLIGHT_PIN D2
|
#define BACKLIGHT_PIN D2
|
||||||
|
|
||||||
|
|
|
@ -1,128 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <avr/io.h>
|
|
||||||
#include <util/delay.h>
|
|
||||||
|
|
||||||
#include "matrix.h"
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#ifndef DEBOUNCE
|
|
||||||
# define DEBOUNCE 5
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static uint8_t debouncing = DEBOUNCE;
|
|
||||||
|
|
||||||
static matrix_row_t matrix[MATRIX_ROWS];
|
|
||||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void matrix_init_kb(void) {
|
|
||||||
matrix_init_user();
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void matrix_scan_kb(void) {
|
|
||||||
matrix_scan_user();
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void matrix_init_user(void) {
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void matrix_scan_user(void) {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void matrix_init(void) {
|
|
||||||
// all outputs for rows high
|
|
||||||
DDRB = 0xFF;
|
|
||||||
PORTB = 0xFF;
|
|
||||||
// all inputs for columns
|
|
||||||
DDRA = 0x00;
|
|
||||||
DDRC &= ~(0x111111<<2);
|
|
||||||
DDRD &= ~(1<<PIND7);
|
|
||||||
// all columns are pulled-up
|
|
||||||
PORTA = 0xFF;
|
|
||||||
PORTC |= (0b111111<<2);
|
|
||||||
PORTD |= (1<<PIND7);
|
|
||||||
|
|
||||||
// initialize matrix state: all keys off
|
|
||||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
|
||||||
matrix[row] = 0x00;
|
|
||||||
matrix_debouncing[row] = 0x00;
|
|
||||||
}
|
|
||||||
matrix_init_kb();
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_set_row_status(uint8_t row) {
|
|
||||||
DDRB = (1 << row);
|
|
||||||
PORTB = ~(1 << row);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t bit_reverse(uint8_t x) {
|
|
||||||
x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa);
|
|
||||||
x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
|
|
||||||
x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0);
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t matrix_scan(void) {
|
|
||||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
|
||||||
matrix_set_row_status(row);
|
|
||||||
_delay_us(5);
|
|
||||||
|
|
||||||
matrix_row_t cols = (
|
|
||||||
// cols 0..7, PORTA 0 -> 7
|
|
||||||
(~PINA) & 0xFF
|
|
||||||
) | (
|
|
||||||
// cols 8..13, PORTC 7 -> 0
|
|
||||||
bit_reverse((~PINC) & 0xFF) << 8
|
|
||||||
) | (
|
|
||||||
// col 14, PORTD 7
|
|
||||||
((~PIND) & (1 << PIND7)) << 7
|
|
||||||
);
|
|
||||||
|
|
||||||
if (matrix_debouncing[row] != cols) {
|
|
||||||
matrix_debouncing[row] = cols;
|
|
||||||
debouncing = DEBOUNCE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (debouncing) {
|
|
||||||
if (--debouncing) {
|
|
||||||
_delay_ms(1);
|
|
||||||
} else {
|
|
||||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
|
||||||
matrix[i] = matrix_debouncing[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
matrix_scan_kb();
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline matrix_row_t matrix_get_row(uint8_t row) {
|
|
||||||
return matrix[row];
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_print(void) {
|
|
||||||
}
|
|
|
@ -34,7 +34,6 @@
|
||||||
{ K30, K11, K12, K13, K14, K15, KC_NO, KC_NO, KC_NO, KC_NO, K1A, K1B, KC_NO, KC_NO, KC_NO }, \
|
{ K30, K11, K12, K13, K14, K15, KC_NO, KC_NO, KC_NO, KC_NO, K1A, K1B, KC_NO, KC_NO, KC_NO }, \
|
||||||
{ K10, K01, K02, K03, K04, K05, KC_NO, KC_NO, KC_NO, KC_NO, K0A, KC_NO, KC_NO, KC_NO, KC_NO }, \
|
{ K10, K01, K02, K03, K04, K05, KC_NO, KC_NO, KC_NO, KC_NO, K0A, KC_NO, KC_NO, KC_NO, KC_NO }, \
|
||||||
{ K00, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, K0B }, \
|
{ K00, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, K0B }, \
|
||||||
{ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
|
|
||||||
{ KC_NO, KC_NO, K06, K16, K26, K35, K38, K3A, K39, K3B, KC_NO, KC_NO, K07, K17, K27 }, \
|
{ KC_NO, KC_NO, K06, K16, K26, K35, K38, K3A, K39, K3B, KC_NO, KC_NO, K07, K17, K27 }, \
|
||||||
{ KC_NO, KC_NO, K09, K19, K29, KC_NO, K2B, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, K08, K18, K28 } \
|
{ KC_NO, KC_NO, K09, K19, K29, KC_NO, K2B, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, K08, K18, K28 } \
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,9 +29,5 @@ TAP_DANCE_ENABLE = no
|
||||||
|
|
||||||
OPT_DEFS = -DDEBUG_LEVEL=0
|
OPT_DEFS = -DDEBUG_LEVEL=0
|
||||||
|
|
||||||
# custom matrix setup
|
|
||||||
CUSTOM_MATRIX = yes
|
|
||||||
SRC = matrix.c
|
|
||||||
|
|
||||||
LAYOUTS = planck_mit
|
LAYOUTS = planck_mit
|
||||||
LAYOUTS_HAS_RGB = no
|
LAYOUTS_HAS_RGB = no
|
||||||
|
|
|
@ -17,16 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "canoe.h"
|
#include "canoe.h"
|
||||||
|
|
||||||
void matrix_init_kb(void) { matrix_init_user(); }
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void matrix_init_user(void) {}
|
|
||||||
|
|
||||||
void matrix_scan_kb(void) { matrix_scan_user(); }
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void matrix_scan_user(void) {}
|
|
||||||
|
|
||||||
#ifdef BACKLIGHT_ENABLE
|
#ifdef BACKLIGHT_ENABLE
|
||||||
void backlight_set(uint8_t level) {
|
void backlight_set(uint8_t level) {
|
||||||
if (level == 0) {
|
if (level == 0) {
|
||||||
|
|
|
@ -32,10 +32,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
{ K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E }, \
|
{ K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E }, \
|
||||||
{ _x_, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E }, \
|
{ _x_, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E }, \
|
||||||
{ K30, _x_, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, K3E }, \
|
{ K30, _x_, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, K3E }, \
|
||||||
{ K40, _x_, K42, K43, K44, _x_, _x_, _x_, K48, _x_, K4A, K4B, K4C, K4D, K4E }, \
|
{ K40, _x_, K42, K43, K44, _x_, _x_, _x_, K48, _x_, K4A, K4B, K4C, K4D, K4E } \
|
||||||
{ _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_ }, \
|
|
||||||
{ _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_ }, \
|
|
||||||
{ _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_ } \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define LAYOUT_65_ansi_blocker( \
|
#define LAYOUT_65_ansi_blocker( \
|
||||||
|
@ -49,10 +46,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
{ K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E }, \
|
{ K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E }, \
|
||||||
{ _x_, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E }, \
|
{ _x_, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E }, \
|
||||||
{ K30, _x_, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, K3E }, \
|
{ K30, _x_, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, K3E }, \
|
||||||
{ K40, _x_, K42, K43, K44, _x_, _x_, _x_, K48, _x_, _x_, K4B, K4C, K4D, K4E }, \
|
{ K40, _x_, K42, K43, K44, _x_, _x_, _x_, K48, _x_, _x_, K4B, K4C, K4D, K4E } \
|
||||||
{ _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_ }, \
|
|
||||||
{ _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_ }, \
|
|
||||||
{ _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_ } \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define LAYOUT LAYOUT_65_ansi_blocker // added to not break existing checked in keymaps
|
#define LAYOUT LAYOUT_65_ansi_blocker // added to not break existing checked in keymaps
|
||||||
|
|
|
@ -28,11 +28,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#define RGBLED_NUM 2
|
#define RGBLED_NUM 2
|
||||||
|
|
||||||
#define MATRIX_ROWS 8
|
#define MATRIX_ROWS 5
|
||||||
#define MATRIX_COLS 15
|
#define MATRIX_COLS 15
|
||||||
|
|
||||||
#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 }
|
#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4 }
|
||||||
#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, C1 }
|
#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7 }
|
||||||
#define UNUSED_PINS
|
#define UNUSED_PINS
|
||||||
|
|
||||||
#define DIODE_DIRECTION COL2ROW
|
#define DIODE_DIRECTION COL2ROW
|
||||||
|
|
|
@ -1,112 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <avr/io.h>
|
|
||||||
#include <util/delay.h>
|
|
||||||
|
|
||||||
#include "matrix.h"
|
|
||||||
|
|
||||||
#ifndef DEBOUNCE
|
|
||||||
# define DEBOUNCE 5
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static uint8_t debouncing = DEBOUNCE;
|
|
||||||
|
|
||||||
static matrix_row_t matrix[MATRIX_ROWS];
|
|
||||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
|
||||||
|
|
||||||
void matrix_set_row_status(uint8_t row);
|
|
||||||
uint8_t bit_reverse(uint8_t x);
|
|
||||||
|
|
||||||
void matrix_init(void) {
|
|
||||||
// all outputs for rows high
|
|
||||||
DDRB = 0xFF;
|
|
||||||
PORTB = 0xFF;
|
|
||||||
// all inputs for columns
|
|
||||||
DDRA = 0x00;
|
|
||||||
DDRC &= ~(0x111111<<2);
|
|
||||||
DDRD &= ~(1<<PIND7);
|
|
||||||
// all columns are pulled-up
|
|
||||||
PORTA = 0xFF;
|
|
||||||
PORTC |= (0b111111<<2);
|
|
||||||
PORTD |= (1<<PIND7);
|
|
||||||
|
|
||||||
// initialize matrix state: all keys off
|
|
||||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
|
||||||
matrix[row] = 0x00;
|
|
||||||
matrix_debouncing[row] = 0x00;
|
|
||||||
}
|
|
||||||
|
|
||||||
matrix_init_quantum();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t matrix_scan(void) {
|
|
||||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
|
||||||
matrix_set_row_status(row);
|
|
||||||
_delay_us(5);
|
|
||||||
|
|
||||||
matrix_row_t cols = (
|
|
||||||
// cols 0..7, PORTA 0 -> 7
|
|
||||||
(~PINA) & 0xFF
|
|
||||||
) | (
|
|
||||||
// cols 8..13, PORTC 7 -> 0
|
|
||||||
bit_reverse((~PINC) & 0xFF) << 8
|
|
||||||
) | (
|
|
||||||
// col 14, PORTD 7
|
|
||||||
((~PIND) & (1 << PIND7)) << 7
|
|
||||||
);
|
|
||||||
|
|
||||||
if (matrix_debouncing[row] != cols) {
|
|
||||||
matrix_debouncing[row] = cols;
|
|
||||||
debouncing = DEBOUNCE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (debouncing) {
|
|
||||||
if (--debouncing) {
|
|
||||||
_delay_ms(1);
|
|
||||||
} else {
|
|
||||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
|
||||||
matrix[i] = matrix_debouncing[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
matrix_scan_quantum();
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// declarations
|
|
||||||
void matrix_set_row_status(uint8_t row) {
|
|
||||||
DDRB = (1 << row);
|
|
||||||
PORTB = ~(1 << row);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t bit_reverse(uint8_t x) {
|
|
||||||
x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa);
|
|
||||||
x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
|
|
||||||
x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0);
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline matrix_row_t matrix_get_row(uint8_t row) {
|
|
||||||
return matrix[row];
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_print(void) {
|
|
||||||
}
|
|
|
@ -23,8 +23,4 @@ WS2812_DRIVER = i2c
|
||||||
|
|
||||||
OPT_DEFS = -DDEBUG_LEVEL=0
|
OPT_DEFS = -DDEBUG_LEVEL=0
|
||||||
|
|
||||||
# custom matrix setup
|
|
||||||
CUSTOM_MATRIX = yes
|
|
||||||
SRC = matrix.c
|
|
||||||
|
|
||||||
LAYOUTS = 65_ansi_blocker 65_iso_blocker
|
LAYOUTS = 65_ansi_blocker 65_iso_blocker
|
||||||
|
|
|
@ -26,9 +26,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#define PRODUCT Skog TKL
|
#define PRODUCT Skog TKL
|
||||||
|
|
||||||
/* matrix size */
|
/* matrix size */
|
||||||
#define MATRIX_ROWS 8
|
#define MATRIX_ROWS 7
|
||||||
#define MATRIX_COLS 14
|
#define MATRIX_COLS 14
|
||||||
|
|
||||||
|
#define MATRIX_ROW_PINS { B0, B1, B2, B3, B5, B6, B7 }
|
||||||
|
#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2 }
|
||||||
|
#define DIODE_DIRECTION COL2ROW
|
||||||
|
|
||||||
#define RGBLED_NUM 2
|
#define RGBLED_NUM 2
|
||||||
#define RGBLIGHT_ANIMATIONS
|
#define RGBLIGHT_ANIMATIONS
|
||||||
|
|
||||||
|
|
|
@ -27,11 +27,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI, KC_MENU, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT
|
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI, KC_MENU, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
void matrix_init_user(void) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_scan_user(void) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,112 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <avr/io.h>
|
|
||||||
#include <util/delay.h>
|
|
||||||
|
|
||||||
#include "matrix.h"
|
|
||||||
|
|
||||||
#ifndef DEBOUNCE
|
|
||||||
# define DEBOUNCE 5
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static uint8_t debouncing = DEBOUNCE;
|
|
||||||
|
|
||||||
static matrix_row_t matrix[MATRIX_ROWS];
|
|
||||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
|
||||||
|
|
||||||
void matrix_set_row_status(uint8_t row);
|
|
||||||
uint8_t bit_reverse(uint8_t x);
|
|
||||||
|
|
||||||
void matrix_init(void) {
|
|
||||||
// all outputs for rows high
|
|
||||||
DDRB = 0xFF;
|
|
||||||
PORTB = 0xFF;
|
|
||||||
// all inputs for columns
|
|
||||||
DDRA = 0x00;
|
|
||||||
DDRC &= ~(0x111111<<2);
|
|
||||||
DDRD &= ~(1<<PIND7);
|
|
||||||
// all columns are pulled-up
|
|
||||||
PORTA = 0xFF;
|
|
||||||
PORTC |= (0b111111<<2);
|
|
||||||
PORTD |= (1<<PIND7);
|
|
||||||
|
|
||||||
// initialize matrix state: all keys off
|
|
||||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
|
||||||
matrix[row] = 0x00;
|
|
||||||
matrix_debouncing[row] = 0x00;
|
|
||||||
}
|
|
||||||
|
|
||||||
matrix_init_quantum();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t matrix_scan(void) {
|
|
||||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
|
||||||
matrix_set_row_status(row);
|
|
||||||
_delay_us(5);
|
|
||||||
|
|
||||||
matrix_row_t cols = (
|
|
||||||
// cols 0..7, PORTA 0 -> 7
|
|
||||||
(~PINA) & 0xFF
|
|
||||||
) | (
|
|
||||||
// cols 8..13, PORTC 7 -> 0
|
|
||||||
bit_reverse((~PINC) & 0xFF) << 8
|
|
||||||
) | (
|
|
||||||
// col 14, PORTD 7
|
|
||||||
((~PIND) & (1 << PIND7)) << 7
|
|
||||||
);
|
|
||||||
|
|
||||||
if (matrix_debouncing[row] != cols) {
|
|
||||||
matrix_debouncing[row] = cols;
|
|
||||||
debouncing = DEBOUNCE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (debouncing) {
|
|
||||||
if (--debouncing) {
|
|
||||||
_delay_ms(1);
|
|
||||||
} else {
|
|
||||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
|
||||||
matrix[i] = matrix_debouncing[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
matrix_scan_quantum();
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// declarations
|
|
||||||
void matrix_set_row_status(uint8_t row) {
|
|
||||||
DDRB = (1 << row);
|
|
||||||
PORTB = ~(1 << row);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t bit_reverse(uint8_t x) {
|
|
||||||
x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa);
|
|
||||||
x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
|
|
||||||
x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0);
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline matrix_row_t matrix_get_row(uint8_t row) {
|
|
||||||
return matrix[row];
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_print(void) {
|
|
||||||
}
|
|
|
@ -22,16 +22,6 @@ ps2avrGB support code by Kenneth A. (bminiex/.[ch])
|
||||||
#include "backlight.h"
|
#include "backlight.h"
|
||||||
#include "backlight_custom.h"
|
#include "backlight_custom.h"
|
||||||
|
|
||||||
void matrix_init_kb(void) { matrix_init_user(); }
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void matrix_init_user(void) {}
|
|
||||||
|
|
||||||
void matrix_scan_kb(void) { matrix_scan_user(); }
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void matrix_scan_user(void) {}
|
|
||||||
|
|
||||||
#ifdef BACKLIGHT_ENABLE
|
#ifdef BACKLIGHT_ENABLE
|
||||||
/// Overrides functions in `quantum.c`
|
/// Overrides functions in `quantum.c`
|
||||||
void backlight_init_ports(void) {
|
void backlight_init_ports(void) {
|
||||||
|
|
|
@ -32,7 +32,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
{ K01, K11, K21, K31, K41, K51, K61, KC_NO, K81, K91, KA1, KB1, KC1, KD1 }, \
|
{ K01, K11, K21, K31, K41, K51, K61, KC_NO, K81, K91, KA1, KB1, KC1, KD1 }, \
|
||||||
{ K02, K12, K22, K32, K42, K52, K62, K72, K82, K92, KA2, KB2, KC2, KD2 }, \
|
{ K02, K12, K22, K32, K42, K52, K62, K72, K82, K92, KA2, KB2, KC2, KD2 }, \
|
||||||
{ K03, K13, K23, K33, K43, K53, K63, K73, K83, K93, KA3, KB3, KC3, KD3 }, \
|
{ K03, K13, K23, K33, K43, K53, K63, K73, K83, K93, KA3, KB3, KC3, KD3 }, \
|
||||||
{ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
|
|
||||||
{ K05, K15, K25, K35, K45, K55, K65, K75, K85, K95, KA5, KB5, KC5, KC_NO }, \
|
{ K05, K15, K25, K35, K45, K55, K65, K75, K85, K95, KA5, KB5, KC5, KC_NO }, \
|
||||||
{ K06, K16, K26, K36, K46, K56, K66, K76, K86, K96, KA6, KB6, KC6, KD6 }, \
|
{ K06, K16, K26, K36, K46, K56, K66, K76, K86, K96, KA6, KB6, KC6, KD6 }, \
|
||||||
{ K07, K17, K27, K37, KC_NO, K57, KC_NO, KC_NO, K87, K97, KA7, KB7, KC7, KD7 } \
|
{ K07, K17, K27, K37, KC_NO, K57, KC_NO, KC_NO, K87, K97, KA7, KB7, KC7, KD7 } \
|
||||||
|
|
|
@ -35,6 +35,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7}
|
#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7}
|
||||||
#define UNUSED_PINS
|
#define UNUSED_PINS
|
||||||
|
|
||||||
|
#define DIODE_DIRECTION COL2ROW
|
||||||
|
|
||||||
#define RGBLED_NUM 16
|
#define RGBLED_NUM 16
|
||||||
#define RGBLIGHT_ANIMATIONS
|
#define RGBLIGHT_ANIMATIONS
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "bmini.h"
|
#include "bmini.h"
|
||||||
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void matrix_scan_user(void) {}
|
|
||||||
|
|
|
@ -31,6 +31,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
/* matrix size */
|
/* matrix size */
|
||||||
#define MATRIX_ROWS 8
|
#define MATRIX_ROWS 8
|
||||||
#define MATRIX_COLS 15
|
#define MATRIX_COLS 15
|
||||||
|
#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 }
|
||||||
|
#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7 }
|
||||||
|
#define DIODE_DIRECTION COL2ROW
|
||||||
|
|
||||||
#define RGBLIGHT_ANIMATIONS
|
#define RGBLIGHT_ANIMATIONS
|
||||||
|
|
||||||
|
|
|
@ -1,106 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <avr/io.h>
|
|
||||||
#include <util/delay.h>
|
|
||||||
|
|
||||||
#include "matrix.h"
|
|
||||||
|
|
||||||
#ifndef DEBOUNCE
|
|
||||||
#define DEBOUNCE 5
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static uint8_t debouncing = DEBOUNCE;
|
|
||||||
|
|
||||||
static matrix_row_t matrix[MATRIX_ROWS];
|
|
||||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
|
||||||
|
|
||||||
void matrix_init(void) {
|
|
||||||
// all outputs for rows high
|
|
||||||
DDRB = 0xFF;
|
|
||||||
PORTB = 0xFF;
|
|
||||||
// all inputs for columns
|
|
||||||
DDRA = 0x00;
|
|
||||||
DDRC &= ~(0x111111<<2);
|
|
||||||
DDRD &= ~(1<<PIND7);
|
|
||||||
// all columns are pulled-up
|
|
||||||
PORTA = 0xFF;
|
|
||||||
PORTC |= (0b111111<<2);
|
|
||||||
PORTD |= (1<<PIND7);
|
|
||||||
|
|
||||||
// initialize matrix state: all keys off
|
|
||||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
|
||||||
matrix[row] = 0x00;
|
|
||||||
matrix_debouncing[row] = 0x00;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_set_row_status(uint8_t row) {
|
|
||||||
DDRB = (1 << row);
|
|
||||||
PORTB = ~(1 << row);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t bit_reverse(uint8_t x) {
|
|
||||||
x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa);
|
|
||||||
x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
|
|
||||||
x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0);
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t matrix_scan(void) {
|
|
||||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
|
||||||
matrix_set_row_status(row);
|
|
||||||
_delay_us(5);
|
|
||||||
|
|
||||||
matrix_row_t cols = (
|
|
||||||
// cols 0..7, PORTA 0 -> 7
|
|
||||||
(~PINA) & 0xFF
|
|
||||||
) | (
|
|
||||||
// cols 8..13, PORTC 7 -> 0
|
|
||||||
bit_reverse((~PINC) & 0xFF) << 8
|
|
||||||
) | (
|
|
||||||
// col 14, PORTD 7
|
|
||||||
((~PIND) & (1 << PIND7)) << 7
|
|
||||||
);
|
|
||||||
|
|
||||||
if (matrix_debouncing[row] != cols) {
|
|
||||||
matrix_debouncing[row] = cols;
|
|
||||||
debouncing = DEBOUNCE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (debouncing) {
|
|
||||||
if (--debouncing) {
|
|
||||||
_delay_ms(1);
|
|
||||||
} else {
|
|
||||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
|
||||||
matrix[i] = matrix_debouncing[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
matrix_scan_user();
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline matrix_row_t matrix_get_row(uint8_t row) {
|
|
||||||
return matrix[row];
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_print(void) {
|
|
||||||
}
|
|
|
@ -22,7 +22,3 @@ RGBLIGHT_ENABLE = yes
|
||||||
WS2812_DRIVER = i2c
|
WS2812_DRIVER = i2c
|
||||||
|
|
||||||
OPT_DEFS = -DDEBUG_LEVEL=0
|
OPT_DEFS = -DDEBUG_LEVEL=0
|
||||||
|
|
||||||
# custom matrix setup
|
|
||||||
CUSTOM_MATRIX = yes
|
|
||||||
SRC = matrix.c
|
|
||||||
|
|
|
@ -30,6 +30,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
/* matrix size */
|
/* matrix size */
|
||||||
#define MATRIX_ROWS 8
|
#define MATRIX_ROWS 8
|
||||||
#define MATRIX_COLS 15
|
#define MATRIX_COLS 15
|
||||||
|
#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 }
|
||||||
|
#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7 }
|
||||||
|
#define DIODE_DIRECTION COL2ROW
|
||||||
|
|
||||||
#define RGBLIGHT_ANIMATIONS
|
#define RGBLIGHT_ANIMATIONS
|
||||||
|
|
||||||
|
|
|
@ -1,122 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <avr/io.h>
|
|
||||||
#include <util/delay.h>
|
|
||||||
|
|
||||||
#include "matrix.h"
|
|
||||||
#include "backlight.h"
|
|
||||||
|
|
||||||
#ifndef DEBOUNCE
|
|
||||||
#define DEBOUNCE 5
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static uint8_t debouncing = DEBOUNCE;
|
|
||||||
|
|
||||||
static matrix_row_t matrix[MATRIX_ROWS];
|
|
||||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void matrix_init_user(void) {}
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void matrix_scan_user(void) {}
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void matrix_init_kb(void) {
|
|
||||||
matrix_init_user();
|
|
||||||
}
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void matrix_scan_kb(void) {
|
|
||||||
matrix_scan_user();
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_init(void) {
|
|
||||||
// all outputs for rows high
|
|
||||||
DDRB = 0xFF;
|
|
||||||
PORTB = 0xFF;
|
|
||||||
// all inputs for columns
|
|
||||||
DDRA = 0x00;
|
|
||||||
DDRC &= ~(0x111111<<2);
|
|
||||||
DDRD &= ~(1<<PIND7);
|
|
||||||
// all columns are pulled-up
|
|
||||||
PORTA = 0xFF;
|
|
||||||
PORTC |= (0b111111<<2);
|
|
||||||
PORTD |= (1<<PIND7);
|
|
||||||
|
|
||||||
// initialize matrix state: all keys off
|
|
||||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
|
||||||
matrix[row] = 0x00;
|
|
||||||
matrix_debouncing[row] = 0x00;
|
|
||||||
}
|
|
||||||
|
|
||||||
matrix_init_quantum();
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_set_row_status(uint8_t row) {
|
|
||||||
DDRB = (1 << row);
|
|
||||||
PORTB = ~(1 << row);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t bit_reverse(uint8_t x) {
|
|
||||||
x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa);
|
|
||||||
x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
|
|
||||||
x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0);
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t matrix_scan(void) {
|
|
||||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
|
||||||
matrix_set_row_status(row);
|
|
||||||
_delay_us(5);
|
|
||||||
|
|
||||||
matrix_row_t cols = (
|
|
||||||
// cols 0..7, PORTA 0 -> 7
|
|
||||||
(~PINA) & 0xFF
|
|
||||||
) | (
|
|
||||||
// cols 8..13, PORTC 7 -> 0
|
|
||||||
bit_reverse((~PINC) & 0xFF) << 8
|
|
||||||
) | (
|
|
||||||
// col 14, PORTD 7
|
|
||||||
((~PIND) & (1 << PIND7)) << 7
|
|
||||||
);
|
|
||||||
|
|
||||||
if (matrix_debouncing[row] != cols) {
|
|
||||||
matrix_debouncing[row] = cols;
|
|
||||||
debouncing = DEBOUNCE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (debouncing) {
|
|
||||||
if (--debouncing) {
|
|
||||||
_delay_ms(1);
|
|
||||||
} else {
|
|
||||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
|
||||||
matrix[i] = matrix_debouncing[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
matrix_scan_quantum();
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline matrix_row_t matrix_get_row(uint8_t row) {
|
|
||||||
return matrix[row];
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_print(void) {
|
|
||||||
}
|
|
|
@ -29,6 +29,4 @@ SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
|
||||||
|
|
||||||
OPT_DEFS = -DDEBUG_LEVEL=0
|
OPT_DEFS = -DDEBUG_LEVEL=0
|
||||||
|
|
||||||
# custom matrix setup
|
SRC += backlight.c
|
||||||
CUSTOM_MATRIX = yes
|
|
||||||
SRC = matrix.c backlight.c
|
|
||||||
|
|
|
@ -35,7 +35,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
/* matrix size */
|
/* matrix size */
|
||||||
#define MATRIX_ROWS 8
|
#define MATRIX_ROWS 8
|
||||||
#define MATRIX_COLS 15
|
#define MATRIX_COLS 15
|
||||||
#define DIODE_DIRECTION ROW2COL
|
#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 }
|
||||||
|
#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7 }
|
||||||
|
#define DIODE_DIRECTION COL2ROW
|
||||||
|
|
||||||
#define BACKLIGHT_LEVELS 12
|
#define BACKLIGHT_LEVELS 12
|
||||||
|
|
||||||
|
|
|
@ -1,108 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
|
|
||||||
Modified 2018 by Wayne K Jones <github.com/WarmCatUK>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <avr/io.h>
|
|
||||||
#include <util/delay.h>
|
|
||||||
|
|
||||||
#include "matrix.h"
|
|
||||||
|
|
||||||
#ifndef DEBOUNCE
|
|
||||||
# define DEBOUNCE 5
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static uint8_t debouncing = DEBOUNCE;
|
|
||||||
|
|
||||||
static matrix_row_t matrix[MATRIX_ROWS];
|
|
||||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
|
||||||
|
|
||||||
void matrix_init(void) {
|
|
||||||
// all outputs for rows high
|
|
||||||
DDRB = 0xFF;
|
|
||||||
PORTB = 0xFF;
|
|
||||||
// all inputs for columns
|
|
||||||
DDRA = 0x00;
|
|
||||||
DDRC &= ~(0x111111<<2);
|
|
||||||
DDRD &= ~(1<<PIND7);
|
|
||||||
// all columns are pulled-up
|
|
||||||
PORTA = 0xFF;
|
|
||||||
PORTC |= (0b111111<<2);
|
|
||||||
PORTD |= (1<<PIND7);
|
|
||||||
|
|
||||||
// initialize matrix state: all keys off
|
|
||||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
|
||||||
matrix[row] = 0x00;
|
|
||||||
matrix_debouncing[row] = 0x00;
|
|
||||||
}
|
|
||||||
matrix_init_quantum(); // missing from original port by Luiz
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_set_row_status(uint8_t row) {
|
|
||||||
DDRB = (1 << row);
|
|
||||||
PORTB = ~(1 << row);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t bit_reverse(uint8_t x) {
|
|
||||||
x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa);
|
|
||||||
x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
|
|
||||||
x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0);
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t matrix_scan(void) {
|
|
||||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
|
||||||
matrix_set_row_status(row);
|
|
||||||
_delay_us(5);
|
|
||||||
|
|
||||||
matrix_row_t cols = (
|
|
||||||
// cols 0..7, PORTA 0 -> 7
|
|
||||||
(~PINA) & 0xFF
|
|
||||||
) | (
|
|
||||||
// cols 8..13, PORTC 7 -> 0
|
|
||||||
bit_reverse((~PINC) & 0xFF) << 8
|
|
||||||
) | (
|
|
||||||
// col 14, PORTD 7
|
|
||||||
((~PIND) & (1 << PIND7)) << 7
|
|
||||||
);
|
|
||||||
|
|
||||||
if (matrix_debouncing[row] != cols) {
|
|
||||||
matrix_debouncing[row] = cols;
|
|
||||||
debouncing = DEBOUNCE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (debouncing) {
|
|
||||||
if (--debouncing) {
|
|
||||||
_delay_ms(1);
|
|
||||||
} else {
|
|
||||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
|
||||||
matrix[i] = matrix_debouncing[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
matrix_scan_quantum(); // also missing in original PS2AVRGB implementation
|
|
||||||
//matrix_scan_user();
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline matrix_row_t matrix_get_row(uint8_t row) {
|
|
||||||
return matrix[row];
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_print(void) {
|
|
||||||
}
|
|
|
@ -33,6 +33,4 @@ SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
|
||||||
|
|
||||||
#OPT_DEFS = -DDEBUG_LEVEL=0
|
#OPT_DEFS = -DDEBUG_LEVEL=0
|
||||||
|
|
||||||
# custom matrix setup
|
SRC = backlight.c
|
||||||
CUSTOM_MATRIX = yes
|
|
||||||
SRC = matrix.c backlight.c
|
|
||||||
|
|
|
@ -20,16 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "backlight.h"
|
#include "backlight.h"
|
||||||
#include "backlight_custom.h"
|
#include "backlight_custom.h"
|
||||||
|
|
||||||
void matrix_init_kb(void) { matrix_init_user(); }
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void matrix_init_user(void) {}
|
|
||||||
|
|
||||||
void matrix_scan_kb(void) { matrix_scan_user(); }
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void matrix_scan_user(void) {}
|
|
||||||
|
|
||||||
#ifdef BACKLIGHT_ENABLE
|
#ifdef BACKLIGHT_ENABLE
|
||||||
/// Overrides functions in `quantum.c`
|
/// Overrides functions in `quantum.c`
|
||||||
void backlight_init_ports(void) {
|
void backlight_init_ports(void) {
|
||||||
|
|
|
@ -25,8 +25,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "keycode.h"
|
#include "keycode.h"
|
||||||
#include "action.h"
|
#include "action.h"
|
||||||
|
|
||||||
void matrix_init_user(void);
|
|
||||||
|
|
||||||
#define LAYOUT( \
|
#define LAYOUT( \
|
||||||
K05, K25, K35, K45, K55, K06, KA6, KA7, K07, KB5, KC5, KD5, KE5, KD1, KE1, KE2, \
|
K05, K25, K35, K45, K55, K06, KA6, KA7, K07, KB5, KC5, KD5, KE5, KD1, KE1, KE2, \
|
||||||
K04, K14, K24, K34, K44, K54, K16, KB6, KB7, K17, KA4, KB4, KC4, KE4, KD0, \
|
K04, K14, K24, K34, K44, K54, K16, KB6, KB7, K17, KA4, KB4, KC4, KE4, KD0, \
|
||||||
|
|
|
@ -31,7 +31,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
/* matrix size */
|
/* matrix size */
|
||||||
#define MATRIX_ROWS 8
|
#define MATRIX_ROWS 8
|
||||||
#define MATRIX_COLS 15
|
#define MATRIX_COLS 15
|
||||||
//#define DIODE_DIRECTION ROW2COL
|
#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 }
|
||||||
|
#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7 }
|
||||||
|
|
||||||
//#define RGB_DI_PIN C4
|
//#define RGB_DI_PIN C4
|
||||||
/* COL2ROW or ROW2COL */
|
/* COL2ROW or ROW2COL */
|
||||||
|
|
|
@ -1,112 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <avr/io.h>
|
|
||||||
#include <util/delay.h>
|
|
||||||
|
|
||||||
#include "matrix.h"
|
|
||||||
|
|
||||||
#ifndef DEBOUNCE
|
|
||||||
# define DEBOUNCE 5
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static uint8_t debouncing = DEBOUNCE;
|
|
||||||
|
|
||||||
static matrix_row_t matrix[MATRIX_ROWS];
|
|
||||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
|
||||||
|
|
||||||
void matrix_set_row_status(uint8_t row);
|
|
||||||
uint8_t bit_reverse(uint8_t x);
|
|
||||||
|
|
||||||
void matrix_init(void) {
|
|
||||||
// all outputs for rows high
|
|
||||||
DDRB = 0xFF;
|
|
||||||
PORTB = 0xFF;
|
|
||||||
// all inputs for columns
|
|
||||||
DDRA = 0x00;
|
|
||||||
DDRC &= ~(0x111111<<2);
|
|
||||||
DDRD &= ~(1<<PIND7);
|
|
||||||
// all columns are pulled-up
|
|
||||||
PORTA = 0xFF;
|
|
||||||
PORTC |= (0b111111<<2);
|
|
||||||
PORTD |= (1<<PIND7);
|
|
||||||
|
|
||||||
// initialize matrix state: all keys off
|
|
||||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
|
||||||
matrix[row] = 0x00;
|
|
||||||
matrix_debouncing[row] = 0x00;
|
|
||||||
}
|
|
||||||
|
|
||||||
matrix_init_quantum(); // missing from original port by Luiz
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t matrix_scan(void) {
|
|
||||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
|
||||||
matrix_set_row_status(row);
|
|
||||||
_delay_us(5);
|
|
||||||
|
|
||||||
matrix_row_t cols = (
|
|
||||||
// cols 0..7, PORTA 0 -> 7
|
|
||||||
(~PINA) & 0xFF
|
|
||||||
) | (
|
|
||||||
// cols 8..13, PORTC 7 -> 0
|
|
||||||
bit_reverse((~PINC) & 0xFF) << 8
|
|
||||||
) | (
|
|
||||||
// col 14, PORTD 7
|
|
||||||
((~PIND) & (1 << PIND7)) << 7
|
|
||||||
);
|
|
||||||
|
|
||||||
if (matrix_debouncing[row] != cols) {
|
|
||||||
matrix_debouncing[row] = cols;
|
|
||||||
debouncing = DEBOUNCE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (debouncing) {
|
|
||||||
if (--debouncing) {
|
|
||||||
_delay_ms(1);
|
|
||||||
} else {
|
|
||||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
|
||||||
matrix[i] = matrix_debouncing[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
matrix_scan_quantum(); // also missing in original PS2AVRGB implementation
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// declarations
|
|
||||||
void matrix_set_row_status(uint8_t row) {
|
|
||||||
DDRB = (1 << row);
|
|
||||||
PORTB = ~(1 << row);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t bit_reverse(uint8_t x) {
|
|
||||||
x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa);
|
|
||||||
x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
|
|
||||||
x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0);
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline matrix_row_t matrix_get_row(uint8_t row) {
|
|
||||||
return matrix[row];
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_print(void) {
|
|
||||||
}
|
|
|
@ -31,6 +31,4 @@ SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
|
||||||
|
|
||||||
OPT_DEFS = -DDEBUG_LEVEL=0
|
OPT_DEFS = -DDEBUG_LEVEL=0
|
||||||
|
|
||||||
# custom matrix setup
|
SRC = backlight.c
|
||||||
CUSTOM_MATRIX = yes
|
|
||||||
SRC = matrix.c backlight.c
|
|
||||||
|
|
|
@ -21,16 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "backlight.h"
|
#include "backlight.h"
|
||||||
#include "backlight_custom.h"
|
#include "backlight_custom.h"
|
||||||
|
|
||||||
void matrix_init_kb(void) { matrix_init_user(); }
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void matrix_init_user(void) {}
|
|
||||||
|
|
||||||
void matrix_scan_kb(void) { matrix_scan_user(); }
|
|
||||||
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void matrix_scan_user(void) {}
|
|
||||||
|
|
||||||
#ifdef BACKLIGHT_ENABLE
|
#ifdef BACKLIGHT_ENABLE
|
||||||
/// Overrides functions in `quantum.c`
|
/// Overrides functions in `quantum.c`
|
||||||
void backlight_init_ports(void) {
|
void backlight_init_ports(void) {
|
||||||
|
|
|
@ -20,8 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
|
|
||||||
void matrix_init_user(void); // TODO port this to other PS2AVRGB boards
|
|
||||||
|
|
||||||
#define LAYOUT_default( \
|
#define LAYOUT_default( \
|
||||||
K50, K52, K53, K54, K55, K60, K6A, K7A, K70, K5B, K5C, K5D, K5E, K1D, K2E, K0D, K76, K79, K78, \
|
K50, K52, K53, K54, K55, K60, K6A, K7A, K70, K5B, K5C, K5D, K5E, K1D, K2E, K0D, K76, K79, K78, \
|
||||||
K40, K41, K42, K43, K44, K45, K61, K6B, K7B, K71, K4A, K4B, K4C, K4E, K46, K47, K48, K49, \
|
K40, K41, K42, K43, K44, K45, K61, K6B, K7B, K71, K4A, K4B, K4C, K4E, K46, K47, K48, K49, \
|
||||||
|
|
|
@ -34,6 +34,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7}
|
#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7}
|
||||||
#define UNUSED_PINS
|
#define UNUSED_PINS
|
||||||
|
|
||||||
|
#define DIODE_DIRECTION COL2ROW
|
||||||
|
|
||||||
#define NO_UART 1
|
#define NO_UART 1
|
||||||
|
|
||||||
#define BACKLIGHT_PIN D4
|
#define BACKLIGHT_PIN D4
|
||||||
|
|
|
@ -1,18 +1,3 @@
|
||||||
# Copyright 2019 Ethan Durrant (emdarcher)
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
# MCU name
|
# MCU name
|
||||||
MCU = atmega32a
|
MCU = atmega32a
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#define PRODUCT np21
|
#define PRODUCT np21
|
||||||
|
|
||||||
/* matrix size */
|
/* matrix size */
|
||||||
#define MATRIX_ROWS 8
|
#define MATRIX_ROWS 4
|
||||||
#define MATRIX_COLS 15
|
#define MATRIX_COLS 6
|
||||||
|
#define MATRIX_ROW_PINS { B0, B1, B2, B3 }
|
||||||
|
#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5 }
|
||||||
|
|
||||||
/* COL2ROW or ROW2COL */
|
/* COL2ROW or ROW2COL */
|
||||||
#define DIODE_DIRECTION COL2ROW
|
#define DIODE_DIRECTION COL2ROW
|
||||||
|
|
|
@ -1,129 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <avr/io.h>
|
|
||||||
#include <util/delay.h>
|
|
||||||
|
|
||||||
#include "matrix.h"
|
|
||||||
|
|
||||||
#ifndef DEBOUNCE
|
|
||||||
# define DEBOUNCE 5
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static uint8_t debouncing = DEBOUNCE;
|
|
||||||
|
|
||||||
static matrix_row_t matrix[MATRIX_ROWS];
|
|
||||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
|
||||||
|
|
||||||
void matrix_set_row_status(uint8_t row);
|
|
||||||
uint8_t bit_reverse(uint8_t x);
|
|
||||||
|
|
||||||
void matrix_init(void) {
|
|
||||||
// all outputs for rows high
|
|
||||||
DDRB = 0xFF;
|
|
||||||
PORTB = 0xFF;
|
|
||||||
// all inputs for columns
|
|
||||||
DDRA = 0x00;
|
|
||||||
DDRC &= ~(0x111111<<2);
|
|
||||||
DDRD &= ~(1<<PIND7);
|
|
||||||
// all columns are pulled-up
|
|
||||||
PORTA = 0xFF;
|
|
||||||
PORTC |= (0b111111<<2);
|
|
||||||
PORTD |= (1<<PIND7);
|
|
||||||
|
|
||||||
// initialize matrix state: all keys off
|
|
||||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
|
||||||
matrix[row] = 0x00;
|
|
||||||
matrix_debouncing[row] = 0x00;
|
|
||||||
}
|
|
||||||
|
|
||||||
matrix_init_quantum(); // missing from original port by Luiz
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t matrix_scan(void) {
|
|
||||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
|
||||||
matrix_set_row_status(row);
|
|
||||||
_delay_us(5);
|
|
||||||
|
|
||||||
matrix_row_t cols = (
|
|
||||||
// cols 0..7, PORTA 0 -> 7
|
|
||||||
(~PINA) & 0xFF
|
|
||||||
) | (
|
|
||||||
// cols 8..13, PORTC 7 -> 0
|
|
||||||
bit_reverse((~PINC) & 0xFF) << 8
|
|
||||||
) | (
|
|
||||||
// col 14, PORTD 7
|
|
||||||
((~PIND) & (1 << PIND7)) << 7
|
|
||||||
);
|
|
||||||
|
|
||||||
if (matrix_debouncing[row] != cols) {
|
|
||||||
matrix_debouncing[row] = cols;
|
|
||||||
debouncing = DEBOUNCE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (debouncing) {
|
|
||||||
if (--debouncing) {
|
|
||||||
_delay_ms(1);
|
|
||||||
} else {
|
|
||||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
|
||||||
matrix[i] = matrix_debouncing[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
matrix_scan_quantum(); // also missing in original PS2AVRGB implementation
|
|
||||||
|
|
||||||
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);
|
|
||||||
PORTB = ~(1 << row);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t bit_reverse(uint8_t x) {
|
|
||||||
x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa);
|
|
||||||
x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
|
|
||||||
x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0);
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline matrix_row_t matrix_get_row(uint8_t row) {
|
|
||||||
return matrix[row];
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_print(void) {
|
|
||||||
}
|
|
|
@ -31,6 +31,4 @@ SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
|
||||||
|
|
||||||
OPT_DEFS = -DDEBUG_LEVEL=0
|
OPT_DEFS = -DDEBUG_LEVEL=0
|
||||||
|
|
||||||
# custom matrix setup
|
SRC = backlight.c
|
||||||
CUSTOM_MATRIX = yes
|
|
||||||
SRC = matrix.c backlight.c
|
|
||||||
|
|
|
@ -23,8 +23,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "keycode.h"
|
#include "keycode.h"
|
||||||
#include "action.h"
|
#include "action.h"
|
||||||
|
|
||||||
void matrix_init_user(void); // TODO port this to other PS2AVRGB boards
|
|
||||||
|
|
||||||
#define LAYOUT( \
|
#define LAYOUT( \
|
||||||
K01, K02, K03, K04, K05, K06, \
|
K01, K02, K03, K04, K05, K06, \
|
||||||
K11, K12, K13, K14, K15, K16, \
|
K11, K12, K13, K14, K15, K16, \
|
||||||
|
|
Loading…
Reference in a new issue