[Keyboard] ErgoTaco Support (#5504)
* ErgoTaco support * Update keyboards/ergotaco/ergotaco.h Co-Authored-By: germ <jeremythegeek@gmail.com> * Update keyboards/ergotaco/keymaps/default/keymap.c Co-Authored-By: germ <jeremythegeek@gmail.com> * Update keyboards/ergotaco/keymaps/default/keymap.c Co-Authored-By: germ <jeremythegeek@gmail.com> * Update keyboards/ergotaco/readme.md Co-Authored-By: germ <jeremythegeek@gmail.com> * Update keyboards/ergotaco/readme.md Co-Authored-By: germ <jeremythegeek@gmail.com> * Update keyboards/ergotaco/rules.mk Co-Authored-By: germ <jeremythegeek@gmail.com> * juggling rules.mk * Update keyboards/ergotaco/rules.mk Co-Authored-By: germ <jeremythegeek@gmail.com> * updating IS_COMMAND * learning2english Meme-tastic --Drashna
This commit is contained in:
parent
3f4d706c98
commit
8fa9f67256
10 changed files with 718 additions and 0 deletions
61
keyboards/ergotaco/config.h
Normal file
61
keyboards/ergotaco/config.h
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
Copyright 2012 Jun Wako <wakojun@gmail.com>
|
||||||
|
Copyright 2013 Oleg Kostyuk <cub.uanic@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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Copy and worked on with love from the EZ team
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "config_common.h"
|
||||||
|
|
||||||
|
#define VERBOSE
|
||||||
|
|
||||||
|
/* USB Device descriptor parameter */
|
||||||
|
#define VENDOR_ID 0xFEED
|
||||||
|
#define PRODUCT_ID 0x1337
|
||||||
|
#define DEVICE_VER 0x0001
|
||||||
|
#define MANUFACTURER g Heavy Industries
|
||||||
|
#define PRODUCT ErgoTaco
|
||||||
|
#define DESCRIPTION QMK keyboard firmware for ErgoTaco
|
||||||
|
|
||||||
|
/* key matrix size */
|
||||||
|
#define MATRIX_ROWS 12
|
||||||
|
#define MATRIX_ROWS_PER_SIDE (MATRIX_ROWS / 2)
|
||||||
|
#define MATRIX_COLS 1
|
||||||
|
|
||||||
|
#define MOUSEKEY_INTERVAL 20
|
||||||
|
#define MOUSEKEY_DELAY 0
|
||||||
|
#define MOUSEKEY_TIME_TO_MAX 60
|
||||||
|
#define MOUSEKEY_MAX_SPEED 7
|
||||||
|
#define MOUSEKEY_WHEEL_DELAY 0
|
||||||
|
#define TAPPING_TOGGLE 1
|
||||||
|
|
||||||
|
/* define if matrix has ghost */
|
||||||
|
//#define MATRIX_HAS_GHOST
|
||||||
|
|
||||||
|
#define TAPPING_TERM 200
|
||||||
|
#define IGNORE_MOD_TAP_INTERRUPT // this makes it possible to do rolling combos (zx) with keys that convert to other keys on hold (z becomes ctrl when you hold it, and when this option isn't enabled, z rapidly followed by x actually sends Ctrl-x. That's bad.)
|
||||||
|
|
||||||
|
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
|
||||||
|
#define LOCKING_SUPPORT_ENABLE
|
||||||
|
/* Locking resynchronize hack */
|
||||||
|
#define LOCKING_RESYNC_ENABLE
|
||||||
|
|
||||||
|
/* key combination for command */
|
||||||
|
#define IS_COMMAND() (get_mods() == MOD_MASK_CTRL || get_mods() == MOD_MASK_SHIFT)
|
||||||
|
|
||||||
|
#define DEBOUNCE 5
|
||||||
|
#define USB_MAX_POWER_CONSUMPTION 500
|
72
keyboards/ergotaco/ergotaco.c
Normal file
72
keyboards/ergotaco/ergotaco.c
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
#include QMK_KEYBOARD_H
|
||||||
|
|
||||||
|
bool i2c_initialized = 0;
|
||||||
|
i2c_status_t mcp23018_status = 0x20;
|
||||||
|
|
||||||
|
void matrix_init_kb(void) {
|
||||||
|
// (tied to Vcc for hardware convenience)
|
||||||
|
//DDRB &= ~(1<<4); // set B(4) as input
|
||||||
|
//PORTB &= ~(1<<4); // set B(4) internal pull-up disabled
|
||||||
|
|
||||||
|
// unused pins
|
||||||
|
// set as input with internal pull-up enabled
|
||||||
|
DDRB &= ~(1<<4 | 1<<5 | 1<<6 | 1<<7);
|
||||||
|
PORTB |= (1<<4 | 1<<5 | 1<<6 | 1<<7);
|
||||||
|
|
||||||
|
DDRC &= ~(1<<7 | 1<<6);
|
||||||
|
PORTC |= (1<<7 | 1<<6);
|
||||||
|
|
||||||
|
DDRD &= ~(1<<4 | 1<<5 | 1<<6 | 1<<7);
|
||||||
|
PORTD |= (1<<4 | 1<<5 | 1<<6 | 1<<7);
|
||||||
|
|
||||||
|
DDRE &= ~(1<<6);
|
||||||
|
PORTE |= (1<<6);
|
||||||
|
|
||||||
|
DDRF &= ~(1<<0 | 1<<1 | 1<<4 | 1<<6 | 1<<7);
|
||||||
|
PORTF |= (1<<0 | 1<<1 | 1<<4 | 1<<6 | 1<<7);
|
||||||
|
|
||||||
|
matrix_init_user();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t init_mcp23018(void) {
|
||||||
|
print("starting init");
|
||||||
|
mcp23018_status = 0x20;
|
||||||
|
|
||||||
|
// I2C subsystem
|
||||||
|
|
||||||
|
// uint8_t sreg_prev;
|
||||||
|
// sreg_prev=SREG;
|
||||||
|
// cli();
|
||||||
|
|
||||||
|
if (i2c_initialized == 0) {
|
||||||
|
i2c_init(); // on pins D(1,0)
|
||||||
|
i2c_initialized = true;
|
||||||
|
_delay_ms(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set pin direction
|
||||||
|
// - unused : input : 1
|
||||||
|
// - input : input : 1
|
||||||
|
// - driving : output : 0
|
||||||
|
mcp23018_status = i2c_start(I2C_ADDR_WRITE, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
|
||||||
|
mcp23018_status = i2c_write(IODIRA, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
|
||||||
|
mcp23018_status = i2c_write(0b00000000, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
|
||||||
|
mcp23018_status = i2c_write(0b11111111, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
|
||||||
|
i2c_stop();
|
||||||
|
|
||||||
|
// set pull-up
|
||||||
|
// - unused : on : 1
|
||||||
|
// - input : on : 1
|
||||||
|
// - driving : off : 0
|
||||||
|
mcp23018_status = i2c_start(I2C_ADDR_WRITE, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
|
||||||
|
mcp23018_status = i2c_write(GPPUA, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
|
||||||
|
mcp23018_status = i2c_write(0b00000000, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
|
||||||
|
mcp23018_status = i2c_write(0b11111111, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
|
||||||
|
|
||||||
|
out:
|
||||||
|
i2c_stop();
|
||||||
|
// SREG=sreg_prev;
|
||||||
|
//uprintf("Init %x\n", mcp23018_status);
|
||||||
|
return mcp23018_status;
|
||||||
|
}
|
50
keyboards/ergotaco/ergotaco.h
Normal file
50
keyboards/ergotaco/ergotaco.h
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
#pragma once
|
||||||
|
#include <util/delay.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include "quantum.h"
|
||||||
|
#include "i2c_master.h"
|
||||||
|
#include "matrix.h"
|
||||||
|
|
||||||
|
|
||||||
|
extern i2c_status_t mcp23018_status;
|
||||||
|
#define ERGODOX_EZ_I2C_TIMEOUT 1000
|
||||||
|
#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))
|
||||||
|
#define CPU_16MHz 0x00
|
||||||
|
|
||||||
|
// I2C aliases and register addresses (see "mcp23018.md")
|
||||||
|
//#define I2C_ADDR 0b0100000
|
||||||
|
#define I2C_ADDR 0x20
|
||||||
|
#define I2C_ADDR_WRITE ( (I2C_ADDR<<1) | I2C_WRITE )
|
||||||
|
#define I2C_ADDR_READ ( (I2C_ADDR<<1) | I2C_READ )
|
||||||
|
#define IODIRA 0x00 // i/o direction register
|
||||||
|
#define IODIRB 0x01
|
||||||
|
#define GPPUA 0x0C // GPIO pull-up resistor register
|
||||||
|
#define GPPUB 0x0D
|
||||||
|
#define GPIOA 0x12 // general purpose i/o port register (write modifies OLAT)
|
||||||
|
#define GPIOB 0x13
|
||||||
|
#define OLATA 0x14 // output latch register
|
||||||
|
#define OLATB 0x15
|
||||||
|
|
||||||
|
void init_ergodox(void);
|
||||||
|
uint8_t init_mcp23018(void);
|
||||||
|
|
||||||
|
/* ---------- LEFT HAND ----------- ---------- RIGHT HAND ---------- */
|
||||||
|
#define LAYOUT( \
|
||||||
|
L00,L01,L02,L03,L04,L05, R00,R01,R02,R03,R04,R05) \
|
||||||
|
\
|
||||||
|
/* matrix positions */ \
|
||||||
|
{ \
|
||||||
|
{R00}, \
|
||||||
|
{R01}, \
|
||||||
|
{R02}, \
|
||||||
|
{R03}, \
|
||||||
|
{R04}, \
|
||||||
|
{R05}, \
|
||||||
|
{L05}, \
|
||||||
|
{L04}, \
|
||||||
|
{L03}, \
|
||||||
|
{L02}, \
|
||||||
|
{L01}, \
|
||||||
|
{L00}, \
|
||||||
|
}
|
61
keyboards/ergotaco/info.json
Normal file
61
keyboards/ergotaco/info.json
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
{
|
||||||
|
"keyboard_name": "ErgoTaco",
|
||||||
|
"url": "http://gboards.ca",
|
||||||
|
"maintainer": "germ",
|
||||||
|
"width": 13,
|
||||||
|
"height": 2.75,
|
||||||
|
"layouts": {
|
||||||
|
"LAYOUT": {
|
||||||
|
"layout": [
|
||||||
|
{
|
||||||
|
"x": 0,
|
||||||
|
"y": 1.25
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 1,
|
||||||
|
"y": 0.75
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 2,
|
||||||
|
"y": 0.5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 3,
|
||||||
|
"y": 0.25
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 4,
|
||||||
|
"y": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 5,
|
||||||
|
"y": 1.75
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 7,
|
||||||
|
"y": 1.75
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 8,
|
||||||
|
"y": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 9,
|
||||||
|
"y": 0.25
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 10,
|
||||||
|
"y": 0.5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 11,
|
||||||
|
"y": 0.75
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 12,
|
||||||
|
"y": 1.25
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
42
keyboards/ergotaco/keymaps/default/keymap.c
Normal file
42
keyboards/ergotaco/keymaps/default/keymap.c
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
/* Good on you for modifying your layout! if you don't have
|
||||||
|
* time to read the QMK docs, a list of keycodes can be found at
|
||||||
|
*
|
||||||
|
* https://github.com/qmk/qmk_firmware/blob/master/docs/keycodes.md
|
||||||
|
*
|
||||||
|
* There's also a template for adding new layers at the bottom of this file!
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include QMK_KEYBOARD_H
|
||||||
|
|
||||||
|
#define FIESTA 0 // default layer
|
||||||
|
#define TACOTIME 1 // symbols
|
||||||
|
|
||||||
|
// Blank template at the bottom
|
||||||
|
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
|
/* Keymap template
|
||||||
|
*
|
||||||
|
* ,-------------------------------------------------. ,--------------------------------------------.
|
||||||
|
* | | | | | | | | | | | | | | |
|
||||||
|
* `-------+------+------+------+------+-------------' `-------+------+------+------+------+--------' */
|
||||||
|
[FIESTA] = LAYOUT(
|
||||||
|
KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Keymap template
|
||||||
|
*
|
||||||
|
* ,-------------------------------------------------. ,--------------------------------------------.
|
||||||
|
* | | | | | | | | | | | | | | |
|
||||||
|
* `-------+------+------+------+------+-------------' `-------+------+------+------+------+--------'
|
||||||
|
[FIESTA] = LAYOUT(
|
||||||
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS
|
||||||
|
),
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Runs just one time when the keyboard initializes.
|
||||||
|
void matrix_init_user(void) {
|
||||||
|
};
|
||||||
|
|
||||||
|
// Runs constantly in the background, in a loop.
|
||||||
|
void matrix_scan_user(void) {
|
||||||
|
};
|
6
keyboards/ergotaco/keymaps/default/readme.md
Normal file
6
keyboards/ergotaco/keymaps/default/readme.md
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
This is the default keymap for the ErgoTaco, Make it your own!
|
||||||
|
|
||||||
|
## Settings
|
||||||
|
To edit various settings, enable the 1u trackball and whatnot please modify /keyboards/ergotaco/keymaps/default/rules.mk
|
||||||
|
|
||||||
|
Ideally you should copy this directory and make your changes there. If you come up with a good layout submit a PR!
|
10
keyboards/ergotaco/keymaps/default/rules.mk
Normal file
10
keyboards/ergotaco/keymaps/default/rules.mk
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# make ergotaco:default:dfu
|
||||||
|
# Make sure you have dfu-programmer installed!
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# Firmware options
|
||||||
|
|
||||||
|
#Debug options
|
||||||
|
VERBOSE = yes
|
||||||
|
DEBUG_MATRIX_SCAN_RATE = no
|
||||||
|
DEBUG_MATRIX = yes
|
366
keyboards/ergotaco/matrix.c
Normal file
366
keyboards/ergotaco/matrix.c
Normal file
|
@ -0,0 +1,366 @@
|
||||||
|
/*
|
||||||
|
Note for ErgoDox EZ customizers: Here be dragons!
|
||||||
|
This is not a file you want to be messing with.
|
||||||
|
All of the interesting stuff for you is under keymaps/ :)
|
||||||
|
Love, Erez
|
||||||
|
|
||||||
|
Copyright 2013 Oleg Kostyuk <cub.uanic@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 "matrix.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include "wait.h"
|
||||||
|
#include "action_layer.h"
|
||||||
|
#include "print.h"
|
||||||
|
#include "debug.h"
|
||||||
|
#include "util.h"
|
||||||
|
#include QMK_KEYBOARD_H
|
||||||
|
#ifdef DEBUG_MATRIX_SCAN_RATE
|
||||||
|
#include "timer.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef DEBOUNCE
|
||||||
|
# define DEBOUNCE 5
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ATmega pin defs
|
||||||
|
#define ROW1 (1<<5)
|
||||||
|
#define COL6 (1<<0)
|
||||||
|
#define COL7 (1<<1)
|
||||||
|
#define COL8 (1<<2)
|
||||||
|
#define COL9 (1<<3)
|
||||||
|
#define COL10 (1<<2)
|
||||||
|
#define COL11 (1<<3)
|
||||||
|
|
||||||
|
|
||||||
|
// bit masks
|
||||||
|
#define BMASK (COL7 | COL8 | COL9 | COL6)
|
||||||
|
#define DMASK (COL10 | COL11)
|
||||||
|
#define FMASK (ROW1)
|
||||||
|
|
||||||
|
/* matrix state(1:on, 0:off) */
|
||||||
|
static matrix_row_t matrix[MATRIX_ROWS];
|
||||||
|
/*
|
||||||
|
* matrix state(1:on, 0:off)
|
||||||
|
* contains the raw values without debounce filtering of the last read cycle.
|
||||||
|
*/
|
||||||
|
static matrix_row_t raw_matrix[MATRIX_ROWS];
|
||||||
|
|
||||||
|
// Debouncing: store for each key the number of scans until it's eligible to
|
||||||
|
// change. When scanning the matrix, ignore any changes in keys that have
|
||||||
|
// already changed in the last DEBOUNCE scans.
|
||||||
|
static uint8_t debounce_matrix[MATRIX_ROWS * MATRIX_COLS];
|
||||||
|
|
||||||
|
static matrix_row_t read_cols(uint8_t row);
|
||||||
|
static void init_cols(void);
|
||||||
|
static void unselect_rows(void);
|
||||||
|
static void select_row(uint8_t row);
|
||||||
|
|
||||||
|
static uint8_t mcp23018_reset_loop;
|
||||||
|
// static uint16_t mcp23018_reset_loop;
|
||||||
|
|
||||||
|
#ifdef DEBUG_MATRIX_SCAN_RATE
|
||||||
|
uint32_t matrix_timer;
|
||||||
|
uint32_t matrix_scan_count;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
__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();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
uint8_t matrix_rows(void)
|
||||||
|
{
|
||||||
|
return MATRIX_ROWS;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
uint8_t matrix_cols(void)
|
||||||
|
{
|
||||||
|
return MATRIX_COLS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void matrix_init(void)
|
||||||
|
{
|
||||||
|
// initialize row and col
|
||||||
|
mcp23018_status = init_mcp23018();
|
||||||
|
unselect_rows();
|
||||||
|
init_cols();
|
||||||
|
|
||||||
|
// initialize matrix state: all keys off
|
||||||
|
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
||||||
|
matrix[i] = 0;
|
||||||
|
raw_matrix[i] = 0;
|
||||||
|
for (uint8_t j=0; j < MATRIX_COLS; ++j) {
|
||||||
|
debounce_matrix[i * MATRIX_COLS + j] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_MATRIX_SCAN_RATE
|
||||||
|
matrix_timer = timer_read32();
|
||||||
|
matrix_scan_count = 0;
|
||||||
|
#endif
|
||||||
|
matrix_init_quantum();
|
||||||
|
}
|
||||||
|
|
||||||
|
void matrix_power_up(void) {
|
||||||
|
mcp23018_status = init_mcp23018();
|
||||||
|
|
||||||
|
unselect_rows();
|
||||||
|
init_cols();
|
||||||
|
|
||||||
|
// initialize matrix state: all keys off
|
||||||
|
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
||||||
|
matrix[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_MATRIX_SCAN_RATE
|
||||||
|
matrix_timer = timer_read32();
|
||||||
|
matrix_scan_count = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns a matrix_row_t whose bits are set if the corresponding key should be
|
||||||
|
// eligible to change in this scan.
|
||||||
|
matrix_row_t debounce_mask(matrix_row_t rawcols, uint8_t row) {
|
||||||
|
matrix_row_t result = 0;
|
||||||
|
matrix_row_t change = rawcols ^ raw_matrix[row];
|
||||||
|
raw_matrix[row] = rawcols;
|
||||||
|
for (uint8_t i = 0; i < MATRIX_COLS; ++i) {
|
||||||
|
if (debounce_matrix[row * MATRIX_COLS + i]) {
|
||||||
|
--debounce_matrix[row * MATRIX_COLS + i];
|
||||||
|
} else {
|
||||||
|
result |= (1 << i);
|
||||||
|
}
|
||||||
|
if (change & (1 << i)) {
|
||||||
|
debounce_matrix[row * MATRIX_COLS + i] = DEBOUNCE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
matrix_row_t debounce_read_cols(uint8_t row) {
|
||||||
|
// Read the row without debouncing filtering and store it for later usage.
|
||||||
|
matrix_row_t cols = read_cols(row);
|
||||||
|
// Get the Debounce mask.
|
||||||
|
matrix_row_t mask = debounce_mask(cols, row);
|
||||||
|
// debounce the row and return the result.
|
||||||
|
return (cols & mask) | (matrix[row] & ~mask);;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t matrix_scan(void)
|
||||||
|
{
|
||||||
|
// Then the keyboard
|
||||||
|
if (mcp23018_status) { // if there was an error
|
||||||
|
if (++mcp23018_reset_loop == 0) {
|
||||||
|
// if (++mcp23018_reset_loop >= 1300) {
|
||||||
|
// since mcp23018_reset_loop is 8 bit - we'll try to reset once in 255 matrix scans
|
||||||
|
// this will be approx bit more frequent than once per second
|
||||||
|
print("trying to reset mcp23018\n");
|
||||||
|
mcp23018_status = init_mcp23018();
|
||||||
|
if (mcp23018_status) {
|
||||||
|
print("left side not responding\n");
|
||||||
|
} else {
|
||||||
|
print("left side attached\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_MATRIX_SCAN_RATE
|
||||||
|
matrix_scan_count++;
|
||||||
|
uint32_t timer_now = timer_read32();
|
||||||
|
if (TIMER_DIFF_32(timer_now, matrix_timer)>1000) {
|
||||||
|
print("matrix scan frequency: ");
|
||||||
|
pdec(matrix_scan_count);
|
||||||
|
print("\n");
|
||||||
|
|
||||||
|
matrix_timer = timer_now;
|
||||||
|
matrix_scan_count = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
for (uint8_t i = 0; i < MATRIX_ROWS_PER_SIDE; i++) {
|
||||||
|
select_row(i);
|
||||||
|
// and select on left hand
|
||||||
|
select_row(i + MATRIX_ROWS_PER_SIDE);
|
||||||
|
// we don't need a 30us delay anymore, because selecting a
|
||||||
|
// left-hand row requires more than 30us for i2c.
|
||||||
|
|
||||||
|
// grab cols from left hand
|
||||||
|
matrix[i] = debounce_read_cols(i);
|
||||||
|
// grab cols from right hand
|
||||||
|
matrix[i + MATRIX_ROWS_PER_SIDE] = debounce_read_cols(i + MATRIX_ROWS_PER_SIDE);
|
||||||
|
|
||||||
|
unselect_rows();
|
||||||
|
}
|
||||||
|
|
||||||
|
matrix_scan_quantum();
|
||||||
|
|
||||||
|
#ifdef DEBUG_MATRIX
|
||||||
|
for (uint8_t c = 0; c < MATRIX_COLS; c++)
|
||||||
|
for (uint8_t r = 0; r < MATRIX_ROWS; r++)
|
||||||
|
if (matrix_is_on(r, c)) xprintf("r:%d c:%d \n", r, c);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool matrix_is_modified(void) // deprecated and evidently not called.
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
bool matrix_is_on(uint8_t row, uint8_t col)
|
||||||
|
{
|
||||||
|
return (matrix[row] & ((matrix_row_t)1<<col));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
matrix_row_t matrix_get_row(uint8_t row)
|
||||||
|
{
|
||||||
|
return matrix[row];
|
||||||
|
}
|
||||||
|
|
||||||
|
void matrix_print(void)
|
||||||
|
{
|
||||||
|
print("\nr/c 0123456789ABCDEF\n");
|
||||||
|
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||||
|
phex(row); print(": ");
|
||||||
|
pbin_reverse16(matrix_get_row(row));
|
||||||
|
print("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t matrix_key_count(void)
|
||||||
|
{
|
||||||
|
uint8_t count = 0;
|
||||||
|
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||||
|
count += bitpop16(matrix[i]);
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remember this means ROWS
|
||||||
|
static void init_cols(void)
|
||||||
|
{
|
||||||
|
// init on mcp23018
|
||||||
|
// not needed, already done as part of init_mcp23018()
|
||||||
|
|
||||||
|
// Input with pull-up(DDR:0, PORT:1)
|
||||||
|
DDRF &= ~FMASK;
|
||||||
|
PORTF |= FMASK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static matrix_row_t read_cols(uint8_t row)
|
||||||
|
{
|
||||||
|
if (row < 6) {
|
||||||
|
if (mcp23018_status) { // if there was an error
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
uint8_t data = 0;
|
||||||
|
mcp23018_status = i2c_start(I2C_ADDR_WRITE, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
|
||||||
|
mcp23018_status = i2c_write(GPIOB, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
|
||||||
|
mcp23018_status = i2c_start(I2C_ADDR_READ, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
|
||||||
|
mcp23018_status = i2c_read_nack(ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status < 0) goto out;
|
||||||
|
data = (~((uint8_t)mcp23018_status) >> 2) & 0x01 ;
|
||||||
|
mcp23018_status = I2C_STATUS_SUCCESS;
|
||||||
|
out:
|
||||||
|
i2c_stop();
|
||||||
|
|
||||||
|
#ifdef DEBUG_MATRIX
|
||||||
|
if (data != 0x00) xprintf("I2C: %d\n", data);
|
||||||
|
#endif
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Read using bitmask
|
||||||
|
return ~((((PINF & ROW1) >> 5)) & 0x1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Row pin configuration
|
||||||
|
static void unselect_rows(void)
|
||||||
|
{
|
||||||
|
// no need to unselect on mcp23018, because the select step sets all
|
||||||
|
// the other row bits high, and it's not changing to a different
|
||||||
|
// direction
|
||||||
|
// Hi-Z(DDR:0, PORT:0) to unselect
|
||||||
|
DDRB &= ~BMASK;
|
||||||
|
PORTB &= ~BMASK;
|
||||||
|
DDRD &= ~DMASK;
|
||||||
|
PORTD &= ~DMASK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void select_row(uint8_t row)
|
||||||
|
{
|
||||||
|
if (row < 6) {
|
||||||
|
// select on mcp23018
|
||||||
|
if (mcp23018_status) { // do nothing on error
|
||||||
|
// Read using bitmask
|
||||||
|
} else { // set active row low : 0 // set other rows hi-Z : 1
|
||||||
|
mcp23018_status = i2c_start(I2C_ADDR_WRITE, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
|
||||||
|
mcp23018_status = i2c_write(GPIOA, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
|
||||||
|
mcp23018_status = i2c_write(~(1<<row), ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
|
||||||
|
out:
|
||||||
|
i2c_stop();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Output low(DDR:1, PORT:0) to select
|
||||||
|
switch (row) {
|
||||||
|
case 6:
|
||||||
|
DDRB |= COL6;
|
||||||
|
PORTB &= ~COL6;
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
DDRB |= COL7;
|
||||||
|
PORTB &= ~COL7;
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
DDRB |= COL8;
|
||||||
|
PORTB &= ~COL8;
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
DDRB |= COL9;
|
||||||
|
PORTB &= ~COL9;
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
DDRD |= COL10;
|
||||||
|
PORTD &= ~COL10;
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
DDRD |= COL11;
|
||||||
|
PORTD &= ~COL11;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
24
keyboards/ergotaco/readme.md
Normal file
24
keyboards/ergotaco/readme.md
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# Gergo
|
||||||
|
|
||||||
|
![ErgoTaco](https://i.redd.it/dbcu5i21m3i21.jpg)
|
||||||
|
|
||||||
|
It's a Taco with a side of HASL. A 12 key fiesta of a board.
|
||||||
|
|
||||||
|
Keyboard Maintainer: [Jeremy Bernhardt](https://github.com/germ)
|
||||||
|
Hardware Supported: ErgoTaco
|
||||||
|
Hardware Availability: [gboards.ca](http://gboards.ca)
|
||||||
|
|
||||||
|
## Firmware building
|
||||||
|
Clone the QMK Repo and install dfu-programmer, flash with:
|
||||||
|
|
||||||
|
make ergotaco:default:dfu
|
||||||
|
|
||||||
|
And reset your keyboard!
|
||||||
|
|
||||||
|
To just test if your build system is sane, try compiling the default keymap using:
|
||||||
|
|
||||||
|
make ergotaco:default
|
||||||
|
|
||||||
|
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).
|
||||||
|
|
||||||
|
## Have an idea? [Reach out to me!](mailto:bernhardtjeremy@gmail.com)
|
26
keyboards/ergotaco/rules.mk
Normal file
26
keyboards/ergotaco/rules.mk
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# make ergotaco:default:dfu
|
||||||
|
# Make sure you have dfu-programmer installed!
|
||||||
|
# Do not edit this file! Make a copy of keymaps/default and modify that!
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Hardware info
|
||||||
|
MCU = atmega32u4
|
||||||
|
F_CPU = 16000000
|
||||||
|
ARCH = AVR8
|
||||||
|
BOOTLOADER = atmel-dfu
|
||||||
|
F_USB = $(F_CPU)
|
||||||
|
|
||||||
|
CUSTOM_MATRIX = yes
|
||||||
|
EXTRAKEY_ENABLE = yes
|
||||||
|
CONSOLE_ENABLE = yes
|
||||||
|
COMMAND_ENABLE = yes
|
||||||
|
|
||||||
|
# A bunch of stuff that you shouldn't touch unless you
|
||||||
|
# know what you're doing.
|
||||||
|
#
|
||||||
|
# No touchy, capiche?
|
||||||
|
SRC += matrix.c i2c_master.c
|
||||||
|
ifeq ($(strip $(DEBUG_MATRIX)), yes)
|
||||||
|
OPT_DEFS += -DDEBUG_MATRIX
|
||||||
|
endif
|
Loading…
Reference in a new issue