From cacf495c91c7f6ad0e31edcefa8355eba98f75b6 Mon Sep 17 00:00:00 2001 From: Joakim Tufvegren Date: Sun, 11 Oct 2020 02:48:52 +0200 Subject: [PATCH] Ergodox Infinity: Add EE_HANDS support. (#9527) Including a guide to set these EEPROM values (in the readme). --- keyboards/ergodox_infinity/matrix.c | 15 ++++++++++-- keyboards/ergodox_infinity/readme.md | 36 ++++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/keyboards/ergodox_infinity/matrix.c b/keyboards/ergodox_infinity/matrix.c index 3a0a179286..941367a360 100644 --- a/keyboards/ergodox_infinity/matrix.c +++ b/keyboards/ergodox_infinity/matrix.c @@ -24,6 +24,7 @@ along with this program. If not, see . #include "print.h" #include "debug.h" #include "matrix.h" +#include "eeconfig.h" #include "serial_link/system/serial_link.h" @@ -118,8 +119,12 @@ uint8_t matrix_scan(void) } uint8_t offset = 0; -#ifdef MASTER_IS_ON_RIGHT +#if (defined(EE_HANDS) || defined(MASTER_IS_ON_RIGHT)) +#ifdef EE_HANDS + if (is_serial_link_master() && !eeconfig_read_handedness()) { +#else if (is_serial_link_master()) { +#endif offset = MATRIX_ROWS - LOCAL_MATRIX_ROWS; } #endif @@ -162,7 +167,13 @@ void matrix_print(void) void matrix_set_remote(matrix_row_t* rows, uint8_t index) { uint8_t offset = 0; -#ifdef MASTER_IS_ON_RIGHT +#ifdef EE_HANDS + if (eeconfig_read_handedness()) { + offset = LOCAL_MATRIX_ROWS * (index + 1); + } else { + offset = MATRIX_ROWS - LOCAL_MATRIX_ROWS * (index + 2); + } +#elif defined(MASTER_IS_ON_RIGHT) offset = MATRIX_ROWS - LOCAL_MATRIX_ROWS * (index + 2); #else offset = LOCAL_MATRIX_ROWS * (index + 1); diff --git a/keyboards/ergodox_infinity/readme.md b/keyboards/ergodox_infinity/readme.md index d712bb880c..73ee3bc1df 100644 --- a/keyboards/ergodox_infinity/readme.md +++ b/keyboards/ergodox_infinity/readme.md @@ -29,6 +29,9 @@ Input Club Infinity Ergodox](https://github.com/fredizzimo/infinity_ergodox/blob The Infinity is two completely independent keyboards, that can connect together. You have a few options in how you flash the firmware: +- Add `#define EE_HANDS` to your config.h, initialize the EEPROM values (see below), + and then flash the same firmware to both halves. + - Flash the left half, rebuild the firmware with "MASTER=right" and then flash the right half. This allows you to plug in either half directly to the computer and is what the above instructions do. @@ -43,6 +46,35 @@ You have a few options in how you flash the firmware: directly connect the right half to the computer. - For minor changes such as changing only the keymap without having updated - any part of the firmware code itself, you can program only the MASTER half. + any part of the firmware code itself, you can program only the MASTER half, + but it is safest to program both halves. + +### EE_HANDS initialization + +To initialize the EEPROM values for `EE_HANDS` to work properly, these steps should work. +They only need to be done once, unless you reset the EEPROM later. + + - Plug in the left keyboard half to the computer, and press its program button. + + - Flash the left half with `make ergodox_infinity:default:dfu-util-split-left` + (If you need to use a different method to flash your keyboard, still run this command, + and abort it with Ctrl+C when the flashing attempts starts to print errors, + then flash the built firmware). + + - On the left half, press the top vertical 1.5U key (second from the top in the rightmost column) once, + then the 1U key at the bottom in the opposite corner (bottom left corner). + + - Plug in the right keyboard half to the computer, and press its program button. + + - Flash the right half with `make ergodox_infinity:default:dfu-util-split-right` + + - On the right half, press the top vertical 1.5U key (second from the top in the leftmost column) once, + then the 1U key at the bottom in the opposite corner (bottom right corner). + + - Add `#define EE_HANDS` to the config.h file of your keymap, and build your firmware using + `make ergodox_infinity:keymapname`. + + - After this, you can flash both halves with the same firmware, _without_ having to rebuild with + "MASTER=right" or risking a mirrored keyboard when connected the wrong way. + If you reset your EEPROM later, you'll have to follow these steps again, though. -- It is safest to program both halves though.