Compare commits
6 Commits
master
...
pr-5-tompi
| Author | SHA1 | Date | |
|---|---|---|---|
| aaa8ff017d | |||
| 4ffaaf42af | |||
| c9c6d33b85 | |||
| 019a0d941a | |||
| 92af2e26a4 | |||
| 0c363cd93a |
@@ -0,0 +1,214 @@
|
|||||||
|
#include "matrix.h"
|
||||||
|
#include "quantum.h"
|
||||||
|
#include "print.h"
|
||||||
|
|
||||||
|
#include QMK_KEYBOARD_H
|
||||||
|
|
||||||
|
// This is to keep state between callbacks, when it is 0 the
|
||||||
|
// initial RGB flash is finished
|
||||||
|
uint8_t _hue_countdown = 50;
|
||||||
|
|
||||||
|
// These are to keep track of user selected color, so we
|
||||||
|
// can restore it after RGB flash
|
||||||
|
uint8_t _hue;
|
||||||
|
uint8_t _saturation;
|
||||||
|
uint8_t _value;
|
||||||
|
|
||||||
|
// Do a little 2.5 seconds display of the different colors
|
||||||
|
// Use the deferred executor so the LED flash dance does not
|
||||||
|
// stop us from using the keyboard.
|
||||||
|
// https://docs.qmk.fm/#/custom_quantum_functions?id=deferred-executor-registration
|
||||||
|
uint32_t flash_led(uint32_t next_trigger_time, void *cb_arg) {
|
||||||
|
rgblight_sethsv(_hue_countdown * 5, 230, 70);
|
||||||
|
_hue_countdown--;
|
||||||
|
if (_hue_countdown == 0) {
|
||||||
|
// Finished, reset to user chosen led color
|
||||||
|
rgblight_sethsv(_hue, _saturation, _value);
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return 50;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void keyboard_post_init_kb(void) {
|
||||||
|
// debug_enable=true;
|
||||||
|
// debug_matrix=true;
|
||||||
|
// debug_keyboard=true;
|
||||||
|
// debug_mouse=true;
|
||||||
|
|
||||||
|
// Store user selected rgb hsv:
|
||||||
|
_hue = rgblight_get_hue();
|
||||||
|
_saturation = rgblight_get_sat();
|
||||||
|
_value = rgblight_get_val();
|
||||||
|
|
||||||
|
// Flash a little on start
|
||||||
|
defer_exec(50, flash_led, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is just to be able to declare constants as they appear in the qmk console
|
||||||
|
#define rev(b) \
|
||||||
|
((b & 1) << 15) | \
|
||||||
|
((b & (1 << 1)) << 13) | \
|
||||||
|
((b & (1 << 2)) << 11) | \
|
||||||
|
((b & (1 << 3)) << 9) | \
|
||||||
|
((b & (1 << 4)) << 7) | \
|
||||||
|
((b & (1 << 5)) << 5) | \
|
||||||
|
((b & (1 << 6)) << 3) | \
|
||||||
|
((b & (1 << 7)) << 1) | \
|
||||||
|
((b & (1 << 8)) >> 1) | \
|
||||||
|
((b & (1 << 9)) >> 3) | \
|
||||||
|
((b & (1 << 10)) >> 5) | \
|
||||||
|
((b & (1 << 11)) >> 7) | \
|
||||||
|
((b & (1 << 12)) >> 9) | \
|
||||||
|
((b & (1 << 13)) >> 11) | \
|
||||||
|
((b & (1 << 14)) >> 13) | \
|
||||||
|
b >> 15
|
||||||
|
|
||||||
|
/* This is for debugging the matrix rows
|
||||||
|
void printBits(uint16_t n)
|
||||||
|
{
|
||||||
|
long i;
|
||||||
|
for (i = 15; i >= 0; i--) {
|
||||||
|
if ((n & (1 << i)) != 0) {
|
||||||
|
printf("1");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("0");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool bit_pattern_set(uint16_t number, uint16_t bitPattern) {
|
||||||
|
return !(~number & bitPattern);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fix_ghosting_instance(
|
||||||
|
matrix_row_t current_matrix[],
|
||||||
|
unsigned short row_num_with_possible_error_cause,
|
||||||
|
uint16_t possible_error_cause,
|
||||||
|
unsigned short row_num_with_possible_error,
|
||||||
|
uint16_t possible_error,
|
||||||
|
uint16_t error_fix) {
|
||||||
|
if (bit_pattern_set(current_matrix[row_num_with_possible_error_cause], possible_error_cause)) {
|
||||||
|
if (bit_pattern_set(current_matrix[row_num_with_possible_error], possible_error)) {
|
||||||
|
current_matrix[row_num_with_possible_error] = current_matrix[row_num_with_possible_error] ^ error_fix;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void fix_ghosting_column(
|
||||||
|
matrix_row_t matrix[],
|
||||||
|
uint16_t possible_error_cause,
|
||||||
|
uint16_t possible_error,
|
||||||
|
uint16_t error_fix) {
|
||||||
|
// First the right side
|
||||||
|
for (short i = 0; i<3; i++) {
|
||||||
|
fix_ghosting_instance(matrix, i, possible_error_cause, (i+1)%3, possible_error, error_fix);
|
||||||
|
fix_ghosting_instance(matrix, i, possible_error_cause, (i+2)%3, possible_error, error_fix);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Then exactly same procedure on the left side
|
||||||
|
for (short i = 0; i<3; i++) {
|
||||||
|
fix_ghosting_instance(matrix, i+4, possible_error_cause<<6, 4+((i+1)%3), possible_error<<6, error_fix<<6);
|
||||||
|
fix_ghosting_instance(matrix, i+4, possible_error_cause<<6, 4+((i+2)%3), possible_error<<6, error_fix<<6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// For QWERTY layout, key combo a+s+e also outputs q. This suppresses the q, and other similar ghosts
|
||||||
|
// These are observed ghosts(following a pattern). TODO: need to fix this for v3
|
||||||
|
// Might need to add 2 diodes(one in each direction) for every row, to increase voltage drop.
|
||||||
|
void fix_ghosting(matrix_row_t matrix[]) {
|
||||||
|
fix_ghosting_column(matrix,
|
||||||
|
rev(0B0110000000000000),
|
||||||
|
rev(0B1010000000000000),
|
||||||
|
rev(0B0010000000000000));
|
||||||
|
fix_ghosting_column(matrix,
|
||||||
|
rev(0B0110000000000000),
|
||||||
|
rev(0B0101000000000000),
|
||||||
|
rev(0B0100000000000000));
|
||||||
|
|
||||||
|
fix_ghosting_column(matrix,
|
||||||
|
rev(0B0001100000000000),
|
||||||
|
rev(0B0010100000000000),
|
||||||
|
rev(0B0000100000000000));
|
||||||
|
fix_ghosting_column(matrix,
|
||||||
|
rev(0B0001100000000000),
|
||||||
|
rev(0B0001010000000000),
|
||||||
|
rev(0B0001000000000000));
|
||||||
|
|
||||||
|
fix_ghosting_column(matrix,
|
||||||
|
rev(0B1000010000000000),
|
||||||
|
rev(0B1000100000000000),
|
||||||
|
rev(0B1000000000000000));
|
||||||
|
fix_ghosting_column(matrix,
|
||||||
|
rev(0B1000010000000000),
|
||||||
|
rev(0B0100010000000000),
|
||||||
|
rev(0B0000010000000000));
|
||||||
|
|
||||||
|
fix_ghosting_column(matrix,
|
||||||
|
rev(0B1001000000000000),
|
||||||
|
rev(0B0101000000000000),
|
||||||
|
rev(0B0001000000000000));
|
||||||
|
fix_ghosting_column(matrix,
|
||||||
|
rev(0B1001000000000000),
|
||||||
|
rev(0B1010000000000000),
|
||||||
|
rev(0B1000000000000000));
|
||||||
|
|
||||||
|
fix_ghosting_column(matrix,
|
||||||
|
rev(0B0100100000000000),
|
||||||
|
rev(0B0100010000000000),
|
||||||
|
rev(0B0100000000000000));
|
||||||
|
fix_ghosting_column(matrix,
|
||||||
|
rev(0B0100100000000000),
|
||||||
|
rev(0B1000100000000000),
|
||||||
|
rev(0B0000100000000000));
|
||||||
|
}
|
||||||
|
|
||||||
|
void encoder_driver_task(void) {
|
||||||
|
// This is intentionally left empty to disable the default encoder driver.
|
||||||
|
// We inject events manually below.
|
||||||
|
}
|
||||||
|
|
||||||
|
// There aren't enough pins on the RJ45 for dedicated encoder pins. Use matrix
|
||||||
|
// intersections instead.
|
||||||
|
void fix_encoder_action(matrix_row_t current_matrix[]) {
|
||||||
|
static const int ENC_ROW = 3;
|
||||||
|
static const int ENC_A_COL = 2;
|
||||||
|
static const int ENC_B_COL = 4;
|
||||||
|
// The button column is unused here and handled through the keymap instead.
|
||||||
|
// static const int ENC_BUTTON_COL = 0;
|
||||||
|
static const matrix_row_t ENC_A_BIT = (1 << ENC_A_COL);
|
||||||
|
static const matrix_row_t ENC_B_BIT = (1 << ENC_B_COL);
|
||||||
|
|
||||||
|
// State machine tracking.
|
||||||
|
static bool colABPressed = false;
|
||||||
|
|
||||||
|
// Check which way the encoder is turned:
|
||||||
|
matrix_row_t encoder_row = current_matrix[ENC_ROW];
|
||||||
|
bool colA = encoder_row & ENC_A_BIT;
|
||||||
|
bool colB = encoder_row & ENC_B_BIT;
|
||||||
|
|
||||||
|
extern bool encoder_queue_event(uint8_t, bool);
|
||||||
|
if (colA && colB) {
|
||||||
|
colABPressed = true;
|
||||||
|
} else if (colA) {
|
||||||
|
if (colABPressed) {
|
||||||
|
// A+B followed by A means clockwise
|
||||||
|
colABPressed = false;
|
||||||
|
encoder_queue_event(0, true);
|
||||||
|
}
|
||||||
|
} else if (colB) {
|
||||||
|
if (colABPressed) {
|
||||||
|
// A+B followed by B means counter-clockwise
|
||||||
|
colABPressed = false;
|
||||||
|
encoder_queue_event(0, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear A+B bits, and leave the button bits intact; it will be picked up
|
||||||
|
// by normal matrix/keymap processing.
|
||||||
|
static const matrix_row_t ROW_MASK = ~(ENC_A_BIT | ENC_B_BIT);
|
||||||
|
current_matrix[ENC_ROW] = encoder_row & ROW_MASK;
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// Copyright 2023 Thomas Haukland (@tompi)
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Force the usage of PIO1 peripheral, by default the WS2812 implementation uses the PIO0 peripheral.
|
||||||
|
#define WS2812_PIO_USE_PIO1
|
||||||
|
#define WS2812_BYTE_ORDER WS2812_BYTE_ORDER_RGB
|
||||||
@@ -0,0 +1,137 @@
|
|||||||
|
{
|
||||||
|
"manufacturer": "Thomas Haukland",
|
||||||
|
"keyboard_name": "cheapino2",
|
||||||
|
"maintainer": "tompi",
|
||||||
|
"bootloader": "rp2040",
|
||||||
|
"diode_direction": "ROW2COL",
|
||||||
|
"ws2812": {
|
||||||
|
"driver": "vendor",
|
||||||
|
"pin": "GP16"
|
||||||
|
},
|
||||||
|
"features": {
|
||||||
|
"bootmagic": true,
|
||||||
|
"caps_word": true,
|
||||||
|
"command": false,
|
||||||
|
"console": false,
|
||||||
|
"deferred_exec": true,
|
||||||
|
"encoder": true,
|
||||||
|
"extrakey": true,
|
||||||
|
"mousekey": true,
|
||||||
|
"nkro": false,
|
||||||
|
"rgblight": true
|
||||||
|
},
|
||||||
|
"tapping": {
|
||||||
|
"term": 230
|
||||||
|
},
|
||||||
|
"caps_word": {
|
||||||
|
"both_shifts_turns_on": true
|
||||||
|
},
|
||||||
|
"encoder": {
|
||||||
|
"_comment0": "These are unused but have to be defined. The encoder is",
|
||||||
|
"_comment1": "actually handled by matrix intersections; see encoder.c",
|
||||||
|
"rotary": [
|
||||||
|
{
|
||||||
|
"pin_a": "GP9",
|
||||||
|
"pin_b": "GP10"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rgblight": {
|
||||||
|
"led_count": 1,
|
||||||
|
"default": {
|
||||||
|
"hue": 128,
|
||||||
|
"sat": 128,
|
||||||
|
"val": 64
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"matrix_pins": {
|
||||||
|
"custom": true,
|
||||||
|
"custom_lite": true,
|
||||||
|
"cols": [
|
||||||
|
"GP6",
|
||||||
|
"GP6",
|
||||||
|
"GP5",
|
||||||
|
"GP5",
|
||||||
|
"GP4",
|
||||||
|
"GP4",
|
||||||
|
|
||||||
|
"GP14",
|
||||||
|
"GP14",
|
||||||
|
"GP15",
|
||||||
|
"GP15",
|
||||||
|
"GP26",
|
||||||
|
"GP26"
|
||||||
|
],
|
||||||
|
"rows": [
|
||||||
|
"GP3",
|
||||||
|
"GP1",
|
||||||
|
"GP2",
|
||||||
|
"GP0",
|
||||||
|
"GP27",
|
||||||
|
"GP28",
|
||||||
|
"GP29",
|
||||||
|
"GP8"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"processor": "RP2040",
|
||||||
|
"url": "",
|
||||||
|
"usb": {
|
||||||
|
"device_version": "1.0.0",
|
||||||
|
"pid": "0x0000",
|
||||||
|
"vid": "0xFEE3"
|
||||||
|
},
|
||||||
|
"layouts": {
|
||||||
|
"LAYOUT_split_3x5_3": {
|
||||||
|
"layout": [
|
||||||
|
{ "matrix": [4, 10], "x": 0, "y": 0.25 },
|
||||||
|
{ "matrix": [4, 9], "x": 1, "y": 0.125 },
|
||||||
|
{ "matrix": [4, 8], "x": 2, "y": 0 },
|
||||||
|
{ "matrix": [4, 7], "x": 3, "y": 0.125 },
|
||||||
|
{ "matrix": [4, 6], "x": 4, "y": 0.25 },
|
||||||
|
|
||||||
|
{ "matrix": [3, 0], "x": 6, "y": 0.25 },
|
||||||
|
|
||||||
|
{ "matrix": [0, 0], "x": 7, "y": 0.25 },
|
||||||
|
{ "matrix": [0, 1], "x": 8, "y": 0.125 },
|
||||||
|
{ "matrix": [0, 2], "x": 9, "y": 0 },
|
||||||
|
{ "matrix": [0, 3], "x": 10, "y": 0.125 },
|
||||||
|
{ "matrix": [0, 4], "x": 11, "y": 0.25 },
|
||||||
|
|
||||||
|
|
||||||
|
{ "matrix": [5, 10], "x": 0, "y": 1.25 },
|
||||||
|
{ "matrix": [5, 9], "x": 1, "y": 1.125 },
|
||||||
|
{ "matrix": [5, 8], "x": 2, "y": 1 },
|
||||||
|
{ "matrix": [5, 7], "x": 3, "y": 1.125 },
|
||||||
|
{ "matrix": [5, 6], "x": 4, "y": 1.25 },
|
||||||
|
|
||||||
|
{ "matrix": [1, 0], "x": 7, "y": 1.25 },
|
||||||
|
{ "matrix": [1, 1], "x": 8, "y": 1.125 },
|
||||||
|
{ "matrix": [1, 2], "x": 9, "y": 1 },
|
||||||
|
{ "matrix": [1, 3], "x": 10, "y": 1.125 },
|
||||||
|
{ "matrix": [1, 4], "x": 11, "y": 1.25 },
|
||||||
|
|
||||||
|
|
||||||
|
{ "matrix": [6, 10], "x": 0, "y": 2.25 },
|
||||||
|
{ "matrix": [6, 9], "x": 1, "y": 2.125 },
|
||||||
|
{ "matrix": [6, 8], "x": 2, "y": 2 },
|
||||||
|
{ "matrix": [6, 7], "x": 3, "y": 2.125 },
|
||||||
|
{ "matrix": [6, 6], "x": 4, "y": 2.25 },
|
||||||
|
|
||||||
|
{ "matrix": [2, 0], "x": 7, "y": 2.25 },
|
||||||
|
{ "matrix": [2, 1], "x": 8, "y": 2.125 },
|
||||||
|
{ "matrix": [2, 2], "x": 9, "y": 2 },
|
||||||
|
{ "matrix": [2, 3], "x": 10, "y": 2.125 },
|
||||||
|
{ "matrix": [2, 4], "x": 11, "y": 2.25 },
|
||||||
|
|
||||||
|
|
||||||
|
{ "matrix": [6, 11], "x": 2.5, "y": 3.25 },
|
||||||
|
{ "matrix": [5, 11], "x": 3.5, "y": 3.5 },
|
||||||
|
{ "matrix": [4, 11], "x": 4.5, "y": 3.75 },
|
||||||
|
|
||||||
|
{ "matrix": [0, 5], "x": 6.5, "y": 3.75 },
|
||||||
|
{ "matrix": [1, 5], "x": 7.5, "y": 3.5 },
|
||||||
|
{ "matrix": [2, 5], "x": 8.5, "y": 3.25 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,148 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2012 Jun Wako <wakojun@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/>.
|
||||||
|
|
||||||
|
Copied from here: https://github.com/e3w2q/qmk_firmware/blob/762fe3e0a7cbea768245a75520f06ff5a2f00b9f/keyboards/2x3test/matrix.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* scan matrix
|
||||||
|
*/
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include "wait.h"
|
||||||
|
#include "util.h"
|
||||||
|
#include "matrix.h"
|
||||||
|
#include "config.h"
|
||||||
|
#include "quantum.h"
|
||||||
|
#include "debounce.h"
|
||||||
|
#include "print.h"
|
||||||
|
|
||||||
|
// How long the scanning code waits for changed io to settle.
|
||||||
|
// Adjust from default 30 to weigh up for increased time spent ghost-hunting.
|
||||||
|
// (the rp2040 does not seem to have any problems with this value...)
|
||||||
|
#define MATRIX_IO_DELAY 25
|
||||||
|
|
||||||
|
#define COL_SHIFTER ((uint16_t)1)
|
||||||
|
|
||||||
|
static const pin_t row_pins[] = MATRIX_ROW_PINS;
|
||||||
|
static const pin_t col_pins[] = MATRIX_COL_PINS;
|
||||||
|
static matrix_row_t previous_matrix[MATRIX_ROWS];
|
||||||
|
|
||||||
|
static void select_row(uint8_t row) {
|
||||||
|
setPinOutput(row_pins[row]);
|
||||||
|
writePinLow(row_pins[row]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void unselect_row(uint8_t row) { setPinInputHigh(row_pins[row]); }
|
||||||
|
|
||||||
|
static void unselect_rows(void) {
|
||||||
|
for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
|
||||||
|
setPinInputHigh(row_pins[x]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void select_col(uint8_t col) {
|
||||||
|
setPinOutput(col_pins[col]);
|
||||||
|
writePinLow(col_pins[col]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void unselect_col(uint8_t col) {
|
||||||
|
setPinInputHigh(col_pins[col]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void unselect_cols(void) {
|
||||||
|
for (uint8_t x = 0; x < MATRIX_COLS/2; x++) {
|
||||||
|
setPinInputHigh(col_pins[x*2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) {
|
||||||
|
// Select row and wait for row selection to stabilize
|
||||||
|
select_row(current_row);
|
||||||
|
wait_us(MATRIX_IO_DELAY);
|
||||||
|
|
||||||
|
// For each col...
|
||||||
|
for (uint8_t col_index = 0; col_index < MATRIX_COLS / 2; col_index++) {
|
||||||
|
uint16_t column_index_bitmask = COL_SHIFTER << ((col_index * 2) + 1);
|
||||||
|
// Check row pin state
|
||||||
|
if (readPin(col_pins[col_index*2])) {
|
||||||
|
// Pin HI, clear col bit
|
||||||
|
current_matrix[current_row] &= ~column_index_bitmask;
|
||||||
|
} else {
|
||||||
|
// Pin LO, set col bit
|
||||||
|
current_matrix[current_row] |= column_index_bitmask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unselect row
|
||||||
|
unselect_row(current_row);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) {
|
||||||
|
// Select col and wait for col selection to stabilize
|
||||||
|
select_col(current_col*2);
|
||||||
|
wait_us(MATRIX_IO_DELAY);
|
||||||
|
|
||||||
|
uint16_t column_index_bitmask = COL_SHIFTER << (current_col * 2);
|
||||||
|
// For each row...
|
||||||
|
for (uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++) {
|
||||||
|
// Check row pin state
|
||||||
|
if (readPin(row_pins[row_index])) {
|
||||||
|
// Pin HI, clear col bit
|
||||||
|
current_matrix[row_index] &= ~column_index_bitmask;
|
||||||
|
} else {
|
||||||
|
// Pin LO, set col bit
|
||||||
|
current_matrix[row_index] |= column_index_bitmask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Unselect col
|
||||||
|
unselect_col(current_col*2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void matrix_init_custom(void) {
|
||||||
|
// initialize key pins
|
||||||
|
unselect_cols();
|
||||||
|
unselect_rows();
|
||||||
|
debounce_init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void store_old_matrix(matrix_row_t current_matrix[]) {
|
||||||
|
memcpy(previous_matrix, current_matrix, MATRIX_ROWS * sizeof(matrix_row_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool has_matrix_changed(matrix_row_t current_matrix[]) {
|
||||||
|
return memcmp(previous_matrix, current_matrix, MATRIX_ROWS * sizeof(matrix_row_t)) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool matrix_scan_custom(matrix_row_t current_matrix[]) {
|
||||||
|
extern void fix_encoder_action(matrix_row_t current_matrix[]);
|
||||||
|
extern void fix_ghosting(matrix_row_t matrix[]);
|
||||||
|
|
||||||
|
store_old_matrix(current_matrix);
|
||||||
|
// Set row, read cols
|
||||||
|
for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) {
|
||||||
|
read_cols_on_row(current_matrix, current_row);
|
||||||
|
}
|
||||||
|
// Set col, read rows
|
||||||
|
for (uint8_t current_col = 0; current_col < MATRIX_COLS/2; current_col++) {
|
||||||
|
read_rows_on_col(current_matrix, current_col);
|
||||||
|
}
|
||||||
|
|
||||||
|
fix_encoder_action(current_matrix);
|
||||||
|
|
||||||
|
fix_ghosting(current_matrix);
|
||||||
|
|
||||||
|
return has_matrix_changed(current_matrix);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include_next <mcuconf.h>
|
||||||
|
|
||||||
|
#undef RP_I2C_USE_I2C1
|
||||||
|
#define RP_I2C_USE_I2C1 TRUE
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
# cheapino
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
*A short description of the keyboard/project*
|
||||||
|
|
||||||
|
* Keyboard Maintainer: [Thomas Haukland](https://github.com/tompi)
|
||||||
|
* Hardware Supported: pcb v2 with RP2040-Zero MCU
|
||||||
|
* Hardware Availability: https://github.com/tompi/cheapino
|
||||||
|
|
||||||
|
Make example for this keyboard (after setting up your build environment):
|
||||||
|
|
||||||
|
make cheapino:default
|
||||||
|
|
||||||
|
Flashing example for this keyboard:
|
||||||
|
|
||||||
|
make cheapino:default:flash
|
||||||
|
|
||||||
|
See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
|
||||||
|
|
||||||
|
## Bootloader
|
||||||
|
|
||||||
|
Enter the bootloader in 3 ways:
|
||||||
|
|
||||||
|
* **Bootmagic reset**: Hold down the key at (0,0) in the matrix (usually the top left key or Escape) and plug in the keyboard
|
||||||
|
* **Physical reset button**: Briefly press the button on the back of the PCB - some may have pads you must short instead
|
||||||
|
* **Keycode in layout**: Press the key mapped to `QK_BOOT` if it is available
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
SRC += matrix.c
|
||||||
Reference in New Issue
Block a user