The cheapino works, except for the encoder

This commit is contained in:
Thomas Haukland 2023-03-22 22:47:54 +01:00
parent 3e94864262
commit 2fa3131f76
5 changed files with 478 additions and 36 deletions

View File

@ -18,3 +18,12 @@
//#define NO_ACTION_LAYER
//#define NO_ACTION_TAPPING
//#define NO_ACTION_ONESHOT
#define BOTH_SHIFTS_TURNS_ON_CAPS_WORD
// Pick good defaults for enabling homerow modifiers
#define TAPPING_TERM 230
// #define PERMISSIVE_HOLD
#define IGNORE_MOD_TAP_INTERRUPT
#define TAPPING_FORCE_HOLD
//#define RETRO_TAPPING

View File

@ -3,7 +3,7 @@
"keyboard_name": "cheapino",
"maintainer": "tompi",
"bootloader": "rp2040",
"diode_direction": "COL2ROW",
"diode_direction": "ROW2COL",
"features": {
"bootmagic": true,
"command": false,
@ -13,7 +13,7 @@
"nkro": false
},
"matrix_pins": {
"cols": ["GP0", "GP0", "GP1", "GP1", "GP2", "GP2", "GP3", "GP3", "GP29", "GP29", "GP28", "GP28", "GP27", "GP27"],
"cols": ["GP0", "GP0", "GP1", "GP1", "GP2", "GP2", "GP29", "GP29", "GP28", "GP28", "GP27", "GP27"],
"rows": ["GP6", "GP5", "GP4", "GP3"]
},
"processor": "RP2040",
@ -26,42 +26,42 @@
"layouts": {
"LAYOUT_split_3x5_3": {
"layout": [
{ "matrix": [0, 0], "x": 0, "y": 0.25 },
{ "matrix": [0, 1], "x": 1, "y": 0.125 },
{ "matrix": [0, 4], "x": 0, "y": 0.25 },
{ "matrix": [0, 3], "x": 1, "y": 0.125 },
{ "matrix": [0, 2], "x": 2, "y": 0 },
{ "matrix": [0, 3], "x": 3, "y": 0.125 },
{ "matrix": [0, 4], "x": 4, "y": 0.25 },
{ "matrix": [0, 7], "x": 7, "y": 0.25 },
{ "matrix": [0, 8], "x": 8, "y": 0.125 },
{ "matrix": [0, 9], "x": 9, "y": 0 },
{ "matrix": [0, 10], "x": 10, "y": 0.125 },
{ "matrix": [0, 11], "x": 11, "y": 0.25 },
{ "matrix": [1, 0], "x": 0, "y": 1.25 },
{ "matrix": [1, 1], "x": 1, "y": 1.125 },
{ "matrix": [0, 1], "x": 3, "y": 0.125 },
{ "matrix": [0, 0], "x": 4, "y": 0.25 },
{ "matrix": [2, 6], "x": 7, "y": 0.25 },
{ "matrix": [2, 7], "x": 8, "y": 0.125 },
{ "matrix": [2, 8], "x": 9, "y": 0 },
{ "matrix": [2, 9], "x": 10, "y": 0.125 },
{ "matrix": [2, 10], "x": 11, "y": 0.25 },
{ "matrix": [1, 4], "x": 0, "y": 1.25 },
{ "matrix": [1, 3], "x": 1, "y": 1.125 },
{ "matrix": [1, 2], "x": 2, "y": 1 },
{ "matrix": [1, 3], "x": 3, "y": 1.125 },
{ "matrix": [1, 4], "x": 4, "y": 1.25 },
{ "matrix": [1, 7], "x": 7, "y": 1.25 },
{ "matrix": [1, 8], "x": 8, "y": 1.125 },
{ "matrix": [1, 9], "x": 9, "y": 1 },
{ "matrix": [1, 10], "x": 10, "y": 1.125 },
{ "matrix": [1, 11], "x": 11, "y": 1.25 },
{ "matrix": [2, 0], "x": 0, "y": 2.25 },
{ "matrix": [2, 1], "x": 1, "y": 2.125 },
{ "matrix": [1, 1], "x": 3, "y": 1.125 },
{ "matrix": [1, 0], "x": 4, "y": 1.25 },
{ "matrix": [1, 6], "x": 7, "y": 1.25 },
{ "matrix": [1, 7], "x": 8, "y": 1.125 },
{ "matrix": [1, 8], "x": 9, "y": 1 },
{ "matrix": [1, 9], "x": 10, "y": 1.125 },
{ "matrix": [1, 10], "x": 11, "y": 1.25 },
{ "matrix": [2, 4], "x": 0, "y": 2.25 },
{ "matrix": [2, 3], "x": 1, "y": 2.125 },
{ "matrix": [2, 2], "x": 2, "y": 2 },
{ "matrix": [2, 3], "x": 3, "y": 2.125 },
{ "matrix": [2, 4], "x": 4, "y": 2.25 },
{ "matrix": [2, 7], "x": 7, "y": 2.25 },
{ "matrix": [2, 8], "x": 8, "y": 2.125 },
{ "matrix": [2, 9], "x": 9, "y": 2 },
{ "matrix": [2, 10], "x": 10, "y": 2.125 },
{ "matrix": [2, 11], "x": 11, "y": 2.25 },
{ "matrix": [3, 2], "x": 2.5, "y": 3.25 },
{ "matrix": [3, 3], "x": 3.5, "y": 3.5 },
{ "matrix": [3, 4], "x": 4.5, "y": 3.75 },
{ "matrix": [3, 6], "x": 6.5, "y": 3.75 },
{ "matrix": [3, 7], "x": 7.5, "y": 3.5 },
{ "matrix": [3, 8], "x": 8.5, "y": 3.25 }
{ "matrix": [2, 1], "x": 3, "y": 2.125 },
{ "matrix": [2, 0], "x": 4, "y": 2.25 },
{ "matrix": [0, 6], "x": 7, "y": 2.25 },
{ "matrix": [0, 7], "x": 8, "y": 2.125 },
{ "matrix": [0, 8], "x": 9, "y": 2 },
{ "matrix": [0, 9], "x": 10, "y": 2.125 },
{ "matrix": [0, 10], "x": 11, "y": 2.25 },
{ "matrix": [2, 5], "x": 2.5, "y": 3.25 },
{ "matrix": [1, 5], "x": 3.5, "y": 3.5 },
{ "matrix": [0, 5], "x": 4.5, "y": 3.75 },
{ "matrix": [2, 11], "x": 6.5, "y": 3.75 },
{ "matrix": [1, 11], "x": 7.5, "y": 3.5 },
{ "matrix": [0, 11], "x": 8.5, "y": 3.25 }
]
}
}

View File

@ -0,0 +1,277 @@
{
"version": 1,
"notes": "My awesome keymap",
"documentation": "\"This file is a QMK Configurator export. You can import this at <https://config.qmk.fm>. It can also be used directly with QMK's source code.\n\nTo setup your QMK environment check out the tutorial: <https://docs.qmk.fm/#/newbs>\n\nYou can convert this file to a keymap.c using this command: `qmk json2c {keymap}`\n\nYou can compile this keymap using this command: `qmk compile {keymap}`\"\n",
"keyboard": "cheapino",
"keymap": "default",
"layout": "LAYOUT_split_3x5_3",
"layers": [
[
"KC_Q",
"KC_W",
"KC_F",
"KC_P",
"KC_B",
"KC_J",
"KC_L",
"KC_U",
"KC_Y",
"KC_SCLN",
"LGUI_T(KC_A)",
"LALT_T(KC_R)",
"LCTL_T(KC_S)",
"LSFT_T(KC_T)",
"KC_G",
"KC_M",
"RSFT_T(KC_N)",
"LCTL_T(KC_E)",
"LALT_T(KC_I)",
"LGUI_T(KC_O)",
"KC_Z",
"KC_X",
"KC_C",
"KC_D",
"LT(5,KC_V)",
"LT(1,KC_K)",
"KC_H",
"KC_COMM",
"KC_DOT",
"KC_SLSH",
"LT(6,KC_ESC)",
"LT(3,KC_SPC)",
"LT(5,KC_TAB)",
"LT(1,KC_DEL)",
"LT(2,KC_BSPC)",
"LT(4,KC_ENT)"
],
[
"KC_VOLU",
"KC_WH_L",
"KC_MS_U",
"KC_WH_U",
"KC_WH_R",
"KC_NO",
"KC_NO",
"KC_NO",
"KC_NO",
"QK_RBT",
"KC_MS_L",
"KC_BTN2",
"KC_BTN1",
"KC_MS_R",
"KC_MUTE",
"KC_NO",
"KC_TRNS",
"KC_TRNS",
"KC_TRNS",
"KC_TRNS",
"KC_VOLD",
"KC_MNXT",
"KC_MS_D",
"KC_WH_D",
"KC_MPLY",
"KC_NO",
"KC_NO",
"KC_NO",
"KC_NO",
"KC_NO",
"KC_NO",
"KC_TRNS",
"KC_TRNS",
"KC_NO",
"KC_NO",
"KC_NO"
],
[
"KC_NO",
"KC_HOME",
"KC_DEL",
"KC_PGUP",
"KC_NO",
"KC_NO",
"KC_NO",
"KC_NO",
"KC_NO",
"KC_NO",
"KC_NO",
"KC_LEFT",
"KC_UP",
"KC_RGHT",
"KC_NO",
"KC_NO",
"KC_TRNS",
"KC_TRNS",
"KC_TRNS",
"KC_TRNS",
"KC_NO",
"KC_END",
"KC_DOWN",
"KC_PGDN",
"KC_NO",
"KC_NO",
"KC_BTN1",
"KC_BTN2",
"KC_BTN3",
"KC_BTN4",
"KC_NO",
"KC_TRNS",
"KC_TRNS",
"KC_NO",
"KC_NO",
"KC_NO"
],
[
"KC_NO",
"KC_NO",
"KC_NO",
"KC_NO",
"KC_WH_U",
"KC_AT",
"KC_UNDS",
"KC_PIPE",
"KC_QUOT",
"KC_PERC",
"KC_TRNS",
"KC_TRNS",
"KC_TRNS",
"KC_TRNS",
"RGB_TOG",
"KC_HASH",
"KC_TAB",
"KC_EXLM",
"KC_DQUO",
"KC_DLR",
"KC_BTN4",
"KC_BTN3",
"KC_BTN2",
"KC_BTN1",
"KC_WH_D",
"KC_TILD",
"KC_QUOT",
"KC_BSLS",
"KC_SLSH",
"KC_AMPR",
"KC_NO",
"KC_NO",
"KC_NO",
"KC_TRNS",
"KC_TRNS",
"KC_NO"
],
[
"KC_EQL",
"KC_COLN",
"KC_LT",
"KC_GT",
"KC_SCLN",
"KC_NO",
"KC_NO",
"KC_NO",
"KC_NO",
"KC_NO",
"KC_LCBR",
"KC_RCBR",
"KC_LPRN",
"KC_RPRN",
"KC_AT",
"KC_NO",
"KC_TRNS",
"KC_TRNS",
"KC_TRNS",
"KC_TRNS",
"KC_MINS",
"KC_EXLM",
"KC_LBRC",
"KC_RBRC",
"KC_TRNS",
"KC_NO",
"KC_NO",
"KC_NO",
"KC_NO",
"KC_NO",
"KC_NO",
"KC_TRNS",
"KC_TRNS",
"KC_TRNS",
"KC_NO",
"KC_NO"
],
[
"QK_RBT",
"KC_NO",
"KC_NO",
"KC_NO",
"KC_NO",
"KC_NO",
"KC_F7",
"KC_F8",
"KC_F9",
"KC_F10",
"KC_TRNS",
"KC_TRNS",
"KC_TRNS",
"KC_TRNS",
"KC_NO",
"KC_NO",
"KC_F4",
"KC_F5",
"KC_F6",
"KC_F11",
"KC_NO",
"KC_NO",
"KC_NO",
"KC_NO",
"KC_NO",
"KC_NO",
"KC_F1",
"KC_F2",
"KC_F3",
"KC_F12",
"KC_TRNS",
"KC_TRNS",
"KC_TRNS",
"KC_TRNS",
"KC_TRNS",
"KC_TRNS"
],
[
"RGB_SPI",
"RGB_VAI",
"RGB_SAI",
"RGB_HUI",
"RGB_MOD",
"KC_PPLS",
"KC_P7",
"KC_P8",
"KC_P9",
"KC_PAST",
"KC_TRNS",
"KC_TRNS",
"KC_TRNS",
"KC_TRNS",
"RGB_TOG",
"KC_PMNS",
"KC_P4",
"KC_P5",
"KC_P6",
"KC_PSLS",
"RGB_SPD",
"RGB_VAD",
"RGB_SAD",
"RGB_HUD",
"RGB_RMOD",
"KC_PDOT",
"KC_P1",
"KC_P2",
"KC_P3",
"KC_PEQL",
"KC_NO",
"KC_NO",
"KC_NO",
"KC_0",
"KC_COMM",
"KC_P0"
]
],
"author": "thomas.haukland@gmail.com"
}

155
keyboards/cheapino/matrix.c Normal file
View File

@ -0,0 +1,155 @@
/*
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"
#define ROW_SHIFTER ((uint16_t)1)
static const pin_t row_pins[] = MATRIX_ROW_PINS;
static const pin_t col_pins[] = MATRIX_COL_PINS;
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 init_pins(void) {
unselect_cols();
unselect_rows();
}
static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) {
// Store last value of row prior to reading
matrix_row_t last_row_value = current_matrix[current_row];
// Clear data in matrix row
//current_matrix[current_row] = 0;
// Select row and wait for row selection to stabilize
select_row(current_row);
wait_us(30);
// For each col...
for (uint8_t col_index = 0; col_index < MATRIX_COLS / 2; col_index++) {
uint16_t column_index_bitmask = ROW_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);
return (last_row_value != current_matrix[current_row]);
}
static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) {
bool matrix_changed = false;
// Select col and wait for col selection to stabilize
select_col(current_col*2);
wait_us(30);
// For each row...
for (uint8_t row_index = 0; row_index < MATRIX_ROWS-1; row_index++) {
// Store last value of row prior to reading
matrix_row_t last_row_value = current_matrix[row_index];
uint16_t column_index_bitmask = ROW_SHIFTER << (current_col * 2);
// 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;
}
// Determine if the matrix changed state
if ((last_row_value != current_matrix[row_index]) && !(matrix_changed)) {
matrix_changed = true;
}
}
// Unselect col
unselect_col(current_col*2);
return matrix_changed;
}
void matrix_init_custom(void) {
// initialize key pins
init_pins();
debounce_init(MATRIX_ROWS);
}
bool matrix_scan_custom(matrix_row_t current_matrix[]) {
bool changed = false;
// Set row, read cols
for (uint8_t current_row = 0; current_row < MATRIX_ROWS-1; current_row++) {
changed |= 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++) {
changed |= read_rows_on_col(current_matrix, current_col);
}
//debounce(raw_matrix, matrix, MATRIX_ROWS, changed);
return changed;
}

View File

@ -1 +1,2 @@
# This file intentionally left blank
CUSTOM_MATRIX = lite
SRC += matrix.c