1
0
Fork 0

Merge remote-tracking branch 'remotes/jackhumbert/master'

This commit is contained in:
IBNobody 2016-05-24 17:55:46 -05:00
commit 76e36a787a
124 changed files with 5899 additions and 2004 deletions

View file

@ -47,8 +47,8 @@ If you have any problems building the firmware, you can try using a tool called
Note: Some keyboard folders have non-standard organizations, and may not even support specifying alternate keymaps. Until these get reorganized, you will need to edit their default keymaps directly.
1. Running the `make` command from your keyboard's folder will generate a .hex file based on the default keymap. All keymaps for a particular keyboard live in the `keymaps` folder in that keyboard's folder. To create your own keymap, copy `keymaps/default/keymap.c` to the `keymaps` folder, and rename it with your name, for example jack.c. Or, if you don't care about the ability to share your keymap with the community via GitHub, you can just modify the default keymap itself. Details on how to program keymap files can be found in other guides.
2. To build a keymap other than the default, type `KEYMAP=<name>` after `make`. So if I've named my keymap jack.c, the full command would be `make KEYMAP=jack`.
1. Running the `make` command from your keyboard's folder will generate a .hex file based on the default keymap. All keymaps for a particular keyboard live in the `keymaps` folder in that keyboard's folder. To create your own keymap, duplicate the folder `keymaps/default`, and rename it with your name, for example `jack`. Or, if you don't care about the ability to share your keymap with the community via GitHub, you can just modify the default keymap itself. Details on how to program keymap files can be found in other guides.
2. To build a keymap other than the default, type `KEYMAP=<name>` after `make`. So if I've named my keymap `jack`, the full command would be `make KEYMAP=jack`.
3. How you deploy the firmware will depend on whether you are using a PCB or a Teensy. In both cases, you'll need to put the keyboard in bootloader mode, either by pressing a button on the PCB/Teensy or pressing the key with the `RESET` keycode. Then, if you're using a PCB, just run `make KEYMAP=<name> dfu` to both build and deploy the firmware. If you're using a Teensy, you'll probably need to take the <keyboardname>.hex file that make produces in the keyboard's folder, and deploy it using the [Teensy Loader.](https://www.pjrc.com/teensy/loader.html)
## Helpful Tips

View file

@ -2,7 +2,7 @@
This is a keyboard firmware based on the [tmk_keyboard firmware](http://github.com/tmk/tmk_keyboard) with some useful features for Atmel AVR controllers, and more specifically, the [OLKB product line](http://olkb.co), the [ErgoDox EZ](http://www.ergodox-ez.com) keyboard, and the [Clueboard product line](http://clueboard.co/).
QMK is developed and maintained by Jack Humbert of OLKB with contributions from the community, and of course, TMK.
QMK is developed and maintained by Jack Humbert of OLKB with contributions from the community, and of course, TMK. In fact, this repo used to be a fork of TMK, and we are incredibly grateful for his founding contributions to the firmware. We've had to break the fork due to purely technical reasons -- it simply became too different over time, and we've had to start refactoring some of the basic bits and pieces. We are huge fans of TMK, both the firmware and the person. :)
This documentation is edited and maintained by Erez Zukerman of ErgoDox EZ. If you spot any typos or inaccuracies, please [open an issue](https://github.com/jackhumbert/qmk_firmware/issues/new).
@ -33,6 +33,10 @@ If your keymap directory has a file called `makefile.mk` (note the lowercase fil
So let's say your keyboard's makefile has `CONSOLE_ENABLE = yes` (or maybe doesn't even list the `CONSOLE_ENABLE` option, which would cause it to revert to the global Quantum default). You want your particular keymap to not have the debug console, so you make a file called `makefile.mk` and specify `CONSOLE_ENABLE = no`.
### Customizing config.h on a per-keymap basis
If you use the ErgoDox EZ, you can make a `config_user.h` file in your keymap directory and use it to override any `config.h` settings you don't like. Anything you set there will take precedence over the global `config.h` for the ErgoDox EZ. To see an example of this, check out `keymaps/erez_experimental`.
## Quick aliases to common actions
Your keymap can include shortcuts to common operations (called "function actions" in tmk).
@ -41,10 +45,13 @@ Your keymap can include shortcuts to common operations (called "function actions
`MO(layer)` - momentary switch to *layer*. As soon as you let go of the key, the layer is deactivated and you pop back out to the previous layer. When you apply this to a key, that same key must be set as `KC_TRNS` on the destination layer. Otherwise, you won't make it back to the original layer when you release the key (and you'll get a keycode sent). You can only switch to layers *above* your current layer. If you're on layer 0 and you use `MO(1)`, that will switch to layer 1 just fine. But if you include `MO(3)` on layer 5, that won't do anything for you -- because layer 3 is lower than layer 5 on the stack.
`OSL(layer)` - momentary switch to *layer*, as a one-shot operation. So if you have a key that's defined as `OSL(1)`, and you tap that key, then only the very next keystroke would come from layer 1. You would drop back to layer zero immediately after that one keystroke. That's handy if you have a layer full of custom shortcuts -- for example, a dedicated key for closing a window. So you tap your one-shot layer mod, then tap that magic 'close window' key, and keep typing like a boss. Layer 1 would remain active as long as you hold that key down, too (so you can use it like a momentary toggle-layer key with extra powers).
`LT(layer, kc)` - momentary switch to *layer* when held, and *kc* when tapped. Like `MO()`, this only works upwards in the layer stack (`layer` must be higher than the current layer).
`TG(layer)` - toggles a layer on or off. As with `MO()`, you should set this key as `KC_TRNS` in the destination layer so that tapping it again actually toggles back to the original layer. Only works upwards in the layer stack.
### Fun with modifier keys
* `LSFT(kc)` - applies left Shift to *kc* (keycode) - `S(kc)` is an alias
@ -80,17 +87,24 @@ The following shortcuts automatically add `LSFT()` to keycodes to get commonly u
KC_PLUS +
KC_LCBR {
KC_RCBR }
KC_LABK <
KC_RABK >
KC_PIPE |
KC_COLN :
`OSM(mod)` - this is a "one shot" modifier. So let's say you have your left Shift key defined as `OSM(MOD_LSFT)`. Tap it, let go, and Shift is "on" -- but only for the next character you'll type. So to write "The", you don't need to hold down Shift -- you tap it, tap t, and move on with life. And if you hold down the left Shift key, it just works as a left Shift key, as you would expect (so you could type THE). There's also a magical, secret way to "lock" a modifier by tapping it multiple times. If you want to learn more about that, open an issue. :)
`MT(mod, kc)` - is *mod* (modifier key - MOD_LCTL, MOD_LSFT) when held, and *kc* when tapped. In other words, you can have a key that sends Esc (or the letter O or whatever) when you tap it, but works as a Control key or a Shift key when you hold it down.
These are the values you can use for the `mod` in `MT()` (right-hand modifiers are not available):
These are the values you can use for the `mod` in `MT()` and `OSM()` (right-hand modifiers are not available for `MT()`):
* MOD_LCTL
* MOD_LSFT
* MOD_LALT
* MOD_LGUI
* MOD_HYPR
* MOD_MEH
These can also be combined like `MOD_LCTL | MOD_LSFT` e.g. `MT(MOD_LCTL | MOD_LSFT, KC_ESC)` which would activate Control and Shift when held, and send Escape when tapped.
@ -363,6 +377,55 @@ You can currently send 4 hex digits with your OS-specific modifier key (RALT for
Enable the backlight from the Makefile.
## Driving a speaker - audio support
Your keyboard can make sounds! If you've got a Planck, Preonic, or basically any keyboard that allows access to the C6 port, you can hook up a simple speaker and have it beep. You can use those beeps to indicate layer transitions, modifiers, special keys, or just to play some funky 8bit tunes.
The audio code lives in [quantum/audio/audio.h](/quantum/audio/audio.h) and in the other files in the audio directory. It's enabled by default on the Planck [stock keymap](/keyboard/planck/keymaps/default/keymap.c). Here are the important bits:
```
#include "audio.h"
```
Then, lower down the file:
```
float tone_startup[][2] = {
ED_NOTE(_E7 ),
E__NOTE(_CS7),
E__NOTE(_E6 ),
E__NOTE(_A6 ),
M__NOTE(_CS7, 20)
};
```
This is how you write a song. Each of these lines is a note, so we have a little ditty composed of five notes here.
Then, we have this chunk:
```
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);
```
Wherein we bind predefined songs (from [audio/song_list.h](/audio/song_list.h)) into named variables. This is one optimization that helps save on memory: These songs only take up memory when you reference them in your keymap, because they're essentially all preprocessor directives.
So now you have something called `tone_plover` for example. How do you make it play the Plover tune, then? If you look further down the keymap, you'll see this:
```
PLAY_NOTE_ARRAY(tone_plover, false, 0); // Signature is: Song name, repeat, rest style
```
This is inside one of the macros. So when that macro executes, your keyboard plays that particular chime.
"Rest style" in the method signature above (the last parameter) specifies if there's a rest (a moment of silence) between the notes.
## MIDI functionalty
This is still a WIP, but check out `quantum/keymap_midi.c` to see what's happening. Enable from the Makefile.

View file

@ -2,27 +2,28 @@
__attribute__ ((weak))
void matrix_init_user(void) {
// leave this function blank - it can be defined in a keymap file
// leave this function blank - it can be defined in a keymap file
};
__attribute__ ((weak))
void matrix_scan_user(void) {
// leave this function blank - it can be defined in a keymap file
// leave this function blank - it can be defined in a keymap file
}
__attribute__ ((weak))
void process_action_user(keyrecord_t *record) {
// leave this function blank - it can be defined in a keymap file
bool process_action_user(keyrecord_t *record) {
// leave this function blank - it can be defined in a keymap file
return true;
}
__attribute__ ((weak))
void led_set_user(uint8_t usb_led) {
// leave this function blank - it can be defined in a keymap file
// leave this function blank - it can be defined in a keymap file
}
void matrix_init_kb(void) {
// put your keyboard start-up code here
// runs once when the firmware starts up
// put your keyboard start-up code here
// runs once when the firmware starts up
MCUCR |= (1<<JTD);
MCUCR |= (1<<JTD);
@ -35,31 +36,39 @@ void matrix_init_kb(void) {
DDRE |= (1<<6);
PORTE |= (1<<6);
matrix_init_user();
matrix_init_user();
}
void matrix_scan_kb(void) {
// put your looping keyboard code here
// runs every cycle (a lot)
// put your looping keyboard code here
// runs every cycle (a lot)
matrix_scan_user();
matrix_scan_user();
}
void process_action_kb(keyrecord_t *record) {
// put your per-action keyboard code here
// runs for every action, just before processing by the firmware
bool process_action_kb(keyrecord_t *record) {
// put your per-action keyboard code here
// runs for every action, just before processing by the firmware
process_action_user(record);
return process_action_user(record);
}
void led_set_kb(uint8_t usb_led) {
// put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
// put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
led_set_user(usb_led);
led_set_user(usb_led);
}
#ifdef BACKLIGHT_ENABLE
#define CHANNEL OCR1C
#define BREATHING_NO_HALT 0
#define BREATHING_HALT_OFF 1
#define BREATHING_HALT_ON 2
static uint8_t breath_intensity;
static uint8_t breath_speed;
static uint16_t breathing_index;
static uint8_t breathing_halt;
void backlight_init_ports()
{
@ -67,54 +76,250 @@ void backlight_init_ports()
// Setup PB7 as output and output low.
DDRB |= (1<<7);
PORTB &= ~(1<<7);
// Use full 16-bit resolution.
// Use full 16-bit resolution.
ICR1 = 0xFFFF;
// I could write a wall of text here to explain... but TL;DW
// Go read the ATmega32u4 datasheet.
// And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on
// Pin PB7 = OCR1C (Timer 1, Channel C)
// Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0
// (i.e. start high, go low when counter matches.)
// WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0
// Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1
TCCR1A = _BV(COM1C1) | _BV(WGM11); // = 0b00001010;
TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;
backlight_init();
breathing_defaults();
}
void backlight_set(uint8_t level)
{
// Prevent backlight blink on lowest level
PORTB &= ~(_BV(PORTB7));
if ( level == 0 )
{
// Turn off PWM control on PB7, revert to output low.
TCCR1A &= ~(_BV(COM1C1));
// Set the brightness to 0
CHANNEL = 0x0;
// Prevent backlight blink on lowest level
PORTB &= ~(_BV(PORTB7));
}
else if ( level == BACKLIGHT_LEVELS )
else if ( level >= BACKLIGHT_LEVELS )
{
// Prevent backlight blink on lowest level
PORTB &= ~(_BV(PORTB7));
// Turn on PWM control of PB7
TCCR1A |= _BV(COM1C1);
// Set the brightness
// Set the brightness to max
CHANNEL = 0xFFFF;
}
else
else
{
// Prevent backlight blink on lowest level
PORTB &= ~(_BV(PORTB7));
// Turn on PWM control of PB7
TCCR1A |= _BV(COM1C1);
// Set the brightness
CHANNEL = 0xFFFF >> ((BACKLIGHT_LEVELS - level) * ((BACKLIGHT_LEVELS + 1) / 2));
}
breathing_intensity_default();
}
void breathing_enable(void)
{
if (get_backlight_level() == 0)
{
breathing_index = 0;
}
else
{
// Set breathing_index to be at the midpoint (brightest point)
breathing_index = 0x20 << breath_speed;
}
breathing_halt = BREATHING_NO_HALT;
// Enable breathing interrupt
TIMSK1 |= _BV(OCIE1A);
}
void breathing_pulse(void)
{
if (get_backlight_level() == 0)
{
breathing_index = 0;
}
else
{
// Set breathing_index to be at the midpoint + 1 (brightest point)
breathing_index = 0x21 << breath_speed;
}
breathing_halt = BREATHING_HALT_ON;
// Enable breathing interrupt
TIMSK1 |= _BV(OCIE1A);
}
void breathing_disable(void)
{
// Disable breathing interrupt
TIMSK1 &= ~_BV(OCIE1A);
backlight_set(get_backlight_level());
}
void breathing_self_disable(void)
{
if (get_backlight_level() == 0)
{
breathing_halt = BREATHING_HALT_OFF;
}
else
{
breathing_halt = BREATHING_HALT_ON;
}
//backlight_set(get_backlight_level());
}
void breathing_toggle(void)
{
if (!is_breathing())
{
if (get_backlight_level() == 0)
{
breathing_index = 0;
}
else
{
// Set breathing_index to be at the midpoint + 1 (brightest point)
breathing_index = 0x21 << breath_speed;
}
breathing_halt = BREATHING_NO_HALT;
}
// Toggle breathing interrupt
TIMSK1 ^= _BV(OCIE1A);
// Restore backlight level
if (!is_breathing())
{
backlight_set(get_backlight_level());
}
}
bool is_breathing(void)
{
return (TIMSK1 && _BV(OCIE1A));
}
void breathing_intensity_default(void)
{
//breath_intensity = (uint8_t)((uint16_t)100 * (uint16_t)get_backlight_level() / (uint16_t)BACKLIGHT_LEVELS);
breath_intensity = ((BACKLIGHT_LEVELS - get_backlight_level()) * ((BACKLIGHT_LEVELS + 1) / 2));
}
void breathing_intensity_set(uint8_t value)
{
breath_intensity = value;
}
void breathing_speed_default(void)
{
breath_speed = 4;
}
void breathing_speed_set(uint8_t value)
{
bool is_breathing_now = is_breathing();
uint8_t old_breath_speed = breath_speed;
if (is_breathing_now)
{
// Disable breathing interrupt
TIMSK1 &= ~_BV(OCIE1A);
}
breath_speed = value;
if (is_breathing_now)
{
// Adjust index to account for new speed
breathing_index = (( (uint8_t)( (breathing_index) >> old_breath_speed ) ) & 0x3F) << breath_speed;
// Enable breathing interrupt
TIMSK1 |= _BV(OCIE1A);
}
}
void breathing_speed_inc(uint8_t value)
{
if ((uint16_t)(breath_speed - value) > 10 )
{
breathing_speed_set(0);
}
else
{
breathing_speed_set(breath_speed - value);
}
}
void breathing_speed_dec(uint8_t value)
{
if ((uint16_t)(breath_speed + value) > 10 )
{
breathing_speed_set(10);
}
else
{
breathing_speed_set(breath_speed + value);
}
}
void breathing_defaults(void)
{
breathing_intensity_default();
breathing_speed_default();
breathing_halt = BREATHING_NO_HALT;
}
/* Breathing Sleep LED brighness(PWM On period) table
* (64[steps] * 4[duration]) / 64[PWM periods/s] = 4 second breath cycle
*
* http://www.wolframalpha.com/input/?i=%28sin%28+x%2F64*pi%29**8+*+255%2C+x%3D0+to+63
* (0..63).each {|x| p ((sin(x/64.0*PI)**8)*255).to_i }
*/
static const uint8_t breathing_table[64] PROGMEM = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 6, 10,
15, 23, 32, 44, 58, 74, 93, 113, 135, 157, 179, 199, 218, 233, 245, 252,
255, 252, 245, 233, 218, 199, 179, 157, 135, 113, 93, 74, 58, 44, 32, 23,
15, 10, 6, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
ISR(TIMER1_COMPA_vect)
{
// CHANNEL = (pgm_read_byte(&breathing_table[ ( (uint8_t)( (breathing_index++) >> breath_speed ) ) & 0x3F ] )) * breath_intensity;
uint8_t local_index = ( (uint8_t)( (breathing_index++) >> breath_speed ) ) & 0x3F;
if (((breathing_halt == BREATHING_HALT_ON) && (local_index == 0x20)) || ((breathing_halt == BREATHING_HALT_OFF) && (local_index == 0x3F)))
{
// Disable breathing interrupt
TIMSK1 &= ~_BV(OCIE1A);
}
CHANNEL = (uint16_t)(((uint16_t)pgm_read_byte(&breathing_table[local_index]) * 257)) >> breath_intensity;
}
#endif

View file

@ -1,11 +1,7 @@
#ifndef ATOMIC_H
#define ATOMIC_H
#include "matrix.h"
#include "keymap_common.h"
#ifdef BACKLIGHT_ENABLE
#include "backlight.h"
#endif
#include "quantum.h"
#include <stddef.h>
#include <avr/io.h>
@ -29,8 +25,24 @@
void matrix_init_user(void);
void matrix_scan_user(void);
void process_action_user(keyrecord_t *record);
bool process_action_user(keyrecord_t *record);
void led_set_user(uint8_t usb_led);
void backlight_init_ports(void);
void breathing_enable(void);
void breathing_pulse(void);
void breathing_disable(void);
void breathing_self_disable(void);
void breathing_toggle(void);
bool is_breathing(void);
void breathing_defaults(void);
void breathing_intensity_default(void);
void breathing_speed_default(void);
void breathing_speed_set(uint8_t value);
void breathing_speed_inc(uint8_t value);
void breathing_speed_dec(uint8_t value);
#endif

View file

@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* USB Device descriptor parameter */
#define VENDOR_ID 0xFEED
#define PRODUCT_ID 0x6060
#define PRODUCT_ID 0x0419
#define DEVICE_VER 0x0001
#define MANUFACTURER Ortholinear Keyboards
#define PRODUCT The Atomic Keyboard
@ -158,4 +158,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//#define NO_ACTION_MACRO
//#define NO_ACTION_FUNCTION
//#define VIBRATO_ENABLE
//#define VIBRATO_STRENGTH_ENABLE
#endif

View file

@ -8,42 +8,44 @@
#include "song_list.h"
#endif
#define LAYER_QWERTY 0
#define LAYER_COLEMAK 1
#define LAYER_DVORAK 2
#define LAYER_LOWER 3
#define LAYER_RAISE 4
#define LAYER_FUNCTION 5
#define LAYER_MOUSE 6
#define LAYER_MUSIC 7
#define LAYER_ADJUST 8
#define LAYER_QWERTY 0
#define LAYER_COLEMAK 1
#define LAYER_DVORAK 2
#define LAYER_UPPER 3
#define LAYER_LOWER 4
#define LAYER_FUNCTION 5
#define LAYER_MOUSE 6
#define LAYER_ADJUST 7
#define MACRO_QWERTY 0
#define MACRO_COLEMAK 1
#define MACRO_DVORAK 2
#define MACRO_LOWER 3
#define MACRO_RAISE 4
#define MACRO_FUNCTION 5
#define MACRO_MOUSE 6
#define MACRO_TIMBRE_1 7
#define MACRO_TIMBRE_2 8
#define MACRO_TIMBRE_3 9
#define MACRO_TIMBRE_4 10
#define MACRO_TEMPO_U 11
#define MACRO_TEMPO_D 12
#define MACRO_TONE_DEFAULT 13
#define MACRO_MUSIC_ON 14
#define MACRO_MUSIC_OFF 15
#define MACRO_AUDIO_ON 16
#define MACRO_AUDIO_OFF 17
#define MACRO_INC_VOICE 18
#define MACRO_DEC_VOICE 19
#define MACRO_QWERTY 0
#define MACRO_COLEMAK 1
#define MACRO_DVORAK 2
#define MACRO_UPPER 3
#define MACRO_LOWER 4
#define MACRO_FUNCTION 5
#define MACRO_MOUSE 6
#define MACRO_TIMBRE_1 7
#define MACRO_TIMBRE_2 8
#define MACRO_TIMBRE_3 9
#define MACRO_TIMBRE_4 10
#define MACRO_TEMPO_U 11
#define MACRO_TEMPO_D 12
#define MACRO_TONE_DEFAULT 13
#define MACRO_MUSIC_TOGGLE 14
#define MACRO_AUDIO_TOGGLE 16
#define MACRO_INC_VOICE 18
#define MACRO_DEC_VOICE 19
#define MACRO_BACKLIGHT 20
#define MACRO_BREATH_TOGGLE 21
#define MACRO_BREATH_SPEED_INC 23
#define MACRO_BREATH_SPEED_DEC 24
#define MACRO_BREATH_DEFAULT 25
#define M_QWRTY M(MACRO_QWERTY)
#define M_COLMK M(MACRO_COLEMAK)
#define M_DVORK M(MACRO_DVORAK)
#define M_UPPER M(MACRO_UPPER)
#define M_LOWER M(MACRO_LOWER)
#define M_RAISE M(MACRO_RAISE)
#define M_FUNCT M(MACRO_FUNCTION)
#define M_MOUSE M(MACRO_MOUSE)
#define TIMBR_1 M(MACRO_TIMBRE_1)
@ -53,12 +55,15 @@
#define TMPO_UP M(MACRO_TEMPO_U)
#define TMPO_DN M(MACRO_TEMPO_D)
#define TMPO_DF M(MACRO_TONE_DEFAULT)
#define M_BACKL M(MACRO_BACKLIGHT)
#define M_BRTOG M(MACRO_BREATH_TOGGLE)
#define M_BSPDU M(MACRO_BREATH_SPEED_INC)
#define M_BSPDD M(MACRO_BREATH_SPEED_DEC)
#define M_BDFLT M(MACRO_BREATH_DEFAULT)
#define MUS_ON M(MACRO_MUSIC_ON)
#define MUS_OFF M(MACRO_MUSIC_OFF)
#define AUD_OFF M(MACRO_AUDIO_OFF)
#define AUD_ON M(MACRO_AUDIO_ON)
//#define MU_TOG M(MACRO_MUSIC_TOGGLE)
//#define AU_TOG M(MACRO_AUDIO_TOGGLE)
#define VC_UP M(MACRO_INC_VOICE)
#define VC_DOWN M(MACRO_DEC_VOICE)
@ -74,6 +79,7 @@
#define SC_ACLS LALT(KC_F4)
#define SC_CCLS LCTL(KC_F4)
#define OS_SHFT KC_FN0
#define _______ KC_TRNS
#define XXXXXXX KC_NO
@ -92,16 +98,16 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+- 2u ---------------------+--------|
* | LSHIFT | Z | X | C | V | B | N | M | , | . | / | XXXXXX . RSHIFT | UP | PG DN |
* |--------+--------+--------+--------+--------+- 2u ------------+--------+--------+--------+--------+-----------------+--------+--------|
* | LCTRL | LWIN | FN | LALT | RAISE | XXXXXX . SPACE | LOWER | RALT | RWIN | MENU | RCTRL | LEFT | DOWN | RIGHT |
* | LCTRL | LWIN | FN | LALT | UPPER | XXXXXX . SPACE | LOWER | SHIFT | RALT | APP | RCTRL | LEFT | DOWN | RIGHT |
* '--------------------------------------------------------------------------------------------------------------------------------------'
*/
[LAYER_QWERTY] = { /* QWERTY */
[LAYER_QWERTY] = { // QWERTY
{ KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_BSPC },
{ KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_DEL },
{ KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_ENT, KC_PGUP },
{ KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_RSFT, KC_UP, KC_PGDN },
{ KC_LCTL, KC_LGUI, M_FUNCT, KC_LALT, M_RAISE, KC_SPC, KC_SPC, M_LOWER, KC_RALT, KC_RGUI, KC_MENU, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT },
{ KC_LCTL, KC_LGUI, M_FUNCT, KC_LALT, M_UPPER, KC_SPC, KC_SPC, M_LOWER, OS_SHFT, KC_RALT, KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT },
},
/* COLEMAK
@ -114,17 +120,17 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+- 2u ---------------------+--------|
* | LSHIFT | Z | X | C | V | B | K | M | , | . | / | XXXXXX . RSHIFT | UP | PG DN |
* |--------+--------+--------+--------+--------+- 2u ------------+--------+--------+--------+--------+-----------------+--------+--------|
* | LCTRL | LWIN | FN | LALT | RAISE | XXXXXX . SPACE | LOWER | RALT | RWIN | MENU | RCTRL | LEFT | DOWN | RIGHT |
* | LCTRL | LWIN | FN | LALT | UPPER | XXXXXX . SPACE | LOWER | SHIFT | RALT | APP | RCTRL | LEFT | DOWN | RIGHT |
* '--------------------------------------------------------------------------------------------------------------------------------------'
*/
[LAYER_COLEMAK] = { /* COLEMAK */
[LAYER_COLEMAK] = { // COLEMAK
{ KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_BSPC },
{ KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_LBRC, KC_RBRC, KC_BSLS, KC_DEL },
{ KC_BSPC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT, KC_ENT, KC_ENT, KC_PGUP },
{ KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_RSFT, KC_UP, KC_PGDN },
{ KC_LCTL, KC_LGUI, M_FUNCT, KC_LALT, M_RAISE, KC_SPC, KC_SPC, M_LOWER, KC_RALT, KC_RGUI, KC_MENU, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT },
},
{ KC_LCTL, KC_LGUI, M_FUNCT, KC_LALT, M_UPPER, KC_SPC, KC_SPC, M_LOWER, OS_SHFT, KC_RALT, KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT },
},
/* DVORAK
* .---------------------------------------------------------------------------------------------------------------------- 2u ------------.
@ -136,36 +142,63 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+- 2u ---------------------+--------|
* | LSHIFT | ; | Q | J | K | X | B | M | W | V | Z | XXXXXX . RSHIFT | UP | PG DN |
* |--------+--------+--------+--------+--------+- 2u ------------+--------+--------+--------+--------+-----------------+--------+--------|
* | LCTRL | LWIN | FN | LALT | RAISE | XXXXXX . SPACE | LOWER | RALT | RWIN | MENU | RCTRL | LEFT | DOWN | RIGHT |
* | LCTRL | LWIN | FN | LALT | UPPER | XXXXXX . SPACE | LOWER | SHIFT | RALT | APP | RCTRL | LEFT | DOWN | RIGHT |
* '--------------------------------------------------------------------------------------------------------------------------------------'
*/
[LAYER_DVORAK] = { /* DVORAK */
[LAYER_DVORAK] = { // DVORAK
{ KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_LBRC, KC_RBRC, KC_BSPC, KC_BSPC },
{ KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_SLSH, KC_EQL, KC_BSLS, KC_DEL },
{ KC_CAPS, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_MINS, KC_ENT, KC_ENT, KC_PGUP },
{ KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_RSFT, KC_RSFT, KC_UP, KC_PGDN },
{ KC_LCTL, KC_LGUI, M_FUNCT, KC_LALT, M_RAISE, KC_SPC, KC_SPC, M_LOWER, KC_RALT, KC_RGUI, KC_MENU, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT },
{ KC_LCTL, KC_LGUI, M_FUNCT, KC_LALT, M_UPPER, KC_SPC, KC_SPC, M_LOWER, OS_SHFT, KC_RALT, KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT },
},
/* UPPER
* .---------------------------------------------------------------------------------------------------------------------- 2u ------------.
* | PRINT | XXXXXX | XXXXXX | XXXXXX | XXXXXX | XXXXXX | XXXXXX | NUM LK | / | * | - | NUM LK | SCR LK | XXXXXX . PAUSE |
* |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+-----------------|
* | | F1 | F2 | F3 | F4 | | | 7 | 8 | 9 | + | ~ | | | INS |
* |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+- 2u ------------+--------|
* | CAP LK | F5 | F6 | F7 | F8 | | | 4 | 5 | 6 | + | ` | XXXXXX . | HOME |
* |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+- 2u ---------------------+--------|
* | | F9 | F10 | F11 | F12 | | | 1 | 2 | 3 | ENTER | XXXXXX . | | END |
* |--------+--------+--------+--------+--------+- 2u ------------+--------+--------+--------+--------+-----------------+--------+--------|
* | | | | | | 0 | | RALT | . | ENTER | | | | |
* '--------------------------------------------------------------------------------------------------------------------------------------'
*/
[LAYER_LOWER] = { /* LOWERED */
{ KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, ________________ },
{ _______, _______, _______, _______, SC_CCLS, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_INS },
{ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ________________, KC_HOME },
{ _______, SC_REDO, _______, _______, _______, _______, _______, _______, _______, _______, _______, ________________, _______, KC_END },
{ _______, _______, _______, _______, _______, KC_BSPC, KC_BSPC, _______, _______, _______, _______, _______, _______, _______, _______ },
[LAYER_UPPER] = { // UPPER
{ KC_PSCR, M_BRTOG, M_BSPDU, M_BSPDD, M_BDFLT, XXXXXXX, XXXXXXX, KC_NLCK, KC_PSLS, KC_PAST, XXXXXXX, XXXXXXX, KC_SLCK, KC_PAUS, KC_PAUS },
{ _______, KC_F1, KC_F2, KC_F3, KC_F4, XXXXXXX, XXXXXXX, KC_KP_7, KC_KP_8, KC_KP_9, KC_PMNS, _______, _______, _______, KC_INS },
{ KC_CAPS, KC_F5, KC_F6, KC_F7, KC_F8, XXXXXXX, XXXXXXX, KC_KP_4, KC_KP_5, KC_KP_6, KC_PPLS, _______, ________________, KC_HOME },
{ _______, KC_F9, KC_F10, KC_F11, KC_F12, XXXXXXX, XXXXXXX, KC_KP_1, KC_KP_2, KC_KP_3, KC_PENT, ________________, _______, KC_END },
{ _______, _______, _______, _______, _______, KC_KP_0, KC_KP_0, _______, KC_RALT, KC_PDOT, KC_PENT, _______, _______, _______, _______ },
},
[LAYER_RAISE] = { /* RAISED */
{ KC_TILD, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, ________________ },
{ _______, _______, _______, _______, SC_ACLS, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_INS },
{ _______, SC_SELA, SC_SAVE, _______, _______, _______, _______, _______, _______, _______, _______, _______, ________________, KC_HOME },
{ _______, SC_UNDO, SC_CUT, SC_COPY, SC_PSTE, _______, _______, _______, _______, _______, _______, ________________, _______, KC_END },
/* LOWER
* .---------------------------------------------------------------------------------------------------------------------- 2u ------------.
* | | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | XXXXXX . BACKSP |
* |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+-----------------|
* | | $ | { | [ | ( | % | # | ) | ] | } | @ | | | | INS |
* |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+- 2u ------------+--------|
* | | ^ | * | + | - | ; | : | _ | ' | " | ` | | XXXXXX . | HOME |
* |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+- 2u ---------------------+--------|
* | | | | & | ! | ~ | / | \ | = | < | > | ? | XXXXXX . | | END |
* |--------+--------+--------+--------+--------+- 2u ------------+--------+--------+--------+--------+-----------------+--------+--------|
* | | | | | | | | | | | | | | |
* '--------------------------------------------------------------------------------------------------------------------------------------'
*/
[LAYER_LOWER] = { // LOWER
{ _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, ________________ },
{ _______, KC_DLR, KC_LCBR, KC_LBRC, KC_LPRN, KC_PERC, KC_HASH, KC_RPRN, KC_RBRC, KC_RCBR, KC_AT, _______, _______, _______, KC_INS },
{ _______, KC_CIRC, KC_ASTR, KC_PPLS, KC_PMNS, KC_SCLN, KC_COLN, KC_UNDS, KC_QUOT, KC_DQT, KC_GRV, _______, ________________, KC_HOME },
{ _______, KC_PIPE, KC_AMPR, KC_EXLM, KC_TILD, KC_SLSH, KC_BSLS, KC_EQL, KC_LT, KC_GT, KC_QUES, ________________, _______, KC_END },
{ _______, _______, _______, _______, _______, ________________, _______, _______, _______, _______, _______, _______, _______, _______ },
},
[LAYER_FUNCTION] = { /* FUNCTION */
[LAYER_FUNCTION] = { // FUNCTION
{ KC_NLCK, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, ________________ },
{ KC_SLCK, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, KC_F21, KC_F22, KC_F23, KC_F24, _______, KC_PAUS },
{ KC_CAPS, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ________________, KC_PSCR },
@ -175,7 +208,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
#ifdef MOUSEKEY_ENABLE
[LAYER_MOUSE] = { /* MOUSE */
[LAYER_MOUSE] = { // MOUSE
{ _______, KC_ACL0, KC_ACL1, KC_ACL2, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXXXXXXXXXXX },
{ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX },
{ XXXXXXX, KC_BTN5, KC_BTN4, KC_BTN3, KC_BTN2, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXXXXXXXXXXX, KC_WH_U },
@ -185,25 +218,17 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
#endif
[LAYER_MUSIC] = { /* MUSIC */
{ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX },
{ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX },
{ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX },
{ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX },
{ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, M_RAISE, XXXXXXX, XXXXXXX, M_LOWER, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX },
},
[LAYER_ADJUST] = { /* ADJUST */
{ _______, TIMBR_1, TIMBR_2, TIMBR_3, TIMBR_4, TMPO_UP, TMPO_DN, TMPO_DF, _______, MUS_ON, MUS_OFF, AUD_ON, AUD_OFF, ________________ },
[LAYER_ADJUST] = { // ADJUST
{ _______, TIMBR_1, TIMBR_2, TIMBR_3, TIMBR_4, TMPO_UP, TMPO_DN, TMPO_DF, _______, _______, _______, MU_TOG, AU_TOG, ________________ },
{ _______, M_QWRTY, M_COLMK, M_DVORK, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ },
{ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ________________, _______ },
{ _______, _______, _______, _______, _______, RESET, _______, M_MOUSE, _______, _______, _______, ________________, VC_UP, _______ },
{ _______, _______, _______, _______, _______, ________________, _______, _______, _______, _______, _______, _______, VC_DOWN, _______ },
{ _______, _______, _______, _______, M_BACKL, RESET, _______, M_MOUSE, _______, _______, _______, ________________, MUV_IN, _______ },
{ _______, _______, _______, _______, _______, ________________, _______, _______, _______, _______, _______, _______, MUV_DE, _______ },
},
/*
[LAYER_EMPTY] = {
[LAYER_EMPTY] = { // LAYER
{ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ________________ },
{ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ },
{ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ________________, _______ },
@ -225,13 +250,14 @@ float tone_colemak[][2] = SONG(COLEMAK_SOUND);
float tone_audio_on[][2] = SONG(CLOSE_ENCOUNTERS_5_NOTE);
float tone_music_on[][2] = SONG(DOE_A_DEER);
float music_scale[][2] = SONG(MUSIC_SCALE_SOUND);
float tone_caps_on[][2] = SONG(CAPS_LOCK_ON_SOUND);
float tone_caps_off[][2] = SONG(CAPS_LOCK_OFF_SOUND);
float tone_numlk_on[][2] = SONG(NUM_LOCK_ON_SOUND);
float tone_numlk_off[][2] = SONG(NUM_LOCK_OFF_SOUND);
float tone_scroll_on[][2] = SONG(SCROLL_LOCK_ON_SOUND);
float tone_scroll_off[][2] = SONG(SCROLL_LOCK_OFF_SOUND);
float music_scale[][2] = SONG(MUSIC_SCALE_SOUND);
#endif /* AUDIO_ENABLE */
@ -242,6 +268,7 @@ void persistant_default_layer_set(uint16_t default_layer)
}
const uint16_t PROGMEM fn_actions[] = {
[0] = ACTION_MODS_ONESHOT(MOD_LSFT),
};
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
@ -251,13 +278,41 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
switch(id)
{
case MACRO_BREATH_TOGGLE:
if (record->event.pressed)
{
breathing_toggle();
}
break;
case MACRO_BREATH_SPEED_INC:
if (record->event.pressed)
{
breathing_speed_inc(1);
}
break;
case MACRO_BREATH_SPEED_DEC:
if (record->event.pressed)
{
breathing_speed_dec(1);
}
break;
case MACRO_BREATH_DEFAULT:
if (record->event.pressed)
{
breathing_defaults();
}
break;
case MACRO_QWERTY:
if (record->event.pressed)
{
persistant_default_layer_set(1UL<<LAYER_QWERTY);
#ifdef AUDIO_ENABLE
PLAY_NOTE_ARRAY(tone_qwerty, false, STACCATO);
#endif /* AUDIO_ENABLE */
#ifdef AUDIO_ENABLE
PLAY_NOTE_ARRAY(tone_qwerty, false, STACCATO);
#endif /* AUDIO_ENABLE */
}
break;
@ -265,9 +320,9 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
if (record->event.pressed)
{
persistant_default_layer_set(1UL<<LAYER_COLEMAK);
#ifdef AUDIO_ENABLE
PLAY_NOTE_ARRAY(tone_colemak, false, STACCATO);
#endif /* AUDIO_ENABLE */
#ifdef AUDIO_ENABLE
PLAY_NOTE_ARRAY(tone_colemak, false, STACCATO);
#endif /* AUDIO_ENABLE */
}
break;
@ -275,9 +330,24 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
if (record->event.pressed)
{
persistant_default_layer_set(1UL<<LAYER_DVORAK);
#ifdef AUDIO_ENABLE
PLAY_NOTE_ARRAY(tone_dvorak, false, STACCATO);
#endif /* AUDIO_ENABLE */
#ifdef AUDIO_ENABLE
PLAY_NOTE_ARRAY(tone_dvorak, false, STACCATO);
#endif /* AUDIO_ENABLE */
}
break;
case MACRO_UPPER:
if (record->event.pressed)
{
layer_on(LAYER_UPPER);
breathing_speed_set(2);
breathing_pulse();
update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST);
}
else
{
layer_off(LAYER_UPPER);
update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST);
}
break;
@ -285,35 +355,28 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
if (record->event.pressed)
{
layer_on(LAYER_LOWER);
update_tri_layer(LAYER_LOWER, LAYER_RAISE, LAYER_ADJUST);
breathing_speed_set(2);
breathing_pulse();
update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST);
}
else
{
layer_off(LAYER_LOWER);
update_tri_layer(LAYER_LOWER, LAYER_RAISE, LAYER_ADJUST);
}
break;
case MACRO_RAISE:
if (record->event.pressed)
{
layer_on(LAYER_RAISE);
update_tri_layer(LAYER_LOWER, LAYER_RAISE, LAYER_ADJUST);
}
else
{
layer_off(LAYER_RAISE);
update_tri_layer(LAYER_LOWER, LAYER_RAISE, LAYER_ADJUST);
update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST);
}
break;
case MACRO_FUNCTION:
if (record->event.pressed)
{
breathing_speed_set(3);
breathing_enable();
layer_on(LAYER_FUNCTION);
}
else
{
breathing_speed_set(1);
breathing_self_disable();
layer_off(LAYER_FUNCTION);
}
break;
@ -363,45 +426,37 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
}
break;
case MACRO_AUDIO_OFF:
/*
case MACRO_AUDIO_TOGGLE:
if (record->event.pressed)
{
#ifdef AUDIO_ENABLE
audio_off();
#endif
if (is_audio_on())
{
audio_off();
}
else
{
audio_on();
PLAY_NOTE_ARRAY(tone_audio_on, false, STACCATO);
}
}
break;
case MACRO_AUDIO_ON:
case MACRO_MUSIC_TOGGLE:
if (record->event.pressed)
{
#ifdef AUDIO_ENABLE
audio_on();
PLAY_NOTE_ARRAY(tone_audio_on, false, STACCATO);
#endif
}
break;
case MACRO_MUSIC_ON:
if (record->event.pressed)
{
#ifdef AUDIO_ENABLE
if (IS_LAYER_ON(LAYER_MUSIC))
{
layer_off(LAYER_MUSIC);
stop_all_notes();
}
else
{
PLAY_NOTE_ARRAY(tone_music_on, false, STACCATO);
layer_on(LAYER_MUSIC);
#endif
}
}
break;
case MACRO_MUSIC_OFF:
if (record->event.pressed)
{
#ifdef AUDIO_ENABLE
layer_off(LAYER_MUSIC);
stop_all_notes();
#endif
}
break;
case MACRO_INC_VOICE:
if (record->event.pressed)
{
@ -421,9 +476,18 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
#endif
}
break;
*/
#endif /* AUDIO_ENABLE */
#ifdef BACKLIGHT_ENABLE
case MACRO_BACKLIGHT:
if (record->event.pressed)
{
backlight_step();
}
#endif
default:
break;
@ -434,8 +498,8 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
#ifdef AUDIO_ENABLE
void process_action_user(keyrecord_t *record)
/*
bool process_action_user(keyrecord_t *record)
{
uint8_t starting_note = 0x0C;
@ -453,7 +517,7 @@ void process_action_user(keyrecord_t *record)
}
}
}
*/
void matrix_init_user(void)
{
@ -468,36 +532,40 @@ void led_set_user(uint8_t usb_led)
_delay_ms(10); // gets rid of tick
if ((usb_led & (1<<USB_LED_CAPS_LOCK)) && !(old_usb_led & (1<<USB_LED_CAPS_LOCK)))
if (!is_playing_notes())
{
// If CAPS LK LED is turning on...
PLAY_NOTE_ARRAY(tone_caps_on, false, LEGATO);
}
else if (!(usb_led & (1<<USB_LED_CAPS_LOCK)) && (old_usb_led & (1<<USB_LED_CAPS_LOCK)))
{
// If CAPS LK LED is turning off...
PLAY_NOTE_ARRAY(tone_caps_off, false, LEGATO);
}
else if ((usb_led & (1<<USB_LED_NUM_LOCK)) && !(old_usb_led & (1<<USB_LED_NUM_LOCK)))
{
// If NUM LK LED is turning on...
PLAY_NOTE_ARRAY(tone_numlk_on, false, LEGATO);
}
else if (!(usb_led & (1<<USB_LED_NUM_LOCK)) && (old_usb_led & (1<<USB_LED_NUM_LOCK)))
{
// If NUM LED is turning off...
PLAY_NOTE_ARRAY(tone_numlk_off, false, LEGATO);
}
else if ((usb_led & (1<<USB_LED_SCROLL_LOCK)) && !(old_usb_led & (1<<USB_LED_SCROLL_LOCK)))
{
// If SCROLL LK LED is turning on...
PLAY_NOTE_ARRAY(tone_scroll_on, false, LEGATO);
}
else if (!(usb_led & (1<<USB_LED_SCROLL_LOCK)) && (old_usb_led & (1<<USB_LED_SCROLL_LOCK)))
{
// If SCROLL LED is turning off...
PLAY_NOTE_ARRAY(tone_scroll_off, false, LEGATO);
if ((usb_led & (1<<USB_LED_CAPS_LOCK)) && !(old_usb_led & (1<<USB_LED_CAPS_LOCK)))
{
// If CAPS LK LED is turning on...
PLAY_NOTE_ARRAY(tone_caps_on, false, LEGATO);
}
else if (!(usb_led & (1<<USB_LED_CAPS_LOCK)) && (old_usb_led & (1<<USB_LED_CAPS_LOCK)))
{
// If CAPS LK LED is turning off...
PLAY_NOTE_ARRAY(tone_caps_off, false, LEGATO);
}
else if ((usb_led & (1<<USB_LED_NUM_LOCK)) && !(old_usb_led & (1<<USB_LED_NUM_LOCK)))
{
// If NUM LK LED is turning on...
PLAY_NOTE_ARRAY(tone_numlk_on, false, LEGATO);
}
else if (!(usb_led & (1<<USB_LED_NUM_LOCK)) && (old_usb_led & (1<<USB_LED_NUM_LOCK)))
{
// If NUM LED is turning off...
PLAY_NOTE_ARRAY(tone_numlk_off, false, LEGATO);
}
else if ((usb_led & (1<<USB_LED_SCROLL_LOCK)) && !(old_usb_led & (1<<USB_LED_SCROLL_LOCK)))
{
// If SCROLL LK LED is turning on...
PLAY_NOTE_ARRAY(tone_scroll_on, false, LEGATO);
}
else if (!(usb_led & (1<<USB_LED_SCROLL_LOCK)) && (old_usb_led & (1<<USB_LED_SCROLL_LOCK)))
{
// If SCROLL LED is turning off...
PLAY_NOTE_ARRAY(tone_scroll_off, false, LEGATO);
}
}
old_usb_led = usb_led;
}
@ -511,7 +579,23 @@ void play_startup_tone()
void play_goodbye_tone()
{
PLAY_NOTE_ARRAY(tone_my_goodbye, false, STACCATO);
_delay_ms(1000);
_delay_ms(2000);
stop_all_notes();
}
void play_audio_on_tone(void)
{
PLAY_NOTE_ARRAY(tone_audio_on, false, STACCATO);
}
void play_music_on_tone(void)
{
PLAY_NOTE_ARRAY(tone_music_on, false, STACCATO);
}
void play_music_scale(void)
{
PLAY_NOTE_ARRAY(music_scale, false, STACCATO);
}
#endif /* AUDIO_ENABLE */

View file

@ -4,7 +4,7 @@ EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
CONSOLE_ENABLE = no # Console for debug(+400)
COMMAND_ENABLE = yes # Commands for debug and configuration
NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
MIDI_ENABLE = no # MIDI controls
AUDIO_ENABLE = yes # Audio output on port C6
UNICODE_ENABLE = no # Unicode

View file

@ -36,7 +36,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// Change this to how you wired your keyboard
// COLS: Left to right, ROWS: Top to bottom
#if defined(ATREUS_ASTAR)
#define COLS (int []){ B7, D6, F7, F6, B6, D4, E6, B4, B5, C6, D7 }
#define COLS (int []){ D7, C6, B5, B4, E6, D4, B6, F6, F7, D6, B7 }
#define ROWS (int []){ D0, D1, D3, D2 }
#elif defined(ATREUS_TEENSY2)
#define COLS (int []){ F6, F5, F4, B7, B6, B5, B4, B3, B2, B1, B0}

View file

@ -101,6 +101,22 @@ NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: ht
# MIDI_ENABLE = yes # MIDI controls
# UNICODE_ENABLE = yes # Unicode
# If you want to have your own config_user.h, you can just put it in
# your keymap directory. Anything you set there will take precedence
# over the global config.h.
ifneq ("$(wildcard keymaps/$(KEYMAP)/config_user.h)","")
CONFIG_USER_H = keymaps/$(KEYMAP)/config_user.h
endif
ifdef KEYMAP
ifeq ("$(wildcard keymaps/$(KEYMAP).c)","")
ifneq ("$(wildcard keymaps/$(KEYMAP)/makefile.mk)","")
include keymaps/$(KEYMAP)/makefile.mk
endif
endif
endif
# Optimize size but this may cause error "relocation truncated to fit"
#EXTRALDFLAGS = -Wl,--relax

Binary file not shown.

View file

@ -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;
}
};

View file

@ -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

View file

@ -36,7 +36,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[BASE] = KEYMAP( // layer 0 : default
// left hand
KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, KC_LEFT,
KC_DELT, KC_Q, KC_W, KC_E, KC_R, KC_T, TG(1),
KC_DELT, KC_Q, KC_W, KC_E, KC_R, KC_T, TG(SYMB),
KC_BSPC, KC_A, KC_S, KC_D, KC_F, KC_G,
KC_LSFT, CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B, ALL_T(KC_NO),
LT(SYMB,KC_GRV),KC_QUOT, LALT(KC_LSFT), KC_LEFT,KC_RGHT,
@ -45,7 +45,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_SPC,KC_BSPC,KC_END,
// right hand
KC_RGHT, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,
TG(1), KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS,
TG(SYMB), KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS,
KC_H, KC_J, KC_K, KC_L, LT(MDIA, KC_SCLN),KC_LGUI,
MEH_T(KC_NO),KC_N, KC_M, KC_COMM,KC_DOT, CTL_T(KC_SLSH), KC_RSFT,
KC_UP, KC_DOWN,KC_LBRC,KC_RBRC, KC_FN1,
@ -117,7 +117,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* `--------------------' `--------------------'
*/
// MEDIA AND MOUSE
KEYMAP(
[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,

View file

@ -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

View file

@ -22,7 +22,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* |--------+------+------+------+------+------| Hyper| | Meh |------+------+------+------+------+--------|
* |LShift/(|Z/Ctrl| X | C | V | B | [ | | ] | N | M | , | . |//Ctrl|RShift/)|
* `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
* |Grv/L1| '" |AltShf| Left | Right| | Up | Down | [ | ] | - |
* |Grv/L1| '" |AltShf| Left | Right| | Up | Down | [ | ] | -/L1 |
* `----------------------------------' `----------------------------------'
* ,-------------. ,-------------.
* | App | LGui | | Alt |Ctrl/Esc|
@ -49,7 +49,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
TG(SYMB), KC_Y,KC_U, KC_I, KC_O, KC_P, KC_BSLS,
KC_H,ALT_T(KC_J),KC_K, KC_L, LT(MDIA,KC_SCLN),GUI_T(KC_QUOT),
MEH_T(KC_RBRC),KC_N,KC_M, KC_COMM,KC_DOT, CTL_T(KC_SLSH), RSFTC,
KC_UP, KC_DOWN,KC_LBRC,KC_RBRC, KC_MINS,
KC_UP, KC_DOWN,KC_LBRC,KC_RBRC, LT(SYMB,KC_MINS),
KC_LALT, CTL_T(KC_ESC),
KC_PGUP,
KC_PGDN,LT(SYMB, KC_TAB), KC_ENT
@ -59,13 +59,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* ,--------------------------------------------------. ,--------------------------------------------------.
* | | F1 | F2 | F3 | F4 | F5 | | | | F6 | F7 | F8 | F9 | F10 | F11 |
* |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
* | | 1 | 2 | 3 | 4 | | | | | | % | = | @ | | F12 |
* | | | | | | | | | | | | | | | F12 |
* |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
* | | 5 | 6 | 7 | 8 | 9 |------| |------| & | _ | - | ; | + | |
* | | 1 | 2 | 3 | 4 | 5 |------| |------| & | _ | - | ; | + | |
* |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
* | | ( | ) | [ | ] | 0 | | | | | | ( | ) | | | |
* | | 6 | 7 | 8 | 9 | 0 | | | | | | @ | = | % | | |
* `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
* | | | | | | | | | | | |
* | | | |NxtTab|PrvTab| | | | | | |
* `----------------------------------' `----------------------------------'
* ,-------------. ,-------------.
* | | | | | |
@ -79,19 +79,19 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[SYMB] = KEYMAP(
// left hand
KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_TRNS,
KC_TRNS, KC_1, KC_2, KC_3, KC_4, KC_TRNS, KC_TRNS,
KC_TRNS, KC_5, KC_6, KC_7, KC_8, KC_9,
KC_TRNS, KC_LPRN,KC_RPRN,KC_LBRC, KC_RBRC, KC_0, KC_TRNS,
KC_TRNS, KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_1, KC_2, KC_3, KC_4, KC_5,
KC_TRNS, KC_6, KC_7, KC_8, KC_9, KC_0, KC_TRNS,
KC_TRNS, KC_TRNS,KC_TRNS,LCTL(KC_PGUP), LCTL(KC_PGDN),
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_TRNS, KC_PERC,KC_EQL, KC_AT, KC_TRNS, KC_F12,
KC_AMPR, KC_UNDS,KC_MINS, CM_SCLN, KC_PLUS, KC_TRNS,
KC_TRNS, KC_PIPE, KC_LPRN,KC_RPRN, KC_3, KC_TRNS, KC_TRNS,
KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_F12,
KC_AMPR, KC_UNDS, KC_MINS, CM_SCLN, KC_PLUS, KC_TRNS,
KC_TRNS, KC_PIPE, KC_AT, KC_EQL, KC_PERC, 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
@ -101,13 +101,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* ,--------------------------------------------------. ,--------------------------------------------------.
* | | | | | | | | | | | | | | | |
* |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
* | | | | MsUp | | | | | | | | | | | |
* | | | | | | | | | | | | | | | |
* |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
* | | |MsLeft|MsDown|MsRght| |------| |------| | | | | | Play |
* | | PgUp | Home | End | PgDn | |------| |------| | | | | | Play |
* |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
* | | | | | | | | | | | | Prev | Next | | |
* `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
* | | | | Lclk | Rclk | |VolUp |VolDn | Mute | | |
* | | | | | | |VolUp |VolDn | Mute | | |
* `----------------------------------' `----------------------------------'
* ,-------------. ,-------------.
* | | | | | |
@ -120,10 +120,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
// 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_PGUP, KC_HOME, KC_END, KC_PGDN, 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,
@ -140,7 +140,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
};
const uint16_t PROGMEM fn_actions[] = {
[1] = ACTION_LAYER_TAP_TOGGLE(SYMB) // FN1 - Momentary Layer 1 (Symbols)
[1] = ACTION_LAYER_TAP_TOGGLE(SYMB), // FN1 - Momentary Layer 1 (Symbols)
[2] = ACTION_MACRO_TAP(0), // Eric Tang's Famous Macro!
[3] = ACTION_MACRO_TAP(1) // Eric Tang's Famous Macro!
};
static uint16_t key_timer;
@ -148,33 +150,46 @@ static uint16_t key_timer;
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
switch(id) {
case 0: {
if (record->event.pressed) {
key_timer = timer_read(); // if the key is being pressed, we start the timer.
register_code(KC_LSFT); // we're now holding down Shift.
} else { // this means the key was just released, so we can figure out how long it was pressed for (tap or "held down").
if (timer_elapsed(key_timer) < 70) { // the threshhold we pick for counting something as a tap.
register_code(KC_9); // sending 9 while Shift is held down gives us an opening paren
unregister_code(KC_9); // now let's let go of that key
}
unregister_code(KC_LSFT); // let's release the Shift key now.
}
break;
case 0:
if (record->event.pressed) {
register_mods(MOD_BIT(KC_LSFT));
if (record->tap.count && !record->tap.interrupted) {
register_code(KC_9);
}
else {
record->tap.count = 0;
}
}
else {
if (record->tap.count) {
unregister_code(KC_9);
}
else {
}
unregister_mods(MOD_BIT(KC_LSFT));
}
break;
case 1:
if (record->event.pressed) {
register_mods(MOD_BIT(KC_LSFT));
if (record->tap.count && !record->tap.interrupted) {
register_code(KC_0);
}
else {
record->tap.count = 0;
}
}
else {
if (record->tap.count) {
unregister_code(KC_0);
}
else {
}
unregister_mods(MOD_BIT(KC_LSFT));
}
break;
}
case 1: {
if (record->event.pressed) {
key_timer = timer_read(); // Now we're doing the same thing, only for the right shift/close paren key
register_code(KC_RSFT);
} else {
if (timer_elapsed(key_timer) < 70) {
register_code(KC_0);
unregister_code(KC_0);
}
unregister_code(KC_RSFT);
}
break;
}
}
return MACRO_NONE;
};

View file

@ -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

View file

@ -4,6 +4,14 @@ This is my personal layout which I use to test out ideas which may or may not ma
Changelog:
## May 8, 2016:
* Makes bottom-right key send minus/underscore when tapped, L1 temporary toggle when held
* Tweaked the positions of the numbers on the symbol layer. Basically, 12345 are now directly under their number-row counterparts in layer 0. You can imagine pulling the number row down to the home row. And 67890 are directly under 12345 - so it's a matter of just adding 5 and going to the next row (1+5 = 6, 2+5 = 7 and so on).
* Tweaks media/nav layer
* Removes mouse control, as I don't use it
* Makes left home row keys PgUp, Home, End, PgDn
## Apr 29, 2016:
* Tweaks the Hyper and Meh key to send brackets when tapped

View file

@ -4,434 +4,421 @@
#include "action_layer.h"
#include "action_util.h"
#define BASE 0 // default layer
#define LOCK 1 // shift-lock layer
#define SYMB_SH 2 // symbols shift layer
#define SYMB_LK 3 // symbols lock layer
#define SYMB_UN 4 // symbols unlock layer
#define MDIA_SH 5 // media shift layer
#define MDIA_LK 6 // media lock layer
#define MDIA_UN 7 // media unlock layer
#define UNLOCK 8 // clear to base layer
#define BASE 0 // default layer
#define SYMB 1 // symbols layer
#define MDIA 2 // media layer
#define SPEC 3 // special layer
#define LCaps 10 // left caps-shift key
#define LSymb 11 // left symbol-shift key
#define LMdia 12 // left media-shift key
#define LSpec 13 // left special-shift key
#define RCaps 14 // right caps-shift key
#define RSymb 15 // right symbol-shift key
#define RMdia 16 // right media-shift key
#define RSpec 17 // right special-shift key
#define MUL 20 // mouse up left
#define MUR 21 // mouse up right
#define MDL 22 // mouse down left
#define MDR 23 // mouse down right
/*
* The Ordinary Layout for the Ergodox EZ keyboard, v3.1
* modifications from default by Nicholas Keene ergodoxez@nicholaskeene.com
* The Ordinary Layout for the Ergodox EZ keyboard, v4
*
* Modifications from default by Nicholas Keene ergodoxez@nicholaskeene.com
*
* No rights reserved. This software is in the public domain.
* Credit me if you are friendly but if you're a jerk don't bother.
*
* Details: readme.md
* https://github.com/nrrkeene/qmk_firmware/tree/master/keyboard/ergodox_ez/keymaps/ordinary
*/
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Keymap 0: Base Layer
/******* Base Layer ********************************************************************************************************
*
* ,-----------------------------------------------------. ,-----------------------------------------------------.
* | LOCK `~ | 1 | 2 | 3 | 4 | 5 | ESC | | - | 6 | 7 | 8 | 9 | 0 | = LOCK |
* |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------|
* | Media Tab | Q | W | E | R | T | [ | | ] | Y | U | I | O | P | \ Media |
* |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------|
* | Symbol | A | S | D | F | G |------| |------| H | J | K | L | ; | ' Symbol |
* |-----------+------+------+------+------+------|Shift | | Tab |------+------+------+------+------+-----------|
* | LShift | Z | X | C | V | B | -Tab | | | N | M | , | . | / | RShift |
* `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------'
* | LCtrl | Meh |Hyper | LAlt | LGui | | RGui | RAlt | Hyper| Meh | RCtrl |
* `-----------------------------------' `-----------------------------------'
* ,-------------. ,-------------.
* | Home | End | | Left | Right|
* ,------|------|------| |------+------+------.
* | | | PgUp | | Up | | |
* |Backsp| Del |------| |------| Enter| Space|
* | | | PgDn | | Down | | |
* `--------------------' `--------------------'
* ,------------------------------------------------------. ,------------------------------------------------------.
* | Special `~ | 1 | 2 | 3 | 4 | 5 | ESC | | - | 6 | 7 | 8 | 9 | 0 | =+ Special |
* |------------+------+------+------+------+-------------| |------+------+------+------+------+------+------------|
* | Media Tab | Q | W | E | R | T | [ | | ] | Y | U | I | O | P | \| Media |
* |------------+------+------+------+------+------| | | |------+------+------+------+------+------------|
* | Symbol | A | S | D | F | G |------| |------| H | J | K | L | ; | '" Symbol |
* |------------+------+------+------+------+------|Shift | | Tab |------+------+------+------+------+------------|
* | Capitals | Z | X | C | V | B | -Tab | | | N | M | , | . | / | Capitals |
* `------------+------+------+------+------+-------------' `-------------+------+------+------+------+------------'
* | LCtrl | Meh |Hyper | LAlt | LGui | | RGui | RAlt | Hyper| Meh | RCtrl |
* `-----------------------------------' `-----------------------------------'
* ,-------------. ,-------------.
* | Home | End | | Left | Right|
* ,------|------|------| |------+------+------.
* | | | PgUp | | Up | | |
* |Backsp| Del |------| |------| Enter| Space|
* | | | PgDn | | Down | | |
* `--------------------' `--------------------'
*/
[BASE] = KEYMAP(
// left hand
LT(LOCK, KC_GRV) ,KC_1 ,KC_2 ,KC_3 ,KC_4 ,KC_5 ,KC_ESC
,LT(MDIA_SH, KC_TAB),KC_Q ,KC_W ,KC_E ,KC_R ,KC_T ,KC_LBRC
,MO(SYMB_SH) ,KC_A ,KC_S ,KC_D ,KC_F ,KC_G
,KC_LSFT ,KC_Z ,KC_X ,KC_C ,KC_V ,KC_B ,LSFT(KC_TAB)
,KC_LCTL ,MEH_T(KC_NO),ALL_T(KC_NO),KC_LALT,KC_LGUI
,KC_HOME,KC_END
,KC_PGUP
,KC_BSPC,KC_DEL ,KC_PGDN
// right hand
,KC_MINS ,KC_6 ,KC_7 ,KC_8 ,KC_9 ,KC_0 ,LT(LOCK, KC_EQL)
,KC_RBRC ,KC_Y ,KC_U ,KC_I ,KC_O ,KC_P ,LT(MDIA_SH, KC_BSLS)
,KC_H ,KC_J ,KC_K ,KC_L ,KC_SCLN ,LT(SYMB_SH, KC_QUOT)
,KC_TAB ,KC_N ,KC_M ,KC_COMM,KC_DOT ,KC_SLSH ,KC_RSFT
,KC_RGUI,KC_RALT,ALL_T(KC_NO),MEH_T(KC_NO),KC_RCTL
,KC_LEFT ,KC_RGHT
,KC_UP
,KC_DOWN ,KC_ENT ,KC_SPC
F(LSpec),KC_1,KC_2,KC_3 ,KC_4 ,KC_5 ,KC_ESC
,F(LMdia) ,KC_Q ,KC_W ,KC_E ,KC_R ,KC_T ,KC_LBRC
,M(LSymb) ,KC_A ,KC_S ,KC_D ,KC_F ,KC_G
,M(LCaps) ,KC_Z ,KC_X ,KC_C ,KC_V ,KC_B ,LSFT(KC_TAB)
,KC_LCTL ,KC_MEH ,KC_HYPR,KC_LALT,KC_LGUI
,KC_HOME,KC_END
,KC_PGUP
,KC_BSPC,KC_DEL ,KC_PGDN
// right hand
,KC_MINS ,KC_6 ,KC_7 ,KC_8 ,KC_9 ,KC_0 ,F(RSpec)
,KC_RBRC ,KC_Y ,KC_U ,KC_I ,KC_O ,KC_P ,F(RMdia)
,KC_H ,KC_J ,KC_K ,KC_L ,KC_SCLN ,F(RSymb)
,KC_TAB ,KC_N ,KC_M ,KC_COMM,KC_DOT ,KC_SLSH ,M(RCaps)
,KC_RGUI,KC_RALT,KC_HYPR ,KC_MEH ,KC_RCTL
,KC_LEFT ,KC_RGHT
,KC_UP
,KC_DOWN ,KC_ENT ,KC_SPC
),
/* Keymap 1: Layer Lock Keys
/******* Symbols Layer *****************************************************************************************************
*
* ,-------------------------------------------------------. ,-------------------------------------------------------.
* | | Esc | | | | | | | | | | | | Bspc | |
* |-------------+------+------+------+------+-------------| |------+------+------+------+------+------+-------------|
* | Media LOCK | | | | | | | | | | | | | | Media LOCK |
* |-------------+------+------+------+------+------| | | |------+------+------+------+------+-------------|
* | Symbol LOCK | | | | | |------| |------| | | | | | Symbol LOCK |
* |-------------+------+------+------+------+------| | | |------+------+------+------+------+-------------|
* | Caps LOCK | | | | | | | | | | | | | | Caps LOCK |
* `-------------+------+------+------+------+-------------' `-------------+------+------+------+------+-------------'
* | | | | | | | | | | | |
* `------------------------------------' `------------------------------------'
* ,-------------. ,-------------.
* | | | | | |
* ,------|------|------| |------+------+------.
* | | | | | | | |
* | | |------| |------| | |
* | | | | | | | |
* `--------------------' `--------------------'
* ,-----------------------------------------------------. ,-----------------------------------------------------.
* | | F1 | F2 | F3 | F4 | F5 | Esc | | - | F6 | F7 | F8 | F9 | F10 | |
* |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------|
* | | ! | @ | { | } | & | < | | > | | | 7 | 8 | 9 | / | |
* |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------|
* | | # | $ | ( | ) | ` |------| |------| / | 4 | 5 | 6 | * | |
* |-----------+------+------+------+------+------| Tab | | Shift|------+------+------+------+------+-----------|
* | | % | ^ | [ | ] | ~ | | | -Tab| \ | 1 | 2 | 3 | - | |
* `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------'
* | LCtrl | Meh |Hyper | LAlt | LGui | |RGui/0|RAlt/.|Hypr/=|Meh/+ |RCtrl/Ent|
* `-----------------------------------' `-------------------------------------'
* ,-------------. ,-------------.
* | Left | Right| | Home | End |
* ,------|------|------| |------+------+------.
* | | | Up | | PgUp | | |
* |Space |Enter |------| |------|BackSp| Del |
* | | | Down | | PgDn | | |
* `--------------------' `--------------------'
*/
[LOCK] = KEYMAP(
[SYMB] = KEYMAP(
// left hand
KC_TRNS ,KC_F1 ,KC_F2 ,KC_F3 ,KC_F4 ,KC_F5 ,KC_ESC
,KC_TRNS ,KC_EXLM ,KC_AT ,KC_LCBR ,KC_RCBR ,KC_AMPR ,LSFT(KC_COMM)
,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_TAB
,KC_LCTL ,KC_MEH ,KC_HYPR,KC_LALT ,KC_LGUI
,KC_LEFT ,KC_RGHT
,KC_UP
,KC_SPC ,KC_ENT ,KC_DOWN
// right hand
,KC_MINS ,KC_F6 ,KC_F7 ,KC_F8 ,KC_F9 ,KC_F10 ,KC_TRNS
,LSFT(KC_DOT),KC_PIPE ,KC_7 ,KC_8 ,KC_9 ,KC_SLSH ,KC_TRNS
,KC_SLSH ,KC_4 ,KC_5 ,KC_6 ,KC_ASTR ,KC_TRNS
,LSFT(KC_TAB),KC_BSLS ,KC_1 ,KC_2 ,KC_3 ,KC_MINS ,KC_TRNS
,GUI_T(KC_0),ALT_T(KC_DOT),ALL_T(KC_EQL),MEH_T(KC_PLUS),CTL_T(KC_ENT)
,KC_HOME ,KC_END
,KC_PGUP
,KC_PGDN ,KC_BSPC ,KC_DEL
),
/******* Media Layer *******************************************************************************************************
*
* ,---------------------------------------------------------------. ,---------------------------------------------------------------.
* | | F11 | F12 | F13 | F14 | F15 | Esc | | | F16 | F17 | F18 | F19 | F20 | |
* |------+---------+---------+---------+---------+----------------| |------+---------+---------+---------+---------+---------+------|
* | |Shut Down|MouseUpLf|Mouse Up |MouseUpRg|Volume Up|Scroll| |Scroll|PrintScrn| Home | Up | PgUp | Mail | |
* |------+---------+---------+---------+---------+---------| Up | | Up |---------+---------+---------+---------+---------+------|
* | | Sleep |MouseLeft|MouseDown|MouseRght|Volume Dn|------| |------| Num Lock| Left | Down | Right | MyComp | |
* |------+---------+---------+---------+---------+---------|Scroll| |Scroll|---------+---------+---------+---------+---------+------|
* | | |MouseDnLf|MouseDown|MouseDnRg| Mute | Down | | Down | | End | Down | PgDn | | |
* `------+---------+---------+---------+---------+----------------' `----------------+---------+---------+---------+---------+------'
* |LCtrl| Meh | MClick | LClick | R Click| |Cmd/Insrt|Optn/Del | Hyper | Meh |RCtrl|
* `---------------------------------------------' `---------------------------------------------'
* ,-------------. ,-------------.
* | Stop |Refrsh| | Prev | Next |
* ,------|------|------| |------+------+------.
* |Brwser|Brwser|Search| |VolUp | | |
* |Back | Fwd |------| |------| Stop | Play-|
* | | | Home | |VolDn | | Pause|
* `--------------------' `--------------------'
*/
[MDIA] = KEYMAP(
// left hand
KC_TRNS ,KC_F11 ,KC_F12 ,KC_F13 ,KC_F14 ,KC_F15 ,KC_ESC
,KC_TRNS ,KC_POWER ,M(MUL) ,KC_MS_U ,M(MUR) ,KC_VOLU ,KC_WH_U
,KC_TRNS ,KC_SLEP ,KC_MS_L ,KC_MS_D ,KC_MS_R ,KC_VOLD
,KC_TRNS ,KC_NO ,M(MDL) ,KC_MS_D ,M(MDR) ,KC_MUTE ,KC_WH_D
,KC_LCTL ,KC_MEH ,KC_BTN3 ,KC_BTN1 ,KC_BTN2
,KC_WSTP ,KC_WREF
,KC_WSCH
,KC_WBAK ,KC_NO ,KC_WHOM
// right hand
,KC_NO ,KC_F16 ,KC_F17 ,KC_F18 ,KC_F19 ,KC_F20 ,KC_TRNS
,KC_WH_U ,KC_PSCR ,KC_HOME ,KC_UP ,KC_PGUP ,KC_MAIL ,KC_TRNS
,KC_NLCK ,KC_LEFT ,KC_DOWN ,KC_RIGHT,KC_MYCM ,KC_TRNS
,KC_WH_D ,KC_NO ,KC_END ,KC_DOWN ,KC_PGDN ,KC_NO ,KC_TRNS
,GUI_T(KC_INS),ALT_T(KC_DEL),KC_HYPR ,KC_MEH ,KC_RCTL
,KC_MPRV ,KC_MNXT
,KC_VOLU
,KC_VOLD ,KC_MSTP ,KC_MPLY
),
/******* Special Layer *****************************************************************************************************
*
* ,-----------------------------------------------------. ,-----------------------------------------------------.
* | | Esc | | | | | | | | | | | | Bspc | |
* |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------|
* | | | | | | | | | | | | | | | |
* |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------|
* | | | | | | |------| |------| | | | | | |
* |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------|
* | | | | | | | | | | | | | | | RShift |
* `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------'
* | | | | | | | | | | | |
* `----------------------------------' `----------------------------------'
* ,-------------. ,-------------.
* | | | | | |
* ,------|------|------| |------+------+------.
* | | | | | | | |
* | | |------| |------| | |
* | | | | | | | |
* `--------------------' `--------------------'
*/
[SPEC] = KEYMAP(
// left hand
KC_TRNS ,KC_ESC ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
,KC_FN3 ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
,KC_FN2 ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
,KC_CAPS ,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_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
// right hand
,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_BSPC ,KC_TRNS
,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_FN3
,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_FN2
,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_CAPS
,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
,KC_TRNS ,KC_TRNS
,KC_TRNS
,KC_TRNS ,KC_TRNS ,KC_TRNS
),
/* Keymap 2: Symbol Shift Layer
*
* ,-----------------------------------------------------. ,-----------------------------------------------------.
* | LOCK | F1 | F2 | F3 | F4 | F5 | | | - | F6 | F7 | F8 | F9 | F10 | LOCK |
* |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------|
* | Media | ! | @ | { | } | & | < | | > | | | 7 | 8 | 9 | / | Media |
* |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------|
* | Symbol | # | $ | ( | ) | ` |------| |------| / | 4 | 5 | 6 | * | Symbol |
* |-----------+------+------+------+------+------| Tab | | Shift|------+------+------+------+------+-----------|
* | LShift | % | ^ | [ | ] | ~ | | | -Tab| \ | 1 | 2 | 3 | - | RShift |
* `-----------+------+------+------+------+-------------' `------------+------+------+------+------+------------'
* | | | | | | | 0 | . | = | + | Entr |
* `----------------------------------' `----------------------------------'
* ,-------------. ,-------------.
* | Left | Right| | Home | End |
* ,------|------|------| |------+------+------.
* | | | Up | | PgUp | | |
* |Space |Enter |------| |------|BackSp| Del |
* | | | Down | | PgDn | | |
* `--------------------' `--------------------'
*/
[SYMB_SH] = KEYMAP(
// left hand
KC_FN2 ,KC_F1 ,KC_F2 ,KC_F3 ,KC_F4 ,KC_F5 ,KC_TRNS
,MO(MDIA_SH) ,KC_EXLM ,KC_AT ,KC_LCBR ,KC_RCBR ,KC_AMPR ,LSFT(KC_COMM)
,MO(SYMB_SH) ,KC_HASH ,KC_DLR ,KC_LPRN ,KC_RPRN ,KC_GRV
,KC_LSFT ,KC_PERC ,KC_CIRC ,KC_LBRC ,KC_RBRC ,KC_TILD ,KC_TAB
,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
,KC_LEFT ,KC_RGHT
,KC_UP
,KC_SPC ,KC_ENT ,KC_DOWN
// right hand
,KC_MINS ,KC_F6 ,KC_F7 ,KC_F8 ,KC_F9 ,KC_F10 ,KC_FN2
,LSFT(KC_DOT),KC_PIPE ,KC_7 ,KC_8 ,KC_9 ,KC_SLSH ,MO(MDIA_SH)
,KC_SLSH ,KC_4 ,KC_5 ,KC_6 ,KC_ASTR ,MO(SYMB_SH)
,LSFT(KC_TAB),KC_BSLS ,KC_1 ,KC_2 ,KC_3 ,KC_MINS ,KC_RSFT
,GUI_T(KC_0),ALT_T(KC_DOT),ALL_T(KC_EQL),MEH_T(KC_PLUS),CTL_T(KC_ENT)
,KC_HOME ,KC_END
,KC_PGUP
,KC_PGDN ,KC_BSPC ,KC_DEL
),
/* Keymap 3: Symbol Lock Layer
*
* ,-----------------------------------------------------. ,-----------------------------------------------------.
* | LOCK | F1 | F2 | F3 | F4 | F5 | | | - | F6 | F7 | F8 | F9 | F10 | LOCK |
* |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------|
* | Media | ! | @ | { | } | & | < | | > | | | 7 | 8 | 9 | / | Media |
* |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------|
* | Symbol | # | $ | ( | ) | ` |------| |------| / | 4 | 5 | 6 | * | Symbol |
* |-----------+------+------+------+------+------| Tab | | Shift|------+------+------+------+------+-----------|
* | LShift | % | ^ | [ | ] | ~ | | | -Tab| \ | 1 | 2 | 3 | - | RShift |
* `-----------+------+------+------+------+-------------' `------------+------+------+------+------+------------'
* | | | | | | | 0 | . | = | + | Entr |
* `----------------------------------' `----------------------------------'
* ,-------------. ,-------------.
* | Left | Right| | Home | End |
* ,------|------|------| |------+------+------.
* | | | Up | | PgUp | | |
* |Space |Enter |------| |------|BackSp| Del |
* | | | Down | | PgDn | | |
* `--------------------' `--------------------'
*/
[SYMB_LK] = KEYMAP(
// left hand
MO(SYMB_UN) ,KC_F1 ,KC_F2 ,KC_F3 ,KC_F4 ,KC_F5 ,KC_TRNS
,MO(MDIA_SH) ,KC_EXLM ,KC_AT ,KC_LCBR ,KC_RCBR ,KC_AMPR ,LSFT(KC_COMM)
,MO(UNLOCK) ,KC_HASH ,KC_DLR ,KC_LPRN ,KC_RPRN ,KC_GRV
,KC_LSFT ,KC_PERC ,KC_CIRC ,KC_LBRC ,KC_RBRC ,KC_TILD ,KC_TAB
,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
,KC_LEFT ,KC_RGHT
,KC_UP
,KC_SPC ,KC_ENT ,KC_DOWN
// right hand
,KC_MINS ,KC_F6 ,KC_F7 ,KC_F8 ,KC_F9 ,KC_F10 ,MO(SYMB_UN)
,LSFT(KC_DOT),KC_PIPE ,KC_7 ,KC_8 ,KC_9 ,KC_SLSH ,MO(MDIA_SH)
,KC_SLSH ,KC_4 ,KC_5 ,KC_6 ,KC_ASTR ,MO(UNLOCK)
,LSFT(KC_TAB),KC_BSLS ,KC_1 ,KC_2 ,KC_3 ,KC_MINS ,KC_RSFT
,GUI_T(KC_0),ALT_T(KC_DOT),ALL_T(KC_EQL),MEH_T(KC_PLUS),CTL_T(KC_ENT)
,KC_HOME ,KC_END
,KC_PGUP
,KC_PGDN ,KC_BSPC ,KC_DEL
),
/* Keymap 4: Symbol Unlock Layer
*
* ,------------------------------------------------------. ,------------------------------------------------------.
* | | Esc | | | | | | | | | | | | Bspc | |
* |------------+------+------+------+------+-------------| |------+------+------+------+------+------+------------|
* | Media LOCK | | | | | | | | | | | | | | Media LOCK |
* |------------+------+------+------+------+------| | | |------+------+------+------+------+------------|
* | UNLOCK | | | | | |------| |------| | | | | | UNLOCK |
* |------------+------+------+------+------+------| | | |------+------+------+------+------+------------|
* | Caps LOCK | | | | | | | | | | | | | | Caps LOCK |
* `------------+------+------+------+------+-------------' `-------------+------+------+------+------+------------'
* | | | | | | | | | | | |
* `----------------------------------' `----------------------------------'
* ,-------------. ,-------------.
* | | | | | |
* ,------|------|------| |------+------+------.
* | | | | | | | |
* | | |------| |------| | |
* | | | | | | | |
* `--------------------' `--------------------'
*/
[SYMB_UN] = KEYMAP(
// left hand
KC_TRNS ,KC_ESC ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
,TG(MDIA_LK) ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
,KC_FN1 ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
,KC_CAPS ,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
// right hand
,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_BSPC ,KC_TRNS
,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,TG(MDIA_LK)
,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_FN1
,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_CAPS
,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_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_RSFT
,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
,KC_TRNS ,KC_TRNS
,KC_TRNS
,KC_TRNS ,KC_TRNS ,KC_TRNS
),
/* Keymap 5: Media Shift Layer
*
* ,-----------------------------------------------------. ,-----------------------------------------------------.
* | LOCK | F11 | F12 | F13 | F14 | F15 | | | | F16 | F17 | F18 | F19 | F20 | LOCK |
* |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------|
* | Media |ShutDn|LClick| MsUp |RClick|Vol Up|ScrlUp| |ScrlUp|PrtScr| Home | Up | PgUp | Mail | Media |
* |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------|
* | Symbol | Sleep|MsLeft|MsDown|MsRght|Vol Dn|------| |------|NumLok| Left | Down | Right|MyComp| Symbol |
* |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------|
* | LShift | | |MsDown| | Mute |ScrlDn| |ScrlDn| | End | Down | PgDn | | RShift |
* `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------'
* | LCtrl| Meh |Hyper | LAlt | LGui | |Insert|Delete| Hyper| LAlt | LGui |
* `----------------------------------' `----------------------------------'
* ,-------------. ,-------------.
* | Stop |Refrsh| | Prev | Next |
* ,------|------|------| |------+------+------.
* |Brwser|Brwser|Search| |VolUp | | |
* |Back | Fwd |------| |------| Stop | Play-|
* | | | Home | |VolDn | | Pause|
* `--------------------' `--------------------'
*/
[MDIA_SH] = KEYMAP(
// left hand
KC_FN3 ,KC_F11 ,KC_F12 ,KC_F13 ,KC_F14 ,KC_F15 ,KC_NO
,MO(MDIA_SH) ,KC_POWER ,KC_BTN1 ,KC_MS_U ,KC_BTN2 ,KC_VOLU ,KC_WH_U
,MO(SYMB_SH) ,KC_SLEP ,KC_MS_L ,KC_MS_D ,KC_MS_R ,KC_VOLD
,KC_LSFT ,KC_NO ,KC_NO ,KC_MS_D ,KC_NO ,KC_MUTE ,KC_WH_D
,KC_LCTL ,MEH_T(KC_NO),ALL_T(KC_NO),KC_LALT,KC_LGUI
,KC_WSTP ,KC_WREF
,KC_WSCH
,KC_WBAK ,KC_NO ,KC_WHOM
// right hand
,KC_NO ,KC_F16 ,KC_F17 ,KC_F18 ,KC_F19 ,KC_F20 ,KC_FN3
,KC_WH_U ,KC_PSCR ,KC_HOME,KC_UP ,KC_PGUP ,KC_MAIL ,MO(MDIA_SH)
,KC_NLCK ,KC_LEFT,KC_DOWN ,KC_RIGHT,KC_MYCM ,MO(SYMB_SH)
,KC_WH_D ,KC_NO ,KC_END ,KC_DOWN ,KC_PGDN ,KC_NO ,KC_RSFT
,GUI_T(KC_INS),ALT_T(KC_DEL),ALL_T(KC_NO),MEH_T(KC_NO),KC_RCTL
,KC_MPRV ,KC_MNXT
,KC_VOLU
,KC_VOLD ,KC_MSTP ,KC_MPLY
),
/* Keymap 6: Media Lock Layer
*
* ,-----------------------------------------------------. ,-----------------------------------------------------.
* | LOCK | F11 | F12 | F13 | F14 | F15 | | | | F16 | F17 | F18 | F19 | F20 | LOCK |
* |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------|
* | Media |ShutDn|LClick| MsUp |RClick|Vol Up|ScrlUp| |ScrlUp|PrtScr| Home | Up | PgUp | Mail | Media |
* |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------|
* | | Sleep|MsLeft|MsDown|MsRght|Vol Dn|------| |------|NumLok| Left | Down | Right|MyComp| |
* |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------|
* | LShift | | |MsDown| | Mute |ScrlDn| |ScrlDn| | End | Down | PgDn | | RShift |
* `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------'
* | LCtrl| Meh |Hyper | LAlt | LGui | |Insert|Delete| Hyper| LAlt | LGui |
* `----------------------------------' `----------------------------------'
* ,-------------. ,-------------.
* | Stop |Refrsh| | Prev | Next |
* ,------|------|------| |------+------+------.
* |Brwser|Brwser|Search| |VolUp | | |
* |Back | Fwd |------| |------| Stop | Play-|
* | | | Home | |VolDn | | Pause|
* `--------------------' `--------------------'
*/
[MDIA_LK] = KEYMAP(
// left hand
MO(MDIA_UN),KC_F11 ,KC_F12 ,KC_F13 ,KC_F14 ,KC_F15 ,KC_NO
,MO(UNLOCK) ,KC_POWER ,KC_BTN1 ,KC_MS_U ,KC_BTN2 ,KC_VOLU ,KC_WH_U
,KC_NO ,KC_SLEP ,KC_MS_L ,KC_MS_D ,KC_MS_R ,KC_VOLD
,KC_LSFT ,KC_NO ,KC_NO ,KC_MS_D ,KC_NO ,KC_MUTE ,KC_WH_D
,KC_LCTL ,MEH_T(KC_NO),ALL_T(KC_NO),KC_LALT,KC_LGUI
,KC_WSTP ,KC_WREF
,KC_WSCH
,KC_WBAK ,KC_NO ,KC_WHOM
// right hand
,KC_NO ,KC_F16 ,KC_F17 ,KC_F18 ,KC_F19 ,KC_F20 ,MO(MDIA_UN)
,KC_WH_U ,KC_PSCR ,KC_HOME,KC_UP ,KC_PGUP ,KC_MAIL ,MO(UNLOCK)
,KC_NLCK ,KC_LEFT,KC_DOWN ,KC_RIGHT,KC_MYCM ,KC_NO
,KC_WH_D ,KC_NO ,KC_END ,KC_DOWN ,KC_PGDN ,KC_NO ,KC_RSFT
,GUI_T(KC_INS),ALT_T(KC_DEL),ALL_T(KC_NO),MEH_T(KC_NO),KC_RCTL
,KC_MPRV ,KC_MNXT
,KC_VOLU
,KC_VOLD ,KC_MSTP ,KC_MPLY
),
/* Keymap 7: Media Unlock Layer
*
* ,-----------------------------------------------------. ,-----------------------------------------------------.
* | | Esc | | | | | | | | | | | | Bspc | |
* |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------|
* | UNLOCK | | | | | | | | | | | | | | UNLOCK |
* |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------|
* | | | | | | |------| |------| | | | | | |
* |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------|
* | Caps LOCK | | | | | | | | | | | | | | Caps LOCK |
* `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------'
* | | | | | | | | | | | |
* `----------------------------------' `----------------------------------'
* ,-------------. ,-------------.
* | | | | | |
* ,------|------|------| |------+------+------.
* | | | | | | | |
* | | |------| |------| | |
* | | | | | | | |
* `--------------------' `--------------------'
*/
[MDIA_UN] = KEYMAP(
// left hand
KC_TRNS ,KC_ESC ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
,KC_FN1 ,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_CAPS ,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
// right hand
,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_BSPC ,KC_TRNS
,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_FN1
,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_CAPS
,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
,KC_TRNS ,KC_TRNS
,KC_TRNS
,KC_TRNS ,KC_TRNS ,KC_TRNS
),
/* Keymap 8: Unlock Layer
*
* ,-----------------------------------------------------. ,-----------------------------------------------------.
* | UNLOCK | | | | | | | | | | | | | | UNLOCK |
* |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------|
* | | | | | | | | | | | | | | | |
* |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------|
* | | | | | | |------| |------| | | | | | |
* |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------|
* | | | | | | | | | | | | | | | |
* `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------'
* | | | | | | | | | | | |
* `----------------------------------' `----------------------------------'
* ,-------------. ,-------------.
* | | | | | |
* ,------|------|------| |------+------+------.
* | | | | | | | |
* | | |------| |------| | |
* | | | | | | | |
* `--------------------' `--------------------'
*/
[UNLOCK] = KEYMAP(
// left hand
KC_FN1 ,KC_ESC ,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_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
// right hand
,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_FN1
,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_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[] = {
[1] = ACTION_LAYER_CLEAR(ON_PRESS) // FN1 - clear to base layer
,[2] = ACTION_LAYER_INVERT(SYMB_LK, ON_PRESS) // FN2 - toggle to Symbols on press
,[3] = ACTION_LAYER_INVERT(MDIA_LK, ON_PRESS) // FN3 - toggle to Media on press
// the faux shift keys are implemented as macro taps
[LCaps] = ACTION_MACRO_TAP(LCaps)
,[LSymb] = ACTION_MACRO_TAP(LSymb)
,[LMdia] = ACTION_MACRO_TAP(LMdia)
,[LSpec] = ACTION_MACRO_TAP(LSpec)
,[RCaps] = ACTION_MACRO_TAP(RCaps)
,[RSymb] = ACTION_MACRO_TAP(RSymb)
,[RMdia] = ACTION_MACRO_TAP(RMdia)
,[RSpec] = ACTION_MACRO_TAP(RSpec)
};
uint16_t caps_shift = 0;
uint16_t symb_shift = 0;
uint16_t mdia_shift = 0;
bool symb_lock = false;
bool mdia_lock = false;
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);
switch(id) {
// There are two shift keys for each layer so we increment a layer_shift var when one
// is pressed and decrement when one is released. If both are pressed at the same time
// then the layer is locked (or unlocked). The shift counts are bound between 0 and 2
// only because sometimes rapid pressing led to irregular events; this way the states
// are self healing during use.
case LCaps: // both caps-shift keys trigger Left Shift
case RCaps: // so they don't interfere with the magic combo
if (record->event.pressed && !record->tap.count) {
if(++caps_shift > 2) caps_shift = 2;
if(caps_shift == 2) {
register_code(KC_CAPS);
unregister_code(KC_CAPS);
} else if(caps_shift == 1) {
register_code(KC_LSFT);
}
} else {
unregister_code(KC_RSFT);
if(--caps_shift < 0) caps_shift = 0;
if(caps_shift == 0) unregister_code(KC_LSFT);
}
break;
}
case LSymb:
if (record->event.pressed) {
if(++symb_shift > 2) symb_shift = 2;
if(symb_shift == 2) {
symb_lock = !symb_lock;
} else if(symb_shift == 1) {
layer_on(SYMB);
}
} else {
if(--symb_shift < 0) symb_shift = 0;
if((symb_shift == 0) && (!symb_lock)) layer_off(SYMB);
}
break;
case LMdia:
if (record->event.pressed) {
if (record->tap.count && (!mdia_shift) && (!mdia_lock)) {
register_code(KC_TAB);
} else {
if(++mdia_shift > 2) mdia_shift = 2;
if(mdia_shift == 2) {
mdia_lock = !mdia_lock;
} else if(mdia_shift == 1) {
layer_on(MDIA);
}
}
} else {
if(record->tap.count && (!mdia_shift) && (!mdia_lock)) {
unregister_code(KC_TAB);
} else {
if(--mdia_shift < 0) mdia_shift = 0;
if((!mdia_shift) && (!mdia_lock)) layer_off(MDIA);
}
}
break;
case LSpec:
if (record->event.pressed) {
if (record->tap.count && !record->tap.interrupted) {
register_code(KC_GRV);
} else {
layer_on(SPEC);
}
} else {
if(record->tap.count && !record->tap.interrupted) {
unregister_code(KC_GRV);
} else {
layer_off(SPEC);
}
}
break;
case RSymb:
if (record->event.pressed) {
if (record->tap.count && (!symb_shift) && (!symb_lock)) {
register_code(KC_QUOT);
} else {
if(++symb_shift > 2) symb_shift = 2;
if(symb_shift == 2) {
symb_lock = !symb_lock;
} else if(symb_shift == 1) {
layer_on(SYMB);
}
}
} else {
if(record->tap.count && symb_shift == 0) {
unregister_code(KC_QUOT);
} else {
if(--symb_shift < 0) symb_shift = 0;
if((!symb_shift) && (!symb_lock)) layer_off(SYMB);
}
}
break;
case RMdia:
if (record->event.pressed) {
if (record->tap.count && (!mdia_shift) && (!mdia_lock)) {
register_code(KC_BSLS);
} else {
if(++mdia_shift > 2) mdia_shift = 2;
if(mdia_shift == 2) {
mdia_lock = !mdia_lock;
} else if(mdia_shift == 1) {
layer_on(MDIA);
}
}
} else {
if(record->tap.count && (!mdia_shift) && (!mdia_lock)) {
unregister_code(KC_BSLS);
} else {
if(--mdia_shift < 0) mdia_shift = 0;
if((!mdia_shift) && (!mdia_lock)) layer_off(MDIA);
}
}
break;
case RSpec:
if (record->event.pressed) {
if (record->tap.count && !record->tap.interrupted) {
register_code(KC_EQL);
} else {
layer_on(SPEC);
}
} else {
if(record->tap.count && !record->tap.interrupted) {
unregister_code(KC_EQL);
} else {
layer_off(SPEC);
}
}
break;
// mouse diagonals
case MUL: // mouse up left
if (record->event.pressed) {
mousekey_on(KC_MS_UP);
mousekey_on(KC_MS_LEFT);
mousekey_send();
} else {
mousekey_off(KC_MS_UP);
mousekey_off(KC_MS_LEFT);
mousekey_send();
}
break;
case MUR: // mouse up right
if (record->event.pressed) {
mousekey_on(KC_MS_UP);
mousekey_on(KC_MS_RIGHT);
mousekey_send();
} else {
mousekey_off(KC_MS_UP);
mousekey_off(KC_MS_RIGHT);
mousekey_send();
}
break;
case MDL: // mouse down left
if (record->event.pressed) {
mousekey_on(KC_MS_DOWN);
mousekey_on(KC_MS_LEFT);
mousekey_send();
} else {
mousekey_off(KC_MS_DOWN);
mousekey_off(KC_MS_LEFT);
mousekey_send();
}
break;
case MDR: // mouse down right
if (record->event.pressed) {
mousekey_on(KC_MS_DOWN);
mousekey_on(KC_MS_RIGHT);
mousekey_send();
} else {
mousekey_off(KC_MS_DOWN);
mousekey_off(KC_MS_RIGHT);
mousekey_send();
}
break;
default:
// none
break;
}
return MACRO_NONE;
};
@ -442,31 +429,22 @@ void matrix_init_user(void) {
// Runs constantly in the background, in a loop.
void matrix_scan_user(void) {
uint8_t layer = biton32(layer_state);
// shift or caps lock turns on red light
if((keyboard_report->mods & (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT))) || (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK))) {
if(caps_shift || (keyboard_report->mods & MOD_BIT(KC_RSFT)) || (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK))) {
ergodox_right_led_1_on();
} else {
ergodox_right_led_1_off();
}
// do not change lights while locking and unlocking
if(layer == LOCK || layer == SYMB_UN || layer == MDIA_UN || layer == UNLOCK) {
return;
}
//ergodox_board_led_off();
// symbol turns on green light
if(layer == SYMB_SH || layer == SYMB_LK) {
// Symbol layer turns on green light
if(layer_state & (1UL<<SYMB)) {
ergodox_right_led_2_on();
} else {
ergodox_right_led_2_off();
}
// media turns on blue light
if(layer == MDIA_SH || layer == MDIA_LK) {
// Media layer turns on blue light
if(layer_state & (1UL<<MDIA)) {
ergodox_right_led_3_on();
} else {
ergodox_right_led_3_off();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 97 KiB

After

Width:  |  Height:  |  Size: 97 KiB

View file

@ -1,7 +1,7 @@
[{x:3.5},"#\n3",{x:10.5},"*\n8"],
[{y:-0.875,x:2.5},"@\n2",{x:1},"$\n4",{x:8.5},"&\n7",{x:1},"(\n9"],
[{y:-0.875,x:5.5},"%\n5",{c:"#ff4444"},"Esc",{x:4.5,c:"#cccccc"},"_\n\n\n\n\n\n-","^\n6"],
[{y:-0.875,c:"#2277ff",w:1.5},"Shift\n\n~\n\n\n\nLock\n`",{c:"#cccccc"},"!\n1",{x:14.5},")\n0",{c:"#2277ff",w:1.5},"+\n\nShift\n\n\n\n=\nLock"],
[{y:-0.875,c:"#2277ff",w:1.5},"Special\n\n~\n\n\n\nShift\n`",{c:"#cccccc"},"!\n1",{x:14.5},")\n0",{c:"#2277ff",w:1.5},"+\n\nSpecial\n\n\n\n=\nShift"],
[{y:-0.375,x:3.5,c:"#cccccc"},"E",{x:10.5},"I"],
[{y:-0.875,x:2.5},"W",{x:1},"R",{x:8.5},"U",{x:1},"O"],
[{y:-0.875,x:5.5},"T",{h:1.5},"{\n\n\n\n\n\n[",{x:4.5,h:1.5},"}\n\n\n\n\n\n]","Y"],
@ -14,7 +14,7 @@
[{y:-0.75,x:3.5,c:"#cccccc"},"C",{x:10.5},"<\n,"],
[{y:-0.875,x:2.5},"X",{x:1},"V",{x:8.5},"M",{x:1},">\n."],
[{y:-0.875,x:5.5},"B",{x:6.5},"N"],
[{y:-0.875,c:"#2277ff",fa:[0,1,0,1,0,0,0],w:1.5},"Capitals\nShift\n\n\n\n\nShift",{c:"#cccccc"},"Z",{x:14.5,f:3},"?\n/",{c:"#2277ff",w:1.5},"\n\nCapitals\nShift\n\n\n\nShift"],
[{y:-0.875,c:"#2277ff",w:1.5},"Capitals\n\n\n\n\n\nShift",{c:"#cccccc"},"Z",{x:14.5},"?\n/",{c:"#2277ff",w:1.5},"\n\nCapitals\n\n\n\n\nShift"],
[{y:-0.375,x:3.5,c:"#77aaff"},"Option\n\n\nLAlt",{x:10.5},"Option\n\n\nRAlt"],
[{y:-0.875,x:2.5},"Hyper",{x:1},"Cmd\n\n\nSuper",{x:8.5},"Cmd\n\n\nSuper",{x:1},"Hyper"],
[{y:-0.75,x:0.5},"Ctrl\n\n\nLCtrl","Meh",{x:14.5},"Meh","Ctrl\n\n\nRCtrl"],

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

After

Width:  |  Height:  |  Size: 121 KiB

View file

@ -1,22 +1,22 @@
[{x:3.5,c:"#99de2a"},"F13",{x:10.5},"F18"],
[{y:-0.875,x:2.5},"F12",{x:1},"F14",{x:8.5},"F17",{x:1},"F19"],
[{y:-0.875,x:5.5},"F15",{c:"#ff4444"},"Esc",{x:4.5,c:"#cccccc",a:7},"",{c:"#99de2a",a:4},"F16"],
[{y:-0.875,c:"#2277ff",w:1.5},"Shift\n\n\n\n\n\nLock",{c:"#99de2a"},"F11",{x:14.5},"F20",{c:"#2277ff",w:1.5},"\n\nShift\n\n\n\n\nLock"],
[{y:-0.875,x:5.5},"F15",{c:"#ff4444"},"Esc",{x:4.5,c:"#737373",a:7},"",{c:"#99de2a",a:4},"F16"],
[{y:-0.875,c:"#2277ff",w:1.5},"Special\n\n\n\n\n\nShift",{c:"#99de2a"},"F11",{x:14.5},"F20",{c:"#2277ff",w:1.5},"\n\nSpecial\n\n\n\n\nShift"],
[{y:-0.375,x:3.5,c:"#ff8500"},"Mouse\n\n\n\n\n\nUp",{x:10.5},"Cursor\n\n\n\n\n\nUp"],
[{y:-0.875,x:2.5},"Left\n\n\n\n\n\nClick",{x:1},"Right\n\n\n\n\n\nClick",{x:8.5,c:"#ffb063"},"Home",{x:1},"Page\n\n\n\n\n\nUp"],
[{y:-0.875,x:2.5},"Mouse\n\n\n\n\n\nUpLeft",{x:1},"Mouse\n\n\n\n\n\nUpRgt",{x:8.5,c:"#ffb063"},"Home",{x:1},"Page\n\n\n\n\n\nUp"],
[{y:-0.875,x:5.5,c:"#e6e067"},"Vol\n\n\n\n\n\nUp",{c:"#ffb063",h:1.5},"Scroll\n\n\n\n\n\nUp",{x:4.5,h:1.5},"Scroll\n\n\n\n\n\nUp",{c:"#e6e067"},"Print\n\n\n\n\n\nScreen"],
[{y:-0.875,c:"#000000",t:"#ff0000",w:1.5},"Media\n\n\n\n\n\nShift",{c:"#e6e067",t:"#000000"},"Shut\n\n\n\n\n\nDown",{x:14.5},"Mail",{c:"#000000",t:"#ff0000",w:1.5},"\n\nMedia\n\n\n\n\nShift"],
[{y:-0.375,x:3.5,c:"#ff8500",t:"#000000"},"Mouse\n\n\n\n\n\nDown",{x:10.5},"Cursor\n\n\n\n\n\nDown"],
[{y:-0.875,x:2.5},"Mouse\n\n\n\n\n\nLeft",{x:1},"Mouse\n\n\n\n\n\nRight",{x:8.5},"Cursor\n\n\n\n\n\nLeft",{x:1},"Cursor\n\n\n\n\n\nRight"],
[{y:-0.875,x:5.5,c:"#e6e067"},"Vol\n\n\n\n\n\nDown",{x:6.5},"Num\n\n\n\n\n\nLock"],
[{y:-0.875,c:"#cccccc",a:7,w:1.5},"",{c:"#e6e067",a:4},"Sleep",{x:14.5},"My\n\n\n\n\n\nComp",{c:"#cccccc",a:7,w:1.5},""],
[{y:-0.625,x:6.5,c:"#ffb063",a:4,h:1.5},"Scroll\n\n\n\n\n\nDown",{x:4.5,h:1.5},"Scroll\n\n\n\n\n\nDown"],
[{y:-0.875,c:"#2277ff",w:1.5},"Symbols\n\n\n\n\n\nShift",{c:"#e6e067"},"Sleep",{x:14.5},"My\n\n\n\n\n\nComp",{c:"#2277ff",w:1.5},"\n\nSymbols\n\n\n\n\nShift"],
[{y:-0.625,x:6.5,c:"#ffb063",h:1.5},"Scroll\n\n\n\n\n\nDown",{x:4.5,h:1.5},"Scroll\n\n\n\n\n\nDown"],
[{y:-0.75,x:3.5,c:"#ff8500"},"Mouse\n\n\n\n\n\nDown",{x:10.5},"Cursor\n\n\n\n\n\nDown"],
[{y:-0.875,x:2.5,c:"#cccccc",a:7},"",{x:1},"",{x:8.5,c:"#ffb063",a:4},"End",{x:1},"Page\n\n\n\n\n\nDown"],
[{y:-0.875,x:5.5,c:"#e6e067"},"Mute",{x:6.5,c:"#cccccc",a:7},""],
[{y:-0.875,c:"#2277ff",a:4,f2:1,w:1.5},"Capitals\nShift\n\n\n\n\nShift",{c:"#cccccc",a:7},"",{x:14.5},"",{c:"#2277ff",a:4,fa:[0,1,0,1],w:1.5},"\n\nCapitals\nShift\n\n\n\nShift"],
[{y:-0.375,x:3.5,c:"#77aaff"},"Option\n\n\nLAlt",{x:10.5,c:"#ffb063"},"Delete\n\n\nOption"],
[{y:-0.875,x:2.5,c:"#77aaff"},"Hyper",{x:1},"Cmd\n\n\nSuper",{x:8.5,c:"#ffb063"},"Insert\n\n\nCmd",{x:1,c:"#77aaff"},"Hyper"],
[{y:-0.875,x:2.5},"Mouse\n\n\n\n\n\nDnLeft",{x:1},"Mouse\n\n\n\n\n\nDnRgt",{x:8.5,c:"#ffb063"},"End",{x:1},"Page\n\n\n\n\n\nDown"],
[{y:-0.875,x:5.5,c:"#e6e067"},"Mute",{x:6.5,c:"#737373",a:7},""],
[{y:-0.875,c:"#2277ff",a:4,w:1.5},"Capitals\n\n\n\n\n\nShift",{c:"#737373",a:7},"",{x:14.5},"",{c:"#2277ff",a:4,w:1.5},"\n\nCapitals\n\n\n\n\nShift"],
[{y:-0.375,x:3.5,c:"#ff8500"},"Middle\n\n\n\n\n\nClick",{x:10.5,c:"#ffb063",fa:[0,0,0,1]},"Delete\n\n\nOption"],
[{y:-0.875,x:2.5,c:"#ff8500"},"Left\n\n\n\n\n\nClick",{x:1},"Right\n\n\n\n\n\nClick",{x:8.5,c:"#ffb063"},"Insert\n\n\nCmd",{x:1,c:"#77aaff"},"Hyper"],
[{y:-0.75,x:0.5},"Ctrl\n\n\nLCtrl","Meh",{x:14.5},"Meh","Crtl\n\n\nRCtrl"],
[{r:30,rx:6.5,ry:4.25,y:-1,x:1,c:"#ccbb00"},"Stop\n\n\nBrowser","Reload\n\n\nBrowser"],
[{h:2},"< Web\n\n\nBrowser",{h:2},"Web >\n\n\nBrowser","Search\n\n\nBrowser"],

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

View file

@ -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},""]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 101 KiB

After

Width:  |  Height:  |  Size: 101 KiB

View file

@ -1,7 +1,7 @@
[{x:3.5,c:"#99de2a"},"F3",{x:10.5},"F8"],
[{y:-0.875,x:2.5},"F2",{x:1},"F4",{x:8.5},"F7",{x:1},"F9"],
[{y:-0.875,x:5.5},"F5",{c:"#ff4444"},"Esc",{x:4.5,c:"#bbddbb"},"_\n\n\n\n\n\n-",{c:"#99de2a"},"F6"],
[{y:-0.875,c:"#2277ff",w:1.5},"Shift\n\n\n\n\n\nLock",{c:"#99de2a"},"F1",{x:14.5},"F10",{c:"#2277ff",w:1.5},"\n\nShift\n\n\n\n\nLock"],
[{y:-0.875,c:"#2277ff",w:1.5},"Special\n\n\n\n\n\nShift",{c:"#99de2a"},"F1",{x:14.5},"F10",{c:"#2277ff",w:1.5},"\n\nSpecial\n\n\n\n\nShift"],
[{y:-0.375,x:3.5,c:"#bbddbb"},"{",{x:10.5,c:"#89b087"},"8"],
[{y:-0.875,x:2.5,c:"#bbddbb"},"@",{x:1},"}",{x:8.5,c:"#89b087"},"7",{x:1},"9"],
[{y:-0.875,x:5.5,c:"#bbddbb"},"&",{h:1.5},"<",{x:4.5,h:1.5},">","|"],
@ -14,7 +14,7 @@
[{y:-0.75,x:3.5,c:"#bbddbb"},"[",{x:10.5,c:"#89b087"},"2"],
[{y:-0.875,x:2.5,c:"#bbddbb"},"^",{x:1},"]",{x:8.5,c:"#89b087"},"1",{x:1},"3"],
[{y:-0.875,x:5.5,c:"#bbddbb"},"~",{x:6.5},"\\"],
[{y:-0.875,c:"#2277ff",fa:[0,1,0,1,0,0,1],w:1.5},"Capitals\nShift\n\n\n\n\nShift",{c:"#bbddbb"},"%",{x:14.5,c:"#89b087"},"-",{c:"#2277ff",w:1.5},"\n\nCapitals\nShift\n\n\n\nShift"],
[{y:-0.875,c:"#2277ff",w:1.5},"Capitals\n\n\n\n\n\nShift",{c:"#bbddbb"},"%",{x:14.5,c:"#89b087"},"-",{c:"#2277ff",w:1.5},"\n\nCapitals\n\n\n\n\nShift"],
[{y:-0.375,x:3.5,c:"#77aaff"},"Option\n\n\nLAlt",{x:10.5,c:"#89b087"},".\n\n\nOption"],
[{y:-0.875,x:2.5,c:"#77aaff"},"Hyper",{x:1},"Cmd\n\n\nSuper",{x:8.5,c:"#89b087"},"0\n\n\nCmd",{x:1},"=\n\n\nHyper"],
[{y:-0.75,x:0.5,c:"#77aaff"},"Ctrl\n\n\nLCtrl","Meh",{x:14.5,c:"#89b087"},"+\n\n\nMeh","Enter\n\n\nCtrl"],
@ -22,6 +22,6 @@
[{h:2},"Space",{h:2},"Enter","Up"],
[{x:2},"Down"],
[{r:-30,rx:13,y:-1,x:-3},"Home","End"],
[{x:-3,f:3},"Page\n\n\n\n\n\nUp",{h:2},"< Del\n\n\nBackspace",{h:2},"Del >\n\n\nDelete"],
[{x:-3,f:3},"Page\n\n\n\n\n\nDown"]
[{x:-3},"Page\n\n\n\n\n\nUp",{h:2},"< Del\n\n\nBackspace",{h:2},"Del >\n\n\nDelete"],
[{x:-3},"Page\n\n\n\n\n\nDown"]

View file

@ -55,7 +55,7 @@ Finally, consider the turquoise text-nav keys. Here in the Symbols layer, these
* The bright green keys are more F-keys
* The dark yellow keys signal Web and Audio applications
* The light yellow keys signal the operating system
* The uncolored keys do nothing in case you bump them by accident
* The dark gray keys do nothing in case you bump them by accident
![Ordinary media layout](ordinary-media.png)
@ -67,14 +67,37 @@ Alas, the yellow keys have at best spotty success with common software. Good luc
## Switching Between Layers ##
The three Shift keys correspond to three logical layers on top of the ever-present base layer, and are represented in the three LEDs on the keyboard: Capitals (red), Symbols (green), Media (blue). The color of a layer illuminates when the layer is active. Shift keys work in the expected way: press them and the keys shift to that layer; release them and the keys shift back to the base layer. The Ordinary Layout also features a Shift Lock key to keep a layer active indefinitely. Hold down the Shift Lock key then press any Shift key to lock to that layer. Or, hold down the Shift key and press the Shift Lock key; it works either way. To revert to the base layer, use the Shift Lock key again in combination with the Shift key.
In addition to Symbols and Media there is the Capitals layer which is exactly the same as pressing the shift key. Each layer is accessed by a shift key on each edge of the keyboard and corresponds to one of the three LEDs on the keyboard: Capitals (red), Symbols (green), Media (blue). The color of a layer illuminates when the layer is active.
This layout attempts to treat the Capitals Shift layer the same as the other two Shift layers, but internally they are different which causes some inconsistencies. For instance, it is possible to switch from any layer to any other layer, and to lock to any layer, *except* it is not possible to go from Media to Symbols. You must exit the Media layer before engaging the Symbols layer. Also, the Caps Lock feature must be triggered by first pressing the Shift Lock key then a Capitals Shift key; it doesn't work if you press the Shift key first (instead you get the secondary symbol character associated with the Shift Lock button).
Shift buttons work in the expected way: press them and all of the keys switch to that layer; release them and the keys switch back to the base layer. If you press both of a pair of shift keys, the layer will lock on until you press both shift keys again. For instance, the widely and rightly loathed Caps Lock is engaged by pressing both Capitals Shift buttons. All the Shift keys work this way.
## Special Escape & Backspace Sequences ##
Multiple layers can be turned on at once. The Capitals layer will affect characters on other layers to capitalize. Other layers, however, don't 'mix': Symbols blankets the base layout; Media blankets Symbols.
In the Ordinary Layout, the most unsatisfying key location is the Escape key which rightly belongs segregated on its own way up on the top left of the keyboard. The Ergodox does not have a physical button in such a location and the nearest one, in the top left corner, is home to the tilde (er, grave) which is commonly found there. The Escape key is important so it features prominently on the other top corner on the left side of the keyboard, and is always there in all layers. Nevertheless, alas, it isn't Ordinary to put the escape in that different corner!
## Special Sequences ##
That tilde key has a second function as the Shift Lock key and that makes possible a special feature. To make this layout as Ordinary as possible, the Escape key can *also* be accessed by pressing Shift Lock then the 1 button right next to it. This easy gesture is a way to partially maintain the ease of flicking your wrist to the left and tapping Escape. This gesture works in all layers.
![Ordinary special layout](ordinary-special.png)
Finally, because the special Escape sequence is so natural and useful, on the top right corner of the Ergodox EZ you can do the same gesture with the 0 key to produce a Backspace. Users of this keyboard and this layout are well advised to learn to use their thumbs for deleting text, but sometimes you are doing other computery things and just want to flick your digits up to the right and press backspace a bunch times. These special sequences should feel unremarkably mundane but might prove to be remarkably useful.
### Escape ###
The One True Location for the Escape key is segregated way up on the top left of the keyboard. The Ergodox does not have a physical button in such a location and the nearest one is home to the tilde (er, grave) which is commonly found there. In the Ordinary layout the Escape key is found on all layers in the prominent location in the corner next to the 5, whnich is easy to remember, and yet it isn't natural for those of us with muscle memory flicking our wrists up and to the left looking for Escape.
The Ordinary layout offers as a consolation prize a Special sequence for Escape: Special Shift + 1. This is natural so you can tap the top left button, then the button next to it and get Escape. This gesture works in all layers.
### Backspace ###
At the top right corner of the Ergodox EZ you can a gesture similar to the special Escape sequence, using the 0 key, to produce a Backspace. Users of this keyboard and this layout are well advised to learn to use their thumbs for deleting text, but sometimes you are doing other computery things and just want to flick your digits up to the right and press backspace a bunch times.
### RShift ###
The Ordinary Layout locks layers by pressing both of a pair of shift keys. This interferes with the QMK firmware magic sequence, which is LShift+RShift. To work around this, both of the Capitals Shift keys produce a *Left Shift* keystroke. If for some reason a person needs *Right Shift* they can find it by pressing a Special Shift key, then the Capitals Shift key on the right side of the keyboard.
****
The Ordinary Layout for the Ergodox EZ keyboard, v4
Modifications from default by Nicholas Keene ergodoxez@nicholaskeene.com
No rights reserved. This software is in the public domain. Credit me if you are friendly but if you're a jerk don't bother.
Details: readme.md
https://github.com/nrrkeene/qmk_firmware/tree/master/keyboard/ergodox_ez/keymaps/ordinary

View file

@ -15,6 +15,15 @@
#include "keymap_extras/keymap_spanish.h"
#include "keymap_extras/keymap_bepo.h"
/**
* This layout was generated using the ErgodoxLayoutGenerator (ELG). You can download it from https://github.com/sboesebeck/ErgodoxLayoutGenerator/releases
* documentation about it can be found here https://boesebeck.name/2016/04/16/ergodoxlayoutgenerator-documentation/
* Thanks to the team of Erez Zukerman for building the great Ergodox-EZ!
*
* use at own risk!
**/
#define BASE 0
#define SYMB 1
#define MDIA 2
@ -23,24 +32,73 @@
#define EGOS 5
#define SMLY_TOG_QUOT 0
#define M_TOGGLE_5 1
#define TGH_NUM 2
#define M_DE_OSX_PLUS_CTRLALT 3
#define SM_KISS 4
#define SM_FROWN 5
#define SM_CRY 6
#define SM_SMILE 7
#define SM_SMIRK 8
#define M_LGUI_SHFT 9
#define SM_HEART 10
#define TOG_HLD_MDIA 11
#define SM_LAUGH 12
#define SM_SAD 13
#define M_DE_OSX_CIRC_CTRLCMD 14
#define M_MEH_SH_ACUT 15
//Layout keymap.c generated with ErgodoxLayoutGenerator V1.0BETA1
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/**
* Layer: BASE
* /-------------------//-------------------//-------------------//-------------------//-------------------//-------------------//-------------------/ /-------------------//-------------------//-------------------//-------------------//-------------------//-------------------//-------------------/
* | ESC | 1 | 2 | 3 | 4 | 5 | Hold or toggle | | Hold or toggle | 6 | 7 | 8 | 9 | 0 | ß |
* | | | | | | | Layer NUMB | | Layer MDIA | | | | | | |
* /-------------------//-------------------//-------------------//-------------------//-------------------//-------------------//-------------------/ /-------------------//-------------------//-------------------//-------------------//-------------------//-------------------//-------------------/
* | TAB | Q | W | E | R | T | Cmd | | Cmd | Z | U | I | O | P | Ü |
* | | | | | | | | | | | | | | | |
* /-------------------//-------------------//-------------------//-------------------//-------------------//-------------------/\-------------------\ \-------------------\/-------------------//-------------------//-------------------//-------------------//-------------------//-------------------/
* | Alt | A | S | D | F | G | | H | J | K | L | Ö | Ä |
* | | | | | | | | | | | | | ALT |
* /-------------------//-------------------//-------------------//-------------------//-------------------//-------------------//-------------------/ /-------------------//-------------------//-------------------//-------------------//-------------------//-------------------//-------------------/
* | Shift | Y | X | C | V | B | Alt | | Alt | N | M | , | . | - | Shift |
* | | Ctrl | | | | | | | | | | | | Ctrl | |
* \-------------------\\-------------------\\-------------------\\-------------------\\-------------------\\-------------------\\-------------------\ \-------------------\\-------------------\\-------------------\\-------------------\\-------------------\\-------------------\\-------------------\
*
*
* /-------------------//-------------------//-------------------//-------------------//-------------------/ /-------------------//-------------------//-------------------//-------------------//-------------------/
* | < | LongPress / Type | LongPress / Type | Shift+Ctrl | Type | | # | ACUT | CMD+Shift | ALT+Shift | + |
* | SYMB | DE_OSX_CIRC_CTRLCMD| DE_OSX_PLUS_CTRAlt | | Toggle SMLY | | Meh | Hyper | | | SYMB |
* \-------------------\\-------------------\\-------------------\\-------------------\/-------------------//-------------------/ /-------------------//-------------------/ \-------------------\\-------------------\\-------------------\\-------------------\\-------------------\
* | HOME | END | | LEFT | RIGHT |
* | | | | | |
* \-------------------\/-------------------/ /-------------------/\-------------------\
* | PGUP | | UP |
* | | | |
* /-------------------//-------------------//-------------------/ /-------------------//-------------------//-------------------/
* | BSPC | DEL | PGDN | | DOWN | ENT | SPC |
* | | | | | | | |
* \-------------------\\-------------------\\-------------------\ \-------------------\\-------------------\\-------------------\
*
*
**/
[BASE]=KEYMAP(
//left half
KC_ESC, DE_OSX_1, DE_OSX_2, DE_OSX_3, DE_OSX_4, DE_OSX_5, M(TGH_NUM),
@ -60,6 +118,39 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_LEFT, KC_RIGHT,
KC_UP,
KC_DOWN, KC_ENT, KC_SPC),
/**
* Layer: SYMB
* /-----------//-----------//-----------//-----------//-----------//-----------//-----------/ /-----------//-----------//-----------//-----------//-----------//-----------//-----------/
* | APPLICATION| F1 | F2 | F3 | F4 | F5 | F5 | | F6 | F6 | F7 | F8 | F9 | F10 | F11 |
* | | | | | | | | | | | | | | | |
* /-----------//-----------//-----------//-----------//-----------//-----------//-----------/ /-----------//-----------//-----------//-----------//-----------//-----------//-----------/
* | | < | > | ! | ? | | | | | \ | [ | ] | < | > | ! |
* | | | | | | | | | | | | | | | |
* /-----------//-----------//-----------//-----------//-----------//-----------/\-----------\ \-----------\/-----------//-----------//-----------//-----------//-----------//-----------/
* | | # | $ | \ | / | . | | / | ( | ) | { | } | # |
* | | | | | | | | | | | | | |
* /-----------//-----------//-----------//-----------//-----------//-----------//-----------/ /-----------//-----------//-----------//-----------//-----------//-----------//-----------/
* | | | < | % | | | ~ | | | | | | ~ | | | | |
* | | | | | | | | | | | | | | | |
* \-----------\\-----------\\-----------\\-----------\\-----------\\-----------\\-----------\ \-----------\\-----------\\-----------\\-----------\\-----------\\-----------\\-----------\
*
*
* /-----------//-----------//-----------//-----------//-----------/ /-----------//-----------//-----------//-----------//-----------/
* | | | | | | | ' | DQOT | | Toggle 5 | |
* | | | | | | | | | | | |
* \-----------\\-----------\\-----------\\-----------\/-----------//-----------/ /-----------//-----------/ \-----------\\-----------\\-----------\\-----------\\-----------\
* | | | | F13 | F12 |
* | | | | | |
* \-----------\/-----------/ /-----------/\-----------\
* | | | F14 |
* | | | |
* /-----------//-----------//-----------/ /-----------//-----------//-----------/
* | | DEL | | | F15 | | |
* | | | | | | | |
* \-----------\\-----------\\-----------\ \-----------\\-----------\\-----------\
*
*
**/
[SYMB]=KEYMAP(
//left half
KC_APPLICATION, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F5,
@ -79,6 +170,39 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_F13, KC_F12,
KC_F14,
KC_F15, KC_TRNS, KC_TRNS),
/**
* Layer: MDIA
* /-----//-----//-----//-----//-----//-----//-----/ /-----//-----//-----//-----//-----//-----//-----/
* | | | | | | | | | | | | | | | |
* | | | | | | | | | | | | | | | |
* /-----//-----//-----//-----//-----//-----//-----/ /-----//-----//-----//-----//-----//-----//-----/
* | | | BTN1 | U | BTN2 | U | | | | | | | | | |
* | | | | | | | | | | | | | | | |
* /-----//-----//-----//-----//-----//-----/\-----\ \-----\/-----//-----//-----//-----//-----//-----/
* | | | L | D | R | D | | | | | | | |
* | | | | | | | | | | | | | |
* /-----//-----//-----//-----//-----//-----//-----/ /-----//-----//-----//-----//-----//-----//-----/
* | | | L | D | R | BTN3 | | | | | | | | UP | |
* | | | | | | | | | | | | | | | |
* \-----\\-----\\-----\\-----\\-----\\-----\\-----\ \-----\\-----\\-----\\-----\\-----\\-----\\-----\
*
*
* /-----//-----//-----//-----//-----/ /-----//-----//-----//-----//-----/
* | | | | | | | | | LEFT | DOWN | RIGHT|
* | | | | | | | | | | | |
* \-----\\-----\\-----\\-----\/-----//-----/ /-----//-----/ \-----\\-----\\-----\\-----\\-----\
* | | | | MPRV | MNXT |
* | | | | | |
* \-----\/-----/ /-----/\-----\
* | | | VOLU |
* | | | |
* /-----//-----//-----/ /-----//-----//-----/
* | | | | | VOLD | MUTE | MPLY |
* | | | | | | | |
* \-----\\-----\\-----\ \-----\\-----\\-----\
*
*
**/
[MDIA]=KEYMAP(
//left half
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
@ -90,14 +214,47 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS,
//right half
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPLY,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_VOLU, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_VOLD, KC_TRNS, KC_MPRV, KC_MNXT, KC_UP, KC_TRNS,
KC_MUTE, KC_TRNS, KC_LEFT, KC_DOWN, KC_RIGHT,
KC_TRNS, KC_TRNS,
KC_TRNS,
KC_TRNS, KC_TRNS, KC_WBAK),
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_UP, KC_TRNS,
KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_RIGHT,
KC_MPRV, KC_MNXT,
KC_VOLU,
KC_VOLD, KC_MUTE, KC_MPLY),
/**
* Layer: SMLY
* /--------//--------//--------//--------//--------//--------//--------/ /--------//--------//--------//--------//--------//--------//--------/
* | | | | | | | | | Typing | Typing | Typing | | | | |
* | | | | | | | | | SM_SMILE| SM_SMIRK| SM_LAUGH| | | | |
* /--------//--------//--------//--------//--------//--------//--------/ /--------//--------//--------//--------//--------//--------//--------/
* | | | | | | | | | | Typing | Typing | Typing | | | |
* | | | | | | | | | | SM_FROWN| SM_SAD | SM_CRY | | | |
* /--------//--------//--------//--------//--------//--------/\--------\ \--------\/--------//--------//--------//--------//--------//--------/
* | | | | | | | | Typing | Typing | | | | |
* | | | | | | | | SM_HEART| SM_KISS | | | | |
* /--------//--------//--------//--------//--------//--------//--------/ /--------//--------//--------//--------//--------//--------//--------/
* | | | | | | | | | | | | | | | |
* | | | | | | | | | | | | | | | |
* \--------\\--------\\--------\\--------\\--------\\--------\\--------\ \--------\\--------\\--------\\--------\\--------\\--------\\--------\
*
*
* /--------//--------//--------//--------//--------/ /--------//--------//--------//--------//--------/
* | | | | | | | | | | | |
* | | | | | | | | | | | |
* \--------\\--------\\--------\\--------\/--------//--------/ /--------//--------/ \--------\\--------\\--------\\--------\\--------\
* | | | | | |
* | | | | | |
* \--------\/--------/ /--------/\--------\
* | | | |
* | | | |
* /--------//--------//--------/ /--------//--------//--------/
* | | | | | | | |
* | | | | | | | |
* \--------\\--------\\--------\ \--------\\--------\\--------\
*
*
**/
[SMLY]=KEYMAP(
//left half
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
@ -117,6 +274,39 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_TRNS, KC_TRNS,
KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS),
/**
* Layer: NUMB
* /----//----//----//----//----//----//----/ /----//----//----//----//----//----//----/
* | | | | | | | | | | F6 | F7 | F8 | F9 | F10 | F11 |
* | | | | | | | | | | | | | | | |
* /----//----//----//----//----//----//----/ /----//----//----//----//----//----//----/
* | | | | UP | | | | | | / | 7 | 8 | 9 | * | F12 |
* | | | | | | | | | | | | | | | |
* /----//----//----//----//----//----/\----\ \----\/----//----//----//----//----//----/
* | | | LEFT| DOWN| RGHT| | | / | 4 | 5 | 6 | + | - |
* | | | | | | | | | | | | | |
* /----//----//----//----//----//----//----/ /----//----//----//----//----//----//----/
* | | | | | | | | | | % | 1 | 2 | 3 | | |
* | | | | | | | | | | | | | | | |
* \----\\----\\----\\----\\----\\----\\----\ \----\\----\\----\\----\\----\\----\\----\
*
*
* /----//----//----//----//----/ /----//----//----//----//----/
* | | | | | | | 0 | . | , | = | |
* | | | | | | | | | | | |
* \----\\----\\----\\----\/----//----/ /----//----/ \----\\----\\----\\----\\----\
* | | | | | |
* | | | | | |
* \----\/----/ /----/\----\
* | | | |
* | | | |
* /----//----//----/ /----//----//----/
* | | | | | | | |
* | | | | | | | |
* \----\\----\\----\ \----\\----\\----\
*
*
**/
[NUMB]=KEYMAP(
//left half
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
@ -136,6 +326,39 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_TRNS, KC_TRNS,
KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS),
/**
* Layer: EGOS
* /--------//--------//--------//--------//--------//--------//--------/ /--------//--------//--------//--------//--------//--------//--------/
* | | | | | | | | | | | | | | | |
* | | | | | | | | | | | | | | | |
* /--------//--------//--------//--------//--------//--------//--------/ /--------//--------//--------//--------//--------//--------//--------/
* | | | | | | | | | | | | | | | |
* | | | | | | | | | | | | | | | |
* /--------//--------//--------//--------//--------//--------/\--------\ \--------\/--------//--------//--------//--------//--------//--------/
* | Shift | | | | | | | | | | | | |
* | | | | | | | | | | | | | |
* /--------//--------//--------//--------//--------//--------//--------/ /--------//--------//--------//--------//--------//--------//--------/
* | | | | | | | | | | | | | | | |
* | | | | | | | | | | | | | | | |
* \--------\\--------\\--------\\--------\\--------\\--------\\--------\ \--------\\--------\\--------\\--------\\--------\\--------\\--------\
*
*
* /--------//--------//--------//--------//--------/ /--------//--------//--------//--------//--------/
* | Ctrl | | | | | | | | | Toggle 5| |
* | | | | | | | | | | | |
* \--------\\--------\\--------\\--------\/--------//--------/ /--------//--------/ \--------\\--------\\--------\\--------\\--------\
* | F1 | F2 | | | |
* | | | | | |
* \--------\/--------/ /--------/\--------\
* | F3 | | |
* | | | |
* /--------//--------//--------/ /--------//--------//--------/
* | SPC | Ctrl | F4 | | | | |
* | | | | | | | |
* \--------\\--------\\--------\ \--------\\--------\\--------\
*
*
**/
[EGOS]=KEYMAP(
//left half
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
@ -259,7 +482,7 @@ case M_LGUI_SHFT:
if (record->event.pressed){
return MACRO(DOWN(KC_LGUI),DOWN(KC_LSFT),END);
}else{
return MACRO(UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),U(LGUI),U(LSFT),END);
return MACRO(UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),U(LGUI),U(LSFT),END);
}
break;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 282 KiB

After

Width:  |  Height:  |  Size: 297 KiB

View file

@ -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/).

View file

@ -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

View file

@ -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();
}
};

View file

@ -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

View file

@ -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 |

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 767 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 381 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 414 KiB

View file

@ -49,9 +49,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_D, KC_H, KC_T, KC_N, KC_S, KC_MINS,
KC_ENT, KC_B, KC_M, KC_W, KC_V, KC_Z , KC_RSFT,
KC_UP, KC_DOWN,KC_LBRC,KC_RBRC, MO(SYMB),
KC_HOME,KC_END,
KC_HOME, KC_END,
KC_RALT,
KC_FN1,KC_SPC,KC_RCTL
MO(MDIA),KC_SPC,KC_RCTL
),
/* Keymap 1: Symbol Layer
*
@ -102,7 +102,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_NO, PV_NUM, PV_NUM, PV_NUM, PV_NUM, PV_NUM, PV_STAR,
KC_NO, PV_LS, PV_LT, PV_LP, PV_LH, PV_STAR,
KC_NO, PV_LS, PV_LK, PV_LW, PV_LR, PV_STAR, PV_STAR,
KC_NO, KC_NO, KC_NO, KC_TRNS, KC_TRNS,
KC_TRNS,KC_NO, KC_NO, KC_TRNS, KC_TRNS,
KC_NO, KC_NO,
KC_NO,
PV_A, PV_O, KC_NO,
@ -111,10 +111,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
PV_STAR, PV_NUM, PV_NUM, PV_NUM, PV_NUM, PV_NUM, PV_NUM,
PV_STAR, PV_RF, PV_RP, PV_RL, PV_RT, PV_RD,
PV_STAR, PV_STAR, PV_RR, PV_RB, PV_RG, PV_RS, PV_RZ,
KC_TRNS, KC_TRNS, KC_NO, KC_NO, KC_NO,
KC_TRNS, KC_TRNS, KC_NO, KC_NO, KC_TRNS,
KC_NO, KC_NO,
KC_NO,
KC_FN1, PV_E, PV_U
KC_TRNS,PV_E, PV_U
),
/* Keymap 3: Media and mouse keys
@ -122,19 +122,19 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* ,--------------------------------------------------. ,--------------------------------------------------.
* | | | | | | | | | | | | | | | |
* |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
* | | | | MsUp | | | | | | | | | | | |
* | | | | MsUp | | | | | | | Back | | Frwd | | |
* |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
* | | |MsLeft|MsDown|MsRght| |------| |------| | | | | | Play |
* | | |MsLeft|MsDown|MsRght| |------| |------| | Prev | Play | Next | | |
* |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
* | | | | | | | | | | | | Prev | Next | | |
* | | | | | | | | | | | | | | | |
* `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
* | | | | Lclk | Rclk | |VolUp |VolDn | Mute | | |
* `----------------------------------' `----------------------------------'
* ,-------------. ,-------------.
* | | | | | |
* ,------|------|------| |------+------+------.
* | | | | | | |Brwser|
* | | |------| |------| |Back |
* | | | | | | | |
* | | |------| |------| | |
* | | | | | | | |
* `--------------------' `--------------------'
*/
@ -150,9 +150,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
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_WBAK, KC_TRNS, KC_WFWD, KC_TRNS, KC_TRNS,
KC_TRNS, KC_MPRV, KC_MPLY, KC_MNXT, 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,
@ -171,15 +171,19 @@ void toggle_steno(int pressed)
if (pressed) {
if (layer != STEN) layer_on(STEN); else layer_off(STEN);
register_code(PV_LS);
register_code(PV_LP);
register_code(PV_LH);
register_code(PV_RF);
register_code(PV_RT);
register_code(PV_LR);
register_code(PV_O);
register_code(PV_RL);
register_code(PV_RG);
} else {
unregister_code(PV_LS);
unregister_code(PV_LP);
unregister_code(PV_LH);
unregister_code(PV_RF);
unregister_code(PV_RT);
unregister_code(PV_LR);
unregister_code(PV_O);
unregister_code(PV_RL);
unregister_code(PV_RG);
}
}

View file

@ -3,8 +3,8 @@
- Layer 0: Non-ANSI Dvorak layout, with modified modifiers — all
modifiers on thumb keys, as well as return and space.
- Layer 1: Default symbol layout.
- Layer 2: Default media/mouse layout.
- Layer 3: Plover-oriented stenography layer.
- Layer 2: Plover-oriented stenography layer.
- Layer 3: Extended media/mouse layout.
## Unusual features
The Plover key (top right key on the left half) also sends my Plover
@ -12,8 +12,6 @@ The Plover key (top right key on the left half) also sends my Plover
layer, so you can toggle between steno and typing modes with a single
keypress.
If you want to use this feature, you'll need to add:
"SH-FT": "{PLOVER:TOGGLE}"
to your Plover dictionary.
If you want to use this feature, you'll need to add the
`commands.json` dictionary to your Plover dictionaries, or define the
toggle stroke (`PHROLG`) yourself.

View file

@ -55,11 +55,11 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* ,--------------------------------------------------. ,--------------------------------------------------.
* | | F1 | F2 | F3 | F4 | F5 | | | | F6 | F7 | F8 | F9 | F10 | F11 |
* |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
* | | ! | @ | { | } | | | | | | / | 7 | 8 | 9 | * | F12 |
* | | [ | ] | { | } | | | | | / | 7 | 8 | 9 | * | F12 |
* |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
* | | # | $ | ( | ) | ` |------| |------| - | 4 | 5 | 6 | + | |
* | | < | > | ( | ) | |------| |------| - | 4 | 5 | 6 | + | |
* |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
* | | % | ^ | [ | ] | ~ | | | | & | 1 | 2 | 3 | = | |
* | | | | | | | | | | & | 1 | 2 | 3 | = | |
* `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
* | | | | | | | 0 | . | | | |
* `----------------------------------' `----------------------------------'
@ -75,9 +75,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[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_LBRC,KC_RBRC,KC_LCBR,KC_RCBR,KC_TRNS,KC_TRNS,
KC_TRNS,KC_LABK,KC_RABK,KC_LPRN,KC_RPRN,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,
@ -109,8 +109,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* | | | | | |
* ,------|------|------| |------+------+------.
* | | | | | | | |
* | | |------| |------| | |
* | | | | | | | |
* | | |------| |------| C | V |
* | | | | | X | | |
* `--------------------' `--------------------'
*/
// MEDIA AND MOUSE
@ -129,9 +129,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
LGUI(KC_LBRC), KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_MPLY,
KC_TRNS, LSFT(KC_SPC), KC_SPC , 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_TRNS, KC_TRNS, KC_TRNS
LGUI(KC_X), LGUI(KC_C), LGUI(KC_V)
),
};
@ -139,6 +139,8 @@ const uint16_t PROGMEM fn_actions[] = {
[1] = ACTION_LAYER_TAP_TOGGLE(SYMB) // FN1 - Momentary Layer 1 (Symbols)
};
// action_get_macro() is unused — remove the “#if 0” and “#endif” lines to reenable
#if 0
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
// MACRODOWN only works in this function
@ -153,6 +155,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
}
return MACRO_NONE;
};
#endif
// Runs just one time when the keyboard initializes.
void matrix_init_user(void) {

View file

@ -12,8 +12,9 @@ void matrix_scan_user(void) {
}
__attribute__ ((weak))
void process_action_user(keyrecord_t *record) {
bool process_action_user(keyrecord_t *record) {
// leave this function blank - it can be defined in a keymap file
return true;
}
__attribute__ ((weak))
@ -35,11 +36,11 @@ void matrix_scan_kb(void) {
matrix_scan_user();
}
void process_action_kb(keyrecord_t *record) {
bool process_action_kb(keyrecord_t *record) {
// put your per-action keyboard code here
// runs for every action, just before processing by the firmware
process_action_user(record);
return process_action_user(record);
}
void led_set_kb(uint8_t usb_led) {

View file

@ -75,7 +75,7 @@ inline void gh60_wasd_leds_off(void) { DDRF &= ~(1<<7); PORTF &= ~(1<<7); }
void matrix_init_user(void);
void matrix_scan_user(void);
void process_action_user(keyrecord_t *record);
bool process_action_user(keyrecord_t *record);
void led_set_user(uint8_t usb_led);
#endif

View file

@ -19,8 +19,7 @@ extern keymap_config_t keymap_config;
#define _DVORAK 2
#define _LOWER 3
#define _RAISE 4
#define _MUSIC 5
#define _PLOVER 6
#define _PLOVER 5
#define _ADJUST 16
// Macro name shortcuts
@ -30,14 +29,9 @@ extern keymap_config_t keymap_config;
#define LOWER M(_LOWER)
#define RAISE M(_RAISE)
#define M_BL 5
#define AUD_OFF M(6)
#define AUD_ON M(7)
#define MUS_OFF M(8)
#define MUS_ON M(9)
#define VC_IN M(10)
#define VC_DE M(11)
#define PLOVER M(12)
#define EXT_PLV M(13)
#define TOG_OUT M(14)
// Fillers to make layering more clear
#define _______ KC_TRNS
@ -105,7 +99,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* |------+------+------+------+------+-------------+------+------+------+------+------|
* | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | |
* |------+------+------+------+------+------|------+------+------+------+------+------|
* | | F7 | F8 | F9 | F10 | F11 | F12 | | | | |Enter |
* | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | | |Enter |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | Next | Vol- | Vol+ | Play |
* `-----------------------------------------------------------------------------------'
@ -113,7 +107,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_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_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}
},
@ -123,7 +117,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* |------+------+------+------+------+-------------+------+------+------+------+------|
* | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ |
* |------+------+------+------+------+------|------+------+------+------+------+------|
* | | F7 | F8 | F9 | F10 | F11 | F12 | | | | |Enter |
* | | F7 | F8 | F9 | F10 | F11 | F12 |ISO # |ISO / | | |Enter |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | Next | Vol- | Vol+ | Play |
* `-----------------------------------------------------------------------------------'
@ -131,27 +125,17 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_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_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, _______, _______, _______},
{_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
},
/* Music (reserved for process_action_user)
*
*/
[_MUSIC] = {
{XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX},
{XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX},
{XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX},
{XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, LOWER, XXXXXXX, XXXXXXX, RAISE, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX}
},
/* Plover layer (http://opensteno.org)
* ,-----------------------------------------------------------------------------------.
* | # | # | # | # | # | # | # | # | # | # | # | # |
* |------+------+------+------+------+-------------+------+------+------+------+------|
* | | S | T | P | H | * | * | F | P | L | T | D |
* |------+------+------+------+------+------|------+------+------+------+------+------|
* | | S | K | W | R | * | * | R | B | G | S | Z |
* |TogOut| S | K | W | R | * | * | R | B | G | S | Z |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | Exit | | | A | O | | E | U | | | |
* `-----------------------------------------------------------------------------------'
@ -160,7 +144,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_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},
{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}
},
@ -177,8 +161,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
*/
[_ADJUST] = {
{_______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL},
{_______, _______, _______, AUD_ON, AUD_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, PLOVER, _______},
{_______, VC_DE, VC_IN, MUS_ON, MUS_OFF, _______, _______, _______, _______, _______, _______, _______},
{_______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, PLOVER, _______},
{_______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, _______, _______, _______, _______, _______},
{_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}
}
@ -204,7 +188,6 @@ 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
@ -269,53 +252,6 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
unregister_code(KC_RSFT);
}
break;
case 6:
if (record->event.pressed) {
#ifdef AUDIO_ENABLE
audio_off();
#endif
}
break;
case 7:
if (record->event.pressed) {
#ifdef AUDIO_ENABLE
audio_on();
PLAY_NOTE_ARRAY(tone_startup, false, 0);
#endif
}
break;
case 8:
if (record->event.pressed) {
#ifdef AUDIO_ENABLE
layer_off(_MUSIC);
stop_all_notes();
#endif
}
break;
case 9:
if (record->event.pressed) {
#ifdef AUDIO_ENABLE
PLAY_NOTE_ARRAY(music_scale, false, 0);
layer_on(_MUSIC);
#endif
}
break;
case 10:
if (record->event.pressed) {
#ifdef AUDIO_ENABLE
voice_iterate();
PLAY_NOTE_ARRAY(music_scale, false, 0);
#endif
}
break;
case 11:
if (record->event.pressed) {
#ifdef AUDIO_ENABLE
voice_deiterate();
PLAY_NOTE_ARRAY(music_scale, false, 0);
#endif
}
break;
case 12:
if (record->event.pressed) {
#ifdef AUDIO_ENABLE
@ -325,7 +261,6 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
layer_off(_RAISE);
layer_off(_LOWER);
layer_off(_ADJUST);
layer_off(_MUSIC);
layer_on(_PLOVER);
if (!eeconfig_is_enabled()) {
eeconfig_init();
@ -343,7 +278,11 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
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;
};
@ -361,19 +300,4 @@ 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

View file

@ -0,0 +1,2 @@
# The Default Planck Layout

View file

@ -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);
}
}
}

View file

@ -0,0 +1,5 @@
AUDIO_ENABLE = yes
NKRO_ENABLE = yes
MIDI_ENABLE = yes
BACKLIGHT_ENABLE = no
COMMAND_ENABLE = no

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View file

@ -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;
};

View file

@ -0,0 +1 @@
Focus of this particular keymap is to enable easy transition from more traditional keyboards to OLKB Planck.

View file

@ -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.

View file

@ -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

View file

@ -0,0 +1,2 @@
AUDIO_ENABLE = no
NKRO_ENABLE = yes

View file

@ -73,7 +73,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* disable debug print */
//#define NO_DEBUG
#define NO_DEBUG
/* disable print */
//#define NO_PRINT

View file

@ -38,6 +38,7 @@
#define MACRO_AUDIO_OFF 17
#define MACRO_INC_VOICE 18
#define MACRO_DEC_VOICE 19
#define MACRO_BACKLIGHT 20
#define M_QWRTY M(MACRO_QWERTY)
#define M_COLMK M(MACRO_COLEMAK)
@ -53,6 +54,7 @@
#define TMPO_UP M(MACRO_TEMPO_U)
#define TMPO_DN M(MACRO_TEMPO_D)
#define TMPO_DF M(MACRO_TONE_DEFAULT)
#define M_BACKL M(MACRO_BACKLIGHT)
#define MUS_ON M(MACRO_MUSIC_ON)
@ -96,7 +98,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[LAYER_QWERTY] = { /* 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_BSPC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT },
{ 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 },
{ KC_LCTL, KC_LGUI, M_FUNCT, KC_LALT, M_RAISE, KC_SPC, KC_SPC, M_LOWER, KC_UP, KC_DOWN, KC_LEFT, KC_RGHT },
},
@ -115,7 +117,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[LAYER_COLEMAK] = { /* COLEMAK */
{ KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_ESC },
{ 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_BSPC, 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_LCTL, KC_LGUI, M_FUNCT, KC_LALT, M_RAISE, KC_SPC, KC_SPC, M_LOWER, KC_UP, KC_DOWN, KC_LEFT, KC_RGHT },
},
@ -217,7 +219,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[LAYER_ADJUST] = { /* ADJUST */
{ _______, TIMBR_1, TIMBR_2, TIMBR_3, TIMBR_4, TMPO_UP, TMPO_DN, TMPO_DF, MUS_ON, MUS_OFF, AUD_ON, AUD_OFF },
{ _______, M_QWRTY, M_COLMK, M_DVORK, _______, _______, _______, _______, _______, _______, _______, _______ },
{ _______, _______, _______, _______, _______, RESET, _______, M_MOUSE, _______, _______, _______, _______ },
{ _______, _______, _______, _______, M_BACKL, RESET, _______, M_MOUSE, _______, _______, _______, _______ },
{ _______, _______, _______, _______, _______, _______, _______, _______, VC_UP, VC_DOWN, _______, _______ },
},
@ -337,6 +339,15 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
}
break;
#ifdef BACKLIGHT_ENABLE
case MACRO_BACKLIGHT:
if (record->event.pressed)
{
backlight_step();
}
#endif
#ifdef MOUSEKEY_ENABLE
case MACRO_MOUSE:

View file

@ -1,11 +1,12 @@
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
CONSOLE_ENABLE = yes # Console for debug(+400)
CONSOLE_ENABLE = no # Console for debug(+400)
COMMAND_ENABLE = yes # Commands for debug and configuration
NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
MIDI_ENABLE = no # MIDI controls
AUDIO_ENABLE = no # Audio output on port C6
AUDIO_ENABLE = yes # Audio output on port C6
UNICODE_ENABLE = no # Unicode
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time.
@ -13,4 +14,4 @@ RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
CONFIG_H = keymaps/$(KEYMAP)/config.h
CONFIG_H = keymaps/$(KEYMAP)/config.h

View file

@ -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

View file

@ -0,0 +1 @@
UNICODE_ENABLE = yes # Unicode

View file

@ -7,7 +7,12 @@ __attribute__ ((weak))
void matrix_scan_user(void) {}
__attribute__ ((weak))
void process_action_user(keyrecord_t *record) {}
bool process_action_user(keyrecord_t *record) {
return true;
}
__attribute__ ((weak))
void led_set_user(uint8_t usb_led) {}
void matrix_init_kb(void) {
#ifdef BACKLIGHT_ENABLE
@ -29,12 +34,26 @@ void matrix_scan_kb(void) {
matrix_scan_user();
}
void process_action_kb(keyrecord_t *record) {
process_action_user(record);
bool process_action_kb(keyrecord_t *record) {
return process_action_user(record);
}
void led_set_kb(uint8_t usb_led) {
// put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
led_set_user(usb_led);
}
#ifdef BACKLIGHT_ENABLE
#define CHANNEL OCR1C
#define BREATHING_NO_HALT 0
#define BREATHING_HALT_OFF 1
#define BREATHING_HALT_ON 2
static uint8_t breath_intensity;
static uint8_t breath_speed;
static uint16_t breathing_index;
static uint8_t breathing_halt;
void backlight_init_ports()
{
@ -60,22 +79,22 @@ void backlight_init_ports()
TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;
backlight_init();
breathing_defaults();
}
void backlight_set(uint8_t level)
{
// Prevent backlight blink on lowest level
PORTB &= ~(_BV(PORTB7));
if ( level == 0 )
{
// Turn off PWM control on PB7, revert to output low.
TCCR1A &= ~(_BV(COM1C1));
CHANNEL = 0x0;
// Prevent backlight blink on lowest level
PORTB &= ~(_BV(PORTB7));
}
else if ( level == BACKLIGHT_LEVELS )
{
// Prevent backlight blink on lowest level
PORTB &= ~(_BV(PORTB7));
// Turn on PWM control of PB7
TCCR1A |= _BV(COM1C1);
// Set the brightness
@ -83,13 +102,205 @@ void backlight_set(uint8_t level)
}
else
{
// Prevent backlight blink on lowest level
PORTB &= ~(_BV(PORTB7));
// Turn on PWM control of PB7
TCCR1A |= _BV(COM1C1);
// Set the brightness
CHANNEL = 0xFFFF >> ((BACKLIGHT_LEVELS - level) * ((BACKLIGHT_LEVELS + 1) / 2));
}
breathing_intensity_default();
}
void breathing_enable(void)
{
if (get_backlight_level() == 0)
{
breathing_index = 0;
}
else
{
// Set breathing_index to be at the midpoint (brightest point)
breathing_index = 0x20 << breath_speed;
}
breathing_halt = BREATHING_NO_HALT;
// Enable breathing interrupt
TIMSK1 |= _BV(OCIE1A);
}
void breathing_pulse(void)
{
if (get_backlight_level() == 0)
{
breathing_index = 0;
}
else
{
// Set breathing_index to be at the midpoint + 1 (brightest point)
breathing_index = 0x21 << breath_speed;
}
breathing_halt = BREATHING_HALT_ON;
// Enable breathing interrupt
TIMSK1 |= _BV(OCIE1A);
}
void breathing_disable(void)
{
// Disable breathing interrupt
TIMSK1 &= ~_BV(OCIE1A);
backlight_set(get_backlight_level());
}
void breathing_self_disable(void)
{
if (get_backlight_level() == 0)
{
breathing_halt = BREATHING_HALT_OFF;
}
else
{
breathing_halt = BREATHING_HALT_ON;
}
//backlight_set(get_backlight_level());
}
void breathing_toggle(void)
{
if (!is_breathing())
{
if (get_backlight_level() == 0)
{
breathing_index = 0;
}
else
{
// Set breathing_index to be at the midpoint + 1 (brightest point)
breathing_index = 0x21 << breath_speed;
}
breathing_halt = BREATHING_NO_HALT;
}
// Toggle breathing interrupt
TIMSK1 ^= _BV(OCIE1A);
// Restore backlight level
if (!is_breathing())
{
backlight_set(get_backlight_level());
}
}
bool is_breathing(void)
{
return (TIMSK1 && _BV(OCIE1A));
}
void breathing_intensity_default(void)
{
//breath_intensity = (uint8_t)((uint16_t)100 * (uint16_t)get_backlight_level() / (uint16_t)BACKLIGHT_LEVELS);
breath_intensity = ((BACKLIGHT_LEVELS - get_backlight_level()) * ((BACKLIGHT_LEVELS + 1) / 2));
}
void breathing_intensity_set(uint8_t value)
{
breath_intensity = value;
}
void breathing_speed_default(void)
{
breath_speed = 4;
}
void breathing_speed_set(uint8_t value)
{
bool is_breathing_now = is_breathing();
uint8_t old_breath_speed = breath_speed;
if (is_breathing_now)
{
// Disable breathing interrupt
TIMSK1 &= ~_BV(OCIE1A);
}
breath_speed = value;
if (is_breathing_now)
{
// Adjust index to account for new speed
breathing_index = (( (uint8_t)( (breathing_index) >> old_breath_speed ) ) & 0x3F) << breath_speed;
// Enable breathing interrupt
TIMSK1 |= _BV(OCIE1A);
}
}
void breathing_speed_inc(uint8_t value)
{
if ((uint16_t)(breath_speed - value) > 10 )
{
breathing_speed_set(0);
}
else
{
breathing_speed_set(breath_speed - value);
}
}
void breathing_speed_dec(uint8_t value)
{
if ((uint16_t)(breath_speed + value) > 10 )
{
breathing_speed_set(10);
}
else
{
breathing_speed_set(breath_speed + value);
}
}
void breathing_defaults(void)
{
breathing_intensity_default();
breathing_speed_default();
breathing_halt = BREATHING_NO_HALT;
}
/* Breathing Sleep LED brighness(PWM On period) table
* (64[steps] * 4[duration]) / 64[PWM periods/s] = 4 second breath cycle
*
* http://www.wolframalpha.com/input/?i=%28sin%28+x%2F64*pi%29**8+*+255%2C+x%3D0+to+63
* (0..63).each {|x| p ((sin(x/64.0*PI)**8)*255).to_i }
*/
static const uint8_t breathing_table[64] PROGMEM = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 6, 10,
15, 23, 32, 44, 58, 74, 93, 113, 135, 157, 179, 199, 218, 233, 245, 252,
255, 252, 245, 233, 218, 199, 179, 157, 135, 113, 93, 74, 58, 44, 32, 23,
15, 10, 6, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
ISR(TIMER1_COMPA_vect)
{
// CHANNEL = (pgm_read_byte(&breathing_table[ ( (uint8_t)( (breathing_index++) >> breath_speed ) ) & 0x3F ] )) * breath_intensity;
uint8_t local_index = ( (uint8_t)( (breathing_index++) >> breath_speed ) ) & 0x3F;
if (((breathing_halt == BREATHING_HALT_ON) && (local_index == 0x20)) || ((breathing_halt == BREATHING_HALT_OFF) && (local_index == 0x3F)))
{
// Disable breathing interrupt
TIMSK1 &= ~_BV(OCIE1A);
}
CHANNEL = (uint16_t)(((uint16_t)pgm_read_byte(&breathing_table[local_index]) * 257)) >> breath_intensity;
}
#endif

View file

@ -1,19 +1,7 @@
#ifndef PLANCK_H
#define PLANCK_H
#include "matrix.h"
#include "keymap_common.h"
#ifdef BACKLIGHT_ENABLE
#include "backlight.h"
#endif
#ifdef RGBLIGHT_ENABLE
#include "rgblight.h"
#endif
#include <stddef.h>
#include <avr/io.h>
#ifdef MIDI_ENABLE
#include <keymap_midi.h>
#endif
#include "quantum.h"
#define PLANCK_MIT( \
k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, \
@ -43,6 +31,24 @@
void matrix_init_user(void);
void matrix_scan_user(void);
void process_action_user(keyrecord_t *record);
bool process_action_user(keyrecord_t *record);
void led_set_user(uint8_t usb_led);
void backlight_init_ports(void);
void breathing_enable(void);
void breathing_pulse(void);
void breathing_disable(void);
void breathing_self_disable(void);
void breathing_toggle(void);
bool is_breathing(void);
void breathing_defaults(void);
void breathing_intensity_default(void);
void breathing_speed_default(void);
void breathing_speed_set(uint8_t value);
void breathing_speed_inc(uint8_t value);
void breathing_speed_dec(uint8_t value);
#endif

View file

@ -14,7 +14,6 @@
#define _DVORAK 2
#define _LOWER 3
#define _RAISE 4
#define _MUSIC 5
#define _ADJUST 16
// Macro name shortcuts
@ -24,12 +23,6 @@
#define LOWER M(_LOWER)
#define RAISE M(_RAISE)
#define M_BL 5
#define AUD_OFF M(6)
#define AUD_ON M(7)
#define MUS_OFF M(8)
#define MUS_ON M(9)
#define VC_IN M(10)
#define VC_DE M(11)
// Fillers to make layering more clear
#define _______ KC_TRNS
@ -108,7 +101,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* |------+------+------+------+------+-------------+------+------+------+------+------|
* | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | |
* |------+------+------+------+------+------|------+------+------+------+------+------|
* | | F7 | F8 | F9 | F10 | F11 | F12 | | | | |Enter |
* | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | | |Enter |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | Next | Vol- | Vol+ | Play |
* `-----------------------------------------------------------------------------------'
@ -117,7 +110,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
{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_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL},
{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_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}
},
@ -129,7 +122,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* |------+------+------+------+------+-------------+------+------+------+------+------|
* | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ |
* |------+------+------+------+------+------|------+------+------+------+------+------|
* | | F7 | F8 | F9 | F10 | F11 | F12 | | | | |Enter |
* | | F7 | F8 | F9 | F10 | F11 | F12 |ISO # |ISO / | | |Enter |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | Next | Vol- | Vol+ | Play |
* `-----------------------------------------------------------------------------------'
@ -138,21 +131,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
{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_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL},
{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_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, _______, _______, _______},
{_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
},
/* Music (reserved for process_action_user)
*
*/
[_MUSIC] = {
{XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX},
{XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX},
{XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX},
{XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX},
{XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, LOWER, XXXXXXX, XXXXXXX, RAISE, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX}
},
/* Adjust (Lower + Raise)
* ,-----------------------------------------------------------------------------------.
* | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 |
@ -169,8 +151,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_ADJUST] = {
{KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12},
{_______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL},
{_______, _______, _______, AUD_ON, AUD_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______},
{_______, VC_DE, VC_IN, MUS_ON, MUS_OFF, _______, _______, _______, _______, _______, _______, _______},
{_______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______},
{_______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, _______, _______, _______, _______, _______},
{_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}
}
@ -193,7 +175,6 @@ float tone_qwerty[][2] = SONG(QWERTY_SOUND);
float tone_dvorak[][2] = SONG(DVORAK_SOUND);
float tone_colemak[][2] = SONG(COLEMAK_SOUND);
float music_scale[][2] = SONG(MUSIC_SCALE_SOUND);
float goodbye[][2] = SONG(GOODBYE_SOUND);
#endif
@ -257,53 +238,6 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
unregister_code(KC_RSFT);
}
break;
case 6:
if (record->event.pressed) {
#ifdef AUDIO_ENABLE
audio_off();
#endif
}
break;
case 7:
if (record->event.pressed) {
#ifdef AUDIO_ENABLE
audio_on();
PLAY_NOTE_ARRAY(start_up, false, 0);
#endif
}
break;
case 8:
if (record->event.pressed) {
#ifdef AUDIO_ENABLE
layer_off(_MUSIC);
stop_all_notes();
#endif
}
break;
case 9:
if (record->event.pressed) {
#ifdef AUDIO_ENABLE
PLAY_NOTE_ARRAY(music_scale, false, 0);
layer_on(_MUSIC);
#endif
}
break;
case 10:
if (record->event.pressed) {
#ifdef AUDIO_ENABLE
voice_iterate();
PLAY_NOTE_ARRAY(music_scale, false, 0);
#endif
}
break;
case 11:
if (record->event.pressed) {
#ifdef AUDIO_ENABLE
voice_deiterate();
PLAY_NOTE_ARRAY(music_scale, false, 0);
#endif
}
break;
}
return MACRO_NONE;
};
@ -318,21 +252,6 @@ void matrix_init_user(void) {
#ifdef AUDIO_ENABLE
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)));
}
}
}
void play_goodbye_tone()
{
PLAY_NOTE_ARRAY(goodbye, false, 0);

View file

@ -11,8 +11,8 @@ void matrix_scan_user(void) {
};
__attribute__ ((weak))
void process_action_user(keyrecord_t *record) {
bool process_action_user(keyrecord_t *record) {
return true;
};
void matrix_init_kb(void) {
@ -36,8 +36,8 @@ void matrix_scan_kb(void) {
matrix_scan_user();
};
void process_action_kb(keyrecord_t *record) {
process_action_user(record);
bool process_action_kb(keyrecord_t *record) {
return process_action_user(record);
}
#ifdef BACKLIGHT_ENABLE

View file

@ -1,19 +1,7 @@
#ifndef PREONIC_H
#define PREONIC_H
#include "matrix.h"
#include "keymap_common.h"
#ifdef BACKLIGHT_ENABLE
#include "backlight.h"
#endif
#ifdef RGBLIGHT_ENABLE
#include "rgblight.h"
#endif
#include <stddef.h>
#include <avr/io.h>
#ifdef MIDI_ENABLE
#include <keymap_midi.h>
#endif
#include "quantum.h"
#define PREONIC_MIT( \
k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, \
@ -47,6 +35,6 @@
void matrix_init_user(void);
void matrix_scan_user(void);
void process_action_kb(keyrecord_t *record);
bool process_action_kb(keyrecord_t *record);
#endif

View file

@ -1,6 +1,6 @@
#include <stdio.h>
#include <string.h>
#include <math.h>
//#include <math.h>
#include <avr/pgmspace.h>
#include <avr/interrupt.h>
#include <avr/io.h>
@ -10,30 +10,28 @@
#include "eeconfig.h"
#ifdef VIBRATO_ENABLE
#include "vibrato_lut.h"
#endif
#define PI 3.14159265
#define CPU_PRESCALER 8
#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
// -----------------------------------------------------------------------------
// Timer Abstractions
// -----------------------------------------------------------------------------
float places[8] = {0, 0, 0, 0, 0, 0, 0, 0};
uint16_t place_int = 0;
bool repeat = true;
#endif
// 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));
// Fast PWM Mode Controls
#define TIMER_3_PERIOD ICR3
#define TIMER_3_DUTY_CYCLE OCR3A
// -----------------------------------------------------------------------------
void delay_us(int count) {
while(count--) {
_delay_us(1);
}
}
int voices = 0;
int voice_place = 0;
@ -45,26 +43,23 @@ 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;
int max = 0xFF;
float sum = 0;
float place = 0;
uint8_t * sample;
uint16_t sample_length = 0;
// float freq = 0;
bool notes = false;
bool note = false;
float note_frequency = 0;
float note_length = 0;
float note_tempo = TEMPO_DEFAULT;
float note_timbre = TIMBRE_DEFAULT;
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;
bool notes_repeat;
float notes_rest;
bool note_resting = false;
uint8_t current_note = 0;
uint8_t rest_counter = 0;
@ -77,20 +72,323 @@ float vibrato_rate = 0.125;
float polyphony_rate = 0;
bool inited = false;
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();
// 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);
audio_initialized = true;
}
void stop_all_notes()
{
if (!audio_initialized) {
audio_init();
}
voices = 0;
DISABLE_AUDIO_COUNTER_3_ISR;
DISABLE_AUDIO_COUNTER_3_OUTPUT;
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();
}
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) {
DISABLE_AUDIO_COUNTER_3_ISR;
DISABLE_AUDIO_COUNTER_3_OUTPUT;
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)
{
float freq;
if (playing_note) {
if (voices > 0) {
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 {
freq = frequencies[voice_place];
}
#else
freq = frequencies[voice_place];
#endif
} 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 {
freq = frequency;
}
#else
freq = frequency;
#endif
}
if (envelope_index < 65535) {
envelope_index++;
}
freq = voice_envelope(freq);
if (freq < 30.517578125) {
freq = 30.52;
}
TIMER_3_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER));
TIMER_3_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre);
}
}
if (playing_notes) {
if (note_frequency > 0) {
#ifdef VIBRATO_ENABLE
if (vibrato_strength > 0) {
freq = vibrato(note_frequency);
} else {
freq = note_frequency;
}
#else
freq = note_frequency;
#endif
if (envelope_index < 65535) {
envelope_index++;
}
freq = voice_envelope(freq);
TIMER_3_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER));
TIMER_3_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre);
} else {
TIMER_3_PERIOD = 0;
TIMER_3_DUTY_CYCLE = 0;
}
note_position++;
bool end_of_note = false;
if (TIMER_3_PERIOD > 0) {
end_of_note = (note_position >= (note_length / TIMER_3_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 {
DISABLE_AUDIO_COUNTER_3_ISR;
DISABLE_AUDIO_COUNTER_3_OUTPUT;
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;
envelope_index = 0;
note_frequency = (*notes_pointer)[current_note][0];
note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100);
}
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;
if (freq > 0) {
frequencies[voices] = freq;
volumes[voices] = vol;
voices++;
}
ENABLE_AUDIO_COUNTER_3_ISR;
ENABLE_AUDIO_COUNTER_3_OUTPUT;
}
}
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;
note_frequency = (*notes_pointer)[current_note][0];
note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100);
note_position = 0;
ENABLE_AUDIO_COUNTER_3_ISR;
ENABLE_AUDIO_COUNTER_3_OUTPUT;
}
}
bool is_playing_notes(void) {
return playing_notes;
}
bool is_audio_on(void) {
return (audio_config.enable != 0);
}
void audio_toggle(void) {
audio_config.enable ^= 1;
eeconfig_update_audio(audio_config.raw);
if (audio_config.enable)
audio_on_user();
}
void audio_on(void) {
audio_config.enable = 1;
eeconfig_update_audio(audio_config.raw);
audio_on_user();
}
void audio_off(void) {
@ -99,6 +397,7 @@ void audio_off(void) {
}
#ifdef VIBRATO_ENABLE
// Vibrato rate functions
void set_vibrato_rate(float rate) {
@ -127,9 +426,9 @@ void decrease_vibrato_strength(float change) {
vibrato_strength /= change;
}
#endif
#endif /* VIBRATO_STRENGTH_ENABLE */
#endif
#endif /* VIBRATO_ENABLE */
// Polyphony functions
@ -161,447 +460,35 @@ void set_timbre(float timbre) {
// Tempo functions
void set_tempo(float tempo) {
void set_tempo(uint8_t tempo) {
note_tempo = tempo;
}
void decrease_tempo(uint8_t tempo_change) {
note_tempo += (float) tempo_change;
note_tempo += tempo_change;
}
void increase_tempo(uint8_t tempo_change) {
if (note_tempo - (float) tempo_change < 10) {
if (note_tempo - tempo_change < 10) {
note_tempo = 10;
} else {
note_tempo -= (float) tempo_change;
note_tempo -= tempo_change;
}
}
void audio_init() {
/* check signature */
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);
TIMSK3 &= ~_BV(OCIE3A); // 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
DDRC |= _BV(PORTC6);
TIMSK3 &= ~_BV(OCIE3A); // Turn off 3A interputs
TCCR3A = (0 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30);
TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (1 << CS31) | (0 << CS30);
#endif
inited = true;
}
void stop_all_notes() {
if (!inited) {
audio_init();
}
voices = 0;
#ifdef PWM_AUDIO
TIMSK3 &= ~_BV(OCIE3A);
#else
TIMSK3 &= ~_BV(OCIE3A);
TCCR3A &= ~_BV(COM3A1);
#endif
notes = false;
note = false;
frequency = 0;
volume = 0;
for (int i = 0; i < 8; i++) {
frequencies[i] = 0;
volumes[i] = 0;
}
}
void stop_note(float freq) {
if (note) {
if (!inited) {
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
TIMSK3 &= ~_BV(OCIE3A);
#else
TIMSK3 &= ~_BV(OCIE3A);
TCCR3A &= ~_BV(COM3A1);
#endif
frequency = 0;
volume = 0;
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 (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;
ICR3 = (int)(((double)F_CPU) / (freq * CPU_PRESCALER)); // Set max to the period
OCR3A = (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
// TIMSK3 &= ~_BV(OCIE3A);
if (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);
ICR3 = (int)(((double)F_CPU) / (freq * CPU_PRESCALER)); // Set max to the period
OCR3A = (int)((((double)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); // Set compare to half the period
} else {
ICR3 = 0;
OCR3A = 0;
}
#endif
note_position++;
bool end_of_note = false;
if (ICR3 > 0)
end_of_note = (note_position >= (note_length / ICR3 * 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
TIMSK3 &= ~_BV(OCIE3A);
#else
TIMSK3 &= ~_BV(OCIE3A);
TCCR3A &= ~_BV(COM3A1);
#endif
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] * (note_tempo / 100);
#else
envelope_index = 0;
note_frequency = (*notes_pointer)[current_note][0];
note_length = ((*notes_pointer)[current_note][1] / 4) * (note_tempo / 100);
#endif
}
note_position = 0;
}
}
if (!audio_config.enable) {
notes = false;
note = false;
}
}
void play_note(float freq, int vol) {
if (!inited) {
audio_init();
}
if (audio_config.enable && voices < 8) {
TIMSK3 &= ~_BV(OCIE3A);
// Cancel notes if notes are playing
if (notes)
stop_all_notes();
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
TIMSK3 |= _BV(OCIE3A);
#else
TIMSK3 |= _BV(OCIE3A);
TCCR3A |= _BV(COM3A1);
#endif
}
}
void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest) {
if (!inited) {
audio_init();
}
if (audio_config.enable) {
TIMSK3 &= ~_BV(OCIE3A);
// Cancel note if a note is playing
if (note)
stop_all_notes();
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] * (note_tempo / 100);
#else
note_frequency = (*notes_pointer)[current_note][0];
note_length = ((*notes_pointer)[current_note][1] / 4) * (note_tempo / 100);
#endif
note_position = 0;
#ifdef PWM_AUDIO
TIMSK3 |= _BV(OCIE3A);
#else
TIMSK3 |= _BV(OCIE3A);
TCCR3A |= _BV(COM3A1);
#endif
}
}
#ifdef PWM_AUDIO
void play_sample(uint8_t * s, uint16_t l, bool r) {
if (!inited) {
audio_init();
}
if (audio_config.enable) {
TIMSK3 &= ~_BV(OCIE3A);
stop_all_notes();
place_int = 0;
sample = s;
sample_length = l;
repeat = r;
TIMSK3 |= _BV(OCIE3A);
}
}
#endif
//------------------------------------------------------------------------------
// Override these functions in your keymap file to play different tunes on
// startup and bootloader jump
__attribute__ ((weak))
void play_startup_tone()
{
}
void play_startup_tone() {}
__attribute__ ((weak))
void play_goodbye_tone()
{
void play_goodbye_tone() {}
}
__attribute__ ((weak))
void audio_on_user() {}
__attribute__ ((weak))
void play_music_scale() {}
//------------------------------------------------------------------------------

View file

@ -25,6 +25,7 @@ typedef union {
};
} audio_config_t;
bool is_audio_on(void);
void audio_toggle(void);
void audio_on(void);
void audio_off(void);
@ -56,7 +57,7 @@ void increase_polyphony_rate(float change);
void decrease_polyphony_rate(float change);
void set_timbre(float timbre);
void set_tempo(float tempo);
void set_tempo(uint8_t tempo);
void increase_tempo(uint8_t tempo_change);
void decrease_tempo(uint8_t tempo_change);
@ -71,11 +72,11 @@ void stop_note(float freq);
void stop_all_notes(void);
void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest);
#define SCALE (int []){ 0 + (12*0), 2 + (12*0), 4 + (12*0), 5 + (12*0), 7 + (12*0), 9 + (12*0), 11 + (12*0), \
0 + (12*1), 2 + (12*1), 4 + (12*1), 5 + (12*1), 7 + (12*1), 9 + (12*1), 11 + (12*1), \
0 + (12*2), 2 + (12*2), 4 + (12*2), 5 + (12*2), 7 + (12*2), 9 + (12*2), 11 + (12*2), \
0 + (12*3), 2 + (12*3), 4 + (12*3), 5 + (12*3), 7 + (12*3), 9 + (12*3), 11 + (12*3), \
0 + (12*4), 2 + (12*4), 4 + (12*4), 5 + (12*4), 7 + (12*4), 9 + (12*4), 11 + (12*4), }
#define SCALE (int8_t []){ 0 + (12*0), 2 + (12*0), 4 + (12*0), 5 + (12*0), 7 + (12*0), 9 + (12*0), 11 + (12*0), \
0 + (12*1), 2 + (12*1), 4 + (12*1), 5 + (12*1), 7 + (12*1), 9 + (12*1), 11 + (12*1), \
0 + (12*2), 2 + (12*2), 4 + (12*2), 5 + (12*2), 7 + (12*2), 9 + (12*2), 11 + (12*2), \
0 + (12*3), 2 + (12*3), 4 + (12*3), 5 + (12*3), 7 + (12*3), 9 + (12*3), 11 + (12*3), \
0 + (12*4), 2 + (12*4), 4 + (12*4), 5 + (12*4), 7 + (12*4), 9 + (12*4), 11 + (12*4), }
// These macros are used to allow play_notes to play an array of indeterminate
// length. This works around the limitation of C's sizeof operation on pointers.
@ -83,7 +84,12 @@ void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest)
#define NOTE_ARRAY_SIZE(x) ((int16_t)(sizeof(x) / (sizeof(x[0]))))
#define PLAY_NOTE_ARRAY(note_array, note_repeat, note_rest_style) play_notes(&note_array, NOTE_ARRAY_SIZE((note_array)), (note_repeat), (note_rest_style));
bool is_playing_notes(void);
void play_goodbye_tone(void);
void play_startup_tone(void);
void audio_on_user(void);
void play_music_scale(void);
#endif

643
quantum/audio/audio_pwm.c Normal file
View file

@ -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()
{
}
//------------------------------------------------------------------------------

View file

@ -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
};

382
quantum/audio/luts.c Normal file
View file

@ -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,
};

15
quantum/audio/luts.h Normal file
View file

@ -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 */

View file

@ -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
};

View file

@ -1,6 +1,6 @@
#include "voices.h"
#include "audio.h"
#include "stdlib.h"
#include "vibrato_lut.h"
// these are imported from audio.c
extern uint16_t envelope_index;
@ -109,7 +109,7 @@ float voice_envelope(float frequency) {
case 0 ... VOICE_VIBRATO_DELAY:
break;
default:
frequency = frequency * VIBRATO_LUT[(int)fmod((((float)compensated_index - (VOICE_VIBRATO_DELAY + 1))/1000*VOICE_VIBRATO_SPEED), VIBRATO_LUT_LENGTH)];
frequency = frequency * vibrato_lut[(int)fmod((((float)compensated_index - (VOICE_VIBRATO_DELAY + 1))/1000*VOICE_VIBRATO_SPEED), VIBRATO_LUT_LENGTH)];
break;
}
break;
@ -160,4 +160,6 @@ float voice_envelope(float frequency) {
}
return frequency;
}
}

View file

@ -2,8 +2,7 @@
#include <stdbool.h>
#include <avr/io.h>
#include <util/delay.h>
#include "musical_notes.h"
#include "song_list.h"
#include "luts.h"
#ifndef VOICES_H
#define VOICES_H

View file

@ -24,10 +24,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "action_macro.h"
#include "debug.h"
#include "backlight.h"
#include "keymap_midi.h"
#include "bootloader.h"
#include "eeconfig.h"
#ifdef MIDI_ENABLE
#include "keymap_midi.h"
#endif
extern keymap_config_t keymap_config;
#include <stdio.h>
@ -150,20 +153,22 @@ static action_t keycode_to_action(uint16_t keycode)
case KC_TRNS:
action.code = ACTION_TRANSPARENT;
break;
case 0x0100 ... 0x1FFF: ;
case LCTL(0) ... 0x1FFF: ;
// Has a modifier
// Split it up
action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF); // adds modifier to key
break;
case 0x2000 ... 0x2FFF:
case FUNC(0) ... FUNC(0xFFF): ;
// Is a shortcut for function layer, pull last 12bits
// This means we have 4,096 FN macros at our disposal
return keymap_func_to_action(keycode & 0xFFF);
break;
case 0x3000 ... 0x3FFF: ;
// When the code starts with 3, it's an action macro.
case M(0) ... M(0xFF):
action.code = ACTION_MACRO(keycode & 0xFF);
break;
case LT(0, 0) ... LT(0xFF, 0xF):
action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF);
break;
#ifdef BACKLIGHT_ENABLE
case BL_0 ... BL_15:
action.code = ACTION_BACKLIGHT_LEVEL(keycode & 0x000F);
@ -197,7 +202,7 @@ static action_t keycode_to_action(uint16_t keycode)
print("\nDEBUG: enabled.\n");
debug_enable = true;
break;
case 0x5002 ... 0x50FF:
case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_UNSWAP_ALT_GUI:
// MAGIC actions (BOOTMAGIC without the boot)
if (!eeconfig_is_enabled()) {
eeconfig_init();
@ -247,7 +252,7 @@ static action_t keycode_to_action(uint16_t keycode)
}
eeconfig_update_keymap(keymap_config.raw);
break;
case 0x5100 ... 0x5FFF: ;
case TO(0, 1) ... OSM(0xFF): ;
// Layer movement shortcuts
// See .h to see constraints/usage
int type = (keycode >> 0x8) & 0xF;
@ -268,25 +273,19 @@ static action_t keycode_to_action(uint16_t keycode)
// Set default layer
int layer = keycode & 0xFF;
action.code = ACTION_LAYER_TOGGLE(layer);
} else if (type == 0x5) {
// OSL(layer) - One-shot layer
int layer = keycode & 0xFF;
action.code = ACTION_LAYER_ONESHOT(layer);
} else if (type == 0x6) {
// OSM(mod) - One-shot mod
int mod = keycode & 0xFF;
action.code = ACTION_MODS_ONESHOT(mod);
}
break;
#ifdef MIDI_ENABLE
case 0x6000 ... 0x6FFF:
action.code = ACTION_FUNCTION_OPT(keycode & 0xFF, (keycode & 0x0F00) >> 8);
break;
#endif
case 0x7000 ... 0x7FFF:
case MT(0, 0) ... MT(0xF, 0xFF):
action.code = ACTION_MODS_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF);
break;
case 0x8000 ... 0x8FFF:
action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF);
break;
#ifdef UNICODE_ENABLE
case 0x8000000 ... 0x8FFFFFF:
uint16_t unicode = keycode & ~(0x8000);
action.code = ACTION_FUNCTION_OPT(unicode & 0xFF, (unicode & 0xFF00) >> 8);
break;
#endif
default:
action.code = ACTION_NO;
break;

View file

@ -67,6 +67,9 @@ extern const uint16_t fn_actions[];
#define MEH(kc) kc | 0x0700
#define LCAG(kc) kc | 0x0D00 // Modifier Ctrl Alt and GUI
#define MOD_HYPR 0xf
#define MOD_MEH 0x7
#define RCTL(kc) kc | 0x1100
#define RSFT(kc) kc | 0x1200
#define RALT(kc) kc | 0x1400
@ -84,8 +87,11 @@ extern const uint16_t fn_actions[];
#define KC_EXCLAIM KC_EXLM
#define KC_AT LSFT(KC_2) // @
#define KC_HASH LSFT(KC_3) // #
#define KC_DLR LSFT(KC_4) // $
#define KC_DOLLAR KC_DLR
@ -107,22 +113,43 @@ extern const uint16_t fn_actions[];
#define KC_RPRN LSFT(KC_0) // )
#define KC_RIGHT_PAREN KC_RPRN
#define KC_UNDS LSFT(KC_MINS) // _
#define KC_UNDERSCORE KC_UNDS
#define KC_PLUS LSFT(KC_EQL) // +
#define KC_LCBR LSFT(KC_LBRC) // {
#define KC_LEFT_CURLY_BRACE KC_LCBR
#define KC_RCBR LSFT(KC_RBRC) // }
#define KC_RIGHT_CURLY_BRACE KC_RCBR
#define KC_LABK LSFT(KC_COMM) // <
#define KC_LEFT_ANGLE_BRACKET KC_LABK
#define KC_RABK LSFT(KC_DOT) // >
#define KC_RIGHT_ANGLE_BRACKET KC_RABK
#define KC_COLN LSFT(KC_SCLN) // :
#define KC_COLON KC_COLN
#define KC_PIPE LSFT(KC_BSLS) // |
#define KC_LT LSFT(KC_COMM) // <
#define KC_GT LSFT(KC_DOT) // >
#define KC_QUES LSFT(KC_SLSH) // ?
#define KC_QUESTION KC_QUES
#define KC_DQT LSFT(KC_QUOT) // "
#define KC_DOUBLE_QUOTE KC_DQT
#define KC_DELT KC_DELETE // Del key (four letter code)
// Alias for function layers than expand past FN31
@ -132,35 +159,14 @@ extern const uint16_t fn_actions[];
#define S(kc) LSFT(kc)
#define F(kc) FUNC(kc)
#define M(kc) kc | 0x3000
#define M(kc) (kc | 0x3000)
#define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE)
// These affect the backlight (if your keyboard has one).
// We don't need to comment them out if your keyboard doesn't have a backlight,
// since they don't take up any space.
#define BL_ON 0x4009
#define BL_OFF 0x4000
#define BL_0 0x4000
#define BL_1 0x4001
#define BL_2 0x4002
#define BL_3 0x4003
#define BL_4 0x4004
#define BL_5 0x4005
#define BL_6 0x4006
#define BL_7 0x4007
#define BL_8 0x4008
#define BL_9 0x4009
#define BL_10 0x400A
#define BL_11 0x400B
#define BL_12 0x400C
#define BL_13 0x400D
#define BL_14 0x400E
#define BL_15 0x400F
#define BL_DEC 0x4010
#define BL_INC 0x4011
#define BL_TOGG 0x4012
#define BL_STEP 0x4013
// 0x3100+ is free
// L-ayer, T-ap - 256 keycode max, 16 layer max
#define LT(layer, kc) (kc | 0x4000 | ((layer & 0xF) << 8))
#define RESET 0x5000
#define DEBUG 0x5001
@ -188,6 +194,51 @@ extern const uint16_t fn_actions[];
#define AG_SWAP MAGIC_SWAP_ALT_GUI
#define AG_NORM MAGIC_UNSWAP_ALT_GUI
#define KC_LEAD 0x5014
// Audio on/off
#define AU_ON 0x5020
#define AU_OFF 0x5021
#define AU_TOG 0x5022
// Music mode on/off
#define MU_ON 0x5023
#define MU_OFF 0x5024
#define MU_TOG 0x5025
// Music voice iterate
#define MUV_IN 0x5026
#define MUV_DE 0x5027
// Midi mode on/off
#define MI_ON 0x5028
#define MI_OFF 0x5029
// These affect the backlight (if your keyboard has one).
// We don't need to comment them out if your keyboard doesn't have a backlight,
// since they don't take up any space.
#define BL_ON 0x5079
#define BL_OFF 0x5070
#define BL_0 0x5070
#define BL_1 0x5071
#define BL_2 0x5072
#define BL_3 0x5073
#define BL_4 0x5074
#define BL_5 0x5075
#define BL_6 0x5076
#define BL_7 0x5077
#define BL_8 0x5078
#define BL_9 0x5079
#define BL_10 0x507A
#define BL_11 0x507B
#define BL_12 0x507C
#define BL_13 0x507D
#define BL_14 0x507E
#define BL_15 0x507F
#define BL_DEC 0x5080
#define BL_INC 0x5081
#define BL_TOGG 0x5082
#define BL_STEP 0x5083
// GOTO layer - 16 layers max
// when:
@ -205,6 +256,14 @@ extern const uint16_t fn_actions[];
// Toggle to layer - 256 layer max
#define TG(layer) (layer | 0x5400)
// One-shot layer - 256 layer max
#define OSL(layer) (layer | 0x5500)
// One-shot mod
#define OSM(layer) (layer | 0x5600)
// chording is currently at 0x57xx
// M-od, T-ap - 256 keycode max
#define MT(mod, kc) (kc | 0x7000 | ((mod & 0xF) << 8))
#define CTL_T(kc) MT(0x1, kc)
@ -220,14 +279,13 @@ extern const uint16_t fn_actions[];
#define KC_HYPR HYPR(KC_NO)
#define KC_MEH MEH(KC_NO)
// L-ayer, T-ap - 256 keycode max, 16 layer max
#define LT(layer, kc) (kc | 0x8000 | ((layer & 0xF) << 8))
// For sending unicode codes.
// You may not send codes over 1FFF -- this supports most of UTF8.
// To have a key that sends out Œ, go UC(0x0152)
#define UNICODE(n) (n | 0x8000)
#define UC(n) UNICODE(n)
#ifdef UNICODE_ENABLE
// For sending unicode codes.
// You may not send codes over 7FFF -- this supports most of UTF8.
// To have a key that sends out Œ, go UC(0x0152)
#define UNICODE(n) (n | 0x8000)
#define UC(n) UNICODE(n)
#endif
// For tri-layer
void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3);

View file

@ -0,0 +1,102 @@
#ifndef KEYMAP_SWISS_GERMAN
#define KEYMAP_SWISS_GERMAN
#include "keymap_common.h"
// Alt gr
#define ALGR(kc) kc | 0x1400
#define CH_ALGR KC_RALT
// normal characters
#define CH_Z KC_Y
#define CH_Y KC_Z
#define CH_A KC_A
#define CH_B KC_B
#define CH_C KC_C
#define CH_D KC_D
#define CH_E KC_E
#define CH_F KC_F
#define CH_G KC_G
#define CH_H KC_H
#define CH_I KC_I
#define CH_J KC_J
#define CH_K KC_K
#define CH_L KC_L
#define CH_M KC_M
#define CH_N KC_N
#define CH_O KC_O
#define CH_P KC_P
#define CH_Q KC_Q
#define CH_R KC_R
#define CH_S KC_S
#define CH_T KC_T
#define CH_U KC_U
#define CH_V KC_V
#define CH_W KC_W
#define CH_X KC_X
#define CH_0 KC_0
#define CH_1 KC_1
#define CH_2 KC_2
#define CH_3 KC_3
#define CH_4 KC_4
#define CH_5 KC_5
#define CH_6 KC_6
#define CH_7 KC_7
#define CH_8 KC_8
#define CH_9 KC_9
#define CH_DOT KC_DOT
#define CH_COMM KC_COMM
#define CH_QUOT KC_MINS // ' ? ´
#define CH_AE KC_QUOT
#define CH_UE KC_LBRC
#define CH_OE KC_SCLN
#define CH_PARA KC_GRAVE // secction sign § and °
#define CH_CARR KC_EQL // carret ^ ` ~
#define CH_DIER KC_RBRC // dieresis ¨ ! ]
#define CH_DLR KC_BSLS // $ £ }
#define CH_LESS KC_NUBS // < and > and backslash
#define CH_MINS KC_SLSH // - and _
// shifted characters
#define CH_RING LSFT(CH_PARA) // °
#define CH_PLUS LSFT(KC_1) // +
#define CH_DQOT LSFT(KC_2) // "
#define CH_PAST LSFT(KC_3) // *
#define CH_CELA LSFT(KC_4) // ç
#define CH_PERC LSFT(KC_5) // %
#define CH_AMPR LSFT(KC_6) // &
#define CH_SLSH LSFT(KC_7) // /
#define CH_LPRN LSFT(KC_8) // (
#define CH_RPRN LSFT(KC_9) // )
#define CH_EQL LSFT(KC_0) // =
#define CH_QST LSFT(CH_QUOT) // ?
#define CH_GRV LSFT(CH_CARR) // `
#define CH_EXLM LSFT(CH_DIER) // !
#define CH_POND LSFT(CH_DLR) // £
#define CH_MORE LSFT(CH_LESS) // >
#define CH_COLN LSFT(KC_DOT) // :
#define CH_SCLN LSFT(KC_COMM) // ;
#define CH_UNDS LSFT(CH_MINS) // _
// Alt Gr-ed characters
#define CH_BRBR ALGR(KC_1) // ¦ brocken bar
#define CH_AT ALGR(KC_2) // @
#define CH_HASH ALGR(KC_3) // #
#define CH_NOTL ALGR(KC_6) // ¬ negative logic
#define CH_PIPE ALGR(KC_7) // |
#define CH_CENT ALGR(KC_8) // ¢ cent
#define CH_ACUT ALGR(CH_QUOT) // ´
#define CH_TILD ALGR(CH_CARR) // ~
#define CH_EURO ALGR(KC_E) // €
#define CH_LBRC ALGR(CH_UE) // [
#define CH_RBRC ALGR(CH_DIER) // ]
#define CH_LCBR ALGR(CH_AE) // {
#define CH_RCBR ALGR(CH_DLR) // }
#define CH_BSLS ALGR(CH_LESS) // backslash
#endif

View file

@ -25,11 +25,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define CHNL(note, channel) (note + (channel << 8))
#define SCALE (int []){ 0 + (12*0), 2 + (12*0), 4 + (12*0), 5 + (12*0), 7 + (12*0), 9 + (12*0), 11 + (12*0), \
0 + (12*1), 2 + (12*1), 4 + (12*1), 5 + (12*1), 7 + (12*1), 9 + (12*1), 11 + (12*1), \
0 + (12*2), 2 + (12*2), 4 + (12*2), 5 + (12*2), 7 + (12*2), 9 + (12*2), 11 + (12*2), \
0 + (12*3), 2 + (12*3), 4 + (12*3), 5 + (12*3), 7 + (12*3), 9 + (12*3), 11 + (12*3), \
0 + (12*4), 2 + (12*4), 4 + (12*4), 5 + (12*4), 7 + (12*4), 9 + (12*4), 11 + (12*4), }
#define SCALE (int8_t []){ 0 + (12*0), 2 + (12*0), 4 + (12*0), 5 + (12*0), 7 + (12*0), 9 + (12*0), 11 + (12*0), \
0 + (12*1), 2 + (12*1), 4 + (12*1), 5 + (12*1), 7 + (12*1), 9 + (12*1), 11 + (12*1), \
0 + (12*2), 2 + (12*2), 4 + (12*2), 5 + (12*2), 7 + (12*2), 9 + (12*2), 11 + (12*2), \
0 + (12*3), 2 + (12*3), 4 + (12*3), 5 + (12*3), 7 + (12*3), 9 + (12*3), 11 + (12*3), \
0 + (12*4), 2 + (12*4), 4 + (12*4), 5 + (12*4), 7 + (12*4), 9 + (12*4), 11 + (12*4), }
#define N_CN1 (0x600C + (12 * -1) + 0 )
#define N_CN1S (0x600C + (12 * -1) + 1 )

Some files were not shown because too many files have changed in this diff Show more