More work on ErgoDox EZ default keymap
This commit is contained in:
		
							parent
							
								
									2739aa8d78
								
							
						
					
					
						commit
						d3db8d62f6
					
				@ -27,7 +27,8 @@ TARGET_DIR = .
 | 
			
		||||
 | 
			
		||||
# # project specific files
 | 
			
		||||
SRC = ergodox_ez.c \
 | 
			
		||||
	  twimaster.c
 | 
			
		||||
	  twimaster.c \
 | 
			
		||||
	  matrix.c
 | 
			
		||||
 | 
			
		||||
ifdef KEYMAP
 | 
			
		||||
    SRC := keymaps/keymap_$(KEYMAP).c $(SRC)
 | 
			
		||||
@ -84,17 +85,18 @@ OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
 | 
			
		||||
#   Atmel DFU loader 4096
 | 
			
		||||
#   LUFA bootloader  4096
 | 
			
		||||
#   USBaspLoader     2048
 | 
			
		||||
OPT_DEFS += -DBOOTLOADER_SIZE=4096
 | 
			
		||||
OPT_DEFS += -DBOOTLOADER_SIZE=512
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Build Options
 | 
			
		||||
#   comment out to disable the options.
 | 
			
		||||
#
 | 
			
		||||
BOOTMAGIC_ENABLE = yes	# Virtual DIP switch configuration(+1000)
 | 
			
		||||
MOUSEKEY_ENABLE = yes	# Mouse keys(+4700)
 | 
			
		||||
EXTRAKEY_ENABLE = yes	# Audio control and System control(+450)
 | 
			
		||||
CONSOLE_ENABLE = yes	# Console for debug(+400)
 | 
			
		||||
COMMAND_ENABLE = yes    # Commands for debug and configuration
 | 
			
		||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
 | 
			
		||||
MOUSEKEY_ENABLE  = yes # Mouse keys(+4700)
 | 
			
		||||
EXTRAKEY_ENABLE  = yes # Audio control and System control(+450)
 | 
			
		||||
CONSOLE_ENABLE   = yes # Console for debug(+400)
 | 
			
		||||
COMMAND_ENABLE   = yes # Commands for debug and configuration
 | 
			
		||||
CUSTOM_MATRIX    = yes # Custom matrix file for the ErgoDox EZ
 | 
			
		||||
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
 | 
			
		||||
# SLEEP_LED_ENABLE = yes  # Breathing sleep LED during USB suspend
 | 
			
		||||
# NKRO_ENABLE = yes		# USB Nkey Rollover - not yet supported in LUFA
 | 
			
		||||
 | 
			
		||||
@ -52,7 +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    100
 | 
			
		||||
#define TAPPING_TERM    200
 | 
			
		||||
 | 
			
		||||
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
 | 
			
		||||
#define LOCKING_SUPPORT_ENABLE
 | 
			
		||||
 | 
			
		||||
@ -4,10 +4,6 @@
 | 
			
		||||
bool i2c_initialized = 0;
 | 
			
		||||
uint8_t mcp23018_status = 0x20;
 | 
			
		||||
 | 
			
		||||
bool ergodox_left_led_1 = 0;  // left top
 | 
			
		||||
bool ergodox_left_led_2 = 0;  // left middle
 | 
			
		||||
bool ergodox_left_led_3 = 0;  // left bottom
 | 
			
		||||
 | 
			
		||||
__attribute__ ((weak))
 | 
			
		||||
void * matrix_init_user(void) {
 | 
			
		||||
 | 
			
		||||
@ -92,32 +88,7 @@ uint8_t init_mcp23018(void) {
 | 
			
		||||
out:
 | 
			
		||||
    i2c_stop();
 | 
			
		||||
 | 
			
		||||
    if (!mcp23018_status) mcp23018_status = ergodox_left_leds_update();
 | 
			
		||||
 | 
			
		||||
    return mcp23018_status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint8_t ergodox_left_leds_update(void) {
 | 
			
		||||
    if (mcp23018_status) { // if there was an error
 | 
			
		||||
        return mcp23018_status;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // set logical value (doesn't matter on inputs)
 | 
			
		||||
    // - unused  : hi-Z : 1
 | 
			
		||||
    // - input   : hi-Z : 1
 | 
			
		||||
    // - driving : hi-Z : 1
 | 
			
		||||
    mcp23018_status = i2c_start(I2C_ADDR_WRITE);    if (mcp23018_status) goto out;
 | 
			
		||||
    mcp23018_status = i2c_write(OLATA);             if (mcp23018_status) goto out;
 | 
			
		||||
    mcp23018_status = i2c_write(0b11111111
 | 
			
		||||
            & ~(ergodox_left_led_3<<LEFT_LED_3_SHIFT)
 | 
			
		||||
          );                                        if (mcp23018_status) goto out;
 | 
			
		||||
    mcp23018_status = i2c_write(0b11111111
 | 
			
		||||
            & ~(ergodox_left_led_2<<LEFT_LED_2_SHIFT)
 | 
			
		||||
            & ~(ergodox_left_led_1<<LEFT_LED_1_SHIFT)
 | 
			
		||||
          );                                        if (mcp23018_status) goto out;
 | 
			
		||||
 | 
			
		||||
out:
 | 
			
		||||
    i2c_stop();
 | 
			
		||||
    return mcp23018_status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -37,29 +37,16 @@ uint8_t ergodox_left_leds_update(void);
 | 
			
		||||
#define LED_BRIGHTNESS_LO       31
 | 
			
		||||
#define LED_BRIGHTNESS_HI       255
 | 
			
		||||
 | 
			
		||||
#define LEFT_LED_1_SHIFT        7       // in MCP23018 port B
 | 
			
		||||
#define LEFT_LED_2_SHIFT        6       // in MCP23018 port B
 | 
			
		||||
#define LEFT_LED_3_SHIFT        7       // in MCP23018 port A
 | 
			
		||||
 | 
			
		||||
extern bool ergodox_left_led_1;         // left top
 | 
			
		||||
extern bool ergodox_left_led_2;         // left middle
 | 
			
		||||
extern bool ergodox_left_led_3;         // left bottom
 | 
			
		||||
 | 
			
		||||
inline void ergodox_board_led_on(void)      { DDRD |=  (1<<6); PORTD |=  (1<<6); }
 | 
			
		||||
inline void ergodox_right_led_1_on(void)    { DDRB |=  (1<<5); PORTB |=  (1<<5); }
 | 
			
		||||
inline void ergodox_right_led_2_on(void)    { DDRB |=  (1<<6); PORTB |=  (1<<6); }
 | 
			
		||||
inline void ergodox_right_led_3_on(void)    { DDRB |=  (1<<7); PORTB |=  (1<<7); }
 | 
			
		||||
inline void ergodox_left_led_1_on(void)     { ergodox_left_led_1 = 1; }
 | 
			
		||||
inline void ergodox_left_led_2_on(void)     { ergodox_left_led_2 = 1; }
 | 
			
		||||
inline void ergodox_left_led_3_on(void)     { ergodox_left_led_3 = 1; }
 | 
			
		||||
 | 
			
		||||
inline void ergodox_board_led_off(void)     { DDRD &= ~(1<<6); PORTD &= ~(1<<6); }
 | 
			
		||||
inline void ergodox_right_led_1_off(void)   { DDRB &= ~(1<<5); PORTB &= ~(1<<5); }
 | 
			
		||||
inline void ergodox_right_led_2_off(void)   { DDRB &= ~(1<<6); PORTB &= ~(1<<6); }
 | 
			
		||||
inline void ergodox_right_led_3_off(void)   { DDRB &= ~(1<<7); PORTB &= ~(1<<7); }
 | 
			
		||||
inline void ergodox_left_led_1_off(void)    { ergodox_left_led_1 = 0; }
 | 
			
		||||
inline void ergodox_left_led_2_off(void)    { ergodox_left_led_2 = 0; }
 | 
			
		||||
inline void ergodox_left_led_3_off(void)    { ergodox_left_led_3 = 0; }
 | 
			
		||||
 | 
			
		||||
inline void ergodox_led_all_on(void)
 | 
			
		||||
{
 | 
			
		||||
@ -67,10 +54,6 @@ inline void ergodox_led_all_on(void)
 | 
			
		||||
    ergodox_right_led_1_on();
 | 
			
		||||
    ergodox_right_led_2_on();
 | 
			
		||||
    ergodox_right_led_3_on();
 | 
			
		||||
    ergodox_left_led_1_on();
 | 
			
		||||
    ergodox_left_led_2_on();
 | 
			
		||||
    ergodox_left_led_3_on();
 | 
			
		||||
    ergodox_left_leds_update();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline void ergodox_led_all_off(void)
 | 
			
		||||
@ -79,10 +62,6 @@ inline void ergodox_led_all_off(void)
 | 
			
		||||
    ergodox_right_led_1_off();
 | 
			
		||||
    ergodox_right_led_2_off();
 | 
			
		||||
    ergodox_right_led_3_off();
 | 
			
		||||
    ergodox_left_led_1_off();
 | 
			
		||||
    ergodox_left_led_2_off();
 | 
			
		||||
    ergodox_left_led_3_off();
 | 
			
		||||
    ergodox_left_leds_update();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline void ergodox_right_led_1_set(uint8_t n)    { OCR1A = n; }
 | 
			
		||||
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -46,15 +46,15 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
 | 
			
		||||
             KC_COLN,KC_Y,   KC_U,   KC_I,   KC_O,   KC_P,             KC_BSLS,
 | 
			
		||||
                     KC_H,   KC_J,   KC_K,   KC_L,   LT(MDIA, KC_SCLN),KC_QUOT,
 | 
			
		||||
             TG(1),  KC_N,   KC_M,   KC_COMM,KC_DOT, CTL_T(KC_SLSH),   KC_RSFT,
 | 
			
		||||
                             KC_UP,  KC_DOWN,KC_RBRC,KC_LBRC,          KC_FN1,
 | 
			
		||||
             KC_RALT,        CTL_T(KC_ESC),
 | 
			
		||||
                             KC_UP,  KC_DOWN,KC_LBRC,KC_RBRC,          KC_FN1,
 | 
			
		||||
             KC_LALT,        CTL_T(KC_ESC),
 | 
			
		||||
             KC_PGUP,
 | 
			
		||||
             KC_PGDN,KC_TAB, KC_ENT
 | 
			
		||||
    ),
 | 
			
		||||
/* Keymap 1: Symbol Layer
 | 
			
		||||
 *
 | 
			
		||||
 * ,--------------------------------------------------.           ,--------------------------------------------------.
 | 
			
		||||
 * |  Flash |  F1  |  F2  |  F3  |  F4  |  F5  |      |           |      |  F6  |  F7  |  F8  |  F9  |  F10 |   F11  |
 | 
			
		||||
 * |        |  F1  |  F2  |  F3  |  F4  |  F5  |      |           |      |  F6  |  F7  |  F8  |  F9  |  F10 |   F11  |
 | 
			
		||||
 * |--------+------+------+------+------+-------------|           |------+------+------+------+------+------+--------|
 | 
			
		||||
 * |        |   !  |   @  |   {  |   }  |   |  |      |           |      |   Up |   7  |   8  |   9  |   *  |   F12  |
 | 
			
		||||
 * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
 | 
			
		||||
@ -75,7 +75,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
 | 
			
		||||
// SYMBOLS
 | 
			
		||||
[SYMB] = KEYMAP(
 | 
			
		||||
       // left hand
 | 
			
		||||
       RESET,  KC_F1,  KC_F2,  KC_F3,  KC_F4,  KC_F5,  KC_TRNS,
 | 
			
		||||
       KC_TRNS,KC_F1,  KC_F2,  KC_F3,  KC_F4,  KC_F5,  KC_TRNS,
 | 
			
		||||
       KC_TRNS,KC_EXLM,KC_AT,  KC_LCBR,KC_RCBR,KC_PIPE,KC_TRNS,
 | 
			
		||||
       KC_COLN,KC_HASH,KC_DLR, KC_LPRN,KC_RPRN,KC_GRV,
 | 
			
		||||
       KC_TRNS,KC_PERC,KC_CIRC,KC_LBRC,KC_RBRC,KC_TILD,KC_TRNS,
 | 
			
		||||
@ -162,50 +162,24 @@ void * matrix_init_user(void) {
 | 
			
		||||
 | 
			
		||||
// Runs constantly in the background, in a loop.
 | 
			
		||||
void * matrix_scan_user(void) {
 | 
			
		||||
 | 
			
		||||
    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();
 | 
			
		||||
    ergodox_right_led_1_off();
 | 
			
		||||
    ergodox_right_led_2_off();
 | 
			
		||||
    ergodox_right_led_3_off();
 | 
			
		||||
    switch (layer) {
 | 
			
		||||
      // TODO: Make this relevant to the ErgoDox EZ.
 | 
			
		||||
        case 1:
 | 
			
		||||
            // all
 | 
			
		||||
            ergodox_left_led_1_on();
 | 
			
		||||
            ergodox_left_led_2_on();
 | 
			
		||||
            ergodox_left_led_3_on();
 | 
			
		||||
            ergodox_right_led_1_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();
 | 
			
		||||
            ergodox_right_led_2_on();
 | 
			
		||||
            break;
 | 
			
		||||
        default:
 | 
			
		||||
            // none
 | 
			
		||||
            break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    mcp23018_status = ergodox_left_leds_update();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -277,7 +277,7 @@ static void unselect_rows(void)
 | 
			
		||||
        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
 | 
			
		||||
                              & ~(ergodox_left_led_3<<LEFT_LED_3_SHIFT)
 | 
			
		||||
                              & ~(0<<7)
 | 
			
		||||
                          );                            if (mcp23018_status) goto out;
 | 
			
		||||
    out:
 | 
			
		||||
        i2c_stop();
 | 
			
		||||
@ -305,7 +305,7 @@ static void select_row(uint8_t row)
 | 
			
		||||
            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)
 | 
			
		||||
                                  & ~(ergodox_left_led_3<<LEFT_LED_3_SHIFT)
 | 
			
		||||
                                  & ~(0<<7)
 | 
			
		||||
                              );                                if (mcp23018_status) goto out;
 | 
			
		||||
        out:
 | 
			
		||||
            i2c_stop();
 | 
			
		||||
 | 
			
		||||
@ -19,6 +19,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
#include "report.h"
 | 
			
		||||
#include "keycode.h"
 | 
			
		||||
#include "action_layer.h"
 | 
			
		||||
#include <util/delay.h>
 | 
			
		||||
#include "action.h"
 | 
			
		||||
#include "action_macro.h"
 | 
			
		||||
#include "debug.h"
 | 
			
		||||
@ -71,6 +72,8 @@ action_t action_for_key(uint8_t layer, keypos_t key)
 | 
			
		||||
        return action;
 | 
			
		||||
#endif
 | 
			
		||||
    } else if (keycode == RESET) { // RESET is 0x5000, which is why this is here
 | 
			
		||||
        clear_keyboard();
 | 
			
		||||
        _delay_ms(250);
 | 
			
		||||
        bootloader_jump();
 | 
			
		||||
        return;
 | 
			
		||||
    } else if (keycode == DEBUG) { // DEBUG is 0x5001
 | 
			
		||||
 | 
			
		||||
@ -190,12 +190,7 @@ extern const uint16_t fn_actions[];
 | 
			
		||||
#define GUI_T(kc) MT(0x8, kc)
 | 
			
		||||
 | 
			
		||||
// L-ayer, T-ap - 256 keycode max, 16 layer max
 | 
			
		||||
#define LT(layer, kc) (kc | 0x7000 | ((layer & 0xF) << 8))
 | 
			
		||||
 | 
			
		||||
// 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 LT(layer, kc) (kc | 0x8000 | ((layer & 0xF) << 8))
 | 
			
		||||
#define UC(n) UNICODE(n)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user