Compare commits

..

4 Commits

Author SHA1 Message Date
James Churchill
563ce3f225 Add explicit eeprom include in split_common
Fixes builds that set EE_HANDS.
2019-01-03 20:00:27 -08:00
James Churchill
38e01a7480 Convert split_common to use generic GPIO api 2019-01-03 20:00:27 -08:00
noroadsleft
54b572159f Preonic rev. 3: fix info.json file
File was saved with an invalid JSON structure.
2019-01-03 21:52:35 -05:00
noroadsleft
6f80217958 Snagpad: fix Configurator mismatch (#4767)
Key objects for the LAYOUT_numpad_5x4 macro were out-of-order in
info.json.

Also white space changes because I'm that guy.
2019-01-03 16:33:32 -08:00
10 changed files with 32 additions and 250 deletions

View File

@@ -1,15 +0,0 @@
#define k_ KC_NO
#define LAYOUT_keymap( \
kMN, kSH, kSL, kST, \
kUP, KY, \
kLF, kRH, kX, kB, \
kDN, kA, \
kL1, kL2, kL3, kL4, kL5 \
) { \
{ kUP, kLF, kDN, kRH, kY, kX, kA, kB }, \
{ kMN, kSH, kSL, kST, k_, k_, k_, k_ }, \
{ kL1, kL2, kL3, kL4, kL5, k_, k_, k_ }, \
}

View File

@@ -1,38 +0,0 @@
/*
Copyright 2019 Jack Humbert <jack.humb@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/>.
*/
#pragma once
/* USB Device descriptor parameter */
#define VENDOR_ID 0xFEED
#define PRODUCT_ID 0xD901
#define DEVICE_VER 0x0001
#define MANUFACTURER clockworkpi
#define PRODUCT keypad
#define DESCRIPTION
#define MATRIX_ROWS 3
#define MATRIX_COLS 8
#define TAPPING_TOGGLE 3
#define NO_UART 1
/* key combination for command */
#define IS_COMMAND() ( \
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
)

View File

@@ -1,20 +0,0 @@
[0] = LAYOUT_keypad(
KC_ESC, MO(1), KC_SPC, KC_ENT,
KC_UP KC_I,
KC_LEFT, KC_RIGHT, KC_U, KC_K,
KC_DOWN, KC_J,
KC_HOME, KC_PGUP, MO(1), KC_PGDN, KC_END
),
[1] = LAYOUT_keypad(
KC_BSPC, MO(1), KC_PMNS, KC_PPLS,
KC_UP KC_O,
KC_LEFT, KC_RIGHT, KC_Y, KC_L,
KC_DOWN, KC_H
KC_H, KC_Y, MO(1), KC_O, KC_L
)

View File

@@ -1,65 +0,0 @@
// 0 DO
// 1 D1
// 2 D2
// 3 D3
// 4 D4
// 5 D5
// 6 D6
// 7 D7
// 8 B0
// 9 B1
// 10 B2
// 11 B3
// 12 B4
// 13 B5
// 14 C0
// 15 C1
// 16 C2
// 17 C3
// 18 C4
// 19 C5
// UP D3
// LF D6
// DN D7
// RH B0
// A B1 Y
// B B2 X
// C B3 A
// D B4 B
// MN C0
// SH C1
// SL C2
// ST B5
// L1 C3
// L2 C4
// L3 C5
// L4 C6
// L5 D7
matrix[0] = (
(readPin(D3) << 0) |
(readPin(D6) << 1) |
(readPin(D7) << 2) |
(readPin(B0) << 3) |
(readPin(B1) << 4) |
(readPin(B2) << 5) |
(readPin(B3) << 6) |
(readPin(B4) << 7)
);
matrix[1] = (
(readPin(C0) << 0) |
(readPin(C1) << 1) |
(readPin(C2) << 2) |
(readPin(B5) << 3)
);
matrix[2] = (
(readPin(C3) << 0) |
(readPin(C4) << 1) |
(readPin(C5) << 2) |
(readPin(C6) << 3) |
(readPin(D7) << 4)
);

View File

@@ -1,52 +0,0 @@
# Copyright 2019 Jack Humbert <jack.humb@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 = atmega328p
PROTOCOL = VUSB
# unsupported features for now
NO_UART = yes
NO_SUSPEND_POWER_DOWN = yes
# processor frequency
F_CPU = 16000000
# Bootloader
# This definition is optional, and if your keyboard supports multiple bootloaders of
# different sizes, comment this out, and the correct address will be loaded
# automatically (+60). See bootloader.mk for all options.
# BOOTLOADER = usbasp
PROGRAM_CMD = avrdude -c usbasp -p m328p -U flash:w:$(BUILD_DIR)/$(TARGET).hex
# build options
BOOTMAGIC_ENABLE = no
MOUSEKEY_ENABLE = yes
EXTRAKEY_ENABLE = yes
CONSOLE_ENABLE = no
COMMAND_ENABLE = yes
KEY_LOCK_ENABLE = no
NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
AUDIO_ENABLE = no
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
OPT_DEFS = -DDEBUG_LEVEL=0
OPT_DEFS += -DBOOTLOADER_SIZE=2048
# custom matrix setup
CUSTOM_MATRIX = yes
SRC = matrix.c

View File

@@ -262,8 +262,8 @@
]
},
"LAYOUT_ortho_5x12": {
"layout": [
"key_count": 60,
"layout": [
{"label":"k00", "x":0, "y":0},
{"label":"k01", "x":1, "y":0},
{"label":"k02", "x":2, "y":0},

View File

@@ -6,12 +6,11 @@
"width": 4,
"height": 5,
"layouts": {
"LAYOUT_ortho_5x4": {
"LAYOUT_ortho_5x4": {
"layout": [{"x":0, "y":0}, {"x":1, "y":0}, {"x":2, "y":0}, {"x":3, "y":0}, {"x":0, "y":1}, {"x":1, "y":1}, {"x":2, "y":1}, {"x":3, "y":1}, {"x":0, "y":2}, {"x":1, "y":2}, {"x":2, "y":2}, {"x":3, "y":2}, {"x":0, "y":3}, {"x":1, "y":3}, {"x":2, "y":3}, {"x":3, "y":3}, {"x":0, "y":4}, {"x":1, "y":4}, {"x":2, "y":4}, {"x":3, "y":4}]
},
},
"LAYOUT_numpad_5x4": {
"layout": [{"x":0, "y":0}, {"x":1, "y":0}, {"x":2, "y":0}, {"x":3, "y":0}, {"x":0, "y":1}, {"x":1, "y":1}, {"x":2, "y":1}, {"x":3, "y":1, "h":2}, {"x":0, "y":2}, {"x":1, "y":2}, {"x":2, "y":2}, {"x":0, "y":3}, {"x":1, "y":3}, {"x":2, "y":3}, {"x":3, "y":3, "h":2}, {"x":0, "y":4, "w":2}, {"x":2, "y":4}]
}
"layout": [{"x":0, "y":0}, {"x":1, "y":0}, {"x":2, "y":0}, {"x":3, "y":0}, {"x":0, "y":1}, {"x":1, "y":1}, {"x":2, "y":1}, {"x":0, "y":2}, {"x":1, "y":2}, {"x":2, "y":2}, {"x":3, "y":1, "h":2}, {"x":0, "y":3}, {"x":1, "y":3}, {"x":2, "y":3}, {"x":0, "y":4, "w":2}, {"x":2, "y":4}, {"x":3, "y":3, "h":2}]
}
}
}

View File

@@ -20,17 +20,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#include "wait.h"
#include "print.h"
#include "debug.h"
#include "util.h"
#include "matrix.h"
#include "split_util.h"
#include "pro_micro.h"
#include "config.h"
#include "timer.h"
#include "split_flags.h"
#include "quantum.h"
#ifdef BACKLIGHT_ENABLE
# include "backlight.h"
@@ -91,8 +88,8 @@ static matrix_row_t matrix_debouncing[MATRIX_ROWS];
static uint8_t error_count = 0;
static uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
static uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
static pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
static pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
/* matrix state(1:on, 0:off) */
static matrix_row_t matrix[MATRIX_ROWS];
@@ -440,9 +437,7 @@ uint8_t matrix_key_count(void)
static void init_cols(void)
{
for(uint8_t x = 0; x < MATRIX_COLS; x++) {
uint8_t pin = col_pins[x];
_SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN
_SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI
setPinInputHigh(col_pins[x]);
}
}
@@ -460,13 +455,8 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
// For each col...
for(uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
// Select the col pin to read (active low)
uint8_t pin = col_pins[col_index];
uint8_t pin_state = (_SFR_IO8(pin >> 4) & _BV(pin & 0xF));
// Populate the matrix row with the state of the col pin
current_matrix[current_row] |= pin_state ? 0 : (ROW_SHIFTER << col_index);
current_matrix[current_row] |= readPin(col_pins[col_index]) ? 0 : (ROW_SHIFTER << col_index);
}
// Unselect row
@@ -477,24 +467,19 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
static void select_row(uint8_t row)
{
uint8_t pin = row_pins[row];
_SFR_IO8((pin >> 4) + 1) |= _BV(pin & 0xF); // OUT
_SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF); // LOW
writePinLow(row_pins[row]);
setPinOutput(row_pins[row]);
}
static void unselect_row(uint8_t row)
{
uint8_t pin = row_pins[row];
_SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN
_SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI
setPinInputHigh(row_pins[row]);
}
static void unselect_rows(void)
{
for(uint8_t x = 0; x < ROWS_PER_HAND; x++) {
uint8_t pin = row_pins[x];
_SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN
_SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI
setPinInputHigh(row_pins[x]);
}
}
@@ -503,9 +488,7 @@ static void unselect_rows(void)
static void init_rows(void)
{
for(uint8_t x = 0; x < ROWS_PER_HAND; x++) {
uint8_t pin = row_pins[x];
_SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN
_SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI
setPinInputHigh(row_pins[x]);
}
}
@@ -525,16 +508,16 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
matrix_row_t last_row_value = current_matrix[row_index];
// Check row pin state
if ((_SFR_IO8(row_pins[row_index] >> 4) & _BV(row_pins[row_index] & 0xF)) == 0)
{
// Pin LO, set col bit
current_matrix[row_index] |= (ROW_SHIFTER << current_col);
}
else
if (readPin(row_pins[row_index]))
{
// Pin HI, clear col bit
current_matrix[row_index] &= ~(ROW_SHIFTER << current_col);
}
else
{
// Pin LO, set col bit
current_matrix[row_index] |= (ROW_SHIFTER << current_col);
}
// Determine if the matrix changed state
if ((last_row_value != current_matrix[row_index]) && !(matrix_changed))
@@ -551,24 +534,19 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
static void select_col(uint8_t col)
{
uint8_t pin = col_pins[col];
_SFR_IO8((pin >> 4) + 1) |= _BV(pin & 0xF); // OUT
_SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF); // LOW
writePinLow(col_pins[col]);
setPinOutput(col_pins[col]);
}
static void unselect_col(uint8_t col)
{
uint8_t pin = col_pins[col];
_SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN
_SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI
setPinInputHigh(col_pins[col]);
}
static void unselect_cols(void)
{
for(uint8_t x = 0; x < MATRIX_COLS; x++) {
uint8_t pin = col_pins[x];
_SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN
_SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI
setPinInputHigh(col_pins[x]);
}
}

View File

@@ -1,24 +1,19 @@
#include <avr/io.h>
#include <avr/wdt.h>
#include <avr/power.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <avr/eeprom.h>
#include "split_util.h"
#include "matrix.h"
#include "keyboard.h"
#include "config.h"
#include "timer.h"
#include "split_flags.h"
#include "quantum.h"
#ifdef EE_HANDS
# include "tmk_core/common/eeprom.h"
#endif
#ifdef BACKLIGHT_ENABLE
# include "backlight.h"
#endif
#ifdef SPLIT_HAND_PIN
# include "pincontrol.h"
#endif
#if defined(USE_I2C) || defined(EH)
# include "i2c.h"
#endif
@@ -30,8 +25,8 @@ volatile uint8_t setTries = 0;
static void setup_handedness(void) {
#ifdef SPLIT_HAND_PIN
// Test pin SPLIT_HAND_PIN for High/Low, if low it's right hand
pinMode(SPLIT_HAND_PIN, PinDirectionInput);
isLeftHand = digitalRead(SPLIT_HAND_PIN);
setPinInput(SPLIT_HAND_PIN);
isLeftHand = readPin(SPLIT_HAND_PIN);
#else
#ifdef EE_HANDS
isLeftHand = eeprom_read_byte(EECONFIG_HANDEDNESS);