From 65f8ee7dc81c1a119de0300dddc5fe2eb87cc2d6 Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Sun, 30 Apr 2017 20:47:40 -0700 Subject: [PATCH] add initial support for left leds on an ergodox ez --- layouts/community/ergodox/don/Makefile | 4 +++ layouts/community/ergodox/don/keymap.c | 40 ++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/layouts/community/ergodox/don/Makefile b/layouts/community/ergodox/don/Makefile index cae19a6f4..14b5afbde 100644 --- a/layouts/community/ergodox/don/Makefile +++ b/layouts/community/ergodox/don/Makefile @@ -15,9 +15,13 @@ UNICODE_ENABLE = yes # Unicode BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend +ifeq ($(SUBPROJECT_DIR),'infinity') VISUALIZER_ENABLE = yes LCD_BACKLIGHT_ENABLE = yes LCD_ENABLE = yes +else +OPT_DEFS+= -DLEFT_LEDS +endif dfu-util: $(BUILD_DIR)/$(TARGET).bin sizeafter while true; do \ diff --git a/layouts/community/ergodox/don/keymap.c b/layouts/community/ergodox/don/keymap.c index 21e71a4ce..39da4d6c2 100644 --- a/layouts/community/ergodox/don/keymap.c +++ b/layouts/community/ergodox/don/keymap.c @@ -206,3 +206,43 @@ void matrix_init_user(void) { void matrix_scan_user(void) { }; + +// if this is my ergodox ez, I have left LEDs. +#ifdef LEFT_LEDS + +extern bool ergodox_left_led_1; +extern bool ergodox_left_led_2; +extern bool ergodox_left_led_3; + + +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<