(intermediate checkin)

partial-rewrite
Ben Blazak 2013-01-27 00:00:47 -08:00
parent 35bfca3662
commit 94e18d611d
25 changed files with 673 additions and 609 deletions

View File

@ -1,14 +1,8 @@
# The MIT License
Retrieved from <http://www.opensource.org/licenses/MIT> on 2012-03-10
This copyright and licence apply to all files in this project, except where
otherwise noted. If you feel that this infringes on any existing intellectual
property, please email me at the address below.
-------------------------------------------------------------------------------
Copyright &copy; 2012, 2013 Ben Blazak <benblazak.dev@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to

View File

@ -49,7 +49,7 @@ void kb__led__set (uint8_t led, float n);
// -------
void kb__led__all_on (void);
void kb__led__all_off (void);
void kb__led__all_set (float n);
void kb__led__all_set (float percent);
// -------
void kb__led__state__power_on (void);
void kb__led__state__ready (void);
@ -59,10 +59,10 @@ void kb__led__delay__usb_init (void);
void kb__led__logical_on (char led);
void kb__led__logical_off (char led);
// -------
void kb__layout__exec_key ( bool pressed,
uint8_t layer,
uint8_t row,
uint8_t column );
uint8_t kb__layout__exec_key ( bool pressed,
uint8_t layer,
uint8_t row,
uint8_t column );
// ----------------------------------------------------------------------------
@ -70,33 +70,37 @@ void kb__layout__exec_key ( bool pressed,
#endif // ERGODOX_FIRMWARE__FIRMWARE__KEYBOARD__H
// ============================================================================
// === documentation ==========================================================
// ============================================================================
// ----------------------------------------------------------------------------
// macros ---------------------------------------------------------------------
// ----------------------------------------------------------------------------
// === KB__ROWS ===
/* macros/KB__ROWS/description
/** macros/KB__ROWS/description
* The number of rows in a given keyboard's matrix
*/
// === KB__COLUMNS ===
/* macros/KB__COLUMNS/description
/** macros/KB__COLUMNS/description
* The number of columns in a given keyboard's matrix
*/
// ----------------------------------------------------------------------------
// functions ------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// controller -----------------------------------------------------------------
// === kb__init() ===
/* functions/kb__init/description
/** functions/kb__init/description
* Initialize the keyboard.
*
* Returns:
@ -108,7 +112,7 @@ void kb__layout__exec_key ( bool pressed,
*/
// === kb__update_matrix() ===
/* functions/kb__update_matrix/description
/** functions/kb__update_matrix/description
* Update the given matrix to the current state of the keyboard.
*
* Arguments:
@ -119,142 +123,146 @@ void kb__layout__exec_key ( bool pressed,
* - failure: [other]
*/
// ----------------------------------------------------------------------------
// LED ------------------------------------------------------------------------
// === kb__led__on() ===
/** functions/kb__led__on/description
* Set the given LED 'on'.
*
* Arguments:
* - `led`: The number of the LED to set. Should be an integer between 1 and 5
* inclusive; behavior is undefined otherwise.
*
* Notes:
* - For US keyboards, likely only LEDs 1 through 3 will be physically present;
* but the function should handle 4 through 5 gracefully anyway.
*/
// === kb__led__off() ===
/** functions/kb__led__off/description
* Set the given LED 'off'.
*
* Arguments:
* - `led`: The number of the LED to set. Should be an integer between 1 and 5
* inclusive; behavior is undefined otherwise.
*
* Notes:
* - For US keyboards, likely only LEDs 1 through 3 will be physically present;
* but the function should handle 4 through 5 gracefully anyway.
*/
// === kb__led__set() ===
/** functions/kb__led__set/description
* Set the given LED's brightness (by percent).
*
* Arguments:
* - `led`: The number of the LED to set. Should be an integer between 1 and 5
* inclusive; behavior is undefined otherwise.
* - `percent`: The percent of the highest possible brightness at which to set
* the LED. Should be a float between 0 and 1 inclusive; behavior is
* undefined otherwise.
*
* Notes:
* - For US keyboards, likely only LEDs 1 through 3 will be physically present;
* but the function should handle 4 through 5 gracefully anyway.
*/
// ----------------------------------------------------------------------------
// === kb__led__all_on() ===
/** functions/kb__led__all_on/description
* Set all the LEDs 'on'.
*/
// === kb__led__all_off() ===
/** functions/kb__led__all_off/description
* Set all the LEDs 'off'.
*/
// === kb__led__all_set() ===
/** functions/kb__led__all_set/description
* Set all the LEDs' brightness (by percent).
*
* Arguments:
* - `percent`: The percent of the highest possible brightness at which to set
* the LED. Should be a float between 0 and 1 inclusive; behavior is
* undefined otherwise.
*/
// ----------------------------------------------------------------------------
// === kb__led__state__power_on() ===
/** functions/kb__led__state__power_on/description
* Set the LEDs to the state that indicates the keyboard just powered on.
*/
// === kb__led__state__ready() ===
/** functions/kb__led__state__ready/description
* Set the LEDs to the state that indicates the keyboard is ready to receive
* keystrokes.
*/
// === kb__led__delay__usb_init() ===
/** functions/kb__led__delay__usb_init/description
* Delay for a total of ~1 second, to allow the host to load drivers and such.
*/
// ----------------------------------------------------------------------------
// layout ---------------------------------------------------------------------
// === kb__led__logical_on ===
/** functions/kb__led__logical_on/description
* Set LEDs 'on' based ontheir meaning (e.g. 'numlock', 'capslock').
*
* Arguments:
* - `led`:
* - `N`: numlock
* - `C`: capslock
* - `S`: scroll lock
* - `O`: compose
* - `K`: kana
*/
// TODO: rewrite, coz of changes
/** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# documentation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// === kb__led__logical_off ===
/** functions/kb__led__logical_off/description
* Set LEDs 'off' based ontheir meaning (e.g. 'numlock', 'capslock').
*
* Arguments:
* - `led`:
* - `N`: numlock
* - `C`: capslock
* - `S`: scroll lock
* - `O`: compose
* - `K`: kana
*/
# controller ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-
// ----------------------------------------------------------------------------
# LED ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--
- .ignore:
- &kb__led___int8_t__led
type: '`int8_t`'
name: '`led`'
description:
The number of the LED to set. Should an integer between 1 and 5
inclusive; behavior is undefined otherwise.
notes:
- For US keyboards, likely only LEDs 1 through 3 will be present. But
the function should handle 4 through 5 gracefully anyway.
- &kb__led___float__n
type: '`float`'
name: '`n`'
description:
The percent of the highest possible brightness at which to set the
LED. Should be a float between 0 and 1 inclusive; behavior is
undefined otherwise.
# ~~~~~~~
- function:
name: '`kb__led__on`'
description: Set the given LED 'on'.
arguments:
- *kb__led___int8_t__led
- function:
name: '`kb__led__off`'
description: Set the given LED 'off'.
arguments:
- *kb__led___int8_t__led
- function:
name: '`kb__led__set`'
description: Set the given LED's brightness (by percent).
arguments:
- *kb__led___int8_t__led
- *kb__led___float__n
# ~~~~~~~
- function:
name: '`kb__led__all_on`'
description: Set all the LEDs 'on'.
- function:
name: '`kb__led__all_off`'
description: Set all the LEDs 'off'.
- function:
name: '`kb__led__all_set`'
description: Set all the LEDs brightness (by percent).
arguments:
- *kb__led___float__n
# ~~~~~~~
- function:
name: '`kb__led__state__power_on`'
description:
Set the LEDs to the state that indicates the keyboard just powered on.
- function:
name: '`kb__led__state__ready`'
description:
Set the LEDs to the state that indicates the keyboard is ready to
receive keystrokes.
- function:
name: '`kb__led__delay__usb_init`'
description:
Delay for a total of ~1 second, to allow the host to load drivers and
such.
# layout ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--
- .ignore:
- &kb__led__logical___arguments
- type: '`char`'
name: '`led`'
values:
- { name: '`N`', description: numlock }
- { name: '`C`', description: capslock }
- { name: '`S`', description: scroll lock }
- { name: '`O`', description: compose }
- { name: '`K`', description: kana }
# ~~~~~~~
- function:
name: '`kb__led__logical_on`'
description:
Set LEDs on based on their meaning (e.g. 'numlock', 'capslock').
arguments: *kb__led__logical___arguments
- function:
name: '`kb__led__logical_off`'
description:
Set LEDs off based on their meaning (e.g. 'numlock', 'capslock').
arguments: *kb__led__logical___arguments
# ~~~~~~~
- function:
name: '`kb__layout__get_key`'
description:
Look up and return the contents of the layout matrix at the given
point.
arguments:
- { type: '`uint8_t`', name: '`layer`' }
- { type: '`uint8_t`', name: '`row`' }
- { type: '`uint8_t`', name: '`column`' }
return value:
type: '`kb__key_t`'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ **/
// === kb__layout__exec_key ===
/** functions/kb__layout__exec_key/description
* Perform the appropriate actions for a "press" or "release" of the key at the
* given position.
*
* Arguments:
* - `pressed`:
* - `true`: Indicates that the key to be "executed" has been pressed
* - `false`: Indicates that the key to be "executed" has been released
* - `layer`: The layer of the key to be "executed"
* - `row`: The row of the key to be "executed"
* - `column`: The column of the key to be "executed"
*
* Returns:
* - success: The layer of the key that was "executed"; this should be passed
* back by `main()` as `layer` when the key at the same `[row][column]` is
* released.
*
* Notes:
* - This function is responsible for quite a bit of a keyboard's apparent
* functionality. It needs to be implemented at this level in order to hide
* the actual representation of keys, where they are stored, etc. from
* `main()`.
*/

View File

@ -4,7 +4,7 @@
* Project located at <https://github.com/benblazak/ergodox-firmware>
* ------------------------------------------------------------------------- */
/*
/** description
* Implements the "controller" section of '.../firmware/keyboard.h'
*/
@ -17,9 +17,10 @@
// ----------------------------------------------------------------------------
/* returns
* - success: 0
* - error: number of the function that failed
/** functions/kb__init/description
* Returns:
* - success: `0`
* - failure: the number of the function that failed
*/
uint8_t kb__init(void) {
if (teensy__init()) // must be first (to initialize twi, and such)
@ -30,9 +31,10 @@ uint8_t kb__init(void) {
return 0; // success
}
/* returns
* - success: 0
* - error: number of the function that failed
/** functions/kb__update_matrix/description
* Returns:
* - success: `0`
* - failure: number of the function that failed
*/
uint8_t kb__update_matrix(bool matrix[KB__ROWS][KB__COLUMNS]) {
if (teensy__update_matrix(matrix))

View File

@ -4,7 +4,7 @@
* Project located at <https://github.com/benblazak/ergodox-firmware>
* ------------------------------------------------------------------------- */
/*
/** description
* MCP23018 (driven by Teensy 2.0 over TWI) specific code, helping to implement
* the "controller" section of '.../firmware/keyboard.h'
*/
@ -22,6 +22,11 @@
#error "Expecting different keyboard dimensions"
#endif
#if ( OPT__MCP23018__DRIVE_ROWS && OPT__MCP23018__DRIVE_COLUMNS ) \
|| !( OPT__MCP23018__DRIVE_ROWS || OPT__MCP23018__DRIVE_COLUMNS )
#error "MCP23018 pin drive direction incorrectly set"
#endif
// ----------------------------------------------------------------------------
// register addresses (see "mcp23018.md")
@ -41,11 +46,12 @@
// ----------------------------------------------------------------------------
/* returns:
* - success: 0
/** functions/mcp23018__init/description
* Returns:
* - success: `0`
* - failure: twi status code
*
* notes:
* Notes:
* - `twi__stop()` must be called *exactly once* for each twi block, the way
* things are currently set up. this may change in the future.
*/
@ -60,10 +66,10 @@ uint8_t mcp23018__init(void) {
ret = twi__send(TWI_ADDR_WRITE);
if (ret) goto out; // make sure we got an ACK
twi__send(IODIRA);
#if MAKE__MCP23018__DRIVE_ROWS
#if OPT__MCP23018__DRIVE_ROWS
twi__send(0b11111111); // IODIRA
twi__send(0b11000000); // IODIRB
#elif MAKE__MCP23018__DRIVE_COLUMNS
#elif OPT__MCP23018__DRIVE_COLUMNS
twi__send(0b10000000); // IODIRA
twi__send(0b11111111); // IODIRB
#endif
@ -77,10 +83,10 @@ uint8_t mcp23018__init(void) {
ret = twi__send(TWI_ADDR_WRITE);
if (ret) goto out; // make sure we got an ACK
twi__send(GPPUA);
#if MAKE__MCP23018__DRIVE_ROWS
#if OPT__MCP23018__DRIVE_ROWS
twi__send(0b11111111); // GPPUA
twi__send(0b11000000); // GPPUB
#elif MAKE__MCP23018__DRIVE_COLUMNS
#elif OPT__MCP23018__DRIVE_COLUMNS
twi__send(0b10000000); // GPPUA
twi__send(0b11111111); // GPPUB
#endif
@ -102,8 +108,9 @@ out:
return ret;
}
/* returns:
* - success: 0
/** functions/mcp23018__update_matrix/description
* Returns:
* - success: `0`
* - failure: twi status code
*/
uint8_t mcp23018__update_matrix(bool matrix[KB__ROWS][KB__COLUMNS]) {
@ -127,7 +134,7 @@ uint8_t mcp23018__update_matrix(bool matrix[KB__ROWS][KB__COLUMNS]) {
// update our part of the matrix ..........................................
#if MAKE__MCP23018__DRIVE_ROWS
#if OPT__MCP23018__DRIVE_ROWS
for (uint8_t row=0; row<=5; row++) {
// set active row low : 0
// set other rows hi-Z : 1
@ -159,7 +166,7 @@ uint8_t mcp23018__update_matrix(bool matrix[KB__ROWS][KB__COLUMNS]) {
twi__send(0xFF);
twi__stop();
#elif MAKE__MCP23018__DRIVE_COLUMNS
#elif OPT__MCP23018__DRIVE_COLUMNS
for (uint8_t col=0; col<=6; col++) {
// set active column low : 0
// set other columns hi-Z : 1

View File

@ -4,7 +4,7 @@
* Project located at <https://github.com/benblazak/ergodox-firmware>
* ------------------------------------------------------------------------- */
/*
/** description
* For inclusion by '../controller.c'
*/

View File

@ -4,7 +4,7 @@
* Project located at <https://github.com/benblazak/ergodox-firmware>
* ------------------------------------------------------------------------- */
/*
/** description
* Teensy 2.0 specific code, helping to implement the "controller" section of
* '.../firmware/keyboard.h'
*/
@ -27,6 +27,11 @@
#error "Expecting different keyboard dimensions"
#endif
#if ( OPT__TEENSY__DRIVE_ROWS && OPT__TEENSY__DRIVE_COLUMNS ) \
|| !( OPT__TEENSY__DRIVE_ROWS || OPT__TEENSY__DRIVE_COLUMNS )
#error "Teensy pin drive direction incorrectly set"
#endif
// ----------------------------------------------------------------------------
// processor frequency (from <http://www.pjrc.com/teensy/prescaler.html>)
@ -162,9 +167,9 @@
// ----------------------------------------------------------------------------
/*
* returns
* - success: 0
/** functions/teensy__init/description
* Returns
* - success: `0`
*/
uint8_t teensy__init(void) {
// CPU speed : should match F_CPU in makefile
@ -194,10 +199,10 @@ uint8_t teensy__init(void) {
// rows and columns
teensypin_write_all_row(DDR, CLEAR); // set as input (hi-Z)
teensypin_write_all_column(DDR, CLEAR); // set as input (hi-Z)
#if MAKE__TEENSY__DRIVE_ROWS
#if OPT__TEENSY__DRIVE_ROWS
teensypin_write_all_row(PORT, CLEAR); // pull-up disabled
teensypin_write_all_column(PORT, SET); // pull-up enabled
#elif MAKE__TEENSY__DRIVE_COLUMNS
#elif OPT__TEENSY__DRIVE_COLUMNS
teensypin_write_all_row(PORT, SET); // pull-up enabled
teensypin_write_all_column(PORT, CLEAR); // pull-up disabled
#endif
@ -205,19 +210,19 @@ uint8_t teensy__init(void) {
return 0; // success
}
/*
* returns
* - success: 0
/** functions/teensy__update_matrix/description
* Returns:
* - success: `0`
*/
uint8_t teensy__update_matrix(bool matrix[KB__ROWS][KB__COLUMNS]) {
#if MAKE__TEENSY__DRIVE_ROWS
#if OPT__TEENSY__DRIVE_ROWS
update_columns_for_row(matrix, 0);
update_columns_for_row(matrix, 1);
update_columns_for_row(matrix, 2);
update_columns_for_row(matrix, 3);
update_columns_for_row(matrix, 4);
update_columns_for_row(matrix, 5);
#elif MAKE__TEENSY__DRIVE_COLUMNS
#elif OPT__TEENSY__DRIVE_COLUMNS
update_rows_for_column(matrix, 7);
update_rows_for_column(matrix, 8);
update_rows_for_column(matrix, 9);

View File

@ -4,7 +4,7 @@
* Project located at <https://github.com/benblazak/ergodox-firmware>
* ------------------------------------------------------------------------- */
/*
/** description
* For inclusion by '../controller.c'
*/

View File

@ -4,21 +4,20 @@
* Project located at <https://github.com/benblazak/ergodox-firmware>
* ------------------------------------------------------------------------- */
/**
* - description: |
* A Colemak layout (modified from the Kinesis layout).
/** description
* A Colemak layout (modified from the Kinesis layout).
*
* Implements the "layout" section of '.../firmware/keyboard.h'
* Implements the "layout" section of '.../firmware/keyboard.h'
*
* Notes:
* * This layout *does not* contain a key mapped to the bootloader function.
* To reflash from this layout, you will need to physically press the
* button on the top right of the Teensy.
* Notes:
* - This layout *does not* contain a key mapped to the bootloader function.
* To reflash from this layout, you will need to physically press the button
* on the top right of the Teensy.
*
* History:
* * Originally submitted by Jason Trill [jjt] (https://github.com/jjt) (who
* declined to be added to the copyright above).
* * Transcribed by Ben Blazak when the layout format changed.
* History:
* - Originally submitted by Jason Trill [jjt] (https://github.com/jjt) (who
* declined to be added to the copyright above).
* - Transcribed by Ben Blazak when the layout format changed.
*
*/
@ -66,10 +65,10 @@ void kb__led__logical_off(char led) {
#include "./default/keys.h"
// layer
key_t L0pu1po = { &kf__layer__push, 0x0001, &kf__layer__pop, 0x00 };
key_t L1pu2 = { &kf__layer__push, 0x0102, NULL, 0 };
key_t L1po = { &kf__layer__pop, 0x01, NULL, 0 };
key_t L1pu2po = { &kf__layer__push, 0x0102, &kf__layer__pop, 0x01 };
key_t L0pu1po = { &kf__layer__push, 0x0001, &kf__layer__pop, 0x0001 };
key_t L1pu2 = { &kf__layer__push, 0x0102, NULL, 0 };
key_t L1po = { &kf__layer__pop, 0x0100, NULL, 0 };
key_t L1pu2po = { &kf__layer__push, 0x0102, &kf__layer__pop, 0x0102 };
// --- NumPush
const uint16_t PROGMEM NumPush__press[] = {
@ -80,7 +79,7 @@ key_t NumPush = { &kf__macro__progmem, &NumPush__press,
// --- NumPop
const uint16_t PROGMEM NumPop__press[] = {
2, &kf__layer__pop, 0x02,
2, &kf__layer__pop, 0x0203,
&kf__press, KEY__LockingNumLock };
key_t NumPop = { &kf__macro__progmem, &NumPop__press,
&kf__release, KEY__LockingNumLock };
@ -91,7 +90,7 @@ const uint16_t PROGMEM NumPuPo__press[] = {
&kf__press, KEY__LockingNumLock,
&kf__release, KEY__LockingNumLock };
const uint16_t PROGMEM NumPuPo__release[] = {
3, &kf__layer__pop, 0x02,
3, &kf__layer__pop, 0x0203,
&kf__press, KEY__LockingNumLock,
&kf__release, KEY__LockingNumLock };
key_t NumPuPo = { &kf__macro__progmem, &NumPuPo__press,
@ -193,7 +192,7 @@ NA,
Transp, Transp, Transp,
Transp, Transp, Transp,
// right hand ..... ......... ......... ......... ......... ......... .........
NumPop, Transp, NumPop, Equal, KPDiv, KPMul,
NumPop, Transp, NumPop, Equal, KPDiv, KPMul, Transp,
Transp, Transp, KP7, KP8, KP9, KPSub, Transp,
Transp, KP4, KP5, KP6, KPAdd, Transp,
Transp, Transp, KP1, KP2, KP3, KPEnter, Transp,

View File

@ -10,8 +10,8 @@
*/
#ifndef ERGODOX_FIRMWARE__KEYBOARD__ERGODOX__LAYOUT__DEFAULT__COMMON_H
#define ERGODOX_FIRMWARE__KEYBOARD__ERGODOX__LAYOUT__DEFAULT__COMMON_H
#ifndef ERGODOX_FIRMWARE__KEYBOARD__ERGODOX__LAYOUT__DEFAULT__COMMON__H
#define ERGODOX_FIRMWARE__KEYBOARD__ERGODOX__LAYOUT__DEFAULT__COMMON__H
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
@ -27,17 +27,17 @@
// ----------------------------------------------------------------------------
struct key_t {
typedef struct {
kf__function_pointer_t press_function;
uint16_t press_value;
kf__function_pointer_t release_function;
uint16_t release_value;
};
} key_t;
typedef const struct key_t * const PROGMEM key_t
#define KEY_T const key_t * const PROGMEM
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
#endif // ERGODOX_FIRMWARE__KEYBOARD__ERGODOX__LAYOUT__DEFAULT__COMMON_H
#endif // ERGODOX_FIRMWARE__KEYBOARD__ERGODOX__LAYOUT__DEFAULT__COMMON__H

View File

@ -4,25 +4,25 @@
* Project located at <https://github.com/benblazak/ergodox-firmware>
* ------------------------------------------------------------------------- */
/**
* - description: |
* A default way to execute keys. Meant to be included by the layout using
* it (and nowhere else, since it's actual code).
/** description
* A default way to execute keys. Meant to be included by the layout using it
* (and nowhere else, since it's actual code).
*
* Note: This oddish setup is used to allow layouts to easily change some
* default things without having to deal with all of them.
* Notes:
* - This oddish setup is used to allow layouts to easily change some default
* things without having to deal with all of them.
*/
#ifndef ERGODOX_FIRMWARE__KEYBOARD__ERGODOX__LAYOUT__DEFAULT__EXEC_KEY_C_H
#define ERGODOX_FIRMWARE__KEYBOARD__ERGODOX__LAYOUT__DEFAULT__EXEC_KEY_C_H
#ifndef ERGODOX_FIRMWARE__KEYBOARD__ERGODOX__LAYOUT__DEFAULT__EXEC_KEY__C__H
#define ERGODOX_FIRMWARE__KEYBOARD__ERGODOX__LAYOUT__DEFAULT__EXEC_KEY__C__H
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
#include "./common.h"
extern key_t layout[][KB__ROWS][KB__COLUMNS];
extern KEY_T layout[][KB__ROWS][KB__COLUMNS];
// ----------------------------------------------------------------------------
@ -44,5 +44,5 @@ void kb__layout__exec_key( bool pressed,
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
#endif // ERGODOX_FIRMWARE__KEYBOARD__ERGODOX__LAYOUT__DEFAULT__EXEC_KEY_C_H
#endif // ERGODOX_FIRMWARE__KEYBOARD__ERGODOX__LAYOUT__DEFAULT__EXEC_KEY__C__H

View File

@ -4,15 +4,14 @@
* Project located at <https://github.com/benblazak/ergodox-firmware>
* ------------------------------------------------------------------------- */
/**
* - description: |
* Extended (from the definitions in ".../lib/layout/keys.h") default key
* definitions. Feel free not to use them, if they're not convenient.
/** description
* Extended (from the definitions in ".../lib/layout/keys.h") default key
* definitions. Feel free not to use them, if they're not convenient.
*/
#ifndef ERGODOX_FIRMWARE__KEYBOARD__ERGODOX__LAYOUT__DEFAULT__KEYS_H
#define ERGODOX_FIRMWARE__KEYBOARD__ERGODOX__LAYOUT__DEFAULT__KEYS_H
#ifndef ERGODOX_FIRMWARE__KEYBOARD__ERGODOX__LAYOUT__DEFAULT__KEYS__H
#define ERGODOX_FIRMWARE__KEYBOARD__ERGODOX__LAYOUT__DEFAULT__KEYS__H
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
@ -24,7 +23,7 @@
// `keys__` macros (needed by ".../lib/layout/keys.h")
#define KEYS__DEFAULT(name, value) \
key_t name = { \
KEY_T name = { \
.press_function = &kf__press, \
.press_value = value, \
.release_function = &kf__release, \
@ -37,7 +36,7 @@
const uint16_t PROGMEM name##__release[] = { \
2, &kf__release, KEY__LeftShift, \
&kf__release, value }; \
key_t name = { &kf__macro__progmem, &name##__press, \
KEY_T name = { &kf__macro__progmem, &name##__press, \
&kf__macro__progmem, &name##__release }
@ -50,7 +49,7 @@
const uint16_t PROGMEM name##__release[] = { \
2, &kf__two_keys_capslock, 0, \
&kf__release, value }; \
key_t name = { &kf__macro__progmem, &name##__press, \
KEY_T name = { &kf__macro__progmem, &name##__press, \
&kf__macro__progmem, &name##release }
// ----------------------------------------------------------------------------
@ -62,8 +61,8 @@
// special meaning
key_t Transp = NULL; // transparent
key_t NA = { NULL, 0, NULL, 0 }; // "not applicable" (do nothing)
KEY_T Transp = NULL; // transparent
KEY_T NA = { NULL, 0, NULL, 0 }; // "not applicable" (do nothing)
// special keycode
@ -83,10 +82,10 @@ KEYS__TWO_KEYS_CAPSLOCK_PRESS_RELEASE( Sh2KCapL, KEY__LeftShift );
KEYS__TWO_KEYS_CAPSLOCK_PRESS_RELEASE( Sh2KCapR, KEY__RightShift );
// --- Btldr
key_t Btldr = { &kf__jump_to_bootloader, 0, NULL, 0 };
KEY_T Btldr = { &kf__jump_to_bootloader, 0, NULL, 0 };
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
#endif // ERGODOX_FIRMWARE__KEYBOARD__ERGODOX__LAYOUT__DEFAULT__KEYS_H
#endif // ERGODOX_FIRMWARE__KEYBOARD__ERGODOX__LAYOUT__DEFAULT__KEYS__H

View File

@ -4,53 +4,47 @@
* Project located at <https://github.com/benblazak/ergodox-firmware>
* ------------------------------------------------------------------------- */
/**
* - description: |
* Information about the matrix
/** description
* Information about the matrix
*/
#ifndef ERGODOX_FIRMWARE__FIRMWARE__KEYBOARD__ERGODOX__LAYOUT__DEFAULT__MATRIX_H
#define ERGODOX_FIRMWARE__FIRMWARE__KEYBOARD__ERGODOX__LAYOUT__DEFAULT__MATRIX_H
#ifndef ERGODOX_FIRMWARE__FIRMWARE__KEYBOARD__ERGODOX__LAYOUT__DEFAULT__MATRIX__H
#define ERGODOX_FIRMWARE__FIRMWARE__KEYBOARD__ERGODOX__LAYOUT__DEFAULT__MATRIX__H
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
/**
* - macro:
* name: '`MATRIX_LAYER`"
* description: |
* Mapping from spatial position to matrix position.
/** macros/MATRIX_LAYER/description
* Mapping from spatial position to matrix position.
*
* - Spatial position: Where the key is spatially, relative to other
* keys, both on the keyboard and in the layout.
* - Matrix position: The coordinate in the matrix to which a key is
* scanned by the update functions.
* - Spatial position: Where the key is spatially, relative to other keys, both
* on the keyboard and in the layout.
* - Matrix position: The coordinate in the matrix to which a key is scanned by
* the update functions.
*
* - Location numbers are in the format `row##column`, where both 'row'
* and 'column' are single digit hex numbers corresponding to the
* matrix position (which also corresponds to the row and column pin
* labels used in the Teensy and MCP23018 files).
* - Location numbers are in the format `row##column`, where both 'row' and
* 'column' are single digit hex numbers corresponding to the matrix position
* (which also corresponds to the row and column pin labels used in the
* Teensy and MCP23018 files).
*
* - Coordinates:
* - optional keys
* k15, k16 (left hand thumb group)
* k17, k18 (right hand thumb group)
* - unused keys
* k36, k00 (left hand)
* k37, k0D (right hand)
* notes:
* - |
* ```
* --- other info -------------------------------------
* rows x columns = positions; used, unused
* per hand: 6 x 7 = 42; 40, 2
* total: 6 x 14 = 84; 80, 4
*
* left hand : rows 0..5, cols 0..6
* right hand : rows 0..5, cols 7..D
* ----------------------------------------------------
* ```
* - Coordinates:
* - optional keys
* - k15, k16 (left hand thumb group)
* - k17, k18 (right hand thumb group)
* - unused keys
* - k36, k00 (left hand)
* - k37, k0D (right hand)
*
* - Other Info:
* ----------------------------------------------------
* rows x columns = positions; used, unused
* per hand: 6 x 7 = 42; 40, 2
* total: 6 x 14 = 84; 80, 4
*
* left hand : rows 0..5, cols 0..6
* right hand : rows 0..5, cols 7..D
* ----------------------------------------------------
*/
#define MATRIX_LAYER( \
/* for unused positions */ \
@ -87,5 +81,5 @@
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
#endif // ERGODOX_FIRMWARE__FIRMWARE__KEYBOARD__ERGODOX__LAYOUT__DEFAULT__MATRIX_H
#endif // ERGODOX_FIRMWARE__FIRMWARE__KEYBOARD__ERGODOX__LAYOUT__DEFAULT__MATRIX__H

View File

@ -4,12 +4,11 @@
* Project located at <https://github.com/benblazak/ergodox-firmware>
* ------------------------------------------------------------------------- */
/**
* - description: |
* A Dvorak layout adapted from the default Kinesis layout. The position of
* the symbol keys on the function layer was taken from the Arensito layout.
/** description
* A Dvorak layout adapted from the default Kinesis layout. The position of
* the symbol keys on the function layer was taken from the Arensito layout.
*
* Implements the "layout" section of '.../firmware/keyboard.h'
* Implements the "layout" section of '.../firmware/keyboard.h'
*/
@ -56,10 +55,10 @@ void kb__led__logical_off(char led) {
#include "./default/keys.h"
// layer
key_t L0pu1 = { &kf__layer__push, 0x0001, NULL, 0 };
key_t L0po = { &kf__layer__pop, 0x00, NULL, 0 };
key_t L0pu1po = { &kf__layer__push, 0x0001, &kf__layer__pop, 0x00 };
key_t L1pu2po = { &kf__layer__push, 0x0102, &kf__layer__pop, 0x01 };
key_t L0pu1 = { &kf__layer__push, 0x0001, NULL, 0 };
key_t L0po = { &kf__layer__pop, 0x0000, NULL, 0 };
key_t L0pu1po = { &kf__layer__push, 0x0001, &kf__layer__pop, 0x0001 };
key_t L1pu2po = { &kf__layer__push, 0x0102, &kf__layer__pop, 0x0102 };
// --- NumPush
const uint16_t PROGMEM NumPush__press[] = {
@ -70,7 +69,7 @@ key_t NumPush = { &kf__macro__progmem, &NumPush__press,
// --- NumPop
const uint16_t PROGMEM NumPop__press[] = {
2, &kf__layer__pop, 0x02,
2, &kf__layer__pop, 0x0203,
&kf__press, KEY__LockingNumLock };
key_t NumPop = { &kf__macro__progmem, &NumPop__press,
&kf__release, KEY__LockingNumLock };
@ -170,7 +169,7 @@ NA,
Transp, Transp, Transp,
Transp, Transp, Transp,
// right hand ..... ......... ......... ......... ......... ......... .........
NumPop, Transp, NumPop, Equal, KPDiv, KPMul,
NumPop, Transp, NumPop, Equal, KPDiv, KPMul, Transp,
Transp, Transp, KP7, KP8, KP9, KPSub, Transp,
Transp, KP4, KP5, KP6, KPAdd, Transp,
Transp, Transp, KP1, KP2, KP3, KPEnter, Transp,

View File

@ -4,12 +4,11 @@
* Project located at <https://github.com/benblazak/ergodox-firmware>
* ------------------------------------------------------------------------- */
/**
* - description: |
* A QWERTY layout adapted from the default Kinesis layout. The position of
* the symbol keys on the function layer was taken from the Arensito layout.
/** description
* A QWERTY layout adapted from the default Kinesis layout. The position of
* the symbol keys on the function layer was taken from the Arensito layout.
*
* Implements the "layout" section of '.../firmware/keyboard.h'
* Implements the "layout" section of '.../firmware/keyboard.h'
*/
@ -56,23 +55,23 @@ void kb__led__logical_off(char led) {
#include "./default/keys.h"
// layer
key_t L0pu1 = { &kf__layer__push, 0x0001, NULL, 0 };
key_t L0po = { &kf__layer__pop, 0x00, NULL, 0 };
key_t L0pu1po = { &kf__layer__push, 0x0001, &kf__layer__pop, 0x00 };
key_t L1pu2po = { &kf__layer__push, 0x0102, &kf__layer__pop, 0x01 };
KEY_T L0pu1 = { &kf__layer__push, 0x0001, NULL, 0 };
KEY_T L0po = { &kf__layer__pop, 0x0000, NULL, 0 };
KEY_T L0pu1po = { &kf__layer__push, 0x0001, &kf__layer__pop, 0x0001 };
KEY_T L1pu2po = { &kf__layer__push, 0x0102, &kf__layer__pop, 0x0102 };
// --- NumPush
const uint16_t PROGMEM NumPush__press[] = {
2, &kf__layer__push, 0x0203,
&kf__press, KEY__LockingNumLock };
key_t NumPush = { &kf__macro__progmem, &NumPush__press,
KEY_T NumPush = { &kf__macro__progmem, &NumPush__press,
&kf__release, KEY__LockingNumLock };
// --- NumPop
const uint16_t PROGMEM NumPop__press[] = {
2, &kf__layer__pop, 0x02,
2, &kf__layer__pop, 0x0203,
&kf__press, KEY__LockingNumLock };
key_t NumPop = { &kf__macro__progmem, &NumPop__press,
KEY_T NumPop = { &kf__macro__progmem, &NumPop__press,
&kf__release, KEY__LockingNumLock };
@ -80,7 +79,7 @@ key_t NumPop = { &kf__macro__progmem, &NumPop__press,
// layout
// ----------------------------------------------------------------------------
key_t layout[][KB__ROWS][KB__COLUMNS] = {
KEY_T layout[][KB__ROWS][KB__COLUMNS] = {
// ............................................................................
@ -170,7 +169,7 @@ NA,
Transp, Transp, Transp,
Transp, Transp, Transp,
// right hand ..... ......... ......... ......... ......... ......... .........
NumPop, Transp, NumPop, Equal, KPDiv, KPMul,
NumPop, Transp, NumPop, Equal, KPDiv, KPMul, Transp,
Transp, Transp, KP7, KP8, KP9, KPSub, Transp,
Transp, KP4, KP5, KP6, KPAdd, Transp,
Transp, Transp, KP1, KP2, KP3, KPEnter, Transp,

View File

@ -4,7 +4,7 @@
* Project located at <https://github.com/benblazak/ergodox-firmware>
* ------------------------------------------------------------------------- */
/*
/** description
* Implements the "LED" section of '.../firmware/keyboard.h'
*
* Code is specific to Teensy 2.0
@ -66,22 +66,22 @@ void kb__led__all_set(float n) {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void kb__led__state__power_on(void) {
kb__led__all_set( MAKE__LED_BRIGHTNESS / 10 );
kb__led__all_set( OPT__LED_BRIGHTNESS / 10 );
kb__led__all_on();
}
void kb__led__state__ready(void) {
kb__led__all_off();
kb__led__all_set( MAKE__LED_BRIGHTNESS );
kb__led__all_set( OPT__LED_BRIGHTNESS );
}
void kb__led__delay__usb_init(void) {
// need to delay for a total of ~1 second
kb__led__set( 1, MAKE__LED_BRIGHTNESS );
kb__led__set( 1, OPT__LED_BRIGHTNESS );
_delay_ms(333);
kb__led__set( 2, MAKE__LED_BRIGHTNESS );
kb__led__set( 2, OPT__LED_BRIGHTNESS );
_delay_ms(333);
kb__led__set( 3, MAKE__LED_BRIGHTNESS );
kb__led__set( 3, OPT__LED_BRIGHTNESS );
_delay_ms(333);
}

View File

@ -1,128 +0,0 @@
# ----------------------------------------------------------------------------
# Copyright (c) 2013 Ben Blazak <benblazak.dev@gmail.com>
# Released under The MIT License (see "doc/license.md")
# Project located at <https://github.com/benblazak/ergodox-firmware>
# ----------------------------------------------------------------------------
## description
# Options, constants, etc. to be included in the toplevel Makefile for the
# ErgoDox keyboard
#
# -----------------------------------------------------------------------------
# variables
# -----------------------------------------------------------------------------
MAKE__LED_BRIGHTNESS := 0.5
# a multiplier, with 1 being the max
MAKE__TEENSY__DRIVE_ROWS := 0
MAKE__TEENSY__DRIVE_COLUMNS := 1
MAKE__MCP23018__DRIVE_ROWS := 0
MAKE__MCP23018__DRIVE_COLUMNS := 1
# .............................................................................
# DRIVE_ROWS and DRIVE_COLUMNS
# .............................................................................
# Select which set of pins will drive (alternate between hi-Z and drive low)
# and which will be inputs (hi-Z)
#
#
# Notes
#
# - You must set exactly one of each 'TEENSY' variable, and one of each
# 'MCP23018' variable, to '1', and the other must be set to '0'
#
# - If you are using internal diodes (inside the key switches), set
# MAKE__TEENSY__DRIVE_COLUMNS := 1
# MAKE__MCP23018__DRIVE_ROWS := 1
#
# - If the diode cathode is towards the square solder pad, set
# MAKE__TEENSY__DRIVE_COLUMNS := 1
# MAKE__MCP23018__DRIVE_COLUMNS := 1
#
# - If the diode cathode is towards the circular solder pad, set
# MAKE__TEENSY__DRIVE_ROWS := 1
# MAKE__MCP23018__DRIVE_ROWS := 1
# .............................................................................
# -----------------------------------------------------------------------------
# constants
# -----------------------------------------------------------------------------
# TODO: move everything to the place it's required; or at least put some
# documentation there (how shall i standardize it? - maybe put defaults, meant
# to be overridden here...)
# required by the makefile ----------------------------------------------------
MCU := atmega32u4
# processor type (for the teensy 2.0)
F_CPU := 16000000
# processor speed, in Hz; max value is 16000000 (16MHz)
# required by the keyboard ----------------------------------------------------
MAKE__TWI_FREQ := 400000
# TWI frequency, in Hz; max value is 400000 (400kHz) (per the Teensy datasheet
# sec 20.1)
MAKE__DEBOUNCE_TIME := 5
# in milliseconds; 5ms should be good for cherry mx switches (per the
# keyswitch spec)
# required by the libraries ---------------------------------------------------
MAKE__USB__STR_MANUFACTURER := L"custom"
MAKE__USB__STR_PRODUCT := L"ErgoDox ergonomic keyboard"
MAKE__USB__VENDOR_ID := 0x1d50 # Openmoko, Inc.
MAKE__USB__PRODUCT_ID := 0x6028 # ErgoDox ergonomic keyboard
# .............................................................................
# USB identifier information
# .............................................................................
# -----------------------------------------------------------------------------
# additions
# -----------------------------------------------------------------------------
SCR += TODO
# -----------------------------------------------------------------------------
# checks
# -----------------------------------------------------------------------------
# DRIVE_ROWS and DRIVE_COLUMNS
ERROR := "see the 'DRIVE_ROWS and DRIVE_COLUMNS' section in '.../firmware/keyboard/ergodox/makefile-options'"
# --- teensy
ifeq($(MAKE__TEENSY__DRIVE_ROWS),1)
ifneq($(MAKE__TEENSY__DRIVE_COLUMNS),0)
$(error $(ERROR))
endif
else
ifeq($(MAKE__TEENSY__DRIVE_ROWS),0)
ifneq($(MAKE__TEENSY__DRIVE_COLUMNS),1)
$(error $(ERROR))
endif
else
$(error $(ERROR))
endif
endif
# --- mcp23018
ifeq($(MAKE__MCP23018__DRIVE_ROWS),1)
ifneq($(MAKE__MCP23018__DRIVE_COLUMNS),0)
$(error $(ERROR))
endif
else
ifeq($(MAKE__MCP23018__DRIVE_ROWS),0)
ifneq($(MAKE__MCP23018__DRIVE_COLUMNS),1)
$(error $(ERROR))
endif
else
$(error $(ERROR))
endif
endif

View File

@ -0,0 +1,113 @@
/* ----------------------------------------------------------------------------
* Copyright (c) 2013 Ben Blazak <benblazak.dev@gmail.com>
* Released under The MIT License (see "doc/license.md")
* Project located at <https://github.com/benblazak/ergodox-firmware>
* ------------------------------------------------------------------------- */
/** description
* A central place for all ErgoDox source-level options
*
* Prefixes: `OPT__`
*
* This file is meant to be globally included on the command line.
*/
#ifndef ERGODOX_FIRMWARE__FIRMWARE__KEYBOARD__ERGODOX__OPTIONS__H
#define ERGODOX_FIRMWARE__FIRMWARE__KEYBOARD__ERGODOX__OPTIONS__H
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// firmware/main
// ----------------------------------------------------------------------------
#define OPT__DEBOUNCE_TIME 5
/** macros/OPT__DEBOUNCE_TIME/description
* in milliseconds; 5ms should be good for cherry mx switches (per the
* keyswitch spec)
*/
// ----------------------------------------------------------------------------
// firmware/keyboard/controller
// ----------------------------------------------------------------------------
#define OPT__TEENSY__DRIVE_ROWS 0
#define OPT__TEENSY__DRIVE_COLUMNS 1
#define OPT__MCP23018__DRIVE_ROWS 0
#define OPT__MCP23018__DRIVE_COLUMNS 1
/** macros/(group) pin drive direction/description
* Select which set of pins will drive (alternate between hi-Z and drive low)
* and which will be inputs (hi-Z)
*
* Members:
* - `OPT__TEENSY__DRIVE_ROWS`
* - `OPT__TEENSY__DRIVE_COLUMNS`
* - `OPT__MCP23018__DRIVE_ROWS`
* - `OPT__MCP23018__DRIVE_COLUMNS`
*
*
* Notes:
*
* - You must set exactly one of each 'TEENSY' variable, and one of each
* 'MCP23018' variable, to '1', and the other must be set to '0'
*
* - If you are using internal diodes (inside the key switches), set
* OPT__TEENSY__DRIVE_COLUMNS := 1
* OPT__MCP23018__DRIVE_ROWS := 1
*
* - If the diode cathode is towards the square solder pad, set
* OPT__TEENSY__DRIVE_COLUMNS := 1
* OPT__MCP23018__DRIVE_COLUMNS := 1
*
* - If the diode cathode is towards the circular solder pad, set
* OPT__TEENSY__DRIVE_ROWS := 1
* OPT__MCP23018__DRIVE_ROWS := 1
*/
// ----------------------------------------------------------------------------
// firmware/keyboard/led
// ----------------------------------------------------------------------------
#define OPT__LED_BRIGHTNESS 0.5
/** macros/MAKE__LED_BRIGHTNESS/description
* a multiplier, with 1 being the max
*/
// ----------------------------------------------------------------------------
// firmware/lib/twi
// ----------------------------------------------------------------------------
#define OPT__TWI_FREQENCY 400000
/** macros/OPT__TWI__FREQENCY/description
* in Hz; max value is 400000 (400kHz) (Teensy datasheet sec 20.1)
*/
// ----------------------------------------------------------------------------
// firmware/lib/from-pjrc/usb_keyboard
// ----------------------------------------------------------------------------
#define OPT__USB__STR_MANUFACTURER L"custom"
#define OPT__USB__STR_PRODUCT L"ErgoDox ergonomic keyboard"
#define OPT__USB__VENDOR_ID 0x1d50 // Openmoko, Inc.
#define OPT__USB__PRODUCT_ID 0x6028 // ErgoDox ergonomic keyboard
/** macros/(group) USB/description
* USB identifier information
*
* Members:
* - `OPT__USB__STR_MANUFACTURER`
* - `OPT__USB__STR_PRODUCT`
* - `OPT__USB__VENDOR_ID`
* - `OPT__USB__PRODUCT_ID`
*/
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
#endif // ERGODOX_FIRMWARE__FIRMWARE__KEYBOARD__ERGODOX__OPTIONS__H

View File

@ -0,0 +1,29 @@
# -----------------------------------------------------------------------------
# Copyright (c) 2013 Ben Blazak <benblazak.dev@gmail.com>
# Released under The MIT License (see "doc/license.md")
# Project located at <https://github.com/benblazak/ergodox-firmware>
# -----------------------------------------------------------------------------
## description
# A central place for all ErgoDox-specific Makefile-level things
#
MCU := atmega32u4
# processor type (for the teensy 2.0)
F_CPU := 16000000
# processor speed, in Hz; max value is 16000000 (16MHz)
KEYBOARD_LAYOUTS := \
colemak-symbol-mod \
dvorak-kinesis-mod \
qwerty-kinesis-mod
# a list of all available layouts for this keyboard
# -----------------------------------------------------------------------------
SCR += $(wildcard *.c)
SRC += $(wildcard controller/*.c)
SRC += $(wildcard layout/$(KEYBOARD_LAYOUT)*.c)

View File

@ -1,6 +1,4 @@
/* ----------------------------------------------------------------------------
* Originally from PJRC
* ----------------------------------------------------------------------------
* USB Keyboard Example for Teensy USB Development Board
* http://www.pjrc.com/teensy/usb_keyboard.html
* Copyright (c) 2009 PJRC.COM, LLC
@ -24,9 +22,14 @@
* THE SOFTWARE.
* ------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------------
* Modified 2012 by Ben Blazak
* ------------------------------------------------------------------------- */
/** description
* Implements the USB interface
*
* History:
* - Originally from [PJRC] (http://pjrc.com/teensy/) : [usb_keyboard]
* (http://pjrc.com/teensy/usb_keyboard.zip)
* - Modified 2012, Ben Blazak
*/
// Version 1.0: Initial Release
@ -42,16 +45,16 @@
**************************************************************************/
// You can change these to give your code its own name.
#define STR_MANUFACTURER MAKE__USB__STR_MANUFACTURER
#define STR_PRODUCT MAKE__USB__STR_PRODUCT
#define STR_MANUFACTURER OPT__USB__STR_MANUFACTURER
#define STR_PRODUCT OPT__USB__STR_PRODUCT
// Mac OS-X and Linux automatically load the correct drivers. On
// Windows, even though the driver is supplied by Microsoft, an
// INF file is needed to load the driver. These numbers need to
// match the INF file.
#define VENDOR_ID MAKE__USB__VENDOR_ID
#define PRODUCT_ID MAKE__USB__PRODUCT_ID
#define VENDOR_ID OPT__USB__VENDOR_ID
#define PRODUCT_ID OPT__USB__PRODUCT_ID
// USB devices are supposed to implment a halt feature, which is

View File

@ -2,18 +2,17 @@
* (See '.c' file for copyright and such)
* ------------------------------------------------------------------------- */
/**
* - description: |
* The USB interface
/** description
* The USB interface
*
* Prefix: `usb__`
* Prefix: `usb__`
*
* File History:
* * Originally from [PJRC] (http://pjrc.com/teensy/) : [usb_keyboard]
* (http://pjrc.com/teensy/usb_keyboard.zip). Modified 2012, Ben Blazak.
* I'd like to rewrite it someday (partly to add a few extra features
* (like mous keys), mostly to learn how); but alas, someday has not yet
* come.
* File History:
* - Originally from [PJRC] (http://pjrc.com/teensy/) : [usb_keyboard]
* (http://pjrc.com/teensy/usb_keyboard.zip)
* - Modified 2012, Ben Blazak. I'd like to rewrite it someday (partly to add
* a few extra features (like mouse keys), mostly to learn how); but alas,
* someday has not yet come.
*/

View File

@ -4,11 +4,10 @@
* Project located at <https://github.com/benblazak/ergodox-firmware>
* ------------------------------------------------------------------------- */
/**
* - description: |
* Some generally useful key-functions, and related definitions
/** description
* Some generally useful key-functions, and related definitions
*
* Prefix: `kf__`
* Prefix: `kf__`
*/
@ -30,8 +29,9 @@ void kf__press (uint16_t keycode);
void kf__release (uint16_t keycode);
void kf__send (uint16_t ignore);
void kf__toggle (uint16_t keycode);
void kf__layer__push (uint16_t layer_stack_id__layer_number);
void kf__layer__pop (uint16_t layer_stack_id);
void kf__layer__push (uint16_t id__layer);
void kf__layer__pop (uint16_t id__ignore);
void kf__macro__sram (uint16_t pointer);
void kf__macro__progmem (uint16_t pointer);
void kf__macro__eeprom (uint16_t pointer);
@ -47,131 +47,180 @@ void kf__two_keys_capslock (uint16_t pressed);
#endif // ERGODOX_FIRMWARE__FIRMWARE__LIB__LAYOUT__KEY_FUNCTIONS__H
// TODO:
// - move documentation to the '.c' files
// - rewrite, coz of changes
/** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# documentation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# typedefs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- typedef
type: '`void (*kf__function_pointer_t)(void)`'
name: '`kf__function_pointer_t`'
description: The pointer type for all key-functions.
notes:
- All key-functions must have the same type so that we can easily store
pointers to them, and call them using the pointers without knowing
which function specifically is being pointed to.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# basic ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- function:
name: '`kf__press_release`'
description: Generate a normal keypress or keyrelease.
- function:
name: '`kf__toggle`'
description: Toggle the key pressed or unpressed.
- function:
name: '`kf__transparent`'
description:
Execute the key that would have been executed if the current layer was
not active.
// ============================================================================
// === documentation ==========================================================
// ============================================================================
# layer ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ----------------------------------------------------------------------------
// typedefs -------------------------------------------------------------------
// ----------------------------------------------------------------------------
- .ignore:
// === kf__function_pointer_t ===
/** typedefs/kf__function_pointer_t/description
* The pointer type for all key-functions
*
* Notes:
* - All key-functions must have the same type so that we can easily store
* pointers to them, and call them using the pointers without knowing which
* function specifically is being pointed to.
*/
- &kf__layer__push
description:
Push a layer element containing the layer value specified in the keymap
to the top of the stack.
- &kf__layer__pop
description:
Pop the layer element created by the corresponding "layer push"
function out of the layer stack.
notes:
- The layer element is popped out of the stack no matter where it is in
the stack, without touching any of the other elements.
// ----------------------------------------------------------------------------
// functions ------------------------------------------------------------------
// ----------------------------------------------------------------------------
# ~~~~~~~
- function: { name: '`kf__layer__push_0`', << : *kf__layer__push }
- function: { name: '`kf__layer__push_1`', << : *kf__layer__push }
- function: { name: '`kf__layer__push_2`', << : *kf__layer__push }
- function: { name: '`kf__layer__push_3`', << : *kf__layer__push }
- function: { name: '`kf__layer__push_4`', << : *kf__layer__push }
- function: { name: '`kf__layer__push_5`', << : *kf__layer__push }
- function: { name: '`kf__layer__push_6`', << : *kf__layer__push }
- function: { name: '`kf__layer__push_7`', << : *kf__layer__push }
- function: { name: '`kf__layer__push_8`', << : *kf__layer__push }
- function: { name: '`kf__layer__push_9`', << : *kf__layer__push }
// ----------------------------------------------------------------------------
// basic ----------------------------------------------------------------------
- function: { name: '`kf__layer__pop_0`', << : *kf__layer__pop }
- function: { name: '`kf__layer__pop_1`', << : *kf__layer__pop }
- function: { name: '`kf__layer__pop_2`', << : *kf__layer__pop }
- function: { name: '`kf__layer__pop_3`', << : *kf__layer__pop }
- function: { name: '`kf__layer__pop_4`', << : *kf__layer__pop }
- function: { name: '`kf__layer__pop_5`', << : *kf__layer__pop }
- function: { name: '`kf__layer__pop_6`', << : *kf__layer__pop }
- function: { name: '`kf__layer__pop_7`', << : *kf__layer__pop }
- function: { name: '`kf__layer__pop_8`', << : *kf__layer__pop }
- function: { name: '`kf__layer__pop_9`', << : *kf__layer__pop }
// === kf__press() ===
/** functions/kf__press/description
* Generate a normal keypress.
*
* Arguments:
* - `keycode`: The keycode to "press"
*/
# device ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// === kf__release() ===
/** functions/kf__release/description
* Generate a normal keyrelease.
*
* Arguments:
* - `keycode`: The keycode to "release"
*/
- function:
name: '`kf__jump_to_bootloader`'
description: For reflashing the controller
// === kf__send() ===
/** functions/kf__send/description
* Send the USB report (immediately, instead of waiting for the scan cycle to
* end).
*
* Arguments:
* - `ignore`: [ignore]
*/
# special ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// === kf__toggle() ===
/** functions/kf__toggle/description
* Toggle the key pressed or unpressed.
*
* Arguments:
* - `keycode`: The keycode to "toggle"
*/
- function:
name: '`kf__shift_press_release`'
description:
Generate a "shift" press or release before the normal keypress or
keyrelease.
// === kf__layer__push() ===
/** functions/kf__layer__push/description
* If no other layer element with the given ID exists, push a layer element
* with the given ID and layer number to the top of the stack. If a layer
* element with the given ID does already exist, update that element with the
* given layer number.
*
* Arguments:
* - `id__layer`:
* - `id`: The high byte of this `uint16_t` argument. The ID of the layer
* element to push.
* - `layer`: The low byte of this `uint16_t` argument. The layer number
* of the layer to push.
*/
- function:
name: '`kf__two_keys_capslock_press_release`'
description:
When assigned to two keys (e.g. the physical left and right shift keys)
(in both the press and release matrices), pressing and holding down on
of the keys will make the second key toggle capslock.
notes:
- If either of the shifts are pressed when the second key is pressed,
they will be released so that capslock will register properly when
pressed. Capslock will then be pressed and released, and the
original state of the shifts will be restored.
// === kf__layer__pop() ===
/** functions/kf__layer__pop/description
* Pop the layer element with the given ID out of the layer stack (no matter
* where it is, but without touching the order of any of the other elements),
* if it exists.
*
* Arguments:
* - `id__layer`:
* - `id`: The high byte of this `uint16_t` argument. The ID of the layer
* element to pop.
* - `ignore`: The low byte of this `uint16_t` argument. To be ignored.
*/
- function:
name: '`kf__layer__push_numpad`'
description:
Set the numpad to on (put the numpad layer, specified in the keymap, in
a layer element at the top of the layer stack) and toggle numlock
(regardless of whether or not numlock is currently on)
notes:
- Meant to be assigned (along with "numpad off") *instead* of a normal
numlock key.
// === kf__macro__sram() ===
/** functions/kf__macro__sram/description
* Execute the macro at the given location in SRAM.
*
* Arguments:
* - `pointer`: A pointer to the location in SRAM where the macro begins
*
* Notes:
* - Macros are arrays of `uint16_t`s with the following format:
* - `[0]`: A count of how many ("function pointer", "argument") pairs
* follow
* - `[1]`: A pointer to a key-function
* - `[2]`: The argument to be passed to the preceding key-function
* - ...
*/
- function:
name: '`kf__layer__pop_numpad`'
description:
Set the numpad to off (pop the layer element created by "numpad on" out
of the stack) and toggle numlock (regardless of whether or not numlock
is currently on).
notes:
- Meant to be assigned (along with "numpad on") *instead* of a normal
numlock key.
// === kf__macro__progmem() ===
/** functions/kf__macro__progmem/description
* Execute the macro at the given location in PROGMEM.
*
* Arguments:
* - `pointer`: A pointer to the location in PROGMEM where the macro begins
*
* Notes:
* - Macros are arrays of `uint16_t`s with the following format:
* - `[0]`: A count of how many ("function pointer", "argument") pairs
* follow
* - `[1]`: A pointer to a key-function
* - `[2]`: The argument to be passed to the preceding key-function
* - ...
*/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ **/
// === kf__macro__eeprom() ===
/** functions/kf__macro__eeprom/description
* Execute the macro at the given location in the EEPROM.
*
* Arguments:
* - `pointer`: A pointer to the location in the EEPROM where the macro begins
*
* Notes:
* - Macros are arrays of `uint16_t`s with the following format:
* - `[0]`: A count of how many ("function pointer", "argument") pairs
* follow
* - `[1]`: A pointer to a key-function
* - `[2]`: The argument to be passed to the preceding key-function
* - ...
*/
// ----------------------------------------------------------------------------
// device ---------------------------------------------------------------------
// === kf__jump_to_bootloader() ===
/** functions/kf__jump_to_bootloader/description
* For reflashing the controller.
*
* Arguments:
* - `ignore`: [ignore]
*/
// ----------------------------------------------------------------------------
// special --------------------------------------------------------------------
// === kf__two_keys_capslock() ===
/** functions/kf__two_keys_capslock/description
* For implementing the behavior wherein pressing both shift keys at the same
* time toggles capslock.
*
* If the count of pressed keys with this function assigned is greater than or
* equal to 1, any subsequent "presses" of this function will toggle capslock.
*
* Arguments:
* - `pressed`:
* - `true`: Add `1` to the count of pressed keys with this function
* assigned.
* - `false`: Subtract `1` from the count of pressed keys with this
* function assigned.
*
* Notes:
* - If either or both of the two shifts is active when capslock is toggled
* (which should usually be the case), they will be released so that capslock
* will register properly when toggled (that is, when we automatically press
* then release it). After this, the original state of the shifts will be
* restored.
*/

View File

@ -4,18 +4,17 @@
* Project located at <https://github.com/benblazak/ergodox-firmware>
* ------------------------------------------------------------------------- */
/**
* - description: |
* Partial key descriptions for the "Boot Keyboard Required" keys (see
* <../../../firmware/lib/usb/usage-page/keyboard.h>).
/** description
* Partial key descriptions for the "Boot Keyboard Required" keys (see
* <../../../firmware/lib/usb/usage-page/keyboard.h>).
*
* Prefixes: `KEYS__`, [none]
* This header is meant to be included, not as an interface to anything, but in
* order to centralize a bit of code that would otherwise be duplicated by most
* layouts.
*
* Usage: `#define` `KEYS__DEFAULT` before `#include`ing.
* Prefixes: `KEYS__`, [none]
*
* Note: This header is meant to be included, not as an interface to
* anything, but in order to centralize a bit of code that would otherwise
* be duplicated by most layouts.
* Usage: `#define` `KEYS__DEFAULT` and `KEYS__SHIFTED` before `#include`ing.
*/

View File

@ -4,28 +4,24 @@
* Project located at <https://github.com/benblazak/ergodox-firmware>
* ------------------------------------------------------------------------- */
/**
* - description: |
* USB Keyboard Key Codes (usage page 0x07)
/** description
* USB Keyboard Key Codes (usage page 0x07)
*
* Prefixes: `KEY__`, `KEYPAD__`
* Prefixes: `KEY__`, `KEYPAD__`
*
* Taken from [the HID Usage Tables pdf][1], Section 10, which can be
* found on [the HID Page][2] at <http://www.usb.org>
* Taken from [the HID Usage Tables pdf][1], Section 10, which can be found on
* [the HID Page][2] at <http://www.usb.org>
*
* - `Boot Keyboard Req.` indicates that the usage code is one that
* should be supported by the listed types of keyboards (104-key, ...)
* on boot
* - `Boot Keyboard Req.` indicates that the usage code is one that should be
* supported by the listed types of keyboards (104-key, ...) on boot
*
* - `KEY_` indicates a Keyboard key
* - `KEYPAD_` indicates a Keypad key
* - Multiple names concatenated in CamelCase indicate a single value
* - Multiple names separated by `_`s indicate shifted or alternate
* values
* - `KEY_` indicates a Keyboard key
* - `KEYPAD_` indicates a Keypad key
* - Multiple names concatenated in CamelCase indicate a single value
* - Multiple names separated by `_`s indicate shifted or alternate values
*
* [1]: http://www.usb.org/developers/devclass_docs/Hut1_12v2.pdf
* [2]: http://www.usb.org/developers/hidpage
* ----------------------------------------------------------------------------
* [1]: http://www.usb.org/developers/devclass_docs/Hut1_12v2.pdf
* [2]: http://www.usb.org/developers/hidpage
*/

View File

@ -4,24 +4,23 @@
* Project located at <https://github.com/benblazak/ergodox-firmware>
* ------------------------------------------------------------------------- */
/**
* - description: |
* USB LED Codes (usage page 0x08)
/** description
* USB LED Codes (usage page 0x08)
*
* Prefix: `LED__`
* Prefix: `LED__`
*
* Taken from [the HID Usage Tables pdf][1], Section 11,
* which can be found on [the HID Page][2] at <http://www.usb.org>
* Taken from [the HID Usage Tables pdf][1], Section 11, which can be found on
* [the HID Page][2] at <http://www.usb.org>
*
* - applicable Usage Types (from Section 3.4)
* - OOC : On/Off Control
* - Sel : Selector
* - DV : Dynamic Value
* - US : Usage Switch
* - UM : Usage Modifier
* - applicable Usage Types (from Section 3.4)
* - OOC : On/Off Control
* - Sel : Selector
* - DV : Dynamic Value
* - US : Usage Switch
* - UM : Usage Modifier
*
* [1]: http://www.usb.org/developers/devclass_docs/Hut1_12v2.pdf
* [2]: http://www.usb.org/developers/hidpage
* [1]: http://www.usb.org/developers/devclass_docs/Hut1_12v2.pdf
* [2]: http://www.usb.org/developers/hidpage
*/

View File

@ -4,17 +4,16 @@
* Project located at <https://github.com/benblazak/ergodox-firmware>
* ------------------------------------------------------------------------- */
/**
* - description: |
* Things kept track of by `main()` that need to be accessible to other parts
* of the program.
/** description
* Things kept track of by `main()` that need to be accessible to other parts
* of the program.
*
* Prefix: `main__`
* Prefix: `main__`
*/
#ifndef ERGODOX_FIRMWARE__FIRMWARE__MAIN_H
#define ERGODOX_FIRMWARE__FIRMWARE__MAIN_H
#ifndef ERGODOX_FIRMWARE__FIRMWARE__MAIN__H
#define ERGODOX_FIRMWARE__FIRMWARE__MAIN__H
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
@ -26,13 +25,13 @@ uint8_t main__layer_stack__pop_id (uint8_t layer_id);
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
#endif // ERGODOX_FIRMWARE__FIRMWARE__MAIN_H
#endif // ERGODOX_FIRMWARE__FIRMWARE__MAIN__H
// ============================================================================
// === documentation ==========================================================
// ============================================================================
// TODO
/** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# documentation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ **/