[Jack & Erez] Comments + tiny updates and cleanup

This commit is contained in:
Erez Zukerman
2015-10-27 00:54:46 +02:00
parent cc1c32671e
commit 0c47e8b008
19 changed files with 65 additions and 1512 deletions
-56
View File
@@ -1,56 +0,0 @@
# TMK Generic
* I'm not sure what the Magic + H does.
Is this a menu that will pop up regardless of what platform and program is open?
Yes, this is sort of debugging.
Use PJRC's [hid_listen](https://www.pjrc.com/teensy/hid_listen.html) to see debug messages.
# TMK/Ergodox specific
* I would like to configure my leds to indicate the active layer.
I read that can be done, but I haven't seen an example for this firmware.
Can someone please post an example or a link?
TMK for Ergodox have support for seven (!) led's:
- three on right
- three on left (see http://geekhack.org/index.php?topic=22780.msg873819#msg873819 for more details)
- Teensy onboard led as well
Any of these leds can be used as layer indicator or NumLock/CapsLock/ScrollLock led.
[Here is example](https://github.com/cub-uanic/tmk_keyboard/blob/cub_layout/keyboard/ergodox/matrix.c#L121-167)
how you can assign some meaning to each led.
In this code only left leds are used to show layers, but you can
[change `led_set()`](https://github.com/cub-uanic/tmk_keyboard/blob/cub_layout/keyboard/ergodox/led.c)
and do anything you want with all leds.
# Firmware
Q: Where to get binaries?
A:
Q: Where to get sources?
A:
Q: How to compile?
A:
# Layouts
description of layouts in base firmware binaries
# Things TO-DO
- [ ] Flash NumLock led only when "numpad" layer is active
- [ ] Command (in terms of IS_COMMAND) to switch to no-leds mode
- [ ] Increase count of ACTION keys
- [ ] Fix command_state() onboard led: it should flash only when kbd in some specific mode (CONSOLE || MOUSE)
- [ ] ergodox_blink_all_leds() should save current state of leds, and restore after blink. initial state of all leds == off
- [ ] add support for pseudo-backlight (reversed LEDs) + docs/photo
- [ ] command to debug all LEDs (on/off/blink)
- [ ] proper (in-core) implementation of DEBUG_MATRIX_SCAN_RATE (non-Ergodox specific)
- [ ] proper (in-core) support for per-layer fn_actions[]
-61
View File
@@ -1,61 +0,0 @@
#include <avr/io.h>
#include "backlight.h"
#define CHANNEL OCR1C
void backlight_init_ports()
{
// Setup PB7 as output and output low.
DDRB |= (1<<7);
PORTB &= ~(1<<7);
// Use full 16-bit resolution.
ICR1 = 0xFFFF;
// I could write a wall of text here to explain... but TL;DW
// Go read the ATmega32u4 datasheet.
// And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on
// Pin PB7 = OCR1C (Timer 1, Channel C)
// Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0
// (i.e. start high, go low when counter matches.)
// WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0
// Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1
TCCR1A = _BV(COM1C1) | _BV(WGM11); // = 0b00001010;
TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;
backlight_init();
}
void backlight_set(uint8_t level)
{
if ( level == 0 )
{
// Turn off PWM control on PB7, revert to output low.
TCCR1A &= ~(_BV(COM1C1));
CHANNEL = 0x0;
// Prevent backlight blink on lowest level
PORTB &= ~(_BV(PORTB7));
}
else if ( level == BACKLIGHT_LEVELS )
{
// Prevent backlight blink on lowest level
PORTB &= ~(_BV(PORTB7));
// Turn on PWM control of PB7
TCCR1A |= _BV(COM1C1);
// Set the brightness
CHANNEL = 0xFFFF;
}
else
{
// Prevent backlight blink on lowest level
PORTB &= ~(_BV(PORTB7));
// Turn on PWM control of PB7
TCCR1A |= _BV(COM1C1);
// Set the brightness
CHANNEL = 0xFFFF >> ((BACKLIGHT_LEVELS - level) * ((BACKLIGHT_LEVELS + 1) / 2));
}
}
File diff suppressed because it is too large Load Diff
@@ -1,23 +0,0 @@
#define MACRO_XMONAD_RESET MACRO( \
I(15), \
D(LCTL), D(LALT), T(F2), W(255), U(LALT), U(LCTL), W(255), \
T(X), T(M), T(O), T(N), T(UP), T(ENT), W(255), \
D(LCTL), D(LALT), T(F5), W(255), U(LALT), U(LCTL), W(255), \
END) \
#define MACRO_PASSWORD1 MACRO( \
I(15), \
T(E), T(X), T(A), T(M), T(P), T(L), T(E), \
END) \
#define MACRO_PASSWORD2 MACRO( \
I(15), \
T(E), T(X), T(A), T(M), T(P), T(L), T(E), \
END) \
#define MACRO_PASSWORD2 MACRO( \
I(15), \
T(E), T(X), T(A), T(M), T(P), T(L), T(E), \
END) \
File diff suppressed because it is too large Load Diff
@@ -1,2 +0,0 @@
case MACRO_PASSWORD1:
return MACRO( D(LSFT), D(H), U(H), U(LSFT), D(E), U(E), D(L), U(L), D(L), U(L), D(O), U(O), D(DOT), U(DOT), D(W), U(W), D(O), U(O), D(R), U(R), D(L), U(L), D(D), U(D), D(ENTER), U(ENTER), END); // types "Hello.world{ENTER}"
@@ -1,45 +1,21 @@
#----------------------------------------------------------------------------
# On command line:
#
# make all = Make software.
# make = 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)
# That's pretty much all you need. To compile, always go make clean,
# followed by make.
#
# For advanced users only:
# 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 = ergodox
TARGET = ergodox_ez
# Directory common source filess exist
@@ -49,9 +25,8 @@ TOP_DIR = ../..
TARGET_DIR = .
# # project specific files
SRC = ergodox.c \
twimaster.c \
backlight.c
SRC = ergodox_ez.c \
twimaster.c
ifdef KEYMAP
SRC := keymaps/keymap_$(KEYMAP).c $(SRC)
+1
View File
@@ -0,0 +1 @@
// TODO: Make up a proper readme for the ErgoDox EZ.
@@ -52,8 +52,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Set 0 if debouncing isn't needed */
#define DEBOUNCE 2
#define TAPPING_TERM 230
#define TAPPING_TOGGLE 2
#define TAPPING_TERM 100
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
#define LOCKING_SUPPORT_ENABLE
@@ -1,4 +1,4 @@
#include "ergodox.h"
#include "ergodox_ez.h"
#include "i2cmaster.h"
bool i2c_initialized = 0;
@@ -1,7 +1,8 @@
#include "ergodox.h"
#include "ergodox_ez.h"
#include "debug.h"
#include "action_layer.h"
// TODO: Define layer names that make sense for the ErgoDox EZ.
#define DEFAULT_LAYER 0
#define COLEMAK_LAYER 1
#define DVORAK_LAYER 2
@@ -76,11 +77,12 @@ 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) {
uint8_t layer = biton32(layer_state);
@@ -89,6 +91,7 @@ void * matrix_scan_user(void) {
ergodox_left_led_2_off();
ergodox_left_led_3_off();
switch (layer) {
// TODO: Make this relevant to the ErgoDox EZ.
case 1:
// all
ergodox_left_led_1_on();
@@ -1,3 +1,4 @@
// TODO: Move all of this stuff into the default keymap, and then get rid of this file.
#include "action_util.h"
#include "action_layer.h"
#define KC_SW0 KC_FN0
@@ -1,4 +1,10 @@
/*
Note for ErgoDox EZ customizers: Here be dragons!
This is not a file you want to be messing with.
All of the interesting stuff for you is under keymaps/ :)
Love, Erez
Copyright 2013 Oleg Kostyuk <cub.uanic@gmail.com>
This program is free software: you can redistribute it and/or modify
@@ -27,7 +33,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "debug.h"
#include "util.h"
#include "matrix.h"
#include "ergodox.h"
#include "ergodox_ez.h"
#include "i2cmaster.h"
#ifdef DEBUG_MATRIX_SCAN_RATE
#include "timer.h"
@@ -80,7 +86,7 @@ void matrix_init(void)
// initialize row and col
mcp23018_status = init_mcp23018();
unselect_rows();
init_cols();
@@ -133,69 +139,6 @@ uint8_t matrix_scan(void)
}
#endif
#ifdef KEYMAP_CUB
uint8_t layer = biton32(layer_state);
ergodox_board_led_off();
ergodox_left_led_1_off();
ergodox_left_led_2_off();
ergodox_left_led_3_off();
switch (layer) {
case 1:
// all
ergodox_left_led_1_on();
ergodox_left_led_2_on();
ergodox_left_led_3_on();
break;
case 2:
// blue
ergodox_left_led_2_on();
break;
case 8:
// blue and green
ergodox_left_led_2_on();
// break missed intentionally
case 3:
// green
ergodox_left_led_3_on();
break;
case 6:
ergodox_board_led_on();
// break missed intentionally
case 4:
case 5:
case 7:
// white
ergodox_left_led_1_on();
break;
case 9:
// white+green
ergodox_left_led_1_on();
ergodox_left_led_3_on();
break;
default:
// none
break;
}
mcp23018_status = ergodox_left_leds_update();
#endif
#ifdef KEYMAP_SIMON
uint8_t layer = biton32(layer_state);
ergodox_board_led_off();
switch (layer) {
case 0:
// none
break;
default:
ergodox_board_led_on();
break;
}
#endif
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
select_row(i);
matrix_row_t cols = read_cols(i);
@@ -268,11 +211,11 @@ uint8_t matrix_key_count(void)
*
* Teensy
* col: 0 1 2 3 4 5
* pin: F0 F1 F4 F5 F6 F7
* pin: F0 F1 F4 F5 F6 F7
*
* MCP23018
* col: 0 1 2 3 4 5
* pin: B5 B4 B3 B2 B1 B0
* pin: B5 B4 B3 B2 B1 B0
*/
static void init_cols(void)
{
@@ -361,7 +304,7 @@ static void select_row(uint8_t row)
// set other rows hi-Z : 1
mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out;
mcp23018_status = i2c_write(GPIOA); if (mcp23018_status) goto out;
mcp23018_status = i2c_write( 0xFF & ~(1<<row)
mcp23018_status = i2c_write( 0xFF & ~(1<<row)
& ~(ergodox_left_led_3<<LEFT_LED_3_SHIFT)
); if (mcp23018_status) goto out;
out:
+11 -4
View File
@@ -1,6 +1,13 @@
// This is the canonical layout file for the Quantum project. If you want to add another keyboard,
// this is the style you want to emulate.
#include "planck.h"
#include "backlight.h"
// Each layer gets a name for readability, which is then used in the keymap matrix below.
// The underscores don't mean anything - you can have a layer called STUFF or any other name.
// Layer names don't all need to be of the same length, obviously, and you can also skip them
// entirely and just use numbers.
#define _QW 0
#define _CM 1
#define _DV 2
@@ -12,7 +19,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
{KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC},
{KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT},
{KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT },
{M(0), KC_LCTL, KC_LALT, KC_LGUI, MO(2), KC_SPC, KC_SPC, MO(1), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
{M(0), KC_LCTL, KC_LALT, KC_LGUI, MO(_RS), KC_SPC, KC_SPC, MO(_LW), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
},
[_CM] = { /* Colemak */
{KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC},
@@ -50,11 +57,11 @@ const uint16_t PROGMEM fn_actions[] = {
};
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
// MACRODOWN only works in this function
switch(id) {
case 0:
case 0:
if (record->event.pressed) {
register_code(KC_RSFT);
backlight_step();
@@ -62,6 +69,6 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
unregister_code(KC_RSFT);
}
break;
}
}
return MACRO_NONE;
};
-40
View File
@@ -1,43 +1,3 @@
#----------------------------------------------------------------------------
# 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".
#----------------------------------------------------------------------------
QUANTUM_DIR = quantum
# # project specific files
+27 -2
View File
@@ -72,33 +72,51 @@ extern const uint16_t fn_actions[];
#define RGUI(kc) kc | 0x1800
// Aliases for shifted symbols
// Each key has a 4-letter code, and some have longer aliases too.
// While the long aliases are descriptive, the 4-letter codes
// make for nicer grid layouts (everything lines up), and are
// the preferred style for Quantum.
#define KC_TILD LSFT(KC_GRV) // ~
#define KC_TILDE KC_TILD
#define KC_EXLM LSFT(KC_1) // !
#define KC_EXCLAIM KC_EXLM
#define KC_AT LSFT(KC_2) // @
#define KC_HASH LSFT(KC_3) // #
#define KC_DLR LSFT(KC_4) // $
#define KC_DOLLAR KC_DLR
#define KC_PERC LSFT(KC_5) // %
#define KC_PERCENT KC_PERC
#define KC_CIRC LSFT(KC_6) // ^
#define KC_CIRCUMFLEX KC_CIRC
#define KC_AMPR LSFT(KC_7) // &
#define KC_AMPERSAND KC_AMPR
#define KC_ASTR LSFT(KC_8) // *
#define KC_ASTERISK KC_ASTR
#define KC_LPRN LSFT(KC_9) // (
#define KC_LEFT_PAREN KC_LPRN
#define KC_RPRN LSFT(KC_0) // )
#define KC_RIGHT_PAREN KC_RPRN
#define KC_UNDS LSFT(KC_MINS) // _
#define KC_UNDERSCORE KC_UNDS
#define KC_PLUS LSFT(KC_EQL) // +
#define KC_LCBR LSFT(KC_LBRC) // {
#define KC_LEFT_CURLY_BRACE KC_LCBR
#define KC_RCBR LSFT(KC_RBRC) // }
#define KC_RIGHT_CURLY_BRACE KC_RCBR
#define KC_PIPE LSFT(KC_SLSH) // |
// Alias for function layers than expand past FN31
@@ -112,6 +130,9 @@ extern const uint16_t fn_actions[];
#define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE)
// These affect the backlight (if your keyboard has one).
// We don't need to comment them out if your keyboard doesn't have a backlight,
// since they don't take up any space.
#define BL_ON 0x4009
#define BL_OFF 0x4000
#define BL_0 0x4000
@@ -142,7 +163,7 @@ extern const uint16_t fn_actions[];
// when:
// ON_PRESS = 1
// ON_RELEASE = 2
// ON_BOTH = 3
// Unless you have a good reason not to do so, prefer ON_PRESS (1) as your default.
#define TO(layer, when) (layer | 0x5100 | (when << 0x4))
// Momentary switch layer - 256 layer max
@@ -153,7 +174,11 @@ extern const uint16_t fn_actions[];
#define MIDI(n) (n | 0x6000)
#define UNI(n) (n | 0x8000)
// For sending unicode codes.
// You may not send codes over 1FFF -- this supports most of UTF8.
// To have a key that sends out Œ, go UC(0x0152)
#define UNICODE(n) (n | 0x8000)
#define UC(n) UNICODE(n)
#endif