Keyboard: add ergoinu keyboard (#3655)
* add ergoinu * remove unnecessary code * replace include guard delete unused code * remove unused RGBLED definesmaster
parent
a828d49f8c
commit
303ca46e77
|
@ -0,0 +1,116 @@
|
||||||
|
/*
|
||||||
|
Copyright 2012 Jun Wako <wakojun@gmail.com>
|
||||||
|
Copyright 2015 Jack Humbert
|
||||||
|
Copyright 2018 Takuya Urakawa<twitter:@hsgw>
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
#include "config_common.h"
|
||||||
|
#include <serial_config.h>
|
||||||
|
|
||||||
|
/* USB Device descriptor parameter
|
||||||
|
VID & PID are lisenced from microchip sublisence program, Don't use other project! */
|
||||||
|
#define VENDOR_ID 0x04D8
|
||||||
|
#define PRODUCT_ID 0xEE60
|
||||||
|
#define DEVICE_VER 0x0001
|
||||||
|
#define MANUFACTURER Dm9Records
|
||||||
|
#define PRODUCT ergoinu
|
||||||
|
#define DESCRIPTION An (Not Portable But Small) Ergonomic split keyboard
|
||||||
|
|
||||||
|
|
||||||
|
#define PREVENT_STUCK_MODIFIERS
|
||||||
|
#define TAPPING_FORCE_HOLD
|
||||||
|
#define TAPPING_TERM 100
|
||||||
|
|
||||||
|
#define USE_SERIAL
|
||||||
|
|
||||||
|
/* Select hand configuration */
|
||||||
|
#define MASTER_LEFT
|
||||||
|
// #define MASTER_RIGHT
|
||||||
|
// #define EE_HANDS
|
||||||
|
|
||||||
|
/* key matrix size */
|
||||||
|
// Rows are doubled-up
|
||||||
|
#define MATRIX_ROWS 10
|
||||||
|
#define MATRIX_ROW_PINS { F6, F7, B1, B3, B2 }
|
||||||
|
|
||||||
|
// wiring of each half
|
||||||
|
#define MATRIX_COLS 7
|
||||||
|
#define MATRIX_COL_PINS { B4, E6, D7, C6, D4, F5, F4 }
|
||||||
|
|
||||||
|
/* define if matrix has ghost */
|
||||||
|
//#define MATRIX_HAS_GHOST
|
||||||
|
|
||||||
|
/* number of backlight levels */
|
||||||
|
// #define BACKLIGHT_LEVELS 3
|
||||||
|
|
||||||
|
/* Set 0 if debouncing isn't needed */
|
||||||
|
#define DEBOUNCING_DELAY 5
|
||||||
|
|
||||||
|
/* 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() ( \
|
||||||
|
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
|
||||||
|
)
|
||||||
|
|
||||||
|
/* ws2812 RGB LED */
|
||||||
|
#define RGB_DI_PIN B6
|
||||||
|
|
||||||
|
#define RGBLED_NUM 7
|
||||||
|
|
||||||
|
#ifndef IOS_DEVICE_ENABLE
|
||||||
|
#if RGBLED_NUM <= 7
|
||||||
|
#define RGBLIGHT_LIMIT_VAL 255
|
||||||
|
#define RGBLIGHT_VAL_STEP 17
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define RGBLIGHT_LIMIT_VAL 90
|
||||||
|
#define RGBLIGHT_VAL_STEP 4
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define RGBLIGHT_HUE_STEP 10
|
||||||
|
#define RGBLIGHT_SAT_STEP 17
|
||||||
|
|
||||||
|
#if defined(RGBLIGHT_ENABLE) && !defined(IOS_DEVICE_ENABLE)
|
||||||
|
#define USB_MAX_POWER_CONSUMPTION 500
|
||||||
|
#else
|
||||||
|
// fix iPhone and iPad power adapter issue
|
||||||
|
// iOS device need lessthan 100
|
||||||
|
#define USB_MAX_POWER_CONSUMPTION 100
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Feature disable options
|
||||||
|
* These options are also useful to firmware size reduction.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* disable debug print */
|
||||||
|
// #define NO_DEBUG
|
||||||
|
|
||||||
|
/* disable print */
|
||||||
|
// #define NO_PRINT
|
||||||
|
|
||||||
|
/* disable action features */
|
||||||
|
//#define NO_ACTION_LAYER
|
||||||
|
//#define NO_ACTION_TAPPING
|
||||||
|
//#define NO_ACTION_ONESHOT
|
||||||
|
//#define NO_ACTION_MACRO
|
||||||
|
//#define NO_ACTION_FUNCTION
|
|
@ -0,0 +1,5 @@
|
||||||
|
#include "ergoinu.h"
|
||||||
|
|
||||||
|
void matrix_init_kb(void) {
|
||||||
|
matrix_init_user();
|
||||||
|
};
|
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
Copyright 2018 Takuya Urakawa<twitter:@hsgw>
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
#include "quantum.h"
|
||||||
|
|
||||||
|
#ifdef RGBLIGHT_ENABLE
|
||||||
|
#include "ws2812.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define LAYOUT( \
|
||||||
|
L00, L01, L02, L03, L04, L05, L06, R00, R01, R02, R03, R04, R05, R06, \
|
||||||
|
L07, L08, L09, L10, L11, L12, L13, R07, R08, R09, R10, R11, R12, R13, \
|
||||||
|
L14, L15, L16, L17, L18, L19, R14, R15, R16, R17, R18, R19, R20, \
|
||||||
|
L20, L21, L22, L23, L24, L25, R21, R22, R23, R24, R25, R26, R27,\
|
||||||
|
L26, L27, L28, L29, L30, R28, R29, R30, R31, R32 \
|
||||||
|
) { \
|
||||||
|
{ L00, L01, L02, L03, L04, L05, L06 }, \
|
||||||
|
{ L07, L08, L09, L10, L11, L12, L13 }, \
|
||||||
|
{ L14, KC_NO, L15, L16, L17, L18, L19 }, \
|
||||||
|
{ L20, KC_NO, L21, L22, L23, L24, L25 }, \
|
||||||
|
{ KC_NO, KC_NO, L26, L27, L28, L29, L30}, \
|
||||||
|
{ R06, R05, R04, R03, R02, R01, R00 }, \
|
||||||
|
{ R13, R12, R11, R10, R09, R08, R07 }, \
|
||||||
|
{ R20, R19, R18, R17, R16, R15, R14 }, \
|
||||||
|
{ R27, R26, R25, R24, R23, R22, R21 }, \
|
||||||
|
{ KC_NO, KC_NO, R32, R31, R30, R29, R28 } \
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"keyboard_name": "Ergoinu",
|
||||||
|
"url": "",
|
||||||
|
"maintainer": "hsgw",
|
||||||
|
"width": 17,
|
||||||
|
"height": 6.75,
|
||||||
|
"layouts": {
|
||||||
|
"LAYOUT": {
|
||||||
|
"key_count": 64,
|
||||||
|
"layout": [
|
||||||
|
{"x": 0, "y": 0.6}, {"x": 1, "y": 0.4}, {"x": 2, "y": 0.4}, {"x": 3, "y": 0.25}, {"x": 4, "y": 0}, {"x": 5, "y": 0.25}, {"x": 6, "y": 0.4}, {"x": 10, "y": 0.4}, {"x": 11, "y": 0.25}, {"x": 12, "y": 0}, {"x": 13, "y": 0.25}, {"x": 14, "y": 0.4}, {"x": 15, "y": 0.4}, {"x": 16, "y": 0.6},
|
||||||
|
{"x": 0, "y": 1.6}, {"x": 1, "y": 1.4}, {"x": 2, "y": 1.4}, {"x": 3, "y": 1.25}, {"x": 4, "y": 1}, {"x": 5, "y": 1.25}, {"x": 6, "y": 1.4}, {"x": 10, "y": 1.4}, {"x": 11, "y": 1.25}, {"x": 12, "y": 1}, {"x": 13, "y": 1.25}, {"x": 14, "y": 1.4}, {"x": 15, "y": 1.4}, {"x": 16, "y": 1.6},
|
||||||
|
{"x": 0.25, "y": 2.6, "W":1.75}, {"x": 2, "y": 2.4}, {"x": 3, "y": 2.25}, {"x": 4, "y": 2}, {"x": 5, "y": 2.25}, {"x": 6, "y": 2.4}, {"x": 10, "y": 2.4}, {"x": 11, "y": 2.25}, {"x": 12, "y": 2}, {"x": 13, "y": 2.25}, {"x": 14, "y": 2.4}, {"x": 15, "y": 2.4}, {"x": 16, "y": 2.6},
|
||||||
|
{"x": 0.25, "y": 3.6, "W":1.75}, {"x": 2, "y": 3.4}, {"x": 3, "y": 3.25}, {"x": 4, "y": 3}, {"x": 5, "y": 3.25}, {"x": 6, "y": 3.4}, {"x": 10, "y": 3.4}, {"x": 11, "y": 3.25}, {"x": 12, "y": 3}, {"x": 13, "y": 3.25}, {"x": 14, "y": 3.4}, {"x": 15, "y": 3.4}, {"x": 16, "y": 3.6},
|
||||||
|
{"x": 3, "y": 4.25}, {"x": 4, "y": 4}, {"x": 5, "y": 4.25}, {"x": 6, "y": 4.4}, {"X":7.5, "Y":4.4, "H":1.25,"R":30, "RX":6, "RY":4.4},
|
||||||
|
{"X":8.25, "Y":4.4, "H":1.25,"R":-30, "RX":11, "RY":4.4}, {"x": 10, "y": 4.4}, {"x": 11, "y": 4.25}, {"x": 12, "y": 4}, {"x": 13, "y": 4.4}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
This is the c configuration file for the keymap
|
||||||
|
|
||||||
|
Copyright 2012 Jun Wako <wakojun@gmail.com>
|
||||||
|
Copyright 2015 Jack Humbert
|
||||||
|
Copyright 2018 Takuya Urakawa <Twitter:@hsgw>
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
#define RGBLIGHT_ANIMATIONS
|
|
@ -0,0 +1,101 @@
|
||||||
|
#include QMK_KEYBOARD_H
|
||||||
|
|
||||||
|
#ifdef RGBLIGHT_ENABLE
|
||||||
|
//Following line allows macro to read current RGB settings
|
||||||
|
extern rgblight_config_t rgblight_config;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define JA_CLON KC_QUOT // : and +
|
||||||
|
#define JA_AT KC_LBRC // @ and `
|
||||||
|
#define JA_HAT KC_EQL // ^ and ~
|
||||||
|
#define JA_ENUN KC_RO // \ and _ (EN mark and UNder score)
|
||||||
|
#define JA_ENVL KC_JYEN // \ and | (EN mark and Vertical Line)
|
||||||
|
#define JA_LBRC KC_RBRC // [ and {
|
||||||
|
#define JA_RBRC KC_BSLS // ] and }
|
||||||
|
|
||||||
|
enum LAYER_NO {
|
||||||
|
BASE = 0,
|
||||||
|
META,
|
||||||
|
CONF
|
||||||
|
};
|
||||||
|
|
||||||
|
enum CUSTOM_KEYCODES {
|
||||||
|
RGB_RST = SAFE_RANGE,
|
||||||
|
RGB_TYPE,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Fillers to make layering more clear
|
||||||
|
#define ______ KC_TRNS
|
||||||
|
#define XXXXXX KC_NO
|
||||||
|
|
||||||
|
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
|
|
||||||
|
[BASE] = LAYOUT( \
|
||||||
|
KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSLS, \
|
||||||
|
KC_DEL, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, \
|
||||||
|
KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_GRV, \
|
||||||
|
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_RSFT, \
|
||||||
|
MO(META),KC_LALT, KC_LGUI, KC_ENT, KC_SPC, KC_ENT, KC_BSPC, KC_RGUI, KC_RALT, MO(META) \
|
||||||
|
),
|
||||||
|
|
||||||
|
[META] = LAYOUT( \
|
||||||
|
MO(CONF),KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_INS, \
|
||||||
|
______, KC_CAPS, ______, ______, ______, ______, ______, ______, ______, ______, KC_SLCK, KC_PSCR, KC_HOME, KC_END, \
|
||||||
|
______, ______, ______, ______, ______, ______, ______, ______, ______, KC_PAUS, KC_PGUP, KC_UP, KC_PGDN, \
|
||||||
|
______, ______, ______, ______, ______, ______, ______, ______, ______, ______, KC_LEFT, KC_DOWN, KC_RGHT, \
|
||||||
|
______, ______, ______, ______, ______, ______, ______, ______, ______, ______ \
|
||||||
|
),
|
||||||
|
[CONF] = LAYOUT( \
|
||||||
|
______, RGB_TYPE,RGB_MOD, RGB_VAI, RGB_HUI, RGB_HUI, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, \
|
||||||
|
RGB_RST, RGB_TOG, RGB_RMOD, RGB_VAD, RGB_HUD, RGB_HUD, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, \
|
||||||
|
XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, \
|
||||||
|
XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, \
|
||||||
|
XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX \
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
bool enableLEDTypeAnime = false;
|
||||||
|
|
||||||
|
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
|
switch(keycode) {
|
||||||
|
case RGB_RST:
|
||||||
|
#ifdef RGBLIGHT_ENABLE
|
||||||
|
if (record->event.pressed) {
|
||||||
|
eeconfig_update_rgblight_default();
|
||||||
|
rgblight_enable();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case RGB_MOD:
|
||||||
|
#ifdef RGBLIGHT_ENABLE
|
||||||
|
if (record->event.pressed) {
|
||||||
|
enableLEDTypeAnime = false;
|
||||||
|
rgblight_step();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
case RGB_TYPE:
|
||||||
|
#ifdef RGBLIGHT_ENABLE
|
||||||
|
if (record->event.pressed) {
|
||||||
|
rgblight_enable_noeeprom();
|
||||||
|
rgblight_mode_noeeprom(1);
|
||||||
|
enableLEDTypeAnime = !enableLEDTypeAnime;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#ifdef RGBLIGHT_ENABLE
|
||||||
|
if(enableLEDTypeAnime) {
|
||||||
|
rgblight_mode_noeeprom(1);
|
||||||
|
uint16_t hue = (rgblight_config.hue + 5) % 360;
|
||||||
|
rgblight_sethsv_noeeprom(hue, rgblight_config.sat, rgblight_config.val);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void matrix_init_user(void) {
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
|
||||||
|
# Build Options
|
||||||
|
# change to "no" to disable the options, or define them in the Makefile in
|
||||||
|
# the appropriate keymap folder that will get included automatically
|
||||||
|
#
|
||||||
|
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
|
||||||
|
MOUSEKEY_ENABLE = no # Mouse keys(+4700)
|
||||||
|
EXTRAKEY_ENABLE = no # Audio control and System control(+450)
|
||||||
|
CONSOLE_ENABLE = no # Console for debug(+400)
|
||||||
|
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||||
|
NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
|
||||||
|
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
|
||||||
|
MIDI_ENABLE = no # MIDI controls
|
||||||
|
AUDIO_ENABLE = no # Audio output on port C6
|
||||||
|
UNICODE_ENABLE = no # Unicode
|
||||||
|
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
|
||||||
|
RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight. Do not enable this with audio at the same time.
|
||||||
|
SWAP_HANDS_ENABLE = no # Enable one-hand typing
|
||||||
|
|
||||||
|
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
|
||||||
|
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
|
||||||
|
|
||||||
|
# ergoinu configs
|
||||||
|
DISABLE_PROMICRO_LEDs = yes
|
||||||
|
|
||||||
|
# Uncomment these for debugging
|
||||||
|
# $(info -- RGBLIGHT_ENABLE=$(RGBLIGHT_ENABLE))
|
||||||
|
# $(info -- OPT_DEFS=$(OPT_DEFS))
|
||||||
|
# $(info )
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
This is the c configuration file for the keymap
|
||||||
|
|
||||||
|
Copyright 2012 Jun Wako <wakojun@gmail.com>
|
||||||
|
Copyright 2015 Jack Humbert
|
||||||
|
Copyright 2018 Takuya Urakawa <Twitter:@hsgw>
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
#define RGBLIGHT_ANIMATIONS
|
|
@ -0,0 +1,101 @@
|
||||||
|
#include QMK_KEYBOARD_H
|
||||||
|
|
||||||
|
#ifdef RGBLIGHT_ENABLE
|
||||||
|
//Following line allows macro to read current RGB settings
|
||||||
|
extern rgblight_config_t rgblight_config;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define JA_CLON KC_QUOT // : and +
|
||||||
|
#define JA_AT KC_LBRC // @ and `
|
||||||
|
#define JA_HAT KC_EQL // ^ and ~
|
||||||
|
#define JA_ENUN KC_RO // \ and _ (EN mark and UNder score)
|
||||||
|
#define JA_ENVL KC_JYEN // \ and | (EN mark and Vertical Line)
|
||||||
|
#define JA_LBRC KC_RBRC // [ and {
|
||||||
|
#define JA_RBRC KC_BSLS // ] and }
|
||||||
|
|
||||||
|
enum LAYER_NO {
|
||||||
|
BASE = 0,
|
||||||
|
META,
|
||||||
|
CONF
|
||||||
|
};
|
||||||
|
|
||||||
|
enum CUSTOM_KEYCODES {
|
||||||
|
RGB_RST = SAFE_RANGE,
|
||||||
|
RGB_TYPE,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Fillers to make layering more clear
|
||||||
|
#define ______ KC_TRNS
|
||||||
|
#define XXXXXX KC_NO
|
||||||
|
|
||||||
|
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
|
|
||||||
|
[BASE] = LAYOUT( \
|
||||||
|
KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, JA_HAT, KC_JYEN, \
|
||||||
|
KC_DEL, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, JA_AT, JA_LBRC, \
|
||||||
|
KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, JA_CLON, JA_RBRC, \
|
||||||
|
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RO, KC_RSFT, \
|
||||||
|
MO(META),KC_LALT, KC_ZKHK, KC_BSPC, KC_SPC, KC_ENT, KC_BSPC, KC_MHEN, KC_KANA, MO(META) \
|
||||||
|
),
|
||||||
|
|
||||||
|
|
||||||
|
[META] = LAYOUT( \
|
||||||
|
MO(CONF),KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_INS, \
|
||||||
|
______, KC_CAPS, ______, KC_UP, ______, ______, ______, ______, ______, ______, KC_SLCK, KC_PSCR, KC_HOME, KC_END, \
|
||||||
|
______, KC_LEFT, KC_DOWN, KC_RGHT, ______, ______, ______, ______, ______, KC_PAUS, KC_PGUP, KC_UP, KC_PGDN, \
|
||||||
|
______, ______, ______, ______, ______, ______, ______, ______, ______, ______, KC_LEFT, KC_DOWN, KC_RGHT, \
|
||||||
|
______, ______, KC_RGUI, KC_DEL, KC_ENT, ______, KC_DEL, KC_HENK, KC_LGUI, ______ \
|
||||||
|
),
|
||||||
|
[CONF] = LAYOUT( \
|
||||||
|
______, RGB_TYPE,RGB_MOD, RGB_VAI, RGB_HUI, RGB_HUI, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, \
|
||||||
|
RGB_RST, RGB_TOG, RGB_RMOD, RGB_VAD, RGB_HUD, RGB_HUD, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, \
|
||||||
|
XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, \
|
||||||
|
XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, \
|
||||||
|
XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX \
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
bool enableLEDTypeAnime = false;
|
||||||
|
|
||||||
|
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
|
switch(keycode) {
|
||||||
|
case RGB_RST:
|
||||||
|
#ifdef RGBLIGHT_ENABLE
|
||||||
|
if (record->event.pressed) {
|
||||||
|
eeconfig_update_rgblight_default();
|
||||||
|
rgblight_enable();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case RGB_MOD:
|
||||||
|
#ifdef RGBLIGHT_ENABLE
|
||||||
|
if (record->event.pressed) {
|
||||||
|
enableLEDTypeAnime = false;
|
||||||
|
rgblight_step();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
case RGB_TYPE:
|
||||||
|
#ifdef RGBLIGHT_ENABLE
|
||||||
|
if (record->event.pressed) {
|
||||||
|
rgblight_enable_noeeprom();
|
||||||
|
rgblight_mode_noeeprom(1);
|
||||||
|
enableLEDTypeAnime = !enableLEDTypeAnime;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#ifdef RGBLIGHT_ENABLE
|
||||||
|
if(enableLEDTypeAnime) {
|
||||||
|
rgblight_mode_noeeprom(1);
|
||||||
|
uint16_t hue = (rgblight_config.hue + 5) % 360;
|
||||||
|
rgblight_sethsv_noeeprom(hue, rgblight_config.sat, rgblight_config.val);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void matrix_init_user(void) {
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
|
||||||
|
# Build Options
|
||||||
|
# change to "no" to disable the options, or define them in the Makefile in
|
||||||
|
# the appropriate keymap folder that will get included automatically
|
||||||
|
#
|
||||||
|
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
|
||||||
|
MOUSEKEY_ENABLE = no # Mouse keys(+4700)
|
||||||
|
EXTRAKEY_ENABLE = no # Audio control and System control(+450)
|
||||||
|
CONSOLE_ENABLE = no # Console for debug(+400)
|
||||||
|
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||||
|
NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
|
||||||
|
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
|
||||||
|
MIDI_ENABLE = no # MIDI controls
|
||||||
|
AUDIO_ENABLE = no # Audio output on port C6
|
||||||
|
UNICODE_ENABLE = no # Unicode
|
||||||
|
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
|
||||||
|
RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight. Do not enable this with audio at the same time.
|
||||||
|
SWAP_HANDS_ENABLE = no # Enable one-hand typing
|
||||||
|
|
||||||
|
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
|
||||||
|
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
|
||||||
|
|
||||||
|
# ergoinu configs
|
||||||
|
DISABLE_PROMICRO_LEDs = yes
|
||||||
|
|
||||||
|
# Uncomment these for debugging
|
||||||
|
# $(info -- RGBLIGHT_ENABLE=$(RGBLIGHT_ENABLE))
|
||||||
|
# $(info -- OPT_DEFS=$(OPT_DEFS))
|
||||||
|
# $(info )
|
|
@ -0,0 +1,303 @@
|
||||||
|
/*
|
||||||
|
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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* scan matrix
|
||||||
|
*/
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/wdt.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <util/delay.h>
|
||||||
|
#include "print.h"
|
||||||
|
#include "debug.h"
|
||||||
|
#include "util.h"
|
||||||
|
#include "matrix.h"
|
||||||
|
#include "split_util.h"
|
||||||
|
|
||||||
|
#include "serial.h"
|
||||||
|
|
||||||
|
// from pro_micro.h
|
||||||
|
#define TX_RX_LED_INIT DDRD |= (1<<5), DDRB |= (1<<0)
|
||||||
|
|
||||||
|
#ifndef DISABLE_PROMICRO_LEDs
|
||||||
|
#define TXLED0 PORTD |= (1<<5)
|
||||||
|
#define TXLED1 PORTD &= ~(1<<5)
|
||||||
|
#define RXLED0 PORTB |= (1<<0)
|
||||||
|
#define RXLED1 PORTB &= ~(1<<0)
|
||||||
|
#else
|
||||||
|
#define TXLED0
|
||||||
|
#define TXLED1
|
||||||
|
#define RXLED0
|
||||||
|
#define RXLED1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef DEBOUNCE
|
||||||
|
# define DEBOUNCE 5
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ERROR_DISCONNECT_COUNT 5
|
||||||
|
|
||||||
|
static uint8_t debouncing = DEBOUNCE;
|
||||||
|
static const int ROWS_PER_HAND = MATRIX_ROWS/2;
|
||||||
|
static uint8_t error_count = 0;
|
||||||
|
uint8_t is_master = 0 ;
|
||||||
|
|
||||||
|
static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
|
||||||
|
static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
|
||||||
|
|
||||||
|
/* matrix state(1:on, 0:off) */
|
||||||
|
static matrix_row_t matrix[MATRIX_ROWS];
|
||||||
|
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
||||||
|
|
||||||
|
static matrix_row_t read_cols(void);
|
||||||
|
static void init_cols(void);
|
||||||
|
static void unselect_rows(void);
|
||||||
|
static void select_row(uint8_t row);
|
||||||
|
static uint8_t matrix_master_scan(void);
|
||||||
|
|
||||||
|
|
||||||
|
__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) {
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
uint8_t matrix_rows(void) {
|
||||||
|
return MATRIX_ROWS;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
uint8_t matrix_cols(void) {
|
||||||
|
return MATRIX_COLS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void matrix_init(void) {
|
||||||
|
debug_enable = true;
|
||||||
|
debug_matrix = true;
|
||||||
|
debug_mouse = true;
|
||||||
|
// initialize row and col
|
||||||
|
unselect_rows();
|
||||||
|
init_cols();
|
||||||
|
|
||||||
|
TX_RX_LED_INIT;
|
||||||
|
|
||||||
|
#ifdef DISABLE_PROMICRO_LEDs
|
||||||
|
PORTD |= (1<<5);
|
||||||
|
PORTB |= (1<<0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// initialize matrix state: all keys off
|
||||||
|
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
||||||
|
matrix[i] = 0;
|
||||||
|
matrix_debouncing[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
is_master = has_usb();
|
||||||
|
|
||||||
|
matrix_init_quantum();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t _matrix_scan(void) {
|
||||||
|
// Right hand is stored after the left in the matirx so, we need to offset it
|
||||||
|
int offset = isLeftHand ? 0 : (ROWS_PER_HAND);
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < ROWS_PER_HAND; i++) {
|
||||||
|
select_row(i);
|
||||||
|
_delay_us(30); // without this wait read unstable value.
|
||||||
|
matrix_row_t cols = read_cols();
|
||||||
|
if (matrix_debouncing[i+offset] != cols) {
|
||||||
|
matrix_debouncing[i+offset] = cols;
|
||||||
|
debouncing = DEBOUNCE;
|
||||||
|
}
|
||||||
|
unselect_rows();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debouncing) {
|
||||||
|
if (--debouncing) {
|
||||||
|
_delay_ms(1);
|
||||||
|
} else {
|
||||||
|
for (uint8_t i = 0; i < ROWS_PER_HAND; i++) {
|
||||||
|
matrix[i+offset] = matrix_debouncing[i+offset];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int serial_transaction(void) {
|
||||||
|
int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
|
||||||
|
int ret=serial_update_buffers();
|
||||||
|
if (ret ) {
|
||||||
|
if(ret==2)RXLED1;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
RXLED0;
|
||||||
|
for (int i = 0; i < ROWS_PER_HAND; ++i) {
|
||||||
|
matrix[slaveOffset+i] = serial_slave_buffer[i];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t matrix_scan(void) {
|
||||||
|
if (is_master) {
|
||||||
|
matrix_master_scan();
|
||||||
|
}else{
|
||||||
|
matrix_slave_scan();
|
||||||
|
|
||||||
|
// if(serial_slave_DATA_CORRUPT()){
|
||||||
|
// TXLED0;
|
||||||
|
int offset = (isLeftHand) ? ROWS_PER_HAND : 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < ROWS_PER_HAND; ++i) {
|
||||||
|
matrix[offset+i] = serial_master_buffer[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
// }else{
|
||||||
|
// TXLED1;
|
||||||
|
// }
|
||||||
|
|
||||||
|
matrix_scan_quantum();
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t matrix_master_scan(void) {
|
||||||
|
|
||||||
|
int ret = _matrix_scan();
|
||||||
|
|
||||||
|
int offset = (isLeftHand) ? 0 : ROWS_PER_HAND;
|
||||||
|
|
||||||
|
for (int i = 0; i < ROWS_PER_HAND; ++i) {
|
||||||
|
serial_master_buffer[i] = matrix[offset+i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if( serial_transaction() ) {
|
||||||
|
// turn on the indicator led when halves are disconnected
|
||||||
|
TXLED1;
|
||||||
|
|
||||||
|
error_count++;
|
||||||
|
|
||||||
|
if (error_count > ERROR_DISCONNECT_COUNT) {
|
||||||
|
// reset other half if disconnected
|
||||||
|
int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
|
||||||
|
for (int i = 0; i < ROWS_PER_HAND; ++i) {
|
||||||
|
matrix[slaveOffset+i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// turn off the indicator led on no error
|
||||||
|
TXLED0;
|
||||||
|
error_count = 0;
|
||||||
|
}
|
||||||
|
matrix_scan_quantum();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void matrix_slave_scan(void) {
|
||||||
|
_matrix_scan();
|
||||||
|
|
||||||
|
int offset = (isLeftHand) ? 0 : ROWS_PER_HAND;
|
||||||
|
|
||||||
|
for (int i = 0; i < ROWS_PER_HAND; ++i) {
|
||||||
|
serial_slave_buffer[i] = matrix[offset+i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool matrix_is_modified(void)
|
||||||
|
{
|
||||||
|
if (debouncing) return false;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void init_cols(void)
|
||||||
|
{
|
||||||
|
for(int x = 0; x < MATRIX_COLS; x++) {
|
||||||
|
_SFR_IO8((col_pins[x] >> 4) + 1) &= ~_BV(col_pins[x] & 0xF);
|
||||||
|
_SFR_IO8((col_pins[x] >> 4) + 2) |= _BV(col_pins[x] & 0xF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static matrix_row_t read_cols(void)
|
||||||
|
{
|
||||||
|
matrix_row_t result = 0;
|
||||||
|
for(int x = 0; x < MATRIX_COLS; x++) {
|
||||||
|
result |= (_SFR_IO8(col_pins[x] >> 4) & _BV(col_pins[x] & 0xF)) ? 0 : (1 << x);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void unselect_rows(void)
|
||||||
|
{
|
||||||
|
for(int x = 0; x < ROWS_PER_HAND; x++) {
|
||||||
|
_SFR_IO8((row_pins[x] >> 4) + 1) &= ~_BV(row_pins[x] & 0xF);
|
||||||
|
_SFR_IO8((row_pins[x] >> 4) + 2) |= _BV(row_pins[x] & 0xF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void select_row(uint8_t row)
|
||||||
|
{
|
||||||
|
_SFR_IO8((row_pins[row] >> 4) + 1) |= _BV(row_pins[row] & 0xF);
|
||||||
|
_SFR_IO8((row_pins[row] >> 4) + 2) &= ~_BV(row_pins[row] & 0xF);
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
ErgoInu
|
||||||
|
===
|
||||||
|
|
||||||
|
![ergoinu](https://i.imgur.com/4CCM8Vl.jpg)
|
||||||
|
|
||||||
|
An (Not Portable But Small) Ergonomic Split Keyboard.
|
||||||
|
|
||||||
|
Keyboard Maintainer: [hsgw](https://github.com/hsgw/) [twitter](https://twitter.com/hsgw)
|
||||||
|
Hardware Supported: Pro Micro
|
||||||
|
Hardware Availability & Repository: [https://github.com/hsgw/ergoinu](https://github.com/hsgw/ergoinu)
|
||||||
|
|
||||||
|
Make example for this keyboard (after setting up your build environment):
|
||||||
|
|
||||||
|
make ergoinu:default
|
||||||
|
|
||||||
|
(or)
|
||||||
|
|
||||||
|
make ergoinu:default_jis
|
||||||
|
|
||||||
|
|
||||||
|
See [build environment setup](https://docs.qmk.fm/build_environment_setup.html) then the [make instructions](https://docs.qmk.fm/make_instructions.html) for more information.
|
|
@ -0,0 +1,84 @@
|
||||||
|
SRC += matrix.c serial.c split_util.c
|
||||||
|
|
||||||
|
# MCU name
|
||||||
|
#MCU = at90usb1287
|
||||||
|
MCU = atmega32u4
|
||||||
|
|
||||||
|
# Processor frequency.
|
||||||
|
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||||
|
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||||
|
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||||
|
# automatically to create a 32-bit value in your source code.
|
||||||
|
#
|
||||||
|
# This will be an integer division of F_USB below, as it is sourced by
|
||||||
|
# F_USB after it has run through any CPU prescalers. Note that this value
|
||||||
|
# does not *change* the processor frequency - it should merely be updated to
|
||||||
|
# reflect the processor speed set externally so that the code can use accurate
|
||||||
|
# software delays.
|
||||||
|
F_CPU = 16000000
|
||||||
|
|
||||||
|
#
|
||||||
|
# LUFA specific
|
||||||
|
#
|
||||||
|
# Target architecture (see library "Board Types" documentation).
|
||||||
|
ARCH = AVR8
|
||||||
|
|
||||||
|
# Input clock frequency.
|
||||||
|
# This will define a symbol, F_USB, in all source code files equal to the
|
||||||
|
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||||
|
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||||
|
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||||
|
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
|
||||||
|
# at the end, this will be done automatically to create a 32-bit value in your
|
||||||
|
# source code.
|
||||||
|
#
|
||||||
|
# If no clock division is performed on the input clock inside the AVR (via the
|
||||||
|
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
|
||||||
|
F_USB = $(F_CPU)
|
||||||
|
|
||||||
|
# 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 = caterina
|
||||||
|
|
||||||
|
# Interrupt driven control endpoint task(+60)
|
||||||
|
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
|
||||||
|
|
||||||
|
# Build Options
|
||||||
|
# change to "no" to disable the options, or define them in the Makefile in
|
||||||
|
# the appropriate keymap folder that will get included automatically
|
||||||
|
#
|
||||||
|
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
|
||||||
|
MOUSEKEY_ENABLE = no # Mouse keys(+4700)
|
||||||
|
EXTRAKEY_ENABLE = no # Audio control and System control(+450)
|
||||||
|
CONSOLE_ENABLE = no # Console for debug(+400)
|
||||||
|
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||||
|
NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
|
||||||
|
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
|
||||||
|
MIDI_ENABLE = no # MIDI controls
|
||||||
|
AUDIO_ENABLE = no # Audio output on port C6
|
||||||
|
UNICODE_ENABLE = no # Unicode
|
||||||
|
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
|
||||||
|
RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time.
|
||||||
|
SUBPROJECT_rev1 = no
|
||||||
|
USE_I2C = no # i2c is not supported
|
||||||
|
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
|
||||||
|
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
|
||||||
|
|
||||||
|
CUSTOM_MATRIX = yes
|
||||||
|
|
||||||
|
DEFAULT_FOLDER = ergoinu
|
||||||
|
|
||||||
|
# ergoinu configs
|
||||||
|
DISABLE_PROMICRO_LEDs = yes
|
||||||
|
|
||||||
|
ifneq ($(strip $(ERGOINU)),)
|
||||||
|
ifeq ($(findstring promicroled, $(ERGOINU)), promicroled)
|
||||||
|
DISABLE_PROMICRO_LEDs = no
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(strip $(DISABLE_PROMICRO_LEDs)), yes)
|
||||||
|
OPT_DEFS += -DDISABLE_PROMICRO_LEDs
|
||||||
|
endif
|
|
@ -0,0 +1,295 @@
|
||||||
|
/*
|
||||||
|
* WARNING: be careful changing this code, it is very timing dependent
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef F_CPU
|
||||||
|
#define F_CPU 16000000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <util/delay.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include "serial.h"
|
||||||
|
|
||||||
|
#ifdef USE_SERIAL
|
||||||
|
|
||||||
|
#define _delay_sub_us(x) __builtin_avr_delay_cycles(x)
|
||||||
|
|
||||||
|
// Serial pulse period in microseconds.
|
||||||
|
#define SELECT_SERIAL_SPEED 1
|
||||||
|
#if SELECT_SERIAL_SPEED == 0
|
||||||
|
// Very High speed
|
||||||
|
#define SERIAL_DELAY 4 // micro sec
|
||||||
|
#define READ_WRITE_START_ADJUST 30 // cycles
|
||||||
|
#define READ_WRITE_WIDTH_ADJUST 10 // cycles
|
||||||
|
#elif SELECT_SERIAL_SPEED == 1
|
||||||
|
// High speed
|
||||||
|
#define SERIAL_DELAY 6 // micro sec
|
||||||
|
#define READ_WRITE_START_ADJUST 23 // cycles
|
||||||
|
#define READ_WRITE_WIDTH_ADJUST 10 // cycles
|
||||||
|
#elif SELECT_SERIAL_SPEED == 2
|
||||||
|
// Middle speed
|
||||||
|
#define SERIAL_DELAY 12 // micro sec
|
||||||
|
#define READ_WRITE_START_ADJUST 25 // cycles
|
||||||
|
#define READ_WRITE_WIDTH_ADJUST 10 // cycles
|
||||||
|
#elif SELECT_SERIAL_SPEED == 3
|
||||||
|
// Low speed
|
||||||
|
#define SERIAL_DELAY 24 // micro sec
|
||||||
|
#define READ_WRITE_START_ADJUST 25 // cycles
|
||||||
|
#define READ_WRITE_WIDTH_ADJUST 10 // cycles
|
||||||
|
#elif SELECT_SERIAL_SPEED == 4
|
||||||
|
// Very Low speed
|
||||||
|
#define SERIAL_DELAY 50 // micro sec
|
||||||
|
#define READ_WRITE_START_ADJUST 25 // cycles
|
||||||
|
#define READ_WRITE_WIDTH_ADJUST 10 // cycles
|
||||||
|
#else
|
||||||
|
#error Illegal Serial Speed
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define SERIAL_DELAY_HALF1 (SERIAL_DELAY/2)
|
||||||
|
#define SERIAL_DELAY_HALF2 (SERIAL_DELAY - SERIAL_DELAY/2)
|
||||||
|
|
||||||
|
#define SLAVE_INT_WIDTH 1
|
||||||
|
#define SLAVE_INT_RESPONSE_TIME SERIAL_DELAY
|
||||||
|
|
||||||
|
uint8_t volatile serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH] = {0};
|
||||||
|
uint8_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0};
|
||||||
|
|
||||||
|
#define SLAVE_DATA_CORRUPT (1<<0)
|
||||||
|
volatile uint8_t status = 0;
|
||||||
|
|
||||||
|
inline static
|
||||||
|
void serial_delay(void) {
|
||||||
|
_delay_us(SERIAL_DELAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static
|
||||||
|
void serial_delay_half1(void) {
|
||||||
|
_delay_us(SERIAL_DELAY_HALF1);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static
|
||||||
|
void serial_delay_half2(void) {
|
||||||
|
_delay_us(SERIAL_DELAY_HALF2);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static
|
||||||
|
void serial_output(void) {
|
||||||
|
SERIAL_PIN_DDR |= SERIAL_PIN_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// make the serial pin an input with pull-up resistor
|
||||||
|
inline static
|
||||||
|
void serial_input_with_pullup(void) {
|
||||||
|
SERIAL_PIN_DDR &= ~SERIAL_PIN_MASK;
|
||||||
|
SERIAL_PIN_PORT |= SERIAL_PIN_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static
|
||||||
|
uint8_t serial_read_pin(void) {
|
||||||
|
return !!(SERIAL_PIN_INPUT & SERIAL_PIN_MASK);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static
|
||||||
|
void serial_low(void) {
|
||||||
|
SERIAL_PIN_PORT &= ~SERIAL_PIN_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static
|
||||||
|
void serial_high(void) {
|
||||||
|
SERIAL_PIN_PORT |= SERIAL_PIN_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void serial_master_init(void) {
|
||||||
|
serial_output();
|
||||||
|
serial_high();
|
||||||
|
}
|
||||||
|
|
||||||
|
void serial_slave_init(void) {
|
||||||
|
serial_input_with_pullup();
|
||||||
|
|
||||||
|
#if SERIAL_PIN_MASK == _BV(PD0)
|
||||||
|
// Enable INT0
|
||||||
|
EIMSK |= _BV(INT0);
|
||||||
|
// Trigger on falling edge of INT0
|
||||||
|
EICRA &= ~(_BV(ISC00) | _BV(ISC01));
|
||||||
|
#elif SERIAL_PIN_MASK == _BV(PD2)
|
||||||
|
// Enable INT2
|
||||||
|
EIMSK |= _BV(INT2);
|
||||||
|
// Trigger on falling edge of INT2
|
||||||
|
EICRA &= ~(_BV(ISC20) | _BV(ISC21));
|
||||||
|
#else
|
||||||
|
#error unknown SERIAL_PIN_MASK value
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// Used by the sender to synchronize timing with the reciver.
|
||||||
|
static
|
||||||
|
void sync_recv(void) {
|
||||||
|
for (int i = 0; i < SERIAL_DELAY*5 && serial_read_pin(); i++ ) {
|
||||||
|
}
|
||||||
|
// This shouldn't hang if the slave disconnects because the
|
||||||
|
// serial line will float to high if the slave does disconnect.
|
||||||
|
while (!serial_read_pin());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Used by the reciver to send a synchronization signal to the sender.
|
||||||
|
static
|
||||||
|
void sync_send(void) {
|
||||||
|
serial_low();
|
||||||
|
serial_delay();
|
||||||
|
serial_high();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reads a byte from the serial line
|
||||||
|
static
|
||||||
|
uint8_t serial_read_byte(void) {
|
||||||
|
uint8_t byte = 0;
|
||||||
|
_delay_sub_us(READ_WRITE_START_ADJUST);
|
||||||
|
for ( uint8_t i = 0; i < 8; ++i) {
|
||||||
|
serial_delay_half1(); // read the middle of pulses
|
||||||
|
byte = (byte << 1) | serial_read_pin();
|
||||||
|
_delay_sub_us(READ_WRITE_WIDTH_ADJUST);
|
||||||
|
serial_delay_half2();
|
||||||
|
}
|
||||||
|
return byte;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sends a byte with MSB ordering
|
||||||
|
static
|
||||||
|
void serial_write_byte(uint8_t data) {
|
||||||
|
uint8_t b = 1<<7;
|
||||||
|
while( b ) {
|
||||||
|
if(data & b) {
|
||||||
|
serial_high();
|
||||||
|
} else {
|
||||||
|
serial_low();
|
||||||
|
}
|
||||||
|
b >>= 1;
|
||||||
|
serial_delay();
|
||||||
|
}
|
||||||
|
serial_low(); // sync_send() / senc_recv() need raise edge
|
||||||
|
}
|
||||||
|
|
||||||
|
// interrupt handle to be used by the slave device
|
||||||
|
ISR(SERIAL_PIN_INTERRUPT) {
|
||||||
|
serial_output();
|
||||||
|
|
||||||
|
// slave send phase
|
||||||
|
uint8_t checksum = 0;
|
||||||
|
for (int i = 0; i < SERIAL_SLAVE_BUFFER_LENGTH; ++i) {
|
||||||
|
sync_send();
|
||||||
|
serial_write_byte(serial_slave_buffer[i]);
|
||||||
|
checksum += serial_slave_buffer[i];
|
||||||
|
}
|
||||||
|
sync_send();
|
||||||
|
serial_write_byte(checksum);
|
||||||
|
|
||||||
|
// slave switch to input
|
||||||
|
sync_send(); //0
|
||||||
|
serial_delay_half1(); //1
|
||||||
|
serial_low(); //2
|
||||||
|
serial_input_with_pullup(); //2
|
||||||
|
serial_delay_half1(); //3
|
||||||
|
|
||||||
|
// slave recive phase
|
||||||
|
uint8_t checksum_computed = 0;
|
||||||
|
for (int i = 0; i < SERIAL_MASTER_BUFFER_LENGTH; ++i) {
|
||||||
|
sync_recv();
|
||||||
|
serial_master_buffer[i] = serial_read_byte();
|
||||||
|
checksum_computed += serial_master_buffer[i];
|
||||||
|
}
|
||||||
|
sync_recv();
|
||||||
|
uint8_t checksum_received = serial_read_byte();
|
||||||
|
|
||||||
|
if ( checksum_computed != checksum_received ) {
|
||||||
|
status |= SLAVE_DATA_CORRUPT;
|
||||||
|
} else {
|
||||||
|
status &= ~SLAVE_DATA_CORRUPT;
|
||||||
|
}
|
||||||
|
|
||||||
|
sync_recv(); //weit master output to high
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
bool serial_slave_DATA_CORRUPT(void) {
|
||||||
|
return status & SLAVE_DATA_CORRUPT;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copies the serial_slave_buffer to the master and sends the
|
||||||
|
// serial_master_buffer to the slave.
|
||||||
|
//
|
||||||
|
// Returns:
|
||||||
|
// 0 => no error
|
||||||
|
// 1 => slave did not respond
|
||||||
|
// 2 => checksum error
|
||||||
|
int serial_update_buffers(void) {
|
||||||
|
// this code is very time dependent, so we need to disable interrupts
|
||||||
|
cli();
|
||||||
|
|
||||||
|
// signal to the slave that we want to start a transaction
|
||||||
|
serial_output();
|
||||||
|
serial_low();
|
||||||
|
_delay_us(SLAVE_INT_WIDTH);
|
||||||
|
|
||||||
|
// wait for the slaves response
|
||||||
|
serial_input_with_pullup();
|
||||||
|
_delay_us(SLAVE_INT_RESPONSE_TIME);
|
||||||
|
|
||||||
|
// check if the slave is present
|
||||||
|
if (serial_read_pin()) {
|
||||||
|
// slave failed to pull the line low, assume not present
|
||||||
|
serial_output();
|
||||||
|
serial_high();
|
||||||
|
sei();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// master recive phase
|
||||||
|
// if the slave is present syncronize with it
|
||||||
|
|
||||||
|
uint8_t checksum_computed = 0;
|
||||||
|
// receive data from the slave
|
||||||
|
for (int i = 0; i < SERIAL_SLAVE_BUFFER_LENGTH; ++i) {
|
||||||
|
sync_recv();
|
||||||
|
serial_slave_buffer[i] = serial_read_byte();
|
||||||
|
checksum_computed += serial_slave_buffer[i];
|
||||||
|
}
|
||||||
|
sync_recv();
|
||||||
|
uint8_t checksum_received = serial_read_byte();
|
||||||
|
|
||||||
|
if (checksum_computed != checksum_received) {
|
||||||
|
serial_output();
|
||||||
|
serial_high();
|
||||||
|
sei();
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// master switch to output
|
||||||
|
sync_recv(); //0
|
||||||
|
serial_delay(); //1
|
||||||
|
serial_low(); //3
|
||||||
|
serial_output(); // 3
|
||||||
|
serial_delay_half1(); //4
|
||||||
|
|
||||||
|
// master send phase
|
||||||
|
uint8_t checksum = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < SERIAL_MASTER_BUFFER_LENGTH; ++i) {
|
||||||
|
sync_send();
|
||||||
|
serial_write_byte(serial_master_buffer[i]);
|
||||||
|
checksum += serial_master_buffer[i];
|
||||||
|
}
|
||||||
|
sync_send();
|
||||||
|
serial_write_byte(checksum);
|
||||||
|
|
||||||
|
// always, release the line when not in use
|
||||||
|
sync_send();
|
||||||
|
|
||||||
|
sei();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,24 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
// ////////////////////////////////////////////
|
||||||
|
// Need Soft Serial defines in serial_config.h
|
||||||
|
// ////////////////////////////////////////////
|
||||||
|
// ex.
|
||||||
|
// #define SERIAL_PIN_DDR DDRD
|
||||||
|
// #define SERIAL_PIN_PORT PORTD
|
||||||
|
// #define SERIAL_PIN_INPUT PIND
|
||||||
|
// #define SERIAL_PIN_MASK _BV(PD?) ?=0,2
|
||||||
|
// #define SERIAL_PIN_INTERRUPT INT?_vect ?=0,2
|
||||||
|
// #define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2
|
||||||
|
// #define SERIAL_MASTER_BUFFER_LENGTH MATRIX_ROWS/2
|
||||||
|
|
||||||
|
// Buffers for master - slave communication
|
||||||
|
extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH];
|
||||||
|
extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH];
|
||||||
|
|
||||||
|
void serial_master_init(void);
|
||||||
|
void serial_slave_init(void);
|
||||||
|
int serial_update_buffers(void);
|
||||||
|
bool serial_slave_data_corrupt(void);
|
|
@ -0,0 +1,11 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
/* Soft Serial defines */
|
||||||
|
#define SERIAL_PIN_DDR DDRD
|
||||||
|
#define SERIAL_PIN_PORT PORTD
|
||||||
|
#define SERIAL_PIN_INPUT PIND
|
||||||
|
#define SERIAL_PIN_MASK _BV(PD2)
|
||||||
|
#define SERIAL_PIN_INTERRUPT INT2_vect
|
||||||
|
|
||||||
|
#define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2
|
||||||
|
#define SERIAL_MASTER_BUFFER_LENGTH MATRIX_ROWS/2
|
|
@ -0,0 +1,56 @@
|
||||||
|
#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 "serial.h"
|
||||||
|
|
||||||
|
volatile bool isLeftHand = true;
|
||||||
|
|
||||||
|
static void setup_handedness(void) {
|
||||||
|
#ifdef EE_HANDS
|
||||||
|
isLeftHand = eeprom_read_byte(EECONFIG_HANDEDNESS);
|
||||||
|
#else
|
||||||
|
// I2C_MASTER_RIGHT is deprecated, use MASTER_RIGHT instead, since this works for both serial and i2c
|
||||||
|
#if defined(I2C_MASTER_RIGHT) || defined(MASTER_RIGHT)
|
||||||
|
isLeftHand = !has_usb();
|
||||||
|
#else
|
||||||
|
isLeftHand = has_usb();
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void keyboard_master_setup(void) {
|
||||||
|
serial_master_init();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void keyboard_slave_setup(void) {
|
||||||
|
serial_slave_init();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool has_usb(void) {
|
||||||
|
USBCON |= (1 << OTGPADE); //enables VBUS pad
|
||||||
|
_delay_us(5);
|
||||||
|
return (USBSTA & (1<<VBUS)); //checks state of VBUS
|
||||||
|
}
|
||||||
|
|
||||||
|
void split_keyboard_setup(void) {
|
||||||
|
setup_handedness();
|
||||||
|
|
||||||
|
if (has_usb()) {
|
||||||
|
keyboard_master_setup();
|
||||||
|
} else {
|
||||||
|
keyboard_slave_setup();
|
||||||
|
}
|
||||||
|
sei();
|
||||||
|
}
|
||||||
|
|
||||||
|
// this code runs before the usb and keyboard is initialized
|
||||||
|
void matrix_setup(void) {
|
||||||
|
split_keyboard_setup();
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include "eeconfig.h"
|
||||||
|
|
||||||
|
extern volatile bool isLeftHand;
|
||||||
|
|
||||||
|
// slave version of matix scan, defined in matrix.c
|
||||||
|
void matrix_slave_scan(void);
|
||||||
|
|
||||||
|
void split_keyboard_setup(void);
|
||||||
|
bool has_usb(void);
|
Loading…
Reference in New Issue