summaryrefslogtreecommitdiffstats
path: root/keyboards/ergodox_ez/ergodox_ez.c
diff options
context:
space:
mode:
authorDon Armstrong <don@donarmstrong.com>2017-10-27 22:34:03 +0200
committerDon Armstrong <don@donarmstrong.com>2017-10-27 22:34:03 +0200
commit364aeeec53b56efae45594940f1b634e7f16d69c (patch)
tree04a3c27e1e78620e729d52e109eacd9bdcc6878f /keyboards/ergodox_ez/ergodox_ez.c
parent2e3b99f7f13f293239808cf546a5d7bd10b5f715 (diff)
downloadqmk_firmware-364aeeec53b56efae45594940f1b634e7f16d69c.tar.gz
qmk_firmware-364aeeec53b56efae45594940f1b634e7f16d69c.tar.xz
implement ergodox_left_leds_update in ergodox_ez
Previously, this code was implemented in keymap.c, but I'm unaware of someone with a different implementation of this particular hack. [If someone has it, we can add another #ifdef in the future.]
Diffstat (limited to 'keyboards/ergodox_ez/ergodox_ez.c')
-rw-r--r--keyboards/ergodox_ez/ergodox_ez.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/keyboards/ergodox_ez/ergodox_ez.c b/keyboards/ergodox_ez/ergodox_ez.c
index 8337db666..8ada551ae 100644
--- a/keyboards/ergodox_ez/ergodox_ez.c
+++ b/keyboards/ergodox_ez/ergodox_ez.c
@@ -151,6 +151,40 @@ out:
return mcp23018_status;
}
+#ifdef LEFT_LEDS
+uint8_t ergodox_left_leds_update(void) {
+ if (mcp23018_status) { // if there was an error
+ return mcp23018_status;
+ }
+#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
+
+ // 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;
+}
+#endif
+
+
#ifdef ONEHAND_ENABLE
__attribute__ ((weak))
// swap-hands action needs a matrix to define the swap