(intermediate checkin)
parent
0129fcae47
commit
35bfca3662
|
@ -4,11 +4,13 @@
|
|||
* Project located at <https://github.com/benblazak/ergodox-firmware>
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* - description: |
|
||||
* The keyboard interface, and related definitions
|
||||
/** description
|
||||
* The keyboard interface, and related definitions.
|
||||
*
|
||||
* Prefix: `kb__`
|
||||
* Keyboard implementations must conditionally define their dimensions in this
|
||||
* file, and implement all prototyped functions.
|
||||
*
|
||||
* Prefix: `kb__`
|
||||
*/
|
||||
|
||||
|
||||
|
@ -20,9 +22,6 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#include "../firmware/lib/layout/key-functions.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
@ -33,21 +32,12 @@
|
|||
|
||||
#else
|
||||
|
||||
#error "A keyboard must be specified"
|
||||
#error "Keyboard dimensions must be defined"
|
||||
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
typedef struct {
|
||||
kf__function_pointer_t press_function;
|
||||
uint16_t press_value;
|
||||
kf__function_pointer_t release_function;
|
||||
uint16_t release_value;
|
||||
} kb__key_t;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// controller
|
||||
uint8_t kb__init (void);
|
||||
uint8_t kb__update_matrix (bool matrix[KB__ROWS][KB__COLUMNS]);
|
||||
|
@ -80,82 +70,72 @@ void kb__layout__exec_key ( bool pressed,
|
|||
#endif // ERGODOX_FIRMWARE__FIRMWARE__KEYBOARD__H
|
||||
|
||||
|
||||
// ============================================================================
|
||||
// === documentation ==========================================================
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// macros ---------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// === KB__ROWS ===
|
||||
/* macros/KB__ROWS/description
|
||||
* The number of rows in a given keyboard's matrix
|
||||
*/
|
||||
|
||||
// === KB__COLUMNS ===
|
||||
/* macros/KB__COLUMNS/description
|
||||
* The number of columns in a given keyboard's matrix
|
||||
*/
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// functions ------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// controller -----------------------------------------------------------------
|
||||
|
||||
// === kb__init() ===
|
||||
/* functions/kb__init/description
|
||||
* Initialize the keyboard.
|
||||
*
|
||||
* Returns:
|
||||
* - success: `0`
|
||||
* - failure: [other]
|
||||
*
|
||||
* Notes:
|
||||
* - Should be called exactly once by `main()` before entering the run loop.
|
||||
*/
|
||||
|
||||
// === kb__update_matrix() ===
|
||||
/* functions/kb__update_matrix/description
|
||||
* Update the given matrix to the current state of the keyboard.
|
||||
*
|
||||
* Arguments:
|
||||
* - `matrix`: The keyboard matrix to update.
|
||||
*
|
||||
* Returns:
|
||||
* - success: `0`
|
||||
* - failure: [other]
|
||||
*/
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// LED ------------------------------------------------------------------------
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// layout ---------------------------------------------------------------------
|
||||
|
||||
|
||||
// TODO: rewrite, coz of changes
|
||||
/** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# documentation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# macros ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--
|
||||
|
||||
- macro:
|
||||
name: '`KB__ROWS`'
|
||||
values:
|
||||
- { name: '`6`', description: for the ErgoDox }
|
||||
|
||||
- macro:
|
||||
name: '`KB__COLUMNS`'
|
||||
values:
|
||||
- { name: '`14`', description: for the ErgoDox }
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# typedefs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
- typedef:
|
||||
type: '`struct`'
|
||||
name: '`kb__key_t`'
|
||||
description: The type of each key in the layout matrix.
|
||||
values:
|
||||
- type: '`uint8_t`'
|
||||
name: '`value`'
|
||||
description:
|
||||
The value passed to the appropriate function when the key changes
|
||||
state. The function may do as it wishes with this value, but it
|
||||
will most commonly be a keycode to send to the host.
|
||||
- type: '`kf__function_pointer_t`'
|
||||
name: '`press`'
|
||||
description:
|
||||
The function to call when the key changes from 'released' to
|
||||
'pressed'.
|
||||
- type: '`kf__function_pointer_t`'
|
||||
name: '`release`'
|
||||
description:
|
||||
The function to call when the key changes from 'pressed' to
|
||||
'released'.
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# controller ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-
|
||||
|
||||
- function:
|
||||
name: '`kb__init`'
|
||||
description: Initialize the keyboard.
|
||||
return value:
|
||||
type: '`int8_t`'
|
||||
values:
|
||||
- { name: '`0`', description: success }
|
||||
- { name: '[other]', description: error }
|
||||
notes:
|
||||
- Should be called exactly once by `main()` before entering the run
|
||||
loop.
|
||||
|
||||
- function:
|
||||
name: '`kb__update_matrix`'
|
||||
description:
|
||||
Update the given matrix to the current state of the keyboard.
|
||||
arguments:
|
||||
- type: '`bool[][]`'
|
||||
name: '`matrix`'
|
||||
description: A pointer to the matrix to update.
|
||||
notes:
|
||||
- Matrix dimensions are `[KB__ROWS][KB__COLUMNS]`.
|
||||
return value:
|
||||
type: '`int8_t`'
|
||||
values:
|
||||
- { name: '`0`', description: success }
|
||||
- { name: '[other]', description: error }
|
||||
|
||||
# LED ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--
|
||||
|
||||
- .ignore:
|
||||
|
|
|
@ -4,11 +4,9 @@
|
|||
* Project located at <https://github.com/benblazak/ergodox-firmware>
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* - description: |
|
||||
* A place for all things common to the other default files, including
|
||||
* `#include`s. Other code (especially functions defined in this directory)
|
||||
* may break if you change things defined here, so be careful if you do.
|
||||
/** description
|
||||
* A place for all things common to the other default files, including
|
||||
* `#include`s.
|
||||
*/
|
||||
|
||||
|
||||
|
@ -29,7 +27,14 @@
|
|||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
typedef const kb__key_t * const PROGMEM key_t
|
||||
struct key_t {
|
||||
kf__function_pointer_t press_function;
|
||||
uint16_t press_value;
|
||||
kf__function_pointer_t release_function;
|
||||
uint16_t release_value;
|
||||
};
|
||||
|
||||
typedef const struct key_t * const PROGMEM key_t
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
@ -3,10 +3,11 @@
|
|||
# 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
|
||||
# -----------------------------------------------------------------------------
|
||||
#
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
@ -16,11 +17,6 @@
|
|||
MAKE__LED_BRIGHTNESS := 0.5
|
||||
# a multiplier, with 1 being the max
|
||||
|
||||
MAKE__DEBOUNCE_TIME := 5
|
||||
# in milliseconds; 5ms should be good for cherry mx switches (per the
|
||||
# keyswitch spec)
|
||||
|
||||
|
||||
MAKE__TEENSY__DRIVE_ROWS := 0
|
||||
MAKE__TEENSY__DRIVE_COLUMNS := 1
|
||||
MAKE__MCP23018__DRIVE_ROWS := 0
|
||||
|
@ -55,21 +51,37 @@ MAKE__MCP23018__DRIVE_COLUMNS := 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
|
||||
# .............................................................................
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
@ -84,7 +96,7 @@ SCR += TODO
|
|||
# -----------------------------------------------------------------------------
|
||||
|
||||
# DRIVE_ROWS and DRIVE_COLUMNS
|
||||
ERROR := "see the 'DRIVE_ROWS and DRIVE_COLUMNS section in 'options.mk'"
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue