example_keyboards
Christopher Browne 9 years ago
commit d649ab3433

@ -85,6 +85,7 @@ The following shortcuts automatically add `LSFT()` to keycodes to get commonly u
KC_RPRN )
KC_UNDS _
KC_PLUS +
KC_DQUO "
KC_LCBR {
KC_RCBR }
KC_LABK <
@ -118,6 +119,56 @@ We've added shortcuts to make common modifier/tap (mod-tap) mappings more compac
* `LCAG_T(kc)` - is CtrlAltGui when held and *kc* when tapped
* `MEH_T(kc)` - is like Hyper, but not as cool -- does not include the Cmd/Win key, so just sends Alt+Ctrl+Shift.
### Space Cadet Shift: The future, built in
Steve Losh [described](http://stevelosh.com/blog/2012/10/a-modern-space-cadet/) the Space Cadet Shift quite well. Essentially, you hit the left Shift on its own, and you get an opening parenthesis; hit the right Shift on its own, and you get the closing one. When hit with other keys, the Shift key keeps working as it always does. Yes, it's as cool as it sounds.
To use it, use `KC_LSPO` (Left Shift, Parens Open) for your left Shift on your keymap, and `KC_RSPC` (Right Shift, Parens Close) for your right Shift.
The only other thing you're going to want to do is create a `makefile.mk` in your keymap directory and set the following:
```
COMMAND_ENABLE = no # Commands for debug and configuration
```
This is just to keep the keyboard from going into command mode when you hold both Shift keys at the same time.
### The Leader key: A new kind of modifier
If you've ever used Vim, you know what a Leader key is. If not, you're about to discover a wonderful concept. :) Instead of hitting Alt+Shift+W for example (holding down three keys at the same time), what if you could hit a _sequence_ of keys instead? So you'd hit our special modifier (the Leader key), followed by W and then C (just a rapid succession of keys), and something would happen.
That's what `KC_LEAD` does. Here's an example:
1. Pick a key on your keyboard you want to use as the Leader key. Assign it the keycode `KC_LEAD`. This key would be dedicated just for this -- it's a single action key, can't be used for anything else.
2. Include the line `#define LEADER_TIMEOUT 300` somewhere in your keymap.c file, probably near the top. The 300 there is 300ms -- that's how long you have for the sequence of keys following the leader. You can tweak this value for comfort, of course.
3. Within your `matrix_scan_user` function, do something like this:
```
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);
}
}
}
```
As you can see, you have three function. you can use - `SEQ_ONE_KEY` for single-key sequences (Leader followed by just one key), and `SEQ_TWO_KEYS` and `SEQ_THREE_.EYS` for longer sequences. Each of these accepts one or more keycodes as arguments. This is an important point: You can use keycodes from **any layer on your keyboard**. That layer would need to be active for the leader macro to fire, obviously.
### Temporarily setting the default layer
`DF(layer)` - sets default layer to *layer*. The default layer is the one at the "bottom" of the layer stack - the ultimate fallback layer. This currently does not persist over power loss. When you plug the keyboard back in, layer 0 will always be the default. It is theoretically possible to work around that, but that's not what `DF` does.
@ -258,9 +309,9 @@ if (timer_elapsed(key_timer) < 100) {
}
```
It's best to declare the `static uint16_t key_timer;` outside of the macro block (top of file, etc).
It's best to declare the `static uint16_t key_timer;` outside of the macro block (top of file, etc).
#### Example 1: Single-key copy/paste (hold to copy, tap to paste)
#### Example: Single-key copy/paste (hold to copy, tap to paste)
With QMK, it's easy to make one key do two things, as long as one of those things is being a modifier. :) So if you want a key to act as Ctrl when held and send the letter R when tapped, that's easy: `CTL_T(KC_R)`. But what do you do when you want that key to send Ctrl-V (paste) when tapped, and Ctrl-C (copy) when held?
@ -276,7 +327,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
case 0: {
if (record->event.pressed) {
key_timer = timer_read(); // if the key is being pressed, we start the timer.
}
}
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) > 150) { // 150 being 150ms, the threshhold we pick for counting something as a tap.
return MACRO( D(LCTL), T(C), U(LCTL), END );
@ -294,52 +345,6 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
And then, to assign this macro to a key on your keyboard layout, you just use `M(0)` on the key you want to press for copy/paste.
#### Example 2: Space Cadet Shift (making it easy to send opening and closing parentheses)
In the [Modern Space Cadet Keyboard](http://stevelosh.com/blog/2012/10/a-modern-space-cadet/#shift-parentheses), one of cooler features is the Shift Parentheses. To quote Steve Losh:
> When held while pressing other keys, act like Shift.
> When pressed and released on their own, type an opening or closing parenthesis (left and right shift respectively).
```
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) < 150) { // 150 being 150ms, 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 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) < 150) {
register_code(KC_0);
unregister_code(KC_0);
}
unregister_code(KC_RSFT);
}
break;
}
}
return MACRO_NONE;
};
```
And then, to assign this macro to a key on your keyboard layout, you just use `M(0)` on the key you want to press for left shift/opening parens, and `M(1)` for right shift/closing parens.
## Additional keycode aliases for software-implemented layouts (Colemak, Dvorak, etc)
Everything is assuming you're in Qwerty (in software) by default, but there is built-in support for using a Colemak or Dvorak layout by including this at the top of your keymap:
@ -510,4 +515,4 @@ what things are (and likely aren't) too risky.
- EEPROM has around a 100000 write cycle. You shouldn't rewrite the
firmware repeatedly and continually; that'll burn the EEPROM
eventually.

@ -1,95 +0,0 @@
#----------------------------------------------------------------------------
# On command line:
#
# make all = Make software.
#
# make clean = Clean out built project files.
#
# make coff = Convert ELF to AVR COFF.
#
# make extcoff = Convert ELF to AVR Extended COFF.
#
# make program = Download the hex file to the device.
# Please customize your programmer settings(PROGRAM_CMD)
#
# make teensy = Download the hex file to the device, using teensy_loader_cli.
# (must have teensy_loader_cli installed).
#
# make dfu = Download the hex file to the device, using dfu-programmer (must
# have dfu-programmer installed).
#
# make flip = Download the hex file to the device, using Atmel FLIP (must
# have Atmel FLIP installed).
#
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
# (must have dfu-programmer installed).
#
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
# (must have Atmel FLIP installed).
#
# make debug = Start either simulavr or avarice as specified for debugging,
# with avr-gdb or avr-insight as the front end for debugging.
#
# make filename.s = Just compile filename.c into the assembler code only.
#
# make filename.i = Create a preprocessed source file for use in submitting
# bug reports to the GCC project.
#
# To rebuild project do "make clean" then "make all".
#----------------------------------------------------------------------------
# Target file name (without extension).
TARGET = IIgs_Standard
# Directory common source filess exist
TMK_DIR = ../../tmk_core
# Directory keyboard dependent files exist
TARGET_DIR = .
# keyboard dependent files
SRC = keymap.c \
matrix.c \
led.c
CONFIG_H = config.h
# MCU name, you MUST set this to match the board you are using
# type "make clean" after changing this, so all files will be rebuilt
#MCU = at90usb162 # Teensy 1.0
#MCU = atmega32u4 # Teensy 2.0
#MCU = at90usb646 # Teensy++ 1.0
MCU = at90usb1286 # Teensy++ 2.0
# Processor frequency.
# Normally the first thing your program should do is set the clock prescaler,
# so your program will run at the correct speed. You should also set this
# variable to same clock speed. The _delay_ms() macro uses this, and many
# examples use this variable to calculate timings. Do not add a "UL" here.
F_CPU = 16000000
# Build Options
# comment out to disable the options.
#
MOUSEKEY_ENABLE = no # Mouse keys
#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
EXTRAKEY_ENABLE = yes # Audio control and System control
#NKRO_ENABLE = yes # USB Nkey Rollover
#---------------- Programming Options --------------------------
PROGRAM_CMD = teensy_loader_cli -mmcu=$(MCU) -w -v $(TARGET).hex
# Search Path
VPATH += $(TARGET_DIR)
VPATH += $(TMK_DIR)
include $(TMK_DIR)/protocol/pjrc.mk
include $(TMK_DIR)/common.mk
include $(TMK_DIR)/rules.mk

@ -1,45 +0,0 @@
Replaceable USB Controller for Apple IIgs/Standard(M0116)
JeffreySung(nattyman@gmail.com)
===============================
Feature
-------
- Replaceable keyboard controller for Apple IIgs(A9M0330)/Standard(M0116)
- Teensy++ 2.0 required
- Some signal bypass required
- ADB keyboard doesn't use matrix for modifier keys. With virtual row for modifier keys,
these keys are merged into key matrix using virtual row.
History
=======
- 2012.09.17 First Release
- 2012.09.17 CapsLock support
- 2012.09.19 Power button added
Build
=====
0. Just Type "Make" and return.
Hardware
========
PJRC Teensy
-----------
0. The following ports should not be connected to board.
From top view of Teensy++, from GND and counter clock wise.
-7,26(in keyboard PCB, these pins are VDD,GND)
-30,31(in Teensy++, these pins are Ref,GND respectively)
-5,6(D2,D3 for bluetooth in future)
1. Bypass #31 pin(from board) to E4(Teensy)
2. Bypass #30 pin(from board) to F2(Teensy)
3. Bypass #6 pin(from board) to A0(Teensy)
4. Refer to documentation directory
To Do
=====
0. When DEBOUNCE defined, there is a errors.
1. Layer Change by toggling Clear Key
2. Eject Key add. (following files should be modified.)
common/keycode.h
common/keyboard.c
3. Use bluetooth
EOF

@ -1,63 +0,0 @@
/*
Copyright 2011 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 CONFIG_H
#define CONFIG_H
/* USB Device descriptor parameter */
/* for Apple
#define VENDOR_ID 0x05AC
#define PRODUCT_ID 0xBEE0
*/
#define VENDOR_ID 0xFEED
#define PRODUCT_ID 0xBEE0
#define DEVICE_VER 0x0202
#define MANUFACTURER t.m.k.
#define PRODUCT Apple Desktop Bus Keyboard
/* message strings */
#define DESCRIPTION Apple M0116/A9M0660 keyboard firmware
/* matrix size */
#define MATRIX_ROWS 11 // last row is virtual for modifier
#define MATRIX_COLS 8
/* define if matrix has ghost */
#define MATRIX_HAS_GHOST
/* Set 0 if need no debouncing */
#define DEBOUNCE 5
/* key combination for command */
#define IS_COMMAND() ( \
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_LCTRL) | MOD_BIT(KC_LALT) | MOD_BIT(KC_LGUI)) || \
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
)
/* layer switching */
#define LAYER_SWITCH_DELAY 100
#define LAYER_SEND_FN_TERM 300
/* legacy keymap support */
#define USE_LEGACY_KEYMAP
#endif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 322 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

@ -1,142 +0,0 @@
/*
Copyright 2012 Jeffrey Sung <nattyman@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/>.
*/
/*
* Keymap for Apple IIgs/Standard Keyboard
*/
#include <stdint.h>
#include <stdbool.h>
#include <avr/pgmspace.h>
#include "keycode.h"
#include "print.h"
#include "debug.h"
#include "util.h"
#include "keymap.h"
// Convert physical keyboard layout to matrix array.
// This is a macro to define keymap easily in keyboard layout form.
#define KEYMAP( R10C5, \
R3C7, R3C6, R3C5, R3C4, R3C3, R3C2, R3C1, R8C1, R8C0, R3C0, R0C0, R0C1, R0C2, R0C3, R4C4, R4C5, R4C6, R4C7, \
R9C7, R9C6, R9C5, R9C4, R9C3, R9C2, R9C1, R9C0, R1C0, R1C1, R1C2, R1C3, R1C4, R2C4, R2C5, R2C6, R2C3, \
R10C0,R7C7, R7C6, R7C5, R7C4, R7C3, R7C2, R7C1, R7C0, R0C4, R1C6, R1C7, R1C5, R2C0, R2C1, R2C2, R2C7, \
R10C1,R6C7, R6C6, R6C5, R6C4, R6C3, R6C2, R6C1, R6C0, R0C5, R0C6, R4C0, R4C1, R4C2, \
R10C4,R10C2,R10C3,R5C4, R5C7, R5C5, R5C6, R5C0, R5C2, R0C7, R5C1, R5C3, R4C3 \
) { \
{ R0C0, R0C1, R0C2, R0C3, R0C4, R0C5, R0C6, R0C7 }, \
{ R1C0, R1C1, R1C2, R1C3, R1C4, R1C5, R1C6, R1C7 }, \
{ R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, R2C6, R2C7 }, \
{ R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C6, R3C7 }, \
{ R4C0, R4C1, R4C2, R4C3, R4C4, R4C5, R4C6, R4C7 }, \
{ R5C0, R5C1, R5C2, R5C3, R5C4, R5C5, R5C6, R5C7 }, \
{ R6C0, R6C1, R6C2, R6C3, R6C4, R6C5, R6C6, R6C7 }, \
{ R7C0, R7C1, R7C2, R7C3, R7C4, R7C5, R7C6, R7C7 }, \
{ R8C0, R8C1, KC_NO, KC_NO, KC_NO,KC_NO, KC_NO, KC_NO }, \
{ R9C0, R9C1, R9C2, R9C3, R9C4, R9C5, R9C6, R9C7 }, \
{ R10C0,R10C1, R10C2, R10C3, R10C4,R10C5, KC_NO, KC_NO} \
}
#define KEYCODE(layer, row, col) (pgm_read_byte(&keymaps[(layer)][(row)][(col)]))
// Assign Fn key(0-7) to a layer to which switch with the Fn key pressed.
static const uint8_t PROGMEM fn_layer[] = {
0, // Fn0
1, // Fn1
2, // Fn2
3, // Fn3
4, // Fn4
0, // Fn5
3, // Fn6
3 // Fn7
};
// Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer.
// See layer.c for details.
static const uint8_t PROGMEM fn_keycode[] = {
KC_NO, // Fn0
KC_NO, // Fn1
KC_SLSH, // Fn2
KC_SCLN, // Fn3
KC_SPC, // Fn4
KC_NO, // Fn5
KC_NO, // Fn6
KC_NO // Fn7
};
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Layer 0: Default Layer
* ,-----------------------------------------------------------. ,---------------,
* | POWER | | |
* |-----------------------------------------------------------| |---------------|
* |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |FN0| = | / | * |
* |-----------------------------------------------------------| |---------------|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| | | 7 | 8 | 9 | + |
* |-----------------------------------------------------' | |---------------|
* |Contro| A| S| D| F| G| H| J| K| L|Fn3| '|Return | | 4 | 5 | 6 | - |
* |-----------------------------------------------------------| |---------------|
* |Shift | Z| X| C| V| B| N| M| ,| .| / |Shift | | 1 | 2 | 3 | E |
* |-----------------------------------------------------------| |-----------| N |
* |CAPS|Alt |Gui |` |SPC |BSLS |LFT|RGT|DN|UP| | 0 | . | T |
* `-----------------------------------------------------------' |---------------'
*/
KEYMAP( KC_PWR,
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_FN1, KC_PEQL, KC_PSLS, KC_PAST, \
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_P7, KC_P8, KC_P9, KC_PPLS, \
KC_LCTL,KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,KC_ENT, KC_P4, KC_P5, KC_P6, KC_PMNS, \
KC_LSFT,KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_P1, KC_P2, KC_P3, \
KC_CAPS,KC_LALT,KC_LGUI,KC_GRV, KC_SPC, KC_BSLS,KC_LEFT,KC_RGHT,KC_DOWN,KC_UP, KC_P0, KC_PDOT, KC_PENT),
/* Layer 1: Tenkey use Layer
* ,-----------------------------------------------------------. ,---------------,
* | POWER | | |
* |-----------------------------------------------------------| |---------------|
* |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |NLK| = | / | * |
* |-----------------------------------------------------------| |---------------|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| | |INS| 8 |PGU|V+ |
* |-----------------------------------------------------' | |---------------|
* |Contro| A| S| D| F| G| H| J| K| L|Fn3| '|Return | |DEL|UP |PGD|V- |
* |-----------------------------------------------------------| |---------------|
* |Shift | Z| X| C| V| B| N| M| ,| .| / |Shift | |LFT|DN |RGT| E |
* |-----------------------------------------------------------| |-----------| N |
* |CAPS|Alt |Gui |` |SPC |BSLS |LFT|RGT|DN|UP| | 0 | . | T |
* `-----------------------------------------------------------' `---------------'
*/
KEYMAP( KC_PWR, \
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_FN1, KC_PEQL, KC_PSLS, KC_MUTE, \
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_INS, KC_P8, KC_PGUP, KC_VOLU, \
KC_LCTL,KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,KC_ENT, KC_DEL, KC_UP, KC_PGDN, KC_VOLD, \
KC_LSFT,KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_LEFT, KC_DOWN, KC_RIGHT, \
KC_CAPS,KC_LALT,KC_LGUI,KC_GRV, KC_SPC, KC_BSLS,KC_LEFT,KC_RGHT,KC_DOWN,KC_UP, KC_P0, KC_PDOT, KC_PENT),
};
uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col)
{
return KEYCODE(layer, row, col);
}
uint8_t keymap_fn_layer(uint8_t index)
{
return pgm_read_byte(&fn_layer[index]);
}
uint8_t keymap_fn_keycode(uint8_t index)
{
return pgm_read_byte(&fn_keycode[index]);
}

@ -1,24 +0,0 @@
/*
Copyright 2011 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 "stdint.h"
#include "led.h"
void led_set(uint8_t usb_led)
{
}

@ -1,363 +0,0 @@
/*
Copyright 2011 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 "print.h"
#include "debug.h"
#include "util.h"
#include "matrix.h"
#include "led.h"
#if (MATRIX_COLS > 16)
# error "MATRIX_COLS must not exceed 16"
#endif
#if (MATRIX_ROWS > 255)
# error "MATRIX_ROWS must not exceed 255"
#endif
#ifndef DEBOUNCE
# define DEBOUNCE 0
#endif
static uint8_t debouncing = DEBOUNCE;
// matrix state buffer(1:on, 0:off)
#if (MATRIX_COLS <= 8)
static uint8_t *matrix;
static uint8_t *matrix_prev;
static uint8_t _matrix0[MATRIX_ROWS];
static uint8_t _matrix1[MATRIX_ROWS];
#else
static uint16_t *matrix;
static uint16_t *matrix_prev;
static uint16_t _matrix0[MATRIX_ROWS];
static uint16_t _matrix1[MATRIX_ROWS];
#endif
#ifdef MATRIX_HAS_GHOST
static bool matrix_has_ghost_in_row(uint8_t row);
#endif
static uint8_t read_col(uint8_t row);
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();
// Input with pull-up(DDR:0, PORT:1)
// Column C1 ~ C7 (PortC0-6)
// Column C0(Port E1)
DDRC &= ~0b01111111;
PORTC |= 0b01111111;
DDRE &= ~0b00000010;
PORTE |= 0b00000010;
//DDRB &= ~0b00000100;
//PORTB |= 0b00000100;
// modifier B3/4,F4/5,E4 always input
// A0
//DDRA |= 0b00000001;
//PORTA &= 0b00000001;
//DDRB |= 0b00011000;
//PORTB &= 0b00011000;
//DDRF |= ~0b00110000;
//PORTF &= 0b00110000;
//DDRB &= ~0b00011000;
//PORTB |= 0b00011000;
//DDRF &= ~0b00110000;
//PORTF |= 0b00110000;
//DDRE &= ~0b00010000;
//PORTE |= 0b00010000;
// initialize matrix state: all keys off
for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix0[i] = 0x00;
for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix1[i] = 0x00;
matrix = _matrix0;
matrix_prev = _matrix1;
}
uint8_t matrix_scan(void)
{
if (!debouncing) {
uint8_t *tmp = matrix_prev;
matrix_prev = matrix;
matrix = tmp;
}
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
unselect_rows();
select_row(i);
_delay_us(30); // without this wait read unstable value.
if ( i == ( MATRIX_ROWS - 1 ) ) { // CHECK CAPS LOCK
if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) { // CAPS LOCK is ON on HOST
if ( ~read_col(i) & (1<< 4) ) { // CAPS LOCK is still DOWN ( 0bXXX1_XXXX)
matrix[i] = ~read_col(i) & 0b11101111; // change CAPS LOCK as released
} else { // CAPS LOCK in UP
matrix[i] = ~read_col(i) | 0b00010000; // send fake caps lock down
}
} else { // CAPS LOCK is OFF on HOST
if (matrix[i] != (uint8_t)~read_col(i)) {
matrix[i] = (uint8_t)~read_col(i);
if (debouncing) {
debug("bounce!: "); debug_hex(debouncing); print("\n");
}
debouncing = DEBOUNCE;
}
}
} else {
if (matrix[i] != (uint8_t)~read_col(i)) {
matrix[i] = (uint8_t)~read_col(i);
if (debouncing) {
debug("bounce!: "); debug_hex(debouncing); print("\n");
}
debouncing = DEBOUNCE;
}
}
}
unselect_rows();
if (debouncing) {
debouncing--;
}
return 1;
}
bool matrix_is_modified(void)
{
if (debouncing) return false;
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
if (matrix[i] != matrix_prev[i]) {
return true;
}
}
return false;
}
inline
bool matrix_has_ghost(void)
{
#ifdef MATRIX_HAS_GHOST
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
if (matrix_has_ghost_in_row(i))
return true;
}
#endif
return false;
}
inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
// if ( row == ( MATRIX_ROWS - 1 ) && col == 4) { // CHECK CAPS LOCK
// if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) { // CAPS LOCK is ON on HOST
// if ((matrix_prev[row] & 0b00010000) && (~matrix[row] & 0b00010000)) {
// debug("CapsLock Reverse:");debug_hex(matrix[row]);
// matrix[row] |= 0b00010000;
// matrix_prev[row] &= ~0b00010000;
// debug("->");debug_hex(matrix[row]);debug("\n");
// }
// }
// }
return (matrix[row] & (1<<col));
}
inline
#if (MATRIX_COLS <= 8)
uint8_t matrix_get_row(uint8_t row)
#else
uint16_t matrix_get_row(uint8_t row)
#endif
{
return matrix[row];
}
void matrix_print(void)
{
print("\nr/c 01234567\n");
for (uint8_t row = 0; row < matrix_rows(); row++) {
phex(row); print(": ");
#if (MATRIX_COLS <= 8)
pbin_reverse(matrix_get_row(row));
#else
pbin_reverse16(matrix_get_row(row));
#endif
#ifdef MATRIX_HAS_GHOST
if (matrix_has_ghost_in_row(row)) {
print(" <ghost");
}
#endif
print("\n");
}
}
uint8_t matrix_key_count(void)
{
uint8_t count = 0;
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
#if (MATRIX_COLS <= 8)
count += bitpop(matrix[i]);
#else
count += bitpop16(matrix[i]);
#endif
}
return count;
}
#ifdef MATRIX_HAS_GHOST
inline
static bool matrix_has_ghost_in_row(uint8_t row)
{
// no ghost exists in case less than 2 keys on
if (((matrix[row] - 1) & matrix[row]) == 0)
return false;
// ghost exists in case same state as other row
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
if (i != row && (matrix[i] & matrix[row]) == matrix[row])
return true;
}
return false;
}
#endif
inline
static uint8_t read_col(uint8_t row)
{
// For normal : Column C1 ~ C7 (PortC0-6), C0(Port E1)
// For modifier : B3(CNTRL)/4(SHIFT),F4(CMD/GUI)/5(OPTION,ALT)
// Modifier would be copied to report->mods except E4(CAPSLOCK)
uint8_t tmp;
if ( row == 10 ) {
tmp = 0xC0;
tmp |= (PINB >> 3 ) & 0b00000011; // LEFT CTRL is 0bit in modifier (HID Spec)
// LEFT SHIFT is 1bit in modifier (HID Spec)
tmp |= (PINF >> 3 ) & 0b00000100; // LEFT ALT is 2bit in modifier (HID Spec)
tmp |= (PINF >> 1 ) & 0b00001000; // LEFT GUI is 3bit in modifier (HID Spec)
tmp |= (PINA << 4 ) & 0b00010000; // CAPSLOCK
tmp |= (PINB << 3 ) & 0b00100000; // POWER
} else {
tmp = 0x00;
tmp = (PINE >> 1)&0b00000001;
tmp |= PINC << 1 ;
}
return tmp;
}
inline
static void unselect_rows(void)
{
// Hi-Z(DDR:0, PORT:0) to unselect
// DDR : 1, output 0, input
DDRB &= ~0b00000011; // PB: 1,0
PORTB &= ~0b00000011;
DDRD &= ~0b00010000; // PD: 4
PORTD &= ~0b00010000;
DDRE &= ~0b11000000; // PE: 7,6
PORTE &= ~0b11000000;
DDRF &= ~0b11000111; // PF: 7,6,2,1,0
PORTF &= ~0b11000111;
// to unselect virtual row(modifier), set port to output with low
DDRA |= 0b00000001; // PA: 0 for CAPSLOCK
PORTA &= ~0b00000001;
DDRB |= 0b00011100; // PB: 3,4 for modifier(row10)
PORTB &= ~0b00011100; // PB: 2 for power
DDRF |= 0b00110000; // PF: 4,5 for modifier
PORTF &= ~0b00110000;
}
inline
static void select_row(uint8_t row)
{
// Output low(DDR:1, PORT:0) to select
// with row enable, column could send low to AVR when pressed
// row: 0 1 2 3 4 5 6 7 8 9
// pin: PB1, PB0, PE7, PE6, PD4, PF2, PF0, PF1, PF6 PF7
switch (row) {
case 0:
DDRB |= (1<<1);
PORTB &= ~(1<<1);
break;
case 1:
DDRB |= (1<<0);
PORTB &= ~(1<<0);
break;
case 2:
DDRE |= (1<<7);
PORTE &= ~(1<<7);
break;
case 3:
DDRE |= (1<<6);
PORTE &= ~(1<<6);
break;
case 4:
DDRD |= (1<<4);
PORTD &= ~(1<<4);
break;
case 5:
DDRF |= (1<<2);
PORTF &= ~(1<<2);
break;
case 6:
DDRF |= (1<<0);
PORTF &= ~(1<<0);
break;
case 7:
DDRF |= (1<<1);
PORTF &= ~(1<<1);
break;
case 8:
DDRF |= (1<<6);
PORTF &= ~(1<<6);
break;
case 9:
DDRF |= (1<<7);
PORTF &= ~(1<<7);
break;
case 10:
// modifier has no row enable
// to select virtual row, set port as input
DDRA &= ~0b00000001;
PORTA |= 0b00000001;
DDRB &= ~0b00011100;
PORTB |= 0b00011100;
DDRF &= ~0b00110000;
PORTF |= 0b00110000;
break;
}
}

@ -1,13 +1,9 @@
#ifndef ERGODOX_EZ_H
#define ERGODOX_EZ_H
#include "matrix.h"
#include "keymap_common.h"
#include "backlight.h"
#include <stddef.h>
#include "quantum.h"
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#include "i2cmaster.h"
#include <util/delay.h>

@ -7,8 +7,7 @@
#define SYMB 1 // symbols
#define MDIA 2 // media keys
#define LSFTO M(0) // Left shift, open parens when tapped
#define RSFTC M(1) // Right shift, close parens when tapped
#define LEADER_TIMEOUT 300
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Keymap 0: Basic layer
@ -27,28 +26,28 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* ,-------------. ,-------------.
* | App | LGui | | Alt |Ctrl/Esc|
* ,------|------|------| |------+--------+------.
* | | L1 | Home | | PgUp | | |
* | Space| Tap/ |------| |------| Tab/L1 |Enter |
* | |Toggle| End | | PgDn | | |
* | | | Home | | PgUp | | |
* | Space|Leader|------| |------| Tab/L1 |Enter |
* | | | 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, KC_Q, KC_W, KC_E, KC_R, KC_T, TG(SYMB),
KC_BSPC, KC_A, KC_S, KC_D, KC_F, KC_G,
LSFTO, CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B, ALL_T(KC_LBRC),
LT(SYMB,KC_GRV),KC_QUOT, LALT(KC_LSFT), KC_LEFT, KC_RGHT,
ALT_T(KC_APP), KC_LGUI,
KC_HOME,
KC_SPC,KC_FN1,KC_END,
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(SYMB),
KC_BSPC, KC_A, KC_S, KC_D, KC_F, KC_G,
KC_LSPO, CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B, ALL_T(KC_LBRC),
LT(SYMB,KC_GRV),KC_QUOT, LALT(KC_LSFT), KC_LEFT, KC_RGHT,
ALT_T(KC_APP), KC_LGUI,
KC_HOME,
KC_SPC,KC_LEAD,KC_END,
// right hand
KC_RGHT, KC_6,KC_7, KC_8, KC_9, KC_0, KC_MINS,
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,
MEH_T(KC_RBRC),KC_N,KC_M, KC_COMM,KC_DOT, CTL_T(KC_SLSH), KC_RSPC,
KC_UP, KC_DOWN,KC_LBRC,KC_RBRC, LT(SYMB,KC_MINS),
KC_LALT, CTL_T(KC_ESC),
KC_PGUP,
@ -149,48 +148,7 @@ 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) {
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;
}
return MACRO_NONE;
return MACRO_NONE;
};
// Runs just one time when the keyboard initializes.
@ -198,28 +156,48 @@ void matrix_init_user(void) {
};
LEADER_EXTERNS();
// Runs constantly in the background, in a loop.
void matrix_scan_user(void) {
uint8_t layer = biton32(layer_state);
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;
}
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;
}
};
LEADER_DICTIONARY() {
leading = false;
leader_end();
SEQ_ONE_KEY(KC_W) {
register_code(KC_LALT);
register_code(KC_F4);
unregister_code(KC_F4);
unregister_code(KC_LALT);
}
SEQ_ONE_KEY(KC_O) {
register_code(KC_LCTL);
register_code(KC_LSFT);
register_code(KC_O);
unregister_code(KC_O);
unregister_code(KC_LSFT);
unregister_code(KC_LCTL);
}
}
}

@ -2,4 +2,4 @@
# for your own particular keymap
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
COMMAND_ENABLE = no # Commands for debug and configuration

@ -4,6 +4,12 @@ This is my personal layout which I use to test out ideas which may or may not ma
Changelog:
## May 24, 2016:
* Implements Leader key example
* Leader, W sends Alt-F4
* Leader, O sends Ctrl-shift-o (a shortcut I use in FrontApp)
## May 8, 2016:
* Makes bottom-right key send minus/underscore when tapped, L1 temporary toggle when held

@ -0,0 +1,29 @@
SuperCoder 2000 layout for the ErgoDox
==================================================
![SuperCoder 2000](images/supercoder_2000.jpg)
Ever found yourself in need of entering binary codes rapidly? Ever wanted to use
all ten fingers to do so? Ever felt your SuperCoder 2000 too limiting, by only
having three buttons? We heard you! With this layout for the ErgoDox EZ, you
will be able to tap in binary at an unparalleled speed and accuracy! Efficiency
never seen before!
Behold the Ultimate SuperCoder 2000 layout!
![SuperCoder layout](images/layout.png)
### To use it...
To use this piece of top quality engineering, you can either
[download the hex file][hex] we have prepared for you, or you can compile it on
your own:
[hex]: https://raw.githubusercontent.com/algernon/ergodox-supercoder/master/supercoder.hex
```
$ git clone https://github.com/jackhumbert/qmk_firmware.git
$ cd qmk_firmware/keyboard/ergodox_ez
$ git clone https://github.com/algernon/ergodox-supercoder.git keymaps/supercoder
$ make KEYMAP=supercoder
```

@ -0,0 +1,9 @@
#ifndef CONFIG_USER_H
#define CONFIG_USER_H 1
#include "config.h"
#undef LOCKING_SUPPORT_ENABLE
#undef LOCKING_RESYNC_ENABLE
#endif

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

@ -0,0 +1,75 @@
/*
* SuperCoder 2000 layout
*/
#include "ergodox_ez.h"
/* Layers */
#define SC2K 0 // default layer
/* The Keymap */
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Keymap 0: Base Layer
*
* ,-----------------------------------------------------. ,-----------------------------------------------------.
* | 0 | 0 | 0 | 0 | 0 | 0 | 0 | | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
* |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------|
* | 0 | 0 | 0 | 0 | 0 | 0 | 0 | | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
* |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------|
* | 0 | 0 | 0 | 0 | 0 | 0 |------| |------| 1 | 1 | 1 | 1 | 1 | 1 |
* |-----------+------+------+------+------+------| 0 | | 1 |------+------+------+------+------+-----------|
* | 0 | 0 | 0 | 0 | 0 | 0 | | | | 1 | 1 | 1 | 1 | 1 | 1 |
* `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------'
* | 0 | 0 | 0 | 0 | 0 | | 1 | 1 | 1 | 1 | 1 |
* `-----------------------------------' `-----------------------------------'
* ,-------------. ,-------------.
* | DONE | DONE | | DONE | DONE |
* ,------|------|------| |------+------+------.
* | | | DONE | | DONE | | |
* | DONE | DONE |------| |------| DONE | DONE |
* | | | DONE | | DONE | | |
* `--------------------' `--------------------'
*/
[SC2K] = KEYMAP(
// left hand
KC_0 ,KC_0 ,KC_0 ,KC_0 ,KC_0 ,KC_0 ,KC_0
,KC_0 ,KC_0 ,KC_0 ,KC_0 ,KC_0 ,KC_0 ,KC_0
,KC_0 ,KC_0 ,KC_0 ,KC_0 ,KC_0 ,KC_0
,KC_0 ,KC_0 ,KC_0 ,KC_0 ,KC_0 ,KC_0 ,KC_0
,KC_0 ,KC_0 ,KC_0 ,KC_0 ,KC_0
,KC_ENT ,KC_ENT
,KC_ENT
,KC_ENT ,KC_ENT ,KC_ENT
// right hand
,KC_1 ,KC_1 ,KC_1 ,KC_1 ,KC_1 ,KC_1 ,KC_1
,KC_1 ,KC_1 ,KC_1 ,KC_1 ,KC_1 ,KC_1 ,KC_1
,KC_1 ,KC_1 ,KC_1 ,KC_1 ,KC_1 ,KC_1
,KC_1 ,KC_1 ,KC_1 ,KC_1 ,KC_1 ,KC_1 ,KC_1
,KC_1 ,KC_1 ,KC_1 ,KC_1 ,KC_1
,KC_ENT ,KC_ENT
,KC_ENT
,KC_ENT ,KC_ENT ,KC_ENT
),
};
const uint16_t PROGMEM fn_actions[] = {
};
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
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) {
}

@ -0,0 +1,6 @@
BOOTMAGIC_ENABLE=no
COMMAND_ENABLE=no
SLEEP_LED_ENABLE=no
UNICODE_ENABLE=no
MOUSEKEY_ENABLE=no
EXTRAKEY_ENABLE=no

@ -0,0 +1,846 @@
:100000000C9456010C949D010C949D010C949D013F
:100010000C949D010C949D010C949D010C949D01E8
:100020000C949D010C949D010C94D90B0C94AB0C79
:100030000C941D190C949D010C949D010C949D0130
:100040000C949D010C949D010C949D010C949D01B8
:100050000C949D010C9485190C949D010C949D01A8
:100060000C949D010C949D010C949D010C949D0198
:100070000C949D010C949D010C949D010C949D0188
:100080000C949D010C949D010C949D010C949D0178
:100090000C949D010C949D010C949D010C949D0168
:1000A0000C949D010C949D010C949D01180D3A0D2A
:1000B000280E3A0D280E7F0DA20D280EF70D0A0E00
:1000C00071107110A010A010FC11FC11FC11FC119A
:1000D000D610FC1186118611ED11FC11FC11F611E0
:1000E00093119311931193119311931193119311F0
:1000F00093119311931193119311931193119311E0
:10010000A511B211B911C011CA112700270027008B
:1001100027002700000027002700270027002700CE
:100120002800270027002700270027002800270095
:100130002700270027002700280027002700270086
:10014000270027002800270027002700270000009D
:1001500028002700270000002700000028001E00BC
:100160001E0000001E00000028001E001E001E00D1
:100170001E00000028001E001E001E001E001E00A3
:1001800028001E001E001E001E001E0028001E006B
:100190001E001E001E001E0028001E001E001E0065
:1001A0001E001E0028001E001E001E001E001E0055
:1001B000000016034500720067006F0044006F00E6
:1001C0007800200045005A00000016034500720028
:1001D00067006F0044006F007800200045005A005F
:1001E00000000403090409023B00020100A0FA090F
:1001F0000400000103010100092111010001223F57
:10020000000705810308000A09040100010300003A
:1002100000092111010001223900070582031000A5
:10022000011201100100000008EDFE07130100019A
:1002300002000105010906A101050719E029E715DA
:100240000025019508750181020508190129059508
:1002500005750191029501750391010507190029A2
:100260007715002501957875018102C00501090601
:10027000A101050719E029E7150025019508750179
:100280008102950175088101050819012905950567
:10029000750191029501750391010507190029FF68
:1002A000150025FF950675088100C00011241FBEAA
:1002B000CFEFDAE0DEBFCDBF04B603FE27C08091EA
:1002C000CA019091CB01A091CC01B091CD018730B2
:1002D000904BA740B04BD1F41092CA011092CB01C1
:1002E0001092CC011092CD0114BE84B7877F84BFD9
:1002F0000FB6F894A89580916000886180936000A3
:10030000109260000FBEE0E0FFE3099511E0A0E06D
:10031000B1E0E6EBF4E302C005900D92A031B10725
:10032000D9F721E0A0E1B1E001C01D92AA3CB207DB
:10033000E1F70E941D090C94591A0C94000080E00A
:1003400090E00895089508950C94A30156985E983E
:1003500025982D9826982E9827982F988FEF90E023
:10036000909389008093880090938B0080938A00FB
:1003700090938D0080938C00259A2D9A2FEF80E723
:1003800092E0215080409040E1F700C00000269AA2
:100390002E9A2FEF80E792E0215080409040E1F7C5
:1003A00000C00000279A2F9A2FEF80E792E021509B
:1003B00080409040E1F700C0000025982D982FEF75
:1003C00080E792E0215080409040E1F700C00000BB
:1003D00026982E982FEF80E792E0215080409040A1
:1003E000E1F700C0000027982F9856985E9825984E
:1003F0002D9826982E9827982F98089589EA80930B
:10040000800089E08093810024982C983F988AB1DD
:100410008F748AB96E98479A8BB1806B8BB9769A34
:100420000E94A6010C94A20180E2809300018091B9
:10043000100181110EC00E94630281E080931001BF
:100440002FEF83ED90E3215080409040E1F700C012
:10045000000080E40E9469028093000181112EC097
:100460000E94930280930001811128C00E94930290
:1004700080930001811122C08FE30E949302809338
:10048000000181111BC00E948B0280E40E9469025E
:1004900080930001811112C08CE00E94930280932E
:1004A000000181110BC00E94930280930001811111
:1004B00005C08FE30E949302809300010E948B028B
:1004C0008091000108951092B9008AE08093B800ED
:1004D000089594EA9093BC009091BC0097FFFCCFE4
:1004E0009091B900987F983021F0903111F081E01F
:1004F00008958093BB0084E88093BC008091BC0089
:1005000087FFFCCF8091B900887F883111F080345B
:1005100071F780E0089584E98093BC008091BC006D
:1005200084FDFCCF08958093BB0084E88093BC00D9
:100530008091BC0087FFFCCF9091B900987F81E04B
:10054000983209F480E0089584E88093BC0080919B
:10055000BC0087FFFCCF8091BB0008958091000113
:10056000811115C080E40E9469028093000181110D
:100570000CC082E10E94930280930001811105C0AA
:100580008FEF0E949302809300010E948B0284B13E
:10059000807F84B985B1807F85B98AB1837F8AB92C
:1005A0008BB1837F8BB93E98469808950E941402C0
:1005B000809300010E94AE0280B38C7080BB81B337
:1005C000836F81BBA2E1B1E0E0E2F1E08EE08E0F4B
:1005D00011921D928E13FCCF0C94FE01BF92CF920C
:1005E000DF92EF92FF920F931F93CF93DF9380914F
:1005F0000001882379F0809111018F5F80931101B0
:10060000811108C00E94140280930001811102C070
:100610000E94A60102E111E0C0E0D0E0DD24D39405
:1006200082E0C82EEE24E394F12CC730D10500F50A
:1006300080910001811164C080E40E94690280936E
:100640000001811112C082E10E9493028093000197
:1006500081110BC0C7010C2E01C0880F0A94EAF764
:1006600080950E949302809300010E948B0248C0F3
:10067000CA30A1F028F4C83059F0C93061F005C083
:10068000CC3089F070F0CD3089F0209A289810C0D5
:10069000219A29980DC0229A2A980AC0239A2B9849
:1006A00007C0529A01C0539A5B9802C03E9A46987E
:1006B00090EA9A95F1F79FB1799902C082E001C062
:1006C00080E091709D25982B7C9902C084E001C048
:1006D00080E0892B7D9902C038E001C030E0832B97
:1006E0007E9902C020E101C020E0822B9FB190954D
:1006F000991F9927991F9295990F907E892B0FC06A
:1007000080910001811149C080E40E9469028093B8
:100710000001882379F1B12C0E948B028B2DF80106
:100720009081981719F08083C09201010E94AE0257
:1007300021960F5F1F4FCE30D10509F076CF809103
:100740000101882361F1815080930101882339F0F0
:100750008FE99FE00197F1F700C0000020C0A0E200
:10076000B1E0E2E1F1E0CF01825F91919D938E13C0
:10077000FCCF15C083E10E94930280930001811198
:10078000CACF81E40E946902809300018111C3CF26
:100790000E94A402B82EB094BFCF80E0C0CF0E94C8
:1007A000A40181E0DF91CF911F910F91FF90EF9015
:1007B000DF90CF90BF900895E82FF0E0E05EFE4F0D
:1007C0008081089508950F931F93CF93DF93C0E224
:1007D000D1E010E00C2F025F899190E00E94CF18C9
:1007E000180F0C13F9CF812FDF91CF911F910F912B
:1007F000089581E0089508950F931F93CF93DF9399
:100800008C01FC01C081D181CE010E945417BE0130
:100810000E949F04EC01F8018281882309F44AC0F8
:100820008091390181111FC0C431F0E5DF0709F063
:1008300051C00E94FB0381E0809339010E944F194F
:100840009093380180933701109230011092320159
:10085000109231011092340110923301109236013E
:100860001092350165C080913701909138010E9446
:100870005B19883C910570F480913001E82FF0E01D
:10088000EE0FFF1FEF5CFE4FD183C0838F5F80931D
:1008900030014EC0C43880E5D80721F0C538D045B6
:1008A00001F13AC0F8018281882341F010922E01B3
:1008B00082E01EC0C438E0E5DE0759F580912E01C4
:1008C000811106C086E20E94700F86E20E94041029
:1008D00082E01CC0C438F0E5DF0741F3C538D045DD
:1008E000D9F4F8018281882331F010922F0180E23F
:1008F0000E942C101DC080912F01811106C087E23B
:100900000E94700F87E20E94041080E20E94331060
:100910000FC0C538D04529F381E080932E01809324
:100920002F01C801DF91CF911F910F910C94F90312
:1009300080E0DF91CF911F910F910895089596E087
:10094000799FF001112494E5899FE00DF11D112498
:10095000E60FF11DEE0FFF1FE65FFE4F85919491AC
:100960000895880F991FFC01E657F04085919491F6
:100970000895880F991FFC01E65FFE4F85919491C1
:1009800008950F931F93CF93DF93EC01811590434C
:1009900050F5C11580E2D80708F0C3C0CB3BD105A4
:1009A00090F4C83AD10508F06AC0C53AD10508F0FC
:1009B0005BC0C430D10508F0D0C1219709F0CAC18D
:1009C00001E010E00AC2CF3FD10511F008F0C5C127
:1009D000C03FD10508F0A2C0CE01805E9109089702
:1009E00008F4BBC1B7C1C13090E5D90709F4A2C072
:1009F00020F5C0318FE4D80770F4C11590E4D90711
:100A000008F094C0C11521E3D20708F0A3C1DD2787
:100A10008E01106CE2C1C115D04509F09BC10E9446
:100A20005B128FEF94E32CE0815090402040E1F77F
:100A300000C000000E94AA19D0C1C11597E5D907CE
:100A400058F4C03121E5D20708F01CC1C43180E55B
:100A5000D80708F475C07EC1CE019057811590412A
:100A600008F078C1DF7073C1C53AD10509F477C1C8
:100A7000C63AD10509F076C102E810E4AEC1C83A21
:100A8000D10509F472C1C93AD10509F471C1CA3A54
:100A9000D10509F470C1CB3AD10509F46FC1CC3A44
:100AA000D10509F46EC1CD3AD10509F46DC1C03B41
:100AB000D10509F46CC1CE3AD10509F46BC1CF3A26
:100AC000D10509F46AC1C13BD10509F469C1C23B32
:100AD000D10509F468C1C33BD10509F467C1C43B22
:100AE000D10509F466C1C53BD10509F465C1C63B12
:100AF000D10509F464C1C73BD10509F463C1C83B02
:100B0000D10509F462C1C93BD10509F461C1CA3BF1
:100B1000D10509F460C100E014E45FC18E011065E5
:100B20005CC1CE019F700E94B90458C1DF708E0174
:100B3000106A53C18091B60181608093B6014DC1A6
:100B40000E94011A811102C00E94E7190E94141A22
:100B500090E09093CA018093C901C23080E5D80724
:100B600021F48091C901816086C0C43090E5D90725
:100B700021F48091C90182607EC0C63020E5D20791
:100B800021F48091C901846076C0C83080E5D8071F
:100B900019F48091C90127C0CA3090E5D90721F422
:100BA0008091C901806167C0CC3020E5D20721F473
:100BB0008091C90180625FC0CE3080E5D80721F402
:100BC0008091C901806457C0C03190E5D90721F4F4
:100BD0008091C90180684FC0C23120E5D20729F455
:100BE0008091C9018460886046C0C33080E5D80721
:100BF00021F48091C9018E7F3EC0C53090E5D907B0
:100C000021F48091C9018D7F36C0C73020E5D2071D
:100C100021F48091C9018B7F2EC0C93080E5D807AF
:100C200019F48091C90126C0CB3090E5D90721F491
:100C30008091C9018F7E1FC0CD3020E5D20721F4FD
:100C40008091C9018F7D17C0CF3080E5D80721F48E
:100C50008091C9018F7B0FC0C13190E5D90721F484
:100C60008091C9018F7707C0C331D04531F480919D
:100C7000C9018B7F877F8093C9018091C9010E9440
:100C8000181AABC08D2F99278F7099278130910545
:100C9000D9F49E012370332702C0880F991F2A952B
:100CA000E2F79C688E0144E0000F111F4A95E1F7BE
:100CB00000271370802B912B53E0CC0FDD1F5A952A
:100CC000E1F7C076DD272FC08230910531F4DC2FAB
:100CD000CC278E01016F106A80C08330910569F4C2
:100CE000CE018370992701E010E002C0000F111FB0
:100CF0008A95E2F7C8019C680FC084309105B9F469
:100D0000CE018370992701E010E002C0000F111F8F
:100D10008A95E2F7C8019A6823E0CC0FDD1F2A9577
:100D2000E1F7C07ED7708C010C2B1D2B56C085308F
:100D3000910531F4DC2FCC278E01046F106A4DC071
:100D4000069709F04AC0CF71DD27DC2FCC278E0132
:100D5000106243C000E010E040C08E013EC001E8D8
:100D600010E43BC003E810E438C002EE14E435C0E0
:100D700009EE14E432C00AEE14E42FC005EB14E4CB
:100D80002CC006EB14E429C007EB14E426C00CECDD
:100D900014E423C00DEC14E420C003E815E41DC0E6
:100DA0000AE815E41AC002E915E417C004E915E4DD
:100DB00014C001E216E411C003E216E40EC004E21E
:100DC00016E40BC005E216E408C006E216E405C00E
:100DD00007E216E402C00AE216E4C801DF91CF91EF
:100DE0001F910F91089596E0799FF001112494E5E9
:100DF000899FE00DF11D1124E60FF11DEE0FFF1F7D
:100E0000E65FFE4F85919491803E9105E0F4803C31
:100E1000910558F58133910509F46FC048F4893282
:100E2000910509F463C08A32910509F46DC072C05E
:100E300089339105E9F082389105D1F08533910528
:100E400009F44DC067C0833E910581F138F4803EBE
:100E50009105B9F0823E9105D9F05CC0863E9105BE
:100E600061F1873E9105A1F155C00E94B10408953A
:100E70002091C90120FD02C021FF4CC080EE90E00E
:100E800049C08091C90180FFF9CF89E390E042C059
:100E90008091C90182FF0EC08091C90184FF03C007
:100EA00080E090E037C083EE90E034C08091C901CB
:100EB00082FFF2CF82EE90E02DC08091C90183FFC6
:100EC0000BC08091C90184FDEBCF87EE90E022C07A
:100ED0008091C90183FFF5CF86EE90E01BC0809121
:100EE000C90185FF07C089E290E014C08091C90163
:100EF00085FFF9CF85E390E00DC08091C90186FFA1
:100F000007C08AE290E006C08091C90186FFF9CF50
:100F100081E390E00E94C104089508950C948D0728
:100F200080914A0108950895CF93DF9300D01F92D6
:100F3000CDB7DEB72091C001243021F523E029830D
:100F40009B838A8381E08093E9008FEF9091E80092
:100F5000815095FD06C095ED9A95F1F7000081113D
:100F6000F5CF8091E80085FF0DC040E050E063E0E0
:100F700070E0CE0101960E94C9098091E8008E7749
:100F80008093E8000F900F900F90DF91CF9108951C
:100F9000CF93DF9300D01F92CDB7DEB72091C00171
:100FA000243021F522E029839B838A8381E080938A
:100FB000E9008FEF9091E800815095FD06C095ED16
:100FC0009A95F1F700008111F5CF8091E80085FF37
:100FD0000DC040E050E063E070E0CE0101960E9459
:100FE000C9098091E8008E778093E8000F900F90F8
:100FF0000F90DF91CF910895CF93DF932091C0019F
:10100000243009F048C0EC0180910C018823E1F004
:1010100080910D018823C1F082E08093E9008FEF79
:101020009091E800815095FD06C095E19A95F1F701
:1010300000008111F5CF8091E80085FF2CC040E0D1
:1010400050E060E170E017C081E08093E9008FEF2D
:101050009091E800815095FD06C095ED9A95F1F7C5
:1010600000008111F5CF8091E80085FF14C040E0B9
:1010700050E068E070E0CE010E94C9098091E8006C
:101080008E778093E80080E1FE01AAE3B1E0019051
:101090000D928A95E1F7DF91CF9108958091BF017C
:1010A000811109C00E945E0B0E94BB0B8091E2007F
:1010B00084608093E20008951092BF01089508951E
:1010C00008950C94171942E061EC81E00E94D80A5F
:1010D00042E161EC82E00C94D80A8091C201833035
:1010E00009F453C030F4813071F0823009F48CC0BF
:1010F00008958A3009F478C08B3009F45EC08930D5
:1011000009F09AC020C08091C101813A09F094C0D1
:101110008091E800877F8093E8008091C5019091DD
:10112000C601892B21F460E18AE391E003C060E00D
:1011300080E090E070E00E94140A8091E8008B77D4
:101140008093E80008958091C101813209F074C054
:101150008091C5019091C601029708F06DC0809101
:10116000E800877F8093E8008091E80082FD05C059
:101170008091C0018111F8CF5FC08091F100809310
:101180004A018091E8008B7753C08091C101813A78
:1011900009F052C08091C5019091C601892B09F0D8
:1011A0004BC08091E800877F8093E8008091E80041
:1011B00080FFFCCF80910C0136C08091C10181324B
:1011C000D9F58091C5019091C601892BA9F580912F
:1011D000E800877F8093E8000E940D0B8091C30197
:1011E00080930C010C945B128091C101813221F536
:1011F0008091E800877F8093E8000E940D0B80912A
:10120000C40180934B0108958091C101813AA1F4FA
:101210008091E800877F8093E8008091E80080FF5C
:10122000FCCF80914B018093F1008091E8008E7794
:101230008093E8000C940D0B089584B7877F84BFDA
:101240000FB6F894A8958091600088618093600043
:10125000109260000FBE90E080E80FB6F894809383
:101260006100909361000FBE0E94A50E0E945E0B6C
:101270000E94BB0B8091E20084608093E20078942E
:101280000E94410E0E94A70E82E091E00E945C0E37
:101290008091C001853069F40E94DB188091BE0105
:1012A0008823B1F30E940919882391F30E94B3099E
:1012B000EFCF0E94AD0EECCF292F3327233031051D
:1012C000C9F064F42130310581F02230310509F094
:1012D00042C08BE390E026EE31E041C0213231057F
:1012E000F1F02232310549F136C082E190E021E28D
:1012F00032E035C099278130910541F08230910567
:1013000041F0892B41F5E2EEF1E005C0EAECF1E0B5
:1013100002C0E2EBF1E0849190E09F0120C06623DF
:1013200039F06130C1F489E090E021E132E017C08A
:1013300089E090E028EF31E012C0662339F0613097
:1013400051F489E390E023E332E009C08FE390E0B9
:101350002CE632E004C080E090E020E030E0FA01CA
:1013600031832083089580E189BD82E189BD09B47C
:1013700000FEFDCF8091D8008F7D8093D8008091B2
:10138000E00082608093E0008091E00081FDFCCF6E
:101390000895CF92DF92EF92FF920F931F93CF9316
:1013A000DF93EC018B016A010E942C0B811133C089
:1013B000C114D10439F0F60180819181081B190B09
:1013C000C80FD91FE12CF12C0115110519F18091DD
:1013D000E80085FD16C08091E8008E778093E800D4
:1013E000C114D10449F0F60180819181E80EF91E03
:1013F000F182E08285E00FC00E942C0B882321F34C
:101400000AC089918093F10001501109FFEFEF1A92
:10141000FF0ADACF80E0DF91CF911F910F91FF900B
:10142000EF90DF90CF9008952091C7013091C801CF
:101430002617370748F06115710539F42091E80047
:101440002E772093E80001C0B90140E061157105D5
:10145000A9F12091C001222309F443C0253009F4E9
:1014600042C02091E80023FD40C02091E80022FD09
:1014700032C02091E80020FFE9CF4091F300209195
:10148000F20030E0342BFC01CF016115710559F0F9
:101490002830310540F481918093F1006150710949
:1014A0002F5F3F4FF1CF41E02830310509F040E098
:1014B0002091E8002E772093E800C8CF4111C9CFD2
:1014C0000AC08091C001882361F0853061F080916D
:1014D000E80083FD0AC08091E80082FFF2CF80E03F
:1014E000089582E0089583E0089581E008952091B1
:1014F000C7013091C8012617370748F061157105FB
:1015000039F42091E8002E772093E80001C0B9015A
:10151000FC0120E06115710591F18091C0018823E3
:1015200009F440C0853009F43FC08091E80083FD94
:101530003DC08091E80082FD2FC08091E80080FFCF
:10154000E9CF2091F3008091F20090E0922B611599
:10155000710559F08830910540F424912093F100F1
:101560003196615071090196F2CF21E0089709F098
:1015700020E08091E8008E778093E800CBCF2111A6
:10158000CCCF0AC08091C001882361F0853061F022
:101590008091E80083FD0AC08091E80082FFF2CFCD
:1015A00080E0089582E0089583E0089581E0089541
:1015B000982F973058F59093E900981739F070916B
:1015C000EC002091ED005091F00003C0242F762F05
:1015D00050E021FF19C03091EB003E7F3093EB00CB
:1015E0003091ED003D7F3093ED003091EB003160A4
:1015F0003093EB007093EC002093ED005093F000DB
:101600002091EE0027FF07C09F5FD3CF8F7080939C
:10161000E90081E0089580E008958091C10187FF8D
:1016200011C08091E80082FD05C08091C001811148
:10163000F8CF11C08091E8008B770BC08091C0017A
:10164000882349F08091E80080FFF8CF8091E8007E
:101650008E778093E80008952091E4003091E500B2
:1016600095E64091EC00842F817040FF22C080916C
:10167000E80080FD1CC08091C001882391F0853076
:1016800091F08091EB0085FD10C04091E4005091F5
:10169000E5004217530729F39A01915011F784E0AE
:1016A000089582E0089583E0089581E0089580E040
:1016B00008954091E80042FFDECF08950E94CC0BD0
:1016C0000E94D40BE0EEF0E0808181608083E8ED41
:1016D000F0E080818F77808319BCA7EDB0E08C911A
:1016E0008E7F8C9380818F7E80831092BF010895BE
:1016F0000F931F93CF93DF930E94CC0B0E94D40BC8
:10170000C8EDD0E088818F7788838881806888835E
:1017100088818F7D888319BC1092C0011092BC0112
:101720001092BE011092BD0100EE10E0F801808120
:101730008B7F808388818160888342E060E080E0E5
:101740000E94D80AE1EEF0E080818E7F8083E2EE95
:10175000F0E0808181608083808188608083F801EF
:1017600080818E7F8083888180618883DF91CF91A3
:101770001F910F910895E8EDF0E080818F7E8083C6
:10178000E7EDF0E080818160808384E082BF81E0CA
:101790008093BF010C94780BE8EDF0E080818E7FA0
:1017A00080831092E20008951092DA001092E10016
:1017B00008951F920F920FB60F9211242F933F930B
:1017C0004F935F936F937F938F939F93AF93BF9349
:1017D000EF93FF938091E10082FF0BC08091E200C4
:1017E00082FF07C08091E1008B7F8093E1000E941F
:1017F000400E8091DA0080FF1FC08091D80080FFEA
:101800001BC08091DA008E7F8093DA008091D9002E
:1018100080FF0DC080E189BD82E189BD09B400FE71
:10182000FDCF81E08093C0010E944E0805C019BC25
:101830001092C0010E945C088091E10080FF19C0F5
:101840008091E20080FF15C08091E2008E7F80933E
:10185000E2008091E20080618093E2008091D800F4
:1018600080628093D80019BC85E08093C0010E94FB
:1018700060088091E10084FF30C08091E20084FF25
:101880002CC080E189BD82E189BD09B400FEFDCF95
:101890008091D8008F7D8093D8008091E1008F7E69
:1018A0008093E1008091E2008F7E8093E20080913E
:1018B000E20081608093E2008091BC01882311F0F6
:1018C00084E007C08091E30087FD02C081E001C091
:1018D00083E08093C0010E9461088091E10083FF52
:1018E00029C08091E20083FF25C08091E100877FBD
:1018F0008093E10082E08093C0011092BC0180914E
:10190000E1008E7F8093E1008091E2008E7F8093E2
:10191000E2008091E20080618093E20042E060E0BA
:1019200080E00E94D80A8091F00088608093F000E7
:101930000E945F08FF91EF91BF91AF919F918F91AE
:101940007F916F915F914F913F912F910F900FBEBB
:101950000F901F9018951F920F920FB60F9211249F
:101960002F933F934F935F936F937F938F939F93A7
:10197000AF93BF93CF93DF93EF93FF93C091E900B1
:10198000CF708091EC00D82FD17080FDD0E81092FC
:10199000E9008091F000877F8093F00078940E94A6
:1019A000EF0C1092E9008091F00088608093F000C5
:1019B000CD2BCF70C093E900FF91EF91DF91CF91D4
:1019C000BF91AF919F918F917F916F915F914F9157
:1019D0003F912F910F900FBE0F901F9018951F935E
:1019E000CF93DF93CDB7DEB7AA970FB6F894DEBFDB
:1019F0000FBECDBFE1ECF1E088E08E0F9091F100D9
:101A000091938E13FBCF0E946D088091E80083FFB5
:101A10001FC18091C1019091C201492F50E04A300D
:101A2000510508F015C1FA01EA5AFF4F0C941D1A2E
:101A3000803881F0823809F00BC18091C5018F7028
:101A40008093E9008091EB0085FB882780F9109254
:101A5000E90006C08091BD019091BE0191118260A4
:101A60009091E800977F9093E8008093F1001092A6
:101A7000F100C8C0282F2D7F09F0EAC0882319F093
:101A8000823061F0E5C08091C301813009F0E0C08F
:101A9000933009F080E08093BE012BC08091C30198
:101AA000811127C08091C5018F7009F4D1C0809346
:101AB000E9002091EB0020FF1CC0933021F48091BD
:101AC000EB00806214C09091EB0090619093EB006A
:101AD00021E030E0A90102C0440F551F8A95E2F7CA
:101AE0004093EA001092EA008091EB0088608093B6
:101AF000EB001092E9008091E800877F86C0811199
:101B0000A7C01091C3011F778091E3008078812BDB
:101B10008093E3008091E800877F8093E8000E9433
:101B20000D0B8091E80080FFFCCF8091E30080687E
:101B30008093E300111102C082E001C083E0809332
:101B4000C00186C08058823008F082C08091C301F5
:101B50009091C4018C3D53E0950779F583E08A8329
:101B60008AE289834FB7F894DE01139620E03EE0C5
:101B700051E2E32FF0E050935700E49120FF03C0BF
:101B8000E295EF703F5FEF708E2F90E0EA3010F03B
:101B9000C79601C0C0968D939D932F5F243149F75E
:101BA0004FBF8091E800877F8093E8006AE270E091
:101BB000CE0101960E94140A14C0AE014F5F5F4F20
:101BC0006091C5010E945C09BC01892B09F440C0E9
:101BD0009091E800977F9093E80089819A810E9414
:101BE000770A8091E8008B778093E80031C08038D5
:101BF00079F58091E800877F8093E8008091BC01AF
:101C00008093F1008091E8008E778093E8000E9435
:101C10000D0B1EC081111CC09091C3019230C0F405
:101C20008091E800877F8093E8009093BC010E9438
:101C30000D0B8091BC01811106C08091E30087FDEE
:101C400002C081E001C084E08093C0010E9463086B
:101C50008091E80083FF0AC08091E800877F80932D
:101C6000E8008091EB0080628093EB00AA960FB6AB
:101C7000F894DEBF0FBECDBFDF91CF911F910895C5
:101C80000895CF938091C0018823A1F0C091E9000D
:101C9000CF709091EC00892F817090FD80E8C82B67
:101CA0001092E9008091E80083FD0E94EF0CCF7054
:101CB000C093E900CF910895909351018093500112
:101CC0000895E0915001F0915101309721F0019079
:101CD000F081E02D099480E00895E0915001F091A9
:101CE0005101309721F00280F381E02D099408958D
:101CF00020914E0130914F018217930771F090931C
:101D00004F0180934E01E0915001F09151013097C5
:101D100021F00680F781E02D0994089520914C016F
:101D200030914D018217930771F090934D0180938C
:101D30004C01E0915001F0915101309721F0008465
:101D4000F185E02D0994089508950C94A40E0E9445
:101D500046190E94D6020C94CC199F92AF92BF9262
:101D6000CF92DF92EF92FF920F931F93CF93DF9367
:101D700000D000D000D0CDB7DEB70E94EE020DE05B
:101D800010E0AA24A394B12C902E802F0E94DC0393
:101D900098012D5A3E4F6901F901F080F826A1F40F
:101DA0000150110988F78FEF89838A831B820E9473
:101DB0004F198160782F9D838C8349815A816B8173
:101DC0008D810E94420F2FC09091B60191FF04C0F7
:101DD0008E830E94E2038E8125E030E0A501022E71
:101DE00001C0440F0A94EAF7E42E4F21C1F0298381
:101DF0009A828E2191E009F490E09B830E944F1912
:101E00008160782F9D838C8349815A816B818D817C
:101E10000E94420FF6018081E826E08204C0215032
:101E20003109E0F6BDCF109152010E94610E1817E2
:101E3000B9F00E94610E8093520126960FB6F89475
:101E4000DEBF0FBECDBFDF91CF911F910F91FF90ED
:101E5000EF90DF90CF90BF90AF909F900C948E0743
:101E600026960FB6F894DEBF0FBECDBFDF91CF919F
:101E70001F910F91FF90EF90DF90CF90BF90AF90A8
:101E80009F900895CF93DF93CDB7DEB72B970FB612
:101E9000F894DEBF0FBECDBF4F83588769877A871E
:101EA0008B87DE01119686E0FD0111928A95E9F794
:101EB00085E0FE01379601900D928A95E1F7498100
:101EC0005A816B817C818D819E810E94F9142B96B1
:101ED0000FB6F894DEBF0FBECDBFDF91CF9108954E
:101EE000882309F490C09CEF980F913A18F40E944F
:101EF000D3170DC090E2980F983058F4877091E096
:101F000001C0990F8A95EAF7892F0E9459180C94FD
:101F1000A0189BE5980F933070F4853A29F0863A23
:101F200031F083E890E005C081E890E002C082E8EB
:101F300090E00C94780E98E5980F933108F063C008
:101F4000883A39F1893A41F18A3A49F18B3A51F1AB
:101F50008C3A59F18D3A61F1803B69F18E3A71F119
:101F60008F3A79F1813B81F1823B89F1833B91F199
:101F7000843B99F1853BA1F1863BA9F1873BB1F107
:101F8000883BB9F1893BC1F18A3BC9F180E090E01F
:101F900038C082EE90E035C089EE90E032C08AEE23
:101FA00090E02FC085EB90E02CC086EB90E029C03C
:101FB00087EB90E026C08CEC90E023C08DEC90E0A5
:101FC00020C083E891E01DC08AE891E01AC082E950
:101FD00091E017C084E991E014C081E292E011C061
:101FE00083E292E00EC084E292E00BC085E292E0D0
:101FF00008C086E292E005C087E292E002C08AE271
:1020000092E00C948E0E0895882329F19CEF980F8E
:10201000913A18F40E9415180DC090E2980F98306C
:1020200058F4877091E001C0990F8A95EAF7892FDB
:102030000E945F180C94A0189BE5980F933020F431
:1020400080E090E00C94780E885A833120F480E090
:1020500090E00C948E0E0895882321F00E94591868
:102060000C94A0180895882321F00E945F180C9406
:10207000A01808957F928F929F92AF92BF92CF92B5
:10208000DF92EF92FF920F931F93CF93DF931F92F4
:10209000CDB7DEB77C01C62E772EFC0115811295D7
:1020A0001F70028101110E9476180E94CC178823AC
:1020B00079F0002369F080E28C0D883048F082E0EE
:1020C0000E94B5170E94CC1791E0D82ED92601C0E6
:1020D000D12CE72DE295EF70F0E0E05AFF4F0C9421
:1020E0001D1A872D807F172D1F70882311F01295E0
:1020F000107F002389F0112309F465C180E28C0D63
:10210000883020F4812F0E94591803C0812F0E942B
:1021100069180E94A01857C18C2D0E940410112329
:1021200009F46AC180E28C0D883020F4812F0E946E
:102130005F1803C0812F0E946F180E94A0185CC115
:10214000972D907F872D8F70903211F08295807F30
:10215000CC2021F0F1E0CF16B1F01EC0002349F0F1
:10216000112309F4E9C0113009F0E6C00E94891872
:1021700043C1112319F0113009F43EC189830E9433
:102180008C188981DFC0002321F0123008F034C19F
:10219000D3C0111131C1D6C0002321F0112309F49D
:1021A000CBC011C1112309F4CDC013C1872D837099
:1021B00009F052C0011120C18C2D8295869587703F
:1021C000880F880F9C2D9F70892E912CA12CB12CEB
:1021D000082E04C0880C991CAA1CBB1C0A94D2F7B8
:1021E000C4FE14C00FE010E020E030E0B901A80107
:1021F00004C0440F551F661F771F8A95D2F7CB0185
:10220000BA01609570958095909503C060E070E08C
:10221000CB01272D26952695237030E022303105FD
:1022200069F02330310589F0682979298A299B29A9
:102230002130310571F00E944116DEC068297929EC
:102240008A299B290E945D16D7C00E944116C501AC
:10225000B4010E942516D0C0002319F0872D81708B
:1022600001C08695882309F4C7C08C2D8295869578
:102270008770880F880F9C2D9F70892E912CA12C20
:10228000B12C082E04C0880C991CAA1CBB1C0A94F3
:10229000D2F7C4FE14C00FE010E020E030E0B90136
:1022A000A80104C0440F551F661F771F8A95D2F7F7
:1022B000CB01BA01609570958095909503C060E060
:1022C00070E0CB01272D269526952370422F50E0F4
:1022D0004230510569F04330510589F06829792968
:1022E0008A299B294130510571F00E941B1784C037
:1022F000682979298A299B290E9437177DC00E9465
:102300001B17C501B4010E94FF1676C08C2D90E00A
:10231000FC01E05EF109E531F10508F050C0E0593B
:10232000FF4F0C941D1A1C2D1F70872D8F710023D9
:1023300031F00E949816812F0E942C105DC00E94DF
:10234000B916812F0E94331057C0002339F01111A4
:1023500053C0872D8F710E94DE164EC0123008F0D8
:102360004BC0F7CF002339F0872D8F710E9498164C
:1023700043C00023C9F3872D8F710E94B9163CC05A
:10238000002329F0872D8F710E94831635C00E948B
:10239000791632C0002351F0172D1F71812F0E9432
:1023A000981663E0812F0E94AC1726C081E00E943E
:1023B000B517123008F182E00E94B5171DC0002346
:1023C00031F0112389F28C2D0E94700F15C011235A
:1023D00091F28C2D0E9404100FC0472D4F706C2D70
:1023E000C7010E949F010E949D1506C0472D4F7096
:1023F0006C2DC7010E949E04DD20F9F00E94A817F1
:1024000080FD1BC0F70112820E94A2170E9498163D
:10241000C7010E942C120E94A2170F90DF91CF914A
:102420001F910F91FF90EF90DF90CF90BF90AF90F2
:102430009F908F907F900C94B9160F90DF91CF9161
:102440001F910F91FF90EF90DF90CF90BF90AF90D2
:102450009F908F907F9008950F931F93CF93DF935A
:10246000EC01888199812B813C81232BB9F09F3F1E
:1024700011F48F3F99F0CE010E94FC03882371F084
:10248000688179818A810E949E178C010E9453176E
:102490000E941A16B801CE010E943A10DF91CF9126
:1024A0001F910F9108950E9476180E9486180E942D
:1024B0004B180C94A0180E9466180C9453120E949A
:1024C0009317292F22952F7030E02C3031054CF4D2
:1024D0002A3031056CF42250310922303105A8F43C
:1024E00007C02C30310569F02F30310551F00DC097
:1024F000803F69F018F4803E40F409C0843F29F41D
:1025000006C093FB882780F9089580E0089581E054
:102510000895CF93DF9300D000D01F92CDB7DEB7E0
:102520000F900F900F900F900F90DF91CF91089523
:10253000CF93DF9300D000D000D0CDB7DEB7269682
:102540000FB6F894DEBF0FBECDBFDF91CF910895D7
:102550001F93CF93DF93C091610116E080916201D8
:10256000C81799F0D0E01C9FF0011D9FF00D1124B9
:10257000ED59FE4F40815181628173818481958143
:102580000E9498122196C770E9CFDF91CF911F91D9
:10259000089540919301509194016091950170913B
:1025A000960180919701909198010C9498128091D6
:1025B000980182958F7009F054C08091950188230D
:1025C00009F44FC080916101A09162016091930173
:1025D000709194014091960150919701B6E08A174D
:1025E00009F43FC090E041155105C1F17F3F11F45E
:1025F0006F3FA1F1B89FF001B99FF00D1124ED5983
:10260000FE4F218172132AC02081621327C02281CC
:10261000211124C0238134812417350710F421505F
:102620003109241B350B283C3105C0F42091980159
:102630002F7020612093980126E0289FF001299FA8
:10264000F00D1124E859FE4F80818F7080618083E6
:1026500083E991E00E942C120C94A81201968770D5
:10266000BECF0895CF92DF92EF92FF920F931F9308
:10267000CF93DF93CDB7DEB762970FB6F894DEBF86
:102680000FBECDBF8C0185E0F801DE011D960190E3
:102690000D928A95E1F7D8014C9111965C911197B2
:1026A00012966C9112971396CD90DC9014973091FE
:1026B00093017091940180919601909197010097F8
:1026C00009F46BC17F3F19F43F3F09F466C1E09004
:1026D0009501EE2009F4C0C020919801C816D906D2
:1026E00028F0F601E81BF90BCF0104C08095909506
:1026F0008C0D9D1DFF24F394883C910578F0F12CFE
:10270000207F09F0C6C07C2DD98AC88A89890E9499
:10271000891283E991E00E942C12B1C0822F807F40
:1027200009F046C0751314C0341312C0611110C0F3
:102730002F702061209398010E94C91283E991E0D3
:102740000E942C1280919801D80115968C932EC06E
:10275000CD2819F15F3F11F44F3FF9F0F62E6111CA
:102760001CC0809161012091620136E0821709F45A
:102770005AC090E0389FF001399FF00D1124ED59B7
:10278000FE4F7181571306C07081471303C07281D9
:10279000711103C001968770E9CFF62E662309F404
:1027A00018C180919801816080939801F12C11C12A
:1027B000751308C0341306C0611104C080919801DC
:1027C000D801C3C04D875E878D859E856A8B0E9428
:1027D0005F126A898823E1F16623D1F12091980183
:1027E000822F82958F7090E0029774F08091930110
:1027F0009091940198878F831986DB86CA862C87EF
:10280000CE0107960E942C1286E0F801A3E9B1E000
:1028100001900D928A95E1F70E94D7120E94C91289
:10282000FF24F394D6C04D875E878D859E850E94D8
:102830009317292F22952F7030E0223031050CF0AC
:10284000BCC09F7009F0B6C0805E883008F4C1C07B
:10285000C8010E942C12E4CFC816D90608F453C050
:10286000F601E81BF90BCF01883C910508F450C034
:10287000F12C7C2DD98AC88A89890E948912E3E9C2
:10288000F1E086E0DF011D928A95E9F70E94C91206
:10289000A0C0751314C0341312C0611110C0809110
:1028A0009801F8018583C8010E942C1286E0E3E9B3
:1028B000F1E0DF011D928A95E9F7FE2C8AC04D8771
:1028C0005E878D859E856A8B0E945F126A89882348
:1028D00009F4BECF662309F4BBCF20919801822F63
:1028E00082958F7090E002970CF48ECF80919301C7
:1028F000909194019A8389831B82DD82CC822E83FE
:10290000CE0101967FCF809590958C0D9D1DACCF0B
:10291000F62E662309F49CCF75132EC034132CC0F9
:102920002091980120FD1FC0822F82958F70D9F0D1
:10293000D80115962C9315978F3049F08F5F982FFB
:102940009295907F822F8F70892B15968C93C8015A
:102950000E942C1286E0F801A3E9B1E001900D92EB
:102960008A95E1F793CF86E0F801A3E9B1E0019001
:102970000D928A95E1F72DC04D875E878D859E85E6
:102980000E945F12811140CF8091980181608093F5
:102990009801C8010E942C121CC0662309F458CF6C
:1029A0004D875E878D859E850E945F12882309F47E
:1029B0004FCF2ACF811148CF0CC0243031050CF005
:1029C00047CF9F7009F440CFF8019581907F09F0BF
:1029D0003BCF8F2D62960FB6F894DEBF0FBECDBFF2
:1029E000DF91CF911F910F91FF90EF90DF90CF90EB
:1029F00008951F93CF93DF93CDB7DEB72C970FB613
:102A0000F894DEBF0FBECDBF4F83588769877A87A2
:102A10008B879C87CE0107960E943213882369F02A
:102A20008F8198852A853B85232BF1F19F3F09F003
:102A300063C08F3F09F060C037C086E0FE01379663
:102A4000DE01119601900D928A95E1F76F817885EC
:102A5000EA85FB85309741F17F3F11F46F3F21F10B
:102A60002091620130E0C901019687709927409159
:102A7000610150E08417950709F447C069837A83A0
:102A8000FD83EC8396E0929FD001939FB00D1124BB
:102A9000AD59BE4FFE01319601900D929A95E1F726
:102AA000809362010E94A81216E0809161019091CA
:102AB00062018917C1F1189FC00111248D599E4FE1
:102AC0000E943213882379F1E09161011E9FF00189
:102AD0001124ED59FE4F40815181628173818481BF
:102AE00095810E9498128091610190E00196877013
:102AF000992780936101D9CF4F81588569857A855F
:102B00008B859C850E949812CFCF0E945B121092F9
:102B1000620110926101E3E9F1E086E0DF011D92BC
:102B20008A95E9F7C1CF2C960FB6F894DEBF0FBE99
:102B3000CDBFDF91CF911F910895EF92FF920F9338
:102B40001F93CF93DF938C01892B09F46CC0F12C78
:102B5000EE24E394E8012196F8018491843740F44F
:102B6000843008F051C0813081F0823019F15BC0AF
:102B7000853709F444C0A8F19CE7980F903708F016
:102B800052C08F770E94041041C00E5F1F4FFE019C
:102B9000C49180E28C0F883048F4C7708E2D01C03C
:102BA000880FCA95EAF70E94791814C08C2F0E94EA
:102BB000700F2DC00E5F1F4FFE01C49180E28C0F7D
:102BC000883058F4C7708E2D01C0880FCA95EAF777
:102BD0000E947F180E94A0181AC08C2F0E94041017
:102BE00016C00E5F1F4FFE01C491CC2381F08FE908
:102BF0009FE00197F1F700C00000C150F6CF0E5FD3
:102C00001F4FFE01F49003C00E94700F8E018F2DA4
:102C1000882309F49FCFEFE9FFE03197F1F700C077
:102C200000008150F5CFDF91CF911F910F91FF9060
:102C3000EF900895089560939D0170939E01809395
:102C40009F019093A0010C9453120F931F93009136
:102C50009D0110919E0120919F013091A001DC0106
:102C6000CB01802B912BA22BB32B80939D019093B2
:102C70009E01A0939F01B093A0011F910F910C940E
:102C800053120F931F9300919D0110919E0120916B
:102C90009F013091A001DC01CB0180239123A2236D
:102CA000B32380939D0190939E01A0939F01B093C5
:102CB000A0011F910F910C9453120F931F93009139
:102CC0009D0110919E0120919F013091A001DC0196
:102CD000CB0180279127A227B32780939D01909352
:102CE0009E01A0939F01B093A0011F910F910C949E
:102CF00053121092990110929A0110929B01109216
:102D00009C010C94531241E050E060E070E004C07C
:102D1000440F551F661F771F8A95D2F7409399017C
:102D200050939A0160939B0170939C010C945312F1
:102D300041E050E060E070E004C0440F551F661FA2
:102D4000771F8A95D2F78091990190919A01A0916D
:102D50009B01B0919C01482B592B6A2B7B2B4093F4
:102D6000990150939A0160939B0170939C010C947C
:102D7000531241E050E060E070E004C0440F551F82
:102D8000661F771F8A95D2F740955095609570958C
:102D90008091990190919A01A0919B01B0919C0121
:102DA000482359236A237B234093990150939A0126
:102DB00060939B0170939C010C94531241E050E08E
:102DC00060E070E004C0440F551F661F771F8A95AE
:102DD000D2F78091990190919A01A0919B01B091B5
:102DE0009C01482759276A277B27409399015093D4
:102DF0009A0160939B0170939C010C9453120F9362
:102E00001F930091990110919A0120919B0130919B
:102E10009C01DC01CB01802B912BA22BB32B809347
:102E2000990190939A01A0939B01B0939C011F91EB
:102E30000F910C9453120F931F93009199011091CD
:102E40009A0120919B0130919C01DC01CB018023F0
:102E50009123A223B3238093990190939A01A09385
:102E60009B01B0939C011F910F910C9453120F93EF
:102E70001F930091990110919A0120919B0130912B
:102E80009C01DC01CB0180279127A227B3278093E7
:102E9000990190939A01A0939B01B0939C011F917B
:102EA0000F910C9453120895CF92DF92EF92FF92FC
:102EB0000F931F93CF93DF938C01C0909D01D0900F
:102EC0009E01E0909F01F090A00180919901909166
:102ED0009A01A0919B01B0919C01C82AD92AEA2AA3
:102EE000FB2ACFE1D0E0D701C6010C2E04C0B69575
:102EF000A795979587950A94D2F780FF06C0B801E9
:102F00008C2F0E94F306019721F4219760F780E04F
:102F100001C08C2FDF91CF911F910F91FF90EF9007
:102F2000DF90CF900895CF93DF93EC010E94541768
:102F3000BE010E94F306DF91CF910895CB010E945C
:102F4000931708958091A10185958595859508959C
:102F50008091A1018770089598E0899F90011124C4
:102F6000262B2093A1010C9498162091A101809505
:102F700082238093A101982F977069F430E0482F45
:102F8000082E000C550B2417350729F085958595DB
:102F900085950C94B91608959091A101977081E0E0
:102FA00009F480E0089590910C01992321F090910B
:102FB0000D01911109C020910E0130910F01F9010D
:102FC00032969FEF40E01FC0982F96959695969564
:102FD0009F3050F5E0910E01F0910F01E90FF11DC6
:102FE000877021E030E0A90102C0440F551F8A9587
:102FF000E2F7CA019181892B818308959F3F39F0BF
:103000004F5F4E3041F051915813F8CF0DC0511120
:10301000F7CF942FF5CF9F3F39F0F901E90FF11D5C
:1030200097FDFA9582830895089590910C01992354
:1030300021F090910D01911109C020910E01309164
:103040000F01F9013296205F3F4F1FC0982F9695D0
:10305000969596959F30F0F4E0910E01F0910F0156
:10306000E90FF11D877021E030E0A90102C0440F93
:10307000551F8A95E2F7CA01809591818923818342
:1030800008953196E217F30729F090819813F9CF4C
:103090001082F7CF089581E090E0E0910E01F09169
:1030A0000F01E80FF91F1082019680319105A9F7F1
:1030B00008959091B501892B8093B501089580956D
:1030C0009091B50189238093B50108951092B501BF
:1030D00008959091B401892B8093B401089580954F
:1030E0009091B40189238093B40108951092B401A2
:1030F00008959091B301892B8093B3010895809531
:103100009091B30189238093B30108951092B30184
:1031100008958093A20108951092A20108958091CC
:103120000E0190910F01FC0131969C01205F3F4FF1
:1031300080E0919191118F5FE217F307D1F7089525
:10314000E0910E01F0910F018091B5018083E09133
:103150000E01F0910F0190818091B401892B808341
:10316000E0910E01F0910F0190818091B301892BC4
:1031700080838091A201882361F0E0910E01F0919B
:103180000F019081892B80830E948F1881111092EA
:10319000A20180910E0190910F010C946D0E20E020
:1031A000009739F0AC0141505109842395232F5FDA
:1031B000F7CF822F08958091C001843039F11092A9
:1031C000B70120E488E190E00FB6F894A8958093C9
:1031D00060000FBE2093600080E00E948E0783B7DE
:1031E000817F846083BF83B7816083BF7894889533
:1031F00083B78E7F83BF0FB6F894A8958091600047
:10320000886180936000109260000FBE0895089559
:1032100008950E9407190E94EE020E9408190E9458
:10322000E30391E0811101C090E0892F08950E948D
:103230005B120E94610E0C948E071F920F920FB6C4
:103240000F9211248F939F93AF93BF938091B701F7
:10325000811113C08091B8019091B901A091BA0178
:10326000B091BB014196A11DB11D8093B80190930F
:10327000B901A093BA01B093BB01BF91AF919F91E7
:103280008F910F900FBE0F901F90189582E084BD14
:1032900093E095BD9AEF97BD80936E0008952FB788
:1032A000F8948091B8019091B901A091BA01B091C0
:1032B000BB012FBF0895CF92DF92EF92FF920F9341
:1032C0001F932FB7F8944091B8015091B9016091C4
:1032D000BA017091BB012FBF6A017B01EE24FF246C
:1032E0008C0120E030E0C016D106E206F30610F4AF
:1032F000415051099A01281B390BC9011F910F91A7
:10330000FF90EF90DF90CF9008951F920F920FB62D
:103310000F9211248F939F93AF93BF938091B80125
:103320009091B901A091BA01B091BB010196A11D84
:10333000B11D8093B8019093B901A093BA01B093E5
:10334000BB01BF91AF919F918F910F900FBE0F90D6
:103350001F9018950E945E0BF8942FEF87EA91E674
:10336000215080409040E1F700C0000087E090EBE2
:10337000DC018093CA019093CB01A093CC01B09360
:10338000CD019CE088E10FB6F894A8958093600089
:103390000FBE90936000FFCF0E94011A811102C0FE
:1033A0000E94E7190E940C1A8093B6010E94141A19
:1033B0008093C90187FB882780F980930D010E94C3
:1033C000101A682F70E080E090E00C941B166DEEF0
:1033D0007EEF80E090E00E94431A60E082E090E09F
:1033E0000E94311A60E083E090E00E94311A60E0B0
:1033F00084E090E00E94311A60E085E090E00C9457
:10340000311A80E090E00E942B1A21E08D3E9E4F01
:1034100009F020E0822F089582E090E00C94231AB6
:1034200083E090E00C94231A84E090E00C94231A3B
:10343000682F84E090E00C94311AEE0FFF1F059086
:10344000F491E02D0994F999FECF92BD81BDF89ACF
:10345000992780B50895A8E1B0E042E050E00C94CF
:103460004B1A262FF999FECF92BD81BDF89A01978C
:1034700000B4021639F01FBA20BD0FB6F894FA9ABC
:10348000F99A0FBE08950196272F0E94321A0C94C4
:10349000311ADC01CB01FC01F999FECF06C0F2BD67
:1034A000E1BDF89A319600B40D9241505040B8F702
:0634B0000895F894FFCF1F
:1034B60020029007FC079307C80794070101A301A0
:00000001FF

@ -6,19 +6,26 @@
#define SYMB 1 // symbols
#define MDIA 2 // media keys
#define SGWK 0 // "sagewick", ⌘S ⌘⇥
#define SGWF 1 // "sagewick freshly", ⌘S ⌘⇥ ⌘R
#define BBED 2 // BBEdit
#define TMNL 3 // Terminal
#define SAFA 4 // Safari
#define ALFRED_LEAD_TIME 100 // time, in milliseconds, to let Alfred come to the fore and accept keyboard input
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Keymap 0: Basic layer
*
* ,--------------------------------------------------. ,--------------------------------------------------.
* | = | 1 | 2 | 3 | 4 | 5 | | | | 6 | 7 | 8 | 9 | 0 | - |
* | = | 1 | 2 | 3 | 4 | 5 | L1 | | L1 | 6 | 7 | 8 | 9 | 0 | - |
* |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
* | | Q | W | E | R | T | L1 | | L1 | Y | U | I | O | P | \ |
* | | Q | W | E | R | T | ~L1 | | ~L1 | Y | U | I | O | P | \ |
* |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
* | | A | S | D | F | G |------| |------| H | J | K | L |; / L2| ' / L |
* |--------+------+------+------+------+------| L | | L |------+------+------+------+------+--------|
* | L | Z | X | C | V | B | | | | N | M | , | . | / / | R |
* `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
* | L | L | L | | | | | | [ | ] | ~L1 |
* | L | L | L | | | | | | [ | ] | |
* `----------------------------------' `----------------------------------'
* ,-------------. ,---------------.
* | `~ | '" | | ⎋ | ⌫ |
@ -32,8 +39,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
// 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, KC_Q, KC_W, KC_E, KC_R, KC_T, TG(SYMB),
KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, TG(SYMB),
KC_DELT, KC_Q, KC_W, KC_E, KC_R, KC_T, MO(SYMB),
KC_BSPC, KC_A, KC_S, KC_D, KC_F, KC_G,
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_LGUI,
KC_LCTL, KC_LALT, KC_LGUI,KC_LEFT,KC_RGHT,
@ -41,11 +48,11 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_PGUP,
KC_SPC,KC_BSPC,KC_LALT,
// right hand
KC_RGHT, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,
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),GUI_T(KC_QUOT),
KC_LGUI, KC_N, KC_M, KC_COMM,KC_DOT, CTL_T(KC_SLSH), KC_RSFT,
KC_UP, KC_DOWN,KC_LBRC,KC_RBRC, KC_FN1,
TG(SYMB), KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,
MO(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),GUI_T(KC_QUOT),
KC_LGUI, KC_N, KC_M, KC_COMM,KC_DOT, CTL_T(KC_SLSH), KC_RSFT,
KC_UP, KC_DOWN,KC_LBRC,KC_RBRC, KC_SPC ,
KC_ESC, KC_BSPC,
KC_PGDN,
KC_LCTL, KC_TAB, KC_ENT
@ -55,9 +62,9 @@ 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 | = | |
* `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
@ -75,8 +82,8 @@ 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_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_LBRC,KC_RBRC,KC_LCBR,KC_RCBR,KC_DQUO,KC_TRNS,
KC_TRNS,KC_LABK,KC_RABK,KC_LPRN,KC_RPRN,KC_QUOT,
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,
@ -95,20 +102,20 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Keymap 2: Media keys
*
* ,--------------------------------------------------. ,--------------------------------------------------.
* | | F14 | F15 | | | | | | Q | W | ` | ` | | | Power |
* | | F14 | F15 | | | | | | Q | W | ` | ` | | | Power |
* |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
* | | | | PgUp | | | | | | ] | | | | | |
* | | | | PgUp |SR| Term | | | | ] | | | | | |
* |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
* | | | Home | PgDn | End | |------| |------| [ | | | | | |
* | | |Safari| PgDn | | |------| |------| [ | | | | | |
* |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
* | | | | | | | | | |L+Spc| Spc | | | | |
* | | | | | |BBEdit| | | |L+Spc| Spc | | | | |
* `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
* | | | | | | |VolUp |VolDn | Mute | | |
* `----------------------------------' `----------------------------------'
* ,-------------. ,-------------.
* | | | | | |
* ,------|------|------| |------+------+------.
* | | | | | | | |
* | | | Home | | End | | |
* | | |------| |------| C | V |
* | | | | | X | | |
* `--------------------' `--------------------'
@ -116,15 +123,15 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
// MEDIA AND MOUSE
[MDIA] = KEYMAP(
KC_TRNS, KC_F14 , KC_F15 , KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, /* F14 dims screen, F15 brightens */
KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_HOME, KC_PGDN, KC_END , KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, M(SGWF), M(TMNL), KC_TRNS,
KC_TRNS, KC_TRNS, M(SAFA), KC_PGDN, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, M(BBED), KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS,
KC_TRNS,
KC_HOME,
KC_TRNS, KC_TRNS, KC_TRNS,
// right hand
LGUI(KC_Q), LGUI(KC_W), LGUI(LSFT(KC_GRV)), LGUI(KC_GRV), LALT(LSFT(KC_TAB)), LALT(KC_TAB), KC_PWR,
LGUI(KC_Q), LGUI(KC_W), LGUI(LSFT(KC_GRV)), LGUI(KC_GRV), KC_TRNS, KC_TRNS, KC_PWR,
KC_TRNS, LGUI(KC_RBRC), LGUI(LALT(KC_UP)), KC_UP , LGUI(LALT(KC_DOWN)), KC_TRNS, KC_TRNS,
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,
@ -139,23 +146,62 @@ 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
switch(id) {
case 0:
if (record->event.pressed) {
register_code(KC_RSFT);
} else {
unregister_code(KC_RSFT);
}
break;
case SGWK:
if (record->event.pressed) {
return MACRO(
I(10),
D(LGUI), T(S), U(LGUI),
D(LGUI), T(TAB), U(LGUI),
END);
}
break;
case SGWF:
if (record->event.pressed) {
return MACRO(
I(10),
D(LGUI), T(S), U(LGUI),
D(LGUI), T(TAB), U(LGUI),
D(LGUI), T(R), U(LGUI),
END);
}
break;
case BBED:
if (record->event.pressed) {
return MACRO(
I(10),
D(LALT), T(SPC), U(LALT), W(ALFRED_LEAD_TIME),
T(B), T(B), T(E), T(D), T(I), T(T),
T(ENT),
END);
}
break;
case TMNL:
if (record->event.pressed) {
return MACRO(
I(10),
D(LALT), T(SPC), U(LALT), W(ALFRED_LEAD_TIME),
T(T), T(E), T(R), T(M), T(I), T(N), T(A), T(L),
T(ENT),
END);
}
break;
case SAFA:
if (record->event.pressed) {
return MACRO(
I(10),
D(LALT), T(SPC), U(LALT), W(ALFRED_LEAD_TIME),
T(S), T(A), T(F), T(A), T(R), T(I),
T(ENT),
END);
}
break;
}
return MACRO_NONE;
};
#endif
// Runs just one time when the keyboard initializes.
void matrix_init_user(void) {

@ -1,117 +0,0 @@
#----------------------------------------------------------------------------
# On command line:
#
# make all = Make software.
#
# make clean = Clean out built project files.
#
# make coff = Convert ELF to AVR COFF.
#
# make extcoff = Convert ELF to AVR Extended COFF.
#
# make program = Download the hex file to the device.
# Please customize your programmer settings(PROGRAM_CMD)
#
# make teensy = Download the hex file to the device, using teensy_loader_cli.
# (must have teensy_loader_cli installed).
#
# make dfu = Download the hex file to the device, using dfu-programmer (must
# have dfu-programmer installed).
#
# make flip = Download the hex file to the device, using Atmel FLIP (must
# have Atmel FLIP installed).
#
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
# (must have dfu-programmer installed).
#
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
# (must have Atmel FLIP installed).
#
# make debug = Start either simulavr or avarice as specified for debugging,
# with avr-gdb or avr-insight as the front end for debugging.
#
# make filename.s = Just compile filename.c into the assembler code only.
#
# make filename.i = Create a preprocessed source file for use in submitting
# bug reports to the GCC project.
#
# To rebuild project do "make clean" then "make all".
#----------------------------------------------------------------------------
# Target file name (without extension).
TARGET = ghostsquid_lufa
# Directory common source filess exist
TMK_DIR = ../../tmk_core
# Directory keyboard dependent files exist
TARGET_DIR = .
# List C source files here. (C dependencies are automatically generated.)
SRC = keymap.c \
matrix.c \
led.c
CONFIG_H = config.h
# MCU name
MCU = atmega32u2
# Processor frequency.
# This will define a symbol, F_CPU, in all source code files equal to the
# processor frequency in Hz. You can then use this symbol in your source code to
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
# automatically to create a 32-bit value in your source code.
#
# This will be an integer division of F_USB below, as it is sourced by
# F_USB after it has run through any CPU prescalers. Note that this value
# does not *change* the processor frequency - it should merely be updated to
# reflect the processor speed set externally so that the code can use accurate
# software delays.
F_CPU = 16000000
#
# LUFA specific
#
# Target architecture (see library "Board Types" documentation).
ARCH = AVR8
# Input clock frequency.
# This will define a symbol, F_USB, in all source code files equal to the
# input clock frequency (before any prescaling is performed) in Hz. This value may
# differ from F_CPU if prescaling is used on the latter, and is required as the
# raw input clock is fed directly to the PLL sections of the AVR for high speed
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
# at the end, this will be done automatically to create a 32-bit value in your
# source code.
#
# If no clock division is performed on the input clock inside the AVR (via the
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
F_USB = $(F_CPU)
# Build Options
# comment out to disable the options.
#
#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)
COMMAND_ENABLE = yes # Commands for debug and configuration
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
# Boot Section Size in bytes
# Teensy halfKay 512
# Atmel DFU loader 4096
# LUFA bootloader 4096
OPT_DEFS += -DBOOTLOADER_SIZE=4096
# Search Path
VPATH += $(TARGET_DIR)
VPATH += $(TMK_DIR)
include $(TMK_DIR)/protocol/lufa.mk
include $(TMK_DIR)/common.mk
include $(TMK_DIR)/rules.mk

@ -1,20 +0,0 @@
The Ghost Squid controller
==========================
Custom controller for the Cooler Master QuickFire XT keyboard designed by bpiphany.
*Note that this is not the official firmware*
Build
-----
Move to this directory then just run `make` like:
$ make -f Makefile.lufa
At the moment only the LUFA stack is supported.
Bootloader
---------
To enter bootloader by hardware use a magnet above the controller before connecting the usb cable.
It is still possible to use Boot Magic and Command (LSFT+RSFT+PAUS) to access the bootloader though.

@ -1,43 +0,0 @@
/*
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
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
/* USB Device descriptor parameter */
#define VENDOR_ID 0xFEED // 0x2516 (original CM XT value)
#define PRODUCT_ID 0x001A
#define DEVICE_VER 0x0000
#define MANUFACTURER Cooler Master
#define PRODUCT Cooler Master QuickFire XT
/* message strings */
#define DESCRIPTION t.m.k. keyboard firmware for Cooler Master QuickFire XT
/* matrix size */
#define MATRIX_ROWS 8
#define MATRIX_COLS 18
/* Set 0 if need no debouncing */
#define DEBOUNCE 5
/* key combination for command */
#define IS_COMMAND() ( \
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
)
#endif

@ -1,102 +0,0 @@
/*
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
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 <stdint.h>
#include <stdbool.h>
#include <avr/pgmspace.h>
#include "keycode.h"
#include "action.h"
#include "action_macro.h"
#include "report.h"
#include "host.h"
#include "debug.h"
#include "keymap.h"
/*
Matrix col/row mapping
,----. ,-------------------. ,-------------------. ,-------------------. ,--------------.
|06/6| |07/4|08/4|08/2|08/6| |15/5|11/6|12/2|12/4| |14/4|14/5|14/6|14/0| |13/5|13/7|15/7|
`----' `-------------------' `-------------------' `-------------------' `--------------'
,-------------------------------------------------------------------------. ,--------------. ,-------------------.
|06/4|06/5|07/5|08/5|09/5|09/4|10/4|10/5|11/5|12/5|05/5|05/4|11/4| 14/2| |17/4|02/4|04/4| |16/1|17/1|04/1|04/0|
|-------------------------------------------------------------------------| |--------------| |-------------------|
|06/2 |06/7|07/7|08/7|09/7|09/2|10/2|10/7|11/7|12/7|05/7|05/2|11/2| 14/3| |16/4|02/5|04/5| |16/7|17/7|04/7| |
|-------------------------------------------------------------------------| '--------------' |-------------- 02/7|
|02/7 |06/3|07/3|08/3|09/3|09/6|10/6|10/3|11/3|12/3|05/3|05/6| 14/1| |16/2|17/2|04/2| |
|-------------------------------------------------------------------------| ,----. |-------------------|
|01/2 |06/1|07/1|08/1|09/1|09/0|10/0|10/1|11/1|12/1|05/0| 01/3| |02/6| |16/3|17/3|04/3| |
|-------------------------------------------------------------------------| ,--------------. |-------------- 02/3|
|15/4|03/2|13/6| 16/6 |13/0|0/3|12/0|15/1| |02/0|16/0|17/0| | 17/6 |04/6| |
`-------------------------------------------------------------------------' `--------------' `-------------------'
*/
#define KEYMAP( \
KG6, KH4, KI4, KI2, KI6, KP5, KL6, KM2, KM4, KO4, KO5, KO6, KO0, KN5, KN7, KP7, \
KG4, KG5, KH5, KI5, KJ5, KJ4, KK4, KK5, KL5, KM5, KF5, KF4, KL4, KO2, KR4, KC4, KE4, KQ1, KR1, KE1, KE0, \
KG2, KG7, KH7, KI7, KJ7, KJ2, KK2, KK7, KL7, KM7, KF7, KF2, KL2, KO3, KQ4, KC5, KE5, KQ7, KR7, KE7, KC7, \
KH2, KG3, KH3, KI3, KJ3, KJ6, KK6, KK3, KL3, KM3, KF3, KF6, KO1, KQ2, KR2, KE2, \
KB2, KH6, KG1, KH1, KI1, KJ1, KJ0, KK0, KK1, KL1, KM1, KF0, KB3, KC6, KQ3, KR3, KE3, KC3, \
KP4, KD2, KN6, KQ6, KN0, KA3, KM0, KP1, KC0, KQ0, KR0, KR6, KE6 \
) { \
/* 0 1 2 3 4 5 6 7 */ \
/* A 0 */ {KC_NO, KC_NO, KC_NO, KC_##KA3, KC_NO, KC_NO, KC_NO, KC_NO },\
/* B 1 */ {KC_NO, KC_NO, KC_##KB2, KC_##KB3, KC_NO, KC_NO, KC_NO, KC_NO },\
/* C 2 */ {KC_##KC0, KC_NO, KC_NO, KC_##KC3, KC_##KC4, KC_##KC5, KC_##KC6, KC_##KC7},\
/* D 3 */ {KC_NO, KC_NO, KC_##KD2, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO },\
/* E 4 */ {KC_##KE0, KC_##KE1, KC_##KE2, KC_##KE3, KC_##KE4, KC_##KE5, KC_##KE6, KC_##KE7},\
/* F 5 */ {KC_##KF0, KC_NO, KC_##KF2, KC_##KF3, KC_##KF4, KC_##KF5, KC_##KF6, KC_##KF7},\
/* G 6 */ {KC_NO, KC_##KG1, KC_##KG2, KC_##KG3, KC_##KG4, KC_##KG5, KC_##KG6, KC_##KG7},\
/* H 7 */ {KC_NO, KC_##KH1, KC_##KH2, KC_##KH3, KC_##KH4, KC_##KH5, KC_##KH6, KC_##KH7},\
/* I 8 */ {KC_NO, KC_##KI1, KC_##KI2, KC_##KI3, KC_##KI4, KC_##KI5, KC_##KI6, KC_##KI7},\
/* J 9 */ {KC_##KJ0, KC_##KJ1, KC_##KJ2, KC_##KJ3, KC_##KJ4, KC_##KJ5, KC_##KJ6, KC_##KJ7},\
/* K 10 */ {KC_##KK0, KC_##KK1, KC_##KK2, KC_##KK3, KC_##KK4, KC_##KK5, KC_##KK6, KC_##KK7},\
/* L 11 */ {KC_NO, KC_##KL1, KC_##KL2, KC_##KL3, KC_##KL4, KC_##KL5, KC_##KL6, KC_##KL7},\
/* M 12 */ {KC_##KM0, KC_##KM1, KC_##KM2, KC_##KM3, KC_##KM4, KC_##KM5, KC_NO, KC_##KM7},\
/* N 13 */ {KC_##KN0, KC_NO, KC_NO, KC_NO, KC_NO, KC_##KN5, KC_##KN6, KC_##KN7},\
/* O 14 */ {KC_##KO0, KC_##KO1, KC_##KO2, KC_##KO3, KC_##KO4, KC_##KO5, KC_##KO6, KC_NO },\
/* P 15 */ {KC_NO, KC_##KP1, KC_NO, KC_NO, KC_##KP4, KC_##KP5, KC_NO, KC_##KP7},\
/* Q 16 */ {KC_##KQ0, KC_##KQ1, KC_##KQ2, KC_##KQ3, KC_##KQ4, KC_NO, KC_##KQ6, KC_##KQ7},\
/* R 17 */ {KC_##KR0, KC_##KR1, KC_##KR2, KC_##KR3, KC_##KR4, KC_NO, KC_##KR6, KC_##KR7} \
}
#include "keymap_ansi.h"
#define KEYMAPS_SIZE (sizeof(keymaps) / sizeof(keymaps[0]))
#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0]))
/* translates key to keycode */
uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
{
if (layer < KEYMAPS_SIZE) {
return pgm_read_byte(&keymaps[(layer)][(key.col)][(key.row)]);
} else {
return pgm_read_byte(&keymaps[0][(key.col)][(key.row)]);
}
}
/* translates Fn keycode to action */
action_t keymap_fn_to_action(uint8_t keycode)
{
action_t action;
if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) {
action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]);
} else {
action.code = ACTION_NO;
}
return action;
}

@ -1,23 +0,0 @@
static const uint8_t PROGMEM keymaps[][MATRIX_COLS][MATRIX_ROWS] = {
/* Layer 0: Standard ANSI layer */
KEYMAP(\
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, \
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS, EQL,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, \
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, PPLS, \
CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, \
LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, PENT, \
LCTL,LGUI,LALT, SPC, RALT,RGUI, FN0,RCTL, LEFT,DOWN,RGHT, P0, PDOT), \
/* Layer 1: Function layer */
KEYMAP(\
CALC,MYCM,WSCH,WHOM,MAIL,VOLD,VOLU,MSEL,MSTP,MPLY,MPRV,MNXT,TRNS, WAKE, PWR,SLEP, \
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, \
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, \
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS, \
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, \
TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS)
};
static const uint16_t PROGMEM fn_actions[] = {
[0] = ACTION_LAYER_MOMENTARY(1)
};

@ -1,60 +0,0 @@
/*
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
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 <avr/io.h>
#include "stdint.h"
#include "led.h"
/* LED pin configuration
*
* Scroll Lock PB7
* CAPS PC6
* NUMLOCK PC5
*
*/
void led_set(uint8_t usb_led)
{
DDRB |= (1<<7);
DDRC |= (1<<5) | (1<<6);
if (usb_led & (1<<USB_LED_CAPS_LOCK))
{
PORTC &= ~(1<<6);
}
else
{
PORTC |= (1<<6);
}
if (usb_led & (1<<USB_LED_NUM_LOCK))
{
PORTC &= ~(1<<5);
}
else
{
PORTC |= (1<<5);
}
if (usb_led & (1<<USB_LED_SCROLL_LOCK))
{
PORTB &= ~(1<<7);
}
else
{
PORTB |= (1<<7);
}
}

@ -1,237 +0,0 @@
/*
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
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 <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"
#ifndef DEBOUNCE
# define DEBOUNCE 0
#endif
static uint8_t debouncing = DEBOUNCE;
static matrix_row_t matrix[MATRIX_ROWS];
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
static uint8_t read_rows(void);
static void init_rows(void);
static void unselect_cols(void);
static void select_col(uint8_t col);
inline uint8_t matrix_rows(void)
{
return MATRIX_ROWS;
}
inline uint8_t matrix_cols(void)
{
return MATRIX_COLS;
}
void matrix_init(void)
{
unselect_cols();
init_rows();
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
matrix[i] = 0;
matrix_debouncing[i] = 0;
}
}
uint8_t matrix_scan(void)
{
for (uint8_t col = 0; col < MATRIX_COLS; col++) {
select_col(col);
_delay_us(3);
uint8_t rows = read_rows();
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<<col);
bool curr_bit = rows & (1<<row);
if (prev_bit != curr_bit) {
matrix_debouncing[row] ^= ((matrix_row_t)1<<col);
debouncing = DEBOUNCE;
}
}
unselect_cols();
}
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++) {
xprintf("%02X: %032lb\n", row, bitrev32(matrix_get_row(row)));
}
}
uint8_t matrix_key_count(void)
{
uint8_t count = 0;
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
count += bitpop32(matrix[i]);
}
return count;
}
/* Row pin configuration
*
* row: 0 1 2 3 4 5 6 7
* pin: PB1 PC2 PB6 PB4 PB3 PB5 PB0 PB2
*
*/
static void init_rows(void)
{
DDRC &= ~0b00000100;
DDRB &= ~0b01111111;
PORTC |= 0b00000100;
PORTB |= 0b01111111;
}
static uint8_t read_rows(void)
{
return (PINB&(1<<1) ? 0 : (1<<0)) |
(PINC&(1<<2) ? 0 : (1<<1)) |
(PINB&(1<<6) ? 0 : (1<<2)) |
(PINB&(1<<4) ? 0 : (1<<3)) |
(PINB&(1<<3) ? 0 : (1<<4)) |
(PINB&(1<<5) ? 0 : (1<<5)) |
(PINB&(1<<0) ? 0 : (1<<6)) |
(PINB&(1<<2) ? 0 : (1<<7));
}
/* These columns uses two 74HC42 4 to 10 bit demultiplexers (low active).
*
* COL PD6 PD5 PD4 PD3 PD2 PD1
* 10 1 1 0 0 0 0
* 15 1 1 0 0 0 1
* 8 1 1 0 0 1 0
* 14 1 1 0 1 0 0
* 6 1 1 0 1 0 1
* 13 1 1 0 1 1 0
* 12 1 1 1 0 0 0
* 9 1 1 1 0 1 0
* 11 1 1 1 1 0 0
* 7 1 1 1 1 1 0
*
* COL PD1 PD2 PD3 PD4 PD5 PD6
* 3 1 1 0 0 0 1
* 4 1 1 0 0 1 0
* 17 1 1 0 1 0 0
* 16 1 1 0 1 1 0
* 0 1 1 1 0 0 1
* 5 1 1 1 0 1 0
* 2 1 1 1 1 0 0
* 1 1 1 1 1 1 0
*/
static void unselect_cols(void)
{
DDRD |= 0b01111111;
PORTD &= ~0b01111111;
}
static void select_col(uint8_t col)
{
switch (col) {
case 0:
PORTD |= (1<<6) | (1<<3) | (1<<2) | (1<<1);
break;
case 1:
PORTD |= (1<<5) | (1<<4) | (1<<3) | (1<<2) | (1<<1);
break;
case 2:
PORTD |= (1<<4) | (1<<3) | (1<<2) | (1<<1);
break;
case 3:
PORTD |= (1<<6) | (1<<2) | (1<<1);
break;
case 4:
PORTD |= (1<<5) | (1<<2) | (1<<1);
break;
case 5:
PORTD |= (1<<5) | (1<<3) | (1<<2) | (1<<1);
break;
case 6:
PORTD |= (1<<6) | (1<<5) | (1<<3) | (1<<1);
break;
case 7:
PORTD |= (1<<6) | (1<<5) | (1<<4) | (1<<3) | (1<<2);
break;
case 8:
PORTD |= (1<<6) | (1<<5) | (1<<2);
break;
case 9:
PORTD |= (1<<6) | (1<<5) | (1<<4) | (1<<2);
break;
case 10:
PORTD |= (1<<6) | (1<<5);
break;
case 11:
PORTD |= (1<<6) | (1<<5) | (1<<4) | (1<<3);
break;
case 12:
PORTD |= (1<<6) | (1<<5) | (1<<4);
break;
case 13:
PORTD |= (1<<6) | (1<<5) | (1<<3) | (1<<2);
break;
case 14:
PORTD |= (1<<6) | (1<<5) | (1<<3);
break;
case 15:
PORTD |= (1<<6) | (1<<5) | (1<<1);
break;
case 16:
PORTD |= (1<<5) | (1<<4) | (1<<2) | (1<<1);
break;
case 17:
PORTD |= (1<<4) | (1<<2) | (1<<1);
break;
}
}

@ -1,120 +0,0 @@
#----------------------------------------------------------------------------
# On command line:
#
# make all = Make software.
#
# make clean = Clean out built project files.
#
# make coff = Convert ELF to AVR COFF.
#
# make extcoff = Convert ELF to AVR Extended COFF.
#
# make program = Download the hex file to the device.
# Please customize your programmer settings(PROGRAM_CMD)
#
# make teensy = Download the hex file to the device, using teensy_loader_cli.
# (must have teensy_loader_cli installed).
#
# make dfu = Download the hex file to the device, using dfu-programmer (must
# have dfu-programmer installed).
#
# make flip = Download the hex file to the device, using Atmel FLIP (must
# have Atmel FLIP installed).
#
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
# (must have dfu-programmer installed).
#
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
# (must have Atmel FLIP installed).
#
# make debug = Start either simulavr or avarice as specified for debugging,
# with avr-gdb or avr-insight as the front end for debugging.
#
# make filename.s = Just compile filename.c into the assembler code only.
#
# make filename.i = Create a preprocessed source file for use in submitting
# bug reports to the GCC project.
#
# To rebuild project do "make clean" then "make all".
#----------------------------------------------------------------------------
# Target file name (without extension).
TARGET = hbkb_lufa
# Directory common source filess exist
TMK_DIR = ../../tmk_core
# Directory keyboard dependent files exist
TARGET_DIR = .
# List C source files here. (C dependencies are automatically generated.)
SRC += keymap.c \
matrix.c \
led.c
CONFIG_H = config.h
# MCU name
#MCU = at90usb1287
MCU = atmega32u4
# Processor frequency.
# This will define a symbol, F_CPU, in all source code files equal to the
# processor frequency in Hz. You can then use this symbol in your source code to
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
# automatically to create a 32-bit value in your source code.
#
# This will be an integer division of F_USB below, as it is sourced by
# F_USB after it has run through any CPU prescalers. Note that this value
# does not *change* the processor frequency - it should merely be updated to
# reflect the processor speed set externally so that the code can use accurate
# software delays.
F_CPU = 16000000
#
# LUFA specific
#
# Target architecture (see library "Board Types" documentation).
ARCH = AVR8
# Input clock frequency.
# This will define a symbol, F_USB, in all source code files equal to the
# input clock frequency (before any prescaling is performed) in Hz. This value may
# differ from F_CPU if prescaling is used on the latter, and is required as the
# raw input clock is fed directly to the PLL sections of the AVR for high speed
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
# at the end, this will be done automatically to create a 32-bit value in your
# source code.
#
# If no clock division is performed on the input clock inside the AVR (via the
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
F_USB = $(F_CPU)
# Build Options
# comment out to disable the options.
#
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = yes # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = yes # Console for debug
COMMAND_ENABLE = yes # Commands for debug and configuration
# Boot Section Size in bytes
# Teensy halfKay 512
# Atmel DFU loader 4096
# LUFA bootloader 4096
OPT_DEFS += -DBOOTLOADER_SIZE=4096
# Search Path
VPATH += $(TARGET_DIR)
VPATH += $(TMK_DIR)
include $(TMK_DIR)/protocol/lufa.mk
include $(TMK_DIR)/common.mk
include $(TMK_DIR)/rules.mk

@ -1,49 +0,0 @@
/*
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/>.
*/
#ifndef CONFIG_H
#define CONFIG_H
#define VENDOR_ID 0xFEED
#define PRODUCT_ID 0xBB00
#define MANUFACTURER t.m.k.
#define DEVICE_VER 0x0100
#define PRODUCT Happy Buckling Keyboard
#define DESCRIPTION mod version of IBM Model M keyboard
/* matrix size */
#define MATRIX_ROWS 12
#define MATRIX_COLS 8
/* define if matrix has ghost */
#define MATRIX_HAS_GHOST
/* Set 0 if need no debouncing */
#define DEBOUNCE 5
/* legacy keymap support */
#define USE_LEGACY_KEYMAP
/* key combination for command */
#define IS_COMMAND() ( \
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_LCTRL) | MOD_BIT(KC_LALT) | MOD_BIT(KC_LGUI)) || \
keyboard_report->mods == (MOD_BIT(KC_LALT) | MOD_BIT(KC_RALT)) \
)
#endif

@ -1,231 +0,0 @@
/*
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/>.
*/
/*
* Keymap for Macway mod
*/
#include <stdint.h>
#include <stdbool.h>
#include <avr/pgmspace.h>
#include "keycode.h"
#include "print.h"
#include "debug.h"
#include "util.h"
#include "keymap.h"
/*
* Layout: 59key
* ,-----------------------------------------------------------.
* |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `|
* |-----------------------------------------------------------|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| BS |
* |-----------------------------------------------------------|
* |Contro| A| S| D| F| G| H| J| K| L|Fn3| '|Return |
* |-----------------------------------------------------------|
* |Shift | Z| X| C| V| B| N| M| ,| .|Fn2|Shift |
* |-----------------------------------------------------------|
* |Ctrl | |Alt | Fn4 |Alt | |Fn1 |
* `-----' `---------------------------------------' `-----'
*
* Matrix: 12x8
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7
* ---+---------+---------+---------+---------+---------+---------+---------+---------
* 0 | | | LCTRL | | | | RCTRL |
* 1 | | LSHIFT | | | | | RSHIFT |
* 2 | | Tab | Grave | 1 | Q | A | Z |
* 3 | | Cpslck | | 2 | W | S | X |
* 4 | | | | 3 | E | D | C |
* 5 | G | T | 5 | 4 | R | F | V | B
* 6 | | Bckspc | | | Key*1 | Bckslsh | Enter | Space
* 7 | H | Y | 6 | 7 | U | J | M | N
* 8 | | Rbrckt | Equal | 8 | I | K | Comma |
* 9 | | | | 9 | O | L | Dot |
* A | | Lbrckt | Minus | 0 | P | Smcolon | | Slash
* B | LALT | | | | | | | RALT
* Key*1 This key locates between Equal and Backspace.
*
* Original matrix here: http://geekhack.org/showthread.php?7767-Wireless-Model-M&p=133911&viewfull=1#post133911
*/
#define KEYMAP( \
K22, K23, K33, K43, K53, K52, K72, K73, K83, K93, KA3, KA2, K82, K64, K61, \
K21, K24, K34, K44, K54, K51, K71, K74, K84, K94, KA4, KA1, K81, K65, \
K31, K25, K35, K45, K55, K50, K70, K75, K85, K95, KA5, KA0, K66, \
K11, K26, K36, K46, K56, K57, K77, K76, K86, K96, KA7, K16, \
K02, KB0, K67, KB7, K06 \
) { \
{ KC_NO, KC_NO, KC_##K02, KC_NO, KC_NO, KC_NO, KC_##K06, KC_NO }, \
{ KC_NO, KC_##K11, KC_NO, KC_NO, KC_NO, KC_NO, KC_##K16, KC_NO }, \
{ KC_NO, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_NO }, \
{ KC_NO, KC_##K31, KC_NO, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_NO }, \
{ KC_NO, KC_NO, KC_NO, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_NO }, \
{ KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \
{ KC_NO, KC_##K61, KC_NO, KC_NO, KC_##K64, KC_##K65, KC_##K66, KC_##K67 }, \
{ KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77 }, \
{ KC_NO, KC_##K81, KC_##K82, KC_##K83, KC_##K84, KC_##K85, KC_##K86, KC_NO }, \
{ KC_NO, KC_NO, KC_NO, KC_##K93, KC_##K94, KC_##K95, KC_##K96, KC_NO }, \
{ KC_##KA0, KC_##KA1, KC_##KA2, KC_##KA3, KC_##KA4, KC_##KA5, KC_NO, KC_##KA7 }, \
{ KC_##KB0, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_##KB7 }, \
}
#define KEYCODE(layer, row, col) (pgm_read_byte(&keymaps[(layer)][(row)][(col)]))
// Assign Fn key(0-7) to a layer to which switch with the Fn key pressed.
static const uint8_t PROGMEM fn_layer[] = {
0, // Fn0
1, // Fn1
2, // Fn2
3, // Fn3
4, // Fn4
0, // Fn5
0, // Fn6
0 // Fn7
};
// Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer.
// See layer.c for details.
static const uint8_t PROGMEM fn_keycode[] = {
KC_NO, // Fn0
KC_NO, // Fn1
KC_SLSH, // Fn2
KC_SCLN, // Fn3
KC_SPC, // Fn4
KC_NO, // Fn5
KC_NO, // Fn6
KC_NO // Fn7
};
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Layer 0: Default Layer
* ,-----------------------------------------------------------.
* |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `|
* |-----------------------------------------------------------|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| BS |
* |-----------------------------------------------------------|
* |Contro| A| S| D| F| G| H| J| K| L|Fn3| '|Return |
* |-----------------------------------------------------------|
* |Shift | Z| X| C| V| B| N| M| ,| .|Fn2|Shift |
* |-----------------------------------------------------------|
* |Ctrl | |Alt | Fn4 |Alt | |Fn1 |
* `-----' `---------------------------------------' `-----'
*/
KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, \
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \
LCTL,A, S, D, F, G, H, J, K, L, FN3, QUOT,ENT, \
LSFT,Z, X, C, V, B, N, M, COMM,DOT, FN2, FN1, \
LGUI, LALT, FN4, RALT, FN1),
/* Layer 1: HHKB mode (HHKB Fn)
* ,-----------------------------------------------------------.
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
* |-----------------------------------------------------------|
* |Caps | | | | | | | |Psc|Slk|Pus|Up | | |
* |-----------------------------------------------------------|
* |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig| |
* |-----------------------------------------------------------|
* |Shift | | | | | | +| -|End|PgD|Dow|Shift |
* |-----------------------------------------------------------|
* |Ctrl | |Alt | Space |Alt | |Fn1 |
* `-----' `---------------------------------------' `-----'
*/
KEYMAP(ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,BRK, UP, NO, NO, \
LCTL,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT,NO, \
LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN,FN1, \
LGUI, LALT, SPC, RALT, FN1),
/* Layer 2: Vi mode (Quote/Rmeta)
* ,-----------------------------------------------------------.
* | `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12| | |
* |-----------------------------------------------------------|
* | \ |Hom|PgD|Up |PgU|End|Hom|PgD|PgU|End| | | | |
* |-----------------------------------------------------------|
* |Contro| |Lef|Dow|Rig| |Lef|Dow|Up |Rig| | | |
* |-----------------------------------------------------------|
* |Shift | | | | | |Hom|PgD|PgU|End|xxx|Shift |
* |-----------------------------------------------------------|
* |Ctrl | |Alt | Space |Alt | |Fn1 |
* `-----' `---------------------------------------' `-----'
*/
KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, NO, NO, \
BSLS,HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, NO, \
LCTL,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, NO, \
LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN2, RSFT, \
LGUI, LALT, SPC, RALT, NO),
/* Layer 3: Mouse mode (Semicolon)
* ,-----------------------------------------------------------.
* | `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12| | |
* |-----------------------------------------------------------|
* | \ |MwL|MwD|McU|MwU|MwR|MwL|MwD|MwU|MwR| | | | |
* |-----------------------------------------------------------|
* |Contro| |McL|McD|McR| |McL|McD|McU|McR|xxx| | |
* |-----------------------------------------------------------|
* |Shift | | |Mb1|Mb2|Mb3|Mb2|Mb1| | | |Shift |
* |-----------------------------------------------------------|
* |Ctrl | |Alt | Space |Alt | | |
* `-----' `---------------------------------------' `-----'
* Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
*/
KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, NO, NO, \
BSLS,WH_L,WH_D,MS_U,WH_U,WH_R,WH_L,WH_D,WH_U,WH_R,NO, NO, NO, NO, \
LCTL,NO, MS_L,MS_D,MS_R,NO, MS_L,MS_D,MS_U,MS_R,FN3, NO, NO, \
LSFT,NO, NO, BTN1,BTN2,BTN3,BTN2,BTN1,NO, NO, NO, RSFT, \
LGUI, LALT, BTN1, RALT, NO),
/* Layer 4: Matias half keyboard style (Space)
* ,-----------------------------------------------------------.
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete |
* |-----------------------------------------------------------|
* |Backs| P| O| I| U| Y| T| R| E| W| Q| | |Tab |
* |-----------------------------------------------------------|
* |Contro| ;| L| K| J| H| G| F| D| S| A|Con|Control |
* |-----------------------------------------------------------|
* |Shift | /| .| ,| M| N| B| V| C| X| Z|Shift |
* |-----------------------------------------------------------|
* |Ctrl | |Alt | Fn4 |Alt | | |
* `-----' `---------------------------------------' `-----'
*/
KEYMAP(MINS,0, 9, 8, 7, 6, 5, 4, 3, 2, 1, NO, NO, NO, ESC, \
BSPC,P, O, I, U, Y, T, R, E, W, Q, NO, NO, TAB, \
LCTL,SCLN,L, K, J, H, G, F, D, S, A, RCTL,RCTL, \
LSFT,SLSH,DOT, COMM,M, N, B, V, C, X, Z, RSFT, \
LGUI, LALT, FN4, RALT, NO),
};
uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col)
{
return KEYCODE(layer, row, col);
}
uint8_t keymap_fn_layer(uint8_t index)
{
return pgm_read_byte(&fn_layer[index]);
}
uint8_t keymap_fn_keycode(uint8_t index)
{
return pgm_read_byte(&fn_keycode[index]);
}

@ -1,24 +0,0 @@
/*
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/>.
*/
#include "stdint.h"
#include "led.h"
void led_set(uint8_t usb_led)
{
}

@ -1,206 +0,0 @@
/*
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/>.
*/
#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"
/*
* Happy Buckling Keyboard(IBM Model M mod)
*
* Pin usage:
* COL: PD0-7
* ROW: PB0-7, PF4-7
*/
#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];
#ifdef MATRIX_HAS_GHOST
static bool matrix_has_ghost_in_row(uint8_t row);
#endif
static matrix_row_t read_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)
{
// JTAG disable for PORT F. write JTD bit twice within four cycles.
MCUCR |= (1<<JTD);
MCUCR |= (1<<JTD);
// initialize rows
unselect_rows();
// initialize columns to input with pull-up(DDR:0, PORT:1)
DDRD = 0x00;
PORTD = 0xFF;
// 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 01234567\n");
for (uint8_t row = 0; row < matrix_rows(); row++) {
phex(row); print(": ");
pbin_reverse(matrix_get_row(row));
#ifdef MATRIX_HAS_GHOST
if (matrix_has_ghost_in_row(row)) {
print(" <ghost");
}
#endif
print("\n");
}
}
#ifdef MATRIX_HAS_GHOST
inline
static bool matrix_has_ghost_in_row(uint8_t row)
{
// no ghost exists in case less than 2 keys on
if (((matrix[row] - 1) & matrix[row]) == 0)
return false;
// ghost exists in case same state as other row
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
if (i != row && (matrix[i] & matrix[row]))
return true;
}
return false;
}
#endif
inline
static matrix_row_t read_cols(void)
{
return ~PIND;
}
inline
static void unselect_rows(void)
{
// Hi-Z(DDR:0, PORT:0) to unselect
DDRB &= ~0b11111111;
PORTB &= ~0b11111111;
DDRF &= ~0b11110000;
PORTF &= ~0b11110000;
}
inline
static void select_row(uint8_t row)
{
// Output low(DDR:1, PORT:0) to select
switch (row) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
DDRB |= (1<<row);
PORTB &= ~(1<<row);
break;
case 8:
DDRF |= (1<<4);
PORTF &= ~(1<<4);
break;
case 9:
case 10:
case 11:
DDRF |= (1<<(row-4));
PORTF &= ~(1<<(row-4));
break;
}
}

@ -27,7 +27,7 @@
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
# (must have Atmel FLIP installed).
#
# make debug = Start either simulavr or avarice as specified for debugging,
# make debug = Start either simulavr or avarice as specified for debugging,
# with avr-gdb or avr-insight as the front end for debugging.
#
# make filename.s = Just compile filename.c into the assembler code only.
@ -39,27 +39,30 @@
#----------------------------------------------------------------------------
# Target file name (without extension).
TARGET = hhkb_lufa
TARGET = hhkb_qmk
# Directory common source filess exist
TOP_DIR = ../..
TMK_DIR = ../../tmk_core
# Directory keyboard dependent files exist
TARGET_DIR = .
# # project specific files
SRC = hhkb_qmk.c \
matrix.c
# List C source files here. (C dependencies are automatically generated.)
SRC += keymap_common.c \
matrix.c \
led.c
ifdef KEYMAP
SRC := keymaps/keymaps/$(KEYMAP).c $(SRC)
else
SRC := keymaps/keymaps/default.c $(SRC)
endif
CONFIG_H = config.h
# MCU name
# PJRC Teensy++ 2.0
#MCU = at90usb1286
# TMK Alt Controller or PJRC Teensy 2.0
#MCU = at90usb1287
MCU = atmega32u4
# Processor frequency.
@ -95,66 +98,52 @@ ARCH = AVR8
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
F_USB = $(F_CPU)
# Interrupt driven control endpoint task
#OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
# Interrupt driven control endpoint task(+60)
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
# Boot Section Size in *bytes*
# Teensy halfKay 512
# Teensy++ halfKay 1024
# Atmel DFU loader 4096 (TMK Alt Controller)
# Atmel DFU loader 4096
# LUFA bootloader 4096
# USBaspLoader 2048
OPT_DEFS += -DBOOTLOADER_SIZE=4096
#OPT_DEFS += -DBOOTLOADER_SIZE=4096
# as per original hasu settings
OPT_DEFS += -DBOOTLOADER_SIZE=512
# Build Options
# comment out to disable the options.
#
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration
MOUSEKEY_ENABLE = yes # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = yes # Console for debug
COMMAND_ENABLE = yes # Commands for debug and configuration
NKRO_ENABLE = yes # USB Nkey Rollover
#KEYMAP_SECTION_ENABLE = yes # fixed address keymap for keymap editor
#HHKB_JP = yes # HHKB JP support
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)
COMMAND_ENABLE = yes # Commands for debug and configuration
CUSTOM_MATRIX = yes # Custom matrix file for the HHKB
# 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 - 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 = YES # MIDI controls
# UNICODE_ENABLE = YES # Unicode
# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID
#OPT_DEFS += -DNO_ACTION_TAPPING
#OPT_DEFS += -DNO_ACTION_LAYER
#OPT_DEFS += -DNO_ACTION_MACRO
#
# Keymap file
#
ifdef KEYMAP
SRC := keymaps/$(KEYMAP).c $(SRC)
else
ifdef HHKB_JP
SRC := keymaps/jp.c $(SRC)
else
SRC := keymaps/hhkb.c $(SRC)
endif
endif
ifneq (, $(or $(findstring jp.c, $(SRC)), $(findstring yes, $(HHKB_JP))))
OPT_DEFS += -DHHKB_JP
endif
# Optimize size but this may cause error "relocation truncated to fit"
#EXTRALDFLAGS = -Wl,--relax
# Search Path
VPATH += $(TARGET_DIR)
VPATH += $(TOP_DIR)
VPATH += $(TMK_DIR)
include $(TMK_DIR)/protocol/lufa.mk
include $(TMK_DIR)/common.mk
include $(TMK_DIR)/rules.mk
debug-on: EXTRAFLAGS += -DDEBUG -DDEBUG_ACTION
debug-on: all
debug-off: EXTRAFLAGS += -DNO_DEBUG -DNO_PRINT
debug-off: OPT_DEFS := $(filter-out -DCONSOLE_ENABLE,$(OPT_DEFS))
debug-off: all
include $(TOP_DIR)/quantum/quantum.mk

@ -1,2 +0,0 @@
HHKB_JP = yes
include Makefile

@ -1,68 +0,0 @@
#
# Makefile for PJRC Teensy
#
# Target file name (without extension).
TARGET = hhkb_pjrc
# Directory common source filess exist
TMK_DIR = ../../tmk_core
# Directory keyboard dependent files exist
TARGET_DIR = .
# keyboard dependent files
SRC = keymap_common.c \
matrix.c \
led.c
ifdef KEYMAP
SRC := keymaps/$(KEYMAP).c $(SRC)
else
SRC := keymaps/hasu.c $(SRC)
endif
CONFIG_H = config.h
# MCU name, you MUST set this to match the board you are using
# type "make clean" after changing this, so all files will be rebuilt
#MCU = at90usb162 # Teensy 1.0
MCU = atmega32u4 # Teensy 2.0
#MCU = at90usb646 # Teensy++ 1.0
#MCU = at90usb1286 # Teensy++ 2.0
# Processor frequency.
# Normally the first thing your program should do is set the clock prescaler,
# so your program will run at the correct speed. You should also set this
# variable to same clock speed. The _delay_ms() macro uses this, and many
# examples use this variable to calculate timings. Do not add a "UL" here.
F_CPU = 16000000
# Build Options
# comment out to disable the options.
#
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration
MOUSEKEY_ENABLE = yes # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = yes # Console for debug
COMMAND_ENABLE = yes # Commands for debug and configuration
NKRO_ENABLE = yes # USB Nkey Rollover
#---------------- Programming Options --------------------------
PROGRAM_CMD = teensy_loader_cli -mmcu=$(MCU) -w -v $(TARGET).hex
# Search Path
VPATH += $(TARGET_DIR)
VPATH += $(TMK_DIR)
include $(TMK_DIR)/protocol/pjrc.mk
include $(TMK_DIR)/common.mk
include $(TMK_DIR)/rules.mk

@ -1,155 +0,0 @@
#----------------------------------------------------------------------------
# On command line:
#
# make all = Make software.
#
# make clean = Clean out built project files.
#
# make coff = Convert ELF to AVR COFF.
#
# make extcoff = Convert ELF to AVR Extended COFF.
#
# make program = Download the hex file to the device.
# Please customize your programmer settings(PROGRAM_CMD)
#
# make teensy = Download the hex file to the device, using teensy_loader_cli.
# (must have teensy_loader_cli installed).
#
# make dfu = Download the hex file to the device, using dfu-programmer (must
# have dfu-programmer installed).
#
# make flip = Download the hex file to the device, using Atmel FLIP (must
# have Atmel FLIP installed).
#
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
# (must have dfu-programmer installed).
#
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
# (must have Atmel FLIP installed).
#
# make debug = Start either simulavr or avarice as specified for debugging,
# with avr-gdb or avr-insight as the front end for debugging.
#
# make filename.s = Just compile filename.c into the assembler code only.
#
# make filename.i = Create a preprocessed source file for use in submitting
# bug reports to the GCC project.
#
# To rebuild project do "make clean" then "make all".
#----------------------------------------------------------------------------
# Target file name (without extension).
TARGET = hhkb_rn42
# Directory common source filess exist
TMK_DIR = ../../tmk_core
# Directory keyboard dependent files exist
TARGET_DIR = .
# List C source files here. (C dependencies are automatically generated.)
SRC += keymap_common.c \
matrix.c \
led.c
CONFIG_H = config_rn42.h
# MCU name
MCU = atmega32u4
# Processor frequency.
# This will define a symbol, F_CPU, in all source code files equal to the
# processor frequency in Hz. You can then use this symbol in your source code to
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
# automatically to create a 32-bit value in your source code.
#
# This will be an integer division of F_USB below, as it is sourced by
# F_USB after it has run through any CPU prescalers. Note that this value
# does not *change* the processor frequency - it should merely be updated to
# reflect the processor speed set externally so that the code can use accurate
# software delays.
F_CPU = 16000000
#
# LUFA specific
#
# Target architecture (see library "Board Types" documentation).
ARCH = AVR8
# Input clock frequency.
# This will define a symbol, F_USB, in all source code files equal to the
# input clock frequency (before any prescaling is performed) in Hz. This value may
# differ from F_CPU if prescaling is used on the latter, and is required as the
# raw input clock is fed directly to the PLL sections of the AVR for high speed
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
# at the end, this will be done automatically to create a 32-bit value in your
# source code.
#
# If no clock division is performed on the input clock inside the AVR (via the
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
F_USB = $(F_CPU)
# Interrupt driven control endpoint task
#OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
# Boot Section Size in *bytes*
# Teensy halfKay 512
# Teensy++ halfKay 1024
# Atmel DFU loader 4096 (TMK Alt Controller)
# LUFA bootloader 4096
# USBaspLoader 2048
OPT_DEFS += -DBOOTLOADER_SIZE=4096
# Build Options
# comment out to disable the options.
#
#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration
MOUSEKEY_ENABLE = yes # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = yes # Console for debug
COMMAND_ENABLE = yes # Commands for debug and configuration
#NKRO_ENABLE = yes # USB Nkey Rollover
#KEYMAP_SECTION_ENABLE = yes # fixed address keymap for keymap editor
#HHKB_JP = yes # HHKB JP support
#
# Keymap file
#
ifdef KEYMAP
SRC := keymaps/$(KEYMAP).c $(SRC)
else
ifdef HHKB_JP
SRC := keymaps/jp.c $(SRC)
else
SRC := keymaps/hhkb.c $(SRC)
endif
endif
ifneq (, $(or $(findstring jp.c, $(SRC)), $(findstring yes, $(HHKB_JP))))
OPT_DEFS += -DHHKB_JP
endif
# Search Path
VPATH += $(TARGET_DIR)
VPATH += $(TMK_DIR)
include rn42.mk
include $(TMK_DIR)/protocol.mk
include $(TMK_DIR)/protocol/lufa.mk
include $(TMK_DIR)/common.mk
include $(TMK_DIR)/rules.mk
debug-on: EXTRAFLAGS += -DDEBUG -DDEBUG_ACTION
debug-on: all
debug-off: EXTRAFLAGS += -DNO_DEBUG -DNO_PRINT
debug-off: OPT_DEFS := $(filter-out -DCONSOLE_ENABLE,$(OPT_DEFS))
debug-off: all

@ -1,102 +1,180 @@
Alternative Controller for HHKB Pro
===================================
I wanted to add some features like vi cursor and mouse keys to my [HHKB][HHKB] but its controller is not programmable and firmware source code is not open, of course. This means customizing this keyboard needs to replace original controller with programmable one.
hhkb_qmk keyboard firmware
======================
This controller can work with HHKB **Professional**, **Professional** 2, **JP** and **Type-S**.
## Quantum MK Firmware
See [this thread][AltController] in geekhack.org.
You have access to a bunch of goodies! Check out the Makefile to enable/disable some of the features. Uncomment the `#` to enable them. Setting them to `no` does nothing and will only confuse future you.
[HHKB]: http://www.pfu.fujitsu.com/hhkeyboard/
[AltController]: http://geekhack.org/index.php?topic=12047.0
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
MIDI_ENABLE = yes # MIDI controls
# UNICODE_ENABLE = yes # Unicode support - this is commented out, just as an example. You have to use #, not //
BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID
## Quick aliases to common actions
## Update
* Bluetooth module RN-42 is supported.(2015/01)
* V-USB and iWRAP are no longer supported now, but still it'll works with a little fix. See not_supported directory.(2015/01)
Your keymap can include shortcuts to common operations (called "function actions" in tmk).
### Switching and toggling layers
##Features
* Customizable keymap
* More keymap layers(more Fn keys)
* Mouse keys
* USB NKRO
* Bluetooth(RN-42)
`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.
See README of [tmk_keyboard] for more.
`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).
[tmk_keyboard]: http://github.com/tmk/tmk_keyboard
###Pros
* No risks: Everything is all reversible
* No need for PCB trace patching, case cutting or any other destructive mod
* Can keep original controller intact
* Can change all HHKB behavior as you like
`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
* `RSFT(kc)` - applies right Shift to *kc*
* `LCTL(kc)` - applies left Control to *kc*
* `RCTL(kc)` - applies right Control to *kc*
* `LALT(kc)` - applies left Alt to *kc*
* `RALT(kc)` - applies right Alt to *kc*
* `LGUI(kc)` - applies left GUI (command/win) to *kc*
* `RGUI(kc)` - applies right GUI (command/win) to *kc*
You can also chain these, like this:
LALT(LCTL(KC_DEL)) -- this makes a key that sends Alt, Control, and Delete in a single keypress.
The following shortcuts automatically add `LSFT()` to keycodes to get commonly used symbols. Their long names are also available and documented in `/quantum/keymap_common.h`.
KC_TILD ~
KC_EXLM !
KC_AT @
KC_HASH #
KC_DLR $
KC_PERC %
KC_CIRC ^
KC_AMPR &
KC_ASTR *
KC_LPRN (
KC_RPRN )
KC_UNDS _
KC_PLUS +
KC_LCBR {
KC_RCBR }
KC_PIPE |
KC_COLN :
`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):
* MOD_LCTL
* MOD_LSFT
* MOD_LALT
* MOD_LGUI
###Cons
* Void your warranty
* Lose USB hub function of Pro2
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.
##DISCLAIMER
I'm not a professional of electronics nor MCU programming. This may damage your HHKB.
And my English writing is poor, I'm not sure I can convey my notions accurately.
We've added shortcuts to make common modifier/tap (mod-tap) mappings more compact:
* `CTL_T(kc)` - is LCTL when held and *kc* when tapped
* `SFT_T(kc)` - is LSFT when held and *kc* when tapped
* `ALT_T(kc)` - is LALT when held and *kc* when tapped
* `GUI_T(kc)` - is LGUI when held and *kc* when tapped
* `ALL_T(kc)` - is Hyper (all mods) when held and *kc* when tapped. To read more about what you can do with a Hyper key, see [this blog post by Brett Terpstra](http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/)
##Documents
See [doc/HHKB.txt](doc/HHKB.txt) and files under [doc/](doc/) for internal of HHKB and this controller.
### Temporarily setting the default layer
`DF(layer)` - sets default layer to *layer*. The default layer is the one at the "bottom" of the layer stack - the ultimate fallback layer. This currently does not persist over power loss. When you plug the keyboard back in, layer 0 will always be the default. It is theoretically possible to work around that, but that's not what `DF` does.
##Build Firmware & Program
See [this document](../../doc/build.md) first.
### Remember: These are just aliases
### Configuration
If your target is **HHKB JP** you need to set `HHKB_JP` build option in `Makefile` or use `Makefile.jp` instead of `Makefile`.
These functions work the same way that their `ACTION_*` functions do - they're just quick aliases. To dig into all of the tmk ACTION_* functions, please see the [TMK documentation](https://github.com/jackhumbert/qmk_firmware/blob/master/tmk_core/doc/keymap.md#2-action).
If you use other than **TMK Alt Controller Board** set proper `MCU`, `BOOTLOADER_SIZE` and other build options in `Makefile` and `config.h`. At least PJRC Teensy requires changing `BOOTLOADER_SIZE` to 512.
Instead of using `FNx` when defining `ACTION_*` functions, you can use `F(x)` - the benefit here is being able to use more than 32 function actions (up to 4096), if you happen to need them.
### Build
Several version of keymap are available in advance but you are recommended to define your favorite layout yourself. Just `make` with `KEYMAP` option like:
## Macro shortcuts: Send a whole string when pressing just one key
$ make -f Makefile.<jp|pjrc|rn42> KEYMAP=(hasu|hhkb|spacefn|<name>)
Instead of using the `ACTION_MACRO` function, you can simply use `M(n)` to access macro *n* - *n* will get passed into the `action_get_macro` as the `id`, and you can use a switch statement to trigger it. This gets called on the keydown and keyup, so you'll need to use an if statement testing `record->event.pressed` (see keymap_default.c).
You can omit `-f` option when you use `Makefile`. `Makefile` is used for **Pro2 and Pro**, `Makefile.jp` fits for **JP** model and `Makefile.rn42` supports Bluetooth module **RN-42**. `Makefile.pjrc` uses **PJRC** as output protocol instead of **LUFA**.
```c
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) // this is the function signature -- just copy/paste it into your keymap file as it is.
{
switch(id) {
case 0: // this would trigger when you hit a key mapped as M(0)
if (record->event.pressed) {
return MACRO( I(255), T(H), T(E), T(L), T(L), W(255), T(O), END ); // this sends the string 'hello' when the macro executes
}
break;
}
return MACRO_NONE;
};
```
A macro can include the following commands:
* I() change interval of stroke in milliseconds.
* D() press key.
* U() release key.
* T() type key(press and release).
* W() wait (milliseconds).
* END end mark.
So above you can see the stroke interval changed to 255ms between each keystroke, then a bunch of keys being typed, waits a while, then the macro ends.
Note: Using macros to have your keyboard send passwords for you is a bad idea.
### Additional keycode aliases for software-implemented layouts (Colemak, Dvorak, etc)
Everything is assuming you're in Qwerty (in software) by default, but there is built-in support for using a Colemak or Dvorak layout by including this at the top of your keymap:
#include "keymap_<layout>.h"
Where <layout> is "colemak" or "dvorak". After including this line, you will get access to:
* `CM_*` for all of the Colemak-equivalent characters
* `DV_*` for all of the Dvorak-equivalent characters
These implementations assume you're using Colemak or Dvorak on your OS, not on your keyboard - this is referred to as a software-implemented layout. If your computer is in Qwerty and your keymap is in Colemak or Dvorak, this is referred to as a firmware-implemented layout, and you won't need these features.
To give an example, if you're using software-implemented Colemak, and want to get an `F`, you would use `CM_F` - `KC_F` under these same circumstances would result in `T`.
### Program
First, push reset button on board to start bootloader.
## Additional language support
This command programs the controller with [dfu-programmer] if the tool is installed and configured properly.
In `quantum/keymap_extras/`, you'll see various language files - these work the same way as the alternative layout ones do. Most are defined by their two letter country/language code followed by an underscore and a 4-letter abbreviation of its name. `FR_UGRV` which will result in a `ù` when using a software-implemented AZERTY layout. It's currently difficult to send such characters in just the firmware (but it's being worked on - see Unicode support).
$ make -f Makefile.<variant> KEYMAP=<name> dfu
## Unicode support
Or you can also use [FLIP] command to program. Also the tool should be installed and configured properly. FLIP GUI application is also available.
You can currently send 4 hex digits with your OS-specific modifier key (RALT for OSX with the "Unicode Hex Input" layout) - this is currently limited to supporting one OS at a time, and requires a recompile for switching. 8 digit hex codes are being worked on. The keycode function is `UC(n)`, where *n* is a 4 digit hexidecimal. Enable from the Makefile.
$ make -f Makefile.<variant> KEYMAP=<name> flip
## Other firmware shortcut keycodes
Use [Teensy Loader] if your controller is Teensy/Teensy++.
* `RESET` - puts the MCU in DFU mode for flashing new firmware (with `make dfu`)
* `DEBUG` - the firmware into debug mode - you'll need hid_listen to see things
* `BL_ON` - turns the backlight on
* `BL_OFF` - turns the backlight off
* `BL_<n>` - sets the backlight to level *n*
* `BL_INC` - increments the backlight level by one
* `BL_DEC` - decrements the backlight level by one
* `BL_TOGG` - toggles the backlight
* `BL_STEP` - steps through the backlight levels
Enable the backlight from the Makefile.
##Keymap
To define your own keymap create a file in the keymaps folder named `<name>.c` and see keymap document (you can find in top README.md) and existent keymap files.
## MIDI functionalty
This is still a WIP, but check out `quantum/keymap_midi.c` to see what's happening. Enable from the Makefile.
##Hardware
You have some options for hardware. Development boards with USB AVR family(ATMega32U4, AT90USB1286) like Teensy will work while MegaAVR with [V-USB] library is also cheaper option for DIY.
## Bluetooth functionality
###1. TMK Alt Controller Board
Design files are available at [Keyboard Controller Board for HHKB(KiCad project)](https://github.com/tmk/HHKB_controller) and see [Controller Distribution thread](http://geekhack.org/index.php?topic=56494.0) if you get an assembled one.
This requires [some hardware changes](https://www.reddit.com/r/MechanicalKeyboards/comments/3psx0q/the_planck_keyboard_with_bluetooth_guide_and/?ref=search_posts), but can be enabled via the Makefile. The firmware will still output characters via USB, so be aware of this when charging via a computer. It would make sense to have a switch on the Bluefruit to turn it off at will.
## Building
###2. PJRC Teensy
See [this thread](http://geekhack.org/index.php?topic=57008.0).
Download or clone the whole firmware and navigate to the keyboard/planck folder. Once your dev env is setup, you'll be able to type `make` to generate your .hex - you can then use `make dfu` to program your PCB once you hit the reset button.
Depending on which keymap you would like to use, you will have to compile slightly differently.
###3. V-USB version
See [V-USB controller for HHKB](doc/V-USB.md).
### Default
To build with the default keymap, simply run `make`.
### Other Keymaps
Several version of keymap are available in advance but you are recommended to define your favorite layout yourself. To define your own keymap create a file in the keymaps folder named `<name>.c` and see keymap document (you can find in top README.md) and existent keymap files.
[LUFA]: http://www.fourwalledcubicle.com/LUFA.php
[PJRC]: http://www.pjrc.com/teensy/usb_keyboard.html
[dfu-programmer]: http://dfu-programmer.sourceforge.net/
[FLIP]: http://www.atmel.com/tools/FLIP.aspx
[Teensy Loader]: http://www.pjrc.com/teensy/loader.html
[V-USB]: http://www.obdev.at/products/vusb/index.html
To build the firmware binary hex file with a keymap just do `make` with `KEYMAP` option like:
```
$ make KEYMAP=[default|jack|<name>]
```
Keymaps follow the format **__\<name\>.c__** and are stored in the `keymaps` folder.

@ -1,5 +1,5 @@
/*
Copyright 2011 Jun Wako <wakojun@gmail.com>
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
@ -18,43 +18,43 @@ 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 0xCAFE
#define DEVICE_VER 0x0104
#define MANUFACTURER t.m.k.
#define MANUFACTURER q.m.k
#define PRODUCT HHKB mod
#define DESCRIPTION t.m.k. keyboard firmware for HHKB mod
#define DESCRIPTION q.m.k keyboard firmware for HHKB
/* matrix size */
#ifdef HHKB_JP
# define MATRIX_ROWS 16
#else
# define MATRIX_ROWS 8
#endif
/* key matrix size */
#define MATRIX_ROWS 8
#define MATRIX_COLS 8
#define TAPPING_TERM 200
/* key combination for command */
#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)))
/* number of backlight levels */
#define BACKLIGHT_LEVELS 3
/* period of tapping(ms) */
#define TAPPING_TERM 300
/* tap count needed for toggling a feature */
#define TAPPING_TOGGLE 5
/* Oneshot timeout(ms) */
#define ONESHOT_TIMEOUT 300
/* Set 0 if debouncing isn't needed */
#define DEBOUNCE 5
/* Boot Magic salt key: Space */
#define BOOTMAGIC_KEY_SALT KC_SPACE
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
//#define LOCKING_SUPPORT_ENABLE
/* Locking resynchronize hack */
//#define LOCKING_RESYNC_ENABLE
/* key combination for command */
#define IS_COMMAND() ( \
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
)
/*
* Feature disable options
* These options are also useful to firmware size reduction.
*/
*/
/* disable debug print */
//#define NO_DEBUG

@ -1,112 +0,0 @@
/*
Copyright 2011 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 CONFIG_H
#define CONFIG_H
#define VENDOR_ID 0xFEED
#define PRODUCT_ID 0x4242
#define DEVICE_VER 0x0104
#define MANUFACTURER t.m.k.
#define PRODUCT HHKB mod
#define DESCRIPTION t.m.k. keyboard firmware for HHKB mod
/* matrix size */
#ifdef HHKB_JP
# define MATRIX_ROWS 16
#else
# define MATRIX_ROWS 8
#endif
#define MATRIX_COLS 8
/* key combination for command */
#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)))
/* period of tapping(ms) */
#define TAPPING_TERM 300
/* tap count needed for toggling a feature */
#define TAPPING_TOGGLE 5
/* Oneshot timeout(ms) */
#define ONESHOT_TIMEOUT 300
/* Boot Magic salt key: Space */
#define BOOTMAGIC_KEY_SALT KC_FN6
/* power control of key switch board */
#define HHKB_POWER_SAVING
/*
* Hardware Serial(UART)
* Baud rate are calculated with round off(+0.5).
*/
#ifdef __AVR_ATmega32U4__
/* iom32u4.h has no definition of UCSR1D. copy from iom32u2.h */
#define UCSR1D _SFR_MEM8(0xCB)
#define RTSEN 0
#define CTSEN 1
#define SERIAL_UART_BAUD 115200
#define SERIAL_UART_DATA UDR1
#define SERIAL_UART_UBRR ((F_CPU/(16.0*SERIAL_UART_BAUD)-1+0.5))
#define SERIAL_UART_RXD_VECT USART1_RX_vect
#define SERIAL_UART_TXD_READY (UCSR1A&(1<<UDRE1))
#define SERIAL_UART_INIT() do { \
UBRR1L = (uint8_t) SERIAL_UART_UBRR; /* baud rate */ \
UBRR1H = ((uint16_t)SERIAL_UART_UBRR>>8); /* baud rate */ \
UCSR1B |= (1<<RXCIE1) | (1<<RXEN1); /* RX interrupt, RX: enable */ \
UCSR1B |= (0<<TXCIE1) | (1<<TXEN1); /* TX interrupt, TX: enable */ \
UCSR1C |= (0<<UPM11) | (0<<UPM10); /* parity: none(00), even(01), odd(11) */ \
UCSR1D |= (0<<RTSEN) | (0<<CTSEN); /* RTS, CTS(no flow control by hardware) */ \
DDRD |= (1<<5); PORTD &= ~(1<<5); /* RTS for flow control by firmware */ \
sei(); \
} while(0)
#define SERIAL_UART_RTS_LO() do { PORTD &= ~(1<<5); } while (0)
#define SERIAL_UART_RTS_HI() do { PORTD |= (1<<5); } while (0)
#else
#error "USART configuration is needed."
#endif
/* for debug */
#define SUART_OUT_PORT PORTD
#define SUART_OUT_BIT 0
#define SUART_IN_PIN PIND
#define SUART_IN_BIT 1
/*
* 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
#endif

@ -1,39 +0,0 @@
HHKB Bluetooth mod
==================
See this article:
http://geekhack.org/showwiki.php?title=Island:20851
Power consume
=============
Switch board
------------
5V
18mA full scan/no power control
16.5mA full scan with power control of POWER_ON/POWER_OFF in matrix.c
3.5-6mA 60ms watchdog timer sleep iwrap/main.c
- the longer sleep time the less power is consumed.
- power control of swtich board must be needed.
FET switch may be better, though 18mA is with in port sink current limit. In current design switch board ground is connected to PB5 pin and power it on by making the pin low.
Blueguiga WT12
--------------
3.3V
-42mA startup/searching/connecting
19-23mA connected
4mA -8mA not connected
iWRAP sleep command may not work. to be looked into.
Power Over all
--------------
5V
-65mA startup
17-24mA idle/not connected
-42mA connecting
32-37mA idle/connecting(with sleep)
50-53mA typing/connecting(no sleep)
2013/06/07

Binary file not shown.

Before

Width:  |  Height:  |  Size: 490 KiB

@ -1,204 +0,0 @@
Internal of HHKB pro
=====================
HHKB pro has MCU and some chips on separate two PCBs.
Controller PCB
--------------
M38K07M4 Renesas MCU with USB function
http://documentation.renesas.com/eng/products/mpumcu/rej03b0192_38k0ds.pdf
(HHKB_controller.jpg)
Keyswitch PCB
-------------
HC4051 Analog Multiplexer: select a row line.
http://www.ti.com/lit/ds/schs122j/schs122j.pdf
LS145 BCD Decoder: select a column line.
http://www.ti.com/lit/ds/symlink/sn74ls145.pdf
BU9831 Non-volatile electronic potentiometer: for calibration?
https://www.spezial.com/doc/rohm-a/bu9831.pdf
TP1683/4 Capacitive Sensing controller: no datasheet available.
(HHKB_keyswitch.jpg)
Topre original chip?
(HHKB_TP1684.jpg)
Connector Cable
---------------
Two PCBs are connected by 15 lines(13 in case of Pro2).
Vcc and GND use 3(2) lines each, other lines are for keyboard signaling.
HHKB connector lines:
JP Pro2 Pro Function Description TMK pin usage
--------------------------------------------------------------------------------------------
1 Vcc(5V) 5V
1 1 2 Vcc(5V) 5V
2 2 3 Vcc(5V) 5V
3 3 4 TP1684 ~KEY: Low(0) when key is pressed PD7 input(with pullup)
4 4 5 TP1684 HYS: High(1) when key is pressed PB7 output
5 5 6 HC4051 A(bit0)\ PB0 output
6 6 7 HC4051 B(bit1) > select row 0-7 PB1 output
7 7 8 HC4051 C(bit2)/ PB2 output
8 8 9 LS145 A(bit0)\ PB3 output
9 9 10 LS145 B(bit1) > select column 0-7 PB4 output
10 10 11 LS145 C(bit2)/ PB5 output
11 11 12 LS145 ~D(enable) Low(0) enables selected column PB6 output
12 12 13 GND GND
13 13 14 GND GND
15 GND
14 HC4051(Z2) ~Enable of Z2 row0-7 PC6
15 HC4051(Z3) ~Enable of Z3 row8-15 PC7
NOTE: Probably HYS changes threshold for upstroke and makes hysteresis in the result.
NOTE: HYS should be given High(1) when previous KEY state is Low(0).
NOTE: 1KOhm didn't work as pullup resistor on KEY. AVR internal pullup or 10KOhm resistor was OK.
NOTE: JP has two HC4051(Z2,Z3) and line 5, 6 and 7 are connected to both of them.
(HHKB_connector.jpg)
Keyswitch matrix
----------------
HHKB switch matrix is ghost-free and bounce-free.
Pro/Pro2(8x8):
COL 0 1 2 3 4 5 6 7
ROW ---------------------------------------------------------------
0| 2 q w s a z x c
1| 3 4 r e d f v b
2| 5 6 y t g h n _NONE_
3| 1 Esc Tab Control LShift LAlt LMeta Space
4| 7 8 u i k j m _NONE_
5| \ ` Delete Return Fn RShift RAlt RMeta
6| 9 0 o p ; l , _NONE_
7| - + ] [ ' / . _NONE_
JP(16x8):
COL 0 1 2 3 4 5 6 7
ROW ---------------------------------------------------------------
0| ESC TAB LFn LShift LCtrl
1| 4 E MuHKN C D
2| 3 W LAlt X S
3| 1 HHK
4|
5| 5 R V F
6| 2 Q LGui Z A
7| 6 T Space B G
8| 9 I Kana , K
9| 8 U Henkan M J
A| 7 Y N H
B| 0 O RAlt . L
C| BS Right RShift Enter
D| \ [ Down Up ]
E| - P RFn / ;
F| ~ @ Left Ro :
Matrix diagram:
Pro/Pro2:
+-------------------------+-+-+-+-+-+-+-+ Vcc
|bias control? - - - - - - - - ---
| 3.9K*8 R R R R R R R R |
+--------^+ +--------+ - - - - - - - - |
| 2| | HC4051 <0-------|-|-|-|-|-|-|-|--|R|-+
| |capa. | <1-------|-|-|-|-|-|-|-|--|R|-+
| TP1684 |sense | <2-------|-|-|-|-|-|-|-|--|R|-+
| 11<------| <3-------|-|-|-|-|-|-|-|--|R|-+
| | | <4-------|-|-|-|-|-|-|-|--|R|-+
| | | <5-------|-|-|-|-|-|-|-|--|R|-+
| <-+ | <6-------|-|-|-|-|-|-|-|--|R|-+
| 1 4 | | | <7-------|-|-|-|-|-|-|-|--|R|-+
+---V---^-+ | +-^-^-^--+ 0 1 2 3 4 5 6 7 33K*8
KEY HYS | A B C +-----------------+
| | +-^----+ | | | | LS145 |
Vcc | | |BU9831| | | | +-^--^--^--^------+
--- | | +------+ | | | A B C D +-------+
| | | | | | | | | | | |
1-3 4 5 6 7 8 9 10 11 12 13-15 Pro |
1-2 3 4 5 6 7 8 9 10 11 12-13 Pro2|
+--------------------------------------------------+ |
| connector | ---
+--------------------------------------------------+ GND
JP:
+-----------------------------+-+-+-+-+ Vcc
|bias control? - - - - - ---
| 3.9K*5 R R R R R |
+--------^+ +--------+ - - - - - |
| | | HC4051 <0-----------|-|-|-|-|----|R|-+
| |capa. | Z2 <1-----------|-|-|-|-|----|R|-+
| TP1684 |sense | <2-----------|-|-|-|-|----|R|-+
| <---+--| <3-----------|-|-|-|-|----|R|-+
| | | | <4-----------|-|-|-|-|----|R|-+
| | ~En| <5-----------|-|-|-|-|----|R|-+
| | +----> <6-----------|-|-|-|-|----|R|-+
| | | | | A B C <7-----------|-|-|-|-|----|R|-+
+---V---^-+ | | +-^-^-^--+ | | | | | |
KEY HYS | | | | | | | | | | |
| | | | +--------+ | | | | | |
| | | | | HC4051 <8-----------|-|-|-|-|----|R|-+
| | | | | Z3 <9-----------|-|-|-|-|----|R|-+
| | | +--| <A-----------|-|-|-|-|----|R|-+
| | | | <B-----------|-|-|-|-|----|R|-+
| | | | <C-----------|-|-|-|-|----|R|-+
| | | ~En| <D-----------|-|-|-|-|----|R|-+
| | | +-> <E-----------|-|-|-|-|----|R|-+
| | | | | A B C <F-----------|-|-|-|-|----|R|-+
| | | | +-^-^-^--+ 0 1 2 3 4 5 6 7 33K*8
| | | | | | | +-----------------+
| | | | | | | | LS145 |
Vcc | | | | | | | +-^--^--^--^------+
--- | | | | | | | A B C D +-------+
| | | | | | | | | | | | | |
1-2 3 4 14 15 5 6 7 8 9 10 11 12-13 |
+--------------------------------------------------+ |
| connector | ---
+--------------------------------------------------+ GND
Signals charts
--------------
While pressing space bar, watched HHKB Pro original controller signals by logic analyzer.
Row and column is looping between 0-7 each for selecting a key.
A key is scaned every about 15ms, so scan rate is 66Hz.
(HHKB_chart1.jpg)
Space bar locate at ROW:3 COL:7. A key is selected by HC4051(C,B,A) and LS145(C,B,A).
Key state can be read on TP1684(4/KEY) while asserting low on LS145(D).
(HHKB_chart2.jpg)
Signal of JP:
1) Select row
rowC ____~~~~____~~~~ 3.8/3.8ms(JP) 7.7/7.7ms(Pro) S2 of HC4051
rowB __~~__~~__~~__~~ 1.9/1.9ms(JP) 3.8/3.8ms(Pro) S1 of HC4051
rowA _~_~_~_~_~_~_~_~ 1.0/1.0ms(JP) 1.9/1.9ms(Pro) S0 of HC4051
0123456701234567 selected row(Pro)
0123456789ABCDEF selected row(JP)
rowEn0 ________~~~~~~~~ 7.7/7.7ms(JP only) ~Enable of Z2 HC4051(JP only)
rowEn1 ~~~~~~~~________ 7.7/7.7ms(JP only) ~Enable of Z3 HC4051(JP only)
2) Select column
colC ____~~~~____~~~~ 550/410us(JP) / us(Pro)
colB __~~__~~__~~__~~ 200/210us(JP) 450/460us(Pro)
colA _~_~_~_~_~_~_~_~ 100/110us(JP) 220/230us(Pro)
0123456701234567 selected column
3) Wait 5us after column select, then set prev, strobe colD to spit out key status and read it.
hys _~~~~_____ 20us if previous key state is low
colD ~~~__~~~~~ 10us strobe
key ~~~____~~~ 22us indicates current state of the key
NOTE: JP scans twice fast as Pro/Pro2 does. So Pro/Pro2 scans 8x8 matrix in 15.4ms while JP scans 16x8 in that time.
EOF

Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 189 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 168 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 204 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 151 KiB

@ -1,69 +0,0 @@
HHKB keycodes
=============
2015/10/03
Looked into unclear keycodes(usages) of Fn-chording-key on HHKB.
Followings are usages of Keyboard/Keypad Page(0x07) that HHKB spits out when Fn key is down.
## HHK mode(Off-Off)
Key Usage
------------------------
⌘ / ◇ 0x78 Stop
## Lite Ext. mode(On-Off)
## Mac mode(Off-On)
Key Usage
------------------------
Esc 0x66 Power
A 0x81 Volume Down
S 0x80 Volume Up
D 0x7F Mute
F 0x6F F20
Delete 0x53 Num Lock and Clear
## Secret mode(On-On)
Key Usage
------------------------
Esc 0x66 Power
Q 0x78 Stop
W 0x7E Find
E 0x74 Execute
R 0x77 Select
T 0x76 Menu
Y 0x75 Help
Z 0x7A Undo
X 0x7B Cut
C 0x7C Copy
V 0x7D Paste
B 0x79 Again
## Matrix Key-Mode
Mode
-------------------------------
Key HHK Lite Mac Secret Desc
---------------------------------------------------------------------------------------
⌘ / ◇ 0x78 - - - Stop
Esc - - 0x66 0x66 Power
A - - 0x81 - Volume Down
S - - 0x80 - Volume Up
D - - 0x7F - Mute
F - - 0x6F - F20
Delete 0x2A 0x2A 0x53 0x2A Num Lock and Clear(0x53)/Backspace(0x2A)
Q - - - 0x78 Stop
W - - - 0x7E Find
E - - - 0x74 Execute
R - - - 0x77 Select
T - - - 0x76 Menu
Y - - - 0x75 Help
Z - - - 0x7A Undo
X - - - 0x7B Cut
C - - - 0x7C Copy
V - - - 0x7D Paste
B - - - 0x79 Again
EOF

@ -1,48 +0,0 @@
HHKB Power consumption
----------------------
**Power consumption
board clock/prescaler keyswitch power ctrl current
--------------------------------------------------------------------------
tmk 16MHz no no 26.4mA
tmk 16MHz pro1 no 45.1mA
tmk 16MHz/2 no no 18.1mA
tmk 16MHz/2 pro1 no 37.3mA
tmk 8MHz no no 18.9mA
tmk 8MHz pro2 no(w/o FET) 32.1mA
tmk 8MHz pro2 no(w FET) 32.1mA withou POWER_ON/FF
tmk 8MHz pro2 no(w FET) 32.6mA with POWR_ON/OFF
tmk 8MHz pro2 15ms(w FET) 21.3mA with POWR_ON/OFF, enumerated but error -32
tmk 8MHz pro2 60ms(w FET) 13.3mA with POWR_ON/OFF, not enumerated
gh60 16MHz 25.8mA
gh60 16MHz USB suspend w LED breathing 17.6-29.1mA
gh60 16MHz USB suspend w/o LED 0.2mA(0.231-0.276mA)
Poker 5.6mA
Poker USB suspend 0.3mA(0.301mA)
gh60 16MHz stock firmware by komar 26.8mA
HHKB pro2 Over All 139.4mA
HHKB pro2 Controller 115.1mA
HHKB pro1 Controller 25.9mA
keyswitch power consumption:
pro1: 45.1-26.4=18.7mA
37.3-18.1=19.2mA
pro2: 32.1-18.9=13.2mA
**Low Freq Crystal or Prescaler?
No advantage of Low Freq Crystal against Prescaled.
Clock routing
X'tal --+---->Prescaler-------> System Clock
|
+---------------------> USB PLL
Design Decision: Install 16MHz crystal on board with using clock rescaler.

@ -1,39 +0,0 @@
V-USB controller for HHKB
=========================
Not supported actively any more.
## Build
Use `Makefile.vusb` for [V-USB] controller.
$ make -f Makefile.vusb
##Hardware
###3. V-USB connection
+---+ +---------------+
USB GND | | ATmega328p |
~~~ C3 | |
5V <-------+--------+---|Vcc,AVCC | HHKB pro pro2
R1 | | ~~~~~~~~ ~~~~
D- <----+--+-----R2-----|INT1 PB2-4|------->ROW (6-8) (5-7)
D+ <----|---+----R3-----|INT0 PC0-2|------->COL (9-11) (8-10)
Z1 Z2 | PC3|------->ENABLE (12) (11)
GND<----+---+-----------|GND PB0|<-------KEY (4) (3)
| PB1|------->PREV (5) (4)
| |
GND+-C2--+--|XTAL1 RXD|------->Debug Console
X1 | TXD|<-------Debug Console
GND+-C3--+--|XTAL2 RST|---SW--+GND
+---------------+
R1: 1.5K Ohm
R2,R3: 68 Ohm
Z1,Z2: Zener 3.6V
C1,C2: 22pF
C3: 0.1uF
X1: Crystal 12MHz
SW: Push Switch(for bootloader)
- NOTE: See [V-USB] documentation for more detail of hardware and the USB stack.
- NOTE: [USBaspLoader] is very useful for firmware update.
[V-USB]: http://www.obdev.at/products/vusb/index.html
[USBaspLoader]: http://www.obdev.at/products/vusb/usbasploader.html

@ -1,33 +0,0 @@
/*
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 <stdint.h>
#include "action.h"
#include <avr/pgmspace.h>
#include "keymap_common.h"
/* translates key to keycode */
uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
{
return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
}
/* translates Fn keycode to action */
action_t keymap_fn_to_action(uint8_t keycode)
{
return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) };
}

@ -1,84 +0,0 @@
/*
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_COMMON_H
#define KEYMAP_COMMON_H
#include <stdint.h>
#include <stdbool.h>
#include "keycode.h"
#include "action.h"
#include "action_code.h"
#include "action_layer.h"
#include "action_macro.h"
#include "action_util.h"
#include "report.h"
#include "host.h"
#include "print.h"
#include "debug.h"
#include "keymap.h"
extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
extern const uint16_t fn_actions[];
#define KEYMAP( \
K31, K30, K00, K10, K11, K20, K21, K40, K41, K60, K61, K70, K71, K50, K51, \
K32, K01, K02, K13, K12, K23, K22, K42, K43, K62, K63, K73, K72, K52, \
K33, K04, K03, K14, K15, K24, K25, K45, K44, K65, K64, K74, K53, \
K34, K05, K06, K07, K16, K17, K26, K46, K66, K76, K75, K55, K54, \
K35, K36, K37, K57, K56 \
) \
{ \
{ KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \
{ KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_NO }, \
{ KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \
{ KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_NO }, \
{ KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \
{ KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_NO }, \
{ KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_NO } \
}
#define KEYMAP_JP( \
K02, K32, K62, K22, K12, K52, K72, KA2, K92, K82, KB2, KE2, KF2, KD2, KC2, \
K03, K63, K23, K13, K53, K73, KA3, K93, K83, KB3, KE3, KF3, KD3, \
K06, K66, K26, K16, K56, K76, KA6, K96, K86, KB6, KE6, KF6, KD6, KC6, \
K05, K65, K25, K15, K55, K75, KA5, K95, K85, KB5, KE5, KF5, KD5, KC5, \
K04, K34, K64, K24, K14, K74, K94, K84, KB4, KE4, KF4, KD4, KC4 \
) \
{ \
{ KC_NO, KC_NO, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_NO }, \
{ KC_NO, KC_NO, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_NO }, \
{ KC_NO, KC_NO, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_NO }, \
{ KC_NO, KC_NO, KC_##K32, KC_NO, KC_##K34, 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_##K52, KC_##K53, KC_NO, KC_##K55, KC_##K56, KC_NO }, \
{ KC_NO, KC_NO, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_NO }, \
{ KC_NO, KC_NO, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_NO }, \
{ KC_NO, KC_NO, KC_##K82, KC_##K83, KC_##K84, KC_##K85, KC_##K86, KC_NO }, \
{ KC_NO, KC_NO, KC_##K92, KC_##K93, KC_##K94, KC_##K95, KC_##K96, KC_NO }, \
{ KC_NO, KC_NO, KC_##KA2, KC_##KA3, KC_NO, KC_##KA5, KC_##KA6, KC_NO }, \
{ KC_NO, KC_NO, KC_##KB2, KC_##KB3, KC_##KB4, KC_##KB5, KC_##KB6, KC_NO }, \
{ KC_NO, KC_NO, KC_##KC2, KC_NO, KC_##KC4, KC_##KC5, KC_##KC6, KC_NO }, \
{ KC_NO, KC_NO, KC_##KD2, KC_##KD3, KC_##KD4, KC_##KD5, KC_##KD6, KC_NO }, \
{ KC_NO, KC_NO, KC_##KE2, KC_##KE3, KC_##KE4, KC_##KE5, KC_##KE6, KC_NO }, \
{ KC_NO, KC_NO, KC_##KF2, KC_##KF3, KC_##KF4, KC_##KF5, KC_##KF6, KC_NO } \
}
#endif

@ -1,282 +0,0 @@
/*
* Hasu: my personal keymap
*/
#include "keymap_common.h"
#ifdef KEYMAP_SECTION_ENABLE
const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
#else
const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
#endif
/* Layer 0: Default Layer
* ,-----------------------------------------------------------.
* |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `|
* |-----------------------------------------------------------|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Backs|
* |-----------------------------------------------------------|
* |Contro| A| S| D| F| G| H| J| K| L|Fn3| '|Fn6 |
* |-----------------------------------------------------------|
* |Fn7 | Z| X| C| V| B| N| M| ,| .|Fn2|Shift |Fn1|
* `-----------------------------------------------------------'
* |Gui|Alt | Fn4 |Fn5 |Gui|
* `-------------------------------------------'
*/
[0] = \
KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, \
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \
LCTL,A, S, D, F, G, H, J, K, L, FN3, QUOT,FN6, \
FN7, Z, X, C, V, B, N, M, COMM,DOT, FN2, RSFT,FN1, \
LGUI,LALT, FN4, FN5, RGUI),
/* Layer 1: HHKB mode[HHKB Fn]
* ,-----------------------------------------------------------.
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
* |-----------------------------------------------------------|
* |Caps | | | | | | | |Psc|Slk|Pus|Up | |Backs|
* |-----------------------------------------------------------|
* |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter |
* |-----------------------------------------------------------|
* |Shift | | | | | | +| -|End|PgD|Dow|Shift | |
* `-----------------------------------------------------------'
* |Gui|Alt | Space |Alt |Gui|
* `-------------------------------------------'
*/
[1] = \
KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS, UP, NO, BSPC, \
LCTL,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT,ENT, \
LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN,RSFT,TRNS, \
LGUI,LALT, TRNS, RALT,RGUI),
/* Layer 2: Vi mode[Slash]
* ,-----------------------------------------------------------.
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
* |-----------------------------------------------------------|
* |Tab |Hom|PgD|Up |PgU|End|Hom|PgD|PgUlEnd| | | |Backs|
* |-----------------------------------------------------------|
* |Contro| |Lef|Dow|Rig| |Lef|Dow|Up |Rig| | |Return |
* |-----------------------------------------------------------|
* |Shift | | | | | |Hom|PgD|PgUlEnd|Fn0|Shift | |
* `-----------------------------------------------------------'
* |Gui|Alt | Space |Alt |Gui|
* `-------------------------------------------'
*/
[2] = \
KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
TAB, HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, BSPC, \
LCTL,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT, \
LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN2, RSFT,TRNS, \
LGUI,LALT, SPC, RALT,RGUI),
/* Layer 3: Mouse mode(IJKL)[Semicolon]
* ,-----------------------------------------------------------.
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
* |-----------------------------------------------------------|
* |Tab | | | | | |MwL|MwD|McU|MwU|MwR|Wbk|Wfr|Alt-T|
* |-----------------------------------------------------------|
* |Contro| | | | | |Mb2|McL|McD|McR|Fn | |Return |
* |-----------------------------------------------------------|
* |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | |
* `-----------------------------------------------------------'
* |Gui |Alt | Mb1 |Fn |Fn |
* `--------------------------------------------'
* Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
*/
[3] = \
KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
FN8, NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,FN9, FN10,FN8, \
LCTL,ACL0,ACL1,ACL2,ACL2,NO, NO, MS_L,MS_D,MS_R,FN3, NO, ENT, \
LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT,TRNS, \
LGUI,LALT, BTN1, TRNS,TRNS),
/* Layer 4: Mouse mode(IJKL)[Space]
* ,-----------------------------------------------------------.
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
* |-----------------------------------------------------------|
* |Tab | | | | | |MwL|MwD|McU|MwU|MwR|Wbk|Wfr|Alt-T|
* |-----------------------------------------------------------|
* |Contro| | | | | |Mb2|McL|McD|McR|Mb1| |Return |
* |-----------------------------------------------------------|
* |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | |
* `-----------------------------------------------------------'
* |Gui |Alt | Mb1 |Fn |Fn |
* `--------------------------------------------'
* Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
*/
[4] = \
KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
FN8, NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,BTN4,BTN5,FN8, \
LCTL,VOLD,VOLU,MUTE,NO, NO, NO, MS_L,MS_D,MS_R,BTN1,NO, ENT, \
LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT,TRNS, \
LGUI,LALT, TRNS, TRNS,TRNS),
#if 0
/* Layer 3: Mouse mode(HJKL)[Semicolon]
* ,-----------------------------------------------------------.
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
* |-----------------------------------------------------------|
* |Tab | | | | | |MwL|MwD|MwU|MwR| | | |Backs|
* |-----------------------------------------------------------|
* |Contro| | | | | |McL|McD|McU|McR|Fn0| |Return |
* |-----------------------------------------------------------|
* |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | |
* `-----------------------------------------------------------'
* |Gui |Alt | Mb1 |Alt |Fn0|
* `--------------------------------------------'
* Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
*/
KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
TAB, NO, NO, NO, NO, NO, NO, WH_D,WH_U,RGHT,NO, NO, NO, BSPC, \
LCTL,NO, ACL0,ACL1,ACL2,NO, MS_L,MS_D,MS_U,MS_R,TRNS,QUOT,ENT, \
LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,SLSH,RSFT,NO, \
LGUI,LALT, BTN1, RALT,TRNS),
/* Layer4: Mouse mode(HJKL)[Space]
* ,-----------------------------------------------------------.
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
* |-----------------------------------------------------------|
* |Tab | | | | | |MwL|MwD|MwU|MwR| |Wbk|Wfr|Alt-T|
* |-----------------------------------------------------------|
* |Contro| | | | | |McL|McD|McU|McR|Fn0| |Return |
* |-----------------------------------------------------------|
* |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | |
* `-----------------------------------------------------------'
* |Gui |Alt | Fn0 |Alt |Fn0|
* `--------------------------------------------'
* Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
*/
KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
FN8, NO, NO, NO, NO, NO, NO, WH_D,WH_U,RGHT,NO, FN9, FN10,FN8, \
LCTL,NO, ACL0,ACL1,ACL2,NO, MS_L,MS_D,MS_U,MS_R,BTN1,NO, ENT, \
LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT,NO, \
LGUI,LALT, TRNS, RALT,RGUI),
#endif
#if 0
/* Layer x: Matias half-qwerty keyboard style[Space]
* ,-----------------------------------------------------------.
* | -| 0| 9| 8| 7| 6| 5| 4| 3| 2| 1| | | |Esc|
* |-----------------------------------------------------------|
* |Backs| P| O| I| U| Y| T| R| E| W| Q| | |Tab |
* |-----------------------------------------------------------|
* |Contro| ;| L| K| J| H| G| F| D| S| A|Con|Control |
* |-----------------------------------------------------------|
* |Shift | /| .| ,| M| N| B| V| C| X| Z|Shift | |
* `-----------------------------------------------------------'
* |Gui |Alt | Fn0 |Alt |Gui|
* `--------------------------------------------'
*/
KEYMAP(MINS,0, 9, 8, 7, 6, 5, 4, 3, 2, 1, NO, NO, NO, ESC, \
BSPC,P, O, I, U, Y, T, R, E, W, Q, NO, NO, TAB, \
LCTL,SCLN,L, K, J, H, G, F, D, S, A, RCTL,RCTL, \
LSFT,SLSH,DOT, COMM,M, N, B, V, C, X, Z, RSFT,NO, \
LGUI,LALT, TRNS, RALT,RGUI),
#endif
};
/* id for user defined functions */
enum function_id {
LSHIFT_LPAREN,
};
enum macro_id {
HELLO,
VOLUP,
ALT_TAB,
};
/*
* Fn action definition
*/
#ifdef KEYMAP_SECTION_ENABLE
const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = {
#else
const uint16_t fn_actions[] PROGMEM = {
#endif
[0] = ACTION_DEFAULT_LAYER_SET(0), // Default layer(not used)
[1] = ACTION_LAYER_TAP_TOGGLE(1), // HHKB layer(toggle with 5 taps)
[2] = ACTION_LAYER_TAP_KEY(2, KC_SLASH), // Cursor layer with Slash*
[3] = ACTION_LAYER_TAP_KEY(3, KC_SCLN), // Mousekey layer with Semicolon*
[4] = ACTION_LAYER_TAP_KEY(4, KC_SPC), // Mousekey layer with Space
[5] = ACTION_LAYER_MOMENTARY(4), // Mousekey layer(IJKL)
[6] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENT), // RControl with tap Enter
[7] = ACTION_MODS_ONESHOT(MOD_LSFT), // Oneshot Shift
[8] = ACTION_MACRO(ALT_TAB), // Application switching
[9] = ACTION_MODS_KEY(MOD_LALT, KC_LEFT),
[10] = ACTION_MODS_KEY(MOD_LALT, KC_RIGHT),
// [x] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_BSPC), // LControl with tap Backspace
// [x] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_ESC), // LControl with tap Esc
// [x] = ACTION_FUNCTION_TAP(LSHIFT_LPAREN), // Function: LShift with tap '('
// [x] = ACTION_MACRO(HELLO), // Macro: say hello
// [x] = ACTION_MACRO(VOLUP), // Macro: media key
};
/*
* Macro definition
*/
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
switch (id) {
case HELLO:
return (record->event.pressed ?
MACRO( I(0), T(H), T(E), T(L), T(L), W(255), T(O), END ) :
MACRO_NONE );
case VOLUP:
return (record->event.pressed ?
MACRO( D(VOLU), U(VOLU), END ) :
MACRO_NONE );
case ALT_TAB:
return (record->event.pressed ?
MACRO( D(LALT), D(TAB), END ) :
MACRO( U(TAB), END ));
}
return MACRO_NONE;
}
/*
* user defined action function
*/
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
{
if (record->event.pressed) dprint("P"); else dprint("R");
dprintf("%d", record->tap.count);
if (record->tap.interrupted) dprint("i");
dprint("\n");
switch (id) {
case LSHIFT_LPAREN:
// Shift parentheses example: LShft + tap '('
// http://stevelosh.com/blog/2012/10/a-modern-space-cadet/#shift-parentheses
// http://geekhack.org/index.php?topic=41989.msg1304899#msg1304899
if (record->event.pressed) {
if (record->tap.count > 0 && !record->tap.interrupted) {
if (record->tap.interrupted) {
dprint("tap interrupted\n");
register_mods(MOD_BIT(KC_LSHIFT));
}
} else {
register_mods(MOD_BIT(KC_LSHIFT));
}
} else {
if (record->tap.count > 0 && !(record->tap.interrupted)) {
add_weak_mods(MOD_BIT(KC_LSHIFT));
send_keyboard_report();
register_code(KC_9);
unregister_code(KC_9);
del_weak_mods(MOD_BIT(KC_LSHIFT));
send_keyboard_report();
record->tap.count = 0; // ad hoc: cancel tap
} else {
unregister_mods(MOD_BIT(KC_LSHIFT));
}
}
break;
}
}

@ -1,95 +0,0 @@
/*
* HHKB Layout
*/
#include "keymap_common.h"
#ifdef KEYMAP_SECTION_ENABLE
const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
#else
const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
#endif
/* Layer 0: Default Layer
* ,-----------------------------------------------------------.
* |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `|
* |-----------------------------------------------------------|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Backs|
* |-----------------------------------------------------------|
* |Contro| A| S| D| F| G| H| J| K| L| ;| '|Enter |
* |-----------------------------------------------------------|
* |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |Fn0|
* `-----------------------------------------------------------'
* |Alt|Gui | Space |Gui |Alt|
* `-------------------------------------------'
*/
KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, \
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \
LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,ENT, \
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT,FN0, \
LALT,LGUI, SPC, RGUI,RALT),
/* Layer 1: HHKB mode (HHKB Fn)
* ,-----------------------------------------------------------.
* |Pwr| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
* |-----------------------------------------------------------|
* |Caps | | | | | | | |Psc|Slk|Pus|Up | |Backs|
* |-----------------------------------------------------------|
* | |VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter |
* |-----------------------------------------------------------|
* | | | | | | | +| -|End|PgD|Dow| | |
* `-----------------------------------------------------------'
* | | | | | |
* `-------------------------------------------'
*/
KEYMAP(PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS, UP, TRNS, BSPC, \
TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,PENT, \
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN,TRNS,TRNS, \
TRNS,TRNS, TRNS, TRNS,TRNS),
};
/*
* Fn action definition
*/
#ifdef KEYMAP_SECTION_ENABLE
const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = {
[0] = ACTION_LAYER_MOMENTARY(1),
[1] = ACTION_LAYER_MOMENTARY(2),
[2] = ACTION_LAYER_MOMENTARY(3),
[3] = ACTION_LAYER_MOMENTARY(4),
[4] = ACTION_LAYER_MOMENTARY(5),
[5] = ACTION_LAYER_MOMENTARY(6),
[6] = ACTION_LAYER_MOMENTARY(7),
[7] = ACTION_LAYER_TOGGLE(1),
[8] = ACTION_LAYER_TOGGLE(2),
[9] = ACTION_LAYER_TOGGLE(3),
[10] = ACTION_LAYER_TAP_TOGGLE(1),
[11] = ACTION_LAYER_TAP_TOGGLE(2),
[12] = ACTION_LAYER_TAP_TOGGLE(3),
[13] = ACTION_LAYER_TAP_KEY(1, KC_A),
[14] = ACTION_LAYER_TAP_KEY(2, KC_F),
[15] = ACTION_LAYER_TAP_KEY(3, KC_J),
[16] = ACTION_LAYER_TAP_KEY(4, KC_SPACE),
[17] = ACTION_LAYER_TAP_KEY(5, KC_SCOLON),
[18] = ACTION_LAYER_TAP_KEY(6, KC_QUOTE),
[19] = ACTION_LAYER_TAP_KEY(7, KC_SLASH),
[20] = ACTION_MODS_TAP_KEY(MOD_LSFT, KC_SPACE),
[21] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_SPACE),
[22] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_QUOTE),
[23] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENTER),
[24] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_ESC),
[25] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_BSPACE),
[26] = ACTION_MODS_ONESHOT(MOD_LCTL),
[27] = ACTION_MODS_TAP_KEY(MOD_LSFT, KC_ESC),
[28] = ACTION_MODS_TAP_KEY(MOD_LSFT, KC_BSPACE),
[29] = ACTION_MODS_ONESHOT(MOD_LSFT),
[30] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_ESC),
[31] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_BSPACE),
};
#else
const uint16_t fn_actions[] PROGMEM = {
[0] = ACTION_LAYER_MOMENTARY(1),
};
#endif

@ -1,50 +0,0 @@
/*
* HHKB JP Layout
*/
#include "keymap_common.h"
#ifdef KEYMAP_SECTION_ENABLE
const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
#else
const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
#endif
/* Layer 0: Default Layer */
KEYMAP_JP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,BSPC, \
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, \
LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,BSLS,ENT, \
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RO, UP, RSFT, \
FN0, ZKHK,LGUI,LALT,MHEN, SPC, HENK,KANA,RALT,FN0, LEFT,DOWN,RGHT),
/* Layer 1: HHKB mode (HHKB Fn)
* ,-----------------------------------------------------------.
* |Pwr| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
* |-----------------------------------------------------------|
* |Caps | | | | | | | |Psc|Slk|Pus|Up | | |
* |------------------------------------------------------` |
* | |VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig| | |
* |-----------------------------------------------------------|
* | | | | | | | +| -|End|PgD|Dow| | | |
* |-----------------------------------------------------------|
* | || | | | | | | | | || | | |
* `-----------------------------------------------------------'
*/
KEYMAP_JP(PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS, UP, TRNS, \
TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,TRNS,PENT, \
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN,TRNS,TRNS,TRNS, \
TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS),
};
/*
* Fn action definition
*/
#ifdef KEYMAP_SECTION_ENABLE
const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = {
#else
const uint16_t fn_actions[] PROGMEM = {
#endif
[0] = ACTION_LAYER_MOMENTARY(1),
};

@ -1,116 +0,0 @@
/*
* SpaceFN
* http://geekhack.org/index.php?topic=51069.0
*/
#include "keymap_common.h"
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Layer 0: Default Layer
* ,-----------------------------------------------------------.
* |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| `|BSp|
* |-----------------------------------------------------------|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \|
* |-----------------------------------------------------------|
* |Contro| A| S| D| F| G| H| J| K| L| ;| '|Enter |
* |-----------------------------------------------------------|
* |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |Fn0|
* `-----------------------------------------------------------'
* |Gui|Alt | SpaceFN |Alt |Gui|
* `-------------------------------------------'
*/
KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, GRV, BSPC, \
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \
LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,ENT, \
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT,FN0, \
LGUI,LALT, FN1, RALT,RGUI),
/* Layer 1: HHKB mode (HHKB Fn)
* ,-----------------------------------------------------------.
* |Pwr| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
* |-----------------------------------------------------------|
* |Caps | | | | | | | |Psc|Slk|Pus|Up | |Backs|
* |-----------------------------------------------------------|
* | |VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter |
* |-----------------------------------------------------------|
* | | | | | | | +| -|End|PgD|Dow| | |
* `-----------------------------------------------------------'
* | | | | | |
* `-------------------------------------------'
*/
KEYMAP(PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS, UP, TRNS, BSPC, \
TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,PENT, \
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN,TRNS,TRNS, \
TRNS,TRNS, SPC, TRNS,TRNS),
/* Layer 2: SpaceFN
* ,-----------------------------------------------------------.
* |` | F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12| |Del|
* |-----------------------------------------------------------|
* | | | |Esc| | | |Hom|Up |End|Psc|Slk|Pau|Ins |
* |-----------------------------------------------------------|
* | | | | | | |PgU|Lef|Dow|Rig| | | |
* |-----------------------------------------------------------|
* | | | | | |Spc|PgD|` |~ | | | | |
* `-----------------------------------------------------------'
* | | | | | |
* `-------------------------------------------'
*/
KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, TRNS,DEL, \
TRNS,TRNS,TRNS,ESC, TRNS,TRNS,TRNS,HOME,FN3, END, PSCR,SLCK,PAUS,INS, \
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PGUP,LEFT,DOWN,RGHT,TRNS,TRNS,TRNS, \
TRNS,TRNS,TRNS,TRNS,TRNS,SPC, PGDN,GRV, FN2, TRNS,TRNS,TRNS,NO, \
TRNS,TRNS, TRNS, TRNS,TRNS),
};
/*
* user defined action function
*/
enum function_id {
CTRL_SPACE_I, // Ctrl + Up(SpaceFN) -> PgUp
};
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
{
# define MODS_CTRL_MASK (MOD_BIT(KC_LCTRL)|MOD_BIT(KC_RCTRL))
static uint8_t ctrl_space_i_prev_ctrl;
switch (id) {
// Ctrl + Up(SpaceFN) -> PgUp
case CTRL_SPACE_I:
ctrl_space_i_prev_ctrl = get_mods()&MODS_CTRL_MASK;
if (record->event.pressed) {
if (ctrl_space_i_prev_ctrl) {
del_mods(ctrl_space_i_prev_ctrl); // remove Ctrl
add_key(KC_PGUP);
send_keyboard_report(); // send PgUp without Ctrl
add_mods(ctrl_space_i_prev_ctrl); // return Ctrl but not sent
} else {
add_key(KC_UP);
send_keyboard_report();
}
} else {
if (ctrl_space_i_prev_ctrl) {
del_key(KC_PGUP);
send_keyboard_report();
} else {
del_key(KC_UP);
send_keyboard_report();
}
}
break;
}
}
/*
* Fn action definition
*/
const uint16_t PROGMEM fn_actions[] = {
[0] = ACTION_LAYER_MOMENTARY(1),
[1] = ACTION_LAYER_TAP_KEY(2, KC_SPACE),
[2] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV), // tilde
[3] = ACTION_FUNCTION(CTRL_SPACE_I), // Ctrl + Up(SpaceFN) -> PgUp
};

@ -1,33 +0,0 @@
/*
Copyright 2011 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 <avr/io.h>
#include "stdint.h"
#include "led.h"
/* HHKB has no LEDs */
void led_set(uint8_t usb_led)
{
if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
DDRD |= (1<<6);
PORTD |= (1<<6);
} else {
DDRD |= (1<<6);
PORTD &= ~(1<<6);
}
}

@ -1,103 +0,0 @@
#
# Makefile for iWRAP
#
# Target file name (without extension).
TARGET = hhkb_iwrap
# Directory common source filess exist
TMK_DIR = ../../tmk_core
# Directory keyboard dependent files exist
TARGET_DIR = .
# keyboard dependent files
SRC = \
keymap.c \
matrix.c \
led.c
CONFIG_H = config_iwrap.h
# V-USB debug level: To use ps2_usart.c level must be 0
# ps2_usart.c requires USART to receive PS/2 signal.
OPT_DEFS = -DDEBUG_LEVEL=0
# MCU name, you MUST set this to match the board you are using
# type "make clean" after changing this, so all files will be rebuilt
MCU = atmega328p
# Processor frequency.
# Normally the first thing your program should do is set the clock prescaler,
# so your program will run at the correct speed. You should also set this
# variable to same clock speed. The _delay_ms() macro uses this, and many
# examples use this variable to calculate timings. Do not add a "UL" here.
F_CPU = 12000000
# Boot Section Size in *bytes*
# Teensy halfKay 512
# Teensy++ halfKay 1024
# Atmel DFU loader 4096
# LUFA bootloader 4096
# USBaspLoader 2048
OPT_DEFS += -DBOOTLOADER_SIZE=2048
# Build Options
# comment out to disable the options.
#
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration
MOUSEKEY_ENABLE = yes # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = yes # Console for debug
COMMAND_ENABLE = yes # Commands for debug and configuration
#NKRO_ENABLE = yes # USB Nkey Rollover
#---------------- Programming Options --------------------------
AVRDUDE = avrdude
# Type: avrdude -c ? to get a full listing.
AVRDUDE_PROGRAMMER = usbasp
AVRDUDE_PORT =
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
# Uncomment the following if you want avrdude's erase cycle counter.
# Note that this counter needs to be initialized first using -Yn,
# see avrdude manual.
#AVRDUDE_ERASE_COUNTER = -y
# Uncomment the following if you do /not/ wish a verification to be
# performed after programming the device.
#AVRDUDE_NO_VERIFY = -V
# Increase verbosity level. Please use this when submitting bug
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
# to submit bug reports.
#AVRDUDE_VERBOSE = -v -v
#AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
AVRDUDE_FLAGS = -p $(MCU) -c $(AVRDUDE_PROGRAMMER)
AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
PROGRAM_CMD = $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
# Search Path
VPATH += $(TARGET_DIR)
VPATH += $(TMK_DIR)
include $(TMK_DIR)/protocol/iwrap.mk
# TODO: to be selectable: V-USB, LUFA or PJRC
#include $(TMK_DIR)/protocol/vusb.mk
include $(TMK_DIR)/common.mk
include $(TMK_DIR)/rules.mk

@ -1,97 +0,0 @@
#
# Makefile for V-USB
#
# Target file name (without extension).
TARGET = hhkb_vusb
# Directory common source filess exist
TMK_DIR = ../../tmk_core
# Directory keyboard dependent files exist
TARGET_DIR = .
# keyboard dependent files
SRC = \
keymap.c \
matrix.c \
led.c
CONFIG_H = config_vusb.h
# V-USB debug level: To use ps2_usart.c level must be 0
# ps2_usart.c requires USART to receive PS/2 signal.
OPT_DEFS = -DDEBUG_LEVEL=0
# MCU name, you MUST set this to match the board you are using
# type "make clean" after changing this, so all files will be rebuilt
MCU = atmega328p
# avrdude doesn't know atmega168p
AVRDUDE_MCU = $(MCU)
# Processor frequency.
# Normally the first thing your program should do is set the clock prescaler,
# so your program will run at the correct speed. You should also set this
# variable to same clock speed. The _delay_ms() macro uses this, and many
# examples use this variable to calculate timings. Do not add a "UL" here.
F_CPU = 12000000
# Build Options
# comment out to disable the options.
#
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration
MOUSEKEY_ENABLE = yes # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = yes # Console for debug
COMMAND_ENABLE = yes # Commands for debug and configuration
#NKRO_ENABLE = yes # USB Nkey Rollover
#---------------- Programming Options --------------------------
AVRDUDE = avrdude
# Type: avrdude -c ? to get a full listing.
AVRDUDE_PROGRAMMER = usbasp
AVRDUDE_PORT =
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
# Uncomment the following if you want avrdude's erase cycle counter.
# Note that this counter needs to be initialized first using -Yn,
# see avrdude manual.
#AVRDUDE_ERASE_COUNTER = -y
# Uncomment the following if you do /not/ wish a verification to be
# performed after programming the device.
#AVRDUDE_NO_VERIFY = -V
# Increase verbosity level. Please use this when submitting bug
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
# to submit bug reports.
#AVRDUDE_VERBOSE = -v -v
#AVRDUDE_FLAGS = -p $(AVRDUDE_MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
AVRDUDE_FLAGS = -p $(AVRDUDE_MCU) -c $(AVRDUDE_PROGRAMMER)
AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
PROGRAM_CMD = $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
# Search Path
VPATH += $(TARGET_DIR)
VPATH += $(TMK_DIR)
include $(TMK_DIR)/protocol/vusb.mk
include $(TMK_DIR)/common.mk
include $(TMK_DIR)/rules.mk
debug-on: EXTRAFLAGS += -DDEBUG
debug-on: all

@ -1,54 +0,0 @@
/*
Copyright 2011 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 CONFIG_H
#define CONFIG_H
#define VENDOR_ID 0xFEED
#define PRODUCT_ID 0xBEEA
// TODO: share these strings with usbconfig.h
// Edit usbconfig.h to change these.
#define MANUFACTURER t.m.k.
#define PRODUCT HHKB mod
#define DESCRIPTION t.m.k. keyboard firmware for HHKB mod
/* matrix size */
#define MATRIX_ROWS 8
#define MATRIX_COLS 8
/* key combination for command */
#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)))
/* pins for Software UART */
#define SUART_IN_PIN PINC
#define SUART_IN_BIT 5
#define SUART_OUT_PORT PORTC
#define SUART_OUT_BIT 4
#define DEBUG_LED 1
#define DEBUG_LED_CONFIG (DDRD |= (1<<4))
#define DEBUG_LED_OFF (PORTD |= (1<<4))
#define DEBUG_LED_ON (PORTD &= ~(1<<4))
/* period of tapping(ms) */
#define TAPPING_TERM 300
/* tap count needed for toggling a feature */
#define TAPPING_TOGGLE 5
#endif

@ -1,38 +0,0 @@
/*
Copyright 2011 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 CONFIG_H
#define CONFIG_H
#define VENDOR_ID 0xFEED
#define PRODUCT_ID 0xC0FE
// TODO: share these strings with usbconfig.h
// Edit usbconfig.h to change these.
#define MANUFACTURER t.m.k.
#define PRODUCT HHKB mod
#define DESCRIPTION t.m.k. keyboard firmware for HHKB mod
/* matrix size */
#define MATRIX_ROWS 8
#define MATRIX_COLS 8
/* key combination for command */
#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)))
#endif

@ -1,32 +0,0 @@
iWRAP
-----
+---------------+ WT12
5V | ATmega168 | 5V/3.3V~~~~
+-----+---|Vcc,AVCC PC4|---/--->iWRAP(RxD)
USB | C3 | PC5|<--/----iWRAP(TxD)
~~~ | + | |
5V <--BATT + GND | | HHKB
R1 | | ~~~~
D- <----+-----+--R2-----|INT1 PB2-4|------->ROW(6-8)
D+ <----|---+----R3-----|INT0 PC0-2|------->COL(9-11)
Z1 Z2 | PC3|------->ENABLE(12)
GND<----+---+-----------|GND PB0|<-------KEY(4)
| PB1|------->PREV(5)
| |
GND+-C2--+--|XTAL1 RXD|------->Debug Console
X1 | TXD|<-------Debug Console
GND+-C3--+--|XTAL2 RST|---SW--+GND
+---------------+
R1: 1.5K Ohm
R2,R3: 68 Ohm
Z1,Z2: Zener 3.6V
C1,C2: 22pF
C3: 0.1uF
X1: Crystal 12MHz
SW: Push Switch(Optional)
BATT: Li-Po Battery, Battery Charger and Voltage Regulator(5V and 3.3V).

@ -1,388 +0,0 @@
/* Name: usbconfig.h
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
* Author: Christian Starkjohann
* Creation Date: 2005-04-01
* Tabsize: 4
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
* This Revision: $Id: usbconfig-prototype.h 785 2010-05-30 17:57:07Z cs $
*/
#ifndef __usbconfig_h_included__
#define __usbconfig_h_included__
#include "config_vusb.h"
/*
General Description:
This file is an example configuration (with inline documentation) for the USB
driver. It configures V-USB for USB D+ connected to Port D bit 2 (which is
also hardware interrupt 0 on many devices) and USB D- to Port D bit 4. You may
wire the lines to any other port, as long as D+ is also wired to INT0 (or any
other hardware interrupt, as long as it is the highest level interrupt, see
section at the end of this file).
*/
/* ---------------------------- Hardware Config ---------------------------- */
#define USB_CFG_IOPORTNAME D
/* This is the port where the USB bus is connected. When you configure it to
* "B", the registers PORTB, PINB and DDRB will be used.
*/
#define USB_CFG_DMINUS_BIT 3
/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected.
* This may be any bit in the port.
*/
#define USB_CFG_DPLUS_BIT 2
/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected.
* This may be any bit in the port. Please note that D+ must also be connected
* to interrupt pin INT0! [You can also use other interrupts, see section
* "Optional MCU Description" below, or you can connect D- to the interrupt, as
* it is required if you use the USB_COUNT_SOF feature. If you use D- for the
* interrupt, the USB interrupt will also be triggered at Start-Of-Frame
* markers every millisecond.]
*/
#define USB_CFG_CLOCK_KHZ (F_CPU/1000)
/* Clock rate of the AVR in kHz. Legal values are 12000, 12800, 15000, 16000,
* 16500, 18000 and 20000. The 12.8 MHz and 16.5 MHz versions of the code
* require no crystal, they tolerate +/- 1% deviation from the nominal
* frequency. All other rates require a precision of 2000 ppm and thus a
* crystal!
* Since F_CPU should be defined to your actual clock rate anyway, you should
* not need to modify this setting.
*/
#define USB_CFG_CHECK_CRC 0
/* Define this to 1 if you want that the driver checks integrity of incoming
* data packets (CRC checks). CRC checks cost quite a bit of code size and are
* currently only available for 18 MHz crystal clock. You must choose
* USB_CFG_CLOCK_KHZ = 18000 if you enable this option.
*/
/* ----------------------- Optional Hardware Config ------------------------ */
/* #define USB_CFG_PULLUP_IOPORTNAME D */
/* If you connect the 1.5k pullup resistor from D- to a port pin instead of
* V+, you can connect and disconnect the device from firmware by calling
* the macros usbDeviceConnect() and usbDeviceDisconnect() (see usbdrv.h).
* This constant defines the port on which the pullup resistor is connected.
*/
/* #define USB_CFG_PULLUP_BIT 4 */
/* This constant defines the bit number in USB_CFG_PULLUP_IOPORT (defined
* above) where the 1.5k pullup resistor is connected. See description
* above for details.
*/
/* --------------------------- Functional Range ---------------------------- */
#define USB_CFG_HAVE_INTRIN_ENDPOINT 1
/* Define this to 1 if you want to compile a version with two endpoints: The
* default control endpoint 0 and an interrupt-in endpoint (any other endpoint
* number).
*/
#define USB_CFG_HAVE_INTRIN_ENDPOINT3 1
/* Define this to 1 if you want to compile a version with three endpoints: The
* default control endpoint 0, an interrupt-in endpoint 3 (or the number
* configured below) and a catch-all default interrupt-in endpoint as above.
* You must also define USB_CFG_HAVE_INTRIN_ENDPOINT to 1 for this feature.
*/
#define USB_CFG_EP3_NUMBER 3
/* If the so-called endpoint 3 is used, it can now be configured to any other
* endpoint number (except 0) with this macro. Default if undefined is 3.
*/
/* #define USB_INITIAL_DATATOKEN USBPID_DATA1 */
/* The above macro defines the startup condition for data toggling on the
* interrupt/bulk endpoints 1 and 3. Defaults to USBPID_DATA1.
* Since the token is toggled BEFORE sending any data, the first packet is
* sent with the oposite value of this configuration!
*/
#define USB_CFG_IMPLEMENT_HALT 0
/* Define this to 1 if you also want to implement the ENDPOINT_HALT feature
* for endpoint 1 (interrupt endpoint). Although you may not need this feature,
* it is required by the standard. We have made it a config option because it
* bloats the code considerably.
*/
#define USB_CFG_SUPPRESS_INTR_CODE 0
/* Define this to 1 if you want to declare interrupt-in endpoints, but don't
* want to send any data over them. If this macro is defined to 1, functions
* usbSetInterrupt() and usbSetInterrupt3() are omitted. This is useful if
* you need the interrupt-in endpoints in order to comply to an interface
* (e.g. HID), but never want to send any data. This option saves a couple
* of bytes in flash memory and the transmit buffers in RAM.
*/
#define USB_CFG_INTR_POLL_INTERVAL 10
/* If you compile a version with endpoint 1 (interrupt-in), this is the poll
* interval. The value is in milliseconds and must not be less than 10 ms for
* low speed devices.
*/
#define USB_CFG_IS_SELF_POWERED 0
/* Define this to 1 if the device has its own power supply. Set it to 0 if the
* device is powered from the USB bus.
*/
#define USB_CFG_MAX_BUS_POWER 100
/* Set this variable to the maximum USB bus power consumption of your device.
* The value is in milliamperes. [It will be divided by two since USB
* communicates power requirements in units of 2 mA.]
*/
#define USB_CFG_IMPLEMENT_FN_WRITE 1
/* Set this to 1 if you want usbFunctionWrite() to be called for control-out
* transfers. Set it to 0 if you don't need it and want to save a couple of
* bytes.
*/
#define USB_CFG_IMPLEMENT_FN_READ 0
/* Set this to 1 if you need to send control replies which are generated
* "on the fly" when usbFunctionRead() is called. If you only want to send
* data from a static buffer, set it to 0 and return the data from
* usbFunctionSetup(). This saves a couple of bytes.
*/
#define USB_CFG_IMPLEMENT_FN_WRITEOUT 0
/* Define this to 1 if you want to use interrupt-out (or bulk out) endpoints.
* You must implement the function usbFunctionWriteOut() which receives all
* interrupt/bulk data sent to any endpoint other than 0. The endpoint number
* can be found in 'usbRxToken'.
*/
#define USB_CFG_HAVE_FLOWCONTROL 0
/* Define this to 1 if you want flowcontrol over USB data. See the definition
* of the macros usbDisableAllRequests() and usbEnableAllRequests() in
* usbdrv.h.
*/
#define USB_CFG_DRIVER_FLASH_PAGE 0
/* If the device has more than 64 kBytes of flash, define this to the 64 k page
* where the driver's constants (descriptors) are located. Or in other words:
* Define this to 1 for boot loaders on the ATMega128.
*/
#define USB_CFG_LONG_TRANSFERS 0
/* Define this to 1 if you want to send/receive blocks of more than 254 bytes
* in a single control-in or control-out transfer. Note that the capability
* for long transfers increases the driver size.
*/
/* #define USB_RX_USER_HOOK(data, len) if(usbRxToken == (uchar)USBPID_SETUP) blinkLED(); */
/* This macro is a hook if you want to do unconventional things. If it is
* defined, it's inserted at the beginning of received message processing.
* If you eat the received message and don't want default processing to
* proceed, do a return after doing your things. One possible application
* (besides debugging) is to flash a status LED on each packet.
*/
/* #define USB_RESET_HOOK(resetStarts) if(!resetStarts){hadUsbReset();} */
/* This macro is a hook if you need to know when an USB RESET occurs. It has
* one parameter which distinguishes between the start of RESET state and its
* end.
*/
/* #define USB_SET_ADDRESS_HOOK() hadAddressAssigned(); */
/* This macro (if defined) is executed when a USB SET_ADDRESS request was
* received.
*/
#define USB_COUNT_SOF 1
/* define this macro to 1 if you need the global variable "usbSofCount" which
* counts SOF packets. This feature requires that the hardware interrupt is
* connected to D- instead of D+.
*/
/* #ifdef __ASSEMBLER__
* macro myAssemblerMacro
* in YL, TCNT0
* sts timer0Snapshot, YL
* endm
* #endif
* #define USB_SOF_HOOK myAssemblerMacro
* This macro (if defined) is executed in the assembler module when a
* Start Of Frame condition is detected. It is recommended to define it to
* the name of an assembler macro which is defined here as well so that more
* than one assembler instruction can be used. The macro may use the register
* YL and modify SREG. If it lasts longer than a couple of cycles, USB messages
* immediately after an SOF pulse may be lost and must be retried by the host.
* What can you do with this hook? Since the SOF signal occurs exactly every
* 1 ms (unless the host is in sleep mode), you can use it to tune OSCCAL in
* designs running on the internal RC oscillator.
* Please note that Start Of Frame detection works only if D- is wired to the
* interrupt, not D+. THIS IS DIFFERENT THAN MOST EXAMPLES!
*/
#define USB_CFG_CHECK_DATA_TOGGLING 0
/* define this macro to 1 if you want to filter out duplicate data packets
* sent by the host. Duplicates occur only as a consequence of communication
* errors, when the host does not receive an ACK. Please note that you need to
* implement the filtering yourself in usbFunctionWriteOut() and
* usbFunctionWrite(). Use the global usbCurrentDataToken and a static variable
* for each control- and out-endpoint to check for duplicate packets.
*/
#define USB_CFG_HAVE_MEASURE_FRAME_LENGTH 0
/* define this macro to 1 if you want the function usbMeasureFrameLength()
* compiled in. This function can be used to calibrate the AVR's RC oscillator.
*/
#define USB_USE_FAST_CRC 0
/* The assembler module has two implementations for the CRC algorithm. One is
* faster, the other is smaller. This CRC routine is only used for transmitted
* messages where timing is not critical. The faster routine needs 31 cycles
* per byte while the smaller one needs 61 to 69 cycles. The faster routine
* may be worth the 32 bytes bigger code size if you transmit lots of data and
* run the AVR close to its limit.
*/
/* -------------------------- Device Description --------------------------- */
#define USB_CFG_VENDOR_ID (VENDOR_ID & 0xFF), ((VENDOR_ID >> 8) & 0xFF)
/* USB vendor ID for the device, low byte first. If you have registered your
* own Vendor ID, define it here. Otherwise you may use one of obdev's free
* shared VID/PID pairs. Be sure to read USB-IDs-for-free.txt for rules!
* *** IMPORTANT NOTE ***
* This template uses obdev's shared VID/PID pair for Vendor Class devices
* with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand
* the implications!
*/
#define USB_CFG_DEVICE_ID (PRODUCT_ID & 0xFF), ((PRODUCT_ID >> 8) & 0xFF)
/* This is the ID of the product, low byte first. It is interpreted in the
* scope of the vendor ID. If you have registered your own VID with usb.org
* or if you have licensed a PID from somebody else, define it here. Otherwise
* you may use one of obdev's free shared VID/PID pairs. See the file
* USB-IDs-for-free.txt for details!
* *** IMPORTANT NOTE ***
* This template uses obdev's shared VID/PID pair for Vendor Class devices
* with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand
* the implications!
*/
#define USB_CFG_DEVICE_VERSION 0x00, 0x01
/* Version number of the device: Minor number first, then major number.
*/
#define USB_CFG_VENDOR_NAME 't', '.', 'm', '.', 'k', '.'
#define USB_CFG_VENDOR_NAME_LEN 6
/* These two values define the vendor name returned by the USB device. The name
* must be given as a list of characters under single quotes. The characters
* are interpreted as Unicode (UTF-16) entities.
* If you don't want a vendor name string, undefine these macros.
* ALWAYS define a vendor name containing your Internet domain name if you use
* obdev's free shared VID/PID pair. See the file USB-IDs-for-free.txt for
* details.
*/
#define USB_CFG_DEVICE_NAME 'H', 'H', 'K', 'B', ' ', 'm', 'o', 'd'
#define USB_CFG_DEVICE_NAME_LEN 8
/* Same as above for the device name. If you don't want a device name, undefine
* the macros. See the file USB-IDs-for-free.txt before you assign a name if
* you use a shared VID/PID.
*/
/*#define USB_CFG_SERIAL_NUMBER 'N', 'o', 'n', 'e' */
/*#define USB_CFG_SERIAL_NUMBER_LEN 0 */
/* Same as above for the serial number. If you don't want a serial number,
* undefine the macros.
* It may be useful to provide the serial number through other means than at
* compile time. See the section about descriptor properties below for how
* to fine tune control over USB descriptors such as the string descriptor
* for the serial number.
*/
#define USB_CFG_DEVICE_CLASS 0
#define USB_CFG_DEVICE_SUBCLASS 0
/* See USB specification if you want to conform to an existing device class.
* Class 0xff is "vendor specific".
*/
#define USB_CFG_INTERFACE_CLASS 3 /* HID */
#define USB_CFG_INTERFACE_SUBCLASS 1 /* Boot */
#define USB_CFG_INTERFACE_PROTOCOL 1 /* Keyboard */
/* See USB specification if you want to conform to an existing device class or
* protocol. The following classes must be set at interface level:
* HID class is 3, no subclass and protocol required (but may be useful!)
* CDC class is 2, use subclass 2 and protocol 1 for ACM
*/
#define USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH 0
/* Define this to the length of the HID report descriptor, if you implement
* an HID device. Otherwise don't define it or define it to 0.
* If you use this define, you must add a PROGMEM character array named
* "usbHidReportDescriptor" to your code which contains the report descriptor.
* Don't forget to keep the array and this define in sync!
*/
/* #define USB_PUBLIC static */
/* Use the define above if you #include usbdrv.c instead of linking against it.
* This technique saves a couple of bytes in flash memory.
*/
/* ------------------- Fine Control over USB Descriptors ------------------- */
/* If you don't want to use the driver's default USB descriptors, you can
* provide our own. These can be provided as (1) fixed length static data in
* flash memory, (2) fixed length static data in RAM or (3) dynamically at
* runtime in the function usbFunctionDescriptor(). See usbdrv.h for more
* information about this function.
* Descriptor handling is configured through the descriptor's properties. If
* no properties are defined or if they are 0, the default descriptor is used.
* Possible properties are:
* + USB_PROP_IS_DYNAMIC: The data for the descriptor should be fetched
* at runtime via usbFunctionDescriptor(). If the usbMsgPtr mechanism is
* used, the data is in FLASH by default. Add property USB_PROP_IS_RAM if
* you want RAM pointers.
* + USB_PROP_IS_RAM: The data returned by usbFunctionDescriptor() or found
* in static memory is in RAM, not in flash memory.
* + USB_PROP_LENGTH(len): If the data is in static memory (RAM or flash),
* the driver must know the descriptor's length. The descriptor itself is
* found at the address of a well known identifier (see below).
* List of static descriptor names (must be declared PROGMEM if in flash):
* char usbDescriptorDevice[];
* char usbDescriptorConfiguration[];
* char usbDescriptorHidReport[];
* char usbDescriptorString0[];
* int usbDescriptorStringVendor[];
* int usbDescriptorStringDevice[];
* int usbDescriptorStringSerialNumber[];
* Other descriptors can't be provided statically, they must be provided
* dynamically at runtime.
*
* Descriptor properties are or-ed or added together, e.g.:
* #define USB_CFG_DESCR_PROPS_DEVICE (USB_PROP_IS_RAM | USB_PROP_LENGTH(18))
*
* The following descriptors are defined:
* USB_CFG_DESCR_PROPS_DEVICE
* USB_CFG_DESCR_PROPS_CONFIGURATION
* USB_CFG_DESCR_PROPS_STRINGS
* USB_CFG_DESCR_PROPS_STRING_0
* USB_CFG_DESCR_PROPS_STRING_VENDOR
* USB_CFG_DESCR_PROPS_STRING_PRODUCT
* USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER
* USB_CFG_DESCR_PROPS_HID
* USB_CFG_DESCR_PROPS_HID_REPORT
* USB_CFG_DESCR_PROPS_UNKNOWN (for all descriptors not handled by the driver)
*
* Note about string descriptors: String descriptors are not just strings, they
* are Unicode strings prefixed with a 2 byte header. Example:
* int serialNumberDescriptor[] = {
* USB_STRING_DESCRIPTOR_HEADER(6),
* 'S', 'e', 'r', 'i', 'a', 'l'
* };
*/
#define USB_CFG_DESCR_PROPS_DEVICE 0
#define USB_CFG_DESCR_PROPS_CONFIGURATION USB_PROP_IS_DYNAMIC
//#define USB_CFG_DESCR_PROPS_CONFIGURATION 0
#define USB_CFG_DESCR_PROPS_STRINGS 0
#define USB_CFG_DESCR_PROPS_STRING_0 0
#define USB_CFG_DESCR_PROPS_STRING_VENDOR 0
#define USB_CFG_DESCR_PROPS_STRING_PRODUCT 0
#define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER 0
#define USB_CFG_DESCR_PROPS_HID USB_PROP_IS_DYNAMIC
//#define USB_CFG_DESCR_PROPS_HID 0
#define USB_CFG_DESCR_PROPS_HID_REPORT USB_PROP_IS_DYNAMIC
//#define USB_CFG_DESCR_PROPS_HID_REPORT 0
#define USB_CFG_DESCR_PROPS_UNKNOWN 0
/* ----------------------- Optional MCU Description ------------------------ */
/* The following configurations have working defaults in usbdrv.h. You
* usually don't need to set them explicitly. Only if you want to run
* the driver on a device which is not yet supported or with a compiler
* which is not fully supported (such as IAR C) or if you use a differnt
* interrupt than INT0, you may have to define some of these.
*/
/* #define USB_INTR_CFG MCUCR */
/* #define USB_INTR_CFG_SET ((1 << ISC00) | (1 << ISC01)) */
/* #define USB_INTR_CFG_CLR 0 */
/* #define USB_INTR_ENABLE GIMSK */
/* #define USB_INTR_ENABLE_BIT INT0 */
/* #define USB_INTR_PENDING GIFR */
/* #define USB_INTR_PENDING_BIT INTF0 */
/* #define USB_INTR_VECTOR INT0_vect */
/* Set INT1 for D- falling edge to count SOF */
/* #define USB_INTR_CFG EICRA */
#define USB_INTR_CFG_SET ((1 << ISC11) | (0 << ISC10))
/* #define USB_INTR_CFG_CLR 0 */
/* #define USB_INTR_ENABLE EIMSK */
#define USB_INTR_ENABLE_BIT INT1
/* #define USB_INTR_PENDING EIFR */
#define USB_INTR_PENDING_BIT INTF1
#define USB_INTR_VECTOR INT1_vect
#endif /* __usbconfig_h_included__ */

@ -1,12 +0,0 @@
RN42_DIR = rn42
SRC += serial_uart.c \
rn42/suart.S \
rn42/rn42.c \
rn42/rn42_task.c \
rn42/battery.c \
rn42/main.c
OPT_DEFS += -DPROTOCOL_RN42
VPATH += $(RN42_DIR)

@ -1,255 +0,0 @@
Memo of deveopment
==================
just memo, NOT WORTH READING
Bug:
- Factory Reset PIO4 doesn't work
- the reason is unclear - 12/08 NOT LOOK INTO ANY MORE
- WORKAROUND: use serial pins(3.3V, GND, RX and TX)
- SF,1 and R,1 to set factory defalult
Todo:
- LED cover and switch knob and new Slide Switch
- RN42 auto configuration
- configure the module as HID device every time powering up
- this'll reduce work load of assembly
- move rn42 to protocol directory when it becomes reusable stack
- sendchar() in lufa.c no buffer
- no buffering. character lost can be caused.
- LUFA sendchar should be buffered and serial_uart.c buffur size is too large(256).
- BT operations
- disconnect
- new connection
- remove connection
- sendchar() in lufa.c block loop - DONE 11/29
- block loop when powered with AC adapter
- FrameNumber is not updated when adapter powered
Improving:
- ADC resolution
AVR120
AVR32138
- Enhancing ADC resolution by oversampling
AVR121 http://www.atmel.com/images/doc8003.pdf
- disable digital input buffer DIDR(7.8.6)
Design:
- suspend.h - DONE 11/26
- remove argument from suspend_power_down() for backward compatitibility
- remove MCU dependent power saving code from core/keyboard - DONE 11/23
- it should be located in project matrix.c
- HHKB matrix.c needs matrix_prev?
- is_modified() is obsolete now. really needs?
- ADC: removing AREF capacitor C10
- seems to be better while usb powered
- still bad while battery powered
http://electronics.stackexchange.com/questions/105849/avcc-and-capacitor-using-adc
- ADC: smaller resistors for voltage dividor
- 1K + 1K: not improved. - 11/27
LUFA:
USB connection check: state of USB deivce
- USB_DeviceState:
USB_Deivce_State_t { Unattached, Powered, Default, Addressed, Configured*, Suspended* }
Unattached: unpluged
Powered: pluged with power adapter
Default: enumerate process bigin
Addressed: addressed
Configured: enumerated
Suspended: suspended
- USB_IsInitialized: state of LUFA core setup
becomes true in USB_Init() USBController_AVR8.c
becomes false in USB_Disable() USBController_AVR8.c
- USB_VBUS_GetStatus(): state of VBUS(power/connection)
- USB_Disable() detaches, disables all interrupts, controller, PLL, regulater.
- When connect to power adapter
- event happened: CW or CSW or C or DDC
- USB state: not configured
- USB evnets
- USB connect: CSWRWRW
- USB connect but fail to enumeration: CWRWRWRWS
- USB disconnect: D
- Power adapter connect: CW, CSW, C
- Power adapter disconnect: D
Power saving:
- Pro2 current consumption
- active: 138.2mA(no device on Hub)
- suspended: 30.9mA(WakeUp enabled DIPSW6)
- suspended: 0mA->46.0mA(WakeUp disabled DIPSW6)
- Pro current consumption
- active: 54.0mA
- suspended: 40.5mA(WakeUp enabled DIPSW6)
- suspended: 0.3mA(WakeUp disabled DIPSW6)
- RN42 3.3V
- disconnected(Idle): 5mA (config mode)
- connected(Active):
SW,0000: 23-26mA
SW,0010: 27-29mA worse than 0000 for unknown reason
SW,0020: 17-19mA mouse NG
SW,0030: 13-16mA laggy mouse NG
SW,0050: 10-13mA laggy mouse NG
- matrix power saving
- power saving while externally powered and not while unpluged
- confirm suspend mode lufa.c: matrix_power_*, suspend_wakeup_condition
- 8MHz clock
- When not connected in a few minutes get into deep sleep to save battery life
- CTS is needed for waking up from deep sleep? How deep sleep is activated?
- firmware controlled 3.3V DC converter to switch on/off BT module
- sleep MCU and BT module(keyboard is not used)
- deep sleep MCU and BT module(keyboard is not used for long time)
- deep sleep MCU and turn off BT module(keyboard is not used and not connected)
- Battery ADC; switching, high resistance
- switching gnd end of divider with PF4
- high resistor 100K/1M?
capacitor 10nF
http://www.eevblog.com/forum/beginners/measuring-battery-voltage-without-consuming-current/
- During USB suspend change clock source to internal RC from external Xtal(6.8)
- FRZCLK: you can freeze clock for power saving. still WAKEUPI and VBUSTI interrupts are available while freezing.(21.7.3)
- Suspend: Clear Suspend Bit, Freeze clock, disable PLL, MCU sleep(21.13)
- Voltage reference(8.1.1)
- to reduce power consumption while power down mode
- unset ADEN before sleep(24.7)
Lipo
----
850mA lasts around 9 hours(07/28)
Sparkfun Polymer Lithium Ion Battery 850mAh:
https://www.sparkfun.com/products/341
Lipo Cell spec:
https://www.sparkfun.com/datasheets/Batteries/063048%20Li-polymer.pdf
Protection spec:
http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Prototyping/BatteryProtection.pdf
min typical max
over-charge 4.255 4.280 4.305
over-charge discover? 4.030 4.080 4.130
over-discharge 2.827 2.900 2.973
over-discharge discover 3.022 3.100 3.178
ADC voltage monitor: voltage divider 10K+10K(0.5)
ADC=V*0.5/2.56*1024
V ADC
------------------
4.20 0x347(839)
3.10 0x26b(619)
TROUBLE SHOOT
-------------
07/16 After fix of voltage dividor on GPIO6, had a trouble that it could not send a char to BT module, though could receive.
Found R8 had wrong 1K resistor and changed to 10K, after that it can send to the module again. Not sure how it had sent with the wrong 1K before.
07/18 On Linux, had an USB related trouble; keyboard or console didn't work for some reason. Changing PID cured this problem. Very annoying, took very long time before resolved it.
12/07 rn42_rts() read 1 every time. R12 broke in open mode(no coductive), idk why, too much heat with soldering? and PF1 pin was not soldered.
It resolved with resoldering PF1 and new resistor on R12.
Done:
- low battery alert(solid light) 09/04
- *** Rev.E BT test *** - DONE
- with MCP73832, new Schottky, tantalum caps - DONE 12/07
* MCP73832 doesn't leak from Vcc pin when unpluged and battery powered
34mV vs 2.07V(MCP73831) at Vcc pin
MCP73832 doesn't need revese protection diode D5
* PMEG2010ER is very low VF while reverse current/voltage is high
VF=0.96 vs 1.98(RB160M-30TR)with Fluke 175
Anode of D11 is 680mV vs 20mV(RB160M-30TR)
780mV is still low < 1.4V VBUS plugin detection(21.11)
this doesn't cause false VBUS detect
and 780mV on MCP73832 Vcc pin is also no problem.
D5 can be removed.
- ADC divider switching - DONE 12/07
* Drain and Source of Q4 Pch was reversed wrongly on Rev.E.
- reverse current from Lipo charger - DONE 12/07
* MCP73832 has no recverse current from Vcc pin unlike MCP73831
- Rev.F design - DONE
- current measure point - DONE 12/08
- change value of cap 68->47 - DONE 12/08
- PPTC land pattern: no solder jumper, use 0Ohm resistor instead - CANCEL 12/08
- Q4 Pch FET: wrong Drain and Source - DONE 12/08
- D5 can be removed. - DONE 12/08
- BT_INDICATOR LED turns on wrongly when touching line or pin. -- pull-up enabled on PF6/GPIO2 08/30
- Lipo charger configuration: fast charge time: USB charger spec? -- used 2kohm
- use LED of charger to alarm low battery. LED should be powered directly from Lipo? - cancel; powered from VUSB
- Use RTS in serial_uart.c to resolve missing chars from help message of RN-42 - done
- CTS/RTS lines are needed? just connect in loop back if no flow control is needed. - done
- add IO pin to charger status CHRG; LED control(low) and detect charge status(input HiZ) 07.24
- LINKED: add trace on PIO2 to PF6 07.24
- Lipo voltage ADC sensing
- Lipo charger MCP73831: needs capacitor 4.7uF *2
- USB connection check - 07.01
- BT on/off check: whether RX line is pulled up? - checking RTS 07.01
- USB/BT switching BT is on -> BT, BT is off -> USB - 07.01
- Under voltage lock out UVLO for protection of Lipo - Lipo has discharge protection at 3.100V 07.01
- Power saving: HHKB scan, BT radio control - 9h with 850mAh, this is enough 07.01
- Power selector doesn't work; Q4 MOSFET leaks from Lipo to USB power line. -- use Schottky instead 07/04
- wrongly suspended when powered from adapter without USB connection - DONE
- suspend event may occur when plug into adapter
- and never wake until conected to real USB line
- without debug print via USB no problem; CSW(wake just after suspend as real USB line)
- seems like USB print causes this problem after suspended
- lose USB connection during power-down mode - DONE
- USB initialize code in main() causes this - WRONG
- Do not power-down during USB connection is active - DONE 11/11
(USB_DeviceState == USB_DEVICE_Configured) is used to check USB connection
matrix_power_down() matrix.c - 11/23
- with Nexus5 keyboard and mouse are very laggy.
Not confirmed. 01/15
- switch BT host connections - CANCEL 01/15
- switch next connection
cannot switch connection with version 6.15 at least
- When given power only from wall wart adapter - DONE? not confirmed 01/15
- it sleeps. it should not sleep
- Configured state without USB connection?
- timer is slow while power down - DONE 11/26
- time out interrupt is lost while power down?
- interrupt of watchdog timer compensates timer counter(avr/suspend.c)
- repeated CHARGING/FULL_CHARGED - No longer problem 01/15
- In LTC sharp pulses are observed.
- MCP has no pulse but still has a problem.
- needs more wait before read pin state? - NO
- USB plug-in fails while BT - No longer problem 01/15
- it ends in suspend state
- maybe, not responsive to host enumeration process due to power-down.
- matrix_power_down() only when state is unattached - 11/26
- need to observe a while

@ -1,88 +0,0 @@
Power Saving
============
MCU+HHKB Power Comsumption
--------------------------
Battery drive:
idle 18.9mA
active 35.8mA
USB powered:
40.0mA
52mA 01/17
Other keyboards:
HHKB Pro 55mA
HHKB Pro2 140mA
HHKB Pro 42mA(Alt)
HHKB Pro2 52mA(Alt BT controller USB mode)
HHKB Pro2 88mA(Alt BT controller BT mode connected)
HHKB Pro2 68mA(Alt BT controller BT mode config mode)
Poker X 6mA
Infinity 24mA(TMK)
65mA(kiibohd)
HHKB key switch power control
-----------------------------
MOS FET Nch: BSS138 or IRLML6344T, either works and no apparent difference.
Normally on(pull-up) or off(pull-down)? interms of power saving it prefers pull-down?
Pull-down will be better for power saving, normally off.
Used Timer
----------
8MHz clock
----------
1) 16MHz xtal with system prescaler div2: F_CPU=8MHz, F_USB=16MHz
2) 8MHz xtal with div1: F_CPU=8MHz, F_USB=8MHz
Hardware USART doesn't work at 115200bps with 8MHz(F_CPU).
workaround:
a) use Sotwre serial for communcation with RN-42
b) reduce baud of RN-42 to lower rate;(factory default is 115200bps)
10/03
Slave mode
----------
Discovery/Inquire
Connect/Page
SI,0012
SJ,0012
InqWindw=0100
PagWindw=0100
Sniff mode
----------
0.625ms * <hex>
SW,0320 Very sluggish. Type is not lost but very slow to register.
SW,0160 Still sluggish. may transposed? can type but ...
Mouse point move intermittently
SW,0020 feel a bit late like stumble(20ms)
SW,0010 feel no latency(10ms)
Deep sleep
----------
SW,8010
TX power
--------
SY,fff4
IO pins
-------
S%,1000 status led and connection control don't work
GPIO5: status LED
GPIO6: Connection control
GPIO2: linked status

@ -1,408 +0,0 @@
RN-42 Bluetooth Module Support
==============================
Bluetooth controller board works with HHKB Pro2, JP, Type-S and Type-S JP and it supports both USB and Bluetooth as keyboard output protocol. Bluetooth module Roving Networks/Microchip RN-42 is installed on the board.
RN-42:
http://www.microchip.com/wwwproducts/Devices.aspx?product=RN42
Capabitlities:
- USB keyboard functions
completely equivarent to USB controller including mouse keys and NKRO.
- Switching between USB and Bluetooth
You can switch the two connections with BT switch or key combination.
- RN-42 config mode
You can change power/connection configuration of the module if needed.
- Low battery alert
Red LED turns on when low voltage.
- RN-42 status indicator
LED indicates status of Bluetooth connection.
- Pairing
The module stores up to 8 connections.
- Auto connect
The module connects the last connected device automatically.
- iOS support
works as keyboard with iPhone5. No tested completely.
- Android support
works as keyboard and mouse with Nexus5. No tested completely.
- Mouse keys over BT
Note that iOS doesn't accept mouse device.
Limitations:
- Short battery life
Around 12hr with 1000mAh
- No connection switching
RN-42 auto-connects to the last connected device.
Some of consumer products can switch between devices, for example Logitech K480.
http://www.logitech.com/en-us/product/multi-device-keyboard-k480?crid=26
- HHKB JP requires case modification for BT switch and LEDs.
without switch power controlled by MCU? Probably using 3.3V regulator enable pin power of RN-42 can be controlled.
NOTE:
- LIPO BATTERY IS VERY DANGEROUS, TAKE EXTRA CARE OF YOUR SAFETY AND PROPERTY.
- RN-42 version 6.15 is supported.
- No NKRO over Bluetooth
- Check you country's wiress regulation and certification of RN-42.
Bugs:
Todos:
Lipo Battery
------------
You can use 3.7V Lithium Ion battery with JST PH 2pin connector and protection circuit.
Battery space inside HHKB is around 54mm x 50mm and its height is 7mm.
Sparkfun 850mAh
https://www.sparkfun.com/products/341
Sparkfun 1000mAh
https://www.sparkfun.com/products/339
Sparkfun 2000mAh battery won't fit due to its size.
Learn about Lipo battery:
https://learn.adafruit.com/li-ion-and-lipoly-batteries
LED Status
----------
Configuring 10 times per sec
Startup/configuration timer 2 times per sec
Discoverable/Inquiring/Idle once per sec
Connected solid on
RN-42 Magic Command
--------------------
Magic key combination is 'LShift+RShift' by default in case of HHKB.
Here is help.
----- Bluetooth RN-42 Help -----
i: RN-42 info
b: battery voltage
Del: enter/exit RN-42 config mode
Slck: RN-42 initialize
p: pairing
u: toggle Force USB mode
RN-42 info: displays information of the module on console.
battery voltage: displays current voltage of battery and uptime.
RN-42 initialize: does factory reset and configures RN-42
pairing: enters Pairing mode.
toggle Force USB mode: switch between USB and Bluetooth
RN-42 Config mode
-----------------
You can tune/operate RN-42 yourself with config(command) mode.
1. hook up USB cable
2. run `hid_listen` command in console
3. turn on Bluetooth switch
4. press LShift+RShift+Delete(Fn+~) you will see output like followings:
Entering config mode ...
CMD
v
Ver 6.15 04/26/2013
(c) Roving Networks
5. do config with RN-42 commands. See documentations of RN-42.
6. to exit also press LShift+RShift+Delete(Fn+~)
Exiting config mode ...
---
END
RN-42 Initial Configuration
---------------------------
RN-42 is configured as SPP device at factory reset, you need to configure it as HID device. This is needed just once first time.
1. hook up USB cable
2. run `hid_listen` command in console
3. turn on Bluetooth switch
4. press LShift+RShift+ScrLk(Fn+O) you will see output like followings:
Entering config mode ...
CMD
Ver 6.15 04/26/2013
(c) Roving Networks
ECHO ON
SF,1
AOK
S-,TmkBT
AOK
SS,Keyboard/Mouse
AOK
SM,4
AOK
SW,8000
AOK
S~,6
AOK
SH,003C
AOK
SY,FFF4
AOK
R,1
Reboot!
Exiting config mode ...
5. output of command 'X' after cofiguration
Ver 6.15 04/26/2013
(c) Roving Networks
***Settings***
BTA=00066667BBE9
BTName=TmkBT-BBE9
Baudrt(SW4)=115K
Mode =DTR
Authen=1
PinCod=1234
Bonded=0
Rem=NONE SET
***ADVANCED Settings***
SrvName= Keyboard/Mouse
SrvClass=0000
DevClass=1F00
InqWindw=0100
PagWindw=0100
CfgTimer=255
StatuStr=NULL
HidFlags=3c
DTRtimer=8
KeySwapr=0
***OTHER Settings***
Profile= HID
CfgChar= $
SniffEna=8000
LowPower=0
TX Power=fff4
IOPorts= 0
IOValues=0
Sleeptmr=0
DebugMod=0
RoleSwch=0
Switch to USB mode
------------------
You can switch between USB and Bluetooth with pressing 'LShift+RShift+u'.
Pairing mode
------------
This disconnects current connect and enter pairing mode.
For deveropment
===============
RN-42 Serial Connection
-----------------------
UART: 115200bps, 8bit, 1-stopbit, non-parity, no flow control
SSP: 115200bps, 8bit, 1-stopbit, non-parity, no flow control(via Bluetooth)
To enter command mode disconnect the module from host and type '$$$'.(you will see 'CMD') and type '+' to get local echo. To exit type '---'(you will see 'END').
RN-42 Commands
--------------
S-,tmkBT // Device name
SS,keyboard/mouse // service name
SM,4 // Auto Connect DTR mode
SW,8010 // Sniff enable 0x10*0.625ms=10ms; 50ms is laggish and not much power save
S~,6 // HID profile
S~,0 // SPP profile
SH,003C // HID register
SY,0004 // Transmit power
SC,0000 // COD: 000005C0 (see HID spec/Bluegiga doc)
SD,05C0 // bit 12-8 7 6 5-0
// 00101 1 1 0
// peripheral pointing keybaord joystick, gamepad, ...
SM,6 // Pairing mode: auto connect
SM,4 // Master mode: Connection can be controled with GPIO6
SF,1 // Factroy reset
R,1 // reboot
SR,Z // removes all remote addresses for reconnecting.
// can be used to connect another host
SR,I // registers last inquiry address
Operation Modes
---------------
SM,3 Auto Connect Master mode
SM,4 Auto Connect DTR Mode uses GPIO6 to make and break connection(Mode =DTR)
confirm: auto connect works and control connection with GPIO6
SM,5 Auto Connect ANY Mode (Mode =ANY)
each time GPIO is set, make inquiry and connect to the first found device
SM,6 automatically reconnect(Mode =Pair)
confirm: auto connect works well but difficult to enter command mode.
HID flag register
-----------------
SH,0200
GH
10 0000 0000(0200) default
00 0011 1000(0038) Combo
|| | | |\_\____ number of paired devices to which the module can reconnect
|| | | \_______ send out reports over UART (0xFF <len> <data>)
|| \__\_________ descriptor type
|\______________ toggle virtual keyboard on iOS when first connected
\_______________ Force HID mode if GPIO11 is high on power-up
Descriptor type:
0000: keybaord
0001: Game Pad
0010: Mouse
0011: Combo
0100: Joystick
1xxx: reserved
Out report - Indicator
----------------------
0xFE 0x02 0x01 <LED_state>
Apple iOS
---------
Keyboard can be used with iPhone, but mouse cannot.
Android
-------
3.7.1.5 Note: To connect with Android phone the modules must wake up 11ms every 2.5seconds.
Power Management
----------------
Inquiry and Page window Idle or Active (3.1.1)
Downside: delay in discovery or connection time
SI, // set inquiry scan window(discovery) on/off duty?
SJ, // set page scan window(connection)
This reduces averaege power >20mA to 5mA(3mA in Sniff mode)
Sniff mode Transmit
Sniff mode is disabled by default and radio is active continuously when connected.(25-30mA)
In Sniff mode the radio wakes up intermittently and sleeps in very low power mode.(2mA)
SW,<val> // set interval timer(*0.625ms) 0000-7FFF
Deep sleep Idle (3.1.2)
In this mode the module shuts down completly and only draws about 300uA. To enable this set the most signifant bit(0x8000) of Sniff interaval timer.
SW,8320 // deep sleep enable(interval=0x320*0.625=500ms)
In normal sleep the firmware is still running in idle mode, and wakes up about 20 times per second to check ports, update LEDs, etc. During deep sleep, the firmware actually stops runnig some tasks and the LEDs only update about once per second.
To wake from deep sleep there are three ways: (in worst case wake up takes 5ms)
*send a charactor to the UART(first charactor will be lost)
*toggle CTS low to high and wait 5ms
*wake automatically every slot time(<val>*0.625ms)
Once the radio is awake it stay active for exactly 1 second of inactivity and then sleeps again.
Downside: latency and data loss
Disable Output driver Idle or Active (3.1.3)
S%,1000 // set all GPIO pins(0-11) to inputs.
Lower Transmit Power Idle or Active (3.1.4)
SY,<hex> // transmit power setting(takes effect after a power cycle and reboot)
Downside: reducing effective range
Optimizig for Latency
---------------------
By default the firmware is optimized for throughput.
SQ,16 // set latency bit
SQ,0 // unset latency bit
Configuration timer settings
----------------------------
Remote configuration is used for the module to be configured with various commands over Bluetooth(SPP profile only?).
The module has remote configuration timer to allow remote configuration over Bluetooth after power up in Slave mode. In Master modes the remote configuration timer is set to 0(no remote configuration). (In Trigger Master mode the timer is used as an idle timer to break the connection after time expires with no charactors receive.)
ST,0 // no remote, no local when connected
ST,<1-252> // local and remote with timeout in seconds from power up
ST,253 // local only without timeout
ST,254 // remote only without timeout
ST,255 // local and remote without timeout
Commands
--------
S7, 7bit mode
SA, Authenticaiton
SB, Send break
SC, Service class
SD, Device class
SM,<val> Operation mode
SP,<string> Pin code(alpahnumeric)
SQ,<mask> Special configuration(GPIO, discovery mode, low latency, reboot, UART)
SR,<hex> Store remote address
SR,Z Erase all address
SS,<string> Set service name(1-20)**
ST,<val> Remote configuration timer(Master:0, Slave:0-255, Triger:as idle timer)
SU,<val> UART baud rate
SW,<val> low-power sniff mode** deep sleep and wake up every 625us * <val>
SX,<0|1> bonding enable only acceps device that matches the stored address
SY,<hex> power setting**
SZ,<val> non-standard raw baud rate <val>=baud*0.004096
S~,<val> Profile 0:SPP, 5:APL, 6:HID
S-,<string> Device name -15 alphanumeric charactors
S?,<0|1> role switch enable
S$,<char> command mode char
$|,<hex> low-power connect mode deep sleep/active(discoverable and connectable) cycle
D display basic setting
E display extended setting
GB display the device's Bluetooth address
GF display Bluetooth address of connected device
GK show connection status
GR show remote address for reconnecting
G& show GPIO pin
G<char> show stored setting
+ toggle local echo on/off
& show GPIO 3,4,6,7(DIP switch)
C connect to stored remote address
C,<address> connect last address
CFI connect and go into fast data mode
CFR connect and go into fast data mode
CT,<address>,<val> connect to the address and disconnect after val?
F,1 fast data mod:
H display help
I,<time>,<cod> inquiry scan with <cod>
IN,<time>,<cod> inquiry scan with <cod>, return without BT name
IR inquiry scan with 0055AA
IS inquiry scan with 001F00
J hide pin code
K, kill disconnects current connection
L link quality
M show modem signlal status
O display other settings
P,<char> pass through?
Q quiet mode make the module not discoverable
Q,0 discoverable and connectable
Q,1 not discoverable and not connectable
Q,2 not discoverable and connectable
Q,? display current quiet mode
R,1 reboot
T,<0|1> pass received data while in command mode
U,<baud>,<parity> change UART setting tentatively
V display firmware version
W wake from quiet mode enable discovery and connection
Z deep sleep mode(<2mA)
Reset to Factory Default
------------------------
SF,1
R,1

@ -1,130 +0,0 @@
#include <avr/io.h>
#include <util/delay.h>
#include "battery.h"
/*
* Battery
*/
void battery_init(void)
{
// blink
battery_led(LED_ON); _delay_ms(500);
battery_led(LED_OFF); _delay_ms(500);
battery_led(LED_ON); _delay_ms(500);
battery_led(LED_OFF); _delay_ms(500);
// LED indicates charger status
battery_led(LED_CHARGER);
// ADC setting for voltage monitor
// Ref:2.56V band-gap, Input:ADC0(PF0), Prescale:128(16MHz/128=125KHz)
ADMUX = (1<<REFS1) | (1<<REFS0);
ADCSRA = (1<<ADPS2) | (1<<ADPS1) | (1<<ADPS0);
// digital input buffer disable(24.9.5)
DIDR0 = (1<<ADC0D) | (1<<ADC4D) | (1<<ADC7D);
DIDR1 = (1<<AIN0D);
DIDR2 = (1<<ADC8D) | (1<<ADC9D) | (1<<ADC11D) | (1<<ADC12D) | (1<<ADC13D);
// ADC disable voltate divider(PF4)
DDRF |= (1<<4);
PORTF &= ~(1<<4);
}
// Indicator for battery
void battery_led(battery_led_t val)
{
if (val == LED_TOGGLE) {
// Toggle LED
DDRF |= (1<<5);
PINF |= (1<<5);
} else if (val == LED_ON) {
// On overriding charger status
DDRF |= (1<<5);
PORTF &= ~(1<<5);
} else if (val == LED_OFF) {
// Off overriding charger status
DDRF |= (1<<5);
PORTF |= (1<<5);
} else {
// Display charger status
DDRF &= ~(1<<5);
PORTF &= ~(1<<5);
}
}
bool battery_charging(void)
{
if (!(USBSTA&(1<<VBUS))) return false;
// Charger Status:
// MCP73831 MCP73832 LTC4054 Status
// Hi-Z Hi-Z Hi-Z Shutdown/No Battery
// Low Low Low Charging
// Hi Hi-Z Hi-Z Charged
// preserve last register status
uint8_t ddrf_prev = DDRF;
uint8_t portf_prev = PORTF;
// Input with pullup
DDRF &= ~(1<<5);
PORTF |= (1<<5);
_delay_ms(1);
bool charging = PINF&(1<<5) ? false : true;
// restore last register status
DDRF = (DDRF&~(1<<5)) | (ddrf_prev&(1<<5));
PORTF = (PORTF&~(1<<5)) | (portf_prev&(1<<5));
// TODO: With MCP73831 this can not get stable status when charging.
// LED is powered from PSEL line(USB or Lipo)
// due to weak low output of STAT pin?
// due to pull-up'd via resitor and LED?
return charging;
}
// Returns voltage in mV
uint16_t battery_voltage(void)
{
// ADC disable voltate divider(PF4)
DDRF |= (1<<4);
PORTF |= (1<<4);
volatile uint16_t bat;
ADCSRA |= (1<<ADEN);
_delay_ms(1); // wait for charging S/H capacitance
ADCSRA |= (1<<ADSC);
while (ADCSRA & (1<<ADSC)) ;
bat = ADC;
ADCSRA &= ~(1<<ADEN);
// ADC disable voltate divider(PF4)
DDRF |= (1<<4);
PORTF &= ~(1<<4);
return (bat - BATTERY_ADC_OFFSET) * BATTERY_ADC_RESOLUTION;
}
static bool low_voltage(void) {
static bool low = false;
uint16_t v = battery_voltage();
if (v < BATTERY_VOLTAGE_LOW_LIMIT) {
low = true;
} else if (v > BATTERY_VOLTAGE_LOW_RECOVERY) {
low = false;
}
return low;
}
battery_status_t battery_status(void)
{
if (USBSTA&(1<<VBUS)) {
/* powered */
return battery_charging() ? CHARGING : FULL_CHARGED;
} else {
/* not powered */
return low_voltage() ? LOW_VOLTAGE : DISCHARGING;
}
}

@ -1,35 +0,0 @@
#ifndef POWER_H
#define POWER_H
#include <stdint.h>
#include <stdbool.h>
typedef enum {
FULL_CHARGED,
CHARGING,
DISCHARGING,
LOW_VOLTAGE,
UNKNOWN,
} battery_status_t;
typedef enum {
LED_CHARGER = 0,
LED_ON,
LED_OFF,
LED_TOGGLE,
} battery_led_t;
/* Battery API */
void battery_init(void);
void battery_led(battery_led_t val);
bool battery_charging(void);
uint16_t battery_voltage(void);
battery_status_t battery_status(void);
#define BATTERY_VOLTAGE_LOW_LIMIT 3500
#define BATTERY_VOLTAGE_LOW_RECOVERY 3700
// ADC offset:16, resolution:5mV
#define BATTERY_ADC_OFFSET 16
#define BATTERY_ADC_RESOLUTION 5
#endif

@ -1,111 +0,0 @@
#include <avr/io.h>
#include <avr/power.h>
#include <avr/wdt.h>
#include "lufa.h"
#include "print.h"
#include "sendchar.h"
#include "rn42.h"
#include "rn42_task.h"
#include "serial.h"
#include "keyboard.h"
#include "keycode.h"
#include "action.h"
#include "action_util.h"
#include "wait.h"
#include "suart.h"
#include "suspend.h"
static int8_t sendchar_func(uint8_t c)
{
xmit(c); // SUART
sendchar(c); // LUFA
return 0;
}
static void SetupHardware(void)
{
/* Disable watchdog if enabled by bootloader/fuses */
MCUSR &= ~(1 << WDRF);
wdt_disable();
/* Disable clock division */
clock_prescale_set(clock_div_1);
// Leonardo needs. Without this USB device is not recognized.
USB_Disable();
USB_Init();
// for Console_Task
USB_Device_EnableSOFEvents();
print_set_sendchar(sendchar_func);
// SUART PD0:output, PD1:input
DDRD |= (1<<0);
PORTD |= (1<<0);
DDRD &= ~(1<<1);
PORTD |= (1<<1);
}
int main(void) __attribute__ ((weak));
int main(void)
{
SetupHardware();
sei();
/* wait for USB startup to get ready for debug output */
uint8_t timeout = 255; // timeout when USB is not available(Bluetooth)
while (timeout-- && USB_DeviceState != DEVICE_STATE_Configured) {
wait_ms(4);
#if defined(INTERRUPT_CONTROL_ENDPOINT)
;
#else
USB_USBTask();
#endif
}
print("\nUSB init\n");
rn42_init();
rn42_task_init();
print("RN-42 init\n");
/* init modules */
keyboard_init();
if (!rn42_rts()) {
host_set_driver(&rn42_driver);
} else {
host_set_driver(&lufa_driver);
}
#ifdef SLEEP_LED_ENABLE
sleep_led_init();
#endif
print("Keyboard start\n");
while (1) {
while (rn42_rts() && // RN42 is off
USB_DeviceState == DEVICE_STATE_Suspended) {
print("[s]");
matrix_power_down();
suspend_power_down();
suspend_power_down();
suspend_power_down();
suspend_power_down();
suspend_power_down();
suspend_power_down();
suspend_power_down();
if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) {
USB_Device_SendRemoteWakeup();
}
}
keyboard_task();
#if !defined(INTERRUPT_CONTROL_ENDPOINT)
USB_USBTask();
#endif
rn42_task();
}
}

@ -1,237 +0,0 @@
#include <avr/io.h>
#include "host.h"
#include "host_driver.h"
#include "serial.h"
#include "rn42.h"
#include "print.h"
#include "timer.h"
#include "wait.h"
/* Host driver */
static uint8_t keyboard_leds(void);
static void send_keyboard(report_keyboard_t *report);
static void send_mouse(report_mouse_t *report);
static void send_system(uint16_t data);
static void send_consumer(uint16_t data);
host_driver_t rn42_driver = {
keyboard_leds,
send_keyboard,
send_mouse,
send_system,
send_consumer
};
void rn42_init(void)
{
// JTAG disable for PORT F. write JTD bit twice within four cycles.
MCUCR |= (1<<JTD);
MCUCR |= (1<<JTD);
// PF7: BT connection control(high: connect, low: disconnect)
rn42_autoconnect();
// PF6: linked(input without pull-up)
DDRF &= ~(1<<6);
PORTF |= (1<<6);
// PF1: RTS(low: allowed to send, high: not allowed)
DDRF &= ~(1<<1);
PORTF &= ~(1<<1);
// PD5: CTS(low: allow to send, high:not allow)
DDRD |= (1<<5);
PORTD &= ~(1<<5);
serial_init();
}
int16_t rn42_getc(void)
{
return serial_recv2();
}
const char *rn42_gets(uint16_t timeout)
{
static char s[24];
uint16_t t = timer_read();
uint8_t i = 0;
int16_t c;
while (i < 23 && timer_elapsed(t) < timeout) {
if ((c = rn42_getc()) != -1) {
if ((char)c == '\r') continue;
if ((char)c == '\n') break;
s[i++] = c;
}
}
s[i] = '\0';
return s;
}
void rn42_putc(uint8_t c)
{
serial_send(c);
}
void rn42_puts(char *s)
{
while (*s)
serial_send(*s++);
}
bool rn42_autoconnecting(void)
{
// GPIO6 for control connection(high: auto connect, low: disconnect)
// Note that this needs config: SM,4(Auto-Connect DTR Mode)
return (PORTF & (1<<7) ? true : false);
}
void rn42_autoconnect(void)
{
// hi to auto connect
DDRF |= (1<<7);
PORTF |= (1<<7);
}
void rn42_disconnect(void)
{
// low to disconnect
DDRF |= (1<<7);
PORTF &= ~(1<<7);
}
bool rn42_rts(void)
{
// low when RN-42 is powered and ready to receive
return PINF&(1<<1);
}
void rn42_cts_hi(void)
{
// not allow to send
PORTD |= (1<<5);
}
void rn42_cts_lo(void)
{
// allow to send
PORTD &= ~(1<<5);
}
bool rn42_linked(void)
{
// RN-42 GPIO2
// Hi-Z: Not powered
// High: Linked
// Low: Connecting
return PINF&(1<<6);
}
static uint8_t leds = 0;
static uint8_t keyboard_leds(void) { return leds; }
void rn42_set_leds(uint8_t l) { leds = l; }
static void send_keyboard(report_keyboard_t *report)
{
// wake from deep sleep
/*
PORTD |= (1<<5); // high
wait_ms(5);
PORTD &= ~(1<<5); // low
*/
serial_send(0xFD); // Raw report mode
serial_send(9); // length
serial_send(1); // descriptor type
serial_send(report->mods);
serial_send(0x00);
serial_send(report->keys[0]);
serial_send(report->keys[1]);
serial_send(report->keys[2]);
serial_send(report->keys[3]);
serial_send(report->keys[4]);
serial_send(report->keys[5]);
}
static void send_mouse(report_mouse_t *report)
{
// wake from deep sleep
/*
PORTD |= (1<<5); // high
wait_ms(5);
PORTD &= ~(1<<5); // low
*/
serial_send(0xFD); // Raw report mode
serial_send(5); // length
serial_send(2); // descriptor type
serial_send(report->buttons);
serial_send(report->x);
serial_send(report->y);
serial_send(report->v);
}
static void send_system(uint16_t data)
{
// Table 5-6 of RN-BT-DATA-UB
// 81,82,83 scan codes can be used?
}
static uint16_t usage2bits(uint16_t usage)
{
switch (usage) {
case AC_HOME: return 0x01;
case AL_EMAIL: return 0x02;
case AC_SEARCH: return 0x04;
//case AL_KBD_LAYOUT: return 0x08; // Apple virtual keybaord toggle
case AUDIO_VOL_UP: return 0x10;
case AUDIO_VOL_DOWN: return 0x20;
case AUDIO_MUTE: return 0x40;
case TRANSPORT_PLAY_PAUSE: return 0x80;
case TRANSPORT_NEXT_TRACK: return 0x100;
case TRANSPORT_PREV_TRACK: return 0x200;
case TRANSPORT_STOP: return 0x400;
case TRANSPORT_STOP_EJECT: return 0x800;
//case return 0x1000; // Fast forward
//case return 0x2000; // Rewind
//case return 0x4000; // Stop/eject
//case return 0x8000; // Internet browser
};
return 0;
}
static void send_consumer(uint16_t data)
{
uint16_t bits = usage2bits(data);
serial_send(0xFD); // Raw report mode
serial_send(3); // length
serial_send(3); // descriptor type
serial_send(bits&0xFF);
serial_send((bits>>8)&0xFF);
}
/* Null driver for config_mode */
static uint8_t config_keyboard_leds(void);
static void config_send_keyboard(report_keyboard_t *report);
static void config_send_mouse(report_mouse_t *report);
static void config_send_system(uint16_t data);
static void config_send_consumer(uint16_t data);
host_driver_t rn42_config_driver = {
config_keyboard_leds,
config_send_keyboard,
config_send_mouse,
config_send_system,
config_send_consumer
};
static uint8_t config_keyboard_leds(void) { return leds; }
static void config_send_keyboard(report_keyboard_t *report) {}
static void config_send_mouse(report_mouse_t *report) {}
static void config_send_system(uint16_t data) {}
static void config_send_consumer(uint16_t data) {}

@ -1,23 +0,0 @@
#ifndef RN42_H
#define RN42_H
#include <stdbool.h>
host_driver_t rn42_driver;
host_driver_t rn42_config_driver;
void rn42_init(void);
int16_t rn42_getc(void);
const char *rn42_gets(uint16_t timeout);
void rn42_putc(uint8_t c);
void rn42_puts(char *s);
bool rn42_autoconnecting(void);
void rn42_autoconnect(void);
void rn42_disconnect(void);
bool rn42_rts(void);
void rn42_cts_hi(void);
void rn42_cts_lo(void);
bool rn42_linked(void);
void rn42_set_leds(uint8_t l);
#endif

@ -1,478 +0,0 @@
#include <stdint.h>
#include <string.h>
#include <avr/pgmspace.h>
#include <avr/eeprom.h>
#include "keycode.h"
#include "serial.h"
#include "host.h"
#include "action.h"
#include "action_util.h"
#include "lufa.h"
#include "rn42_task.h"
#include "print.h"
#include "debug.h"
#include "timer.h"
#include "wait.h"
#include "command.h"
#include "battery.h"
static bool config_mode = false;
static bool force_usb = false;
static void status_led(bool on)
{
if (on) {
DDRE |= (1<<6);
PORTE &= ~(1<<6);
} else {
DDRE |= (1<<6);
PORTE |= (1<<6);
}
}
void rn42_task_init(void)
{
battery_init();
}
void rn42_task(void)
{
int16_t c;
// Raw mode: interpret output report of LED state
while ((c = rn42_getc()) != -1) {
// LED Out report: 0xFE, 0x02, 0x01, <leds>
// To get the report over UART set bit3 with SH, command.
static enum {LED_INIT, LED_FE, LED_02, LED_01} state = LED_INIT;
switch (state) {
case LED_INIT:
if (c == 0xFE) state = LED_FE;
else {
if (0x0 <= c && c <= 0x7f) xprintf("%c", c);
else xprintf(" %02X", c);
}
break;
case LED_FE:
if (c == 0x02) state = LED_02;
else state = LED_INIT;
break;
case LED_02:
if (c == 0x01) state = LED_01;
else state = LED_INIT;
break;
case LED_01:
dprintf("LED status: %02X\n", c);
rn42_set_leds(c);
state = LED_INIT;
break;
default:
state = LED_INIT;
}
}
/* Bluetooth mode when ready */
if (!config_mode && !force_usb) {
if (!rn42_rts() && host_get_driver() != &rn42_driver) {
clear_keyboard();
host_set_driver(&rn42_driver);
} else if (rn42_rts() && host_get_driver() != &lufa_driver) {
clear_keyboard();
host_set_driver(&lufa_driver);
}
}
static uint16_t prev_timer = 0;
uint16_t e = timer_elapsed(prev_timer);
if (e > 1000) {
/* every second */
prev_timer += e/1000*1000;
/* Low voltage alert */
uint8_t bs = battery_status();
if (bs == LOW_VOLTAGE) {
battery_led(LED_ON);
} else {
battery_led(LED_CHARGER);
}
/* every minute */
uint32_t t = timer_read32()/1000;
if (t%60 == 0) {
uint16_t v = battery_voltage();
uint8_t h = t/3600;
uint8_t m = t%3600/60;
uint8_t s = t%60;
dprintf("%02u:%02u:%02u\t%umV\n", h, m, s, v);
/* TODO: xprintf doesn't work for this.
xprintf("%02u:%02u:%02u\t%umV\n", (t/3600), (t%3600/60), (t%60), v);
*/
}
}
/* Connection monitor */
if (!rn42_rts() && rn42_linked()) {
status_led(true);
} else {
status_led(false);
}
}
/******************************************************************************
* Command
******************************************************************************/
static host_driver_t *prev_driver = &rn42_driver;
static void print_rn42(void)
{
int16_t c;
while ((c = rn42_getc()) != -1) {
xprintf("%c", c);
}
}
static void clear_rn42(void)
{
while (rn42_getc() != -1) ;
}
#define SEND_STR(str) send_str(PSTR(str))
#define SEND_COMMAND(cmd) send_command(PSTR(cmd))
static void send_str(const char *str)
{
uint8_t c;
while ((c = pgm_read_byte(str++)))
rn42_putc(c);
}
static const char *send_command(const char *cmd)
{
static const char *s;
send_str(cmd);
wait_ms(500);
s = rn42_gets(100);
xprintf("%s\r\n", s);
print_rn42();
return s;
}
static void enter_command_mode(void)
{
prev_driver = host_get_driver();
clear_keyboard();
host_set_driver(&rn42_config_driver); // null driver; not to send a key to host
rn42_disconnect();
while (rn42_linked()) ;
print("Entering config mode ...\n");
wait_ms(1100); // need 1 sec
SEND_COMMAND("$$$");
wait_ms(600); // need 1 sec
print_rn42();
const char *s = SEND_COMMAND("v\r\n");
if (strncmp("v", s, 1) != 0) SEND_COMMAND("+\r\n"); // local echo on
}
static void exit_command_mode(void)
{
print("Exiting config mode ...\n");
SEND_COMMAND("---\r\n"); // exit
rn42_autoconnect();
clear_keyboard();
host_set_driver(prev_driver);
}
static void init_rn42(void)
{
// RN-42 configure
if (!config_mode) enter_command_mode();
SEND_COMMAND("SF,1\r\n"); // factory defaults
SEND_COMMAND("S-,TmkBT\r\n");
SEND_COMMAND("SS,Keyboard/Mouse\r\n");
SEND_COMMAND("SM,4\r\n"); // auto connect(DTR)
SEND_COMMAND("SW,8000\r\n"); // Sniff disable
SEND_COMMAND("S~,6\r\n"); // HID profile
SEND_COMMAND("SH,003C\r\n"); // combo device, out-report, 4-reconnect
SEND_COMMAND("SY,FFF4\r\n"); // transmit power -12
SEND_COMMAND("R,1\r\n");
if (!config_mode) exit_command_mode();
}
#if 0
// Switching connections
// NOTE: Remote Address doesn't work in the way manual says.
// EEPROM address for link store
#define RN42_LINK0 (uint8_t *)128
#define RN42_LINK1 (uint8_t *)140
#define RN42_LINK2 (uint8_t *)152
#define RN42_LINK3 (uint8_t *)164
static void store_link(uint8_t *eeaddr)
{
enter_command_mode();
SEND_STR("GR\r\n"); // remote address
const char *s = rn42_gets(500);
if (strcmp("GR", s) == 0) s = rn42_gets(500); // ignore local echo
xprintf("%s(%d)\r\n", s, strlen(s));
if (strlen(s) == 12) {
for (int i = 0; i < 12; i++) {
eeprom_update_byte(eeaddr+i, *(s+i));
dprintf("%c ", *(s+i));
}
dprint("\r\n");
}
exit_command_mode();
}
static void restore_link(const uint8_t *eeaddr)
{
enter_command_mode();
SEND_COMMAND("SR,Z\r\n"); // remove remote address
SEND_STR("SR,"); // set remote address from EEPROM
for (int i = 0; i < 12; i++) {
uint8_t c = eeprom_read_byte(eeaddr+i);
rn42_putc(c);
dprintf("%c ", c);
}
dprintf("\r\n");
SEND_COMMAND("\r\n");
SEND_COMMAND("R,1\r\n"); // reboot
exit_command_mode();
}
static const char *get_link(uint8_t * eeaddr)
{
static char s[13];
for (int i = 0; i < 12; i++) {
uint8_t c = eeprom_read_byte(eeaddr+i);
s[i] = c;
}
s[12] = '\0';
return s;
}
#endif
static void pairing(void)
{
enter_command_mode();
SEND_COMMAND("SR,Z\r\n"); // remove remote address
SEND_COMMAND("R,1\r\n"); // reboot
exit_command_mode();
}
bool command_extra(uint8_t code)
{
uint32_t t;
uint16_t b;
switch (code) {
case KC_H:
case KC_SLASH: /* ? */
print("\n\n----- Bluetooth RN-42 Help -----\n");
print("i: RN-42 info\n");
print("b: battery voltage\n");
print("Del: enter/exit RN-42 config mode\n");
print("Slck: RN-42 initialize\n");
#if 0
print("1-4: restore link\n");
print("F1-F4: store link\n");
#endif
print("p: pairing\n");
if (config_mode) {
return true;
} else {
print("u: toggle Force USB mode\n");
return false; // to display default command help
}
case KC_P:
pairing();
return true;
#if 0
/* Store link address to EEPROM */
case KC_F1:
store_link(RN42_LINK0);
return true;
case KC_F2:
store_link(RN42_LINK1);
return true;
case KC_F3:
store_link(RN42_LINK2);
return true;
case KC_F4:
store_link(RN42_LINK3);
return true;
/* Restore link address to EEPROM */
case KC_1:
restore_link(RN42_LINK0);
return true;
case KC_2:
restore_link(RN42_LINK1);
return true;
case KC_3:
restore_link(RN42_LINK2);
return true;
case KC_4:
restore_link(RN42_LINK3);
return true;
#endif
case KC_I:
print("\n----- RN-42 info -----\n");
xprintf("protocol: %s\n", (host_get_driver() == &rn42_driver) ? "RN-42" : "LUFA");
xprintf("force_usb: %X\n", force_usb);
xprintf("rn42: %s\n", rn42_rts() ? "OFF" : (rn42_linked() ? "CONN" : "ON"));
xprintf("rn42_autoconnecting(): %X\n", rn42_autoconnecting());
xprintf("config_mode: %X\n", config_mode);
xprintf("USB State: %s\n",
(USB_DeviceState == DEVICE_STATE_Unattached) ? "Unattached" :
(USB_DeviceState == DEVICE_STATE_Powered) ? "Powered" :
(USB_DeviceState == DEVICE_STATE_Default) ? "Default" :
(USB_DeviceState == DEVICE_STATE_Addressed) ? "Addressed" :
(USB_DeviceState == DEVICE_STATE_Configured) ? "Configured" :
(USB_DeviceState == DEVICE_STATE_Suspended) ? "Suspended" : "?");
xprintf("battery: ");
switch (battery_status()) {
case FULL_CHARGED: xprintf("FULL"); break;
case CHARGING: xprintf("CHARG"); break;
case DISCHARGING: xprintf("DISCHG"); break;
case LOW_VOLTAGE: xprintf("LOW"); break;
default: xprintf("?"); break;
};
xprintf("\n");
xprintf("RemoteWakeupEnabled: %X\n", USB_Device_RemoteWakeupEnabled);
xprintf("VBUS: %X\n", USBSTA&(1<<VBUS));
t = timer_read32()/1000;
uint8_t d = t/3600/24;
uint8_t h = t/3600;
uint8_t m = t%3600/60;
uint8_t s = t%60;
xprintf("uptime: %02u %02u:%02u:%02u\n", d, h, m, s);
#if 0
xprintf("LINK0: %s\r\n", get_link(RN42_LINK0));
xprintf("LINK1: %s\r\n", get_link(RN42_LINK1));
xprintf("LINK2: %s\r\n", get_link(RN42_LINK2));
xprintf("LINK3: %s\r\n", get_link(RN42_LINK3));
#endif
return true;
case KC_B:
// battery monitor
t = timer_read32()/1000;
b = battery_voltage();
xprintf("BAT: %umV\t", b);
xprintf("%02u:", t/3600);
xprintf("%02u:", t%3600/60);
xprintf("%02u\n", t%60);
return true;
case KC_U:
if (config_mode) return false;
if (force_usb) {
print("Auto mode\n");
force_usb = false;
} else {
print("USB mode\n");
force_usb = true;
clear_keyboard();
host_set_driver(&lufa_driver);
}
return true;
case KC_DELETE:
/* RN-42 Command mode */
if (rn42_autoconnecting()) {
enter_command_mode();
command_state = CONSOLE;
config_mode = true;
} else {
exit_command_mode();
command_state = ONESHOT;
config_mode = false;
}
return true;
case KC_SCROLLLOCK:
init_rn42();
return true;
default:
if (config_mode)
return true;
else
return false; // yield to default command
}
return true;
}
/*
* RN-42 Command mode
* sends charactors to the module
*/
static uint8_t code2asc(uint8_t code);
bool command_console_extra(uint8_t code)
{
rn42_putc(code2asc(code));
return true;
}
// convert keycode into ascii charactor
static uint8_t code2asc(uint8_t code)
{
bool shifted = (get_mods() & (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT))) ? true : false;
switch (code) {
case KC_A: return (shifted ? 'A' : 'a');
case KC_B: return (shifted ? 'B' : 'b');
case KC_C: return (shifted ? 'C' : 'c');
case KC_D: return (shifted ? 'D' : 'd');
case KC_E: return (shifted ? 'E' : 'e');
case KC_F: return (shifted ? 'F' : 'f');
case KC_G: return (shifted ? 'G' : 'g');
case KC_H: return (shifted ? 'H' : 'h');
case KC_I: return (shifted ? 'I' : 'i');
case KC_J: return (shifted ? 'J' : 'j');
case KC_K: return (shifted ? 'K' : 'k');
case KC_L: return (shifted ? 'L' : 'l');
case KC_M: return (shifted ? 'M' : 'm');
case KC_N: return (shifted ? 'N' : 'n');
case KC_O: return (shifted ? 'O' : 'o');
case KC_P: return (shifted ? 'P' : 'p');
case KC_Q: return (shifted ? 'Q' : 'q');
case KC_R: return (shifted ? 'R' : 'r');
case KC_S: return (shifted ? 'S' : 's');
case KC_T: return (shifted ? 'T' : 't');
case KC_U: return (shifted ? 'U' : 'u');
case KC_V: return (shifted ? 'V' : 'v');
case KC_W: return (shifted ? 'W' : 'w');
case KC_X: return (shifted ? 'X' : 'x');
case KC_Y: return (shifted ? 'Y' : 'y');
case KC_Z: return (shifted ? 'Z' : 'z');
case KC_1: return (shifted ? '!' : '1');
case KC_2: return (shifted ? '@' : '2');
case KC_3: return (shifted ? '#' : '3');
case KC_4: return (shifted ? '$' : '4');
case KC_5: return (shifted ? '%' : '5');
case KC_6: return (shifted ? '^' : '6');
case KC_7: return (shifted ? '&' : '7');
case KC_8: return (shifted ? '*' : '8');
case KC_9: return (shifted ? '(' : '9');
case KC_0: return (shifted ? ')' : '0');
case KC_ENTER: return '\n';
case KC_ESCAPE: return 0x1B;
case KC_BSPACE: return '\b';
case KC_TAB: return '\t';
case KC_SPACE: return ' ';
case KC_MINUS: return (shifted ? '_' : '-');
case KC_EQUAL: return (shifted ? '+' : '=');
case KC_LBRACKET: return (shifted ? '{' : '[');
case KC_RBRACKET: return (shifted ? '}' : ']');
case KC_BSLASH: return (shifted ? '|' : '\\');
case KC_NONUS_HASH: return (shifted ? '|' : '\\');
case KC_SCOLON: return (shifted ? ':' : ';');
case KC_QUOTE: return (shifted ? '"' : '\'');
case KC_GRAVE: return (shifted ? '~' : '`');
case KC_COMMA: return (shifted ? '<' : ',');
case KC_DOT: return (shifted ? '>' : '.');
case KC_SLASH: return (shifted ? '?' : '/');
case KC_DELETE: return '\0'; // Delete to disconnect
default: return ' ';
}
}

@ -1,10 +0,0 @@
#ifndef RN42_TASK_H
#define RN42_TASK_H
#include <stdbool.h>
#include "rn42.h"
void rn42_task_init(void);
void rn42_task(void);
#endif

@ -1,156 +0,0 @@
;---------------------------------------------------------------------------;
; Software implemented UART module ;
; (C)ChaN, 2005 (http://elm-chan.org/) ;
;---------------------------------------------------------------------------;
; Bit rate settings:
;
; 1MHz 2MHz 4MHz 6MHz 8MHz 10MHz 12MHz 16MHz 20MHz
; 2.4kbps 138 - - - - - - - -
; 4.8kbps 68 138 - - - - - - -
; 9.6kbps 33 68 138 208 - - - - -
; 19.2kbps - 33 68 102 138 173 208 - -
; 38.4kbps - - 33 50 68 85 102 138 172
; 57.6kbps - - 21 33 44 56 68 91 114
; 115.2kbps - - - - 21 27 33 44 56
.nolist
#include <avr/io.h>
.list
#define BPS 44 /* Bit delay. (see above table) */
#define BIDIR 0 /* 0:Separated Tx/Rx, 1:Shared Tx/Rx */
#define OUT_1 sbi _SFR_IO_ADDR(SUART_OUT_PORT), SUART_OUT_BIT /* Output 1 */
#define OUT_0 cbi _SFR_IO_ADDR(SUART_OUT_PORT), SUART_OUT_BIT /* Output 0 */
#define SKIP_IN_1 sbis _SFR_IO_ADDR(SUART_IN_PIN), SUART_IN_BIT /* Skip if 1 */
#define SKIP_IN_0 sbic _SFR_IO_ADDR(SUART_IN_PIN), SUART_IN_BIT /* Skip if 0 */
#ifdef SPM_PAGESIZE
.macro _LPMI reg
lpm \reg, Z+
.endm
.macro _MOVW dh,dl, sh,sl
movw \dl, \sl
.endm
#else
.macro _LPMI reg
lpm
mov \reg, r0
adiw ZL, 1
.endm
.macro _MOVW dh,dl, sh,sl
mov \dl, \sl
mov \dh, \sh
.endm
#endif
;---------------------------------------------------------------------------;
; Transmit a byte in serial format of N81
;
;Prototype: void xmit (uint8_t data);
;Size: 16 words
.global xmit
.func xmit
xmit:
#if BIDIR
ldi r23, BPS-1 ;Pre-idle time for bidirectional data line
5: dec r23 ;
brne 5b ;/
#endif
in r0, _SFR_IO_ADDR(SREG) ;Save flags
com r24 ;C = start bit
ldi r25, 10 ;Bit counter
cli ;Start critical section
1: ldi r23, BPS-1 ;----- Bit transferring loop
2: dec r23 ;Wait for a bit time
brne 2b ;/
brcs 3f ;MISO = bit to be sent
OUT_1 ;
3: brcc 4f ;
OUT_0 ;/
4: lsr r24 ;Get next bit into C
dec r25 ;All bits sent?
brne 1b ; no, coutinue
out _SFR_IO_ADDR(SREG), r0 ;End of critical section
ret
.endfunc
;---------------------------------------------------------------------------;
; Receive a byte
;
;Prototype: uint8_t rcvr (void);
;Size: 19 words
.global rcvr
.func rcvr
rcvr:
in r0, _SFR_IO_ADDR(SREG) ;Save flags
ldi r24, 0x80 ;Receiving shift reg
cli ;Start critical section
1: SKIP_IN_1 ;Wait for idle
rjmp 1b
2: SKIP_IN_0 ;Wait for start bit
rjmp 2b
ldi r25, BPS/2 ;Wait for half bit time
3: dec r25
brne 3b
4: ldi r25, BPS ;----- Bit receiving loop
5: dec r25 ;Wait for a bit time
brne 5b ;/
lsr r24 ;Next bit
SKIP_IN_0 ;Get a data bit into r24.7
ori r24, 0x80
brcc 4b ;All bits received? no, continue
out _SFR_IO_ADDR(SREG), r0 ;End of critical section
ret
.endfunc
; Not wait for start bit. This should be called after detecting start bit.
.global recv
.func recv
recv:
in r0, _SFR_IO_ADDR(SREG) ;Save flags
ldi r24, 0x80 ;Receiving shift reg
cli ;Start critical section
;1: SKIP_IN_1 ;Wait for idle
; rjmp 1b
;2: SKIP_IN_0 ;Wait for start bit
; rjmp 2b
ldi r25, BPS/2 ;Wait for half bit time
3: dec r25
brne 3b
4: ldi r25, BPS ;----- Bit receiving loop
5: dec r25 ;Wait for a bit time
brne 5b ;/
lsr r24 ;Next bit
SKIP_IN_0 ;Get a data bit into r24.7
ori r24, 0x80
brcc 4b ;All bits received? no, continue
ldi r25, BPS/2 ;Wait for half bit time
6: dec r25
brne 6b
7: SKIP_IN_1 ;Wait for stop bit
rjmp 7b
out _SFR_IO_ADDR(SREG), r0 ;End of critical section
ret
.endfunc

@ -1,8 +0,0 @@
#ifndef SUART
#define SUART
void xmit(uint8_t);
uint8_t rcvr(void);
uint8_t recv(void);
#endif /* SUART */

@ -1,149 +0,0 @@
#----------------------------------------------------------------------------
# On command line:
#
# make all = Make software.
#
# make clean = Clean out built project files.
#
# make coff = Convert ELF to AVR COFF.
#
# make extcoff = Convert ELF to AVR Extended COFF.
#
# make program = Download the hex file to the device.
# Please customize your programmer settings(PROGRAM_CMD)
#
# make teensy = Download the hex file to the device, using teensy_loader_cli.
# (must have teensy_loader_cli installed).
#
# make dfu = Download the hex file to the device, using dfu-programmer (must
# have dfu-programmer installed).
#
# make flip = Download the hex file to the device, using Atmel FLIP (must
# have Atmel FLIP installed).
#
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
# (must have dfu-programmer installed).
#
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
# (must have Atmel FLIP installed).
#
# make debug = Start either simulavr or avarice as specified for debugging,
# with avr-gdb or avr-insight as the front end for debugging.
#
# make filename.s = Just compile filename.c into the assembler code only.
#
# make filename.i = Create a preprocessed source file for use in submitting
# bug reports to the GCC project.
#
# To rebuild project do "make clean" then "make all".
#----------------------------------------------------------------------------
# Target file name (without extension).
TARGET = hhkb_qmk
# Directory common source filess exist
TOP_DIR = ../..
TMK_DIR = ../../tmk_core
# Directory keyboard dependent files exist
TARGET_DIR = .
# # project specific files
SRC = hhkb_qmk.c \
matrix.c
ifdef KEYMAP
SRC := keymaps/keymaps/$(KEYMAP).c $(SRC)
else
SRC := keymaps/keymaps/default.c $(SRC)
endif
CONFIG_H = config.h
# MCU name
#MCU = at90usb1287
MCU = atmega32u4
# Processor frequency.
# This will define a symbol, F_CPU, in all source code files equal to the
# processor frequency in Hz. You can then use this symbol in your source code to
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
# automatically to create a 32-bit value in your source code.
#
# This will be an integer division of F_USB below, as it is sourced by
# F_USB after it has run through any CPU prescalers. Note that this value
# does not *change* the processor frequency - it should merely be updated to
# reflect the processor speed set externally so that the code can use accurate
# software delays.
F_CPU = 16000000
#
# LUFA specific
#
# Target architecture (see library "Board Types" documentation).
ARCH = AVR8
# Input clock frequency.
# This will define a symbol, F_USB, in all source code files equal to the
# input clock frequency (before any prescaling is performed) in Hz. This value may
# differ from F_CPU if prescaling is used on the latter, and is required as the
# raw input clock is fed directly to the PLL sections of the AVR for high speed
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
# at the end, this will be done automatically to create a 32-bit value in your
# source code.
#
# If no clock division is performed on the input clock inside the AVR (via the
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
F_USB = $(F_CPU)
# Interrupt driven control endpoint task(+60)
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
# Boot Section Size in *bytes*
# Teensy halfKay 512
# Teensy++ halfKay 1024
# Atmel DFU loader 4096
# LUFA bootloader 4096
# USBaspLoader 2048
#OPT_DEFS += -DBOOTLOADER_SIZE=4096
# as per original hasu settings
OPT_DEFS += -DBOOTLOADER_SIZE=512
# Build Options
# comment out to disable the options.
#
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)
COMMAND_ENABLE = yes # Commands for debug and configuration
CUSTOM_MATRIX = yes # Custom matrix file for the HHKB
# 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 - 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 = YES # MIDI controls
# UNICODE_ENABLE = YES # Unicode
# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID
# Optimize size but this may cause error "relocation truncated to fit"
#EXTRALDFLAGS = -Wl,--relax
# Search Path
VPATH += $(TARGET_DIR)
VPATH += $(TOP_DIR)
VPATH += $(TMK_DIR)
debug-on: EXTRAFLAGS += -DDEBUG -DDEBUG_ACTION
debug-on: all
debug-off: EXTRAFLAGS += -DNO_DEBUG -DNO_PRINT
debug-off: OPT_DEFS := $(filter-out -DCONSOLE_ENABLE,$(OPT_DEFS))
debug-off: all
include $(TOP_DIR)/quantum/quantum.mk

@ -1,180 +0,0 @@
hhkb_qmk keyboard firmware
======================
## Quantum MK Firmware
You have access to a bunch of goodies! Check out the Makefile to enable/disable some of the features. Uncomment the `#` to enable them. Setting them to `no` does nothing and will only confuse future you.
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
MIDI_ENABLE = yes # MIDI controls
# UNICODE_ENABLE = yes # Unicode support - this is commented out, just as an example. You have to use #, not //
BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID
## Quick aliases to common actions
Your keymap can include shortcuts to common operations (called "function actions" in tmk).
### Switching and toggling layers
`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.
`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
* `RSFT(kc)` - applies right Shift to *kc*
* `LCTL(kc)` - applies left Control to *kc*
* `RCTL(kc)` - applies right Control to *kc*
* `LALT(kc)` - applies left Alt to *kc*
* `RALT(kc)` - applies right Alt to *kc*
* `LGUI(kc)` - applies left GUI (command/win) to *kc*
* `RGUI(kc)` - applies right GUI (command/win) to *kc*
You can also chain these, like this:
LALT(LCTL(KC_DEL)) -- this makes a key that sends Alt, Control, and Delete in a single keypress.
The following shortcuts automatically add `LSFT()` to keycodes to get commonly used symbols. Their long names are also available and documented in `/quantum/keymap_common.h`.
KC_TILD ~
KC_EXLM !
KC_AT @
KC_HASH #
KC_DLR $
KC_PERC %
KC_CIRC ^
KC_AMPR &
KC_ASTR *
KC_LPRN (
KC_RPRN )
KC_UNDS _
KC_PLUS +
KC_LCBR {
KC_RCBR }
KC_PIPE |
KC_COLN :
`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):
* MOD_LCTL
* MOD_LSFT
* MOD_LALT
* MOD_LGUI
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.
We've added shortcuts to make common modifier/tap (mod-tap) mappings more compact:
* `CTL_T(kc)` - is LCTL when held and *kc* when tapped
* `SFT_T(kc)` - is LSFT when held and *kc* when tapped
* `ALT_T(kc)` - is LALT when held and *kc* when tapped
* `GUI_T(kc)` - is LGUI when held and *kc* when tapped
* `ALL_T(kc)` - is Hyper (all mods) when held and *kc* when tapped. To read more about what you can do with a Hyper key, see [this blog post by Brett Terpstra](http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/)
### Temporarily setting the default layer
`DF(layer)` - sets default layer to *layer*. The default layer is the one at the "bottom" of the layer stack - the ultimate fallback layer. This currently does not persist over power loss. When you plug the keyboard back in, layer 0 will always be the default. It is theoretically possible to work around that, but that's not what `DF` does.
### Remember: These are just aliases
These functions work the same way that their `ACTION_*` functions do - they're just quick aliases. To dig into all of the tmk ACTION_* functions, please see the [TMK documentation](https://github.com/jackhumbert/qmk_firmware/blob/master/tmk_core/doc/keymap.md#2-action).
Instead of using `FNx` when defining `ACTION_*` functions, you can use `F(x)` - the benefit here is being able to use more than 32 function actions (up to 4096), if you happen to need them.
## Macro shortcuts: Send a whole string when pressing just one key
Instead of using the `ACTION_MACRO` function, you can simply use `M(n)` to access macro *n* - *n* will get passed into the `action_get_macro` as the `id`, and you can use a switch statement to trigger it. This gets called on the keydown and keyup, so you'll need to use an if statement testing `record->event.pressed` (see keymap_default.c).
```c
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) // this is the function signature -- just copy/paste it into your keymap file as it is.
{
switch(id) {
case 0: // this would trigger when you hit a key mapped as M(0)
if (record->event.pressed) {
return MACRO( I(255), T(H), T(E), T(L), T(L), W(255), T(O), END ); // this sends the string 'hello' when the macro executes
}
break;
}
return MACRO_NONE;
};
```
A macro can include the following commands:
* I() change interval of stroke in milliseconds.
* D() press key.
* U() release key.
* T() type key(press and release).
* W() wait (milliseconds).
* END end mark.
So above you can see the stroke interval changed to 255ms between each keystroke, then a bunch of keys being typed, waits a while, then the macro ends.
Note: Using macros to have your keyboard send passwords for you is a bad idea.
### Additional keycode aliases for software-implemented layouts (Colemak, Dvorak, etc)
Everything is assuming you're in Qwerty (in software) by default, but there is built-in support for using a Colemak or Dvorak layout by including this at the top of your keymap:
#include "keymap_<layout>.h"
Where <layout> is "colemak" or "dvorak". After including this line, you will get access to:
* `CM_*` for all of the Colemak-equivalent characters
* `DV_*` for all of the Dvorak-equivalent characters
These implementations assume you're using Colemak or Dvorak on your OS, not on your keyboard - this is referred to as a software-implemented layout. If your computer is in Qwerty and your keymap is in Colemak or Dvorak, this is referred to as a firmware-implemented layout, and you won't need these features.
To give an example, if you're using software-implemented Colemak, and want to get an `F`, you would use `CM_F` - `KC_F` under these same circumstances would result in `T`.
## Additional language support
In `quantum/keymap_extras/`, you'll see various language files - these work the same way as the alternative layout ones do. Most are defined by their two letter country/language code followed by an underscore and a 4-letter abbreviation of its name. `FR_UGRV` which will result in a `ù` when using a software-implemented AZERTY layout. It's currently difficult to send such characters in just the firmware (but it's being worked on - see Unicode support).
## Unicode support
You can currently send 4 hex digits with your OS-specific modifier key (RALT for OSX with the "Unicode Hex Input" layout) - this is currently limited to supporting one OS at a time, and requires a recompile for switching. 8 digit hex codes are being worked on. The keycode function is `UC(n)`, where *n* is a 4 digit hexidecimal. Enable from the Makefile.
## Other firmware shortcut keycodes
* `RESET` - puts the MCU in DFU mode for flashing new firmware (with `make dfu`)
* `DEBUG` - the firmware into debug mode - you'll need hid_listen to see things
* `BL_ON` - turns the backlight on
* `BL_OFF` - turns the backlight off
* `BL_<n>` - sets the backlight to level *n*
* `BL_INC` - increments the backlight level by one
* `BL_DEC` - decrements the backlight level by one
* `BL_TOGG` - toggles the backlight
* `BL_STEP` - steps through the backlight levels
Enable the backlight from the Makefile.
## MIDI functionalty
This is still a WIP, but check out `quantum/keymap_midi.c` to see what's happening. Enable from the Makefile.
## Bluetooth functionality
This requires [some hardware changes](https://www.reddit.com/r/MechanicalKeyboards/comments/3psx0q/the_planck_keyboard_with_bluetooth_guide_and/?ref=search_posts), but can be enabled via the Makefile. The firmware will still output characters via USB, so be aware of this when charging via a computer. It would make sense to have a switch on the Bluefruit to turn it off at will.
## Building
Download or clone the whole firmware and navigate to the keyboard/planck folder. Once your dev env is setup, you'll be able to type `make` to generate your .hex - you can then use `make dfu` to program your PCB once you hit the reset button.
Depending on which keymap you would like to use, you will have to compile slightly differently.
### Default
To build with the default keymap, simply run `make`.
### Other Keymaps
Several version of keymap are available in advance but you are recommended to define your favorite layout yourself. To define your own keymap create a file in the keymaps folder named `<name>.c` and see keymap document (you can find in top README.md) and existent keymap files.
To build the firmware binary hex file with a keymap just do `make` with `KEYMAP` option like:
```
$ make KEYMAP=[default|jack|<name>]
```
Keymaps follow the format **__\<name\>.c__** and are stored in the `keymaps` folder.

@ -1,71 +0,0 @@
/*
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/>.
*/
#ifndef CONFIG_H
#define CONFIG_H
#include "config_common.h"
/* USB Device descriptor parameter */
#define VENDOR_ID 0xFEED
#define PRODUCT_ID 0xCAFE
#define DEVICE_VER 0x0104
#define MANUFACTURER q.m.k
#define PRODUCT HHKB mod
#define DESCRIPTION q.m.k keyboard firmware for HHKB
/* key matrix size */
#define MATRIX_ROWS 8
#define MATRIX_COLS 8
#define TAPPING_TERM 200
/* number of backlight levels */
#define BACKLIGHT_LEVELS 3
/* Set 0 if debouncing isn't needed */
#define DEBOUNCE 5
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
//#define LOCKING_SUPPORT_ENABLE
/* Locking resynchronize hack */
//#define LOCKING_RESYNC_ENABLE
/* key combination for command */
#define IS_COMMAND() ( \
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
)
/*
* 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
#endif

@ -1,167 +0,0 @@
#ifndef HHKB_AVR_H
#define HHKB_AVR_H
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
// Timer resolution check
#if (1000000/TIMER_RAW_FREQ > 20)
# error "Timer resolution(>20us) is not enough for HHKB matrix scan tweak on V-USB."
#endif
/*
* HHKB Matrix I/O
*
* row: HC4051[A,B,C] selects scan row0-7
* row-ext: [En0,En1] row extention for JP
* col: LS145[A,B,C,D] selects scan col0-7 and enable(D)
* key: on: 0/off: 1
* prev: hysteresis control: assert(1) when previous key state is on
*/
#if defined(__AVR_ATmega32U4__)
/*
* For TMK HHKB alt controller(ATMega32U4)
*
* row: PB0-2
* col: PB3-5,6
* key: PD7(pull-uped)
* prev: PB7
* power: PD4(L:off/H:on)
* row-ext: PC6,7 for HHKB JP(active low)
*/
static inline void KEY_ENABLE(void) { (PORTB &= ~(1<<6)); }
static inline void KEY_UNABLE(void) { (PORTB |= (1<<6)); }
static inline bool KEY_STATE(void) { return (PIND & (1<<7)); }
static inline void KEY_PREV_ON(void) { (PORTB |= (1<<7)); }
static inline void KEY_PREV_OFF(void) { (PORTB &= ~(1<<7)); }
#ifdef HHKB_POWER_SAVING
static inline void KEY_POWER_ON(void) {
DDRB = 0xFF; PORTB = 0x40; // change pins output
DDRD |= (1<<4); PORTD |= (1<<4); // MOS FET switch on
/* Without this wait you will miss or get false key events. */
_delay_ms(5); // wait for powering up
}
static inline void KEY_POWER_OFF(void) {
/* input with pull-up consumes less than without it when pin is open. */
DDRB = 0x00; PORTB = 0xFF; // change pins input with pull-up
DDRD |= (1<<4); PORTD &= ~(1<<4); // MOS FET switch off
}
static inline bool KEY_POWER_STATE(void) { return PORTD & (1<<4); }
#else
static inline void KEY_POWER_ON(void) {}
static inline void KEY_POWER_OFF(void) {}
static inline bool KEY_POWER_STATE(void) { return true; }
#endif
static inline void KEY_INIT(void)
{
/* row,col,prev: output */
DDRB = 0xFF;
PORTB = 0x40; // unable
/* key: input with pull-up */
DDRD &= ~0x80;
PORTD |= 0x80;
#ifdef HHKB_JP
/* row extention for HHKB JP */
DDRC |= (1<<6|1<<7);
PORTC |= (1<<6|1<<7);
#endif
KEY_UNABLE();
KEY_PREV_OFF();
KEY_POWER_OFF();
}
static inline void KEY_SELECT(uint8_t ROW, uint8_t COL)
{
PORTB = (PORTB & 0xC0) | (((COL) & 0x07)<<3) | ((ROW) & 0x07);
#ifdef HHKB_JP
if ((ROW) & 0x08) PORTC = (PORTC & ~(1<<6|1<<7)) | (1<<6);
else PORTC = (PORTC & ~(1<<6|1<<7)) | (1<<7);
#endif
}
#elif defined(__AVR_AT90USB1286__)
/*
* For Teensy++(AT90USB1286)
*
* HHKB pro HHKB pro2
* row: PB0-2 (6-8) (5-7)
* col: PB3-5,6 (9-12) (8-11)
* key: PE6(pull-uped) (4) (3)
* prev: PE7 (5) (4)
*
* TODO: convert into 'staitc inline' function
*/
#define KEY_INIT() do { \
DDRB |= 0x7F; \
DDRE |= (1<<7); \
DDRE &= ~(1<<6); \
PORTE |= (1<<6); \
} while (0)
#define KEY_SELECT(ROW, COL) (PORTB = (PORTB & 0xC0) | \
(((COL) & 0x07)<<3) | \
((ROW) & 0x07))
#define KEY_ENABLE() (PORTB &= ~(1<<6))
#define KEY_UNABLE() (PORTB |= (1<<6))
#define KEY_STATE() (PINE & (1<<6))
#define KEY_PREV_ON() (PORTE |= (1<<7))
#define KEY_PREV_OFF() (PORTE &= ~(1<<7))
#define KEY_POWER_ON()
#define KEY_POWER_OFF()
#define KEY_POWER_STATE() true
#else
# error "define code for matrix scan"
#endif
#if 0
// For ATMega328P with V-USB
//
// #elif defined(__AVR_ATmega328P__)
// Ports for V-USB
// key: PB0(pull-uped)
// prev: PB1
// row: PB2-4
// col: PC0-2,3
// power: PB5(Low:on/Hi-z:off)
#define KEY_INIT() do { \
DDRB |= 0x3E; \
DDRB &= ~(1<<0); \
PORTB |= 1<<0; \
DDRC |= 0x0F; \
KEY_UNABLE(); \
KEY_PREV_OFF(); \
} while (0)
#define KEY_SELECT(ROW, COL) do { \
PORTB = (PORTB & 0xE3) | ((ROW) & 0x07)<<2; \
PORTC = (PORTC & 0xF8) | ((COL) & 0x07); \
} while (0)
#define KEY_ENABLE() (PORTC &= ~(1<<3))
#define KEY_UNABLE() (PORTC |= (1<<3))
#define KEY_STATE() (PINB & (1<<0))
#define KEY_PREV_ON() (PORTB |= (1<<1))
#define KEY_PREV_OFF() (PORTB &= ~(1<<1))
// Power supply switching
#define KEY_POWER_ON() do { \
KEY_INIT(); \
PORTB &= ~(1<<5); \
_delay_ms(1); \
} while (0)
#define KEY_POWER_OFF() do { \
DDRB &= ~0x3F; \
PORTB &= ~0x3F; \
DDRC &= ~0x0F; \
PORTC &= ~0x0F; \
} while (0)
#endif
#endif

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

Loading…
Cancel
Save