(working)
parent
75a987d5a8
commit
43d849606a
|
@ -11,8 +11,8 @@
|
|||
* Meant to be included *only* by the layout using it.
|
||||
*/
|
||||
|
||||
// TODO: implement chords (as in, for a chorded key layout)
|
||||
// TODO: implement sticky keys
|
||||
// TODO: write a chordmak (or asetniop) layout, on top of a standard colemak
|
||||
// layout, using chained sticky keys for the modifiers
|
||||
|
||||
// TODO: write tutorials
|
||||
// - about
|
||||
|
|
|
@ -13,8 +13,9 @@
|
|||
|
||||
include ../../../firmware/lib/twi/options.mk
|
||||
include ../../../firmware/lib/usb/options.mk
|
||||
include ../../../firmware/lib/layout/eeprom-macro/options.mk
|
||||
include ../../../firmware/lib/layout/key-functions/options.mk
|
||||
# TODO: add other 'options.mk' files as they appear
|
||||
include ../../../firmware/lib/layout/layer-stack/options.mk
|
||||
|
||||
|
||||
BINARY_FORMAT := ihex
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2013 Ben Blazak <benblazak.dev@gmail.com>
|
||||
* Released under The MIT License (see "doc/licenses/MIT.md")
|
||||
* Project located at <https://github.com/benblazak/ergodox-firmware>
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
/** description
|
||||
* EEPROM macro interface
|
||||
*
|
||||
* Prefix: `eeprom_macro__`
|
||||
*
|
||||
* This file is meant to be included and used by the keyboard layout
|
||||
* implemenmtation.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ERGODOX_FIRMWARE__LIB__LAYOUT__EEPROM_MACRO__H
|
||||
#define ERGODOX_FIRMWARE__LIB__LAYOUT__EEPROM_MACRO__H
|
||||
// ----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
// TODO
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
#endif // ERGODOX_FIRMWARE__LIB__LAYOUT__EEPROM_MACRO__H
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2013 Ben Blazak <benblazak.dev@gmail.com>
|
||||
* Released under The MIT License (see "doc/licenses/MIT.md")
|
||||
* Project located at <https://github.com/benblazak/ergodox-firmware>
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
/** description
|
||||
* Implements the eeprom-macro functionality defined in "../eeprom-macro.h" for
|
||||
* the ATMega32U4
|
||||
*
|
||||
* TODO: implement
|
||||
*/
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
# -----------------------------------------------------------------------------
|
||||
# Copyright (c) 2013 Ben Blazak <benblazak.dev@gmail.com>
|
||||
# Released under The MIT License (see "doc/licenses/MIT.md")
|
||||
# Project located at <https://github.com/benblazak/ergodox-firmware>
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
## description
|
||||
# eeprom-macro options
|
||||
#
|
||||
# This file is meant to be included by the using '.../options.mk'
|
||||
#
|
||||
|
||||
|
||||
SRC += $(wildcard $(MCU).c)
|
||||
|
|
@ -5,8 +5,7 @@
|
|||
* ------------------------------------------------------------------------- */
|
||||
|
||||
/** description
|
||||
* Implements the "basic" section of
|
||||
* ".../firmware/lib/layout/key-functions.h"
|
||||
* Implements the "basic" section of "../key-functions.h"
|
||||
*/
|
||||
|
||||
|
||||
|
|
|
@ -5,9 +5,8 @@
|
|||
* ------------------------------------------------------------------------- */
|
||||
|
||||
/** description
|
||||
* Implements the "device" section of
|
||||
* ".../firmware/lib/layout/key-functions.h"
|
||||
* for the ATMega23U4
|
||||
* Implements the "device" section of "../../key-functions.h" for the
|
||||
* ATMega23U4
|
||||
*/
|
||||
|
||||
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
* ------------------------------------------------------------------------- */
|
||||
|
||||
/** description
|
||||
* Implements the "special" section of
|
||||
* ".../firmware/lib/layout/key-functions.h"
|
||||
* Implements the "special" section of "../key-functions.h"
|
||||
*/
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2013 Ben Blazak <benblazak.dev@gmail.com>
|
||||
* Released under The MIT License (see "doc/licenses/MIT.md")
|
||||
* Project located at <https://github.com/benblazak/ergodox-firmware>
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
/** description
|
||||
* Implements the layer-stack defined in "../layer-stack.h"
|
||||
*
|
||||
* TODO: implement, document, everything
|
||||
* - this needs to be reorganized
|
||||
* - much of this should probably be split out into a generic flexable_array
|
||||
* type of some sort
|
||||
*/
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define BLOCK_SIZE 5
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
typedef struct {
|
||||
uint8_t id;
|
||||
uint8_t number;
|
||||
} element_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t size_allocated;
|
||||
uint8_t size_filled;
|
||||
element_t * data;
|
||||
} stack_t;
|
||||
|
||||
stack_t stack = { .size_allocated = BLOCK_SIZE;
|
||||
.size_filled = 0,
|
||||
.data = malloc( sizeof(element *) * BLOCK_SIZE ); };
|
||||
|
||||
uint8_t grow_stack(stack_t stack) {
|
||||
element_t * temp = realloc( stack.data, stack.size_allocated + BLOCK_SIZE );
|
||||
if (temp) {
|
||||
stack.data = temp;
|
||||
stack.size_allocated += BLOCK_SIZE;
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t shrink_stack(stack_t stack) {
|
||||
if (stack.size_allocated == BLOCK_SIZE)
|
||||
return 0;
|
||||
|
||||
element_t * temp = realloc( stack.data, stack.size_allocated - BLOCK_SIZE );
|
||||
if (temp) {
|
||||
stack.data = temp;
|
||||
stack.size_allocated -= BLOCK_SIZE;
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
uint8_t layer_stack__peek (uint8_t offset) {
|
||||
}
|
||||
|
||||
uint8_t layer_stack__push (uint8_t layer_id, uint8_t layer_number) {
|
||||
}
|
||||
|
||||
uint8_t layer_stack__pop_id (uint8_t layer_id) {
|
||||
}
|
||||
|
||||
uint8_t layer_stack__size (void) {
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
# -----------------------------------------------------------------------------
|
||||
# Copyright (c) 2013 Ben Blazak <benblazak.dev@gmail.com>
|
||||
# Released under The MIT License (see "doc/licenses/MIT.md")
|
||||
# Project located at <https://github.com/benblazak/ergodox-firmware>
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
## description
|
||||
# layer-stack options
|
||||
#
|
||||
# This file is meant to be included by the using '.../options.mk'
|
||||
#
|
||||
|
||||
|
||||
SRC += $(wildcard *.c)
|
||||
|
|
@ -11,6 +11,9 @@
|
|||
#
|
||||
|
||||
|
||||
SRC += $(wildcard *.c)
|
||||
SRC += $(wildcard keyboard/from-pjrc/*.c)
|
||||
SRC += $(wildcard $(MCU)/*.c)
|
||||
|
||||
ifeq '$(MCU)' 'atmega32u4'
|
||||
SRC += $(wildcard $(MCU)/keyboard/from-pjrc/*.c)
|
||||
endif
|
||||
|
||||
|
|
|
@ -5,10 +5,13 @@
|
|||
* ------------------------------------------------------------------------- */
|
||||
|
||||
/** description
|
||||
* `main()`: tying it all together // TODO
|
||||
* `main()`: tying it all together
|
||||
*/
|
||||
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <util/delay.h>
|
||||
#include "./main.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -26,6 +29,13 @@
|
|||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "../firmware/keyboard.h"
|
||||
#include "../firmware/lib/usb.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define main__is_pressed is_pressed
|
||||
#define main__was_pressed was_pressed
|
||||
#define main__row row
|
||||
|
@ -43,6 +53,64 @@ uint8_t col;
|
|||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/** functions/main/description
|
||||
* Initialize things, then loop forever
|
||||
*
|
||||
* Mostly all that happens here after initialization is that current and
|
||||
* previous key states are tracked, keys that change state are "executed", the
|
||||
* USB report is sent, and the LEDs are updated. We also have a delay, to make
|
||||
* sure the keys have time to debounce. Almost everything interesting happens
|
||||
* somewhere else (especially in ".../firmware/keyboard/.../layout"); have a
|
||||
* look through the source, especially the documentation, to see how things are
|
||||
* defined and what's actually happening.
|
||||
*/
|
||||
void main(void) {
|
||||
static bool (*temp)[OPT__KB__ROWS][OPT__KB__COLUMNS]; // for swapping below
|
||||
|
||||
kb__init(); // initialize hardware (besides USB)
|
||||
|
||||
kb__led__state__power_on();
|
||||
|
||||
usb__init();
|
||||
while (!usb__configured());
|
||||
kb__led__delay__usb_init(); // give the OS time to load drivers, etc.
|
||||
|
||||
kb__led__state__ready();
|
||||
|
||||
for(;;) {
|
||||
temp = is_pressed;
|
||||
is_pressed = was_pressed;
|
||||
was_pressed = temp;
|
||||
|
||||
kb__update_matrix(*is_pressed);
|
||||
|
||||
// "execute" keys that have changed state
|
||||
for(row=0; row<OPT__KB__ROWS; row++) {
|
||||
for(col=0; col<OPT__KB__COLUMNS; col++) {
|
||||
key_is_pressed = (*is_pressed)[row][col];
|
||||
key_was_pressed = (*was_pressed)[row][col];
|
||||
|
||||
if (key_is_pressed != key_was_pressed)
|
||||
kb__layout__exec_key(key_is_pressed, row, col);
|
||||
}
|
||||
}
|
||||
|
||||
usb__kb__send_report(); // (even if nothing's changed)
|
||||
_delay_ms(OPT__DEBOUNCE_TIME);
|
||||
|
||||
// note: only use the `kb__led__logical...` functions here, since the
|
||||
// meaning of the physical LEDs should be controlled by the layout
|
||||
#define read usb__kb__read_led
|
||||
#define on kb__led__logical_on
|
||||
#define off kb__led__logical_off
|
||||
read('N') ? on('N') : off('N'); // numlock
|
||||
read('C') ? on('C') : off('C'); // capslock
|
||||
read('S') ? on('S') : off('S'); // scroll lock
|
||||
read('O') ? on('O') : off('O'); // compose
|
||||
read('K') ? on('K') : off('K'); // kana
|
||||
#undef read
|
||||
#undef on
|
||||
#undef off
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue