diff options
| -rw-r--r-- | keyboards/ergodox_infinity/config.h | 20 | ||||
| -rw-r--r-- | keyboards/ergodox_infinity/ergodox_infinity.c | 76 | ||||
| -rw-r--r-- | keyboards/ergodox_infinity/ergodox_infinity.h | 4 | ||||
| -rw-r--r-- | keyboards/ergodox_infinity/keymaps/default/keymap.c | 4 | ||||
| -rw-r--r-- | keyboards/ergodox_infinity/rules.mk | 15 |
5 files changed, 107 insertions, 12 deletions
diff --git a/keyboards/ergodox_infinity/config.h b/keyboards/ergodox_infinity/config.h index a00c593ee..275d4e1dc 100644 --- a/keyboards/ergodox_infinity/config.h +++ b/keyboards/ergodox_infinity/config.h | |||
| @@ -77,6 +77,26 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 77 | #define I2C1_SCL 0 | 77 | #define I2C1_SCL 0 |
| 78 | #define I2C1_SDA 1 | 78 | #define I2C1_SDA 1 |
| 79 | 79 | ||
| 80 | #ifdef ST7565_ENABLE | ||
| 81 | /* LCD driver */ | ||
| 82 | # define ST7565_A0_PIN C7 | ||
| 83 | # define ST7565_RST_PIN C8 | ||
| 84 | # define ST7565_SS_PIN C4 | ||
| 85 | # define ST7565_SPI_CLK_DIVISOR 2 | ||
| 86 | # define ST7565_CONTRAST 22 | ||
| 87 | # define ST7565_DISPLAY_WIDTH 128 | ||
| 88 | # define ST7565_DISPLAY_HEIGHT 32 | ||
| 89 | |||
| 90 | /* SPI (for LCD) */ | ||
| 91 | # define SPI_DRIVER SPID1 | ||
| 92 | # define SPI_SCK_PIN C5 | ||
| 93 | # define SPI_SCK_PAL_MODE PAL_MODE_ALTERNATIVE_2 | ||
| 94 | # define SPI_MOSI_PIN C6 | ||
| 95 | # define SPI_MOSI_PAL_MODE PAL_MODE_ALTERNATIVE_2 | ||
| 96 | # define SPI_MISO_PIN A4 // Just an unused pin, the "normal" MISO pin (C7) is used for other things | ||
| 97 | # define SPI_MISO_PAL_MODE PAL_MODE_ALTERNATIVE_7 // Default for A4 | ||
| 98 | #endif | ||
| 99 | |||
| 80 | /* define if matrix has ghost */ | 100 | /* define if matrix has ghost */ |
| 81 | //#define MATRIX_HAS_GHOST | 101 | //#define MATRIX_HAS_GHOST |
| 82 | 102 | ||
diff --git a/keyboards/ergodox_infinity/ergodox_infinity.c b/keyboards/ergodox_infinity/ergodox_infinity.c index da8ea311a..b802bf014 100644 --- a/keyboards/ergodox_infinity/ergodox_infinity.c +++ b/keyboards/ergodox_infinity/ergodox_infinity.c | |||
| @@ -128,7 +128,11 @@ static uint16_t cie_lightness(uint16_t v) { | |||
| 128 | return y * 65535.0f; | 128 | return y * 65535.0f; |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | #ifdef VISUALIZER_ENABLE | ||
| 131 | void lcd_backlight_hal_color(uint16_t r, uint16_t g, uint16_t b) { | 132 | void lcd_backlight_hal_color(uint16_t r, uint16_t g, uint16_t b) { |
| 133 | #else | ||
| 134 | void ergodox_infinity_lcd_color(uint16_t r, uint16_t g, uint16_t b) { | ||
| 135 | #endif | ||
| 132 | CHANNEL_RED.CnV = cie_lightness(r); | 136 | CHANNEL_RED.CnV = cie_lightness(r); |
| 133 | CHANNEL_GREEN.CnV = cie_lightness(g); | 137 | CHANNEL_GREEN.CnV = cie_lightness(g); |
| 134 | CHANNEL_BLUE.CnV = cie_lightness(b); | 138 | CHANNEL_BLUE.CnV = cie_lightness(b); |
| @@ -145,6 +149,13 @@ void keyboard_pre_init_kb() { | |||
| 145 | setPinOutput(B16); | 149 | setPinOutput(B16); |
| 146 | writePinHigh(B16); | 150 | writePinHigh(B16); |
| 147 | #endif | 151 | #endif |
| 152 | #ifndef VISUALIZER_ENABLE | ||
| 153 | // The backlight always has to be initialized, otherwise it will stay lit | ||
| 154 | lcd_backlight_hal_init(); | ||
| 155 | # ifdef ST7565_ENABLE | ||
| 156 | ergodox_infinity_lcd_color(UINT16_MAX / 2, UINT16_MAX / 2, UINT16_MAX / 2); | ||
| 157 | # endif | ||
| 158 | #endif | ||
| 148 | keyboard_pre_init_user(); | 159 | keyboard_pre_init_user(); |
| 149 | } | 160 | } |
| 150 | 161 | ||
| @@ -165,10 +176,6 @@ void matrix_init_kb(void) { | |||
| 165 | #endif | 176 | #endif |
| 166 | 177 | ||
| 167 | matrix_init_user(); | 178 | matrix_init_user(); |
| 168 | // The backlight always has to be initialized, otherwise it will stay lit | ||
| 169 | #ifndef VISUALIZER_ENABLE | ||
| 170 | lcd_backlight_hal_init(); | ||
| 171 | #endif | ||
| 172 | #if (defined(LED_MATRIX_ENABLE) || defined(WPM_ENABLE)) | 179 | #if (defined(LED_MATRIX_ENABLE) || defined(WPM_ENABLE)) |
| 173 | add_remote_objects(remote_objects, sizeof(remote_objects) / sizeof(remote_object_t *)); | 180 | add_remote_objects(remote_objects, sizeof(remote_objects) / sizeof(remote_object_t *)); |
| 174 | #endif | 181 | #endif |
| @@ -404,3 +411,64 @@ led_config_t g_led_config = { | |||
| 404 | } | 411 | } |
| 405 | }; | 412 | }; |
| 406 | #endif | 413 | #endif |
| 414 | |||
| 415 | #ifdef ST7565_ENABLE | ||
| 416 | __attribute__((weak)) void st7565_on_user(void) { | ||
| 417 | ergodox_infinity_lcd_color(UINT16_MAX / 2, UINT16_MAX / 2, UINT16_MAX / 2); | ||
| 418 | } | ||
| 419 | |||
| 420 | __attribute__((weak)) void st7565_off_user(void) { | ||
| 421 | ergodox_infinity_lcd_color(0, 0, 0); | ||
| 422 | } | ||
| 423 | |||
| 424 | static void format_layer_bitmap_string(char* buffer, uint8_t offset) { | ||
| 425 | for (int i = 0; i < 16 && i + offset < MAX_LAYER; i++) { | ||
| 426 | if (i == 0 || i == 4 || i == 8 || i == 12) { | ||
| 427 | *buffer = ' '; | ||
| 428 | ++buffer; | ||
| 429 | } | ||
| 430 | |||
| 431 | uint8_t layer = i + offset; | ||
| 432 | if (layer_state_cmp(default_layer_state, layer)) { | ||
| 433 | *buffer = 'D'; | ||
| 434 | } else if (layer_state_is(layer)) { | ||
| 435 | *buffer = '1'; | ||
| 436 | } else { | ||
| 437 | *buffer = '_'; | ||
| 438 | } | ||
| 439 | ++buffer; | ||
| 440 | } | ||
| 441 | *buffer = 0; | ||
| 442 | } | ||
| 443 | |||
| 444 | __attribute__((weak)) void st7565_task_user(void) { | ||
| 445 | if (is_keyboard_master()) { | ||
| 446 | // Draw led and layer status | ||
| 447 | led_t leds = host_keyboard_led_state(); | ||
| 448 | if(leds.num_lock) { st7565_write("Num ", false); } | ||
| 449 | if(leds.caps_lock) { st7565_write("Cap ", false); } | ||
| 450 | if(leds.scroll_lock) { st7565_write("Scrl ", false); } | ||
| 451 | if(leds.compose) { st7565_write("Com ", false); } | ||
| 452 | if(leds.kana) { st7565_write("Kana", false); } | ||
| 453 | st7565_advance_page(true); | ||
| 454 | |||
| 455 | char layer_buffer[16 + 5]; // 3 spaces and one null terminator | ||
| 456 | st7565_set_cursor(0, 1); | ||
| 457 | format_layer_bitmap_string(layer_buffer, 0); | ||
| 458 | st7565_write_ln(layer_buffer, false); | ||
| 459 | format_layer_bitmap_string(layer_buffer, 16); | ||
| 460 | st7565_write_ln(layer_buffer, false); | ||
| 461 | st7565_write_ln(" 1=On D=Default", false); | ||
| 462 | } else { | ||
| 463 | // Draw logo | ||
| 464 | static const char qmk_logo[] = { | ||
| 465 | 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, | ||
| 466 | 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, | ||
| 467 | 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0x00 | ||
| 468 | }; | ||
| 469 | |||
| 470 | st7565_write(qmk_logo, false); | ||
| 471 | st7565_write(" Infinity Ergodox ", false); | ||
| 472 | } | ||
| 473 | } | ||
| 474 | #endif | ||
diff --git a/keyboards/ergodox_infinity/ergodox_infinity.h b/keyboards/ergodox_infinity/ergodox_infinity.h index 79f01b184..81ac1f338 100644 --- a/keyboards/ergodox_infinity/ergodox_infinity.h +++ b/keyboards/ergodox_infinity/ergodox_infinity.h | |||
| @@ -80,6 +80,10 @@ inline void ergodox_led_all_set(uint8_t n) { | |||
| 80 | ergodox_right_led_3_set(n); | 80 | ergodox_right_led_3_set(n); |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | #ifndef VISUALIZER_ENABLE | ||
| 84 | void ergodox_infinity_lcd_color(uint16_t r, uint16_t g, uint16_t b); | ||
| 85 | #endif | ||
| 86 | |||
| 83 | /* | 87 | /* |
| 84 | * LEFT HAND: LINES 88-95 | 88 | * LEFT HAND: LINES 88-95 |
| 85 | * RIGHT HAND: LINES 97-104 | 89 | * RIGHT HAND: LINES 97-104 |
diff --git a/keyboards/ergodox_infinity/keymaps/default/keymap.c b/keyboards/ergodox_infinity/keymaps/default/keymap.c index cd9b476bb..ce8a3661e 100644 --- a/keyboards/ergodox_infinity/keymaps/default/keymap.c +++ b/keyboards/ergodox_infinity/keymaps/default/keymap.c | |||
| @@ -167,7 +167,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 167 | // Runs just one time when the keyboard initializes. | 167 | // Runs just one time when the keyboard initializes. |
| 168 | void matrix_init_user(void) { | 168 | void matrix_init_user(void) { |
| 169 | 169 | ||
| 170 | }; | 170 | } |
| 171 | 171 | ||
| 172 | 172 | ||
| 173 | // Runs constantly in the background, in a loop. | 173 | // Runs constantly in the background, in a loop. |
| @@ -192,4 +192,4 @@ void matrix_scan_user(void) { | |||
| 192 | break; | 192 | break; |
| 193 | } | 193 | } |
| 194 | 194 | ||
| 195 | }; | 195 | } |
diff --git a/keyboards/ergodox_infinity/rules.mk b/keyboards/ergodox_infinity/rules.mk index 70bcabe80..c7ff07d4e 100644 --- a/keyboards/ergodox_infinity/rules.mk +++ b/keyboards/ergodox_infinity/rules.mk | |||
| @@ -20,19 +20,22 @@ SWAP_HANDS_ENABLE= yes # Allow swapping hands of keyboard | |||
| 20 | 20 | ||
| 21 | CUSTOM_MATRIX = yes # Custom matrix file | 21 | CUSTOM_MATRIX = yes # Custom matrix file |
| 22 | SERIAL_LINK_ENABLE = yes | 22 | SERIAL_LINK_ENABLE = yes |
| 23 | VISUALIZER_ENABLE = yes | 23 | |
| 24 | LCD_ENABLE = yes | ||
| 25 | LCD_BACKLIGHT_ENABLE = yes | ||
| 26 | MIDI_ENABLE = no | 24 | MIDI_ENABLE = no |
| 27 | RGBLIGHT_ENABLE = no | 25 | RGBLIGHT_ENABLE = no |
| 28 | 26 | ||
| 29 | LCD_DRIVER = st7565 | 27 | ST7565_ENABLE = yes |
| 30 | LCD_WIDTH = 128 | ||
| 31 | LCD_HEIGHT = 32 | ||
| 32 | 28 | ||
| 33 | LED_MATRIX_ENABLE = yes | 29 | LED_MATRIX_ENABLE = yes |
| 34 | LED_MATRIX_DRIVER = IS31FL3731 | 30 | LED_MATRIX_DRIVER = IS31FL3731 |
| 35 | 31 | ||
| 32 | # Config for Visualizer (set VISUALIZER_ENABLE = yes and ST7565_ENABLE = no to use) | ||
| 33 | LCD_ENABLE = yes | ||
| 34 | LCD_BACKLIGHT_ENABLE = yes | ||
| 35 | LCD_DRIVER = st7565 | ||
| 36 | LCD_WIDTH = 128 | ||
| 37 | LCD_HEIGHT = 32 | ||
| 38 | |||
| 36 | # project specific files | 39 | # project specific files |
| 37 | SRC = matrix.c \ | 40 | SRC = matrix.c \ |
| 38 | led.c | 41 | led.c |
