summaryrefslogtreecommitdiff
path: root/keyboard/planck
diff options
context:
space:
mode:
authorcr3473 <joe@createtank.com>2015-05-27 08:29:48 -0700
committercr3473 <joe@createtank.com>2015-05-27 08:29:48 -0700
commitb36d1a87da2395fd5429e2817409c76f065387b5 (patch)
tree1e4a76822deaf92db83896548fa3c3003f7640f3 /keyboard/planck
parenta4cf9ae660b16d1952738139ba8f788368b73eff (diff)
parentd61d1f5ca3a7dcccc495ac6688e0632c601c0623 (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'keyboard/planck')
-rw-r--r--keyboard/planck/Makefile35
-rw-r--r--keyboard/planck/README.md56
-rw-r--r--keyboard/planck/__avr_gdbinit6
-rw-r--r--keyboard/planck/backlight.c49
-rw-r--r--keyboard/planck/common_keymaps/keymap_brett.c (renamed from keyboard/planck/keymap_brett.c)12
-rw-r--r--keyboard/planck/common_keymaps/keymap_dotcom.c (renamed from keyboard/planck/keymap_dotcom.c)0
-rw-r--r--keyboard/planck/common_keymaps/keymap_jack.c (renamed from keyboard/planck/keymap_jack.c)2
-rw-r--r--keyboard/planck/common_keymaps/keymap_joe.c (renamed from keyboard/planck/keymap_joe.c)0
-rw-r--r--keyboard/planck/common_keymaps/keymap_matthew.c (renamed from keyboard/planck/keymap_matthew.c)0
-rw-r--r--keyboard/planck/common_keymaps/keymap_nathan.c (renamed from keyboard/planck/keymap_nathan.c)49
-rw-r--r--keyboard/planck/common_keymaps/keymap_peasant.c (renamed from keyboard/planck/keymap_peasant.c)0
-rw-r--r--keyboard/planck/common_keymaps/keymap_reed.c74
-rw-r--r--keyboard/planck/common_keymaps/keymap_sean.c57
-rw-r--r--keyboard/planck/common_keymaps/keymap_shane.c (renamed from keyboard/planck/keymap_shane.c)0
-rw-r--r--keyboard/planck/common_keymaps/keymap_simon.c44
-rw-r--r--keyboard/planck/common_keymaps/keymap_tim.c44
-rw-r--r--keyboard/planck/common_keymaps/keymap_wilba.c56
-rw-r--r--keyboard/planck/config.h8
-rw-r--r--keyboard/planck/extended_keymap_common.c208
-rw-r--r--keyboard/planck/extended_keymap_common.h177
-rw-r--r--keyboard/planck/extended_keymaps/extended_keymap_austin.c50
-rw-r--r--keyboard/planck/extended_keymaps/extended_keymap_charlie.c54
-rw-r--r--keyboard/planck/extended_keymaps/extended_keymap_default.c50
-rw-r--r--keyboard/planck/extended_keymaps/extended_keymap_jack.c50
-rw-r--r--keyboard/planck/keymap_common.h26
-rw-r--r--keyboard/planck/keymap_sean.c50
-rw-r--r--keyboard/planck/led.c16
-rw-r--r--keyboard/planck/matrix.c2
-rw-r--r--keyboard/planck/matrix_center.c202
-rw-r--r--keyboard/planck/matrix_pcb.c222
30 files changed, 1474 insertions, 125 deletions
diff --git a/keyboard/planck/Makefile b/keyboard/planck/Makefile
index c456cb51b3..964e6832ea 100644
--- a/keyboard/planck/Makefile
+++ b/keyboard/planck/Makefile
@@ -47,15 +47,35 @@ TOP_DIR = ../..
# Directory keyboard dependent files exist
TARGET_DIR = .
-# project specific files
-SRC = keymap_common.c \
- matrix.c \
- led.c
+
+
+# # project specific files
+ifdef COMMON
+
+ SRC = keymap_common.c \
+ matrix_pcb.c \
+ led.c \
+ backlight.c
ifdef KEYMAP
- SRC := keymap_$(KEYMAP).c $(SRC)
+ SRC := common_keymaps/keymap_$(KEYMAP).c $(SRC)
else
- SRC := keymap_jack.c $(SRC)
+ SRC := common_keymaps/keymap_jack.c $(SRC)
+endif
+
+else
+
+SRC = extended_keymap_common.c \
+ matrix_pcb.c \
+ led.c \
+ backlight.c
+
+ifdef KEYMAP
+ SRC := extended_keymaps/extended_keymap_$(KEYMAP).c $(SRC)
+else
+ SRC := extended_keymaps/extended_keymap_default.c $(SRC)
+endif
+
endif
CONFIG_H = config.h
@@ -118,9 +138,10 @@ MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
CONSOLE_ENABLE = yes # Console for debug(+400)
COMMAND_ENABLE = yes # Commands for debug and configuration
+# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
-
+BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
# Optimize size but this may cause error "relocation truncated to fit"
#EXTRALDFLAGS = -Wl,--relax
diff --git a/keyboard/planck/README.md b/keyboard/planck/README.md
index cb009c005d..ee824d26e0 100644
--- a/keyboard/planck/README.md
+++ b/keyboard/planck/README.md
@@ -1,24 +1,56 @@
Planck keyboard firmware
======================
-DIY/Assembled compact ortholinear keyboard by [Ortholinear Keyboards](http://ortholinearkeyboards.com).
+DIY/Assembled compact ortholinear 40% keyboard by [Ortholinear Keyboards](http://ortholinearkeyboards.com).
-## Notable TMK forks (which some of the keymap files are from)
-- [Shane's Fork](https://github.com/shanecelis/tmk_keyboard/tree/master/keyboard/planck)
-- [Pierre's Fork](https://github.com/pcarrier/tmk_keyboard/blob/pcarrier/planck/keyboard/gh60/keymap_planck.c)
-- [Nathan's Fork](https://github.com/nathanrosspowell/tmk_keyboard/tree/planck-jack/keyboard/planck)
-- [Matthew's Fork](https://github.com/pepers/tmk_keyboard/tree/master/keyboard/planck_grid)
+## Extended Keymap
+If you include extended_keymap_common.h instead of keymap_common.h at the top of your file, you'll have access to a bunch of goodies:
+
+- Use `LSFT()`, `LCTL()`, et. al. (listed in extended_keymap_common.h) as modifiers for keys (daisy-chain-able)
+- Use `FUNC(1)` instead of `FN1` (etc.) to access the function layers beyond the 32 function layer limit
+- Use `CM_F` instead of `KC_F` to get the ColeMak equivilent for shortcuts (maps backwards)
+- Use `MACRODOWN()` instead of `MACRO()` to easily make a keydown macro (`CM_*` works here too)
+
+### Some notes on usage:
+
+- The `KEYMAP()` macro is unable to be used due to the bitwise modifications that take place - refer to extended_keymap_jack.c to see how to set things up with the `KC_` prefix
+- Keep an eye on the Makefile - this needs to include the correct files to work
+- Don't forget to use `const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {` instead of the 8bit equivilent
## Build
-Move to this directory then just run `make` like:
- $ make
+Follow [this guide](http://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html) to setup your development environment before anything else. Abbreviated instructions are provide at the [bottom of this document](https://github.com/rswiernik/tmk_keyboard/tree/rswiernik_dev/keyboard/planck#environment-setup)
-Use `make -f Makefile.pjrc` if you want to use PJRC stack but I find no reason to do so now.
+Download the whole firmware [here](https://github.com/jackhumbert/tmk_keyboard/archive/master.zip) and navigate to the keyboard/planck folder. Once your dev env is setup, you'll be able to type `make` to generate your .hex that you can load with the Teensy app onto your Planck (once you've hit reset/shorted GND & RST).
+Depending on which keymap you would like to use, you will have to compile slightly differently.
+
+####Default
+To build with the default keymap, simply move to the tmk\_keyboard/keyboard/planck/ and run `make` as follows:
+```
+$ make
+```
## Keymap
-Several version of keymap are available in advance but you are recommended to define your favorite layout yourself. To define your own keymap create file named `keymap_<name>.c` and see keymap document(you can find in top README.md) and existent keymap files.
+Several version of keymap are available in advance but you are recommended to define your favorite layout yourself. To define your own keymap create file named `keymap_<name>.c` and see keymap document (you can find in top README.md) and existent keymap files.
+
+####**Extended Keymaps**
+
+To build the firmware binary hex file with an extended keymap just do `make` with `KEYMAP` option like:
+```
+$ make KEYMAP=[common|jack|<name>]
+```
+_The only applicable keymaps will work with this option._ Extended keymaps follow the format **__extended\_keymap\_\<name\>.c__**
-To build firmware binary hex file with a certain keymap just do `make` with `KEYMAP` option like:
+####**Common Keymaps**
- $ make KEYMAP=[<name>]
+Building with a common keymap is as simple as adding the COMMON option. Note that only
+```
+$ make KEYMAP=[common|jack|<name>] COMMON=true
+```
+_The only applicable keymaps will work with this option._ Common keymaps follow the format **__keymap\_\<name\>.c__**
+
+## Notable TMK forks (which some of the keymap files are from)
+- [Shane's Fork](https://github.com/shanecelis/tmk_keyboard/tree/master/keyboard/planck)
+- [Pierre's Fork](https://github.com/pcarrier/tmk_keyboard/blob/pcarrier/planck/keyboard/gh60/keymap_planck.c)
+- [Nathan's Fork](https://github.com/nathanrosspowell/tmk_keyboard/tree/planck-jack/keyboard/planck)
+- [Matthew's Fork](https://github.com/pepers/tmk_keyboard/tree/master/keyboard/planck_grid)
diff --git a/keyboard/planck/__avr_gdbinit b/keyboard/planck/__avr_gdbinit
new file mode 100644
index 0000000000..afc51e6d19
--- /dev/null
+++ b/keyboard/planck/__avr_gdbinit
@@ -0,0 +1,6 @@
+define reset
+SIGNAL SIGHUP
+end
+file planck_lufa.elf
+target remote localhost:4242
+break main
diff --git a/keyboard/planck/backlight.c b/keyboard/planck/backlight.c
new file mode 100644
index 0000000000..06f103b4ac
--- /dev/null
+++ b/keyboard/planck/backlight.c
@@ -0,0 +1,49 @@
+
+#include <avr/io.h>
+#include "backlight.h"
+
+#define CHANNEL OCR1C
+
+void backlight_init_ports()
+{
+
+ // Setup PB7 as output and output low.
+ DDRB |= (1<<7);
+ PORTB &= ~(1<<7);
+
+ // 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();
+}
+
+void backlight_set(uint8_t level)
+{
+ if ( level == 0 )
+ {
+ // Turn off PWM control on PB7, revert to output low.
+ TCCR1A &= ~(_BV(COM1C1));
+ // CHANNEL = level << OFFSET | 0x0FFF;
+ CHANNEL = ((1 << level) - 1);
+ }
+ else
+ {
+ // Turn on PWM control of PB7
+ TCCR1A |= _BV(COM1C1);
+ // CHANNEL = level << OFFSET | 0x0FFF;
+ CHANNEL = ((1 << level) - 1);
+ }
+} \ No newline at end of file
diff --git a/keyboard/planck/keymap_brett.c b/keyboard/planck/common_keymaps/keymap_brett.c
index 16a12837cc..97d832b47a 100644
--- a/keyboard/planck/keymap_brett.c
+++ b/keyboard/planck/common_keymaps/keymap_brett.c
@@ -5,15 +5,15 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
ESC, Q, W, E, R, T, Y, U, I, O, P, BSPC,
LCTL, A, S, D, F, G, H, J, K, L, SCLN, ENT,
LSFT, Z, X, C, V, B, N, M, COMM, DOT, SLSH, RSFT,
- LGUI, TAB, LCTL, LALT, FN2, SPC, FN1, LEFT, DOWN, UP, RGHT),
+ TAB, LGUI, RSFT, LALT, FN2, SPC, FN1, LEFT, DOWN, UP, RGHT),
[1] = KEYMAP( /* RAISE */
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, DEL,
- TRNS, F1, F2, F3, F4, F5, F6, 4, 5, 6, TRNS, TRNS,
- TRNS, F7, F8, F9, F10, F11, F12, 1, 2, 3, TRNS, PGUP,
- MPRV, MNXT, TRNS, MUTE, TRNS, TRNS, FN1, TRNS, TRNS, TRNS, PGDN),
+ TRNS, F1, F2, F3, F4, F5, F6, 4, 5, 6, QUOT, TRNS,
+ TRNS, F7, F8, F9, F10, F11, F12, 1, 2, 3, TRNS, PGUP,
+ MPRV, MNXT, TRNS, MUTE, TRNS, TRNS, FN1, 0, 0, TRNS, PGDN),
[2] = KEYMAP( /* LOWER */
- FN22, FN10, FN11, FN12, FN13, FN14, FN15, FN16, FN17, FN18, FN19, MINS,
- TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, EQL,
+ TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, MINS,
+ TRNS, TRNS, TRNS, PAUSE, TRNS, TRNS, TRNS, TRNS, LBRC, RBRC, BSLS, EQL,
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
MPLY, MSTP, VOLU, VOLD, FN2, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS),
};
diff --git a/keyboard/planck/keymap_dotcom.c b/keyboard/planck/common_keymaps/keymap_dotcom.c
index 347f6dea91..347f6dea91 100644
--- a/keyboard/planck/keymap_dotcom.c
+++ b/keyboard/planck/common_keymaps/keymap_dotcom.c
diff --git a/keyboard/planck/keymap_jack.c b/keyboard/planck/common_keymaps/keymap_jack.c
index 3724bca49f..c74812121f 100644
--- a/keyboard/planck/keymap_jack.c
+++ b/keyboard/planck/common_keymaps/keymap_jack.c
@@ -24,7 +24,7 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
};
const uint16_t PROGMEM fn_actions[] = {
[1] = ACTION_LAYER_MOMENTARY(2), // to Fn overlay
- [2] = ACTION_LAYER_MOMENTARY(3), // to Fn overlay
+ [2] = ACTION_LAYER_MOMENTARY(3), // to Fn overlay
[3] = ACTION_DEFAULT_LAYER_SET(0),
[4] = ACTION_DEFAULT_LAYER_SET(1),
diff --git a/keyboard/planck/keymap_joe.c b/keyboard/planck/common_keymaps/keymap_joe.c
index 598b0c455c..598b0c455c 100644
--- a/keyboard/planck/keymap_joe.c
+++ b/keyboard/planck/common_keymaps/keymap_joe.c
diff --git a/keyboard/planck/keymap_matthew.c b/keyboard/planck/common_keymaps/keymap_matthew.c
index 56e7003a97..56e7003a97 100644
--- a/keyboard/planck/keymap_matthew.c
+++ b/keyboard/planck/common_keymaps/keymap_matthew.c
diff --git a/keyboard/planck/keymap_nathan.c b/keyboard/planck/common_keymaps/keymap_nathan.c
index 47539188ed..5a0900b66d 100644
--- a/keyboard/planck/keymap_nathan.c
+++ b/keyboard/planck/common_keymaps/keymap_nathan.c
@@ -3,31 +3,6 @@
#include "keymap_common.h"
-#ifndef KEYMAP_GRID
- /* Planck keymap definition macro for the 'grid' layout
- * ,-----------------------------------------------------------------------.
- * | | | | | | | | | | | | |
- * |-----------------------------------------------------------------------|
- * | | | | | | | | | | | | |
- * |-----------------------------------------------------------------------|
- * | | | | | | | | | | | | |
- * |-----------------------------------------------------------------------|
- * | | | | | | | | | | | | |
- * `-----------------------------------------------------------------------'
- */
-#define KEYMAP_GRID( \
- K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, \
- K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, \
- K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, \
- K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B \
-) { \
- { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B }, \
- { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B }, \
- { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B }, \
- { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B } \
-}
-#endif
-
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* 0: main layer
* ,-----------------------------------------------------------------------.
@@ -50,9 +25,9 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* The top row are Visual Studio combos:
* 'Run', 'Breakpoint', 'Step over', 'Step into', 'Set cursor to line'
* 2nd row are key combos:
- * 'ctrl-alt-delete', 'ctrl-shift-escape'
+ * 'ctrl-alt-delete', 'ctrl-shift-escape'
* 3rd row are macros keys:
- * 'P0' - 'P5' execute a script on Windows machines
+ * 'P0' - 'P5' execute a script on Windows machines
* ,-----------------------------------------------------------------------.
* | ESC | F5 | F9 | F10 | F11 |S+F11|CSF10|NLock|Num7 |Num8 |Num9 | Del |
* |-----------------------------------------------------------------------|
@@ -113,7 +88,7 @@ const uint16_t PROGMEM fn_actions[] = {
[11] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC), // {
[12] = ACTION_MODS_KEY(MOD_LSFT, KC_COMMA), // <
[13] = ACTION_MODS_KEY(MOD_LSFT, KC_0), // )
- [14] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC), // {
+ [14] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC), // }
[15] = ACTION_MODS_KEY(MOD_LSFT, KC_DOT), // >
// Combo
[16] = ACTION_MODS_KEY(MOD_LALT | MOD_LCTL, KC_DEL), // Ctrl+Alt+Delete
@@ -127,7 +102,7 @@ const uint16_t PROGMEM fn_actions[] = {
[23] = ACTION_MODS_KEY(MOD_LSFT, KC_6), // ^
[24] = ACTION_MODS_KEY(MOD_LSFT, KC_7), // &
[25] = ACTION_MODS_KEY(MOD_LSFT, KC_8), // *
- [26] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL), // +
+ [26] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL), // +
[27] = ACTION_MODS_KEY(MOD_LSFT, KC_MINUS), // _
[28] = ACTION_MODS_KEY(MOD_LSFT, KC_QUOTE), // "
[29] = ACTION_MODS_KEY(MOD_LSFT, KC_GRAVE), // ~
@@ -142,39 +117,37 @@ const uint16_t PROGMEM fn_actions[] = {
// *return*
#define RUN_PYTHON_PROGRAM_ON_WIN MACRO( T(ENT), END )
-const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
-{
+const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
keyevent_t event = record->event;
switch (id) {
case M_P0:
return event.pressed ?
- ADD_PYTHON_PROGRAM_ON_WIN( 0 ) :
+ ADD_PYTHON_PROGRAM_ON_WIN( 0 ) :
RUN_PYTHON_PROGRAM_ON_WIN;
case M_P1:
return event.pressed ?
- ADD_PYTHON_PROGRAM_ON_WIN( 1 ) :
+ ADD_PYTHON_PROGRAM_ON_WIN( 1 ) :
RUN_PYTHON_PROGRAM_ON_WIN;
case M_P2:
return event.pressed ?
- ADD_PYTHON_PROGRAM_ON_WIN( 2 ) :
+ ADD_PYTHON_PROGRAM_ON_WIN( 2 ) :
RUN_PYTHON_PROGRAM_ON_WIN;
case M_P3:
return event.pressed ?
- ADD_PYTHON_PROGRAM_ON_WIN( 3 ) :
+ ADD_PYTHON_PROGRAM_ON_WIN( 3 ) :
RUN_PYTHON_PROGRAM_ON_WIN;
case M_P4:
return event.pressed ?
- ADD_PYTHON_PROGRAM_ON_WIN( 4 ) :
+ ADD_PYTHON_PROGRAM_ON_WIN( 4 ) :
RUN_PYTHON_PROGRAM_ON_WIN;
case M_P5:
return event.pressed ?
- ADD_PYTHON_PROGRAM_ON_WIN( 5 ) :
+ ADD_PYTHON_PROGRAM_ON_WIN( 5 ) :
RUN_PYTHON_PROGRAM_ON_WIN;
case M_USERNAME:
return event.pressed ?
MACRO( T(N), T(A), T(T), T(H), T(A), T(N), T(R), T(O), T(S), T(S), T(P), T(O), T(W), T(E), T(L), T(L), END ) :
MACRO_NONE;
-
}
return MACRO_NONE;
}
diff --git a/keyboard/planck/keymap_peasant.c b/keyboard/planck/common_keymaps/keymap_peasant.c
index ddacb614e6..ddacb614e6 100644
--- a/keyboard/planck/keymap_peasant.c
+++ b/keyboard/planck/common_keymaps/keymap_peasant.c
diff --git a/keyboard/planck/common_keymaps/keymap_reed.c b/keyboard/planck/common_keymaps/keymap_reed.c
new file mode 100644
index 0000000000..1aa24e10de
--- /dev/null
+++ b/keyboard/planck/common_keymaps/keymap_reed.c
@@ -0,0 +1,74 @@
+#include "keymap_common.h"
+
+/*
+ * BUILD:
+ * Simply run the command below in the keyboard/planck directory
+ * to build against this keymap
+ *
+ * make KEYMAP=reed COMMON_KEYMAP=true
+ *
+ *
+ * DETAILS:
+ *
+ * This layout works off of Jack's layout, making some changes that I
+ * feel significantly improve the function of the keyboard. Major changes
+ * include adding a "gaming mode" that will allow users to still access
+ * the number keys 1 through 4 easily for games that require it. Also
+ * included is the ability to use the tap/hold function for easy use of
+ * right shift and thumb shift with their tapped companions.
+ *
+ */
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+[0] = KEYMAP_GRID( /* Reed */
+ ESC, Q, W, E, R, T, Y, U, I, O, P, BSPC,
+ TAB, A, S, D, F, G, H, J, K, L, SCLN, QUOT,
+ LSFT, Z, X, C, V, B, N, M, COMM, DOT, SLSH, FN5,
+ LCTL, CAPS, LALT, LGUI, FN2, FN7, SPC, FN1, LEFT, DOWN, UP, RGHT),
+
+[1] = KEYMAP_GRID( /* Reed EXTREME GAMING */
+ ESC, Q, W, E, R, T, Y, U, I, O, P, BSPC,
+ TAB, A, S, D, F, G, H, J, K, L, SCLN, QUOT,
+ LSFT, Z, X, C, V, B, N, M, COMM, DOT, SLSH, FN5,
+ LCTL, 1, 2, 3, 4, SPC, FN2, FN1, LEFT, DOWN, UP, RGHT),
+
+[2] = KEYMAP_GRID( /* Reed RAISE */
+ GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, BSPC,
+ TRNS, FN3, FN4, PAUSE, TRNS, TRNS, TRNS, MINS, EQL, LBRC, RBRC, BSLS,
+ TRNS, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, TRNS,
+ TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, FN1, MNXT, VOLD, VOLU, MPLY),
+
+[3] = KEYMAP_GRID( /* Reed LOWER */
+ TRNS, FN10, FN11, FN12, FN13, FN14, FN15, FN16, FN17, FN18, FN19, DEL,
+ TRNS, TRNS, INS, HOME, PGUP, TRNS, TRNS, FN20, FN21, FN23, FN24, FN28,
+ TRNS, TRNS, DEL, END, PGDN, F11, F12, F13, TRNS, VOLD, VOLU, TRNS,
+ TRNS, TRNS, TRNS, TRNS, FN2, TRNS, TRNS, TRNS, MPRV, MUTE, MPLY, MNXT),
+};
+const uint16_t PROGMEM fn_actions[] = {
+ [1] = ACTION_LAYER_MOMENTARY(2), // to Fn overlay - RAISE
+ [2] = ACTION_LAYER_MOMENTARY(3), // to Fn overlay - LOWER
+
+ [3] = ACTION_DEFAULT_LAYER_SET(0),
+ [4] = ACTION_DEFAULT_LAYER_SET(1),
+ // Actions for the tap/hold modifiers listed above
+ [5] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_ENT),
+ [7] = ACTION_MODS_TAP_KEY(MOD_LSFT, KC_BSPC),
+
+ [10] = ACTION_MODS_KEY(MOD_LSFT, KC_1),
+ [11] = ACTION_MODS_KEY(MOD_LSFT, KC_2),
+ [12] = ACTION_MODS_KEY(MOD_LSFT, KC_3),
+ [13] = ACTION_MODS_KEY(MOD_LSFT, KC_4),
+ [14] = ACTION_MODS_KEY(MOD_LSFT, KC_5),
+ [15] = ACTION_MODS_KEY(MOD_LSFT, KC_6),
+ [16] = ACTION_MODS_KEY(MOD_LSFT, KC_7),
+ [17] = ACTION_MODS_KEY(MOD_LSFT, KC_8),
+ [18] = ACTION_MODS_KEY(MOD_LSFT, KC_9),
+ [19] = ACTION_MODS_KEY(MOD_LSFT, KC_0),
+ [20] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS),
+ [21] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL),
+ [22] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV),
+ [23] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC),
+ [24] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC),
+ [28] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),
+
+ [29] = ACTION_MODS_KEY(MOD_LSFT | MOD_RSFT, KC_PAUSE),
+};
diff --git a/keyboard/planck/common_keymaps/keymap_sean.c b/keyboard/planck/common_keymaps/keymap_sean.c
new file mode 100644
index 0000000000..4fe07f701a
--- /dev/null
+++ b/keyboard/planck/common_keymaps/keymap_sean.c
@@ -0,0 +1,57 @@
+#include "keymap_common.h"
+
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ [0] = KEYMAP( /* Matrix Dvorak */
+ QUOT, COMM, DOT, P, Y, SLSH, EQL, F, G, C, R, L,
+ A, O, E, U, I, ESC, BSPC, D, H, T, N, S,
+ SCLN, Q, J, K, X, TAB, ENT, B, M, W, V, Z,
+ LSFT, LCTL, LALT, LGUI, FN1, SPC, FN2, LEFT, DOWN, UP, RGHT),
+
+ [1] = KEYMAP( /* Matrix Qwerty */
+ Q, W, E, R, T, QUOT, EQL, Y, U, I, O, P,
+ A, S, D, F, G, ESC, BSPC, H, J, K, L, SCLN,
+ Z, X, C, V, B, TAB, ENT, N, M, COMM, DOT, SLSH,
+ LSFT, LCTL, LALT, LGUI, FN1, SPC, FN2, LEFT, DOWN, UP, RGHT),
+
+ [2] = KEYMAP( /* fn1 lower */
+ F1, F2, F3, F4, F5, TRNS, TRNS, F6, F7, F8, F9, F10,
+ 1, 2, 3, 4, 5, F18, DEL, 6, 7, 8, 9, 0,
+ FN3, FN4, TRNS, GRV, MINS, TRNS, TRNS, BSLS, LBRC, RBRC, TRNS, TRNS,
+ TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, FN5, HOME, PGDN, PGUP, END),
+
+ [3] = KEYMAP( /* fn2 raise */
+ F1, F2, F3, F4, F5, TRNS, TRNS, F6, F7, F8, F9, F10,
+ F11, F12, F13, F14, F15, F18, DEL, F16, F17, F18, F19, F20,
+ FN3, FN4, TRNS, TRNS, TRNS, TRNS, TRNS, EJCT, PWR, LSFT,PAUSE, RSFT,
+ LEFT, DOWN, UP, RGHT, FN5, TRNS, TRNS, MNXT, VOLD, VOLU, MUTE),
+
+ [4] = KEYMAP( /* lower + raise */
+ LEFT, DOWN, UP, RGHT, TRNS, TRNS, TRNS, TRNS, LEFT, DOWN, UP, RGHT,
+ HOME, PGDN, PGUP, END, TRNS, F18, DEL, TRNS, HOME, PGDN, PGUP, END,
+ FN3, FN4, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, EJCT, PWR, MPLY, RSFT,
+ TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, MNXT, VOLD, VOLU, MUTE),
+};
+const uint16_t PROGMEM fn_actions[] = {
+ [1] = ACTION_LAYER_MOMENTARY(2), // to Fn overlay LOWER
+ [2] = ACTION_LAYER_MOMENTARY(3), // to Fn overlay RAISE
+ [3] = ACTION_DEFAULT_LAYER_SET(0),
+ [4] = ACTION_DEFAULT_LAYER_SET(1),
+ [5] = ACTION_LAYER_MOMENTARY(4), // to Fn overlay LOWER + RAISE
+
+ [10] = ACTION_MODS_KEY(MOD_LSFT, KC_1),
+ [11] = ACTION_MODS_KEY(MOD_LSFT, KC_2),
+ [12] = ACTION_MODS_KEY(MOD_LSFT, KC_3),
+ [13] = ACTION_MODS_KEY(MOD_LSFT, KC_4),
+ [14] = ACTION_MODS_KEY(MOD_LSFT, KC_5),
+ [15] = ACTION_MODS_KEY(MOD_LSFT, KC_6),
+ [16] = ACTION_MODS_KEY(MOD_LSFT, KC_7),
+ [17] = ACTION_MODS_KEY(MOD_LSFT, KC_8),
+ [18] = ACTION_MODS_KEY(MOD_LSFT, KC_9),
+ [19] = ACTION_MODS_KEY(MOD_LSFT, KC_0),
+ [20] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS),
+ [21] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL),
+ [22] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV),
+ [23] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC),
+ [24] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC),
+ [28] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),
+};
diff --git a/keyboard/planck/keymap_shane.c b/keyboard/planck/common_keymaps/keymap_shane.c
index d4e40fe63a..d4e40fe63a 100644
--- a/keyboard/planck/keymap_shane.c
+++ b/keyboard/planck/common_keymaps/keymap_shane.c
diff --git a/keyboard/planck/common_keymaps/keymap_simon.c b/keyboard/planck/common_keymaps/keymap_simon.c
new file mode 100644
index 0000000000..37951364be
--- /dev/null
+++ b/keyboard/planck/common_keymaps/keymap_simon.c
@@ -0,0 +1,44 @@
+#include "keymap_common.h"
+
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+[0] = KEYMAP( /* Jack */
+ ESC, Q, W, E, R, T, Y, U, I, O, P, BSPC,
+ TAB, A, S, D, F, G, H, J, K, L, DOT, ENT,
+ LSFT, Z, X, C, V, B, N, M, COMM, DOT, SCLN, DEL,
+ LCTL, ENT, LALT, CAPS, FN2, SPC, FN1, LEFT, DOWN, UP, RGHT),
+[1] = KEYMAP( /* Jack RAISE */
+ TRNS, F1, F2, F3, F4, NO, FN11, FN9, FN12, NO, FN14, TRNS,
+ TRNS, F5, F6, F7, F8, FN16, SLSH, MINS, EQL, LBRC, FN8, TRNS,
+ TRNS, F9, F10, F11, F12, F15, F16, FN22, SCLN, MINS, QUOT, TRNS,
+ TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS),
+[2] = KEYMAP( /* Jack LOWER */
+ FN22, 1, 2, 3, FN13, FN14, FN15, FN16, FN17, FN18, FN19, BSPC,
+ TRNS, 4, 5, 6, TRNS, TRNS, TRNS, FN20, FN21, FN23, FN24, FN28,
+ TRNS, 7, 8, 9, 0, FN28, FN15, F7, F8, F9, F10, TRNS,
+ TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS),
+};
+const uint16_t PROGMEM fn_actions[] = {
+ [1] = ACTION_LAYER_MOMENTARY(1), // to Fn overlay
+ [2] = ACTION_LAYER_MOMENTARY(2), // to Fn overlay
+
+ [8] = ACTION_MODS_KEY(MOD_LSFT, KC_SLSH),
+ [9] = ACTION_MODS_KEY(MOD_LSFT, KC_QUOT),
+ [10] = ACTION_MODS_KEY(MOD_LSFT, KC_1),
+ [11] = ACTION_MODS_KEY(MOD_LSFT, KC_2),
+ [12] = ACTION_MODS_KEY(MOD_LSFT, KC_3),
+ [13] = ACTION_MODS_KEY(MOD_LSFT, KC_4),
+ [14] = ACTION_MODS_KEY(MOD_LSFT, KC_5),
+ [15] = ACTION_MODS_KEY(MOD_LSFT, KC_6),
+ [16] = ACTION_MODS_KEY(MOD_LSFT, KC_7),
+ [17] = ACTION_MODS_KEY(MOD_LSFT, KC_8),
+ [18] = ACTION_MODS_KEY(MOD_LSFT, KC_9),
+ [19] = ACTION_MODS_KEY(MOD_LSFT, KC_0),
+ [20] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS),
+ [21] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL),
+ [22] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV),
+ [23] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC),
+ [24] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC),
+ [28] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),
+
+ [29] = ACTION_MODS_KEY(MOD_LSFT | MOD_RSFT, KC_PAUSE),
+};
diff --git a/keyboard/planck/common_keymaps/keymap_tim.c b/keyboard/planck/common_keymaps/keymap_tim.c
new file mode 100644
index 0000000000..7444f3877b
--- /dev/null
+++ b/keyboard/planck/common_keymaps/keymap_tim.c
@@ -0,0 +1,44 @@
+#include "keymap_common.h"
+
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+[0] = KEYMAP(
+ ESC, Q, W, E, R, T, Y, U, I, O, P, BSPC,
+ TAB, A, S, D, F, G, H, J, K, L, SCLN, ENT,
+ LSFT, Z, X, C, V, B, N, M, COMM, DOT, SLSH, RSFT,
+ LCTL, LALT, DEL, LGUI, FN2, SPC, FN1, F2, F5, F9, F12),
+[2] = KEYMAP( /* RAISE */
+ TRNS, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, BSPC,
+ GRV, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, MINS, EQL, LBRC, RBRC, BSLS,
+ TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, QUOT, FN29, TRNS, TRNS,
+ TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, FN1, TRNS, TRNS, TRNS, TRNS),
+[3] = KEYMAP( /* LOWER */
+ TRNS, FN10, FN11, FN12, FN13, FN14, FN15, FN16, FN17, FN18, FN19, BSPC,
+ FN22, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, FN20, FN21, FN23, FN24, FN28,
+ TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, QUOT, FN29, TRNS, TRNS,
+ TRNS, TRNS, TRNS, TRNS, FN2, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS),
+};
+const uint16_t PROGMEM fn_actions[] = {
+ [1] = ACTION_LAYER_MOMENTARY(2), // to Fn overlay
+ [2] = ACTION_LAYER_MOMENTARY(3), // to Fn overlay
+
+ [3] = ACTION_DEFAULT_LAYER_SET(0),
+ [4] = ACTION_DEFAULT_LAYER_SET(1),
+
+ [10] = ACTION_MODS_KEY(MOD_LSFT, KC_1),
+ [11] = ACTION_MODS_KEY(MOD_LSFT, KC_2),
+ [12] = ACTION_MODS_KEY(MOD_LSFT, KC_3),
+ [13] = ACTION_MODS_KEY(MOD_LSFT, KC_4),
+ [14] = ACTION_MODS_KEY(MOD_LSFT, KC_5),
+ [15] = ACTION_MODS_KEY(MOD_LSFT, KC_6),
+ [16] = ACTION_MODS_KEY(MOD_LSFT, KC_7),
+ [17] = ACTION_MODS_KEY(MOD_LSFT, KC_8),
+ [18] = ACTION_MODS_KEY(MOD_LSFT, KC_9),
+ [19] = ACTION_MODS_KEY(MOD_LSFT, KC_0),
+ [20] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS),
+ [21] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL),
+ [22] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV),
+ [23] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC),
+ [24] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC),
+ [28] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),
+ [29] = ACTION_MODS_KEY(MOD_LSFT, KC_QUOT),
+};
diff --git a/keyboard/planck/common_keymaps/keymap_wilba.c b/keyboard/planck/common_keymaps/keymap_wilba.c
new file mode 100644
index 0000000000..9781f8fcd8
--- /dev/null
+++ b/keyboard/planck/common_keymaps/keymap_wilba.c
@@ -0,0 +1,56 @@
+#include "keymap_common.h"
+
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+[0] = KEYMAP( /* Wilba */
+ FN27, FN28, FN29, E, R, T, Y, U, I, O, P, BSPC,
+ TAB, A, S, D, F, G, H, J, K, L, SCLN, QUOT,
+ LSFT, Z, X, C, V, B, N, M, COMM, DOT, SLSH, ENT,
+ LCTL, LGUI, LALT, RSFT, FN1, SPC, FN2, LEFT, DOWN, UP, RGHT),
+[1] = KEYMAP( /* Wilba Alternate */
+ ESC, Q, W, E, R, T, Y, U, I, O, P, BSPC,
+ TAB, A, S, D, F, G, H, J, K, L, SCLN, QUOT,
+ LSFT, Z, X, C, V, B, N, M, COMM, DOT, SLSH, ENT,
+ LCTL, LGUI, LALT, RSFT, FN1, SPC, FN2, LEFT, DOWN, UP, RGHT),
+[2] = KEYMAP( /* Wilba LOWER */
+ TRNS, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, TRNS,
+ TRNS, F11, F12, LBRC, RBRC, FN20, EQL, FN23, FN24, MINS, FN21, TRNS,
+ TRNS, BSLS, GRV, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
+ TRNS, TRNS, TRNS, TRNS, FN1, TRNS, TRNS, MNXT, VOLD, VOLU, MPLY),
+[3] = KEYMAP( /* Wilba RAISE */
+ TRNS, FN10, FN11, FN12, FN13, FN14, FN15, FN16, FN17, FN18, FN19, TRNS,
+ TRNS, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, TRNS,
+ TRNS, FN25, FN22, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
+ TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, FN2, TRNS, TRNS, TRNS, TRNS),
+};
+const uint16_t PROGMEM fn_actions[] = {
+ [1] = ACTION_LAYER_MOMENTARY(2), // LOWER
+ [2] = ACTION_LAYER_MOMENTARY(3), // RAISE
+
+ [3] = ACTION_DEFAULT_LAYER_SET(0),
+ [4] = ACTION_DEFAULT_LAYER_SET(1),
+
+ [10] = ACTION_MODS_KEY(MOD_LSFT, KC_1), // !
+ [11] = ACTION_MODS_KEY(MOD_LSFT, KC_2), // @
+ [12] = ACTION_MODS_KEY(MOD_LSFT, KC_3), // #
+ [13] = ACTION_MODS_KEY(MOD_LSFT, KC_4), // $
+ [14] = ACTION_MODS_KEY(MOD_LSFT, KC_5), // %
+ [15] = ACTION_MODS_KEY(MOD_LSFT, KC_6), // ^
+ [16] = ACTION_MODS_KEY(MOD_LSFT, KC_7), // &
+ [17] = ACTION_MODS_KEY(MOD_LSFT, KC_8), // *
+ [18] = ACTION_MODS_KEY(MOD_LSFT, KC_9), // (
+ [19] = ACTION_MODS_KEY(MOD_LSFT, KC_0), // )
+
+ [20] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS), // _
+ [21] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL), // +
+ [22] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV), // ~
+ [23] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC), // {
+ [24] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC), // }
+ [25] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS), // |
+
+ [26] = ACTION_MODS_KEY(MOD_LSFT | MOD_RSFT, KC_PAUSE),
+
+ [27] = ACTION_BACKLIGHT_TOGGLE(),
+ [28] = ACTION_BACKLIGHT_INCREASE(),
+ [29] = ACTION_BACKLIGHT_DECREASE()
+
+};
diff --git a/keyboard/planck/config.h b/keyboard/planck/config.h
index 81637f45b2..4e49a2b897 100644
--- a/keyboard/planck/config.h
+++ b/keyboard/planck/config.h
@@ -23,9 +23,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define VENDOR_ID 0xFEED
#define PRODUCT_ID 0x6060
#define DEVICE_VER 0x0001
-#define MANUFACTURER jackhumbert
+#define MANUFACTURER Ortholinear Keyboards
#define PRODUCT Planck
-#define DESCRIPTION t.m.k. keyboard firmware for the Planck
+#define DESCRIPTION A compact ortholinear keyboard
/* key matrix size */
#define MATRIX_ROWS 4
@@ -34,6 +34,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* define if matrix has ghost */
//#define MATRIX_HAS_GHOST
+/* number of backlight levels */
+/* NOTE: this is the max value of 0..BACKLIGHT_LEVELS so really 16 levels. */
+#define BACKLIGHT_LEVELS 15
+
/* Set 0 if debouncing isn't needed */
#define DEBOUNCE 5
diff --git a/keyboard/planck/extended_keymap_common.c b/keyboard/planck/extended_keymap_common.c
new file mode 100644
index 0000000000..841b249431
--- /dev/null
+++ b/keyboard/planck/extended_keymap_common.c
@@ -0,0 +1,208 @@
+/*
+Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "extended_keymap_common.h"
+#include "report.h"
+#include "keycode.h"
+#include "action_layer.h"
+#include "action.h"
+#include "action_macro.h"
+#include "debug.h"
+#include "backlight.h"
+
+
+static action_t keycode_to_action(uint16_t keycode);
+
+
+/* converts key to action */
+action_t action_for_key(uint8_t layer, keypos_t key)
+{
+ // 16bit keycodes - important
+ uint16_t keycode = keymap_key_to_keycode(layer, key);
+
+ if (keycode >= 0x0100 && keycode < 0x2000) {
+ // Has a modifier
+ action_t action;
+ // Split it up
+ action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF);
+ return action;
+ } else if (keycode >= 0x2000 && keycode < 0x3000) {
+ // Is a shortcut for function layer, pull last 12bits
+ return keymap_func_to_action(keycode & 0xFFF);
+ } else if (keycode >= 0x3000 && keycode < 0x4000) {
+ action_t action;
+ action.code = ACTION_MACRO(keycode & 0xFF);
+ return action;
+ } else if (keycode >= BL_0 & keycode <= BL_15) {
+ action_t action;
+ action.code = ACTION_BACKLIGHT_LEVEL(keycode & 0x000F);
+ return action;
+ } else if (keycode == BL_DEC) {
+ action_t action;
+ action.code = ACTION_BACKLIGHT_DECREASE();
+ return action;
+ } else if (keycode == BL_INC) {
+ action_t action;
+ action.code = ACTION_BACKLIGHT_INCREASE();
+ return action;
+ } else if (keycode == BL_TOGG) {
+ action_t action;
+ action.code = ACTION_BACKLIGHT_TOGGLE();
+ return action;
+ } else if (keycode == BL_STEP) {
+ action_t action;
+ action.code = ACTION_BACKLIGHT_STEP();
+ return action;
+ } else if (keycode == RESET) {
+ bootloader_jump();
+ return;
+ }
+
+ switch (keycode) {
+ case KC_FN0 ... KC_FN31:
+ return keymap_fn_to_action(keycode);
+#ifdef BOOTMAGIC_ENABLE
+ case KC_CAPSLOCK:
+ case KC_LOCKING_CAPS:
+ if (keymap_config.swap_control_capslock || keymap_config.capslock_to_control) {
+ return keycode_to_action(KC_LCTL);
+ }
+ return keycode_to_action(keycode);
+ case KC_LCTL:
+ if (keymap_config.swap_control_capslock) {
+ return keycode_to_action(KC_CAPSLOCK);
+ }
+ return keycode_to_action(KC_LCTL);
+ case KC_LALT:
+ if (keymap_config.swap_lalt_lgui) {
+ if (keymap_config.no_gui) {
+ return keycode_to_action(ACTION_NO);
+ }
+ return keycode_to_action(KC_LGUI);
+ }
+ return keycode_to_action(KC_LALT);
+ case KC_LGUI:
+ if (keymap_config.swap_lalt_lgui) {
+ return keycode_to_action(KC_LALT);
+ }
+ if (keymap_config.no_gui) {
+ return keycode_to_action(ACTION_NO);
+ }
+ return keycode_to_action(KC_LGUI);
+ case KC_RALT:
+ if (keymap_config.swap_ralt_rgui) {
+ if (keymap_config.no_gui) {
+ return keycode_to_action(ACTION_NO);
+ }
+ return keycode_to_action(KC_RGUI);
+ }
+ return keycode_to_action(KC_RALT);
+ case KC_RGUI:
+ if (keymap_config.swap_ralt_rgui) {
+ return keycode_to_action(KC_RALT);
+ }
+ if (keymap_config.no_gui) {
+ return keycode_to_action(ACTION_NO);
+ }
+ return keycode_to_action(KC_RGUI);
+ case KC_GRAVE:
+ if (keymap_config.swap_grave_esc) {
+ return keycode_to_action(KC_ESC);
+ }
+ return keycode_to_action(KC_GRAVE);
+ case KC_ESC:
+ if (keymap_config.swap_grave_esc) {
+ return keycode_to_action(KC_GRAVE);
+ }
+ return keycode_to_action(KC_ESC);
+ case KC_BSLASH:
+ if (keymap_config.swap_backslash_backspace) {
+ return keycode_to_action(KC_BSPACE);
+ }
+ return keycode_to_action(KC_BSLASH);
+ case KC_BSPACE:
+ if (keymap_config.swap_backslash_backspace) {
+ return keycode_to_action(KC_BSLASH);
+ }
+ return keycode_to_action(KC_BSPACE);
+#endif
+ default:
+ return keycode_to_action(keycode);
+ }
+}
+
+
+/* Macro */
+__attribute__ ((weak))
+const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
+{
+ return MACRO_NONE;
+}
+
+/* Function */
+__attribute__ ((weak))
+void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
+{
+}
+
+/* translates keycode to action */
+static action_t keycode_to_action(uint16_t keycode)
+{
+ action_t action;
+ switch (keycode) {
+ case KC_A ... KC_EXSEL:
+ case KC_LCTRL ... KC_RGUI:
+ action.code = ACTION_KEY(keycode);
+ break;
+ case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE:
+ action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode));
+ break;
+ case KC_AUDIO_MUTE ... KC_WWW_FAVORITES:
+ action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode));
+ break;
+ case KC_MS_UP ... KC_MS_ACCEL2:
+ action.code = ACTION_MOUSEKEY(keycode);
+ break;
+ case KC_TRNS:
+ action.code = ACTION_TRANSPARENT;
+ break;
+ default:
+ action.code = ACTION_NO;
+ break;
+ }
+ return action;
+}
+
+
+/* translates key to keycode */
+uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
+{
+ // Read entire word (16bits)
+ return pgm_read_word(&keymaps[(layer)][(key.row)][(key.col)]);
+}
+
+/* translates Fn keycode to action */
+action_t keymap_fn_to_action(uint16_t keycode)
+{
+ return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) };
+}
+
+action_t keymap_func_to_action(uint16_t keycode)
+{
+ // For FUNC without 8bit limit
+ return (action_t){ .code = pgm_read_word(&fn_actions[(int)keycode]) };
+}
diff --git a/keyboard/planck/extended_keymap_common.h b/keyboard/planck/extended_keymap_common.h
new file mode 100644
index 0000000000..21d8978b7b
--- /dev/null
+++ b/keyboard/planck/extended_keymap_common.h
@@ -0,0 +1,177 @@
+/*
+Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef KEYMAP_H
+#define KEYMAP_H
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "action.h"
+#include <avr/pgmspace.h>
+#include "keycode.h"
+#include "keymap.h"
+#include "action_macro.h"
+#include "report.h"
+#include "host.h"
+#include "print.h"
+#include "debug.h"
+
+#ifdef BOOTMAGIC_ENABLE
+/* NOTE: Not portable. Bit field order depends on implementation */
+typedef union {
+ uint16_t raw;
+ struct {
+ bool swap_control_capslock:1;
+ bool capslock_to_control:1;
+ bool swap_lalt_lgui:1;
+ bool swap_ralt_rgui:1;
+ bool no_gui:1;
+ bool swap_grave_esc:1;
+ bool swap_backslash_backspace:1;
+ bool nkro:1;
+ };
+} keymap_config_t;
+keymap_config_t keymap_config;
+#endif
+
+/* translates key to keycode */
+uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key);
+
+/* translates Fn keycode to action */
+action_t keymap_fn_to_action(uint16_t keycode);
+
+/* translates Fn keycode to action */
+action_t keymap_func_to_action(uint16_t keycode);
+
+extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
+extern const uint16_t fn_actions[];
+
+// Ability to use mods in layouts
+#define LCTL(kc) kc | 0x0100
+#define LSFT(kc) kc | 0x0200
+#define LALT(kc) kc | 0x0400
+#define LGUI(kc) kc | 0x0800
+#define RCTL(kc) kc | 0x1100
+#define RSFT(kc) kc | 0x1200
+#define RALT(kc) kc | 0x1400
+#define RGUI(kc) kc | 0x1800
+
+// Alias for function layers than expand past FN31
+#define FUNC(kc) kc | 0x2000
+
+// Aliases
+#define S(kc) LSFT(kc)
+#define F(kc) FUNC(kc)
+
+// For software implementation of colemak
+#define CM_Q KC_Q
+#define CM_W KC_W
+#define CM_F KC_E
+#define CM_P KC_R
+#define CM_G KC_T
+#define CM_J KC_Y
+#define CM_L KC_U
+#define CM_U KC_I
+#define CM_Y KC_O
+#define CM_SCLN KC_P
+
+#define CM_A KC_A
+#define CM_R KC_S
+#define CM_S KC_D
+#define CM_T KC_F
+#define CM_D KC_G
+#define CM_H KC_H
+#define CM_N KC_J
+#define CM_E KC_K
+#define CM_I KC_L
+#define CM_O KC_SCLN
+
+#define CM_Z KC_Z
+#define CM_X KC_X
+#define CM_C KC_C
+#define CM_V KC_V
+#define CM_B KC_B
+#define CM_K KC_N
+#define CM_M KC_M
+#define CM_COMM KC_COMM
+#define CM_DOT KC_DOT
+#define CM_SLSH KC_SLSH
+
+// Make it easy to support these in macros
+#define KC_CM_Q CM_Q
+#define KC_CM_W CM_W
+#define KC_CM_F CM_F
+#define KC_CM_P CM_P
+#define KC_CM_G CM_G
+#define KC_CM_J CM_J
+#define KC_CM_L CM_L
+#define KC_CM_U CM_U
+#define KC_CM_Y CM_Y
+#define KC_CM_SCLN CM_SCLN
+
+#define KC_CM_A CM_A
+#define KC_CM_R CM_R
+#define KC_CM_S CM_S
+#define KC_CM_T CM_T
+#define KC_CM_D CM_D
+#define KC_CM_H CM_H
+#define KC_CM_N CM_N
+#define KC_CM_E CM_E
+#define KC_CM_I CM_I
+#define KC_CM_O CM_O
+
+#define KC_CM_Z CM_Z
+#define KC_CM_X CM_X
+#define KC_CM_C CM_C
+#define KC_CM_V CM_V
+#define KC_CM_B CM_B
+#define KC_CM_K CM_K
+#define KC_CM_M CM_M
+#define KC_CM_COMM CM_COMM
+#define KC_CM_DOT CM_DOT
+#define KC_CM_SLSH CM_SLSH
+
+#define M(kc) kc | 0x3000
+
+#define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE)
+
+#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
+
+#define RESET 0x5000
+
+#endif
diff --git a/keyboard/planck/extended_keymaps/extended_keymap_austin.c b/keyboard/planck/extended_keymaps/extended_keymap_austin.c
new file mode 100644
index 0000000000..35330be747
--- /dev/null
+++ b/keyboard/planck/extended_keymaps/extended_keymap_austin.c
@@ -0,0 +1,50 @@
+#include "extended_keymap_common.h"
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+[0] = { /* 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},
+ {BL_STEP, KC_LGUI, KC_LALT, KC_LCTL, FUNC(2), KC_SPC, KC_SPC, FUNC(1), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
+ // Space is repeated to accommadate for both spacebar wiring positions
+},
+[1] = { /* 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_FN3, KC_LGUI, KC_LALT, KC_LCTL, FUNC(2), KC_SPC, KC_SPC, FUNC(1), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
+},
+[2] = { /* 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_TRNS, FUNC(3), FUNC(4), LSFT(RSFT(KC_PAUSE)), KC_TRNS, KC_TRNS, KC_TRNS, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS},
+ {KC_TRNS, KC_F11, KC_F12, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, KC_TRNS},
+ {KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, FUNC(1), KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
+},
+[3] = { /* LOWER */
+ {S(KC_GRV), S(KC_1), S(KC_2), S(KC_3), S(KC_4), S(KC_5), S(KC_6), S(KC_7), S(KC_8), S(KC_9), S(KC_0), KC_BSPC},
+ {KC_TRNS, FUNC(3), FUNC(4), LSFT(RSFT(KC_PAUSE)), KC_TRNS, KC_TRNS, KC_TRNS, S(KC_MINS), S(KC_EQL), S(KC_LBRC), S(KC_RBRC), S(KC_BSLS)},
+ {KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_TRNS},
+ {KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, FUNC(2), KC_TRNS, KC_TRNS, KC_TRNS, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
+}
+};
+
+
+const uint16_t PROGMEM fn_actions[] = {
+ [1] = ACTION_LAYER_MOMENTARY(2), // to RAISE
+ [2] = ACTION_LAYER_MOMENTARY(3), // to LOWER
+
+ [3] = ACTION_DEFAULT_LAYER_SET(0),
+ [4] = ACTION_DEFAULT_LAYER_SET(1),
+
+};
+
+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:
+ return MACRODOWN(T(CM_T), END);
+ break;
+ }
+ return MACRO_NONE;
+};
diff --git a/keyboard/planck/extended_keymaps/extended_keymap_charlie.c b/keyboard/planck/extended_keymaps/extended_keymap_charlie.c
new file mode 100644
index 0000000000..18657c8e41
--- /dev/null
+++ b/keyboard/planck/extended_keymaps/extended_keymap_charlie.c
@@ -0,0 +1,54 @@
+#include "extended_keymap_common.h"
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ [0] = { /* Native */
+ {KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, FUNC(2)},
+ {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_TAB, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT},
+ {KC_DEL, KC_LCTL, KC_NO, KC_LSFT, KC_LALT, KC_SPC, KC_NO, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
+},
+ [1] = { /* QWERTY->PHOTOSHOP */
+ {KC_DELETE, KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, FUNC(1)},
+ {KC_O, KC_G, KC_S, KC_U, KC_T, FUNC(27), KC_F21, KC_F10, KC_F11, KC_F7, KC_F8, KC_F9},
+ {KC_TAB, FUNC(4), FUNC(5), FUNC(6), KC_F1, FUNC(7), KC_F18, KC_F19, KC_F23, KC_F20, KC_F22, FUNC(9)},
+ {KC_COMM, KC_DOT, KC_R, FUNC(11), FUNC(3), KC_SPC, FUNC(12), KC_F2, FUNC(8), KC_F3, KC_F14}
+ },
+ [2] = { /* 2: FUNC(3 PHOTOSHOP */
+ {KC_ESC, FUNC(25), FUNC(26), KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO},
+ {KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, FUNC(19), FUNC(20), FUNC(21)},
+ {KC_C, KC_NO, FUNC(22), FUNC(5), KC_NO, FUNC(23), KC_NO, KC_NO, KC_NO, KC_NO, FUNC(13), KC_NO},
+ {FUNC(14), FUNC(15), FUNC(16), FUNC(17), FUNC(3), KC_SPC, FUNC(18), KC_NO, KC_NO, KC_F24, KC_NO}
+ }
+};
+
+const uint16_t PROGMEM fn_actions[] = {
+ [1] = ACTION_DEFAULT_LAYER_SET(0), // set Qwerty layout
+ [2] = ACTION_DEFAULT_LAYER_SET(1), // set Photoshop presets
+ [3] = ACTION_LAYER_MOMENTARY(2), // Photoshop function layer
+
+ [4] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL | MOD_LALT, KC_F9), // photo folder AHK
+ [5] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL, KC_I), // select inverse
+ [6] = ACTION_MODS_KEY(MOD_LSFT, KC_M), // marquee select
+ [7] = ACTION_MODS_KEY(MOD_LALT, KC_BSPC), // fill
+ [8] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL | MOD_LALT, KC_X), // warp
+ [9] = ACTION_MODS_KEY(MOD_LCTL | MOD_LALT | MOD_LSFT, KC_F12), // merge all new layer
+ [10] = ACTION_MODS_KEY(MOD_LCTL, KC_MINS), // zoom out
+ [11] = ACTION_MODS_KEY(MOD_LCTL, KC_H), // RBG sliders
+ [12] = ACTION_MODS_KEY(MOD_LCTL, KC_S), // save
+ [13] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL, KC_F5), // layer mask from transparancy
+ [14] = ACTION_MODS_KEY(MOD_LCTL, KC_F2), // stroke
+ [15] = ACTION_MODS_KEY(MOD_LCTL | MOD_LSFT, KC_F2), // stroke layer
+ [16] = ACTION_MODS_KEY(MOD_LCTL, KC_0), // zoom 0
+ [17] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL, KC_H), // HSV sliders
+ [18] = ACTION_MODS_KEY(MOD_LCTL | MOD_LSFT, KC_S), // save as
+ [19] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL | MOD_LALT, KC_F7), // gaussian blur
+ [20] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL | MOD_LALT, KC_F8), // motion blur
+ [21] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL, KC_X), // liquify filter
+ [22] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS), // prev layer blending
+ [23] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL, KC_BSPC), // KC_NOrmal layer blending
+ [24] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL), // next layer blending
+ [25] = ACTION_MODS_KEY(MOD_LCTL, KC_Z), // step back
+ [26] = ACTION_MODS_KEY(MOD_LCTL, KC_Y), // step forward
+ [27] = ACTION_MODS_KEY(MOD_LCTL, KC_R), // rasterize
+
+};
diff --git a/keyboard/planck/extended_keymaps/extended_keymap_default.c b/keyboard/planck/extended_keymaps/extended_keymap_default.c
new file mode 100644
index 0000000000..c35b283675
--- /dev/null
+++ b/keyboard/planck/extended_keymaps/extended_keymap_default.c
@@ -0,0 +1,50 @@
+#include "extended_keymap_common.h"
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+[0] = { /* 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},
+ {BL_STEP, KC_LCTL, KC_LALT, KC_LGUI, FUNC(2), KC_SPC, KC_SPC, FUNC(1), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
+ // Space is repeated to accommadate for both spacebar wiring positions
+},
+[1] = { /* 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_FN3, KC_LCTL, KC_LALT, KC_LGUI, FUNC(2), KC_SPC, KC_SPC, FUNC(1), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
+},
+[2] = { /* 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_TRNS, FUNC(3), FUNC(4), LSFT(RSFT(KC_PAUSE)), KC_TRNS, KC_TRNS, KC_TRNS, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS},
+ {KC_TRNS, KC_F11, KC_F12, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, KC_TRNS},
+ {KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, FUNC(1), KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
+},
+[3] = { /* LOWER */
+ {S(KC_GRV), S(KC_1), S(KC_2), S(KC_3), S(KC_4), S(KC_5), S(KC_6), S(KC_7), S(KC_8), S(KC_9), S(KC_0), KC_BSPC},
+ {KC_TRNS, FUNC(3), FUNC(4), LSFT(RSFT(KC_PAUSE)), KC_TRNS, KC_TRNS, KC_TRNS, S(KC_MINS), S(KC_EQL), S(KC_LBRC), S(KC_RBRC), S(KC_BSLS)},
+ {KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_TRNS},
+ {KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, FUNC(2), KC_TRNS, KC_TRNS, KC_TRNS, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
+}
+};
+
+
+const uint16_t PROGMEM fn_actions[] = {
+ [1] = ACTION_LAYER_MOMENTARY(2), // to RAISE
+ [2] = ACTION_LAYER_MOMENTARY(3), // to LOWER
+
+ [3] = ACTION_DEFAULT_LAYER_SET(0),
+ [4] = ACTION_DEFAULT_LAYER_SET(1),
+
+};
+
+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:
+ return MACRODOWN(T(CM_T), END);
+ break;
+ }
+ return MACRO_NONE;
+};
diff --git a/keyboard/planck/extended_keymaps/extended_keymap_jack.c b/keyboard/planck/extended_keymaps/extended_keymap_jack.c
new file mode 100644
index 0000000000..d39dc5b84c
--- /dev/null
+++ b/keyboard/planck/extended_keymaps/extended_keymap_jack.c
@@ -0,0 +1,50 @@
+#include "extended_keymap_common.h"
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+[0] = { /* Jack soft-coded colemak */
+ {KC_TAB, CM_Q, CM_W, CM_F, CM_P, CM_G, CM_J, CM_L, CM_U, CM_Y, CM_SCLN, KC_BSPC},
+ {KC_ESC, CM_A, CM_R, CM_S, CM_T, CM_D, CM_H, CM_N, CM_E, CM_I, CM_O, KC_QUOT},
+ {KC_LSFT, CM_Z, CM_X, CM_C, CM_V, CM_B, CM_K, CM_M, CM_COMM, CM_DOT, CM_SLSH, KC_ENT},
+ {BL_STEP, KC_LCTL, KC_LALT, KC_LGUI, FUNC(2), KC_SPC, KC_SPC, FUNC(1), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
+ // Space is repeated to accommadate for both spacebar wiring positions
+},
+[1] = { /* Jack hard-coded 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_FN3, KC_LCTL, KC_LALT, KC_LGUI, FUNC(2), KC_SPC, KC_SPC, FUNC(1), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
+},
+[2] = { /* Jack 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_TRNS, FUNC(3), FUNC(4), LSFT(RSFT(KC_PAUSE)), KC_TRNS, KC_TRNS, KC_TRNS, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS},
+ {KC_TRNS, KC_F11, KC_F12, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, KC_TRNS},
+ {KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, FUNC(1), KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
+},
+[3] = { /* Jack LOWER */
+ {S(KC_GRV), S(KC_1), S(KC_2), S(KC_3), S(KC_4), S(KC_5), S(KC_6), S(KC_7), S(KC_8), S(KC_9), S(KC_0), KC_BSPC},
+ {KC_TRNS, FUNC(3), FUNC(4), LSFT(RSFT(KC_PAUSE)), KC_TRNS, KC_TRNS, KC_TRNS, S(KC_MINS), S(KC_EQL), S(KC_LBRC), S(KC_RBRC), S(KC_BSLS)},
+ {KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_TRNS},
+ {KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, FUNC(2), KC_TRNS, KC_TRNS, KC_TRNS, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
+}
+};
+
+
+const uint16_t PROGMEM fn_actions[] = {
+ [1] = ACTION_LAYER_MOMENTARY(2), // to Fn overlay
+ [2] = ACTION_LAYER_MOMENTARY(3), // to Fn overlay
+
+ [3] = ACTION_DEFAULT_LAYER_SET(0),
+ [4] = ACTION_DEFAULT_LAYER_SET(1),
+
+};
+
+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:
+ return MACRODOWN(T(CM_T), END);
+ break;
+ }
+ return MACRO_NONE;
+};
diff --git a/keyboard/planck/keymap_common.h b/keyboard/planck/keymap_common.h
index 8a55fd9ee0..d888d81733 100644
--- a/keyboard/planck/keymap_common.h
+++ b/keyboard/planck/keymap_common.h
@@ -35,19 +35,41 @@ extern const uint16_t fn_actions[];
// MIT Layout
+/*
+ * ,-----------------------------------------------------------------------.
+ * | | | | | | | | | | | | |
+ * |-----------------------------------------------------------------------|
+ * | | | | | | | | | | | | |
+ * |-----------------------------------------------------------------------|
+ * | | | | | | | | | | | | |
+ * |-----------------------------------------------------------------------|
+ * | | | | | | | | | | | |
+ * `-----------------------------------------------------------------------'
+ */
#define KEYMAP( \
K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, \
K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, \
K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, \
- K30, K31, K32, K33, K34, K35, K37, K38, K39, K3A, K3B \
+ K30, K31, K32, K33, K34, K35, K37, K38, K39, K3A, K3B \
) { \
{ KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B }, \
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B }, \
{ KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B }, \
- { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_NO, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B } \
+ { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K35, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B } \
}
// Grid Layout
+/*
+ * ,-----------------------------------------------------------------------.
+ * | | | | | | | | | | | | |
+ * |-----------------------------------------------------------------------|
+ * | | | | | | | | | | | | |
+ * |-----------------------------------------------------------------------|
+ * | | | | | | | | | | | | |
+ * |-----------------------------------------------------------------------|
+ * | | | | | | | | | | | | |
+ * `-----------------------------------------------------------------------'
+ */
#define KEYMAP_GRID( \
K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, \
K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, \
diff --git a/keyboard/planck/keymap_sean.c b/keyboard/planck/keymap_sean.c
deleted file mode 100644
index 9ad572a72c..0000000000
--- a/keyboard/planck/keymap_sean.c
+++ /dev/null
@@ -1,50 +0,0 @@
-#include "keymap_common.h"
-
-const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
- [0] = KEYMAP( /* Matrix Dvorak */
- QUOT, COMM, DOT, P, Y, SLSH, EQL, F, G, C, R, L,
- A, O, E, U, I, ESC, BSPC, D, H, T, N, S,
- SCLN, Q, J, K, X, TAB, ENT, B, M, W, V, Z,
- LSFT, LCTL, LALT, LGUI, FN1, SPC, FN2, LEFT, DOWN, UP, RGHT),
-
- [1] = KEYMAP( /* Matrix Qwerty */
- Q, W, E, R, T, SLSH, EQL, Y, U, I, O, P,
- A, S, D, F, G, ESC, BSPC, H, J, K, L, SCLN,
- Z, X, C, V, B, TAB, ENT, N, M, COMM, DOT, SLSH,
- LSFT, LCTL, LALT, LGUI, FN1, SPC, FN2, LEFT, DOWN, UP, RGHT),
-
- [2] = KEYMAP( /* fn1 lower */
- F1, F2, F3, F4, F5, TRNS, TRNS, F6, F7, F8, F9, F10,
- 1, 2, 3, 4, 5, ESC, DEL, 6, 7, 8, 9, 0,
- FN3, FN4, TRNS, GRV, MINS, TRNS, TRNS, BSLS, LBRC, RBRC, TRNS, TRNS,
- TRNS, TRNS, TRNS, TRNS, FN1, TRNS, TRNS, HOME, PGDN, PGUP, END),
-
- [3] = KEYMAP( /* fn2 raise */
- F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12,
- FN10, FN11, FN12, FN13, FN14, ESC, DEL, FN15, FN16, FN17, FN18, FN19,
- FN3, FN4, TRNS, FN22, FN20, TRNS, TRNS, FN28, FN23, FN24, TRNS, TRNS,
- TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, FN2, MNXT, VOLD, VOLU, MPLY),
-};
-const uint16_t PROGMEM fn_actions[] = {
- [1] = ACTION_LAYER_MOMENTARY(2), // to Fn overlay
- [2] = ACTION_LAYER_MOMENTARY(3), // to Fn overlay
- [3] = ACTION_DEFAULT_LAYER_SET(0),
- [4] = ACTION_DEFAULT_LAYER_SET(1),
-
- [10] = ACTION_MODS_KEY(MOD_LSFT, KC_1),
- [11] = ACTION_MODS_KEY(MOD_LSFT, KC_2),
- [12] = ACTION_MODS_KEY(MOD_LSFT, KC_3),
- [13] = ACTION_MODS_KEY(MOD_LSFT, KC_4),
- [14] = ACTION_MODS_KEY(MOD_LSFT, KC_5),
- [15] = ACTION_MODS_KEY(MOD_LSFT, KC_6),
- [16] = ACTION_MODS_KEY(MOD_LSFT, KC_7),
- [17] = ACTION_MODS_KEY(MOD_LSFT, KC_8),
- [18] = ACTION_MODS_KEY(MOD_LSFT, KC_9),
- [19] = ACTION_MODS_KEY(MOD_LSFT, KC_0),
- [20] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS),
- [21] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL),
- [22] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV),
- [23] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC),
- [24] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC),
- [28] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),
-}; \ No newline at end of file
diff --git a/keyboard/planck/led.c b/keyboard/planck/led.c
index 6cffd5ea7b..2c05746607 100644
--- a/keyboard/planck/led.c
+++ b/keyboard/planck/led.c
@@ -22,13 +22,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
void led_set(uint8_t usb_led)
{
- // if (usb_led & (1<<USB_LED_FUNCTION)) {
+ // // Using PE6 Caps Lock LED
+ // if (usb_led & (1<<USB_LED_CAPS_LOCK))
+ // {
// // Output high.
- // DDRF |= (1<<0);
- // PORTF |= (1<<0);
- // } else {
+ // DDRE |= (1<<6);
+ // PORTE |= (1<<6);
+ // }
+ // else
+ // {
// // Output low.
- // DDRF &= ~(1<<0);
- // PORTF &= ~(1<<0);
+ // DDRE &= ~(1<<6);
+ // PORTE &= ~(1<<6);
// }
}
diff --git a/keyboard/planck/matrix.c b/keyboard/planck/matrix.c
index 38d35e3e07..2f2dbdb108 100644
--- a/keyboard/planck/matrix.c
+++ b/keyboard/planck/matrix.c
@@ -190,4 +190,4 @@ static void select_row(uint8_t row)
break;
}
-} \ No newline at end of file
+}
diff --git a/keyboard/planck/matrix_center.c b/keyboard/planck/matrix_center.c
new file mode 100644
index 0000000000..8e34130d6f
--- /dev/null
+++ b/keyboard/planck/matrix_center.c
@@ -0,0 +1,202 @@
+/*
+Copyright 2012 Jun Wako <wakojun@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+ * scan matrix
+ */
+#include <stdint.h>
+#include <stdbool.h>
+#include <avr/io.h>
+#include <util/delay.h>
+#include "action_layer.h"
+#include "print.h"
+#include "debug.h"
+#include "util.h"
+#include "matrix.h"
+
+
+#ifndef DEBOUNCE
+# define DEBOUNCE 10
+#endif
+static uint8_t debouncing = DEBOUNCE;
+
+/* matrix state(1:on, 0:off) */
+static matrix_row_t matrix[MATRIX_ROWS];
+static matrix_row_t matrix_debouncing[MATRIX_ROWS];
+
+static matrix_row_t read_cols(void);
+static void init_cols(void);
+static void unselect_rows(void);
+static void select_row(uint8_t row);
+
+
+inline
+uint8_t matrix_rows(void)
+{
+ return MATRIX_ROWS;
+}
+
+inline
+uint8_t matrix_cols(void)
+{
+ return MATRIX_COLS;
+}
+
+void matrix_init(void)
+{
+ // initialize row and col
+ unselect_rows();
+ init_cols();
+
+ // initialize matrix state: all keys off
+ for (uint8_t i=0; i < MATRIX_ROWS; i++) {
+ matrix[i] = 0;
+ matrix_debouncing[i] = 0;
+ }
+}
+
+uint8_t matrix_scan(void)
+{
+ for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+ select_row(i);
+ _delay_us(30); // without this wait read unstable value.
+ matrix_row_t cols = read_cols();
+ if (matrix_debouncing[i] != cols) {
+ matrix_debouncing[i] = cols;
+ if (debouncing) {
+ debug("bounce!: "); debug_hex(debouncing); debug("\n");
+ }
+ debouncing = DEBOUNCE;
+ }
+ unselect_rows();
+ }
+
+ if (debouncing) {
+ if (--debouncing) {
+ _delay_ms(1);
+ } else {
+ for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+ matrix[i] = matrix_debouncing[i];
+ }
+ }
+ }
+
+ return 1;
+}
+
+bool matrix_is_modified(void)
+{
+ if (debouncing) return false;
+ return true;
+}
+
+inline
+bool matrix_is_on(uint8_t row, uint8_t col)
+{
+ return (matrix[row] & ((matrix_row_t)1<<col));
+}
+
+inline
+matrix_row_t matrix_get_row(uint8_t row)
+{
+ return matrix[row];
+}
+
+void matrix_print(void)
+{
+ print("\nr/c 0123456789ABCDEF\n");
+ for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+ phex(row); print(": ");
+ pbin_reverse16(matrix_get_row(row));
+ print("\n");
+ }
+}
+
+uint8_t matrix_key_count(void)
+{
+ uint8_t count = 0;
+ for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+ count += bitpop16(matrix[i]);
+ }
+ return count;
+}
+
+/* Column pin configuration
+ * col: 0 1 2 3 4 5 6 7 8 9 10 11
+ * pin: F0 F1 F4 F5 F6 F7 B6 B5 B4 D7 D5 D4
+ */
+
+static void init_cols(void)
+{
+ DDRF &= ~(1<<0 | 1<<1 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
+ PORTF |= (1<<0 | 1<<1 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
+ DDRD &= ~(1<<0);
+ PORTD |= (1<<0);
+ DDRB &= ~(1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<7);
+ PORTB |= (1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<7);
+}
+
+static matrix_row_t read_cols(void)
+{
+ return (PINB&(1<<0) ? 0 : (1<< 0)) |
+ (PINB&(1<<1) ? 0 : (1<< 1)) |
+ (PINB&(1<<2) ? 0 : (1<< 2)) |
+ (PINB&(1<<3) ? 0 : (1<< 3)) |
+ (PINB&(1<<7) ? 0 : (1<< 4)) |
+ (PIND&(1<<0) ? 0 : (1<< 5)) |
+ (PINF&(1<<7) ? 0 : (1<< 6)) |
+ (PINF&(1<<6) ? 0 : (1<< 7)) |
+ (PINF&(1<<5) ? 0 : (1<< 8)) |
+ (PINF&(1<<4) ? 0 : (1<< 9)) |
+ (PINF&(1<<1) ? 0 : (1<<10)) |
+ (PINF&(1<<0) ? 0 : (1<<11));
+}
+
+/* Row pin configuration
+ * row: 0 1 2 3
+ * pin: B0 B1 B2 B3
+ */
+static void unselect_rows(void)
+{
+ // Hi-Z(DDR:0, PORT:0) to unselect
+ DDRB &= ~0b01110000;
+ PORTB &= ~0b01110000;
+ DDRD &= ~0b10000000;
+ PORTD &= ~0b10000000;
+}
+
+static void select_row(uint8_t row)
+{
+ switch (row) {
+ case 0:
+ DDRB |= (1<<6);
+ PORTB &= ~(1<<6);
+ break;
+ case 1:
+ DDRB |= (1<<5);
+ PORTB &= ~(1<<5);
+ break;
+ case 2:
+ DDRB |= (1<<4);
+ PORTB &= ~(1<<4);
+ break;
+ case 3:
+ DDRD |= (1<<7);
+ PORTD &= ~(1<<7);
+ break;
+ }
+}
diff --git a/keyboard/planck/matrix_pcb.c b/keyboard/planck/matrix_pcb.c
new file mode 100644
index 0000000000..7d46baf3de
--- /dev/null
+++ b/keyboard/planck/matrix_pcb.c
@@ -0,0 +1,222 @@
+/*
+Copyright 2012 Jun Wako
+Generated by planckkeyboard.com (2014 Jack Humbert)
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+ * scan matrix
+ */
+#include <stdint.h>
+#include <stdbool.h>
+#include <avr/io.h>
+#include <util/delay.h>
+#include "print.h"
+#include "debug.h"
+#include "util.h"
+#include "matrix.h"
+#include "backlight.h" // TODO fix this dependency
+
+
+#ifndef DEBOUNCE
+# define DEBOUNCE 10
+#endif
+static uint8_t debouncing = DEBOUNCE;
+
+/* matrix state(1:on, 0:off) */
+static matrix_row_t matrix[MATRIX_ROWS];
+static matrix_row_t matrix_debouncing[MATRIX_ROWS];
+
+static matrix_row_t read_cols(void);
+static void init_cols(void);
+static void unselect_rows(void);
+static void select_row(uint8_t row);
+
+inline
+uint8_t matrix_rows(void)
+{
+ return MATRIX_ROWS;
+}
+
+inline
+uint8_t matrix_cols(void)
+{
+ return MATRIX_COLS;
+}
+
+void matrix_init(void)
+{
+ // To use PORTF disable JTAG with writing JTD bit twice within four cycles.
+ MCUCR |= (1<<JTD);
+ MCUCR |= (1<<JTD);
+
+ backlight_init_ports();
+
+ // Turn status LED on
+ DDRE |= (1<<6);
+ PORTE |= (1<<6);
+
+ // initialize row and col
+ unselect_rows();
+ init_cols();
+
+ // initialize matrix state: all keys off
+ for (uint8_t i=0; i < MATRIX_ROWS; i++) {
+ matrix[i] = 0;
+ matrix_debouncing[i] = 0;
+ }
+}
+
+uint8_t matrix_scan(void)
+{
+ for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+ select_row(i);
+ _delay_us(30); // without this wait read unstable value.
+ matrix_row_t cols = read_cols();
+ if (matrix_debouncing[i] != cols) {
+ matrix_debouncing[i] = cols;
+ if (debouncing) {
+ debug("bounce!: "); debug_hex(debouncing); debug("\n");
+ }
+ debouncing = DEBOUNCE;
+ }
+ unselect_rows();
+ }
+
+ if (debouncing) {
+ if (--debouncing) {
+ _delay_ms(1);
+ } else {
+ for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+ matrix[i] = matrix_debouncing[i];
+ }
+ }
+ }
+
+ return 1;
+}
+
+bool matrix_is_modified(void)
+{
+ if (debouncing) return false;
+ return true;
+}
+
+inline
+bool matrix_is_on(uint8_t row, uint8_t col)
+{
+ return (matrix[row] & ((matrix_row_t)1<col));
+}
+
+inline
+matrix_row_t matrix_get_row(uint8_t row)
+{
+ return matrix[row];
+}
+
+void matrix_print(void)
+{
+ print("\nr/c 0123456789ABCDEF\n");
+ for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+ phex(row); print(": ");
+ pbin_reverse16(matrix_get_row(row));
+ print("\n");
+ }
+}
+
+uint8_t matrix_key_count(void)
+{
+ uint8_t count = 0;
+ for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+ count += bitpop16(matrix[i]);
+ }
+ return count;
+}
+
+//
+// Planck PCB Rev 1 Pin Assignments
+//
+// Column: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
+// Pin: F1, F0, B0, C7, F4, F5, F6, F7, D4, D6, B4, D7
+//
+
+static void init_cols(void)
+{
+ DDRB &= ~(1<<4 | 1<<0);
+ PORTB |= (1<<4 | 1<<0);
+ DDRC &= ~(1<<7);
+ PORTC |= (1<<7);
+ DDRD &= ~(1<<7 | 1<<6 | 1<<4);
+ PORTD |= (1<<7 | 1<<6 | 1<<4);
+ DDRF &= ~(1<<0 | 1<<1 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
+ PORTF |= (1<<0 | 1<<1 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
+
+}
+
+static matrix_row_t read_cols(void)
+{
+ return (PINF&(1<<1) ? 0 : (1<<0)) |
+ (PINF&(1<<0) ? 0 : (1<<1)) |
+ (PINB&(1<<0) ? 0 : (1<<2)) |
+ (PINC&(1<<7) ? 0 : (1<<3)) |
+ (PINF&(1<<4) ? 0 : (1<<4)) |
+ (PINF&(1<<5) ? 0 : (1<<5)) |
+ (PINF&(1<<6) ? 0 : (1<<6)) |
+ (PINF&(1<<7) ? 0 : (1<<7)) |
+ (PIND&(1<<4) ? 0 : (1<<8)) |
+ (PIND&(1<<6) ? 0 : (1<<9)) |
+ (PINB&(1<<4) ? 0 : (1<<10)) |
+ (PIND&(1<<7) ? 0 : (1<<11));
+
+}
+
+static void unselect_rows(void)
+{
+ DDRB &= ~(1<<5 | 1<<6);
+ PORTB |= (1<<5 | 1<<6);
+ DDRD &= ~(1<<0 | 1<<5);
+ PORTD |= (1<<0 | 1<<5);
+
+}
+
+//
+// Planck PCB Rev 1 Pin Assignments
+//
+// Row: 0, 1, 2, 3
+// Pin: D0, D5, B5, B6
+//
+
+static void select_row(uint8_t row)
+{
+ switch (row) {
+ case 0:
+ DDRD |= (1<<0);
+ PORTD &= ~(1<<0);
+ break;
+ case 1:
+ DDRD |= (1<<5);
+ PORTD &= ~(1<<5);
+ break;
+ case 2:
+ DDRB |= (1<<5);
+ PORTB &= ~(1<<5);
+ break;
+ case 3:
+ DDRB |= (1<<6);
+ PORTB &= ~(1<<6);
+ break;
+
+ }
+} \ No newline at end of file