Merge remote-tracking branch 'remotes/jackhumbert/master'
@ -0,0 +1,185 @@
|
||||
#include "ergodox_ez.h"
|
||||
#include "debug.h"
|
||||
#include "action_layer.h"
|
||||
#include "keymap_extras/keymap_german.h"
|
||||
|
||||
#define BASE 0 // default layer
|
||||
#define SYMB 1 // symbols
|
||||
#define MDIA 2 // media keys
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* Keymap 0: Basic layer
|
||||
*
|
||||
* ,--------------------------------------------------. ,--------------------------------------------------.
|
||||
* | = | 1 | 2 | 3 | 4 | 5 | LEFT | | RIGHT| 6 | 7 | 8 | 9 | 0 | - |
|
||||
* |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
|
||||
* | Del | K | . | O | , | Y | L1 | | L1 | V | G | C | L | ß | Z |
|
||||
* |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
|
||||
* | BkSp | H | A | E | I | U |------| |------| D | T | R | N | S | F |
|
||||
* |--------+------+------+------+------+------| Hyper| | Meh |------+------+------+------+------+--------|
|
||||
* | LShift |X/Ctrl| Q | Ä | Ü | Ö | | | | B | P | W | M | J | RShift |
|
||||
* `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
|
||||
* |Grv/L1| '" |AltShf| Left | Right| | Up | Down | [ | ] | ~L1 |
|
||||
* `----------------------------------' `----------------------------------'
|
||||
* ,-------------. ,-------------.
|
||||
* | App | LGui | | Alt |Ctrl/Esc|
|
||||
* ,------|------|------| |------+--------+------.
|
||||
* | | | Home | | PgUp | | |
|
||||
* | Space|Enter |------| |------| Tab |RShift|
|
||||
* | | | End | | PgDn | | |
|
||||
* `--------------------' `----------------------'
|
||||
*/
|
||||
// If it accepts an argument (i.e, is a function), it doesn't need KC_.
|
||||
// Otherwise, it needs KC_*
|
||||
[BASE] = KEYMAP( // layer 0 : default
|
||||
// left hand
|
||||
KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, KC_LEFT,
|
||||
KC_DELT, DE_K, DE_DOT, DE_O, DE_COMM,DE_Y, TG(SYMB),
|
||||
KC_BSPC, DE_H, DE_A, DE_E, DE_I, DE_U,
|
||||
KC_LSFT, CTL_T(DE_X), DE_Q, DE_AE, DE_UE, DE_OE, ALL_T(KC_NO),
|
||||
LT(SYMB,KC_GRV),KC_QUOT, LALT(KC_LSFT), KC_LEFT,KC_RGHT,
|
||||
ALT_T(KC_APP), KC_LGUI,
|
||||
KC_HOME,
|
||||
KC_SPC,KC_ENT ,KC_END,
|
||||
// right hand
|
||||
KC_RGHT, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,
|
||||
TG(SYMB), DE_V, DE_G, DE_C, DE_L, DE_SS, DE_Z,
|
||||
DE_D, DE_T, DE_R, DE_N, LT(MDIA, DE_S), GUI_T(KC_F),
|
||||
MEH_T(KC_NO),KC_B, KC_P, KC_W, KC_M, CTL_T(KC_J), KC_RSFT,
|
||||
KC_UP, KC_DOWN,KC_LBRC,KC_RBRC, KC_FN1,
|
||||
KC_LALT, CTL_T(KC_ESC),
|
||||
KC_PGUP,
|
||||
KC_PGDN,KC_TAB, KC_RSFT
|
||||
),
|
||||
/* Keymap 1: Symbol Layer
|
||||
*
|
||||
* ,--------------------------------------------------. ,--------------------------------------------------.
|
||||
* | | F1 | F2 | F3 | F4 | F5 | | | | F6 | F7 | F8 | F9 | F10 | F11 |
|
||||
* |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
|
||||
* | | ! | @ | { | } | | | | | | Up | 7 | 8 | 9 | * | F12 |
|
||||
* |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
|
||||
* | | # | $ | ( | ) | ` |------| |------| Down | 4 | 5 | 6 | + | |
|
||||
* |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
|
||||
* | | % | ^ | [ | ] | ~ | | | | & | 1 | 2 | 3 | \ | |
|
||||
* `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
|
||||
* | | | | | | | | . | 0 | = | |
|
||||
* `----------------------------------' `----------------------------------'
|
||||
* ,-------------. ,-------------.
|
||||
* | | | | | |
|
||||
* ,------|------|------| |------+------+------.
|
||||
* | | | | | | | |
|
||||
* | | |------| |------| | |
|
||||
* | | | | | | | |
|
||||
* `--------------------' `--------------------'
|
||||
*/
|
||||
// SYMBOLS
|
||||
[SYMB] = KEYMAP(
|
||||
// left hand
|
||||
KC_TRNS,KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_TRNS,
|
||||
KC_TRNS,KC_EXLM,KC_AT, KC_LCBR,KC_RCBR,KC_PIPE,KC_TRNS,
|
||||
KC_TRNS,KC_HASH,KC_DLR, KC_LPRN,KC_RPRN,KC_GRV,
|
||||
KC_TRNS,KC_PERC,KC_CIRC,KC_LBRC,KC_RBRC,KC_TILD,KC_TRNS,
|
||||
KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,
|
||||
KC_TRNS,KC_TRNS,
|
||||
KC_TRNS,
|
||||
KC_TRNS,KC_TRNS,KC_TRNS,
|
||||
// right hand
|
||||
KC_TRNS, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,
|
||||
KC_TRNS, KC_UP, KC_7, KC_8, KC_9, KC_ASTR, KC_F12,
|
||||
KC_DOWN, KC_4, KC_5, KC_6, KC_PLUS, KC_TRNS,
|
||||
KC_TRNS, KC_AMPR, KC_1, KC_2, KC_3, KC_BSLS, KC_TRNS,
|
||||
KC_TRNS,KC_DOT, KC_0, KC_EQL, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS,
|
||||
KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS
|
||||
),
|
||||
/* Keymap 2: Media and mouse keys
|
||||
*
|
||||
* ,--------------------------------------------------. ,--------------------------------------------------.
|
||||
* | | | | | | | | | | | | | | | |
|
||||
* |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
|
||||
* | | | | MsUp | | | | | | | | | | | |
|
||||
* |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
|
||||
* | | |MsLeft|MsDown|MsRght| |------| |------| | | | | | Play |
|
||||
* |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
|
||||
* | | | | | | | | | | | | Prev | Next | | |
|
||||
* `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
|
||||
* | | | | Lclk | Rclk | |VolUp |VolDn | Mute | | |
|
||||
* `----------------------------------' `----------------------------------'
|
||||
* ,-------------. ,-------------.
|
||||
* | | | | | |
|
||||
* ,------|------|------| |------+------+------.
|
||||
* | | | | | | |Brwser|
|
||||
* | | |------| |------| |Back |
|
||||
* | | | | | | | |
|
||||
* `--------------------' `--------------------'
|
||||
*/
|
||||
// MEDIA AND MOUSE
|
||||
[MDIA] = KEYMAP(
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_MS_U, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_MS_L, KC_MS_D, KC_MS_R, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_BTN1, KC_BTN2,
|
||||
KC_TRNS, KC_TRNS,
|
||||
KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
// right hand
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPLY,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_MPRV, KC_MNXT, KC_TRNS, KC_TRNS,
|
||||
KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS,
|
||||
KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_WBAK
|
||||
),
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM fn_actions[] = {
|
||||
[1] = ACTION_LAYER_TAP_TOGGLE(SYMB) // FN1 - Momentary Layer 1 (Symbols)
|
||||
};
|
||||
|
||||
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
|
||||
{
|
||||
// MACRODOWN only works in this function
|
||||
switch(id) {
|
||||
case 0:
|
||||
if (record->event.pressed) {
|
||||
register_code(KC_RSFT);
|
||||
} else {
|
||||
unregister_code(KC_RSFT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return MACRO_NONE;
|
||||
};
|
||||
|
||||
// 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) {
|
||||
|
||||
uint8_t layer = biton32(layer_state);
|
||||
|
||||
ergodox_board_led_off();
|
||||
ergodox_right_led_1_off();
|
||||
ergodox_right_led_2_off();
|
||||
ergodox_right_led_3_off();
|
||||
switch (layer) {
|
||||
// TODO: Make this relevant to the ErgoDox EZ.
|
||||
case 1:
|
||||
ergodox_right_led_1_on();
|
||||
break;
|
||||
case 2:
|
||||
ergodox_right_led_2_on();
|
||||
break;
|
||||
default:
|
||||
// none
|
||||
break;
|
||||
}
|
||||
|
||||
};
|
@ -0,0 +1,7 @@
|
||||
# Basic implementation for k.o,y variant of the adnw layout
|
||||
|
||||
adnw is a layout optimised for usage with german and english language
|
||||
k.o,y is a variant of this layout
|
||||
http://www.adnw.de/index.php?n=Main.SeitlicheNachbaranschl%C3%A4ge
|
||||
|
||||
The os must use the de_DE layout
|
@ -0,0 +1,8 @@
|
||||
#ifndef CONFIG_USER_H
|
||||
#define CONFIG_USER_H
|
||||
|
||||
#include "config.h"
|
||||
#define ONESHOT_TAP_TOGGLE 2
|
||||
#define ONESHOT_TIMEOUT 3000
|
||||
|
||||
#endif
|
@ -0,0 +1,5 @@
|
||||
# Having a file like this allows you to override Makefile definitions
|
||||
# for your own particular keymap
|
||||
|
||||
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
|
||||
|
Before Width: | Height: | Size: 97 KiB After Width: | Height: | Size: 97 KiB |
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 121 KiB |
After Width: | Height: | Size: 62 KiB |
@ -0,0 +1,27 @@
|
||||
[{x:3.5,a:7},"",{x:10.5},""],
|
||||
[{y:-0.875,x:2.5},"",{x:1},"",{x:8.5},"",{x:1},""],
|
||||
[{y:-0.875,x:5.5},"",{c:"#ff4444",a:4},"Esc",{x:4.5,c:"#cccccc",a:7},"",""],
|
||||
[{y:-0.875,c:"#000000",t:"#ff0000",a:4,w:1.5},"Special\n\n\n\n\n\nShift",{c:"#ff4444",t:"#000000"},"Esc",{x:14.5,c:"#54d6de"},"Back\n\n\n\n\n\nspace",{c:"#000000",t:"#ff0000",w:1.5},"\n\nSpecial\n\n\n\n\nShift"],
|
||||
[{y:-0.375,x:3.5,c:"#cccccc",t:"#000000",a:7},"",{x:10.5},""],
|
||||
[{y:-0.875,x:2.5},"",{x:1},"",{x:8.5},"",{x:1},""],
|
||||
[{y:-0.875,x:5.5},"",{h:1.5},"",{x:4.5,h:1.5},"",""],
|
||||
[{y:-0.875,w:1.5},"","",{x:14.5},"",{w:1.5},""],
|
||||
[{y:-0.375,x:3.5},"",{x:10.5},""],
|
||||
[{y:-0.875,x:2.5},"",{x:1},"",{x:8.5},"",{x:1},""],
|
||||
[{y:-0.875,x:5.5},"",{x:6.5},""],
|
||||
[{y:-0.875,w:1.5},"","",{x:14.5},"",{w:1.5},""],
|
||||
[{y:-0.625,x:6.5,h:1.5},"",{x:4.5,h:1.5},""],
|
||||
[{y:-0.75,x:3.5},"",{x:10.5},""],
|
||||
[{y:-0.875,x:2.5},"",{x:1},"",{x:8.5},"",{x:1},""],
|
||||
[{y:-0.875,x:5.5},"",{x:6.5},""],
|
||||
[{y:-0.875,w:1.5},"","",{x:14.5},"",{c:"#2277ff",w:1.5},"RShift"],
|
||||
[{y:-0.375,x:3.5,c:"#cccccc"},"",{x:10.5},""],
|
||||
[{y:-0.875,x:2.5},"",{x:1},"",{x:8.5},"",{x:1},""],
|
||||
[{y:-0.75,x:0.5},"","",{x:14.5},"",""],
|
||||
[{r:30,rx:6.5,ry:4.25,y:-1,x:1},"",""],
|
||||
[{h:2},"",{h:2},"",""],
|
||||
[{x:2},""],
|
||||
[{r:-30,rx:13,y:-1,x:-3},"",""],
|
||||
[{x:-3},"",{h:2},"",{h:2},""],
|
||||
[{x:-3},""]
|
||||
|
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 101 KiB |
Before Width: | Height: | Size: 282 KiB After Width: | Height: | Size: 297 KiB |
@ -0,0 +1,22 @@
|
||||
|
||||
# Ergodox und Ergodox-EZ experimentelles Layout
|
||||
|
||||
dieses layout ist experimentell und wird im Lufe der Zeit viele Änderungen und Verbesserungen durchlaufen. Falls diese sich als vorteilhaft erweisen, werden sie evtl. auch in das `osx_de` layout übernommen.
|
||||
|
||||
|
||||
|
||||
# Erstellt Mit Dem ErgodoxLayoutGenerator
|
||||
|
||||
Der ErgodoxLayoutGenerator (ELG) ist ein kleines Werkzeug, welches die Erstellung und Pflege der eigenen Keymaps erleichtern soll. Es ist in java geschrieben und kann [hier](https://github.com/sboesebeck/ErgodoxLayoutGenerator/releases) heruntergeladen werden. Damit das Tool funktioniert sollte das offizielle Oracle JDK in aktueller Version installiert sein.
|
||||
Die Dokumentation für den ELG kann man [hier](https://boesebeck.name/2016/04/16/ergodoxlayoutgenerator-documentation/) nachlesen (momentan leider nur in Englisch verfügbar).
|
||||
---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
# Ergodox and Ergodox-EZ experimental layout
|
||||
|
||||
This is an experimental layout which will undergo heavy changes over time. If changes prove to be good, they might also move into the `osx_de` layout.
|
||||
|
||||
Created Using the ErgodoxLayoutGenerator
|
||||
|
||||
The ErgodoxLayoutGenerator (ELG) is a little tool, which makes the creation and maintenance of keycaps a lot easier. It was written in Java and can be downloaded [here](https://github.com/sboesebeck/ErgodoxLayoutGenerator/releases). To use the tool, you need to have a current version of Oracles JDK installed.
|
||||
|
||||
The documentation of the ELG can be viewed [here](https://boesebeck.name/2016/04/16/ergodoxlayoutgenerator-documentation/).
|
@ -0,0 +1,92 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#include "config_common.h"
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define VENDOR_ID 0xFEED
|
||||
#define PRODUCT_ID 0x1307
|
||||
#define DEVICE_VER 0x0001
|
||||
#define MANUFACTURER ErgoDox EZ
|
||||
#define PRODUCT ErgoDox EZ
|
||||
#define DESCRIPTION t.m.k. keyboard firmware for Ergodox
|
||||
|
||||
/* key matrix size */
|
||||
#define MATRIX_ROWS 14
|
||||
#define MATRIX_COLS 6
|
||||
|
||||
#define MOUSEKEY_DELAY 100
|
||||
#define MOUSEKEY_INTERVAL 20
|
||||
#define MOUSEKEY_MAX_SPEED 3
|
||||
#define MOUSEKEY_TIME_TO_MAX 10
|
||||
|
||||
#define TAPPING_TOGGLE 1
|
||||
|
||||
#define COLS (int []){ F1, F0, B0, C7, F4, F5, F6, F7, D4, D6, B4, D7 }
|
||||
#define ROWS (int []){ D0, D5, B5, B6 }
|
||||
|
||||
/* COL2ROW or ROW2COL */
|
||||
#define DIODE_DIRECTION COL2ROW
|
||||
|
||||
/* 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 DEBOUNCE 2
|
||||
#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() ( \
|
||||
keyboard_report->mods == (MOD_BIT(KC_LCTL) | MOD_BIT(KC_RCTL)) || \
|
||||
keyboard_report->mods == (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)) \
|
||||
)
|
||||
|
||||
/*
|
||||
* 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
|
||||
//#define DEBUG_MATRIX_SCAN_RATE
|
||||
#define ONESHOT_TAP_TOGGLE 2
|
||||
#define ONESHOT_TIMEOUT 3000
|
||||
|
||||
#endif
|
@ -0,0 +1,285 @@
|
||||
#include "ergodox_ez.h"
|
||||
#include "debug.h"
|
||||
#include "action_layer.h"
|
||||
#include "action_util.h"
|
||||
#include "led.h"
|
||||
#include "keymap_common.h"
|
||||
#include "timer.h"
|
||||
|
||||
/*
|
||||
|
||||
# Why this Layout
|
||||
|
||||
This layout was based on Kinesis layout and other ErgoDox user layouts
|
||||
available. It's target to be used on a MacOS but I'm pretty sure it can be
|
||||
addapted to Windows and/or Linux easily.
|
||||
|
||||
## Function Key
|
||||
|
||||
The `fn` key work almost like it would in any other keyboard with the exception
|
||||
it has a semi-sticky behavior. What does that mean?
|
||||
|
||||
Well, if you press the `fn` and release it, the keyboard will be put on the
|
||||
_function layout_ and the next key stroke will be processed as if the `fn` key
|
||||
was pressed. Aftwards, the leyout get back to _normal_. If you hold `fn` and
|
||||
press any other key, when you release them, the keyboard leyout is back to
|
||||
_normal_.
|
||||
|
||||
While pressing the `fn` with the left hand and strikeing the other keys on the
|
||||
right hand is farly easy, the same cannot being said for the other keys on the
|
||||
left side. So, instead of trying to do contorcionism with my left hand, I
|
||||
decided to do a semi-sticky version of `fn`. This way, I can press the `fn`
|
||||
key with my pinky, release it and press the `1` key to issue an `F1` to the
|
||||
operating system.
|
||||
|
||||
## Key-Pad Key
|
||||
|
||||
The `key pad` key is a layout switch key. If pressed, it will put the keyboard
|
||||
on the _key pad layout_ and stay there until key is pressed again.
|
||||
|
||||
This is used to make the keyboard behave mostly like a **num pad keyboard**.
|
||||
|
||||
## Notes
|
||||
- Regardless in which layout you are, keys from other layouts are not
|
||||
accessible. This means that if you are on the _key pad layout_, the left hand
|
||||
will be pretty much unusable.
|
||||
Of course that like anything else, there are exceptions to this rule.
|
||||
Modifiers should remain accessible throughout the layers.
|
||||
- The _shift key_ is, like the _function key_, also configured to have a sticky
|
||||
behavior.
|
||||
- All sticky keys have a timeout of 3 seconds.
|
||||
|
||||
*/
|
||||
#define BASE 0
|
||||
#define KEYPAD 1
|
||||
#define FN 2
|
||||
|
||||
#define MACRO_TMUX_ESC 10
|
||||
#define MACRO_TMUX_PASTE 11
|
||||
#define MACRO_OSX_COPY 12
|
||||
#define MACRO_OSX_PASTE 13
|
||||
|
||||
#define M_TESC M(MACRO_TMUX_ESC)
|
||||
#define M_TPASTE M(MACRO_TMUX_PASTE)
|
||||
#define M_OSXCPY M(MACRO_OSX_COPY)
|
||||
#define M_OSXPST M(MACRO_OSX_PASTE)
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* Keymap 0: Base Layer
|
||||
*
|
||||
* ,-----------------------------------------------------. ,-----------------------------------------------------.
|
||||
* | `~ | 1 | 2 | 3 | 4 | 5 | ESC | | Pwr | 6 | 7 | 8 | 9 | 0 | - _ |
|
||||
* |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------|
|
||||
* | Tab | Q | W | E | R | T | F16 | | F17 | Y | U | I | O | P | = + |
|
||||
* |-----------+------+------+------+------+------| Meh | | Meh |------+------+------+------+------+-----------|
|
||||
* | \ (Ctrl) | A | S | D | F | G |------| |------| H | J | K | L | ; | ' " (Ctrl)|
|
||||
* |-----------+------+------+------+------+------| F18 | | F19 |------+------+------+------+------+-----------|
|
||||
* | LShift | Z | X | C | V | B | Hyper| | Hyper| N | M | , | . | / | RShift |
|
||||
* `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------'
|
||||
* | FN | KPAD |LCtrl | LAlt | LGui | | RGui | RAlt | RCtrl| KPAD | FN |
|
||||
* `-----------------------------------' `-----------------------------------'
|
||||
* ,-------------. ,-------------.
|
||||
* | M(0) | M(1) | | M(2) | M(3) |
|
||||
* ,------|------|------| |------+------+------.
|
||||
* | | | Home | | PgUp | | |
|
||||
* |Backsp| Del |------| |------| Enter| Space|
|
||||
* | | | End | | PgDn | | |
|
||||
* `--------------------' `--------------------'
|
||||
*
|
||||
* M(0) = Ctrk+A Esc
|
||||
* (this is used to issue the Esc key to the Tmux application)
|
||||
* M(1) = Ctrk+A P
|
||||
* (this is used to issue the Paste key to the Tmux application)
|
||||
* M(2) = Cmd+C
|
||||
* M(3) = Cmd+V
|
||||
*/
|
||||
[BASE]=KEYMAP(//left half
|
||||
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_ESC,
|
||||
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, MEH_T(KC_F16),
|
||||
CTL_T(KC_BSLS), KC_A, KC_S, KC_D, KC_F, KC_G,
|
||||
KC_FN2, KC_Z, KC_X, KC_C, KC_V, KC_B, ALL_T(KC_F18),
|
||||
KC_FN1, TG(KEYPAD), KC_LCTRL, KC_LALT, KC_LGUI,
|
||||
M_TESC, M_TPASTE,
|
||||
KC_HOME,
|
||||
KC_BSPC, KC_DELT, KC_END,
|
||||
//right half
|
||||
KC_POWER, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,
|
||||
MEH_T(KC_F17), KC_Y, KC_U, KC_I, KC_O, KC_P, KC_EQL,
|
||||
KC_H, KC_J, KC_K, KC_L, KC_SCLN, CTL_T(KC_QUOT),
|
||||
ALL_T(KC_F19), KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_FN2,
|
||||
KC_RGUI, KC_RALT, CTL_T(KC_LBRC), KC_FN3, KC_FN1,
|
||||
M_OSXCPY, M_OSXPST,
|
||||
KC_PGUP,
|
||||
KC_PGDN, KC_ENT, KC_SPC),
|
||||
|
||||
/* Keymap 1: KeyPad Layer
|
||||
*
|
||||
* ,-----------------------------------------------------. ,-----------------------------------------------------.
|
||||
* | | | LClk | RClk | MClk | | | | BTab | Clear| / | * | ^ | ( | |
|
||||
* |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------|
|
||||
* | M.Accel 2 | |ScrlUp| U |ScrlDn| | | | Tab | 7 | 8 | 9 | + | ) | |
|
||||
* |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------|
|
||||
* | M.Accel 1 | | L | D | R | |------| |------| 4 | 5 | 6 | - | | |
|
||||
* |-----------+------+------+------+------+------| | |Return|------+------+------+------+------+-----------|
|
||||
* | M.Accel 0 | |ScrlL | |ScrlR | | | | | 1 | 2 | 3 | = | | |
|
||||
* `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------'
|
||||
* | | XXXX | | | | | 0 | . | , | XXXX | |
|
||||
* `-----------------------------------' `-----------------------------------'
|
||||
* ,-------------. ,-------------.
|
||||
* | | | | | |
|
||||
* ,------|------|------| |------+------+------.
|
||||
* | | | | | | XXXX | |
|
||||
* | | |------| |------| XXXX | |
|
||||
* | | | | | | XXXX | |
|
||||
* `--------------------' `--------------------'
|
||||
*/
|
||||
[KEYPAD]=KEYMAP(//left half
|
||||
KC_NO, KC_NO, KC_MS_BTN1, KC_MS_BTN2, KC_MS_BTN3, KC_NO, KC_NO,
|
||||
KC_MS_ACCEL2, KC_NO, KC_MS_WH_UP, KC_MS_U, KC_MS_WH_DOWN, KC_NO, KC_NO,
|
||||
KC_MS_ACCEL1, KC_NO, KC_MS_L, KC_MS_D, KC_MS_R, KC_NO,
|
||||
KC_MS_ACCEL0, KC_NO, KC_MS_WH_LEFT, KC_NO, KC_MS_WH_RIGHT, KC_NO, KC_NO,
|
||||
KC_NO, KC_TRNS, KC_NO, KC_NO, KC_NO,
|
||||
KC_NO, KC_NO,
|
||||
KC_NO,
|
||||
KC_NO, KC_NO, KC_NO,
|
||||
//right half
|
||||
LSFT(KC_TAB), KC_CLEAR, KC_KP_SLASH, KC_KP_ASTERISK, KC_CIRCUMFLEX, KC_LPRN, KC_NO,
|
||||
KC_TAB, KC_KP_7, KC_KP_8, KC_KP_9, KC_KP_PLUS, KC_RPRN, KC_NO,
|
||||
KC_KP_4, KC_KP_5, KC_KP_6, KC_KP_MINUS, KC_NO, KC_NO,
|
||||
KC_KP_ENTER, KC_KP_1, KC_KP_2, KC_KP_3, KC_KP_EQUAL, KC_NO, KC_NO,
|
||||
KC_KP_0, KC_KP_DOT, KC_KP_COMMA, KC_TRNS, KC_NO,
|
||||
KC_NO, KC_NO,
|
||||
KC_NO,
|
||||
KC_NO, KC_TRNS, KC_NO),
|
||||
|
||||
/* Keymap 2: Functions Layer
|
||||
*
|
||||
* ,-----------------------------------------------------. ,-----------------------------------------------------.
|
||||
* | | F1 | F2 | F3 | F4 | F5 | F6 | | F7 | F8 | F9 | F10 | F11 | F12 | Vol. Up |
|
||||
* |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------|
|
||||
* | | Stop | Rw | Rec | FF | | XXXX | | XXXX | | | | | | Vol. Down |
|
||||
* |-----------+------+------+------+------+------| XXXX | | XXXX |------+------+------+------+------+-----------|
|
||||
* | CapsLock | Eject| Prev | Play | Next | |------| |------| Left | Down | Up | Right| | Mute |
|
||||
* |-----------+------+------+------+------+------| XXXX | | XXXX |------+------+------+------+------+-----------|
|
||||
* | L Shift | | | | | | XXXX | | XXXX | | | | | | R Shift |
|
||||
* `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------'
|
||||
* | XXXXX | | XXXX | XXXX | XXXX | | XXXX | XXXX | XXXX | | XXXXX |
|
||||
* `-----------------------------------' `-----------------------------------'
|
||||
* ,-------------. ,-------------.
|
||||
* | | | | | |
|
||||
* ,------|------|------| |------+------+------.
|
||||
* | | | | | | | |
|
||||
* | | |------| |------| | |
|
||||
* | | | | | | | |
|
||||
* `--------------------' `--------------------'
|
||||
*
|
||||
* XXX = These keys are transparent keys that, when pressed, they issue the key from the previous layer.
|
||||
*/
|
||||
[FN]=KEYMAP(//left half
|
||||
KC_NO, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6,
|
||||
KC_NO, KC_MEDIA_STOP, KC_MEDIA_REWIND, KC_MEDIA_SELECT, KC_MEDIA_FAST_FORWARD, KC_NO, KC_TRNS,
|
||||
KC_CAPS, KC_MEDIA_EJECT, KC_MEDIA_PREV_TRACK, KC_MEDIA_PLAY_PAUSE, KC_MEDIA_NEXT_TRACK, KC_NO,
|
||||
KC_LSFT, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_TRNS,
|
||||
KC_TRNS, KC_NO, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_NO, KC_NO,
|
||||
KC_NO,
|
||||
KC_NO, KC_NO, KC_NO,
|
||||
//right half
|
||||
KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_VOLU,
|
||||
KC_TRNS, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_VOLD,
|
||||
KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, KC_NO, KC_MUTE,
|
||||
KC_TRNS, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_RSFT,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_NO, KC_TRNS,
|
||||
KC_NO, KC_NO,
|
||||
KC_NO,
|
||||
KC_NO, KC_NO, KC_NO)};
|
||||
|
||||
const uint16_t PROGMEM fn_actions[] = {
|
||||
[1] = ACTION_LAYER_ONESHOT(FN),
|
||||
[2] = ACTION_MODS_ONESHOT(MOD_LSFT), // Sticky shift light. Tap for the next keypress to be shifted. Hold for regular shift.
|
||||
[3] = ACTION_LAYER_TAP_KEY(KEYPAD, KC_RBRC),
|
||||
};
|
||||
|
||||
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
|
||||
// MACRODOWN only works in this function
|
||||
switch(id) {
|
||||
case MACRO_TMUX_ESC:
|
||||
if (record->event.pressed) {
|
||||
return MACRO(D(LCTRL), T(A), U(LCTRL), D(ESC), END);
|
||||
}
|
||||
return MACRO(U(ESC), END);
|
||||
case MACRO_TMUX_PASTE:
|
||||
if (record->event.pressed) {
|
||||
return MACRO(D(LCTRL), T(A), U(LCTRL), D(P), END);
|
||||
}
|
||||
return MACRO(U(P), END);
|
||||
case MACRO_OSX_COPY:
|
||||
if (record->event.pressed) {
|
||||
return MACRO(D(LGUI), D(C), END);
|
||||
}
|
||||
return MACRO(U(C), U(LGUI), END);
|
||||
case MACRO_OSX_PASTE:
|
||||
if (record->event.pressed) {
|
||||
return MACRO(D(LGUI), D(V), END);
|
||||
}
|
||||
return MACRO(U(V), U(LGUI), END);
|
||||
}
|
||||
return MACRO_NONE;
|
||||
};
|
||||
|
||||
// Runs just one time when the keyboard initializes.
|
||||
void matrix_init_user(void) {
|
||||
};
|
||||
|
||||
uint8_t current_layer = BASE;
|
||||
|
||||
// Runs constantly in the background, in a loop.
|
||||
void matrix_scan_user(void) {
|
||||
uint8_t layer = biton32(layer_state);
|
||||
|
||||
ergodox_led_all_off();
|
||||
ergodox_led_all_set(LED_BRIGHTNESS_LO);
|
||||
|
||||
switch (layer) {
|
||||
case BASE:
|
||||
current_layer = BASE;
|
||||
break;
|
||||
case KEYPAD:
|
||||
current_layer = KEYPAD;
|
||||
break;
|
||||
default:
|
||||
// none
|
||||
break;
|
||||
}
|
||||
|
||||
// layer leds
|
||||
if (current_layer == KEYPAD) {
|
||||
ergodox_right_led_3_on();
|
||||
}
|
||||
|
||||
// capslock
|
||||
if (host_keyboard_leds() & (3<<USB_LED_CAPS_LOCK)) {
|
||||
ergodox_right_led_1_on();
|
||||
}
|
||||
|
||||
// Temporary leds
|
||||
|
||||
// The function layer takes over other layers and we need to reflect that on the leds.
|
||||
// If the current layer is the BASE, we simply turn on the FN led, but if the current
|
||||
// layer is the KEYPAD, than we must turn it off before turning on the FN led.
|
||||
if (layer == FN && !has_oneshot_layer_timed_out()) {
|
||||
ergodox_right_led_3_off();
|
||||
ergodox_right_led_2_on();
|
||||
}
|
||||
|
||||
// if the shifted is pressed I show the case led in a brighter color. This is nice to
|
||||
// differenciate the shift from the capslock.
|
||||
// Notice that I make sure that we're not using the shift on a chord shortcut (pressing
|
||||
// shift togather with other modifiers).
|
||||
if((keyboard_report->mods & (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)) && // is shift pressed and there is no other
|
||||
!(keyboard_report->mods & (~MOD_BIT(KC_LSFT) & ~MOD_BIT(KC_RSFT)))) || // modifier being pressed as well
|
||||
(get_oneshot_mods() & (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)) && !has_oneshot_mods_timed_out())) { // or the one shot shift didn't timed out
|
||||
ergodox_right_led_1_set(LED_BRIGHTNESS_HI);
|
||||
ergodox_right_led_1_on();
|
||||
}
|
||||
};
|
@ -0,0 +1,4 @@
|
||||
# I don't want my keyboard blinking lights when is suppose to be asleep.
|
||||
SLEEP_LED_ENABLE = no
|
||||
|
||||
CONFIG_H = keymaps/$(KEYMAP)/config.h
|
@ -0,0 +1,77 @@
|
||||
# Townk's Keymap
|
||||
|
||||
Trying to take care of an enjury on my arm I borrow an ergonomic keyboard from
|
||||
a frient ([Kinesis Advantage](http://www.kinesis-ergo.com/shop/advantage-pro-for-pc-mac/)).
|
||||
|
||||
I really enjoyed my time with it but there were some anoyancies:
|
||||
|
||||
* The curvature on the keys bothered me since I'm a Vim user and using the
|
||||
motion keys on my editor was awkard.
|
||||
* I had to spend too much time remapping the keyboard to make some symbol keys
|
||||
more accessible to me.
|
||||
* The fact that my hands had to stay close to each other was a bit stressfull
|
||||
to my sholders.
|
||||
|
||||
After a long research I find out that Ergodox EZ would be perfect for my needs
|
||||
and purchase one. Before the keyboard even got in my hands I started to think
|
||||
on the layout I would use on it and soon enough I planed couple adjustments
|
||||
from the Kinesis I was using so far.
|
||||
|
||||
## The layout
|
||||
|
||||
Here are the layout mapping in images so you can have a glimpse on it:
|
||||
|
||||
![Base Layout](townk_osx_base.png)
|
||||
![fn Layout](townk_osx_fn.png)
|
||||
![Keypad & Mouse Layout](townk_osx_keypad.png)
|
||||
|
||||
Notice that, differently from the default behavior, my layer keys are not transparent
|
||||
by default, which means that if you press any non-labeled white key, nothing will be
|
||||
handled to the OS.
|
||||
|
||||
### One shot keys
|
||||
|
||||
It all started with the access to the function keys (F1, F2, F3...), since
|
||||
those keys are located on a different layer I needed a way to press them with
|
||||
minimal effort without disrupting my flow.
|
||||
|
||||
For me, togglihg a layer to press a button and than toggle it back is a waste
|
||||
of time (although I admit it's a single tap from what I have), so I decided to
|
||||
do it as a one shot key. I could press it and the next pressed key would be
|
||||
handled by the target layer which just after it delivers the key to the OS it
|
||||
would get back to the previous layer.
|
||||
|
||||
After setting up my layout to do just that I realized that occasionally I
|
||||
would stop myseld on the middle of the process and the one shot layer would be
|
||||
still triggered until I press any other key. So to prevent me from tapping
|
||||
keys I don't want I added a timeout of 3 seconds for the one shot actions.
|
||||
|
||||
Ultimately I tested the shift key as a one shot one and really like it, so
|
||||
here you have it, all the one shot keys on my layout.
|
||||
|
||||
## Glossary
|
||||
|
||||
If you're not familiar with the Mac symbols used on some keys, here is a
|
||||
reference to them:
|
||||
|
||||
| Symbol | Description |
|
||||
| :----: | ------------------- |
|
||||
| ⌘ | Command |
|
||||
| ⇪ | Caps Lock |
|
||||
| ⇧ | Shift |
|
||||
| ⌥ | Option (alt) |
|
||||
| ⎋ | Esc |
|
||||
| ⇥ | Tab forward |
|
||||
| ⇤ | Tab backward |
|
||||
| ⌃ | Control |
|
||||
| ␣ | Space |
|
||||
| ⌫ | Backspace |
|
||||
| ⌦ | Delete |
|
||||
| ⏎ | Enter |
|
||||
| ⌤ | Return |
|
||||
| ⌽ | Power on/off button |
|
||||
| ↖ | Home |
|
||||
| ↘ | End |
|
||||
| ⇞ | Page up |
|
||||
| ⇟ | Page down |
|
||||
| ⌧ | Clear |
|
After Width: | Height: | Size: 767 KiB |
After Width: | Height: | Size: 381 KiB |
After Width: | Height: | Size: 414 KiB |
@ -0,0 +1,2 @@
|
||||
# The Default Planck Layout
|
||||
|
@ -0,0 +1,333 @@
|
||||
// This is the canonical layout file for the Quantum project. If you want to add another keyboard,
|
||||
// this is the style you want to emulate.
|
||||
|
||||
#include "planck.h"
|
||||
#include "action_layer.h"
|
||||
#ifdef AUDIO_ENABLE
|
||||
#include "audio.h"
|
||||
#endif
|
||||
|
||||
#include "eeconfig.h"
|
||||
|
||||
extern keymap_config_t keymap_config;
|
||||
|
||||
// Each layer gets a name for readability, which is then used in the keymap matrix below.
|
||||
// The underscores don't mean anything - you can have a layer called STUFF or any other name.
|
||||
// Layer names don't all need to be of the same length, obviously, and you can also skip them
|
||||
// entirely and just use numbers.
|
||||
#define _QWERTY 0
|
||||
#define _COLEMAK 1
|
||||
#define _DVORAK 2
|
||||
#define _LOWER 3
|
||||
#define _RAISE 4
|
||||
#define _PLOVER 5
|
||||
#define _ADJUST 16
|
||||
|
||||
// Macro name shortcuts
|
||||
#define QWERTY M(_QWERTY)
|
||||
#define COLEMAK M(_COLEMAK)
|
||||
#define DVORAK M(_DVORAK)
|
||||
#define LOWER M(_LOWER)
|
||||
#define RAISE M(_RAISE)
|
||||
#define M_BL 5
|
||||
#define PLOVER M(12)
|
||||
#define EXT_PLV M(13)
|
||||
|
||||
// Fillers to make layering more clear
|
||||
#define _______ KC_TRNS
|
||||
#define XXXXXXX KC_NO
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
/* Qwerty
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Esc | A | S | D | F | G | H | J | K | L | ; | " |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | Shift| Z | X | C | V | B | N | M | , | . | / |Enter |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_QWERTY] = {
|
||||
{KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC},
|
||||
{KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT},
|
||||
{KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT },
|
||||
{M(M_BL), KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
|
||||
},
|
||||
|
||||
/* Colemak
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | Tab | Q | W | F | P | G | J | L | U | Y | ; | Bksp |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Esc | A | R | S | T | D | H | N | E | I | O | " |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | Shift| Z | X | C | V | B | K | M | , | . | / |Enter |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_COLEMAK] = {
|
||||
{KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC},
|
||||
{KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT},
|
||||
{KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT },
|
||||
{KC_LEAD, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
|
||||
},
|
||||
|
||||
/* Dvorak
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | Tab | " | , | . | P | Y | F | G | C | R | L | Bksp |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Esc | A | O | E | U | I | D | H | T | N | S | / |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | Shift| ; | Q | J | K | X | B | M | W | V | Z |Enter |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_DVORAK] = {
|
||||
{KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC},
|
||||
{KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH},
|
||||
{KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT },
|
||||
{M(M_BL), KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
|
||||
},
|
||||
|
||||
/* Lower
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | | |Enter |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | | | | | | | | Next | Vol- | Vol+ | Play |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_LOWER] = {
|
||||
{KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC},
|
||||
{KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE},
|
||||
{_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,S(KC_NUHS),S(KC_NUBS),_______, _______, _______},
|
||||
{_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
|
||||
},
|
||||
|
||||
/* Raise
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | | F7 | F8 | F9 | F10 | F11 | F12 |ISO # |ISO / | | |Enter |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | | | | | | | | Next | Vol- | Vol+ | Play |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_RAISE] = {
|
||||
{KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC},
|
||||
{KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS},
|
||||
{_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUHS, _______, _______, _______},
|
||||
{_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
|
||||
},
|
||||
|
||||
/* Plover layer (http://opensteno.org)
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | # | # | # | # | # | # | # | # | # | # | # | # |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | | S | T | P | H | * | * | F | P | L | T | D |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | | S | K | W | R | * | * | R | B | G | S | Z |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | Exit | | | A | O | | E | U | | | |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
|
||||
[_PLOVER] = {
|
||||
{KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1 },
|
||||
{XXXXXXX, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC},
|
||||
{XXXXXXX, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT},
|
||||
{EXT_PLV, XXXXXXX, XXXXXXX, KC_C, KC_V, XXXXXXX, XXXXXXX, KC_N, KC_M, XXXXXXX, XXXXXXX, XXXXXXX}
|
||||
},
|
||||
|
||||
/* Adjust (Lower + Raise)
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | | Reset| | | | | | | | | | Del |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak|Plover| |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | |Voice-|Voice+|Mus on|Musoff| | | | | | | |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | | | | | | | | | | | |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_ADJUST] = {
|
||||
{_______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL},
|
||||
{_______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, PLOVER, _______},
|
||||
{_______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, _______, _______, _______, _______, _______},
|
||||
{_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM fn_actions[] = {
|
||||
|
||||
};
|
||||
|
||||
#ifdef AUDIO_ENABLE
|
||||
float tone_startup[][2] = {
|
||||
{440.0*pow(2.0,(31)/12.0), 12},
|
||||
{440.0*pow(2.0,(28)/12.0), 8},
|
||||
{440.0*pow(2.0,(19)/12.0), 8},
|
||||
{440.0*pow(2.0,(24)/12.0), 8},
|
||||
{440.0*pow(2.0,(28)/12.0), 20}
|
||||
};
|
||||
|
||||
float tone_qwerty[][2] = SONG(QWERTY_SOUND);
|
||||
float tone_dvorak[][2] = SONG(DVORAK_SOUND);
|
||||
float tone_colemak[][2] = SONG(COLEMAK_SOUND);
|
||||
float tone_plover[][2] = SONG(PLOVER_SOUND);
|
||||
float tone_plover_gb[][2] = SONG(PLOVER_GOODBYE_SOUND);
|
||||
|
||||
float goodbye[][2] = SONG(GOODBYE_SOUND);
|
||||
#endif
|
||||
|
||||
|
||||
void persistant_default_layer_set(uint16_t default_layer) {
|
||||
eeconfig_update_default_layer(default_layer);
|
||||
default_layer_set(default_layer);
|
||||
}
|
||||
|
||||
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
|
||||
{
|
||||
switch(id) {
|
||||
case _QWERTY:
|
||||
if (record->event.pressed) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
PLAY_NOTE_ARRAY(tone_qwerty, false, 0);
|
||||
#endif
|
||||
persistant_default_layer_set(1UL<<_QWERTY);
|
||||
}
|
||||
break;
|
||||
case _COLEMAK:
|
||||
if (record->event.pressed) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
PLAY_NOTE_ARRAY(tone_colemak, false, 0);
|
||||
#endif
|
||||
persistant_default_layer_set(1UL<<_COLEMAK);
|
||||
}
|
||||
break;
|
||||
case _DVORAK:
|
||||
if (record->event.pressed) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
PLAY_NOTE_ARRAY(tone_dvorak, false, 0);
|
||||
#endif
|
||||
persistant_default_layer_set(1UL<<_DVORAK);
|
||||
}
|
||||
break;
|
||||
case _LOWER:
|
||||
if (record->event.pressed) {
|
||||
layer_on(_LOWER);
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
breathing_speed_set(2);
|
||||
breathing_pulse();
|
||||
#endif
|
||||
update_tri_layer(_LOWER, _RAISE, _ADJUST);
|
||||
} else {
|
||||
layer_off(_LOWER);
|
||||
update_tri_layer(_LOWER, _RAISE, _ADJUST);
|
||||
}
|
||||
break;
|
||||
case _RAISE:
|
||||
if (record->event.pressed) {
|
||||
layer_on(_RAISE);
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
breathing_speed_set(2);
|
||||
breathing_pulse();
|
||||
#endif
|
||||
update_tri_layer(_LOWER, _RAISE, _ADJUST);
|
||||
} else {
|
||||
layer_off(_RAISE);
|
||||
update_tri_layer(_LOWER, _RAISE, _ADJUST);
|
||||
}
|
||||
break;
|
||||
case M_BL:
|
||||
if (record->event.pressed) {
|
||||
register_code(KC_RSFT);
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
backlight_step();
|
||||
#endif
|
||||
} else {
|
||||
unregister_code(KC_RSFT);
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
if (record->event.pressed) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
stop_all_notes();
|
||||
PLAY_NOTE_ARRAY(tone_plover, false, 0);
|
||||
#endif
|
||||
layer_off(_RAISE);
|
||||
layer_off(_LOWER);
|
||||
layer_off(_ADJUST);
|
||||
layer_on(_PLOVER);
|
||||
if (!eeconfig_is_enabled()) {
|
||||
eeconfig_init();
|
||||
}
|
||||
keymap_config.raw = eeconfig_read_keymap();
|
||||
keymap_config.nkro = 1;
|
||||
eeconfig_update_keymap(keymap_config.raw);
|
||||
}
|
||||
break;
|
||||
case 13:
|
||||
if (record->event.pressed) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
PLAY_NOTE_ARRAY(tone_plover_gb, false, 0);
|
||||
#endif
|
||||
layer_off(_PLOVER);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
return MACRO_NONE;
|
||||
};
|
||||
|
||||
void matrix_init_user(void) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
_delay_ms(20); // stops the tick
|
||||
PLAY_NOTE_ARRAY(tone_startup, false, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef AUDIO_ENABLE
|
||||
void play_goodbye_tone(void)
|
||||
{
|
||||
PLAY_NOTE_ARRAY(goodbye, false, 0);
|
||||
_delay_ms(150);
|
||||
}
|
||||
#endif
|
||||
|
||||
LEADER_EXTERNS();
|
||||
|
||||
#define LEADER_TIMEOUT 300
|
||||
|
||||
void matrix_scan_user(void) {
|
||||
LEADER_DICTIONARY() {
|
||||
leading = false;
|
||||
leader_end();
|
||||
|
||||
SEQ_ONE_KEY(KC_F) {
|
||||
register_code(KC_S);
|
||||
unregister_code(KC_S);
|
||||
}
|
||||
SEQ_TWO_KEYS(KC_A, KC_S) {
|
||||
register_code(KC_H);
|
||||
unregister_code(KC_H);
|
||||
}
|
||||
SEQ_THREE_KEYS(KC_A, KC_S, KC_D) {
|
||||
register_code(KC_LGUI);
|
||||
register_code(KC_S);
|
||||
unregister_code(KC_S);
|
||||
unregister_code(KC_LGUI);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
AUDIO_ENABLE = yes
|
||||
NKRO_ENABLE = yes
|
||||
MIDI_ENABLE = yes
|
||||
BACKLIGHT_ENABLE = no
|
||||
COMMAND_ENABLE = no
|
After Width: | Height: | Size: 17 KiB |
@ -0,0 +1,56 @@
|
||||
#include "planck.h"
|
||||
#include "action_layer.h"
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
#include "backlight.h"
|
||||
#endif
|
||||
|
||||
//Simple Keymap where CTRL, WINKEY, and ALT keys are placed in a more familiar location for Windows users.
|
||||
//Focus of this particular keymap is to enable easy transition from more traditional keyboards to OLKB Planck.
|
||||
|
||||
// Each layer gets a name for readability, which is then used in the keymap matrix below.
|
||||
#define _QW 0
|
||||
#define _LW 1
|
||||
#define _RS 2
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[_QW] = { /* Qwerty */
|
||||
{KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC},
|
||||
{KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT},
|
||||
{KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, MT(MOD_RSFT, KC_ENT)},
|
||||
{KC_LCTL, KC_LGUI, KC_LALT, M(0), MO(_LW), KC_SPC, KC_SPC, MO(_RS), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
|
||||
},
|
||||
[_RS] = { /* RAISE */
|
||||
{KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL },
|
||||
{KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS},
|
||||
{KC_TRNS, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS},
|
||||
{KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS}
|
||||
},
|
||||
[_LW] = { /* LOWER */
|
||||
{KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL },
|
||||
{KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE},
|
||||
{KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_LBRC, KC_RBRC, KC_TRNS},
|
||||
{KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS}
|
||||
}
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM fn_actions[] = {
|
||||
|
||||
};
|
||||
|
||||
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
|
||||
{
|
||||
// MACRODOWN only works in this function
|
||||
switch(id) {
|
||||
case 0:
|
||||
if (record->event.pressed) {
|
||||
register_code(KC_RSFT);
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
backlight_step();
|
||||
#endif
|
||||
} else {
|
||||
unregister_code(KC_RSFT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return MACRO_NONE;
|
||||
};
|
@ -0,0 +1 @@
|
||||
Focus of this particular keymap is to enable easy transition from more traditional keyboards to OLKB Planck.
|
@ -0,0 +1,14 @@
|
||||
# Planck Layout by Pete
|
||||
|
||||
This layout is based on the default layout but uses a FN key in the bottom left corner instead of the shift / backlight key.
|
||||
On the FN layer you can do the following things
|
||||
|
||||
- Step through back light
|
||||
- Put a mac to sleep
|
||||
- The Fxx keys in a block to click with the right hand
|
||||
- The delete key in the upper right corner
|
||||
- Quick access to screenshot functions
|
||||
- Control volume and media playback
|
||||
- Home/PgDown/PgUp/End buttons where the arrow keys are
|
||||
|
||||
Pressing the lower and raise buttons allows to reset and change from QWERT to Colemak or Dvorak.
|
@ -0,0 +1,223 @@
|
||||
// This is the canonical layout file for the Quantum project. If you want to add another keyboard,
|
||||
// this is the style you want to emulate.
|
||||
|
||||
#include "planck.h"
|
||||
#include "action_layer.h"
|
||||
#ifdef AUDIO_ENABLE
|
||||
#include "audio.h"
|
||||
#endif
|
||||
#include "eeconfig.h"
|
||||
|
||||
extern keymap_config_t keymap_config;
|
||||
|
||||
// Each layer gets a name for readability, which is then used in the keymap matrix below.
|
||||
// The underscores don't mean anything - you can have a layer called STUFF or any other name.
|
||||
// Layer names don't all need to be of the same length, obviously, and you can also skip them
|
||||
// entirely and just use numbers.
|
||||
#define _QWERTY 0
|
||||
#define _COLEMAK 1
|
||||
#define _DVORAK 2
|
||||
#define _LOWER 3
|
||||
#define _RAISE 4
|
||||
#define _FCT 5
|
||||
#define _SETUP 6
|
||||
#define _MICMUTE 16
|
||||
|
||||
// Macro name shortcuts
|
||||
#define QWERTY M(_QWERTY)
|
||||
#define COLEMAK M(_COLEMAK)
|
||||
#define DVORAK M(_DVORAK)
|
||||
#define LOWER M(_LOWER)
|
||||
#define RAISE M(_RAISE)
|
||||
#define FCT M(_FCT)
|
||||
#define MICMUTE M(_MICMUTE)
|
||||
|
||||
#define MACPRNT LGUI(LSFT(KC_3))
|
||||
#define MACPRNT2 LGUI(LSFT(KC_4))
|
||||
#define CYCLWIN LGUI(KC_GRV)
|
||||
#define MAC_SLEP LSFT(LCTL(KC_POWER))
|
||||
|
||||
// Fillers to make layering more clear
|
||||
#define _______ KC_TRNS
|
||||
#define XXXXXXX KC_NO
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
[_QWERTY] = {
|
||||
{KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC},
|
||||
{KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT},
|
||||
{KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT },
|
||||
{FCT, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
|
||||
},
|
||||
|
||||
[_COLEMAK] = {
|
||||
{KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC},
|
||||
{KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT},
|
||||
{KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT },
|
||||
{FCT, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
|
||||
},
|
||||
|
||||
[_DVORAK] = {
|
||||
{KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC},
|
||||
{KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH},
|
||||
{KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT },
|
||||
{FCT, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
|
||||
},
|
||||
|
||||
[_LOWER] = {
|
||||
{KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC},
|
||||
{_______, _______, _______, _______, _______, _______, _______, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE},
|
||||
{_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______},
|
||||
{_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
|
||||
},
|
||||
|
||||
[_RAISE] = {
|
||||
{KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC},
|
||||
{_______, _______, _______, _______, _______, _______, _______, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS},
|
||||
{_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______},
|
||||
{_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
|
||||
},
|
||||
|
||||
[_FCT] = { /* Function */
|
||||
{BL_STEP, MAC_SLEP,XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_F1, KC_F2, KC_F3, KC_F4, KC_DELT},
|
||||
{_______, MICMUTE, KC_MUTE, KC_VOLD, KC_VOLU, XXXXXXX, XXXXXXX, KC_F5, KC_F6, KC_F7, KC_F8, MACPRNT},
|
||||
{_______, CYCLWIN, KC_MPRV, KC_MPLY, KC_MNXT, XXXXXXX, XXXXXXX, KC_F9, KC_F10, KC_F11, KC_F12, MACPRNT2},
|
||||
{FCT, _______, _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_HOME, KC_PGDOWN,KC_PGUP,KC_END }
|
||||
},
|
||||
|
||||
[_SETUP] = { /* Setup */
|
||||
{_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______},
|
||||
{_______, _______, _______, _______, _______, _______, _______, QWERTY, COLEMAK, DVORAK, _______, _______},
|
||||
{_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______},
|
||||
{_______, _______, _______, _______, _______, RESET, RESET, _______, _______, _______, _______, _______}
|
||||
}
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM fn_actions[] = {
|
||||
|
||||
};
|
||||
|
||||
#ifdef AUDIO_ENABLE
|
||||
float tone_startup[][2] = {
|
||||
{440.0*pow(2.0,(31)/12.0), 12},
|
||||
{440.0*pow(2.0,(28)/12.0), 8},
|
||||
{440.0*pow(2.0,(19)/12.0), 8},
|
||||
{440.0*pow(2.0,(24)/12.0), 8},
|
||||
{440.0*pow(2.0,(28)/12.0), 20}
|
||||
};
|
||||
|
||||
float tone_qwerty[][2] = SONG(QWERTY_SOUND);
|
||||
float tone_dvorak[][2] = SONG(DVORAK_SOUND);
|
||||
float tone_colemak[][2] = SONG(COLEMAK_SOUND);
|
||||
float tone_plover[][2] = SONG(PLOVER_SOUND);
|
||||
float tone_plover_gb[][2] = SONG(PLOVER_GOODBYE_SOUND);
|
||||
|
||||
float music_scale[][2] = SONG(MUSIC_SCALE_SOUND);
|
||||
float goodbye[][2] = SONG(GOODBYE_SOUND);
|
||||
#endif
|
||||
|
||||
|
||||
void persistant_default_layer_set(uint16_t default_layer) {
|
||||
eeconfig_update_default_layer(default_layer);
|
||||
default_layer_set(default_layer);
|
||||
}
|
||||
|
||||
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
|
||||
{
|
||||
switch(id) {
|
||||
case _QWERTY:
|
||||
if (record->event.pressed) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
PLAY_NOTE_ARRAY(tone_qwerty, false, 0);
|
||||
#endif
|
||||
persistant_default_layer_set(1UL<<_QWERTY);
|
||||
}
|
||||
break;
|
||||
case _COLEMAK:
|
||||
if (record->event.pressed) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
PLAY_NOTE_ARRAY(tone_colemak, false, 0);
|
||||
#endif
|
||||
persistant_default_layer_set(1UL<<_COLEMAK);
|
||||
}
|
||||
break;
|
||||
case _DVORAK:
|
||||
if (record->event.pressed) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
PLAY_NOTE_ARRAY(tone_dvorak, false, 0);
|
||||
#endif
|
||||
persistant_default_layer_set(1UL<<_DVORAK);
|
||||
}
|
||||
break;
|
||||
case _LOWER:
|
||||
if (record->event.pressed) {
|
||||
layer_on(_LOWER);
|
||||
update_tri_layer(_LOWER, _RAISE, _SETUP);
|
||||
} else {
|
||||
layer_off(_LOWER);
|
||||
update_tri_layer(_LOWER, _RAISE, _SETUP);
|
||||
}
|
||||
break;
|
||||
case _RAISE:
|
||||
if (record->event.pressed) {
|
||||
layer_on(_RAISE);
|
||||
update_tri_layer(_LOWER, _RAISE, _SETUP);
|
||||
} else {
|
||||
layer_off(_RAISE);
|
||||
update_tri_layer(_LOWER, _RAISE, _SETUP);
|
||||
}
|
||||
break;
|
||||
case _FCT:
|
||||
if (record->event.pressed) {
|
||||
layer_on(_FCT);
|
||||
} else {
|
||||
layer_off(_FCT);
|
||||
}
|
||||
break;
|
||||
case _MICMUTE:
|
||||
if (record->event.pressed) {
|
||||
register_code(KC_RSFT);
|
||||
register_code(KC_RCTL);
|
||||
register_code(KC_RALT);
|
||||
register_code(KC_RGUI);
|
||||
} else {
|
||||
unregister_code(KC_RSFT);
|
||||
unregister_code(KC_RCTL);
|
||||
unregister_code(KC_RALT);
|
||||
unregister_code(KC_RGUI);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
return MACRO_NONE;
|
||||
};
|
||||
|
||||
void matrix_init_user(void) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
_delay_ms(20); // stops the tick
|
||||
PLAY_NOTE_ARRAY(tone_startup, false, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef AUDIO_ENABLE
|
||||
void play_goodbye_tone()
|
||||
{
|
||||
PLAY_NOTE_ARRAY(goodbye, false, 0);
|
||||
_delay_ms(150);
|
||||
}
|
||||
|
||||
uint8_t starting_note = 0x0C;
|
||||
int offset = 0;
|
||||
|
||||
void process_action_user(keyrecord_t *record) {
|
||||
|
||||
if (IS_LAYER_ON(_MUSIC)) {
|
||||
if (record->event.pressed) {
|
||||
play_note(((double)220.0)*pow(2.0, -4.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)), 0xF);
|
||||
} else {
|
||||
stop_note(((double)220.0)*pow(2.0, -4.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
@ -0,0 +1,2 @@
|
||||
AUDIO_ENABLE = no
|
||||
NKRO_ENABLE = yes
|
@ -0,0 +1,326 @@
|
||||
/*
|
||||
Copyright
|
||||
2015 Jack Humbert <jack.humb@gmail.com>
|
||||
2016 Francois Marlier <fmarlier@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/>.
|
||||
|
||||
For more info on how this works per OS, see here
|
||||
https://en.wikipedia.org/wiki/Unicode_input#Hexadecimal_code_input
|
||||
*/
|
||||
|
||||
|
||||
#include "planck.h"
|
||||
#include "action_layer.h"
|
||||
#ifdef AUDIO_ENABLE
|
||||
#include "audio.h"
|
||||
#endif
|
||||
#include "eeconfig.h"
|
||||
|
||||
extern keymap_config_t keymap_config;
|
||||
|
||||
// Each layer gets a name for readability, which is then used in the keymap matrix below.
|
||||
// The underscores don't mean anything - you can have a layer called STUFF or any other name.
|
||||
// Layer names don't all need to be of the same length, obviously, and you can also skip them
|
||||
// entirely and just use numbers.
|
||||
#define _QWERTY 0
|
||||
#define _COLEMAK 1
|
||||
#define _DVORAK 2
|
||||
#define _LOWER 3
|
||||
#define _RAISE 4
|
||||
#define _PLOVER 5
|
||||
#define _ADJUST 16
|
||||
|
||||
// Macro name shortcuts
|
||||
#define QWERTY M(_QWERTY)
|
||||
#define COLEMAK M(_COLEMAK)
|
||||
#define DVORAK M(_DVORAK)
|
||||
#define LOWER M(_LOWER)
|
||||
#define RAISE M(_RAISE)
|
||||
#define M_BL 5
|
||||
#define PLOVER M(12)
|
||||
#define EXT_PLV M(13)
|
||||
#define TOG_OUT M(14)
|
||||
|
||||
// Fillers to make layering more clear
|
||||
#define _______ KC_TRNS
|
||||
#define XXXXXXX KC_NO
|
||||
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
/* Qwerty
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Esc | A | S | D | F | G | H | J | K | L | ; | " |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | Shift| Z | X | C | V | B | N | M | , | . | / |Enter |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_QWERTY] = {
|
||||
{KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC},
|
||||
{KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT},
|
||||
{KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT },
|
||||
{M(M_BL), KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
|
||||
},
|
||||
|
||||
/* Colemak
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | Tab | Q | W | F | P | G | J | L | U | Y | ; | Bksp |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Esc | A | R | S | T | D | H | N | E | I | O | " |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | Shift| Z | X | C | V | B | K | M | , | . | / |Enter |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_COLEMAK] = {
|
||||
{KC_TAB, UC_q, UC_w, UC_f, UC_p, UC_g, UC_j, UC_l, UC_u, UC_y, UC_SCLN, UC_BSPC},
|
||||
{KC_ESC, UC_a, UC_r, UC_s, UC_t, UC_d, UC_h, UC_n, UC_e, UC_i, UC_o, UC_QUOT},
|
||||
{KC_LSFT, UC_z, UC_x, UC_c, UC_v, UC_b, UC_k, UC_m, UC_COMM, UC_DOT, UC_SLSH, KC_ENT},
|
||||
{KC_TRNS, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
|
||||
},
|
||||
|
||||
/* Dvorak
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | Tab | " | , | . | P | Y | F | G | C | R | L | Bksp |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Esc | A | O | E | U | I | D | H | T | N | S | / |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | Shift| ; | Q | J | K | X | B | M | W | V | Z |Enter |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_DVORAK] = {
|
||||
{KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC},
|
||||
{KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH},
|
||||
{KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT },
|
||||
{M(M_BL), KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
|
||||
},
|
||||
|
||||
/* Lower
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | | F7 | F8 | F9 | F10 | F11 | F12 | | | | |Enter |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | | | | | | | | Next | Vol- | Vol+ | Play |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_LOWER] = {
|
||||
{KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC},
|
||||
{KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE},
|
||||
{_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______, _______, _______},
|
||||
{_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
|
||||
},
|
||||
|
||||
/* Raise
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | | F7 | F8 | F9 | F10 | F11 | F12 | | | | |Enter |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | | | | | | | | Next | Vol- | Vol+ | Play |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_RAISE] = {
|
||||
{KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC},
|
||||
{KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS},
|
||||
{_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______, _______, _______},
|
||||
{_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
|
||||
},
|
||||
|
||||
/* Plover layer (http://opensteno.org)
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | # | # | # | # | # | # | # | # | # | # | # | # |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | | S | T | P | H | * | * | F | P | L | T | D |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* |TogOut| S | K | W | R | * | * | R | B | G | S | Z |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | Exit | | | A | O | | E | U | | | |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
|
||||
[_PLOVER] = {
|
||||
{KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1 },
|
||||
{XXXXXXX, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC},
|
||||
{TOG_OUT, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT},
|
||||
{EXT_PLV, XXXXXXX, XXXXXXX, KC_C, KC_V, XXXXXXX, XXXXXXX, KC_N, KC_M, XXXXXXX, XXXXXXX, XXXXXXX}
|
||||
},
|
||||
|
||||
/* Adjust (Lower + Raise)
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | | Reset| | | | | | | | | | Del |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak|Plover| |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | |Voice-|Voice+|Mus on|Musoff| | | | | | | |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | | | | | | | | | | | |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_ADJUST] = {
|
||||
{_______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL},
|
||||
{_______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, PLOVER, _______},
|
||||
{_______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, _______, _______, _______, _______, _______},
|
||||
{_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM fn_actions[] = {
|
||||
|
||||
};
|
||||
|
||||
#ifdef AUDIO_ENABLE
|
||||
float tone_startup[][2] = {
|
||||
{440.0*pow(2.0,(31)/12.0), 12},
|
||||
{440.0*pow(2.0,(28)/12.0), 8},
|
||||
{440.0*pow(2.0,(19)/12.0), 8},
|
||||
{440.0*pow(2.0,(24)/12.0), 8},
|
||||
{440.0*pow(2.0,(28)/12.0), 20}
|
||||
};
|
||||
|
||||
float tone_qwerty[][2] = SONG(QWERTY_SOUND);
|
||||
float tone_dvorak[][2] = SONG(DVORAK_SOUND);
|
||||
float tone_colemak[][2] = SONG(COLEMAK_SOUND);
|
||||
float tone_plover[][2] = SONG(PLOVER_SOUND);
|
||||
float tone_plover_gb[][2] = SONG(PLOVER_GOODBYE_SOUND);
|
||||
|
||||
float goodbye[][2] = SONG(GOODBYE_SOUND);
|
||||
#endif
|
||||
|
||||
|
||||
void persistant_default_layer_set(uint16_t default_layer) {
|
||||
eeconfig_update_default_layer(default_layer);
|
||||
default_layer_set(default_layer);
|
||||
}
|
||||
|
||||
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
|
||||
{
|
||||
switch(id) {
|
||||
case _QWERTY:
|
||||
if (record->event.pressed) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
PLAY_NOTE_ARRAY(tone_qwerty, false, 0);
|
||||
#endif
|
||||
persistant_default_layer_set(1UL<<_QWERTY);
|
||||
}
|
||||
break;
|
||||
case _COLEMAK:
|
||||
if (record->event.pressed) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
PLAY_NOTE_ARRAY(tone_colemak, false, 0);
|
||||
#endif
|
||||
persistant_default_layer_set(1UL<<_COLEMAK);
|
||||
}
|
||||
break;
|
||||
case _DVORAK:
|
||||
if (record->event.pressed) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
PLAY_NOTE_ARRAY(tone_dvorak, false, 0);
|
||||
#endif
|
||||
persistant_default_layer_set(1UL<<_DVORAK);
|
||||
}
|
||||
break;
|
||||
case _LOWER:
|
||||
if (record->event.pressed) {
|
||||
layer_on(_LOWER);
|
||||
update_tri_layer(_LOWER, _RAISE, _ADJUST);
|
||||
} else {
|
||||
layer_off(_LOWER);
|
||||
update_tri_layer(_LOWER, _RAISE, _ADJUST);
|
||||
}
|
||||
break;
|
||||
case _RAISE:
|
||||
if (record->event.pressed) {
|
||||
layer_on(_RAISE);
|
||||
update_tri_layer(_LOWER, _RAISE, _ADJUST);
|
||||
} else {
|
||||
layer_off(_RAISE);
|
||||
update_tri_layer(_LOWER, _RAISE, _ADJUST);
|
||||
}
|
||||
break;
|
||||
case M_BL:
|
||||
if (record->event.pressed) {
|
||||
register_code(KC_RSFT);
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
backlight_step();
|
||||
#endif
|
||||
} else {
|
||||
unregister_code(KC_RSFT);
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
if (record->event.pressed) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
stop_all_notes();
|
||||
PLAY_NOTE_ARRAY(tone_plover, false, 0);
|
||||
#endif
|
||||
layer_off(_RAISE);
|
||||
layer_off(_LOWER);
|
||||
layer_off(_ADJUST);
|
||||
layer_on(_PLOVER);
|
||||
if (!eeconfig_is_enabled()) {
|
||||
eeconfig_init();
|
||||
}
|
||||
keymap_config.raw = eeconfig_read_keymap();
|
||||
keymap_config.nkro = 1;
|
||||
eeconfig_update_keymap(keymap_config.raw);
|
||||
}
|
||||
break;
|
||||
case 13:
|
||||
if (record->event.pressed) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
PLAY_NOTE_ARRAY(tone_plover_gb, false, 0);
|
||||
#endif
|
||||
layer_off(_PLOVER);
|
||||
}
|
||||
break;
|
||||
case 14:
|
||||
if (record->event.pressed) {
|
||||
return MACRO( D(E), D(R), D(F), D(V), D(O), D(L), U(E), U(R), U(F), U(V), U(O), U(L), END );
|
||||
}
|
||||
break;
|
||||
}
|
||||
return MACRO_NONE;
|
||||
};
|
||||
|
||||
void matrix_init_user(void) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
_delay_ms(20); // stops the tick
|
||||
PLAY_NOTE_ARRAY(tone_startup, false, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef AUDIO_ENABLE
|
||||
void play_goodbye_tone()
|
||||
{
|
||||
PLAY_NOTE_ARRAY(goodbye, false, 0);
|
||||
_delay_ms(150);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
UNICODE_ENABLE = yes # Unicode
|
@ -0,0 +1,643 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
//#include <math.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/io.h>
|
||||
#include "print.h"
|
||||
#include "audio.h"
|
||||
#include "keymap_common.h"
|
||||
|
||||
#include "eeconfig.h"
|
||||
|
||||
#define PI 3.14159265
|
||||
|
||||
#define CPU_PRESCALER 8
|
||||
|
||||
|
||||
// Timer Abstractions
|
||||
|
||||
// TIMSK3 - Timer/Counter #3 Interrupt Mask Register
|
||||
// Turn on/off 3A interputs, stopping/enabling the ISR calls
|
||||
#define ENABLE_AUDIO_COUNTER_3_ISR TIMSK3 |= _BV(OCIE3A)
|
||||
#define DISABLE_AUDIO_COUNTER_3_ISR TIMSK3 &= ~_BV(OCIE3A)
|
||||
|
||||
|
||||
// TCCR3A: Timer/Counter #3 Control Register
|
||||
// Compare Output Mode (COM3An) = 0b00 = Normal port operation, OC3A disconnected from PC6
|
||||
#define ENABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A |= _BV(COM3A1);
|
||||
#define DISABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A &= ~(_BV(COM3A1) | _BV(COM3A0));
|
||||
|
||||
|
||||
#define NOTE_PERIOD ICR3
|
||||
#define NOTE_DUTY_CYCLE OCR3A
|
||||
|
||||
|
||||
#ifdef PWM_AUDIO
|
||||
#include "wave.h"
|
||||
#define SAMPLE_DIVIDER 39
|
||||
#define SAMPLE_RATE (2000000.0/SAMPLE_DIVIDER/2048)
|
||||
// Resistor value of 1/ (2 * PI * 10nF * (2000000 hertz / SAMPLE_DIVIDER / 10)) for 10nF cap
|
||||
|
||||
float places[8] = {0, 0, 0, 0, 0, 0, 0, 0};
|
||||
uint16_t place_int = 0;
|
||||
bool repeat = true;
|
||||
#endif
|
||||
|
||||
void delay_us(int count) {
|
||||
while(count--) {
|
||||
_delay_us(1);
|
||||
}
|
||||
}
|
||||
|
||||
int voices = 0;
|
||||
int voice_place = 0;
|
||||
float frequency = 0;
|
||||
int volume = 0;
|
||||
long position = 0;
|
||||
|
||||
float frequencies[8] = {0, 0, 0, 0, 0, 0, 0, 0};
|
||||
int volumes[8] = {0, 0, 0, 0, 0, 0, 0, 0};
|
||||
bool sliding = false;
|
||||
|
||||
float place = 0;
|
||||
|
||||
uint8_t * sample;
|
||||
uint16_t sample_length = 0;
|
||||
// float freq = 0;
|
||||
|
||||
bool playing_notes = false;
|
||||
bool playing_note = false;
|
||||
float note_frequency = 0;
|
||||
float note_length = 0;
|
||||
uint8_t note_tempo = TEMPO_DEFAULT;
|
||||
float note_timbre = TIMBRE_DEFAULT;
|
||||
uint16_t note_position = 0;
|
||||
float (* notes_pointer)[][2];
|
||||
uint16_t notes_count;
|
||||
bool notes_repeat;
|
||||
float notes_rest;
|
||||
bool note_resting = false;
|
||||
|
||||
uint8_t current_note = 0;
|
||||
uint8_t rest_counter = 0;
|
||||
|
||||
#ifdef VIBRATO_ENABLE
|
||||
float vibrato_counter = 0;
|
||||
float vibrato_strength = .5;
|
||||
float vibrato_rate = 0.125;
|
||||
#endif
|
||||
|
||||
float polyphony_rate = 0;
|
||||
|
||||
static bool audio_initialized = false;
|
||||
|
||||
audio_config_t audio_config;
|
||||
|
||||
uint16_t envelope_index = 0;
|
||||
|
||||
void audio_init() {
|
||||
|
||||
// Check EEPROM
|
||||
if (!eeconfig_is_enabled())
|
||||
{
|
||||
eeconfig_init();
|
||||
}
|
||||
audio_config.raw = eeconfig_read_audio();
|
||||
|
||||
#ifdef PWM_AUDIO
|
||||
|
||||
PLLFRQ = _BV(PDIV2);
|
||||
PLLCSR = _BV(PLLE);
|
||||
while(!(PLLCSR & _BV(PLOCK)));
|
||||
PLLFRQ |= _BV(PLLTM0); /* PCK 48MHz */
|
||||
|
||||
/* Init a fast PWM on Timer4 */
|
||||
TCCR4A = _BV(COM4A0) | _BV(PWM4A); /* Clear OC4A on Compare Match */
|
||||
TCCR4B = _BV(CS40); /* No prescaling => f = PCK/256 = 187500Hz */
|
||||
OCR4A = 0;
|
||||
|
||||
/* Enable the OC4A output */
|
||||
DDRC |= _BV(PORTC6);
|
||||
|
||||
DISABLE_AUDIO_COUNTER_3_ISR; // Turn off 3A interputs
|
||||
|
||||
TCCR3A = 0x0; // Options not needed
|
||||
TCCR3B = _BV(CS31) | _BV(CS30) | _BV(WGM32); // 64th prescaling and CTC
|
||||
OCR3A = SAMPLE_DIVIDER - 1; // Correct count/compare, related to sample playback
|
||||
|
||||
#else
|
||||
|
||||
// Set port PC6 (OC3A and /OC4A) as output
|
||||
DDRC |= _BV(PORTC6);
|
||||
|
||||
DISABLE_AUDIO_COUNTER_3_ISR;
|
||||
|
||||
// TCCR3A / TCCR3B: Timer/Counter #3 Control Registers
|
||||
// Compare Output Mode (COM3An) = 0b00 = Normal port operation, OC3A disconnected from PC6
|
||||
// Waveform Generation Mode (WGM3n) = 0b1110 = Fast PWM Mode 14 (Period = ICR3, Duty Cycle = OCR3A)
|
||||
// Clock Select (CS3n) = 0b010 = Clock / 8
|
||||
TCCR3A = (0 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30);
|
||||
TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (1 << CS31) | (0 << CS30);
|
||||
|
||||
#endif
|
||||
|
||||
audio_initialized = true;
|
||||
}
|
||||
|
||||
void stop_all_notes() {
|
||||
if (!audio_initialized) {
|
||||
audio_init();
|
||||
}
|
||||
voices = 0;
|
||||
#ifdef PWM_AUDIO
|
||||
DISABLE_AUDIO_COUNTER_3_ISR;
|
||||
#else
|
||||
DISABLE_AUDIO_COUNTER_3_ISR;
|
||||
DISABLE_AUDIO_COUNTER_3_OUTPUT;
|
||||
#endif
|
||||
|
||||
playing_notes = false;
|
||||
playing_note = false;
|
||||
frequency = 0;
|
||||
volume = 0;
|
||||
|
||||
for (uint8_t i = 0; i < 8; i++)
|
||||
{
|
||||
frequencies[i] = 0;
|
||||
volumes[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void stop_note(float freq)
|
||||
{
|
||||
if (playing_note) {
|
||||
if (!audio_initialized) {
|
||||
audio_init();
|
||||
}
|
||||
#ifdef PWM_AUDIO
|
||||
freq = freq / SAMPLE_RATE;
|
||||
#endif
|
||||
for (int i = 7; i >= 0; i--) {
|
||||
if (frequencies[i] == freq) {
|
||||
frequencies[i] = 0;
|
||||
volumes[i] = 0;
|
||||
for (int j = i; (j < 7); j++) {
|
||||
frequencies[j] = frequencies[j+1];
|
||||
frequencies[j+1] = 0;
|
||||
volumes[j] = volumes[j+1];
|
||||
volumes[j+1] = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
voices--;
|
||||
if (voices < 0)
|
||||
voices = 0;
|
||||
if (voice_place >= voices) {
|
||||
voice_place = 0;
|
||||
}
|
||||
if (voices == 0) {
|
||||
#ifdef PWM_AUDIO
|
||||
DISABLE_AUDIO_COUNTER_3_ISR;
|
||||
#else
|
||||
DISABLE_AUDIO_COUNTER_3_ISR;
|
||||
DISABLE_AUDIO_COUNTER_3_OUTPUT;
|
||||
#endif
|
||||
frequency = 0;
|
||||
volume = 0;
|
||||
playing_note = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VIBRATO_ENABLE
|
||||
|
||||
float mod(float a, int b)
|
||||
{
|
||||
float r = fmod(a, b);
|
||||
return r < 0 ? r + b : r;
|
||||
}
|
||||
|
||||
float vibrato(float average_freq) {
|
||||
#ifdef VIBRATO_STRENGTH_ENABLE
|
||||
float vibrated_freq = average_freq * pow(vibrato_lut[(int)vibrato_counter], vibrato_strength);
|
||||
#else
|
||||
float vibrated_freq = average_freq * vibrato_lut[(int)vibrato_counter];
|
||||
#endif
|
||||
vibrato_counter = mod((vibrato_counter + vibrato_rate * (1.0 + 440.0/average_freq)), VIBRATO_LUT_LENGTH);
|
||||
return vibrated_freq;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
ISR(TIMER3_COMPA_vect)
|
||||
{
|
||||
if (playing_note) {
|
||||
#ifdef PWM_AUDIO
|
||||
if (voices == 1) {
|
||||
// SINE
|
||||
OCR4A = pgm_read_byte(&sinewave[(uint16_t)place]) >> 2;
|
||||
|
||||
// SQUARE
|
||||
// if (((int)place) >= 1024){
|
||||
// OCR4A = 0xFF >> 2;
|
||||
// } else {
|
||||
// OCR4A = 0x00;
|
||||
// }
|
||||
|
||||
// SAWTOOTH
|
||||
// OCR4A = (int)place / 4;
|
||||
|
||||
// TRIANGLE
|
||||
// if (((int)place) >= 1024) {
|
||||
// OCR4A = (int)place / 2;
|
||||
// } else {
|
||||
// OCR4A = 2048 - (int)place / 2;
|
||||
// }
|
||||
|
||||
place += frequency;
|
||||
|
||||
if (place >= SINE_LENGTH)
|
||||
place -= SINE_LENGTH;
|
||||
|
||||
} else {
|
||||
int sum = 0;
|
||||
for (int i = 0; i < voices; i++) {
|
||||
// SINE
|
||||
sum += pgm_read_byte(&sinewave[(uint16_t)places[i]]) >> 2;
|
||||
|
||||
// SQUARE
|
||||
// if (((int)places[i]) >= 1024){
|
||||
// sum += 0xFF >> 2;
|
||||
// } else {
|
||||
// sum += 0x00;
|
||||
// }
|
||||
|
||||
places[i] += frequencies[i];
|
||||
|
||||
if (places[i] >= SINE_LENGTH)
|
||||
places[i] -= SINE_LENGTH;
|
||||
}
|
||||
OCR4A = sum;
|
||||
}
|
||||
#else
|
||||
if (voices > 0) {
|
||||
float freq;
|
||||
if (polyphony_rate > 0) {
|
||||
if (voices > 1) {
|
||||
voice_place %= voices;
|
||||
if (place++ > (frequencies[voice_place] / polyphony_rate / CPU_PRESCALER)) {
|
||||
voice_place = (voice_place + 1) % voices;
|
||||
place = 0.0;
|
||||
}
|
||||
}
|
||||
#ifdef VIBRATO_ENABLE
|
||||
if (vibrato_strength > 0) {
|
||||
freq = vibrato(frequencies[voice_place]);
|
||||
} else {
|
||||
#else
|
||||
{
|
||||
#endif
|
||||
freq = frequencies[voice_place];
|
||||
}
|
||||
} else {
|
||||
if (frequency != 0 && frequency < frequencies[voices - 1] && frequency < frequencies[voices - 1] * pow(2, -440/frequencies[voices - 1]/12/2)) {
|
||||
frequency = frequency * pow(2, 440/frequency/12/2);
|
||||
} else if (frequency != 0 && frequency > frequencies[voices - 1] && frequency > frequencies[voices - 1] * pow(2, 440/frequencies[voices - 1]/12/2)) {
|
||||
frequency = frequency * pow(2, -440/frequency/12/2);
|
||||
} else {
|
||||
frequency = frequencies[voices - 1];
|
||||
}
|
||||
|
||||
|
||||
#ifdef VIBRATO_ENABLE
|
||||
if (vibrato_strength > 0) {
|
||||
freq = vibrato(frequency);
|
||||
} else {
|
||||
#else
|
||||
{
|
||||
#endif
|
||||
freq = frequency;
|
||||
}
|
||||
}
|
||||
|
||||
if (envelope_index < 65535) {
|
||||
envelope_index++;
|
||||
}
|
||||
freq = voice_envelope(freq);
|
||||
|
||||
if (freq < 30.517578125)
|
||||
freq = 30.52;
|
||||
NOTE_PERIOD = (int)(((double)F_CPU) / (freq * CPU_PRESCALER)); // Set max to the period
|
||||
NOTE_DUTY_CYCLE = (int)((((double)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); // Set compare to half the period
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// SAMPLE
|
||||
// OCR4A = pgm_read_byte(&sample[(uint16_t)place_int]);
|
||||
|
||||
// place_int++;
|
||||
|
||||
// if (place_int >= sample_length)
|
||||
// if (repeat)
|
||||
// place_int -= sample_length;
|
||||
// else
|
||||
// DISABLE_AUDIO_COUNTER_3_ISR;
|
||||
|
||||
|
||||
if (playing_notes) {
|
||||
#ifdef PWM_AUDIO
|
||||
OCR4A = pgm_read_byte(&sinewave[(uint16_t)place]) >> 0;
|
||||
|
||||
place += note_frequency;
|
||||
if (place >= SINE_LENGTH)
|
||||
place -= SINE_LENGTH;
|
||||
#else
|
||||
if (note_frequency > 0) {
|
||||
float freq;
|
||||
|
||||
#ifdef VIBRATO_ENABLE
|
||||
if (vibrato_strength > 0) {
|
||||
freq = vibrato(note_frequency);
|
||||
} else {
|
||||
#else
|
||||
{
|
||||
#endif
|
||||
freq = note_frequency;
|
||||
}
|
||||
|
||||
if (envelope_index < 65535) {
|
||||
envelope_index++;
|
||||
}
|
||||
freq = voice_envelope(freq);
|
||||
|
||||
NOTE_PERIOD = (int)(((double)F_CPU) / (freq * CPU_PRESCALER)); // Set max to the period
|
||||
NOTE_DUTY_CYCLE = (int)((((double)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); // Set compare to half the period
|
||||
} else {
|
||||
NOTE_PERIOD = 0;
|
||||
NOTE_DUTY_CYCLE = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
note_position++;
|
||||
bool end_of_note = false;
|
||||
if (NOTE_PERIOD > 0)
|
||||
end_of_note = (note_position >= (note_length / NOTE_PERIOD * 0xFFFF));
|
||||
else
|
||||
end_of_note = (note_position >= (note_length * 0x7FF));
|
||||
if (end_of_note) {
|
||||
current_note++;
|
||||
if (current_note >= notes_count) {
|
||||
if (notes_repeat) {
|
||||
current_note = 0;
|
||||
} else {
|
||||
#ifdef PWM_AUDIO
|
||||
DISABLE_AUDIO_COUNTER_3_ISR;
|
||||
#else
|
||||
DISABLE_AUDIO_COUNTER_3_ISR;
|
||||
DISABLE_AUDIO_COUNTER_3_OUTPUT;
|
||||
#endif
|
||||
playing_notes = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!note_resting && (notes_rest > 0)) {
|
||||
note_resting = true;
|
||||
note_frequency = 0;
|
||||
note_length = notes_rest;
|
||||
current_note--;
|
||||
} else {
|
||||
note_resting = false;
|
||||
#ifdef PWM_AUDIO
|
||||
note_frequency = (*notes_pointer)[current_note][0] / SAMPLE_RATE;
|
||||
note_length = (*notes_pointer)[current_note][1] * (((float)note_tempo) / 100);
|
||||
#else
|
||||
envelope_index = 0;
|
||||
note_frequency = (*notes_pointer)[current_note][0];
|
||||
note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100);
|
||||
#endif
|
||||
}
|
||||
note_position = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!audio_config.enable) {
|
||||
playing_notes = false;
|
||||
playing_note = false;
|
||||
}
|
||||
}
|
||||
|
||||
void play_note(float freq, int vol) {
|
||||
|
||||
if (!audio_initialized) {
|
||||
audio_init();
|
||||
}
|
||||
|
||||
if (audio_config.enable && voices < 8) {
|
||||
DISABLE_AUDIO_COUNTER_3_ISR;
|
||||
|
||||
// Cancel notes if notes are playing
|
||||
if (playing_notes)
|
||||
stop_all_notes();
|
||||
|
||||
playing_note = true;
|
||||
|
||||
envelope_index = 0;
|
||||
|
||||
#ifdef PWM_AUDIO
|
||||
freq = freq / SAMPLE_RATE;
|
||||
#endif
|
||||
if (freq > 0) {
|
||||
frequencies[voices] = freq;
|
||||
volumes[voices] = vol;
|
||||
voices++;
|
||||
}
|
||||
|
||||
#ifdef PWM_AUDIO
|
||||
ENABLE_AUDIO_COUNTER_3_ISR;
|
||||
#else
|
||||
ENABLE_AUDIO_COUNTER_3_ISR;
|
||||
ENABLE_AUDIO_COUNTER_3_OUTPUT;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest)
|
||||
{
|
||||
|
||||
if (!audio_initialized) {
|
||||
audio_init();
|
||||
}
|
||||
|
||||
if (audio_config.enable) {
|
||||
|
||||
DISABLE_AUDIO_COUNTER_3_ISR;
|
||||
|
||||
// Cancel note if a note is playing
|
||||
if (playing_note)
|
||||
stop_all_notes();
|
||||
|
||||
playing_notes = true;
|
||||
|
||||
notes_pointer = np;
|
||||
notes_count = n_count;
|
||||
notes_repeat = n_repeat;
|
||||
notes_rest = n_rest;
|
||||
|
||||
place = 0;
|
||||
current_note = 0;
|
||||
|
||||
#ifdef PWM_AUDIO
|
||||
note_frequency = (*notes_pointer)[current_note][0] / SAMPLE_RATE;
|
||||
note_length = (*notes_pointer)[current_note][1] * (((float)note_tempo) / 100);
|
||||
#else
|
||||
note_frequency = (*notes_pointer)[current_note][0];
|
||||
note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100);
|
||||
#endif
|
||||
note_position = 0;
|
||||
|
||||
|
||||
#ifdef PWM_AUDIO
|
||||
ENABLE_AUDIO_COUNTER_3_ISR;
|
||||
#else
|
||||
ENABLE_AUDIO_COUNTER_3_ISR;
|
||||
ENABLE_AUDIO_COUNTER_3_OUTPUT;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifdef PWM_AUDIO
|
||||
void play_sample(uint8_t * s, uint16_t l, bool r) {
|
||||
if (!audio_initialized) {
|
||||
audio_init();
|
||||
}
|
||||
|
||||
if (audio_config.enable) {
|
||||
DISABLE_AUDIO_COUNTER_3_ISR;
|
||||
stop_all_notes();
|
||||
place_int = 0;
|
||||
sample = s;
|
||||
sample_length = l;
|
||||
repeat = r;
|
||||
|
||||
ENABLE_AUDIO_COUNTER_3_ISR;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void audio_toggle(void) {
|
||||
audio_config.enable ^= 1;
|
||||
eeconfig_update_audio(audio_config.raw);
|
||||
}
|
||||
|
||||
void audio_on(void) {
|
||||
audio_config.enable = 1;
|
||||
eeconfig_update_audio(audio_config.raw);
|
||||
}
|
||||
|
||||
void audio_off(void) {
|
||||
audio_config.enable = 0;
|
||||
eeconfig_update_audio(audio_config.raw);
|
||||
}
|
||||
|
||||
#ifdef VIBRATO_ENABLE
|
||||
|
||||
// Vibrato rate functions
|
||||
|
||||
void set_vibrato_rate(float rate) {
|
||||
vibrato_rate = rate;
|
||||
}
|
||||
|
||||
void increase_vibrato_rate(float change) {
|
||||
vibrato_rate *= change;
|
||||
}
|
||||
|
||||
void decrease_vibrato_rate(float change) {
|
||||
vibrato_rate /= change;
|
||||
}
|
||||
|
||||
#ifdef VIBRATO_STRENGTH_ENABLE
|
||||
|
||||
void set_vibrato_strength(float strength) {
|
||||
vibrato_strength = strength;
|
||||
}
|
||||
|
||||
void increase_vibrato_strength(float change) {
|
||||
vibrato_strength *= change;
|
||||
}
|
||||
|
||||
void decrease_vibrato_strength(float change) {
|
||||
vibrato_strength /= change;
|
||||
}
|
||||
|
||||
#endif /* VIBRATO_STRENGTH_ENABLE */
|
||||
|
||||
#endif /* VIBRATO_ENABLE */
|
||||
|
||||
// Polyphony functions
|
||||
|
||||
void set_polyphony_rate(float rate) {
|
||||
polyphony_rate = rate;
|
||||
}
|
||||
|
||||
void enable_polyphony() {
|
||||
polyphony_rate = 5;
|
||||
}
|
||||
|
||||
void disable_polyphony() {
|
||||
polyphony_rate = 0;
|
||||
}
|
||||
|
||||
void increase_polyphony_rate(float change) {
|
||||
polyphony_rate *= change;
|
||||
}
|
||||
|
||||
void decrease_polyphony_rate(float change) {
|
||||
polyphony_rate /= change;
|
||||
}
|
||||
|
||||
// Timbre function
|
||||
|
||||
void set_timbre(float timbre) {
|
||||
note_timbre = timbre;
|
||||
}
|
||||
|
||||
// Tempo functions
|
||||
|
||||
void set_tempo(uint8_t tempo) {
|
||||
note_tempo = tempo;
|
||||
}
|
||||
|
||||
void decrease_tempo(uint8_t tempo_change) {
|
||||
note_tempo += tempo_change;
|
||||
}
|
||||
|
||||
void increase_tempo(uint8_t tempo_change) {
|
||||
if (note_tempo - tempo_change < 10) {
|
||||
note_tempo = 10;
|
||||
} else {
|
||||
note_tempo -= tempo_change;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Override these functions in your keymap file to play different tunes on
|
||||
// startup and bootloader jump
|
||||
__attribute__ ((weak))
|
||||
void play_startup_tone()
|
||||
{
|
||||
}
|
||||
|
||||
__attribute__ ((weak))
|
||||
void play_goodbye_tone()
|
||||
{
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
@ -1,357 +0,0 @@
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#define FREQUENCY_LUT_LENGTH 349
|
||||
|
||||
const uint16_t FREQUENCY_LUT[FREQUENCY_LUT_LENGTH] = {
|
||||
0x8E0B,
|
||||
0x8C02,
|
||||
0x8A00,
|
||||
0x8805,
|
||||
0x8612,
|
||||
0x8426,
|
||||
0x8241,
|
||||
0x8063,
|
||||
0x7E8C,
|
||||
0x7CBB,
|
||||
0x7AF2,
|
||||
0x792E,
|
||||
0x7772,
|
||||
0x75BB,
|
||||
0x740B,
|
||||
0x7261,
|
||||
0x70BD,
|
||||
0x6F20,
|
||||
0x6D88,
|
||||
0x6BF6,
|
||||
0x6A69,
|
||||
0x68E3,
|
||||
0x6762,
|
||||
0x65E6,
|
||||
0x6470,
|
||||
0x6300,
|
||||
0x6194,
|
||||
0x602E,
|
||||
0x5ECD,
|
||||
0x5D71,
|
||||
0x5C1A,
|
||||
0x5AC8,
|
||||
0x597B,
|
||||
0x5833,
|
||||
0x56EF,
|
||||
0x55B0,
|
||||
0x5475,
|
||||
0x533F,
|
||||
0x520E,
|
||||
0x50E1,
|
||||
0x4FB8,
|
||||
0x4E93,
|
||||
0x4D73,
|
||||
0x4C57,
|
||||
0x4B3E,
|
||||
0x4A2A,
|
||||
0x491A,
|
||||
0x480E,
|
||||
0x4705,
|
||||
0x4601,
|
||||
0x4500,
|
||||
0x4402,
|
||||
0x4309,
|
||||
0x4213,
|
||||
0x4120,
|
||||
0x4031,
|
||||
0x3F46,
|
||||
0x3E5D,
|
||||
0x3D79,
|
||||
0x3C97,
|
||||
0x3BB9,
|
||||
0x3ADD,
|
||||
0x3A05,
|
||||
0x3930,
|
||||
0x385E,
|
||||
0x3790,
|
||||
0x36C4,
|
||||
0x35FB,
|
||||
0x3534,
|
||||
0x3471,
|
||||
0x33B1,
|
||||
0x32F3,
|
||||
0x3238,
|
||||
0x3180,
|
||||
0x30CA,
|
||||
0x3017,
|
||||
0x2F66,
|
||||
0x2EB8,
|
||||
0x2E0D,
|
||||
0x2D64,
|
||||
0x2CBD,
|
||||
0x2C19,
|
||||
0x2B77,
|
||||
0x2AD8,
|
||||
0x2A3A,
|
||||
0x299F,
|
||||
0x2907,
|
||||
0x2870,
|
||||
0x27DC,
|
||||
0x2749,
|
||||
0x26B9,
|
||||
0x262B,
|
||||
0x259F,
|
||||
0x2515,
|
||||
0x248D,
|
||||
0x2407,
|
||||
0x2382,
|
||||
0x2300,
|
||||
0x2280,
|
||||
0x2201,
|
||||
0x2184,
|
||||
0x2109,
|
||||
0x2090,
|
||||
0x2018,
|
||||
0x1FA3,
|
||||
0x1F2E,
|
||||
0x1EBC,
|
||||
0x1E4B,
|
||||
0x1DDC,
|
||||
0x1D6E,
|
||||
0x1D02,
|
||||
0x1C98,
|
||||
0x1C2F,
|
||||
0x1BC8,
|
||||
0x1B62,
|
||||
0x1AFD,
|
||||
0x1A9A,
|
||||
0x1A38,
|
||||
0x19D8,
|
||||
0x1979,
|
||||
0x191C,
|
||||
0x18C0,
|
||||
0x1865,
|
||||
0x180B,
|
||||
0x17B3,
|
||||
0x175C,
|
||||
0x1706,
|
||||
0x16B2,
|
||||
0x165E,
|
||||
0x160C,
|
||||
0x15BB,
|
||||
0x156C,
|
||||
0x151D,
|
||||
0x14CF,
|
||||
0x1483,
|
||||
0x1438,
|
||||
0x13EE,
|
||||
0x13A4,
|
||||
0x135C,
|
||||
0x1315,
|
||||
0x12CF,
|
||||
0x128A,
|
||||
0x1246,
|
||||
0x1203,
|
||||
0x11C1,
|
||||
0x1180,
|
||||
0x1140,
|
||||
0x1100,
|
||||
0x10C2,
|
||||
0x1084,
|
||||
0x1048,
|
||||
0x100C,
|
||||
0xFD1,
|
||||
0xF97,
|
||||
0xF5E,
|
||||
0xF25,
|
||||
0xEEE,
|
||||
0xEB7,
|
||||
0xE81,
|
||||
0xE4C,
|
||||
0xE17,
|
||||
0xDE4,
|
||||
0xDB1,
|
||||
0xD7E,
|
||||
0xD4D,
|
||||
0xD1C,
|
||||
0xCEC,
|
||||
0xCBC,
|
||||
0xC8E,
|
||||
0xC60,
|
||||
0xC32,
|
||||
0xC05,
|
||||
0xBD9,
|
||||
0xBAE,
|
||||
0xB83,
|
||||
0xB59,
|
||||
0xB2F,
|
||||
0xB06,
|
||||
0xADD,
|
||||
0xAB6,
|
||||
0xA8E,
|
||||
0xA67,
|
||||
0xA41,
|
||||
0xA1C,
|
||||
0x9F7,
|
||||
0x9D2,
|
||||
0x9AE,
|
||||
0x98A,
|
||||
0x967,
|
||||
0x945,
|
||||
0x923,
|
||||
0x901,
|
||||
0x8E0,
|
||||
0x8C0,
|
||||
0x8A0,
|
||||
0x880,
|
||||
0x861,
|
||||
0x842,
|
||||
0x824,
|
||||
0x806,
|
||||
0x7E8,
|
||||
0x7CB,
|
||||
0x7AF,
|
||||
0x792,
|
||||
0x777,
|
||||
0x75B,
|
||||
0x740,
|
||||
0x726,
|
||||
0x70B,
|
||||
0x6F2,
|
||||
0x6D8,
|
||||
0x6BF,
|
||||
0x6A6,
|
||||
0x68E,
|
||||
0x676,
|
||||
0x65E,
|
||||
0x647,
|
||||
0x630,
|
||||
0x619,
|
||||
0x602,
|
||||
0x5EC,
|
||||
0x5D7,
|
||||
0x5C1,
|
||||
0x5AC,
|
||||
0x597,
|
||||
0x583,
|
||||
0x56E,
|
||||
0x55B,
|
||||
0x547,
|
||||
0x533,
|
||||
0x520,
|
||||
0x50E,
|
||||
0x4FB,
|
||||
0x4E9,
|
||||
0x4D7,
|
||||
0x4C5,
|
||||
0x4B3,
|
||||
0x4A2,
|
||||
0x491,
|
||||
0x480,
|
||||
0x470,
|
||||
0x460,
|
||||
0x450,
|
||||
0x440,
|
||||
0x430,
|
||||
0x421,
|
||||
0x412,
|
||||
0x403,
|
||||
0x3F4,
|
||||
0x3E5,
|
||||
0x3D7,
|
||||
0x3C9,
|
||||
0x3BB,
|
||||
0x3AD,
|
||||
0x3A0,
|
||||
0x393,
|
||||
0x385,
|
||||
0x379,
|
||||
0x36C,
|
||||
0x35F,
|
||||
0x353,
|
||||
0x347,
|
||||
0x33B,
|
||||
0x32F,
|
||||
0x323,
|
||||
0x318,
|
||||
0x30C,
|
||||
0x301,
|
||||
0x2F6,
|
||||
0x2EB,
|
||||
0x2E0,
|
||||
0x2D6,
|
||||
0x2CB,
|
||||
0x2C1,
|
||||
0x2B7,
|
||||
0x2AD,
|
||||
0x2A3,
|
||||
0x299,
|
||||
0x290,
|
||||
0x287,
|
||||
0x27D,
|
||||
0x274,
|
||||
0x26B,
|
||||
0x262,
|
||||
0x259,
|
||||
0x251,
|
||||
0x248,
|
||||
0x240,
|
||||
0x238,
|
||||
0x230,
|
||||
0x228,
|
||||
0x220,
|
||||
0x218,
|
||||
0x210,
|
||||
0x209,
|
||||
0x201,
|
||||
0x1FA,
|
||||
0x1F2,
|
||||
0x1EB,
|
||||
0x1E4,
|
||||
0x1DD,
|
||||
0x1D6,
|
||||
0x1D0,
|
||||
0x1C9,
|
||||
0x1C2,
|
||||
0x1BC,
|
||||
0x1B6,
|
||||
0x1AF,
|
||||
0x1A9,
|
||||
0x1A3,
|
||||
0x19D,
|
||||
0x197,
|
||||
0x191,
|
||||
0x18C,
|
||||
0x186,
|
||||
0x180,
|
||||
0x17B,
|
||||
0x175,
|
||||
0x170,
|
||||
0x16B,
|
||||
0x165,
|
||||
0x160,
|
||||
0x15B,
|
||||
0x156,
|
||||
0x151,
|
||||
0x14C,
|
||||
0x148,
|
||||
0x143,
|
||||
0x13E,
|
||||
0x13A,
|
||||
0x135,
|
||||
0x131,
|
||||
0x12C,
|
||||
0x128,
|
||||
0x124,
|
||||
0x120,
|
||||
0x11C,
|
||||
0x118,
|
||||
0x114,
|
||||
0x110,
|
||||
0x10C,
|
||||
0x108,
|
||||
0x104,
|
||||
0x100,
|
||||
0xFD,
|
||||
0xF9,
|
||||
0xF5,
|
||||
0xF2,
|
||||
0xEE
|
||||
};
|
@ -0,0 +1,382 @@
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include "luts.h"
|
||||
|
||||
const float vibrato_lut[VIBRATO_LUT_LENGTH] =
|
||||
{
|
||||
1.0022336811487,
|
||||
1.0042529943610,
|
||||
1.0058584256028,
|
||||
1.0068905285205,
|
||||
1.0072464122237,
|
||||
1.0068905285205,
|
||||
1.0058584256028,
|
||||
1.0042529943610,
|
||||
1.0022336811487,
|
||||
1.0000000000000,
|
||||
0.9977712970630,
|
||||
0.9957650169978,
|
||||
0.9941756956510,
|
||||
0.9931566259436,
|
||||
0.9928057204913,
|
||||
0.9931566259436,
|
||||
0.9941756956510,
|
||||
0.9957650169978,
|
||||
0.9977712970630,
|
||||
1.0000000000000,
|
||||
};
|
||||
|
||||
const uint16_t frequency_lut[FREQUENCY_LUT_LENGTH] =
|
||||
{
|
||||
0x8E0B,
|
||||
0x8C02,
|
||||
0x8A00,
|
||||
0x8805,
|
||||
0x8612,
|
||||
0x8426,
|
||||
0x8241,
|
||||
0x8063,
|
||||
0x7E8C,
|
||||
0x7CBB,
|
||||
0x7AF2,
|
||||
0x792E,
|
||||
0x7772,
|
||||
0x75BB,
|
||||
0x740B,
|
||||
0x7261,
|
||||
0x70BD,
|
||||
0x6F20,
|
||||
0x6D88,
|
||||
0x6BF6,
|
||||
0x6A69,
|
||||
0x68E3,
|
||||
0x6762,
|
||||
0x65E6,
|
||||
0x6470,
|
||||
0x6300,
|
||||
0x6194,
|
||||
0x602E,
|
||||
0x5ECD,
|
||||
0x5D71,
|
||||
0x5C1A,
|
||||
0x5AC8,
|
||||
0x597B,
|
||||
0x5833,
|
||||
0x56EF,
|
||||
0x55B0,
|
||||
0x5475,
|
||||
0x533F,
|
||||
0x520E,
|
||||
0x50E1,
|
||||
0x4FB8,
|
||||
0x4E93,
|
||||
0x4D73,
|
||||
0x4C57,
|
||||
0x4B3E,
|
||||
0x4A2A,
|
||||
0x491A,
|
||||
0x480E,
|
||||
0x4705,
|
||||
0x4601,
|
||||
0x4500,
|
||||
0x4402,
|
||||
0x4309,
|
||||
0x4213,
|
||||
0x4120,
|
||||
0x4031,
|
||||
0x3F46,
|
||||
0x3E5D,
|
||||
0x3D79,
|
||||
0x3C97,
|
||||
0x3BB9,
|
||||
0x3ADD,
|
||||
0x3A05,
|
||||
0x3930,
|
||||
0x385E,
|
||||
0x3790,
|
||||
0x36C4,
|
||||
0x35FB,
|
||||
0x3534,
|
||||
0x3471,
|
||||
0x33B1,
|
||||
0x32F3,
|
||||
0x3238,
|
||||
0x3180,
|
||||
0x30CA,
|
||||
0x3017,
|
||||
0x2F66,
|
||||
0x2EB8,
|
||||
0x2E0D,
|
||||
0x2D64,
|
||||
0x2CBD,
|
||||
0x2C19,
|
||||
0x2B77,
|
||||
0x2AD8,
|
||||
0x2A3A,
|
||||
0x299F,
|
||||
0x2907,
|
||||
0x2870,
|
||||
0x27DC,
|
||||
0x2749,
|
||||
0x26B9,
|
||||
0x262B,
|
||||
0x259F,
|
||||
0x2515,
|
||||
0x248D,
|
||||
0x2407,
|
||||
0x2382,
|
||||
0x2300,
|
||||
0x2280,
|
||||
0x2201,
|
||||
0x2184,
|
||||
0x2109,
|
||||
0x2090,
|
||||
0x2018,
|
||||
0x1FA3,
|
||||
0x1F2E,
|
||||
0x1EBC,
|
||||
0x1E4B,
|
||||
0x1DDC,
|
||||
0x1D6E,
|
||||
0x1D02,
|
||||
0x1C98,
|
||||
0x1C2F,
|
||||
0x1BC8,
|
||||
0x1B62,
|
||||
0x1AFD,
|
||||
0x1A9A,
|
||||
0x1A38,
|
||||
0x19D8,
|
||||
0x1979,
|
||||
0x191C,
|
||||
0x18C0,
|
||||
0x1865,
|
||||
0x180B,
|
||||
0x17B3,
|
||||
0x175C,
|
||||
0x1706,
|
||||
0x16B2,
|
||||
0x165E,
|
||||
0x160C,
|
||||
0x15BB,
|
||||
0x156C,
|
||||
0x151D,
|
||||
0x14CF,
|
||||
0x1483,
|
||||
0x1438,
|
||||
0x13EE,
|
||||
0x13A4,
|
||||
0x135C,
|
||||
0x1315,
|
||||
0x12CF,
|
||||
0x128A,
|
||||
0x1246,
|
||||
0x1203,
|
||||
0x11C1,
|
||||
0x1180,
|
||||
0x1140,
|
||||
0x1100,
|
||||
0x10C2,
|
||||
0x1084,
|
||||
0x1048,
|
||||
0x100C,
|
||||
0xFD1,
|
||||
0xF97,
|
||||
0xF5E,
|
||||
0xF25,
|
||||
0xEEE,
|
||||
0xEB7,
|
||||
0xE81,
|
||||
0xE4C,
|
||||
0xE17,
|
||||
0xDE4,
|
||||
0xDB1,
|
||||
0xD7E,
|
||||
0xD4D,
|
||||
0xD1C,
|
||||
0xCEC,
|
||||
0xCBC,
|
||||
0xC8E,
|
||||
0xC60,
|
||||
0xC32,
|
||||
0xC05,
|
||||
0xBD9,
|
||||
0xBAE,
|
||||
0xB83,
|
||||
0xB59,
|
||||
0xB2F,
|
||||
0xB06,
|
||||
0xADD,
|
||||
0xAB6,
|
||||
0xA8E,
|
||||
0xA67,
|
||||
0xA41,
|
||||
0xA1C,
|
||||
0x9F7,
|
||||
0x9D2,
|
||||
0x9AE,
|
||||
0x98A,
|
||||
0x967,
|
||||
0x945,
|
||||
0x923,
|
||||
0x901,
|
||||
0x8E0,
|
||||
0x8C0,
|
||||
0x8A0,
|
||||
0x880,
|
||||
0x861,
|
||||
0x842,
|
||||
0x824,
|
||||
0x806,
|
||||
0x7E8,
|
||||
0x7CB,
|
||||
0x7AF,
|
||||
0x792,
|
||||
0x777,
|
||||
0x75B,
|
||||
0x740,
|
||||
0x726,
|
||||
0x70B,
|
||||
0x6F2,
|
||||
0x6D8,
|
||||
0x6BF,
|
||||
0x6A6,
|
||||
0x68E,
|
||||
0x676,
|
||||
0x65E,
|
||||
0x647,
|
||||
0x630,
|
||||
0x619,
|
||||
0x602,
|
||||
0x5EC,
|
||||
0x5D7,
|
||||
0x5C1,
|
||||
0x5AC,
|
||||
0x597,
|
||||
0x583,
|
||||
0x56E,
|
||||
0x55B,
|
||||
0x547,
|
||||
0x533,
|
||||
0x520,
|
||||
0x50E,
|
||||
0x4FB,
|
||||
0x4E9,
|
||||
0x4D7,
|
||||
0x4C5,
|
||||
0x4B3,
|
||||
0x4A2,
|
||||
0x491,
|
||||
0x480,
|
||||
0x470,
|
||||
0x460,
|
||||
0x450,
|
||||
0x440,
|
||||
0x430,
|
||||
0x421,
|
||||
0x412,
|
||||
0x403,
|
||||
0x3F4,
|
||||
0x3E5,
|
||||
0x3D7,
|
||||
0x3C9,
|
||||
0x3BB,
|
||||
0x3AD,
|
||||
0x3A0,
|
||||
0x393,
|
||||
0x385,
|
||||
0x379,
|
||||
0x36C,
|
||||
0x35F,
|
||||
0x353,
|
||||
0x347,
|
||||
0x33B,
|
||||
0x32F,
|
||||
0x323,
|
||||
0x318,
|
||||
0x30C,
|
||||
0x301,
|
||||
0x2F6,
|
||||
0x2EB,
|
||||
0x2E0,
|
||||
0x2D6,
|
||||
0x2CB,
|
||||
0x2C1,
|
||||
0x2B7,
|
||||
0x2AD,
|
||||
0x2A3,
|
||||
0x299,
|
||||
0x290,
|
||||
0x287,
|
||||
0x27D,
|
||||
0x274,
|
||||
0x26B,
|
||||
0x262,
|
||||
0x259,
|
||||
0x251,
|
||||
0x248,
|
||||
0x240,
|
||||
0x238,
|
||||
0x230,
|
||||
0x228,
|
||||
0x220,
|
||||
0x218,
|
||||
0x210,
|
||||
0x209,
|
||||
0x201,
|
||||
0x1FA,
|
||||
0x1F2,
|
||||
0x1EB,
|
||||
0x1E4,
|
||||
0x1DD,
|
||||
0x1D6,
|
||||
0x1D0,
|
||||
0x1C9,
|
||||
0x1C2,
|
||||
0x1BC,
|
||||
0x1B6,
|
||||
0x1AF,
|
||||
0x1A9,
|
||||
0x1A3,
|
||||
0x19D,
|
||||
0x197,
|
||||
0x191,
|
||||
0x18C,
|
||||
0x186,
|
||||
0x180,
|
||||
0x17B,
|
||||
0x175,
|
||||
0x170,
|
||||
0x16B,
|
||||
0x165,
|
||||
0x160,
|
||||
0x15B,
|
||||
0x156,
|
||||
0x151,
|
||||
0x14C,
|
||||
0x148,
|
||||
0x143,
|
||||
0x13E,
|
||||
0x13A,
|
||||
0x135,
|
||||
0x131,
|
||||
0x12C,
|
||||
0x128,
|
||||
0x124,
|
||||
0x120,
|
||||
0x11C,
|
||||
0x118,
|
||||
0x114,
|
||||
0x110,
|
||||
0x10C,
|
||||
0x108,
|
||||
0x104,
|
||||
0x100,
|
||||
0xFD,
|
||||
0xF9,
|
||||
0xF5,
|
||||
0xF2,
|
||||
0xEE,
|
||||
};
|
||||
|
@ -0,0 +1,15 @@
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#ifndef LUTS_H
|
||||
#define LUTS_H
|
||||
|
||||
#define VIBRATO_LUT_LENGTH 20
|
||||
|
||||
#define FREQUENCY_LUT_LENGTH 349
|
||||
|
||||
extern const float vibrato_lut[VIBRATO_LUT_LENGTH];
|
||||
extern const uint16_t frequency_lut[FREQUENCY_LUT_LENGTH];
|
||||
|
||||
#endif /* LUTS_H */
|
@ -1,28 +0,0 @@
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#define VIBRATO_LUT_LENGTH 20
|
||||
|
||||
const float VIBRATO_LUT[VIBRATO_LUT_LENGTH] = { \
|
||||
1.00223368114872,
|
||||
1.00425299436105,
|
||||
1.00585842560279,
|
||||
1.00689052852052,
|
||||
1.0072464122237,
|
||||
1.00689052852052,
|
||||
1.00585842560279,
|
||||
1.00425299436105,
|
||||
1.00223368114872,
|
||||
1,
|
||||
0.99777129706302,
|
||||
0.99576501699778,
|
||||
0.994175695650927,
|
||||
0.993156625943589,
|
||||
0.992805720491269,
|
||||
0.993156625943589,
|
||||
0.994175695650927,
|
||||
0.99576501699778,
|
||||
0.99777129706302,
|
||||
1
|
||||
};
|