diff options
Diffstat (limited to 'keyboards/ergodox_infinity')
17 files changed, 68 insertions, 1549 deletions
diff --git a/keyboards/ergodox_infinity/board_is31fl3731c.h b/keyboards/ergodox_infinity/board_is31fl3731c.h deleted file mode 100644 index b2ed2b0031..0000000000 --- a/keyboards/ergodox_infinity/board_is31fl3731c.h +++ /dev/null @@ -1,110 +0,0 @@ -/* -Copyright 2016 Fred Sundvik <fsundvik@gmail.com> - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -#ifndef _GDISP_LLD_BOARD_H -#define _GDISP_LLD_BOARD_H - -static const I2CConfig i2ccfg = { - 400000 // clock speed (Hz); 400kHz max for IS31 -}; - -static const uint8_t led_mask[] = { - 0xFF, 0x00, /* C1-1 -> C1-16 */ - 0xFF, 0x00, /* C2-1 -> C2-16 */ - 0xFF, 0x00, /* C3-1 -> C3-16 */ - 0xFF, 0x00, /* C4-1 -> C4-16 */ - 0x3F, 0x00, /* C5-1 -> C5-16 */ - 0x00, 0x00, /* C6-1 -> C6-16 */ - 0x00, 0x00, /* C7-1 -> C7-16 */ - 0x00, 0x00, /* C8-1 -> C8-16 */ - 0x00, 0x00, /* C9-1 -> C9-16 */ -}; - -// The address of the LED -#define LA(c, r) (c + r * 16 ) -// Need to be an address that is not mapped, but inside the range of the controller matrix -#define NA LA(8, 8) - -// The numbers in the comments are the led numbers DXX on the PCB -// The mapping is taken from the schematic of left hand side -static const uint8_t led_mapping[GDISP_SCREEN_HEIGHT][GDISP_SCREEN_WIDTH] = { -// 45 44 43 42 41 40 39 - { LA(1, 1), LA(1, 0), LA(0, 4), LA(0, 3), LA(0, 2), LA(0, 1), LA(0, 0)}, -// 52 51 50 49 48 47 46 - { LA(2, 3), LA(2, 2), LA(2, 1), LA(2, 0), LA(1, 4), LA(1, 3), LA(1, 2) }, -// 58 57 56 55 54 53 N/A - { LA(3, 4), LA(3, 3), LA(3, 2), LA(3, 1), LA(3, 0), LA(2, 4), NA }, -// 67 66 65 64 63 62 61 - { LA(5, 3), LA(5, 2), LA(5, 1), LA(5, 0), LA(4, 4), LA(4, 3), LA(4, 2) }, -// 76 75 74 73 72 60 59 - { LA(7, 3), LA(7, 2), LA(7, 1), LA(7, 0), LA(6, 3), LA(4, 1), LA(4, 0) }, -// N/A N/A N/A N/A N/A N/A 68 - { NA, NA, NA, NA, NA, NA, LA(5, 4) }, -// N/A N/A N/A N/A 71 70 69 - { NA, NA, NA, NA, LA(6, 2), LA(6, 1), LA(6, 0) }, -}; - - -#define IS31_ADDR_DEFAULT 0x74 // AD connected to GND -#define IS31_TIMEOUT 5000 - -static GFXINLINE void init_board(GDisplay *g) { - (void) g; - /* I2C pins */ - palSetPadMode(GPIOB, 0, PAL_MODE_ALTERNATIVE_2); // PTB0/I2C0/SCL - palSetPadMode(GPIOB, 1, PAL_MODE_ALTERNATIVE_2); // PTB1/I2C0/SDA - palSetPadMode(GPIOB, 16, PAL_MODE_OUTPUT_PUSHPULL); - palClearPad(GPIOB, 16); - /* start I2C */ - i2cStart(&I2CD1, &i2ccfg); - // try high drive (from kiibohd) - I2CD1.i2c->C2 |= I2Cx_C2_HDRS; - // try glitch fixing (from kiibohd) - I2CD1.i2c->FLT = 4; -} - -static GFXINLINE void post_init_board(GDisplay *g) { - (void) g; -} - -static GFXINLINE const uint8_t* get_led_mask(GDisplay* g) { - (void) g; - return led_mask; -} - -static GFXINLINE uint8_t get_led_address(GDisplay* g, uint16_t x, uint16_t y) -{ - (void) g; - return led_mapping[y][x]; -} - -static GFXINLINE void set_hardware_shutdown(GDisplay* g, bool shutdown) { - (void) g; - if(!shutdown) { - palSetPad(GPIOB, 16); - } - else { - palClearPad(GPIOB, 16); - } -} - -static GFXINLINE void write_data(GDisplay *g, uint8_t* data, uint16_t length) { - (void) g; - i2cMasterTransmitTimeout(&I2CD1, IS31_ADDR_DEFAULT, data, length, 0, 0, TIME_US2I(IS31_TIMEOUT)); -} - -#endif /* _GDISP_LLD_BOARD_H */ diff --git a/keyboards/ergodox_infinity/board_st7565.h b/keyboards/ergodox_infinity/board_st7565.h deleted file mode 100644 index 875ed9e65c..0000000000 --- a/keyboards/ergodox_infinity/board_st7565.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * This file is subject to the terms of the GFX License. If a copy of - * the license was not distributed with this file, you can obtain one at: - * - * http://ugfx.org/license.html - */ - -#ifndef _GDISP_LLD_BOARD_H -#define _GDISP_LLD_BOARD_H - -#include "quantum.h" - -#define ST7565_LCD_BIAS ST7565_LCD_BIAS_7 -#define ST7565_COM_SCAN ST7565_COM_SCAN_DEC -#define ST7565_PAGE_ORDER 0, 1, 2, 3 -/* - * Custom page order for several LCD boards, e.g. HEM12864-99 - * #define ST7565_PAGE_ORDER 4,5,6,7,0,1,2,3 - */ - -#define ST7565_A0_PIN C7 -#define ST7565_RST_PIN C8 -#define ST7565_MOSI_PIN C6 -#define ST7565_SCLK_PIN C5 -#define ST7565_SS_PIN C4 - -// DSPI Clock and Transfer Attributes -// Frame Size: 8 bits -// MSB First -// CLK Low by default -static const SPIConfig spi1config = { - // Operation complete callback or @p NULL. - .end_cb = NULL, - // The chip select line port - when not using pcs. - .ssport = PAL_PORT(ST7565_SS_PIN), - // brief The chip select line pad number - when not using pcs. - .sspad = PAL_PAD(ST7565_SS_PIN), - // SPI initialization data. - .tar0 = SPIx_CTARn_FMSZ(7) // Frame size = 8 bytes - | SPIx_CTARn_ASC(1) // After SCK Delay Scaler (min 50 ns) = 55.56ns - | SPIx_CTARn_DT(0) // Delay After Transfer Scaler (no minimum)= 27.78ns - | SPIx_CTARn_CSSCK(0) // PCS to SCK Delay Scaler (min 20 ns) = 27.78ns - | SPIx_CTARn_PBR(0) // Baud Rate Prescaler = 2 - | SPIx_CTARn_BR(0) // Baud rate (min 50ns) = 55.56ns -}; - -static GFXINLINE void acquire_bus(GDisplay *g) { - (void)g; - // Only the LCD is using the SPI bus, so no need to acquire - // spiAcquireBus(&SPID1); - spiSelect(&SPID1); -} - -static GFXINLINE void release_bus(GDisplay *g) { - (void)g; - // Only the LCD is using the SPI bus, so no need to release - // spiReleaseBus(&SPID1); - spiUnselect(&SPID1); -} - -static GFXINLINE void init_board(GDisplay *g) { - (void)g; - setPinOutput(ST7565_A0_PIN); - writePinHigh(ST7565_A0_PIN); - setPinOutput(ST7565_RST_PIN); - writePinHigh(ST7565_RST_PIN); - setPinOutput(ST7565_SS_PIN); - - palSetPadMode(PAL_PORT(ST7565_MOSI_PIN), PAL_PAD(ST7565_MOSI_PIN), PAL_MODE_ALTERNATIVE_2); - palSetPadMode(PAL_PORT(ST7565_SCLK_PIN), PAL_PAD(ST7565_SCLK_PIN), PAL_MODE_ALTERNATIVE_2); - - spiInit(); - spiStart(&SPID1, &spi1config); - release_bus(g); -} - -static GFXINLINE void post_init_board(GDisplay *g) { (void)g; } - -static GFXINLINE void setpin_reset(GDisplay *g, bool_t state) { - (void)g; - writePin(ST7565_RST_PIN, !state); -} - -static GFXINLINE void write_cmd(GDisplay *g, gU8 cmd) { - (void)g; - writePinLow(ST7565_A0_PIN); - spiSend(&SPID1, 1, &cmd); -} - -static GFXINLINE void write_data(GDisplay *g, gU8 *data, gU16 length) { - (void)g; - writePinHigh(ST7565_A0_PIN); - spiSend(&SPID1, length, data); -} - -#endif /* _GDISP_LLD_BOARD_H */ diff --git a/keyboards/ergodox_infinity/config.h b/keyboards/ergodox_infinity/config.h index 4bee8c3d93..5dcc707a5d 100644 --- a/keyboards/ergodox_infinity/config.h +++ b/keyboards/ergodox_infinity/config.h @@ -15,9 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef INFINITY_ERGODOX_CONFIG_H -#define INFINITY_ERGODOX_CONFIG_H - +#pragma once /* USB Device descriptor parameter */ #define VENDOR_ID 0x1c11 @@ -85,9 +83,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define I2C1_CLOCK_SPEED 400000 #define I2C1_SCL_PAL_MODE PAL_MODE_ALTERNATIVE_2 #define I2C1_SDA_PAL_MODE PAL_MODE_ALTERNATIVE_2 -#define I2C1_BANK GPIOB -#define I2C1_SCL 0 -#define I2C1_SDA 1 +#define I2C1_SCL_PIN B0 +#define I2C1_SDA_PIN B1 #ifdef ST7565_ENABLE /* LCD driver */ @@ -115,8 +112,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. /* Set 0 if debouncing isn't needed */ #define DEBOUNCE 5 -#define VISUALIZER_USER_DATA_SIZE 16 - /* * Feature disable options * These options are also useful to firmware size reduction. @@ -134,5 +129,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. //#define NO_ACTION_ONESHOT //#define NO_ACTION_MACRO //#define NO_ACTION_FUNCTION - -#endif diff --git a/keyboards/ergodox_infinity/ergodox_infinity.c b/keyboards/ergodox_infinity/ergodox_infinity.c index 8f5b068a72..88028d3638 100644 --- a/keyboards/ergodox_infinity/ergodox_infinity.c +++ b/keyboards/ergodox_infinity/ergodox_infinity.c @@ -3,10 +3,6 @@ #include <hal.h> #include <string.h> #include "eeconfig.h" -#include "serial_link/system/serial_link.h" -#ifdef VISUALIZER_ENABLE -# include "lcd_backlight.h" -#endif #define RED_PIN 1 #define GREEN_PIN 2 @@ -87,11 +83,7 @@ static uint16_t cie_lightness(uint16_t v) { return y * 65535.0f; } -#ifdef VISUALIZER_ENABLE -void lcd_backlight_hal_color(uint16_t r, uint16_t g, uint16_t b) { -#else void ergodox_infinity_lcd_color(uint16_t r, uint16_t g, uint16_t b) { -#endif CHANNEL_RED.CnV = cie_lightness(r); CHANNEL_GREEN.CnV = cie_lightness(g); CHANNEL_BLUE.CnV = cie_lightness(b); @@ -108,12 +100,10 @@ void keyboard_pre_init_kb() { setPinOutput(B16); writePinHigh(B16); #endif -#ifndef VISUALIZER_ENABLE // The backlight always has to be initialized, otherwise it will stay lit lcd_backlight_hal_init(); -# ifdef ST7565_ENABLE +#ifdef ST7565_ENABLE ergodox_infinity_lcd_color(UINT16_MAX / 2, UINT16_MAX / 2, UINT16_MAX / 2); -# endif #endif keyboard_pre_init_user(); } diff --git a/keyboards/ergodox_infinity/ergodox_infinity.h b/keyboards/ergodox_infinity/ergodox_infinity.h index 81ac1f338a..b9636b69be 100644 --- a/keyboards/ergodox_infinity/ergodox_infinity.h +++ b/keyboards/ergodox_infinity/ergodox_infinity.h @@ -1,5 +1,4 @@ -#ifndef KEYBOARDS_ERGODOX_INFINITY_INFINITY_H_ -#define KEYBOARDS_ERGODOX_INFINITY_INFINITY_H_ +#pragma once #include "quantum.h" @@ -80,85 +79,75 @@ inline void ergodox_led_all_set(uint8_t n) { ergodox_right_led_3_set(n); } -#ifndef VISUALIZER_ENABLE void ergodox_infinity_lcd_color(uint16_t r, uint16_t g, uint16_t b); -#endif -/* - * LEFT HAND: LINES 88-95 - * RIGHT HAND: LINES 97-104 - */ +#define XXX KC_NO + #define LAYOUT_ergodox( \ - A80, A70, A60, A50, A40, A30, A20, \ - A81, A71, A61, A51, A41, A31, A21, \ - A82, A72, A62, A52, A42, A32, \ - A83, A73, A63, A53, A43, A33, A23, \ - A84, A74, A64, A54, A44, \ + A80, A70, A60, A50, A40, A30, A20, \ + A81, A71, A61, A51, A41, A31, A21, \ + A82, A72, A62, A52, A42, A32, \ + A83, A73, A63, A53, A43, A33, A23, \ + A84, A74, A64, A54, A44, \ A13, A03, \ A04, \ A34, A24, A14, \ - \ +\ B20, B30, B40, B50, B60, B70, B80, \ B21, B31, B41, B51, B61, B71, B81, \ B32, B42, B52, B62, B72, B82, \ B23, B33, B43, B53, B63, B73, B83, \ B44, B54, B64, B74, B84, \ - B03, B13, \ - B04, \ + B03, B13, \ + B04, \ B14, B24, B34 \ ) { \ - { KC_NO, KC_NO, KC_NO, A03, A04 }, \ - { KC_NO, KC_NO, KC_NO, A13, A14 }, \ - { A20, A21, KC_NO, A23, A24 }, \ - { A30, A31, A32, A33, A34 }, \ - { A40, A41, A42, A43, A44 }, \ - { A50, A51, A52, A53, A54 }, \ - { A60, A61, A62, A63, A64 }, \ - { A70, A71, A72, A73, A74 }, \ - { A80, A81, A82, A83, A84 }, \ - { KC_NO, KC_NO, KC_NO, B03, B04 }, \ - { KC_NO, KC_NO, KC_NO, B13, B14 }, \ - { B20, B21, KC_NO, B23, B24 }, \ - { B30, B31, B32, B33, B34 }, \ - { B40, B41, B42, B43, B44 }, \ - { B50, B51, B52, B53, B54 }, \ - { B60, B61, B62, B63, B64 }, \ - { B70, B71, B72, B73, B74 }, \ - { B80, B81, B82, B83, B84 } \ + { XXX, XXX, XXX, A03, A04 }, \ + { XXX, XXX, XXX, A13, A14 }, \ + { A20, A21, XXX, A23, A24 }, \ + { A30, A31, A32, A33, A34 }, \ + { A40, A41, A42, A43, A44 }, \ + { A50, A51, A52, A53, A54 }, \ + { A60, A61, A62, A63, A64 }, \ + { A70, A71, A72, A73, A74 }, \ + { A80, A81, A82, A83, A84 }, \ + { XXX, XXX, XXX, B03, B04 }, \ + { XXX, XXX, XXX, B13, B14 }, \ + { B20, B21, XXX, B23, B24 }, \ + { B30, B31, B32, B33, B34 }, \ + { B40, B41, B42, B43, B44 }, \ + { B50, B51, B52, B53, B54 }, \ + { B60, B61, B62, B63, B64 }, \ + { B70, B71, B72, B73, B74 }, \ + { B80, B81, B82, B83, B84 } \ } -/* -------------- LEFT HAND -------------- -------------- RIGHT HAND -------------- */ -#define LAYOUT_ergodox_pretty( \ - \ - A80, A70, A60, A50, A40, A30, A20, B20, B30, B40, B50, B60, B70, B80, \ - A81, A71, A61, A51, A41, A31, A21, B21, B31, B41, B51, B61, B71, B81, \ - A82, A72, A62, A52, A42, A32, B32, B42, B52, B62, B72, B82, \ - A83, A73, A63, A53, A43, A33, A23, B23, B33, B43, B53, B63, B73, B83, \ - A84, A74, A64, A54, A44, B44, B54, B64, B74, B84, \ - A13, A03, B03, B13, \ - A04, B04, \ - A34, A24, A14, B14, B24, B34 ) \ - \ - /* matrix positions */ \ - { \ - { KC_NO, KC_NO, KC_NO, A03, A04 }, \ - { KC_NO, KC_NO, KC_NO, A13, A14 }, \ - { A20, A21, KC_NO, A23, A24 }, \ - { A30, A31, A32, A33, A34 }, \ - { A40, A41, A42, A43, A44 }, \ - { A50, A51, A52, A53, A54 }, \ - { A60, A61, A62, A63, A64 }, \ - { A70, A71, A72, A73, A74 }, \ - { A80, A81, A82, A83, A84 }, \ - { KC_NO, KC_NO, KC_NO, B03, B04 }, \ - { KC_NO, KC_NO, KC_NO, B13, B14 }, \ - { B20, B21, KC_NO, B23, B24 }, \ - { B30, B31, B32, B33, B34 }, \ - { B40, B41, B42, B43, B44 }, \ - { B50, B51, B52, B53, B54 }, \ - { B60, B61, B62, B63, B64 }, \ - { B70, B71, B72, B73, B74 }, \ - { B80, B81, B82, B83, B84 } \ +#define LAYOUT_ergodox_pretty( \ + A80, A70, A60, A50, A40, A30, A20, B20, B30, B40, B50, B60, B70, B80, \ + A81, A71, A61, A51, A41, A31, A21, B21, B31, B41, B51, B61, B71, B81, \ + A82, A72, A62, A52, A42, A32, B32, B42, B52, B62, B72, B82, \ + A83, A73, A63, A53, A43, A33, A23, B23, B33, B43, B53, B63, B73, B83, \ + A84, A74, A64, A54, A44, B44, B54, B64, B74, B84, \ + A13, A03, B03, B13, \ + A04, B04, \ + A34, A24, A14, B14, B24, B34 \ +) { \ + { XXX, XXX, XXX, A03, A04 }, \ + { XXX, XXX, XXX, A13, A14 }, \ + { A20, A21, XXX, A23, A24 }, \ + { A30, A31, A32, A33, A34 }, \ + { A40, A41, A42, A43, A44 }, \ + { A50, A51, A52, A53, A54 }, \ + { A60, A61, A62, A63, A64 }, \ + { A70, A71, A72, A73, A74 }, \ + { A80, A81, A82, A83, A84 }, \ + { XXX, XXX, XXX, B03, B04 }, \ + { XXX, XXX, XXX, B13, B14 }, \ + { B20, B21, XXX, B23, B24 }, \ + { B30, B31, B32, B33, B34 }, \ + { B40, B41, B42, B43, B44 }, \ + { B50, B51, B52, B53, B54 }, \ + { B60, B61, B62, B63, B64 }, \ + { B70, B71, B72, B73, B74 }, \ + { B80, B81, B82, B83, B84 } \ } - -#endif /* KEYBOARDS_ERGODOX_INFINITY_INFINITY_H_ */ diff --git a/keyboards/ergodox_infinity/gfxconf.h b/keyboards/ergodox_infinity/gfxconf.h deleted file mode 100644 index ca338399d3..0000000000 --- a/keyboards/ergodox_infinity/gfxconf.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * This file has a different license to the rest of the uGFX system. - * You can copy, modify and distribute this file as you see fit. - * You do not need to publish your source modifications to this file. - * The only thing you are not permitted to do is to relicense it - * under a different license. - */ - -/** - * Copy this file into your project directory and rename it as gfxconf.h - * Edit your copy to turn on the uGFX features you want to use. - * The values below are the defaults. - * - * Only remove the comments from lines where you want to change the - * default value. This allows definitions to be included from - * driver makefiles when required and provides the best future - * compatibility for your project. - * - * Please use spaces instead of tabs in this file. - */ - -#ifndef _GFXCONF_H -#define _GFXCONF_H - -#include "common_gfxconf.h" - -#endif /* _GFXCONF_H */ diff --git a/keyboards/ergodox_infinity/keymaps/dudeofawesome/config.h b/keyboards/ergodox_infinity/keymaps/dudeofawesome/config.h index 161958233e..9dcf8a7f43 100644 --- a/keyboards/ergodox_infinity/keymaps/dudeofawesome/config.h +++ b/keyboards/ergodox_infinity/keymaps/dudeofawesome/config.h @@ -6,6 +6,4 @@ #include "../../config.h" #include "dudeofawesome.h" -#include "./visualizer.h" - #endif diff --git a/keyboards/ergodox_infinity/keymaps/dudeofawesome/keymap.c b/keyboards/ergodox_infinity/keymaps/dudeofawesome/keymap.c index c3ea48654d..675b56edec 100644 --- a/keyboards/ergodox_infinity/keymaps/dudeofawesome/keymap.c +++ b/keyboards/ergodox_infinity/keymaps/dudeofawesome/keymap.c @@ -471,8 +471,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { }; void matrix_init_user() { - backlight_enable(); - backlight_level(BACKLIGHT_LEVELS); + led_matrix_enable_noeeprom(); + led_matrix_set_val_noeeprom(UINT8_MAX); } bool process_record_user(uint16_t keycode, keyrecord_t *record) { diff --git a/keyboards/ergodox_infinity/keymaps/dudeofawesome/simple_visualizer.h b/keyboards/ergodox_infinity/keymaps/dudeofawesome/simple_visualizer.h deleted file mode 100644 index 9213e99f42..0000000000 --- a/keyboards/ergodox_infinity/keymaps/dudeofawesome/simple_visualizer.h +++ /dev/null @@ -1,123 +0,0 @@ -/* Copyright 2017 Fred Sundvik - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef KEYBOARDS_ERGODOX_INFINITY_SIMPLE_VISUALIZER_H_ -#define KEYBOARDS_ERGODOX_INFINITY_SIMPLE_VISUALIZER_H_ - -// Currently we are assuming that both the backlight and LCD are enabled -// But it's entirely possible to write a custom visualizer that use only -// one of them -#ifndef LCD_BACKLIGHT_ENABLE -#error This visualizer needs that LCD backlight is enabled -#endif - -#ifndef LCD_ENABLE -#error This visualizer needs that LCD is enabled -#endif - -#include "visualizer.h" -#include "visualizer_keyframes.h" -#include "lcd_keyframes.h" -#include "lcd_backlight_keyframes.h" -#include "system/serial_link.h" -#include "led.h" -#include "default_animations.h" - -static const uint32_t logo_background_color = LCD_COLOR(0x00, 0x00, 0xFF); -static const uint32_t initial_color = LCD_COLOR(0, 0, 0); - -static bool initial_update = true; - -// Feel free to modify the animations below, or even add new ones if needed - -static keyframe_animation_t lcd_layer_display = { - .num_frames = 1, - .loop = false, - .frame_lengths = {gfxMillisecondsToTicks(0)}, - .frame_functions = {lcd_keyframe_display_layer_and_led_states} -}; - -// The color animation animates the LCD color when you change layers -static keyframe_animation_t color_animation = { - .num_frames = 2, - .loop = false, - // Note that there's a 200 ms no-operation frame, - // this prevents the color from changing when activating the layer - // momentarily - .frame_lengths = {gfxMillisecondsToTicks(1), gfxMillisecondsToTicks(5)}, - .frame_functions = {keyframe_no_operation, lcd_backlight_keyframe_animate_color}, -}; - -void initialize_user_visualizer(visualizer_state_t* state) { - // The brightness will be dynamically adjustable in the future - // But for now, change it here. - lcd_backlight_brightness(130); - state->current_lcd_color = initial_color; - state->target_lcd_color = logo_background_color; - initial_update = true; - start_keyframe_animation(&default_startup_animation); -} - - -// This function should be implemented by the keymap visualizer -// Don't change anything else than state->target_lcd_color and state->layer_text as that's the only thing -// that the simple_visualizer assumes that you are updating -// Also make sure that the buffer passed to state->layer_text remains valid until the previous animation is -// stopped. This can be done by either double buffering it or by using constant strings -static void get_visualizer_layer_and_color(visualizer_state_t* state); - -void update_user_visualizer_state(visualizer_state_t* state, visualizer_keyboard_status_t* prev_status) { - // Add more tests, change the colors and layer texts here - // Usually you want to check the high bits (higher layers first) - // because that's the order layers are processed for keypresses - // You can for check for example: - // state->status.layer - // state->status.default_layer - // state->status.leds (see led.h for available statuses) - - uint32_t prev_color = state->target_lcd_color; - const char* prev_layer_text = state->layer_text; - - get_visualizer_layer_and_color(state); - - if (initial_update || prev_color != state->target_lcd_color) { - start_keyframe_animation(&color_animation); - } - - if (initial_update || prev_layer_text != state->layer_text) { - start_keyframe_animation(&lcd_layer_display); - } - // You can also stop existing animations, and start your custom ones here - // remember that you should normally have only one animation for the LCD - // and one for the background. But you can also combine them if you want. -} - -void user_visualizer_suspend(visualizer_state_t* state) { - state->layer_text = "Suspending..."; - uint8_t hue = LCD_HUE(state->current_lcd_color); - uint8_t sat = LCD_SAT(state->current_lcd_color); - state->target_lcd_color = LCD_COLOR(hue, sat, 0); - start_keyframe_animation(&default_suspend_animation); -} - -void user_visualizer_resume(visualizer_state_t* state) { - state->current_lcd_color = initial_color; - state->target_lcd_color = logo_background_color; - initial_update = true; - start_keyframe_animation(&default_startup_animation); -} - -#endif /* KEYBOARDS_ERGODOX_INFINITY_SIMPLE_VISUALIZER_H_ */ diff --git a/keyboards/ergodox_infinity/keymaps/dudeofawesome/visualizer.c b/keyboards/ergodox_infinity/keymaps/dudeofawesome/visualizer.c deleted file mode 100644 index 54fc2363c7..0000000000 --- a/keyboards/ergodox_infinity/keymaps/dudeofawesome/visualizer.c +++ /dev/null @@ -1,79 +0,0 @@ -/* -Copyright 2017 Fred Sundvik - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -#include "./simple_visualizer.h" -#include "util.h" -#include "layers.h" - -// This function should be implemented by the keymap visualizer -// Don't change anything else than state->target_lcd_color and state->layer_text as that's the only thing -// that the simple_visualizer assumes that you are updating -// Also make sure that the buffer passed to state->layer_text remains valid until the previous animation is -// stopped. This can be done by either double buffering it or by using constant strings -static void get_visualizer_layer_and_color(visualizer_state_t* state) { - switch(biton32(default_layer_state)) { - case _QWERTY: - state->layer_text = "QWERTY"; - state->target_lcd_color = LCD_COLOR(0, 255, 128); - break; - case _WORKMAN: - state->layer_text = "Workman"; - state->target_lcd_color = LCD_COLOR(80, 255, 128); - break; - case _DVORAK: - state->layer_text = "Dvorak"; - state->target_lcd_color = LCD_COLOR(194, 255, 128); - break; - case _COLEMAK: - state->layer_text = "Colemak"; - state->target_lcd_color = LCD_COLOR(18, 255, 128); - break; - } - - switch(biton32(state->status.layer)) { - case _LOWER: - state->layer_text = "Lower"; - state->target_lcd_color = LCD_COLOR(141, 255, 255); - break; - case _RAISE: - state->layer_text = "Raise"; - state->target_lcd_color = LCD_COLOR(18, 255, 255); - break; - case _ADJUST: - state->layer_text = "Adjust"; - state->target_lcd_color = LCD_COLOR(194, 255, 255); - break; - case _NUM: - state->layer_text = "Numpad"; - state->target_lcd_color = LCD_COLOR(80, 255, 255); - break; - case _MOUSE: - state->layer_text = "Mouse"; - state->target_lcd_color = LCD_COLOR(300, 255, 255); - break; - case _GAME: - state->layer_text = "Game"; - state->target_lcd_color = LCD_COLOR(300, 255, 255); - break; - case _QWERTY: case _WORKMAN: case _DVORAK: case _COLEMAK: - break; - default: - state->layer_text = "NONE"; - state->target_lcd_color = LCD_COLOR(0, 255, 255); - break; - } -} diff --git a/keyboards/ergodox_infinity/keymaps/dudeofawesome/visualizer.h b/keyboards/ergodox_infinity/keymaps/dudeofawesome/visualizer.h deleted file mode 100644 index 740a951ec8..0000000000 --- a/keyboards/ergodox_infinity/keymaps/dudeofawesome/visualizer.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright 2017 Fred Sundvik - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef VISUALIZER_H_ -#define VISUALIZER_H_ - -#include "visualizer.h" -#include "led.h" - -void ergodox_led_lower_on (void); -void ergodox_led_raise_on (void); -void ergodox_led_adjust_on (void); - -void ergodox_led_lower_off (void); -void ergodox_led_raise_off (void); -void ergodox_led_adjust_off (void); - -void ergodox_led_lower_set (uint8_t n); -void ergodox_led_raise_set (uint8_t n); -void ergodox_led_adjust_set (uint8_t n); - -#endif /* VISUALIZER_H_ */ diff --git a/keyboards/ergodox_infinity/keymaps/halfkeyboard/visualizer.c b/keyboards/ergodox_infinity/keymaps/halfkeyboard/visualizer.c deleted file mode 100644 index 61a724c63f..0000000000 --- a/keyboards/ergodox_infinity/keymaps/halfkeyboard/visualizer.c +++ /dev/null @@ -1,384 +0,0 @@ -/* -Copyright 2017 Fred Sundvik -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -#include "visualizer.h" -#include "gfx.h" -#include "math.h" -#include "default_animations.h" -#include "led_backlight_keyframes.h" - -#define NUM_ROWS LED_HEIGHT -#define NUM_COLS LED_WIDTH - -#define ONESIDESCAN 10 -#define BOTHSIDESCAN 20 -#define FULL_ON LUMA2COLOR(255) -#define THREE_QUARTER LUMA2COLOR(200) -#define HALF_ON LUMA2COLOR(150) -#define ONE_QUARTER LUMA2COLOR(50) - -#define CROSSFADE_TIME 500 -#define GRADIENT_TIME 3000 -bool led_backlight_keyframe_one_period_sweep(keyframe_animation_t* animation, visualizer_state_t* state); -bool led_backlight_keyframe_half_period_sweep_to_on(keyframe_animation_t* animation, visualizer_state_t* state); -bool led_backlight_keyframe_half_period_sweep_to_off(keyframe_animation_t* animation, visualizer_state_t* state); -keyframe_animation_t Fade_in_all_leds = { - .num_frames = 1, - .loop = false, - .frame_lengths = { - CROSSFADE_TIME, - }, - .frame_functions = { - led_backlight_keyframe_fade_in_all, - }, -}; -keyframe_animation_t decreasing_gradient = { - .num_frames = 8, - .loop = true, - .frame_lengths = { - gfxMillisecondsToTicks(GRADIENT_TIME), // left to rigt (outside in) - 0, // mirror leds - gfxMillisecondsToTicks(GRADIENT_TIME), // left_to_right (mirrored, so inside out) - 0, // normal leds - gfxMillisecondsToTicks(GRADIENT_TIME), // left to rigt (outside in) - 0, // mirror leds - gfxMillisecondsToTicks(GRADIENT_TIME), // left_to_right (mirrored, so inside out) - 0, // normal leds - }, - .frame_functions = { - led_backlight_keyframe_one_period_sweep, - led_backlight_keyframe_mirror_orientation, - keyframe_no_operation, - keyframe_no_operation, - keyframe_no_operation, - keyframe_no_operation, - led_backlight_keyframe_one_period_sweep, - led_backlight_keyframe_normal_orientation, - - }, -}; - - - -static uint8_t off_on_off_gradient(float t, float index, float num) { - const float two_pi = M_PI * 2.0f; - float normalized_index = (1.0f - index / (num - 1.0f)) * two_pi; - float x = t * two_pi + normalized_index-M_PI; - if((1*M_PI) < x && x < (3*M_PI)) - { - float v = 0.5 * (cosf(x) + 1.0f); - return (uint8_t)(255.0f * v); - } - else - { - return 0; - } -} -static uint8_t off_on_gradient(float t, float index, float num) { - const float two_pi = M_PI * 2.0f; - float normalized_index = (1.0f - index / (num - 1.0f)) * two_pi; - float x = t * two_pi + normalized_index-M_PI; - float v; - if((1*M_PI) < x && x < (2*M_PI)) - { - v = 0.5 * (cosf(x) + 1.0f); - } - else if(x >= (2*M_PI)) - { - v = 1; - } - else - { - v = 0; - } - return (uint8_t)(255.0f * v); -} -static uint8_t on_off_gradient(float t, float index, float num) { - const float two_pi = M_PI * 2.0f; - float normalized_index = (1.0f - index / (num - 1.0f)) * two_pi; - float x = t * two_pi + normalized_index-M_PI; - float v; - if((2*M_PI) < x && x < (3*M_PI)) - { - v = 0.5 * (cosf(x) + 1.0f); - - } - else if(x >= (3*M_PI)) - { - v = 0; - } - else - { - v = 1; - } - return (uint8_t)(255.0f * v); -} - -bool led_backlight_keyframe_one_period_sweep(keyframe_animation_t* animation, visualizer_state_t* state) { - (void)state; - float frame_length = animation->frame_lengths[animation->current_frame]; - float current_pos = frame_length - animation->time_left_in_frame; - float t = current_pos / frame_length; - for (int i=0; i< NUM_COLS; i++) { - uint8_t color = off_on_off_gradient(t*2, i, NUM_COLS); - gdispGDrawLine(LED_DISPLAY, i, 0, i, NUM_ROWS - 1, LUMA2COLOR(color)); - } - return true; -} - -bool led_backlight_keyframe_half_period_sweep_to_on(keyframe_animation_t* animation, visualizer_state_t* state) { - (void)state; - float frame_length = animation->frame_lengths[animation->current_frame]; - float current_pos = frame_length - animation->time_left_in_frame; - float t = current_pos / frame_length; - for (int i=0; i< NUM_COLS; i++) { - uint8_t color = off_on_gradient(t*2, i, NUM_COLS); - gdispGDrawLine(LED_DISPLAY, i, 0, i, NUM_ROWS - 1, LUMA2COLOR(color)); - } - return true; -} -bool led_backlight_keyframe_half_period_sweep_to_off(keyframe_animation_t* animation, visualizer_state_t* state) { - (void)state; - float frame_length = animation->frame_lengths[animation->current_frame]; - float current_pos = frame_length - animation->time_left_in_frame; - float t = current_pos / frame_length; - for (int i=0; i< NUM_COLS; i++) { - uint8_t color = on_off_gradient(t*2, i, NUM_COLS); - gdispGDrawLine(LED_DISPLAY, i, 0, i, NUM_ROWS - 1, LUMA2COLOR(color)); - } - return true; -} - - -/* - +---+---+---+---+---+---+---+---+---+---+---+---+---+---+-------+ -| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | phase | -+---+---+---+---+---+---+---+---+---+---+---+---+---+---+-------+ -| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | -| 6 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | -| 5 | 6 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | -| 4 | 5 | 6 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 | -| 3 | 4 | 5 | 6 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 4 | -| 2 | 3 | 4 | 5 | 6 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 5 | -| 1 | 2 | 3 | 4 | 5 | 6 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 6 | -| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 7 | -| 0 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 0 | 0 | 0 | 0 | 0 | 0 | 8 | -| 0 | 0 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 0 | 0 | 0 | 0 | 0 | 9 | -| 0 | 0 | 0 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 0 | 0 | 0 | 0 | 10 | -| 0 | 0 | 0 | 0 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 0 | 0 | 0 | 11 | -| 0 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 0 | 0 | 12 | -| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 0 | 13 | -| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 14 | -| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 3 | 4 | 5 | 15 | -| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 3 | 4 | 16 | -| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 3 | 17 | -| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 18 | -| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 19 | -| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 20 | -+---+---+---+---+---+---+---+---+---+---+---+---+---+---+-------+ -*/ - -#ifdef MASTER_IS_ON_RIGHT /*right side*/ -keyframe_animation_t sweep_on_sweep_off_left_and_right = { - .num_frames = 12, - .loop = true, - .frame_lengths = { - 0, - 1, - gfxMillisecondsToTicks(GRADIENT_TIME), // left on - gfxMillisecondsToTicks(GRADIENT_TIME), // right on - gfxMillisecondsToTicks(GRADIENT_TIME), // left off - gfxMillisecondsToTicks(GRADIENT_TIME), // right off - 0, // mirror leds - gfxMillisecondsToTicks(GRADIENT_TIME), // right on - gfxMillisecondsToTicks(GRADIENT_TIME), // left on - gfxMillisecondsToTicks(GRADIENT_TIME), // right off - gfxMillisecondsToTicks(GRADIENT_TIME), // left off - 0, // normal leds - }, - .frame_functions = { - led_backlight_keyframe_mirror_orientation, - led_backlight_keyframe_fade_out_all, - keyframe_no_operation, - led_backlight_keyframe_half_period_sweep_to_on, - keyframe_no_operation, - led_backlight_keyframe_half_period_sweep_to_off, - led_backlight_keyframe_normal_orientation, - led_backlight_keyframe_half_period_sweep_to_on, - keyframe_no_operation, - led_backlight_keyframe_half_period_sweep_to_off, - keyframe_no_operation, - led_backlight_keyframe_mirror_orientation, - - }, -}; -keyframe_animation_t both_sides_fade_across = { - .num_frames = 10, - .loop = true, - .frame_lengths = { - 0, - 1, - gfxMillisecondsToTicks(GRADIENT_TIME), // left to rigt (outside in) - 0, // mirror leds - gfxMillisecondsToTicks(GRADIENT_TIME), // left_to_right (mirrored, so inside out) - 0, // normal leds - gfxMillisecondsToTicks(GRADIENT_TIME), // left to rigt (outside in) - 0, // mirror leds - gfxMillisecondsToTicks(GRADIENT_TIME), // left_to_right (mirrored, so inside out) - 0, // normal leds - }, - .frame_functions = { - led_backlight_keyframe_mirror_orientation, - led_backlight_keyframe_fade_out_all, - keyframe_no_operation, - keyframe_no_operation, - led_backlight_keyframe_one_period_sweep, - led_backlight_keyframe_normal_orientation, - led_backlight_keyframe_one_period_sweep, - led_backlight_keyframe_mirror_orientation, - keyframe_no_operation, - keyframe_no_operation, - }, -}; - -#else /*left side*/ -keyframe_animation_t sweep_on_sweep_off_left_and_right = { - .num_frames = 10, - .loop = true, - .frame_lengths = { - gfxMillisecondsToTicks(GRADIENT_TIME), // left on - gfxMillisecondsToTicks(GRADIENT_TIME), // right on - gfxMillisecondsToTicks(GRADIENT_TIME), // left off - gfxMillisecondsToTicks(GRADIENT_TIME), // right off - 0, // mirror leds - gfxMillisecondsToTicks(GRADIENT_TIME), // right on - gfxMillisecondsToTicks(GRADIENT_TIME), // left on - gfxMillisecondsToTicks(GRADIENT_TIME), // right off - gfxMillisecondsToTicks(GRADIENT_TIME), // left off - 0, // normal leds - }, - .frame_functions = { - led_backlight_keyframe_half_period_sweep_to_on, - keyframe_no_operation, - led_backlight_keyframe_half_period_sweep_to_off, - keyframe_no_operation, - led_backlight_keyframe_mirror_orientation, - keyframe_no_operation, - led_backlight_keyframe_half_period_sweep_to_on, - keyframe_no_operation, - led_backlight_keyframe_half_period_sweep_to_off, - led_backlight_keyframe_normal_orientation, - - }, -}; -keyframe_animation_t both_sides_fade_across = { - .num_frames = 8, - .loop = true, - .frame_lengths = { - gfxMillisecondsToTicks(GRADIENT_TIME), // left to rigt (outside in) - 0, // mirror leds - gfxMillisecondsToTicks(GRADIENT_TIME), // left_to_right (mirrored, so inside out) - 0, // normal leds - gfxMillisecondsToTicks(GRADIENT_TIME), // left to rigt (outside in) - 0, // mirror leds - gfxMillisecondsToTicks(GRADIENT_TIME), // left_to_right (mirrored, so inside out) - 0, // normal leds - }, - .frame_functions = { - led_backlight_keyframe_one_period_sweep, - led_backlight_keyframe_mirror_orientation, - keyframe_no_operation, - keyframe_no_operation, - keyframe_no_operation, - keyframe_no_operation, - led_backlight_keyframe_one_period_sweep, - led_backlight_keyframe_normal_orientation, - - }, -}; - - -#endif - -#define RED 0 -#define ORANGE 21 -#define YELLOW 42 -#define SPRING_GREEN 64 -#define GREEN 85 -#define TURQUOISE 107 -#define CYAN 127 -#define OCEAN 149 -#define BLUE 170 -#define VIOLET 192 -#define MAGENTA 212 -#define RASPBERRY 234 - -// This function should be implemented by the keymap visualizer -// Don't change anything else than state->target_lcd_color and state->layer_text as that's the only thing -// that the simple_visualizer assumes that you are updating -// Also make sure that the buffer passed to state->layer_text remains valid until the previous animation is -// stopped. This can be done by either double buffering it or by using constant strings -static void get_visualizer_layer_and_color(visualizer_state_t* state) { - uint8_t saturation = 255; - /* if (state->status.leds & (1u << USB_LED_CAPS_LOCK)) { - saturation = 255; - } */ - - if (state->status.layer & 0x400) { - state->target_lcd_color = LCD_COLOR(OCEAN, saturation, 0xFF); - state->layer_text = "STENOGRAPHY"; - } - else if (state->status.layer & 0x200) { - state->target_lcd_color = LCD_COLOR(GREEN, saturation, 0xFF); - state->layer_text = "FUNCTION"; - } - else if (state->status.layer & 0x100) { - state->target_lcd_color = LCD_COLOR(MAGENTA, saturation, 0xFF); - state->layer_text = "Shortcuts Layer"; - stop_keyframe_animation(&sweep_on_sweep_off_left_and_right); - start_keyframe_animation(&led_test_animation); - } - else if (state->status.layer & 0x80) { - state->target_lcd_color = LCD_COLOR(VIOLET, saturation, 0xFF); - state->layer_text = "Plover"; - } - else if (state->status.layer & 0x40) { - state->target_lcd_color = LCD_COLOR(RASPBERRY, saturation, 0xFF); - state->layer_text = "Mirrored Symbols"; - } - else if (state->status.layer & 0x20) { - state->target_lcd_color = LCD_COLOR(RED, saturation, 0xFF); - state->layer_text = "Symbols"; - } - else if (state->status.layer & 0x8) { - state->target_lcd_color = LCD_COLOR(OCEAN, saturation, 0xFF); - state->layer_text = "Mirrored Dvorak"; - } - else if (state->status.layer & 0x4) { - state->target_lcd_color = LCD_COLOR(BLUE, saturation, 0xFF); - state->layer_text = "Dvorak"; - stop_keyframe_animation(&led_test_animation); - start_keyframe_animation(&sweep_on_sweep_off_left_and_right); - } - else if (state->status.layer & 0x2) { - state->target_lcd_color = LCD_COLOR(ORANGE, saturation, 0xFF); - state->layer_text = "Mirrored Qwerty"; - } - else { - state->target_lcd_color = LCD_COLOR(YELLOW, saturation, 0xFF); - state->layer_text = "Qwerty"; - stop_keyframe_animation(&led_test_animation); - start_keyframe_animation(&Fade_in_all_leds); - } -} diff --git a/keyboards/ergodox_infinity/keymaps/halfkeyboard/visualizer.h b/keyboards/ergodox_infinity/keymaps/halfkeyboard/visualizer.h deleted file mode 100644 index c97a7a22a5..0000000000 --- a/keyboards/ergodox_infinity/keymaps/halfkeyboard/visualizer.h +++ /dev/null @@ -1,125 +0,0 @@ -/* Copyright 2017 Fred Sundvik - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef VISUALIZER_H_ -#define VISUALIZER_H_ - -// Currently we are assuming that both the backlight and LCD are enabled -// But it's entirely possible to write a custom visualizer that use only -// one of them -#ifndef LCD_BACKLIGHT_ENABLE -#error This visualizer needs that LCD backlight is enabled -#endif - -#ifndef LCD_ENABLE -#error This visualizer needs that LCD is enabled -#endif - -#include "visualizer.h" -#include "visualizer_keyframes.h" -#include "lcd_keyframes.h" -#include "lcd_backlight_keyframes.h" -#include "system/serial_link.h" -#include "led.h" -#include "default_animations.h" - -static const uint32_t logo_background_color = LCD_COLOR(0x00, 0x00, 0xFF); -static const uint32_t initial_color = LCD_COLOR(0, 0, 0); - -static bool initial_update = true; - -// Feel free to modify the animations below, or even add new ones if needed -extern keyframe_animation_t KITT_Scanner_animation; - -static keyframe_animation_t lcd_layer_display = { - .num_frames = 1, - .loop = false, - .frame_lengths = {gfxMillisecondsToTicks(0)}, - .frame_functions = {lcd_keyframe_display_layer_and_led_states} -}; - -// The color animation animates the LCD color when you change layers -static keyframe_animation_t color_animation = { - .num_frames = 2, - .loop = false, - // Note that there's a 200 ms no-operation frame, - // this prevents the color from changing when activating the layer - // momentarily - .frame_lengths = {gfxMillisecondsToTicks(200), gfxMillisecondsToTicks(500)}, - .frame_functions = {keyframe_no_operation, lcd_backlight_keyframe_animate_color}, -}; - -void initialize_user_visualizer(visualizer_state_t* state) { - // The brightness will be dynamically adjustable in the future - // But for now, change it here. - lcd_backlight_brightness(130); - state->current_lcd_color = initial_color; - state->target_lcd_color = logo_background_color; - initial_update = true; - start_keyframe_animation(&default_startup_animation); -} - - -// This function should be implemented by the keymap visualizer -// Don't change anything else than state->target_lcd_color and state->layer_text as that's the only thing -// that the simple_visualizer assumes that you are updating -// Also make sure that the buffer passed to state->layer_text remains valid until the previous animation is -// stopped. This can be done by either double buffering it or by using constant strings -static void get_visualizer_layer_and_color(visualizer_state_t* state); - -void update_user_visualizer_state(visualizer_state_t* state, visualizer_keyboard_status_t* prev_status) { - // Add more tests, change the colors and layer texts here - // Usually you want to check the high bits (higher layers first) - // because that's the order layers are processed for keypresses - // You can for check for example: - // state->status.layer - // state->status.default_layer - // state->status.leds (see led.h for available statuses) - - uint32_t prev_color = state->target_lcd_color; - const char* prev_layer_text = state->layer_text; - - get_visualizer_layer_and_color(state); - - if (initial_update || prev_color != state->target_lcd_color) { - start_keyframe_animation(&color_animation); - } - - if (initial_update || prev_layer_text != state->layer_text) { - start_keyframe_animation(&lcd_layer_display); - } - // You can also stop existing animations, and start your custom ones here - // remember that you should normally have only one animation for the LCD - // and one for the background. But you can also combine them if you want. - -} - -void user_visualizer_suspend(visualizer_state_t* state) { - state->layer_text = "Suspending..."; - uint8_t hue = LCD_HUE(state->current_lcd_color); - uint8_t sat = LCD_SAT(state->current_lcd_color); - state->target_lcd_color = LCD_COLOR(hue, sat, 0); - start_keyframe_animation(&default_suspend_animation); -} - -void user_visualizer_resume(visualizer_state_t* state) { - state->current_lcd_color = initial_color; - state->target_lcd_color = logo_background_color; - initial_update = true; - start_keyframe_animation(&default_startup_animation); -} - -#endif /* VISUALIZER_H_ */ diff --git a/keyboards/ergodox_infinity/readme.md b/keyboards/ergodox_infinity/readme.md index 73ee3bc1df..c51bdd7c82 100644 --- a/keyboards/ergodox_infinity/readme.md +++ b/keyboards/ergodox_infinity/readme.md @@ -13,18 +13,16 @@ for the left and right halves seperately. To flash them: - Install the firmware with `sudo make ergodox_infinity:keymapname:dfu-util` - - Build right hand firmware with `make ergodox_infinity:keymapname MASTER=right` - - Plug in the right hand keyboard only. - Press the program button (back of keyboard, above thumb pad). - - Install the firmware with `sudo make ergodox_infinity:keymapname:dfu-util MASTER=right` + - Install the firmware with `sudo make ergodox_infinity:keymapname:dfu-util` More information on the Infinity firmware is available in the [TMK/chibios for Input Club Infinity Ergodox](https://github.com/fredizzimo/infinity_ergodox/blob/master/README.md) -## Infinity Master/Two Halves +## Infinity Two Halves The Infinity is two completely independent keyboards, that can connect together. You have a few options in how you flash the firmware: @@ -32,21 +30,10 @@ 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. - -- Flash the left half, then flash the same firmware on the right. This only - works when the left half is plugged directly to the computer and the keymap - is mirrored. It saves the small extra step of rebuilding with - "MASTER=right". - -- The same as the previous one but with "MASTER=right" when you build the - firmware, then flash the same firmware to both halves. You just have to - directly connect the right half to the computer. +- Flash with the instructions above, which assume the left hand is connected to USB. - 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 half connected to USB, but it is safest to program both halves. ### EE_HANDS initialization @@ -74,7 +61,6 @@ They only need to be done once, unless you reset the EEPROM later. - 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. + - After this, you can flash both halves with the same firmware, _without_ risking a mirrored keyboard when connected the wrong way. If you reset your EEPROM later, you'll have to follow these steps again, though. diff --git a/keyboards/ergodox_infinity/rules.mk b/keyboards/ergodox_infinity/rules.mk index 06b62f547d..b6922e1ee6 100644 --- a/keyboards/ergodox_infinity/rules.mk +++ b/keyboards/ergodox_infinity/rules.mk @@ -34,11 +34,4 @@ ST7565_ENABLE = yes LED_MATRIX_ENABLE = yes LED_MATRIX_DRIVER = IS31FL3731 -# Config for Visualizer (set VISUALIZER_ENABLE = yes and ST7565_ENABLE = no to use) -LCD_ENABLE = yes -LCD_BACKLIGHT_ENABLE = yes -LCD_DRIVER = st7565 -LCD_WIDTH = 128 -LCD_HEIGHT = 32 - LAYOUTS = ergodox diff --git a/keyboards/ergodox_infinity/simple_visualizer.h b/keyboards/ergodox_infinity/simple_visualizer.h deleted file mode 100644 index 73d0e08870..0000000000 --- a/keyboards/ergodox_infinity/simple_visualizer.h +++ /dev/null @@ -1,123 +0,0 @@ -/* Copyright 2017 Fred Sundvik - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef KEYBOARDS_ERGODOX_INFINITY_SIMPLE_VISUALIZER_H_ -#define KEYBOARDS_ERGODOX_INFINITY_SIMPLE_VISUALIZER_H_ - -// Currently we are assuming that both the backlight and LCD are enabled -// But it's entirely possible to write a custom visualizer that use only -// one of them -#ifndef LCD_BACKLIGHT_ENABLE -#error This visualizer needs that LCD backlight is enabled -#endif - -#ifndef LCD_ENABLE -#error This visualizer needs that LCD is enabled -#endif - -#include "visualizer.h" -#include "visualizer_keyframes.h" -#include "lcd_keyframes.h" -#include "lcd_backlight_keyframes.h" -#include "system/serial_link.h" -#include "led.h" -#include "default_animations.h" - -static const uint32_t logo_background_color = LCD_COLOR(0x00, 0x00, 0xFF); -static const uint32_t initial_color = LCD_COLOR(0, 0, 0); - -static bool initial_update = true; - -// Feel free to modify the animations below, or even add new ones if needed - -static keyframe_animation_t lcd_layer_display = { - .num_frames = 1, - .loop = false, - .frame_lengths = {gfxMillisecondsToTicks(0)}, - .frame_functions = {lcd_keyframe_display_layer_and_led_states} -}; - -// The color animation animates the LCD color when you change layers -static keyframe_animation_t color_animation = { - .num_frames = 2, - .loop = false, - // Note that there's a 200 ms no-operation frame, - // this prevents the color from changing when activating the layer - // momentarily - .frame_lengths = {gfxMillisecondsToTicks(200), gfxMillisecondsToTicks(500)}, - .frame_functions = {keyframe_no_operation, lcd_backlight_keyframe_animate_color}, -}; - -void initialize_user_visualizer(visualizer_state_t* state) { - // The brightness will be dynamically adjustable in the future - // But for now, change it here. - lcd_backlight_brightness(130); - state->current_lcd_color = initial_color; - state->target_lcd_color = logo_background_color; - initial_update = true; - start_keyframe_animation(&default_startup_animation); -} - - -// This function should be implemented by the keymap visualizer -// Don't change anything else than state->target_lcd_color and state->layer_text as that's the only thing -// that the simple_visualizer assumes that you are updating -// Also make sure that the buffer passed to state->layer_text remains valid until the previous animation is -// stopped. This can be done by either double buffering it or by using constant strings -static void get_visualizer_layer_and_color(visualizer_state_t* state); - -void update_user_visualizer_state(visualizer_state_t* state, visualizer_keyboard_status_t* prev_status) { - // Add more tests, change the colors and layer texts here - // Usually you want to check the high bits (higher layers first) - // because that's the order layers are processed for keypresses - // You can for check for example: - // state->status.layer - // state->status.default_layer - // state->status.leds (see led.h for available statuses) - - uint32_t prev_color = state->target_lcd_color; - const char* prev_layer_text = state->layer_text; - - get_visualizer_layer_and_color(state); - - if (initial_update || prev_color != state->target_lcd_color) { - start_keyframe_animation(&color_animation); - } - - if (initial_update || prev_layer_text != state->layer_text) { - start_keyframe_animation(&lcd_layer_display); - } - // You can also stop existing animations, and start your custom ones here - // remember that you should normally have only one animation for the LCD - // and one for the background. But you can also combine them if you want. -} - -void user_visualizer_suspend(visualizer_state_t* state) { - state->layer_text = "Suspending..."; - uint8_t hue = LCD_HUE(state->current_lcd_color); - uint8_t sat = LCD_SAT(state->current_lcd_color); - state->target_lcd_color = LCD_COLOR(hue, sat, 0); - start_keyframe_animation(&default_suspend_animation); -} - -void user_visualizer_resume(visualizer_state_t* state) { - state->current_lcd_color = initial_color; - state->target_lcd_color = logo_background_color; - initial_update = true; - start_keyframe_animation(&default_startup_animation); -} - -#endif /* KEYBOARDS_ERGODOX_INFINITY_SIMPLE_VISUALIZER_H_ */ diff --git a/keyboards/ergodox_infinity/visualizer.c b/keyboards/ergodox_infinity/visualizer.c deleted file mode 100644 index 1ea891e830..0000000000 --- a/keyboards/ergodox_infinity/visualizer.c +++ /dev/null @@ -1,328 +0,0 @@ -/* -Copyright 2016 Fred Sundvik <fsundvik@gmail.com> - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -// Currently we are assuming that both the backlight and LCD are enabled -// But it's entirely possible to write a custom visualizer that use only -// one of them -#ifndef LCD_BACKLIGHT_ENABLE -#error This visualizer needs that LCD backlight is enabled -#endif - -#ifndef LCD_ENABLE -#error This visualizer needs that LCD is enabled -#endif - -#include "visualizer.h" -#include "visualizer_keyframes.h" -#include "lcd_keyframes.h" -#include "lcd_backlight_keyframes.h" -#include "default_animations.h" - -static const uint32_t logo_background_color = LCD_COLOR(0x00, 0x00, 0xFF); -static const uint32_t initial_color = LCD_COLOR(0, 0, 0); - -static const uint32_t led_emulation_colors[4] = { - LCD_COLOR(0, 0, 0), - LCD_COLOR(255, 255, 255), - LCD_COLOR(84, 255, 255), - LCD_COLOR(168, 255, 255), -}; - -static uint32_t next_led_target_color = 0; - -typedef enum { - LCD_STATE_INITIAL, - LCD_STATE_LAYER_BITMAP, - LCD_STATE_BITMAP_AND_LEDS, -} lcd_state_t; - -static lcd_state_t lcd_state = LCD_STATE_INITIAL; - -typedef struct { - uint8_t led_on; - uint8_t led1; - uint8_t led2; - uint8_t led3; -} visualizer_user_data_t; - -// Don't access from visualization function, use the visualizer state instead -static visualizer_user_data_t user_data_keyboard = { - .led_on = 0, - .led1 = LED_BRIGHTNESS_HI, - .led2 = LED_BRIGHTNESS_HI, - .led3 = LED_BRIGHTNESS_HI, -}; - -_Static_assert(sizeof(visualizer_user_data_t) <= VISUALIZER_USER_DATA_SIZE, - "Please increase the VISUALIZER_USER_DATA_SIZE"); - -// Feel free to modify the animations below, or even add new ones if needed - - -// The color animation animates the LCD color when you change layers -static keyframe_animation_t one_led_color = { - .num_frames = 1, - .loop = false, - .frame_lengths = {gfxMillisecondsToTicks(0)}, - .frame_functions = {lcd_backlight_keyframe_set_color}, -}; - -bool swap_led_target_color(keyframe_animation_t* animation, visualizer_state_t* state) { - uint32_t temp = next_led_target_color; - next_led_target_color = state->target_lcd_color; - state->target_lcd_color = temp; - return false; -} - -// The color animation animates the LCD color when you change layers -static keyframe_animation_t two_led_colors = { - .num_frames = 2, - .loop = true, - .frame_lengths = {gfxMillisecondsToTicks(1000), gfxMillisecondsToTicks(0)}, - .frame_functions = {lcd_backlight_keyframe_set_color, swap_led_target_color}, -}; - -// The LCD animation alternates between the layer name display and a -// bitmap that displays all active layers -static keyframe_animation_t lcd_bitmap_animation = { - .num_frames = 1, - .loop = false, - .frame_lengths = {gfxMillisecondsToTicks(0)}, - .frame_functions = {lcd_keyframe_display_layer_bitmap}, -}; - -static keyframe_animation_t lcd_bitmap_leds_animation = { - .num_frames = 2, - .loop = true, - .frame_lengths = {gfxMillisecondsToTicks(2000), gfxMillisecondsToTicks(2000)}, - .frame_functions = {lcd_keyframe_display_layer_bitmap, lcd_keyframe_display_led_states}, -}; - -void initialize_user_visualizer(visualizer_state_t* state) { - // The brightness will be dynamically adjustable in the future - // But for now, change it here. - lcd_backlight_brightness(130); - state->current_lcd_color = initial_color; - state->target_lcd_color = logo_background_color; - lcd_state = LCD_STATE_INITIAL; - start_keyframe_animation(&default_startup_animation); -} - -static inline bool is_led_on(visualizer_user_data_t* user_data, uint8_t num) { - return user_data->led_on & (1u << num); -} - -static uint8_t get_led_index_master(visualizer_user_data_t* user_data) { - for (int i=0; i < 3; i++) { - if (is_led_on(user_data, i)) { - return i + 1; - } - } - return 0; -} - -static uint8_t get_led_index_slave(visualizer_user_data_t* user_data) { - uint8_t master_index = get_led_index_master(user_data); - if (master_index!=0) { - for (int i=master_index; i < 3; i++) { - if (is_led_on(user_data, i)) { - return i + 1; - } - } - } - - return 0; -} - -static uint8_t get_secondary_led_index(visualizer_user_data_t* user_data) { - if (is_led_on(user_data, 0) && - is_led_on(user_data, 1) && - is_led_on(user_data, 2)) { - return 3; - } - return 0; -} - -static uint8_t get_brightness(visualizer_user_data_t* user_data, uint8_t index) { - switch (index) { - case 1: - return user_data->led1; - case 2: - return user_data->led2; - case 3: - return user_data->led3; - } - return 0; -} - -static void update_emulated_leds(visualizer_state_t* state, visualizer_keyboard_status_t* prev_status) { - visualizer_user_data_t* user_data_new = (visualizer_user_data_t*)state->status.user_data; - visualizer_user_data_t* user_data_old = (visualizer_user_data_t*)prev_status->user_data; - - uint8_t new_index; - uint8_t old_index; - - if (is_keyboard_master()) { - new_index = get_led_index_master(user_data_new); - old_index = get_led_index_master(user_data_old); - } - else { - new_index = get_led_index_slave(user_data_new); - old_index = get_led_index_slave(user_data_old); - } - uint8_t new_secondary_index = get_secondary_led_index(user_data_new); - uint8_t old_secondary_index = get_secondary_led_index(user_data_old); - - uint8_t old_brightness = get_brightness(user_data_old, old_index); - uint8_t new_brightness = get_brightness(user_data_new, new_index); - - uint8_t old_secondary_brightness = get_brightness(user_data_old, old_secondary_index); - uint8_t new_secondary_brightness = get_brightness(user_data_new, new_secondary_index); - - if (lcd_state == LCD_STATE_INITIAL || - new_index != old_index || - new_secondary_index != old_secondary_index || - new_brightness != old_brightness || - new_secondary_brightness != old_secondary_brightness) { - - if (new_secondary_index != 0) { - state->target_lcd_color = change_lcd_color_intensity( - led_emulation_colors[new_index], new_brightness); - next_led_target_color = change_lcd_color_intensity( - led_emulation_colors[new_secondary_index], new_secondary_brightness); - - stop_keyframe_animation(&one_led_color); - start_keyframe_animation(&two_led_colors); - } else { - state->target_lcd_color = change_lcd_color_intensity( - led_emulation_colors[new_index], new_brightness); - stop_keyframe_animation(&two_led_colors); - start_keyframe_animation(&one_led_color); - } - } -} - -static void update_lcd_text(visualizer_state_t* state, visualizer_keyboard_status_t* prev_status) { - if (state->status.leds) { - if (lcd_state != LCD_STATE_BITMAP_AND_LEDS || - state->status.leds != prev_status->leds || - state->status.layer != prev_status->layer || - state->status.default_layer != prev_status->default_layer) { - - // NOTE: that it doesn't matter if the animation isn't playing, stop will do nothing in that case - stop_keyframe_animation(&lcd_bitmap_animation); - - lcd_state = LCD_STATE_BITMAP_AND_LEDS; - // For information: - // The logic in this function makes sure that this doesn't happen, but if you call start on an - // animation that is already playing it will be restarted. - start_keyframe_animation(&lcd_bitmap_leds_animation); - } - } else { - if (lcd_state != LCD_STATE_LAYER_BITMAP || - state->status.layer != prev_status->layer || - state->status.default_layer != prev_status->default_layer) { - - stop_keyframe_animation(&lcd_bitmap_leds_animation); - - lcd_state = LCD_STATE_LAYER_BITMAP; - start_keyframe_animation(&lcd_bitmap_animation); - } - } -} - -void update_user_visualizer_state(visualizer_state_t* state, visualizer_keyboard_status_t* prev_status) { - // Check the status here to start and stop animations - // You might have to save some state, like the current animation here so that you can start the right - // This function is called every time the status changes - - // NOTE that this is called from the visualizer thread, so don't access anything else outside the status - // This is also important because the slave won't have access to the active layer for example outside the - // status. - - update_emulated_leds(state, prev_status); - update_lcd_text(state, prev_status); - -} - -void user_visualizer_suspend(visualizer_state_t* state) { - state->layer_text = "Suspending..."; - uint8_t hue = LCD_HUE(state->current_lcd_color); - uint8_t sat = LCD_SAT(state->current_lcd_color); - state->target_lcd_color = LCD_COLOR(hue, sat, 0); - start_keyframe_animation(&default_suspend_animation); -} - -void user_visualizer_resume(visualizer_state_t* state) { - state->current_lcd_color = initial_color; - state->target_lcd_color = logo_background_color; - lcd_state = LCD_STATE_INITIAL; - start_keyframe_animation(&default_startup_animation); -} - -void ergodox_board_led_on(void){ - // No board led support -} - -void ergodox_right_led_1_on(void){ - user_data_keyboard.led_on |= (1u << 0); - visualizer_set_user_data(&user_data_keyboard); -} - -void ergodox_right_led_2_on(void){ - user_data_keyboard.led_on |= (1u << 1); - visualizer_set_user_data(&user_data_keyboard); -} - -void ergodox_right_led_3_on(void){ - user_data_keyboard.led_on |= (1u << 2); - visualizer_set_user_data(&user_data_keyboard); -} - -void ergodox_board_led_off(void){ - // No board led support -} - -void ergodox_right_led_1_off(void){ - user_data_keyboard.led_on &= ~(1u << 0); - visualizer_set_user_data(&user_data_keyboard); -} - -void ergodox_right_led_2_off(void){ - user_data_keyboard.led_on &= ~(1u << 1); - visualizer_set_user_data(&user_data_keyboard); -} - -void ergodox_right_led_3_off(void){ - user_data_keyboard.led_on &= ~(1u << 2); - visualizer_set_user_data(&user_data_keyboard); -} - -void ergodox_right_led_1_set(uint8_t n) { - user_data_keyboard.led1 = n; - visualizer_set_user_data(&user_data_keyboard); -} - -void ergodox_right_led_2_set(uint8_t n) { - user_data_keyboard.led2 = n; - visualizer_set_user_data(&user_data_keyboard); -} - -void ergodox_right_led_3_set(uint8_t n) { - user_data_keyboard.led3 = n; - visualizer_set_user_data(&user_data_keyboard); -} |