diff options
author | Jack Humbert <jack.humb@gmail.com> | 2018-06-12 10:59:35 -0400 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2018-06-12 10:59:35 -0400 |
commit | 998ddbb122c9d3e2a77bd4e88c881b225ca0d569 (patch) | |
tree | ca91ff7ad3c4866555d1e623fe9ea05276397e1c /keyboards/helix | |
parent | c0095710a7c7e9bd94aa9f4dd814dc28d718c731 (diff) | |
parent | 06487daaddf923d635e8a528d1eb644b875a73f6 (diff) |
Merge branch 'master' of github.com:qmk/qmk_firmware into hf/shinydox
Diffstat (limited to 'keyboards/helix')
-rw-r--r-- | keyboards/helix/rev2/keymaps/default/config.h | 32 | ||||
-rw-r--r-- | keyboards/helix/rev2/keymaps/default/keymap.c | 27 | ||||
-rw-r--r-- | keyboards/helix/rev2/keymaps/default/readme.md | 6 | ||||
-rw-r--r-- | keyboards/helix/rev2/keymaps/default/readme_jp.md | 15 | ||||
-rw-r--r-- | keyboards/helix/rev2/keymaps/default/rules.mk | 39 | ||||
-rw-r--r-- | keyboards/helix/rev2/keymaps/froggy/config.h | 123 | ||||
-rw-r--r-- | keyboards/helix/rev2/keymaps/froggy/helixfont.h | 244 | ||||
-rw-r--r-- | keyboards/helix/rev2/keymaps/froggy/keymap.c | 650 | ||||
-rw-r--r-- | keyboards/helix/rev2/keymaps/froggy/readme.md | 83 | ||||
-rw-r--r-- | keyboards/helix/rev2/keymaps/froggy/rules.mk | 123 | ||||
-rw-r--r-- | keyboards/helix/rev2/keymaps/led_test/keymap.c | 8 | ||||
-rw-r--r-- | keyboards/helix/rev2/keymaps/led_test/rgblight.c | 185 | ||||
-rw-r--r-- | keyboards/helix/rev2/keymaps/led_test/rgblight.h | 22 | ||||
-rw-r--r-- | keyboards/helix/serial.c | 2 |
14 files changed, 1481 insertions, 78 deletions
diff --git a/keyboards/helix/rev2/keymaps/default/config.h b/keyboards/helix/rev2/keymaps/default/config.h index 66c9b9e8bd..17c4a30b34 100644 --- a/keyboards/helix/rev2/keymaps/default/config.h +++ b/keyboards/helix/rev2/keymaps/default/config.h @@ -78,30 +78,44 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define RGBLED_NUM 6 #endif -#if RGBLED_NUM <= 6 - #define RGBLIGHT_LIMIT_VAL 255 +#ifndef IOS_DEVICE_ENABLE + #if RGBLED_NUM <= 6 + #define RGBLIGHT_LIMIT_VAL 255 + #else + #if HELIX_ROWS == 5 + #define RGBLIGHT_LIMIT_VAL 120 + #else + #define RGBLIGHT_LIMIT_VAL 130 + #endif + #endif + #define RGBLIGHT_VAL_STEP 17 #else - #if HELIX_ROWS == 5 - #define RGBLIGHT_LIMIT_VAL 120 + #if RGBLED_NUM <= 6 + #define RGBLIGHT_LIMIT_VAL 90 #else - #define RGBLIGHT_LIMIT_VAL 130 + #if HELIX_ROWS == 5 + #define RGBLIGHT_LIMIT_VAL 35 + #else + #define RGBLIGHT_LIMIT_VAL 45 + #endif #endif + #define RGBLIGHT_VAL_STEP 4 #endif #define RGBLIGHT_HUE_STEP 10 #define RGBLIGHT_SAT_STEP 17 -#define RGBLIGHT_VAL_STEP 17 -#endif -#ifdef RGBLIGHT_ENABLE +#if defined(RGBLIGHT_ENABLE) && !defined(IOS_DEVICE_ENABLE) // USB_MAX_POWER_CONSUMPTION value for Helix keyboard // 120 RGBoff, OLEDoff // 120 OLED // 330 RGB 6 // 300 RGB 32 // 310 OLED & RGB 32 - #define USB_MAX_POWER_CONSUMPTION 330 + #define USB_MAX_POWER_CONSUMPTION 400 #else // fix iPhone and iPad power adapter issue // iOS device need lessthan 100 #define USB_MAX_POWER_CONSUMPTION 100 #endif + +#endif /* CONFIG_USER_H */ diff --git a/keyboards/helix/rev2/keymaps/default/keymap.c b/keyboards/helix/rev2/keymaps/default/keymap.c index b8a9baee34..1a268b32d5 100644 --- a/keyboards/helix/rev2/keymaps/default/keymap.c +++ b/keyboards/helix/rev2/keymaps/default/keymap.c @@ -27,12 +27,14 @@ extern uint8_t is_master; // The underscores don't mean anything - you can have a layer called STUFF or any other name. // Layer names don't all need to be of the same length, obviously, and you can also skip them // entirely and just use numbers. -#define _QWERTY 0 -#define _COLEMAK 1 -#define _DVORAK 2 -#define _LOWER 3 -#define _RAISE 4 -#define _ADJUST 16 +enum layer_number { + _QWERTY = 0, + _COLEMAK, + _DVORAK, + _LOWER, + _RAISE, + _ADJUST +}; enum custom_keycodes { QWERTY = SAFE_RANGE, @@ -526,15 +528,10 @@ void matrix_update(struct CharacterMatrix *dest, //assign the right code to your layers for OLED display #define L_BASE 0 -#define L_LOWER 8 -#define L_RAISE 16 -#define L_FNLAYER 64 -#define L_NUMLAY 128 -#define L_NLOWER 136 -#define L_NFNLAYER 192 -#define L_MOUSECURSOR 256 -#define L_ADJUST 65536 -#define L_ADJUST_TRI 65560 +#define L_LOWER (1<<_LOWER) +#define L_RAISE (1<<_RAISE) +#define L_ADJUST (1<<_ADJUST) +#define L_ADJUST_TRI (L_ADJUST|L_RAISE|L_LOWER) static void render_logo(struct CharacterMatrix *matrix) { diff --git a/keyboards/helix/rev2/keymaps/default/readme.md b/keyboards/helix/rev2/keymaps/default/readme.md index 307e5c30b9..2cdc5506ca 100644 --- a/keyboards/helix/rev2/keymaps/default/readme.md +++ b/keyboards/helix/rev2/keymaps/default/readme.md @@ -109,13 +109,15 @@ see `qmk_firmware/keyboards/helix/rev2/keymaps/default/rules.mk` ``` # Helix keyboard customize -# you can edit follows 5 Variables -# jp: 以下の5つの変数を必要に応じて編集します。 +# you can edit follows 7 Variables +# jp: 以下の7つの変数を必要に応じて編集します。 HELIX_ROWS = 5 # Helix Rows is 4 or 5 OLED_ENABLE = no # OLED_ENABLE +LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" LED_BACK_ENABLE = no # LED backlight (Enable WS2812 RGB underlight.) LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) LED_ANIMATIONS = yes # LED animations +IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) ``` ## Compile diff --git a/keyboards/helix/rev2/keymaps/default/readme_jp.md b/keyboards/helix/rev2/keymaps/default/readme_jp.md index 88ffc02ff3..3eaeab48ec 100644 --- a/keyboards/helix/rev2/keymaps/default/readme_jp.md +++ b/keyboards/helix/rev2/keymaps/default/readme_jp.md @@ -52,13 +52,15 @@ RGB バックライトまたは、RGB Underglow をつけた場合は、 ``` # Helix keyboard customize -# you can edit follows 5 Variables -# jp: 以下の5つの変数を必要に応じて編集します。 +# you can edit follows 7 Variables +# jp: 以下の7つの変数を必要に応じて編集します。 HELIX_ROWS = 5 # Helix Rows is 4 or 5 OLED_ENABLE = no # OLED_ENABLE +LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" LED_BACK_ENABLE = no # LED backlight (Enable WS2812 RGB underlight.) LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) LED_ANIMATIONS = yes # LED animations +IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) ``` @@ -92,6 +94,15 @@ rules.mk の下記の部分を編集して no を yes に変更してくださ OLED_ENABLE = yes # OLED_ENABLE ``` +## iPad/iPhoneサポートを有効にする。 + +rules.mk の下記の部分を編集して no を yes に変更してください。 +RBG Underglow や RGBバックライトの輝度を抑えて、iPad, iPhone にも接続できるようになります。 + +``` +IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) +``` + ## リンク * さらに詳細は、[こちら helix/Doc/firmware_jp.md](https://github.com/MakotoKurauchi/helix/blob/master/Doc/firmware_jp.md)をご覧ください。 diff --git a/keyboards/helix/rev2/keymaps/default/rules.mk b/keyboards/helix/rev2/keymaps/default/rules.mk index d407dfb5eb..4174a30457 100644 --- a/keyboards/helix/rev2/keymaps/default/rules.mk +++ b/keyboards/helix/rev2/keymaps/default/rules.mk @@ -23,21 +23,52 @@ define HELIX_CUSTOMISE_MSG $(info - LED_BACK_ENABLE=$(LED_BACK_ENABLE)) $(info - LED_UNDERGLOW_ENABLE=$(LED_UNDERGLOW_ENABLE)) $(info - LED_ANIMATION=$(LED_ANIMATIONS)) + $(info - IOS_DEVICE_ENABLE=$(IOS_DEVICE_ENABLE)) endef # Helix keyboard customize -# you can edit follows 6 Variables -# jp: 以下の6つの変数を必要に応じて編集します。 +# you can edit follows 7 Variables +# jp: 以下の7つの変数を必要に応じて編集します。 HELIX_ROWS = 5 # Helix Rows is 4 or 5 OLED_ENABLE = no # OLED_ENABLE LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" LED_BACK_ENABLE = no # LED backlight (Enable WS2812 RGB underlight.) LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) LED_ANIMATIONS = yes # LED animations +IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) #### LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE. #### Do not enable these with audio at the same time. +### Helix keyboard 'default' keymap: convenient command line option +## make HELIX=<options> helix:defualt +## option= oled | back | under | na | ios +## ex. +## make HELIX=oled helix:defualt +## make HELIX=oled,back helix:defualt +## make HELIX=oled,under helix:defualt +## make HELIX=oled,back,na helix:defualt +## make HELIX=oled,back,ios helix:defualt +## +ifneq ($(strip $(HELIX)),) + ifeq ($(findstring oled,$(HELIX)), oled) + OLED_ENABLE = yes + endif + ifeq ($(findstring back,$(HELIX)), back) + LED_BACK_ENABLE = yes + else ifeq ($(findstring under,$(HELIX)), under) + LED_UNDERGLOW_ENABLE = yes + endif + ifeq ($(findstring na,$(HELIX)), na) + LED_ANIMATIONS = no + endif + ifeq ($(findstring ios,$(HELIX)), ios) + IOS_DEVICE_ENABLE = yes + endif + $(eval $(call HELIX_CUSTOMISE_MSG)) + $(info ) +endif + # Uncomment these for checking # jp: コンパイル時にカスタマイズの状態を表示したい時はコメントをはずします。 # $(eval $(call HELIX_CUSTOMISE_MSG)) @@ -63,6 +94,10 @@ else RGBLIGHT_ENABLE = no endif +ifeq ($(strip $(IOS_DEVICE_ENABLE)), yes) + OPT_DEFS += -DIOS_DEVICE_ENABLE +endif + ifeq ($(strip $(LED_ANIMATIONS)), yes) OPT_DEFS += -DRGBLIGHT_ANIMATIONS endif diff --git a/keyboards/helix/rev2/keymaps/froggy/config.h b/keyboards/helix/rev2/keymaps/froggy/config.h new file mode 100644 index 0000000000..19718a458d --- /dev/null +++ b/keyboards/helix/rev2/keymaps/froggy/config.h @@ -0,0 +1,123 @@ +/* +This is the c configuration file for the keymap + +Copyright 2012 Jun Wako <wakojun@gmail.com> +Copyright 2015 Jack Humbert + +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 CONFIG_USER_H +#define CONFIG_USER_H + +#include "../../config.h" + +/* Use I2C or Serial */ + +#define USE_I2C +#define USE_SERIAL +//#define USE_MATRIX_I2C + +/* Select hand configuration */ + +#define MASTER_LEFT +// #define MASTER_RIGHT +// #define EE_HANDS + +// Helix keyboard OLED support +// see ./rules.mk: OLED_ENABLE=yes or no +#ifdef OLED_ENABLE + #define SSD1306OLED +#endif + +/* Select rows configuration */ +// Rows are 4 or 5 +// #define HELIX_ROWS 5 see ./rules.mk + +/* key matrix size */ +// Rows are doubled-up +#if HELIX_ROWS == 4 + #define MATRIX_ROWS 8 + #define MATRIX_COLS 7 + #define MATRIX_ROW_PINS { D4, C6, D7, E6 } +#elif HELIX_ROWS == 5 + #define MATRIX_ROWS 10 + #define MATRIX_COLS 7 + #define MATRIX_ROW_PINS { D4, C6, D7, E6, B4 } +#else + #error "expected HELIX_ROWS 4 or 5" +#endif + +#define USE_SERIAL_PD2 + +#define PREVENT_STUCK_MODIFIERS +#define TAPPING_FORCE_HOLD +#define TAPPING_TERM 200 +#define ONESHOT_TAP_TOGGLE 5 /* Tapping this number of times holds the key until tapped this number of times again. */ +#define ONESHOT_TIMEOUT 5000 /* Time (in ms) before the one shot key is released */ + +// Helix keyboard RGB LED support +//#define RGBLIGHT_ANIMATIONS : see ./rules.mk: LED_ANIMATIONS = yes or no +// see ./rules.mk: LED_BACK_ENABLE or LED_UNDERGLOW_ENABLE set yes +#ifdef RGBLED_BACK + #if HELIX_ROWS == 4 + #define RGBLED_NUM 25 + #elif HELIX_ROWS == 5 + #define RGBLED_NUM 32 + #endif +#else + #define RGBLED_NUM 6 +#endif + +#ifndef IOS_DEVICE_ENABLE + #if RGBLED_NUM <= 6 + #define RGBLIGHT_LIMIT_VAL 255 + #else + #if HELIX_ROWS == 5 + #define RGBLIGHT_LIMIT_VAL 120 + #else + #define RGBLIGHT_LIMIT_VAL 130 + #endif + #endif + #define RGBLIGHT_VAL_STEP 17 +#else + #if RGBLED_NUM <= 6 + #define RGBLIGHT_LIMIT_VAL 90 + #else + #if HELIX_ROWS == 5 + #define RGBLIGHT_LIMIT_VAL 35 + #else + #define RGBLIGHT_LIMIT_VAL 45 + #endif + #endif + #define RGBLIGHT_VAL_STEP 4 +#endif +#define RGBLIGHT_HUE_STEP 10 +#define RGBLIGHT_SAT_STEP 17 + +#if defined(RGBLIGHT_ENABLE) && !defined(IOS_DEVICE_ENABLE) +// USB_MAX_POWER_CONSUMPTION value for Helix keyboard +// 120 RGBoff, OLEDoff +// 120 OLED +// 330 RGB 6 +// 300 RGB 32 +// 310 OLED & RGB 32 + #define USB_MAX_POWER_CONSUMPTION 400 +#else + // fix iPhone and iPad power adapter issue + // iOS device need lessthan 100 + #define USB_MAX_POWER_CONSUMPTION 100 +#endif + +#endif /* CONFIG_USER_H */ diff --git a/keyboards/helix/rev2/keymaps/froggy/helixfont.h b/keyboards/helix/rev2/keymaps/froggy/helixfont.h new file mode 100644 index 0000000000..7f54748151 --- /dev/null +++ b/keyboards/helix/rev2/keymaps/froggy/helixfont.h @@ -0,0 +1,244 @@ +// This is the 'classic' fixed-space bitmap font for Adafruit_GFX since 1.0. +// See gfxfont.h for newer custom bitmap font info. + +#ifndef FONT5X7_H +#define FONT5X7_H + +#ifdef __AVR__ + #include <avr/io.h> + #include <avr/pgmspace.h> +#elif defined(ESP8266) + #include <pgmspace.h> +#else + #define PROGMEM +#endif + +// Standard ASCII 5x7 font + +static const unsigned char font[] PROGMEM = { +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x00, +0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x00, +0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x00, +0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x00, +0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x00, +0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00, +0x00, 0x18, 0x3C, 0x18, 0x00, 0x00, +0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00, +0x00, 0x18, 0x24, 0x18, 0x00, 0x00, +0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x00, +0x30, 0x48, 0x3A, 0x06, 0x0E, 0x00, +0x26, 0x29, 0x79, 0x29, 0x26, 0x00, +0x40, 0x7F, 0x05, 0x05, 0x07, 0x00, +0x40, 0x7F, 0x05, 0x25, 0x3F, 0x00, +0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 0x00, +0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x00, +0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x00, +0x14, 0x22, 0x7F, 0x22, 0x14, 0x00, +0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x00, +0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00, +0x00, 0x66, 0x89, 0x95, 0x6A, 0x00, +0x60, 0x60, 0x60, 0x60, 0x60, 0x00, +0x94, 0xA2, 0xFF, 0xA2, 0x94, 0x00, +0x08, 0x04, 0x7E, 0x04, 0x08, 0x00, +0x10, 0x20, 0x7E, 0x20, 0x10, 0x00, +0x08, 0x08, 0x2A, 0x1C, 0x08, 0x00, +0x08, 0x1C, 0x2A, 0x08, 0x08, 0x00, +0x1E, 0x10, 0x10, 0x10, 0x10, 0x00, +0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x00, +0x30, 0x38, 0x3E, 0x38, 0x30, 0x00, +0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, +0x00, 0x07, 0x00, 0x07, 0x00, 0x00, +0x14, 0x7F, 0x14, 0x7F, 0x14, 0x00, +0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x00, +0x23, 0x13, 0x08, 0x64, 0x62, 0x00, +0x36, 0x49, 0x56, 0x20, 0x50, 0x00, +0x00, 0x08, 0x07, 0x03, 0x00, 0x00, +0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, +0x00, 0x41, 0x22, 0x1C, 0x00, 0x00, +0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x00, +0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, +0x00, 0x80, 0x70, 0x30, 0x00, 0x00, +0x08, 0x08, 0x08, 0x08, 0x08, 0x00, +0x00, 0x00, 0x60, 0x60, 0x00, 0x00, +0x20, 0x10, 0x08, 0x04, 0x02, 0x00, +0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, +0x00, 0x42, 0x7F, 0x40, 0x00, 0x00, +0x72, 0x49, 0x49, 0x49, 0x46, 0x00, +0x21, 0x41, 0x49, 0x4D, 0x33, 0x00, +0x18, 0x14, 0x12, 0x7F, 0x10, 0x00, +0x27, 0x45, 0x45, 0x45, 0x39, 0x00, +0x3C, 0x4A, 0x49, 0x49, 0x31, 0x00, +0x41, 0x21, 0x11, 0x09, 0x07, 0x00, +0x36, 0x49, 0x49, 0x49, 0x36, 0x00, +0x46, 0x49, 0x49, 0x29, 0x1E, 0x00, +0x00, 0x00, 0x14, 0x00, 0x00, 0x00, +0x00, 0x40, 0x34, 0x00, 0x00, 0x00, +0x00, 0x08, 0x14, 0x22, 0x41, 0x00, +0x14, 0x14, 0x14, 0x14, 0x14, 0x00, +0x00, 0x41, 0x22, 0x14, 0x08, 0x00, +0x02, 0x01, 0x59, 0x09, 0x06, 0x00, +0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x00, +0x7C, 0x12, 0x11, 0x12, 0x7C, 0x00, +0x7F, 0x49, 0x49, 0x49, 0x36, 0x00, +0x3E, 0x41, 0x41, 0x41, 0x22, 0x00, +0x7F, 0x41, 0x41, 0x41, 0x3E, 0x00, +0x7F, 0x49, 0x49, 0x49, 0x41, 0x00, +0x7F, 0x09, 0x09, 0x09, 0x01, 0x00, +0x3E, 0x41, 0x41, 0x51, 0x73, 0x00, +0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, +0x00, 0x41, 0x7F, 0x41, 0x00, 0x00, +0x20, 0x40, 0x41, 0x3F, 0x01, 0x00, +0x7F, 0x08, 0x14, 0x22, 0x41, 0x00, +0x7F, 0x40, 0x40, 0x40, 0x40, 0x00, +0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x00, +0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00, +0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, +0x7F, 0x09, 0x09, 0x09, 0x06, 0x00, +0x3E, 0x41, 0x51, 0x21, 0x5E, 0x00, +0x7F, 0x09, 0x19, 0x29, 0x46, 0x00, +0x26, 0x49, 0x49, 0x49, 0x32, 0x00, +0x03, 0x01, 0x7F, 0x01, 0x03, 0x00, +0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00, +0x1F, 0x20, 0x40, 0x20, 0x1F, 0x00, +0x3F, 0x40, 0x38, 0x40, 0x3F, 0x00, +0x63, 0x14, 0x08, 0x14, 0x63, 0x00, +0x03, 0x04, 0x78, 0x04, 0x03, 0x00, +0x61, 0x59, 0x49, 0x4D, 0x43, 0x00, +0x00, 0x7F, 0x41, 0x41, 0x41, 0x00, +0x02, 0x04, 0x08, 0x10, 0x20, 0x00, +0x00, 0x41, 0x41, 0x41, 0x7F, 0x00, +0x04, 0x02, 0x01, 0x02, 0x04, 0x00, +0x40, 0x40, 0x40, 0x40, 0x40, 0x00, +0xFC, 0xFE, 0x02, 0x82, 0x82, 0x82, +0x82, 0x82, 0x82, 0xC2, 0x82, 0x02, +0x02, 0xFE, 0x00, 0x00, 0xFE, 0xFE, +0x02, 0x62, 0x62, 0x62, 0x62, 0xE2, +0x62, 0x62, 0xE2, 0x02, 0x02, 0xFC, +0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, +0x30, 0x40, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x80, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x40, 0x00, 0x00, 0x24, 0xA4, +0xA4, 0xBC, 0xA4, 0x24, 0x24, 0x00, +0x00, 0x00, 0x24, 0xA4, 0x24, 0x24, +0x3C, 0x04, 0x04, 0x00, 0x00, 0x00, +0xB8, 0xA4, 0xA4, 0xA4, 0xBC, 0x00, +0x00, 0x00, 0x00, 0xFC, 0x00, 0xFC, +0x00, 0x44, 0x44, 0x44, 0xDC, 0x44, +0x04, 0x3C, 0x00, 0x00, 0x00, 0x00, +0xFC, 0xFE, 0xFE, 0x7E, 0x7E, 0x7E, +0x7E, 0x7E, 0x7E, 0x3E, 0x7E, 0xFE, +0xFE, 0xFE, 0x00, 0x00, 0xFE, 0xFE, +0xFE, 0x9E, 0x9E, 0x9E, 0x9E, 0x1E, +0x9E, 0x9E, 0x1E, 0xFE, 0xFE, 0xFC, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x08, 0x36, 0x41, 0x00, 0x00, +0x00, 0x00, 0x77, 0x00, 0x00, 0x00, +0x00, 0x41, 0x36, 0x08, 0x00, 0x00, +0x02, 0x01, 0x02, 0x04, 0x02, 0x00, +0x3C, 0x26, 0x23, 0x26, 0x3C, 0x00, +0x7F, 0x7F, 0x40, 0x41, 0x41, 0x41, +0x41, 0x41, 0x41, 0x41, 0x41, 0x40, +0x40, 0x7F, 0x00, 0x00, 0x7F, 0x7F, +0x40, 0x40, 0x40, 0x40, 0x40, 0x41, +0x40, 0x40, 0x43, 0x40, 0x40, 0x7F, +0x00, 0x00, 0x00, 0xF0, 0xFB, 0xFB, +0x00, 0x50, 0x60, 0xFF, 0xFC, 0x3C, +0x1E, 0x0E, 0x0C, 0xFC, 0xF8, 0xE8, +0xE8, 0xE8, 0x30, 0x00, 0x00, 0x00, +0x00, 0x00, 0x02, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x02, 0x02, 0x0D, 0x02, +0x02, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x57, 0x50, +0x57, 0x54, 0x57, 0x10, 0x50, 0x00, +0x00, 0x00, 0x97, 0x94, 0x97, 0x94, +0xF7, 0x00, 0x00, 0x00, 0x00, 0x00, +0xE4, 0x14, 0xF4, 0x94, 0xF7, 0x00, +0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, +0x00, 0x38, 0xA4, 0xA4, 0xA5, 0x3C, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x7F, 0x7F, 0x7F, 0x7E, 0x7E, 0x7E, +0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7F, +0x7F, 0x7F, 0x00, 0x00, 0x7F, 0x7F, +0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7E, +0x7F, 0x7F, 0x7C, 0x7F, 0x7F, 0x7F, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0xFE, 0xFE, 0x02, 0x62, 0x62, 0x62, +0xE2, 0x62, 0x62, 0x62, 0xC2, 0x02, +0x02, 0xFE, 0x00, 0x00, 0xFE, 0xFE, +0x02, 0x82, 0xC2, 0xE2, 0xF2, 0x82, +0x82, 0x82, 0x82, 0x02, 0x02, 0xFE, +0x00, 0x00, 0x00, 0x07, 0x7F, 0xDF, +0x00, 0x05, 0x03, 0x7F, 0x1F, 0x1E, +0x3C, 0x38, 0x18, 0x1F, 0x0F, 0x0D, +0x0D, 0x0D, 0x06, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x20, 0x20, 0x50, +0x8C, 0x50, 0x20, 0x20, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x80, 0x80, +0x40, 0x30, 0x40, 0x80, 0x89, 0x09, +0x06, 0x09, 0x09, 0x00, 0x00, 0x00, +0x00, 0x00, 0x1C, 0x12, 0x12, 0x12, +0x1E, 0x10, 0x10, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0xFF, 0x00, 0x73, +0x84, 0xE7, 0x94, 0x94, 0x94, 0x67, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0xFE, 0xFE, 0xFE, 0x9E, 0x9E, 0x9E, +0x1E, 0x9E, 0x9E, 0x9E, 0x3E, 0xFE, +0xFE, 0xFE, 0x00, 0x00, 0xFE, 0xFE, +0xFE, 0x7E, 0x3E, 0x1E, 0x0E, 0x7E, +0x7E, 0x7E, 0x7E, 0xFE, 0xFE, 0xFE, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x3F, 0x7F, 0x40, 0x46, 0x46, 0x46, +0x47, 0x46, 0x46, 0x46, 0x43, 0x40, +0x40, 0x7F, 0x00, 0x00, 0x7F, 0x7F, +0x40, 0x41, 0x43, 0x47, 0x4F, 0x41, +0x41, 0x41, 0x41, 0x40, 0x40, 0x3F, +0x00, 0x00, 0x00, 0x00, 0x00, 0x07, +0x06, 0x01, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x01, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x04, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x01, 0x06, 0x01, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x08, 0x08, +0x36, 0x08, 0x08, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x1F, 0x00, 0x0E, +0x10, 0x1C, 0x12, 0x12, 0x12, 0x12, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x3F, 0x7F, 0x7F, 0x79, 0x79, 0x79, +0x78, 0x79, 0x79, 0x79, 0x7C, 0x7F, +0x7F, 0x7F, 0x00, 0x00, 0x7F, 0x7F, +0x7F, 0x7E, 0x7C, 0x78, 0x70, 0x7E, +0x7E, 0x7E, 0x7E, 0x7F, 0x7F, 0x3F, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; +#endif // FONT5X7_H diff --git a/keyboards/helix/rev2/keymaps/froggy/keymap.c b/keyboards/helix/rev2/keymaps/froggy/keymap.c new file mode 100644 index 0000000000..69c41856b5 --- /dev/null +++ b/keyboards/helix/rev2/keymaps/froggy/keymap.c @@ -0,0 +1,650 @@ +#include "helix.h" +#include "bootloader.h" +#include "action_layer.h" +#include "eeconfig.h" +#ifdef PROTOCOL_LUFA +#include "lufa.h" +#include "split_util.h" +#endif +#include "LUFA/Drivers/Peripheral/TWI.h" +#ifdef AUDIO_ENABLE + #include "audio.h" +#endif +#ifdef SSD1306OLED + #include "ssd1306.h" +#endif + +extern keymap_config_t keymap_config; + +#ifdef RGBLIGHT_ENABLE +//Following line allows macro to read current RGB settings +extern rgblight_config_t rgblight_config; +#endif + +extern uint8_t is_master; + +#define DELAY_TIME 75 +static uint16_t key_timer; +static uint16_t tap_timer; +static uint16_t delay_registered_code; +static uint8_t delay_mat_row; +static uint8_t delay_mat_col; +static bool delay_key_stat; +static bool delay_key_pressed; +static bool tapping_key; + +// Each layer gets a name for readability, which is then used in the keymap matrix below. +// The underscores don't mean anything - you can have a layer called STUFF or any other name. +// Layer names don't all need to be of the same length, obviously, and you can also skip them +// entirely and just use numbers. +#define _BASE 0 +#define _OPT 1 +#define _FUNC 2 +#define _SYM 3 +#define _NUM 4 + +bool RGBAnimation = false; //Flag for LED Layer color Refresh. + +enum custom_keycodes { + QWERTY = SAFE_RANGE, + EISU, + KANA, + RGBRST, + RGBOFF, + RGB1, + RGB2, + RGB3, + OPT_TAP_SP, + DESKTOP, + MAC, + WIN, +}; + +enum macro_keycodes { + KC_SAMPLEMACRO, +}; + + +// Fillers to make layering more clear +#define _______ KC_TRNS +#define XXXXXXX KC_NO +//Macros +#define M_SAMPLE M(KC_SAMPLEMACRO) + +#if HELIX_ROWS == 5 +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + + /* Base + * ,-----------------------------------------. ,-----------------------------------------. + * | C+z | ; | [ | ( | < | { | | | | | | | | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | KANA | P | K | R | A | F | | | | | | | | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | BS | D | T | H | E | O | | | | | | | | + * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| + * | Shift| Y | S | N | I | U |Space | | | | | | | | + * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| + * | Ctrl | Alt | win | Sym | Num | OPT | Ent | | | | | | | | + * `-------------------------------------------------------------------------------------------------' + */ + [_BASE] = KEYMAP( \ + LCTL(KC_Z), KC_SCLN, KC_LBRC, KC_LPRN, KC_LT, KC_LCBR, _______, _______, _______, _______, _______, _______, \ + KANA, KC_P, KC_K, KC_R, KC_A, KC_F, _______, _______, _______, _______, _______, _______, \ + KC_BSPC, KC_D, KC_T, KC_H, KC_E, KC_O, _______, _______, _______, _______, _______, _______, \ + OSM(MOD_LSFT), KC_Y, KC_S, KC_N, KC_I, KC_U, KC_SPC, _______, _______, _______, _______, _______, _______, _______, \ + OSM(MOD_LCTL), OSM(MOD_LALT), OSM(MOD_LGUI), MO(_SYM), MO(_NUM), OPT_TAP_SP, KC_ENT, _______, _______, _______, _______, _______, _______, _______ \ + ), + + /* Opt + * ,-----------------------------------------. ,-----------------------------------------. + * | Esc | : | ] | ) | > | } | | | | | | | | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | EISU| J | M | B | ' | Tab | | | | | | | | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | . | V | C | L | Z | Q | | | | | | | | + * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| + * | | X | G | W | - | Del | Esc | | | | | | | | + * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| + * | | | | , | DTOP | | | | | | | | | | + * `-------------------------------------------------------------------------------------------------' + */ + [_OPT] = KEYMAP( \ + KC_ESC, KC_COLN,KC_RBRC, KC_RPRN,KC_GT, KC_RCBR, _______, _______, _______, _______, _______, _______, \ + EISU, KC_J, KC_M, KC_B, KC_QUOT, KC_TAB, _______, _______, _______, _______, _______, _______, \ + KC_DOT, KC_V, KC_C, KC_L, KC_Z, KC_Q, _______, _______, _______, _______, _______, _______, \ + _______, KC_X, KC_G, KC_W, KC_MINUS, KC_DEL, KC_ESC, _______, _______, _______, _______, _______, _______, _______, \ + _______, _______,_______, KC_COMM,DESKTOP, _______, _______, _______, _______, _______, _______, _______, _______, _______ \ + ), + + /* Func + * ,-----------------------------------------. ,-----------------------------------------. + * |RGBRST| Hue | | RST | Mac | Win | | | | | | | | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | RGB1 | VAL+ | F7 | F8 | F9 | | | | | | | | | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | RGB2 | VAL- | F4 | F5 | F6 | F12 | | | | | | | | + * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| + * | RGB3 | F10 | F1 | F2 | F3 | F11 | | | | | | | | | + * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| + * |RGBOFF| | | | | | | | | | | | | | + * `-------------------------------------------------------------------------------------------------' + */ + [_FUNC] = KEYMAP( \ + RGBRST,RGB_HUI, _______, RESET, MAC, WIN, _______, _______, _______, _______, _______, _______, \ + RGB1, RGB_VAI, KC_F7, KC_F8, KC_F9, _______, _______, _______, _______, _______, _______, _______, \ + RGB2, RGB_VAD, KC_F4, KC_F5, KC_F6, KC_F12, _______, _______, _______, _______, _______, _______, \ + RGB3, KC_F10, KC_F1, KC_F2, KC_F3, KC_F11, _______, _______, _______, _______, _______, _______, _______, _______, \ + RGBOFF,_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \ + ), + + /* Sym + * ,-----------------------------------------. ,-----------------------------------------. + * | Ins | GRV | | PU | PD | ^ | | | | | | | | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | | \ | # | = | ? | % | | | | | | | | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | | $ | upA | @ | ! | | | | | | | | | | + * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| + * | CL | <- | dwA | -> | _ | & | | | | | | | | | + * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| + * | | | PS | | ~ | | | | | | | | | | + * `-------------------------------------------------------------------------------------------------' + */ + [_SYM] = KEYMAP( \ + KC_INS, KC_GRV, _______, KC_PGUP, KC_PGDN, KC_CIRC, _______, _______, _______, _______, _______, _______, \ + _______, KC_BSLS, KC_HASH, KC_EQL, KC_QUES, KC_PERC, _______, _______, _______, _______, _______, _______, \ + _______, KC_DLR, KC_UP, KC_AT, KC_EXLM, KC_PIPE, _______, _______, _______, _______, _______, _______, \ + KC_CAPS, KC_LEFT, KC_DOWN, KC_RIGHT,KC_UNDS, KC_AMPR, _______, _______, _______, _______, _______, _______, _______, _______, \ + _______, _______, KC_PSCR, _______, KC_TILD, _______, _______, _______, _______, _______, _______, _______, _______, _______ \ + ), + + /* Raise + * ,-----------------------------------------. ,-----------------------------------------. + * | | | Func | home | End | | | | | | | | | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | | * | 7 | 8 | 9 | - | | | | | | | | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | . | / | 4 | 5 | 6 | + | | | | | | | | + * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| + * | LN | 0 | 1 | 2 | 3 |C+S+F1| | | | | | | | | + * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| + * | | | | , | | | | | | | | | | | + * `-------------------------------------------------------------------------------------------------' + */ + [_NUM] = KEYMAP( \ + _______, _______, OSL(_FUNC), KC_HOME, KC_END, _______, _______, _______, _______, _______, _______, _______, \ + _______, KC_ASTR, KC_P7, KC_P8, KC_P9, KC_MINS, _______, _______, _______, _______, _______, _______, \ + KC_PDOT, KC_SLSH, KC_P4, KC_P5, KC_P6, KC_PLUS, _______, _______, _______, _______, _______, _______, \ + KC_NLCK, KC_P0, KC_P1, KC_P2, KC_P3, LCTL(S(KC_F1)), _______, _______, _______, _______, _______, _______, _______, _______, \ + _______, _______, KC_PDOT, KC_COMM, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \ + ) +}; +#else +#error "undefined keymaps" +#endif + + +#ifdef AUDIO_ENABLE + +float tone_qwerty[][2] = SONG(QWERTY_SOUND); +float tone_dvorak[][2] = SONG(DVORAK_SOUND); +float tone_colemak[][2] = SONG(COLEMAK_SOUND); +float tone_plover[][2] = SONG(PLOVER_SOUND); +float tone_plover_gb[][2] = SONG(PLOVER_GOODBYE_SOUND); +float music_scale[][2] = SONG(MUSIC_SCALE_SOUND); +#endif + +// define variables for reactive RGB +//bool TOG_STATUS = false; +int RGB_current_mode; + +void persistent_default_layer_set(uint16_t default_layer) { + eeconfig_update_default_layer(default_layer); + default_layer_set(default_layer); +} + +bool find_mairix(uint16_t keycode, uint8_t *row, uint8_t *col){ + for(uint8_t i=0; i<MATRIX_ROWS; i++){ + for(uint8_t j=0; j<MATRIX_COLS; j++){ + if( pgm_read_word(&(keymaps[_BASE][i][j]))==keycode){ + *row = i; + *col = j; + return true; + } + } + } + return false; +} + +void unregister_delay_code(void){ + if(delay_registered_code){ + unregister_code(delay_registered_code); + if (delay_registered_code & QK_LSFT){ + unregister_code(KC_LSFT); + } + if (delay_registered_code & QK_LCTL){ + unregister_code(KC_LCTL); + } + if (delay_registered_code & QK_LALT){ + unregister_code(KC_LALT); + } + if (delay_registered_code & QK_LGUI){ + unregister_code(KC_LGUI); + } + delay_registered_code=0; + } +} + +void register_delay_code(uint8_t layer){ + if(delay_key_stat){ + unregister_delay_code(); + + uint16_t code = pgm_read_word(&(keymaps[layer][delay_mat_row][delay_mat_col])); + if (code & QK_LSFT){ + register_code(KC_LSFT); + } + if (code & QK_LCTL){ + register_code(KC_LCTL); + } + if (code & QK_LALT){ + register_code(KC_LALT); + } + if (code & QK_LGUI){ + register_code(KC_LGUI); + } + register_code(code); + delay_registered_code = code; + delay_key_stat = false; + tapping_key = true; + } +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + + if(tap_timer&&keycode!=OPT_TAP_SP){ + tapping_key = true; + } + + if(keycode==delay_registered_code){ + if (!record->event.pressed){ + unregister_delay_code(); + } + } + + switch (keycode) { + case KC_SCLN: + case KC_LBRC: + case KC_LPRN: + case KC_LT: + case KC_LCBR: + case KC_P: + case KC_K: + case KC_R: + case KC_A: + case KC_F: + case KC_BSPC: + case KC_D: + case KC_T: + case KC_H: + case KC_E: + case KC_O: + case KC_Y: + case KC_S: + case KC_N: + case KC_I: + case KC_U: + case LCTL(KC_Z): + case KC_SPC: + if (record->event.pressed) { + register_delay_code(_BASE); + if(find_mairix(keycode, &delay_mat_row, &delay_mat_col)){ + key_timer = timer_read(); + delay_key_stat = true; + delay_key_pressed = true; + } + }else{ + delay_key_pressed = false; + } + return false; + break; + case OPT_TAP_SP: + if (record->event.pressed) { + tapping_key = false; + register_delay_code(_OPT); + layer_on(_OPT); + tap_timer = timer_read(); + }else{ + layer_off(_OPT); + if(tapping_key==false && timer_elapsed(tap_timer) < TAPPING_TERM){ + SEND_STRING(" "); + } + tap_timer = 0; + } + return false; + break; + case EISU: + if (record->event.pressed) { + if(keymap_config.swap_lalt_lgui==false){ + register_code(KC_LANG2); + }else{ + SEND_STRING(SS_LALT("`")); + } + } else { + unregister_code(KC_LANG2); + } + return false; + break; + case KANA: + if (record->event.pressed) { + if(keymap_config.swap_lalt_lgui==false){ + register_code(KC_LANG1); + }else{ + SEND_STRING(SS_LALT("`")); + } + } else { + unregister_code(KC_LANG1); + } + return false; + break; + case DESKTOP: + if (record->event.pressed) { + if(keymap_config.swap_lalt_lgui==false){ + register_code(KC_F11); + }else{ + SEND_STRING(SS_LGUI("d")); + } + } else { + unregister_code(KC_F11); + } + return false; + break; + case RGBRST: + #ifdef RGBLIGHT_ENABLE + if (record->event.pressed) { + eeconfig_update_rgblight_default(); + rgblight_enable(); + RGB_current_mode = rgblight_config.mode; + RGBAnimation = false; + } + #endif + break; + case RGBOFF: + #ifdef RGBLIGHT_ENABLE + if (record->event.pressed) { + rgblight_disable(); + } + #endif + break; + case RGB1: + #ifdef RGBLIGHT_ENABLE + if (record->event.pressed) { + RGBAnimation = true; + rgblight_mode(6); + RGB_current_mode = rgblight_config.mode; + } + #endif + break; + case RGB2: + #ifdef RGBLIGHT_ENABLE + if (record->event.pressed) { + RGBAnimation = true; + rgblight_mode(10); + RGB_current_mode = rgblight_config.mode; + } + #endif + break; + case RGB3: + #ifdef RGBLIGHT_ENABLE + if (record->event.pressed) { + RGBAnimation = true; + rgblight_mode(21); + RGB_current_mode = rgblight_config.mode; + } + #endif + break; + case MAC: + if (record->event.pressed) { + keymap_config.swap_lalt_lgui = false; + keymap_config.swap_ralt_rgui = false; + #ifdef AUDIO_ENABLE + PLAY_SONG(ag_norm_song); + #endif + } + break; + case WIN: + if (record->event.pressed) { + keymap_config.swap_lalt_lgui = true; + keymap_config.swap_ralt_rgui = true; + #ifdef AUDIO_ENABLE + PLAY_SONG(ag_swap_song); + #endif + } + break; + } + return true; +} + + +//keyboard start-up code. Runs once when the firmware starts up. +void matrix_init_user(void) { + #ifdef AUDIO_ENABLE + startup_user(); + #endif + #ifdef RGBLIGHT_ENABLE + RGB_current_mode = rgblight_config.mode; + #endif + //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h + #ifdef SSD1306OLED + TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 800000)); + iota_gfx_init(!has_usb()); // turns on the display + #endif +} + + +#ifdef AUDIO_ENABLE + +void startup_user() +{ + _delay_ms(20); // gets rid of tick +} + +void shutdown_user() +{ + _delay_ms(150); + stop_all_notes(); +} + +void music_on_user(void) +{ + music_scale_user(); +} + +void music_scale_user(void) +{ + PLAY_SONG(music_scale); +} + +#endif + + +//assign the right code to your layers for OLED display +#define L_BASE 0 +#define L_OPT 2 +#define L_FUNC 4 +#define L_SYM 8 +#define L_NUM 16 +#define L_FNLAYER 64 +#define L_NUMLAY 128 +#define L_NLOWER 136 +#define L_NFNLAYER 192 +#define L_MOUSECURSOR 256 + + +uint8_t layer_state_old; + +//runs every scan cycle (a lot) +void matrix_scan_user(void) { + #ifdef SSD1306OLED + iota_gfx_task(); // this is what updates the display continuously + #endif + + if(delay_key_stat && (timer_elapsed(key_timer) > DELAY_TIME)){ + register_delay_code(_BASE); + if(!delay_key_pressed){ + unregister_delay_code(); + } + } + + if(layer_state_old != layer_state){ + switch (layer_state) { + case L_BASE: + #ifdef RGBLIGHT_ENABLE + if (!RGBAnimation){ + rgblight_sethsv(187,255,255); + rgblight_mode(1); + }else{ + rgblight_mode(RGB_current_mode); + } + #endif + break; + case L_OPT: + register_delay_code(_OPT); + break; + case L_NUM: + register_delay_code(_NUM); + #ifdef RGBLIGHT_ENABLE + rgblight_sethsv(25,255,255); + rgblight_mode(1); + #endif + break; + case L_SYM: + register_delay_code(_SYM); + #ifdef RGBLIGHT_ENABLE + rgblight_sethsv(96,255,255); + rgblight_mode(1); + #endif + break; + case L_FUNC: + register_delay_code(_FUNC); + #ifdef RGBLIGHT_ENABLE + rgblight_sethsv(331,255,255); + rgblight_mode(1); + #endif + break; + } + layer_state_old = layer_state; + } +} + +//SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h +#ifdef SSD1306OLED + +void matrix_update(struct CharacterMatrix *dest, + const struct CharacterMatrix *source) { + if (memcmp(dest->display, source->display, sizeof(dest->display))) { + memcpy(dest->display, source->display, sizeof(dest->display)); + dest->dirty = true; + } +} + +// Render to OLED +void render_status(struct CharacterMatrix *matrix) { + + // froggy logo + static char logo[4][1][17]= + { + { + {0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,0x70,0x71,0x72,0x73,0x74,0} + }, + { + {0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,0} + }, + { + {0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,0} + }, + { + {0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0} + } + }; + + static char indctr[8][2][4]= + { + // white icon + { + {0x60,0x61,0x62,0}, + {0x63,0x64,0} + }, + { + {0x80,0x81,0x82,0}, + {0x83,0x84,0} + }, + { + {0xa0,0xa1,0xa2,0}, + {0xa3,0xa4,0} + }, + { + {0xc0,0xc1,0xc2,0}, + {0xc3,0xc4,0} + }, + // Black icon + { + {0x75,0x76,0x77,0}, + {0x78,0x79,0} + }, + { + {0x95,0x96,0x97,0}, + {0x98,0x99,0} + }, + { + {0xb5,0xb6,0xb7,0}, + {0xb8,0xb9,0} + }, + { + {0xd5,0xd6,0xd7,0}, + {0xd8,0xd9,0} + }, + }; + + int rown = 0; + int rowf = 0; + int rowa = 0; + int rows = 0; + + //Set Indicator icon + if (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) { rown = 4; } else { rown = 0; } + if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) { rowa = 4; } else { rowa = 0; } + if (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) { rows = 4; } else { rows = 0; } + if (layer_state == L_FUNC) { rowf = 4; } + + matrix_write(matrix, indctr[rown] [0]); + matrix_write(matrix, indctr[rowf] [1]); + matrix_write(matrix, logo [0] [0]); + matrix_write(matrix, indctr[rown+1][0]); + matrix_write(matrix, indctr[rowf+1][1]); + matrix_write(matrix, logo [1] [0]); + matrix_write(matrix, indctr[rowa+2][0]); + matrix_write(matrix, indctr[rows+2][1]); + matrix_write(matrix, logo [2] [0]); + matrix_write(matrix, indctr[rowa+3][0]); + matrix_write(matrix, indctr[rows+3][1]); + matrix_write(matrix, logo [3] [0]); + +} + +void iota_gfx_task_user(void) { + struct CharacterMatrix matrix; + +#if DEBUG_TO_SCREEN + if (debug_enable) { + return; + } +#endif + + matrix_clear(&matrix); + if(is_master){ + render_status(&matrix); + } + matrix_update(&display, &matrix); +} + +#endif diff --git a/keyboards/helix/rev2/keymaps/froggy/readme.md b/keyboards/helix/rev2/keymaps/froggy/readme.md new file mode 100644 index 0000000000..624e738a6c --- /dev/null +++ b/keyboards/helix/rev2/keymaps/froggy/readme.md @@ -0,0 +1,83 @@ +Froggy -one hand Helix- +====== + +![Imgur](https://i.imgur.com/S1Dw3XW.jpg) + +## Features +It is a one-handed keyboard with reference to Frogpad. Layout Designed by タクマ ([@humid](https://twitter.com/humid)). + +## Layout +### Base +``` +,-----------------------------------------. +| C+z | ; | [ | ( | < | { | +|------+------+------+------+------+------| +| KANA | P | K | R | A | F | +|------+------+------+------+------+------| +| BS | D | T | H | E | O | +|------+------+------+------+------+------+------. +| Shift| Y | S | N | I | U | Space| +|------+------+------+------+------+------+------| +| Ctrl | Alt | win | Sym | Num | OPT | Ent | +`------------------------------------------------' +``` + +### Opt +``` +,-----------------------------------------. +| Esc | : | ] | ) | > | } | +|------+------+------+------+------+------| +| EISU | J | M | B | ' | Tab | +|------+------+------+------+------+------| +| . | V | C | L | Z | Q | +|------+------+------+------+------+------+------. +| | X | G | W | - | Del | Esc | +|------+------+------+------+------+------+------| +| | | | , | DTOP | | | +`------------------------------------------------' +``` + +### Num +``` +,-----------------------------------------. +| | | Func | home | End | | +|------+------+------+------+------+------| +| | * | 7 | 8 | 9 | - | +|------+------+------+------+------+------| +| . | / | 4 | 5 | 6 | + | +|------+------+------+------+------+------+------. +| LN | 0 | 1 | 2 | 3 |C+S+F1| | +|------+------+------+------+------+------+------| +| | | | , | | | | +`------------------------------------------------' +``` + +### Sym +``` +,-----------------------------------------. +| Ins | GRV | | PU | PD | ^ | +|------+------+------+------+------+------| +| | \ | # | = | ? | % | +|------+------+------+------+------+------| +| | $ | upA | @ | ! | | | +|------+------+------+------+------+------+------. +| CL | <- | dwA | -> | _ | & | | +|------+------+------+------+------+------+------| +| | | PS | | ~ | | | + `-----------------------------------------------' +``` + +### Func +``` +,-----------------------------------------. +|RGBRST| Hue | | RST | Mac | Win | +|------+------+------+------+------+------| +| RGB1 | VAL+ | F7 | F8 | F9 | | +|------+------+------+------+------+------| +| RGB2 | VAL- | F4 | F5 | F6 | F12 | +|------+------+------+------+------+------+------. +| RGB3 | F10 | F1 | F2 | F3 | F11 | | +|------+------+------+------+------+------+------| +|RGBOFF| | | | | | | +`------------------------------------------------' +``` diff --git a/keyboards/helix/rev2/keymaps/froggy/rules.mk b/keyboards/helix/rev2/keymaps/froggy/rules.mk new file mode 100644 index 0000000000..2052b8f4e3 --- /dev/null +++ b/keyboards/helix/rev2/keymaps/froggy/rules.mk @@ -0,0 +1,123 @@ + +# Build Options +# change to "no" to disable the options, or define them in the Makefile in +# the appropriate keymap folder that will get included automatically +# +BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) +MOUSEKEY_ENABLE = no # Mouse keys(+4700) +EXTRAKEY_ENABLE = no # Audio control and System control(+450) +CONSOLE_ENABLE = no # Console for debug(+400) +COMMAND_ENABLE = no # Commands for debug and configuration +NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +MIDI_ENABLE = no # MIDI controls +AUDIO_ENABLE = no # Audio output on port C6 +UNICODE_ENABLE = no # 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. +SWAP_HANDS_ENABLE = no # Enable one-hand typing + +define HELIX_CUSTOMISE_MSG + $(info Helix customize) + $(info - OLED_ENABLE=$(OLED_ENABLE)) + $(info - LED_BACK_ENABLE=$(LED_BACK_ENABLE)) + $(info - LED_UNDERGLOW_ENABLE=$(LED_UNDERGLOW_ENABLE)) + $(info - LED_ANIMATION=$(LED_ANIMATIONS)) + $(info - IOS_DEVICE_ENABLE=$(IOS_DEVICE_ENABLE)) +endef + +# Helix keyboard customize +# you can edit follows 7 Variables +# jp: 以下の7つの変数を必要に応じて編集します。 +HELIX_ROWS = 5 # Helix Rows is 4 or 5 +OLED_ENABLE = yes # OLED_ENABLE +LOCAL_GLCDFONT = yes # use each keymaps "helixfont.h" insted of "common/glcdfont.c" +LED_BACK_ENABLE = yes # LED backlight (Enable WS2812 RGB underlight.) +LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) +LED_ANIMATIONS = yes # LED animations +IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) + +#### LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE. +#### Do not enable these with audio at the same time. + +### Helix keyboard 'default' keymap: convenient command line option +## make HELIX=<options> helix:defualt +## option= oled | back | under | na | ios +## ex. +## make HELIX=oled helix:defualt +## make HELIX=oled,back helix:defualt +## make HELIX=oled,under helix:defualt +## make HELIX=oled,back,na helix:defualt +## make HELIX=oled,back,ios helix:defualt +## +ifneq ($(strip $(HELIX)),) + ifeq ($(findstring oled,$(HELIX)), oled) + OLED_ENABLE = yes + endif + ifeq ($(findstring back,$(HELIX)), back) + LED_BACK_ENABLE = yes + else ifeq ($(findstring under,$(HELIX)), under) + LED_UNDERGLOW_ENABLE = yes + endif + ifeq ($(findstring na,$(HELIX)), na) + LED_ANIMATIONS = no + endif + ifeq ($(findstring ios,$(HELIX)), ios) + IOS_DEVICE_ENABLE = yes + endif + $(eval $(call HELIX_CUSTOMISE_MSG)) + $(info ) +endif + +# Uncomment these for checking +# jp: コンパイル時にカスタマイズの状態を表示したい時はコメントをはずします。 +# $(eval $(call HELIX_CUSTOMISE_MSG)) +# $(info ) + +ifneq ($(strip $(HELIX_ROWS)), 4) + ifneq ($(strip $(HELIX_ROWS)), 5) + $(error HELIX_ROWS = $(strip $(HELIX_ROWS)) is unexpected value) + endif +endif +OPT_DEFS += -DHELIX_ROWS=$(strip $(HELIX_ROWS)) + +ifeq ($(strip $(LED_BACK_ENABLE)), yes) + RGBLIGHT_ENABLE = yes + OPT_DEFS += -DRGBLED_BACK + ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) + $(eval $(call HELIX_CUSTOMISE_MSG)) + $(error LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE both 'yes') + endif +else ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) + RGBLIGHT_ENABLE = yes +else + RGBLIGHT_ENABLE = no +endif + +ifeq ($(strip $(IOS_DEVICE_ENABLE)), yes) + OPT_DEFS += -DIOS_DEVICE_ENABLE +endif + +ifeq ($(strip $(LED_ANIMATIONS)), yes) + OPT_DEFS += -DRGBLIGHT_ANIMATIONS +endif + +ifeq ($(strip $(OLED_ENABLE)), yes) + OPT_DEFS += -DOLED_ENABLE +endif + +ifeq ($(strip $(LOCAL_GLCDFONT)), yes) + OPT_DEFS += -DLOCAL_GLCDFONT +endif + +# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend + +ifndef QUANTUM_DIR + include ../../../../Makefile +endif + +# Uncomment these for debugging +# $(info -- RGBLIGHT_ENABLE=$(RGBLIGHT_ENABLE)) +# $(info -- OPT_DEFS=$(OPT_DEFS)) +# $(info ) diff --git a/keyboards/helix/rev2/keymaps/led_test/keymap.c b/keyboards/helix/rev2/keymaps/led_test/keymap.c index b8a9baee34..d597020d87 100644 --- a/keyboards/helix/rev2/keymaps/led_test/keymap.c +++ b/keyboards/helix/rev2/keymaps/led_test/keymap.c @@ -32,7 +32,7 @@ extern uint8_t is_master; #define _DVORAK 2 #define _LOWER 3 #define _RAISE 4 -#define _ADJUST 16 +#define _ADJUST 6 enum custom_keycodes { QWERTY = SAFE_RANGE, @@ -513,6 +513,12 @@ void music_scale_user(void) #ifdef SSD1306OLED void matrix_scan_user(void) { + static int scan_count = 0; + if( scan_count == 2 ) { + rgblight_enable(); + rgblight_mode(35); + } + if( scan_count < 3 ) scan_count ++; iota_gfx_task(); // this is what updates the display continuously } diff --git a/keyboards/helix/rev2/keymaps/led_test/rgblight.c b/keyboards/helix/rev2/keymaps/led_test/rgblight.c index fee614db05..e0ca585e0e 100644 --- a/keyboards/helix/rev2/keymaps/led_test/rgblight.c +++ b/keyboards/helix/rev2/keymaps/led_test/rgblight.c @@ -23,8 +23,15 @@ #include "debug.h" #include "led_tables.h" +#ifndef RGBLIGHT_LIMIT_VAL +#define RGBLIGHT_LIMIT_VAL 255 +#endif + +#define MIN(a,b) (((a)<(b))?(a):(b)) +#define MAX(a,b) (((a)>(b))?(a):(b)) + __attribute__ ((weak)) -const uint16_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {1024, 20, 10, 5}; //modify for led_test +const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5}; __attribute__ ((weak)) const uint8_t RGBLED_RAINBOW_MOOD_INTERVALS[] PROGMEM = {120, 60, 30}; __attribute__ ((weak)) @@ -35,9 +42,10 @@ __attribute__ ((weak)) const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {127, 63, 31}; __attribute__ ((weak)) const uint16_t RGBLED_GRADIENT_RANGES[] PROGMEM = {360, 240, 180, 120, 90}; +__attribute__ ((weak)) +const uint16_t RGBLED_RGBCYCLIC_INTERVALS[] PROGMEM = {1024}; rgblight_config_t rgblight_config; -rgblight_config_t inmem_config; LED_TYPE led[RGBLED_NUM]; uint8_t rgblight_inited = 0; @@ -46,11 +54,9 @@ bool rgblight_timer_enabled = false; void sethsv(uint16_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) { uint8_t r = 0, g = 0, b = 0, base, color; - #ifdef RGBLIGHT_LIMIT_VAL - if (val > RGBLIGHT_LIMIT_VAL) { + if (val > RGBLIGHT_LIMIT_VAL) { val=RGBLIGHT_LIMIT_VAL; // limit the val - } - #endif + } if (sat == 0) { // Acromatic color (gray). Hue doesn't mind. r = val; @@ -119,7 +125,8 @@ void eeconfig_update_rgblight_default(void) { rgblight_config.mode = 1; rgblight_config.hue = 0; rgblight_config.sat = 255; - rgblight_config.val = 255; + rgblight_config.val = RGBLIGHT_LIMIT_VAL; + rgblight_config.speed = 0; eeconfig_update_rgblight(rgblight_config.raw); } void eeconfig_debug_rgblight(void) { @@ -129,6 +136,7 @@ void eeconfig_debug_rgblight(void) { dprintf("rgblight_config.hue = %d\n", rgblight_config.hue); dprintf("rgblight_config.sat = %d\n", rgblight_config.sat); dprintf("rgblight_config.val = %d\n", rgblight_config.val); + dprintf("rgblight_config.speed = %d\n", rgblight_config.speed); } void rgblight_init(void) { @@ -154,7 +162,7 @@ void rgblight_init(void) { #endif if (rgblight_config.enable) { - rgblight_mode(rgblight_config.mode); + rgblight_mode_noeeprom(rgblight_config.mode); } } @@ -211,7 +219,7 @@ uint32_t rgblight_get_mode(void) { return rgblight_config.mode; } -void rgblight_mode(uint8_t mode) { +void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) { if (!rgblight_config.enable) { return; } @@ -222,13 +230,18 @@ void rgblight_mode(uint8_t mode) { } else { rgblight_config.mode = mode; } - eeconfig_update_rgblight(rgblight_config.raw); - xprintf("rgblight mode: %u\n", rgblight_config.mode); + if (write_to_eeprom) { + eeconfig_update_rgblight(rgblight_config.raw); + xprintf("rgblight mode [EEPROM]: %u\n", rgblight_config.mode); + } else { + xprintf("rgblight mode [NOEEPROM]: %u\n", rgblight_config.mode); + } if (rgblight_config.mode == 1) { #ifdef RGBLIGHT_ANIMATIONS rgblight_timer_disable(); #endif - } else if (rgblight_config.mode >= 2 && rgblight_config.mode <= 24) { + } else if ((rgblight_config.mode >= 2 && rgblight_config.mode <= 24) || + rgblight_config.mode == 35 ) { // MODE 2-5, breathing // MODE 6-8, rainbow mood // MODE 9-14, rainbow swirl @@ -236,6 +249,7 @@ void rgblight_mode(uint8_t mode) { // MODE 21-23, knight // MODE 24, xmas // MODE 25-34, static rainbow + // MODE 35 RGB cyclic #ifdef RGBLIGHT_ANIMATIONS rgblight_timer_enable(); @@ -247,11 +261,20 @@ void rgblight_mode(uint8_t mode) { rgblight_timer_disable(); #endif } - rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val); + rgblight_sethsv_noeeprom(rgblight_config.hue, rgblight_config.sat, rgblight_config.val); +} + +void rgblight_mode(uint8_t mode) { + rgblight_mode_eeprom_helper(mode, true); +} + +void rgblight_mode_noeeprom(uint8_t mode) { + rgblight_mode_eeprom_helper(mode, false); } + void rgblight_toggle(void) { - xprintf("rgblight toggle: rgblight_config.enable = %u\n", !rgblight_config.enable); + xprintf("rgblight toggle [EEPROM]: rgblight_config.enable = %u\n", !rgblight_config.enable); if (rgblight_config.enable) { rgblight_disable(); } @@ -260,17 +283,34 @@ void rgblight_toggle(void) { } } +void rgblight_toggle_noeeprom(void) { + xprintf("rgblight toggle [NOEEPROM]: rgblight_config.enable = %u\n", !rgblight_config.enable); + if (rgblight_config.enable) { + rgblight_disable_noeeprom(); + } + else { + rgblight_enable_noeeprom(); + } +} + void rgblight_enable(void) { rgblight_config.enable = 1; - eeconfig_update_rgblight(rgblight_config.raw); - xprintf("rgblight enable: rgblight_config.enable = %u\n", rgblight_config.enable); + // No need to update EEPROM here. rgblight_mode() will do that, actually + //eeconfig_update_rgblight(rgblight_config.raw); + xprintf("rgblight enable [EEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable); rgblight_mode(rgblight_config.mode); } +void rgblight_enable_noeeprom(void) { + rgblight_config.enable = 1; + xprintf("rgblight enable [NOEEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable); + rgblight_mode_noeeprom(rgblight_config.mode); +} + void rgblight_disable(void) { rgblight_config.enable = 0; eeconfig_update_rgblight(rgblight_config.raw); - xprintf("rgblight disable: rgblight_config.enable = %u\n", rgblight_config.enable); + xprintf("rgblight disable [EEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable); #ifdef RGBLIGHT_ANIMATIONS rgblight_timer_disable(); #endif @@ -278,6 +318,29 @@ void rgblight_disable(void) { rgblight_set(); } +void rgblight_disable_noeeprom(void) { + rgblight_config.enable = 0; + xprintf("rgblight disable [noEEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable); + #ifdef RGBLIGHT_ANIMATIONS + rgblight_timer_disable(); + #endif + _delay_ms(50); + rgblight_set(); +} + + +// Deals with the messy details of incrementing an integer +uint8_t increment( uint8_t value, uint8_t step, uint8_t min, uint8_t max ) { + int16_t new_value = value; + new_value += step; + return MIN( MAX( new_value, min ), max ); +} + +uint8_t decrement( uint8_t value, uint8_t step, uint8_t min, uint8_t max ) { + int16_t new_value = value; + new_value -= step; + return MIN( MAX( new_value, min ), max ); +} void rgblight_increase_hue(void) { uint16_t hue; @@ -313,8 +376,8 @@ void rgblight_decrease_sat(void) { } void rgblight_increase_val(void) { uint8_t val; - if (rgblight_config.val + RGBLIGHT_VAL_STEP > 255) { - val = 255; + if (rgblight_config.val + RGBLIGHT_VAL_STEP > RGBLIGHT_LIMIT_VAL) { + val = RGBLIGHT_LIMIT_VAL; } else { val = rgblight_config.val + RGBLIGHT_VAL_STEP; } @@ -329,24 +392,32 @@ void rgblight_decrease_val(void) { } rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, val); } +void rgblight_increase_speed(void) { + rgblight_config.speed = increment( rgblight_config.speed, 1, 0, 3 ); + eeconfig_update_rgblight(rgblight_config.raw);//EECONFIG needs to be increased to support this +} -void rgblight_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) { - inmem_config.raw = rgblight_config.raw; +void rgblight_decrease_speed(void) { + rgblight_config.speed = decrement( rgblight_config.speed, 1, 0, 3 ); + eeconfig_update_rgblight(rgblight_config.raw);//EECONFIG needs to be increased to support this +} + +void rgblight_sethsv_noeeprom_old(uint16_t hue, uint8_t sat, uint8_t val) { if (rgblight_config.enable) { LED_TYPE tmp_led; sethsv(hue, sat, val, &tmp_led); - inmem_config.hue = hue; - inmem_config.sat = sat; - inmem_config.val = val; // dprintf("rgblight set hue [MEMORY]: %u,%u,%u\n", inmem_config.hue, inmem_config.sat, inmem_config.val); rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b); } } -void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val) { + +void rgblight_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom) { if (rgblight_config.enable) { if (rgblight_config.mode == 1) { // same static color - rgblight_sethsv_noeeprom(hue, sat, val); + LED_TYPE tmp_led; + sethsv(hue, sat, val, &tmp_led); + rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b); } else { // all LEDs in same color if (rgblight_config.mode >= 2 && rgblight_config.mode <= 5) { @@ -371,11 +442,23 @@ void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val) { rgblight_config.hue = hue; rgblight_config.sat = sat; rgblight_config.val = val; - eeconfig_update_rgblight(rgblight_config.raw); - xprintf("rgblight set hsv [EEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val); + if (write_to_eeprom) { + eeconfig_update_rgblight(rgblight_config.raw); + xprintf("rgblight set hsv [EEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val); + } else { + xprintf("rgblight set hsv [NOEEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val); + } } } +void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val) { + rgblight_sethsv_eeprom_helper(hue, sat, val, true); +} + +void rgblight_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) { + rgblight_sethsv_eeprom_helper(hue, sat, val, false); +} + uint16_t rgblight_get_hue(void) { return rgblight_config.hue; } @@ -480,18 +563,11 @@ void rgblight_show_solid_color(uint8_t r, uint8_t g, uint8_t b) { } void rgblight_task(void) { - if (rgblight_inited == 1) { //modify for led_test - /* first call */ - rgblight_inited = 2; - rgblight_enable(); - rgblight_mode(2); - } if (rgblight_timer_enabled) { // mode = 1, static light, do nothing here if (rgblight_config.mode >= 2 && rgblight_config.mode <= 5) { // mode = 2 to 5, breathing mode rgblight_effect_breathing(rgblight_config.mode - 2); -#if 0 } else if (rgblight_config.mode >= 6 && rgblight_config.mode <= 8) { // mode = 6 to 8, rainbow mood mod rgblight_effect_rainbow_mood(rgblight_config.mode - 6); @@ -507,7 +583,9 @@ void rgblight_task(void) { } else if (rgblight_config.mode == 24) { // mode = 24, christmas mode rgblight_effect_christmas(); -#endif + } else if (rgblight_config.mode == 35) { + // mode = 35, RGB cyclic + rgblight_effect_rgbcyclic(); } } } @@ -516,19 +594,19 @@ void rgblight_task(void) { void rgblight_effect_breathing(uint8_t interval) { static uint8_t pos = 0; static uint16_t last_timer = 0; + float val; - if (timer_elapsed(last_timer) < pgm_read_word(&RGBLED_BREATHING_INTERVALS[interval])) {//modify for led_test + if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_BREATHING_INTERVALS[interval])) { return; } last_timer = timer_read(); - //modify for led_test - rgblight_config.hue = (pos*120)%360; - rgblight_sethsv_noeeprom(rgblight_config.hue, rgblight_config.sat, rgblight_config.val); - pos = (pos + 1) % 3; + // http://sean.voisen.org/blog/2011/10/breathing-led-with-arduino/ + val = (exp(sin((pos/255.0)*M_PI)) - RGBLIGHT_EFFECT_BREATHE_CENTER/M_E)*(RGBLIGHT_EFFECT_BREATHE_MAX/(M_E-1/M_E)); + rgblight_sethsv_noeeprom_old(rgblight_config.hue, rgblight_config.sat, val); + pos = (pos + 1) % 256; } -#if 0 void rgblight_effect_rainbow_mood(uint8_t interval) { static uint16_t current_hue = 0; static uint16_t last_timer = 0; @@ -537,7 +615,7 @@ void rgblight_effect_rainbow_mood(uint8_t interval) { return; } last_timer = timer_read(); - rgblight_sethsv_noeeprom(current_hue, rgblight_config.sat, rgblight_config.val); + rgblight_sethsv_noeeprom_old(current_hue, rgblight_config.sat, rgblight_config.val); current_hue = (current_hue + 1) % 360; } void rgblight_effect_rainbow_swirl(uint8_t interval) { @@ -662,5 +740,24 @@ void rgblight_effect_christmas(void) { } rgblight_set(); } -#endif /* 0 */ + +void rgblight_effect_rgbcyclic(void) { + static uint8_t pos = 0; + static uint16_t last_timer = 0; + uint8_t g; uint8_t r; uint8_t b; + + if (timer_elapsed(last_timer) < pgm_read_word(&RGBLED_RGBCYCLIC_INTERVALS[0])) { + return; + } + last_timer = timer_read(); + g = r = b = 0; + switch( pos ) { + case 0: r = RGBLIGHT_LIMIT_VAL; break; + case 1: g = RGBLIGHT_LIMIT_VAL; break; + case 2: b = RGBLIGHT_LIMIT_VAL; break; + } + rgblight_setrgb(r, g, b); + pos = (pos + 1) % 3; +} + #endif /* RGBLIGHT_ANIMATIONS */ diff --git a/keyboards/helix/rev2/keymaps/led_test/rgblight.h b/keyboards/helix/rev2/keymaps/led_test/rgblight.h index 9c1c0add23..965a1bbf63 100644 --- a/keyboards/helix/rev2/keymaps/led_test/rgblight.h +++ b/keyboards/helix/rev2/keymaps/led_test/rgblight.h @@ -17,7 +17,7 @@ #define RGBLIGHT_H #ifdef RGBLIGHT_ANIMATIONS - #define RGBLIGHT_MODES 5 + #define RGBLIGHT_MODES 35 #else #define RGBLIGHT_MODES 1 #endif @@ -74,14 +74,16 @@ #include "ws2812.h" #endif #include "rgblight_types.h" +#include "rgblight_list.h" extern LED_TYPE led[RGBLED_NUM]; -extern const uint16_t RGBLED_BREATHING_INTERVALS[4] PROGMEM; //modify for led_test +extern const uint8_t RGBLED_BREATHING_INTERVALS[4] PROGMEM; extern const uint8_t RGBLED_RAINBOW_MOOD_INTERVALS[3] PROGMEM; extern const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[3] PROGMEM; extern const uint8_t RGBLED_SNAKE_INTERVALS[3] PROGMEM; extern const uint8_t RGBLED_KNIGHT_INTERVALS[3] PROGMEM; +extern const uint16_t RGBLED_RGBCYCLIC_INTERVALS[1] PROGMEM; typedef union { uint32_t raw; @@ -91,6 +93,7 @@ typedef union { uint16_t hue :9; uint8_t sat :8; uint8_t val :8; + uint8_t speed :8;//EECONFIG needs to be increased to support this }; } rgblight_config_t; @@ -112,6 +115,8 @@ void rgblight_increase_sat(void); void rgblight_decrease_sat(void); void rgblight_increase_val(void); void rgblight_decrease_val(void); +void rgblight_increase_speed(void); +void rgblight_decrease_speed(void); void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val); uint16_t rgblight_get_hue(void); uint8_t rgblight_get_sat(void); @@ -125,9 +130,21 @@ void eeconfig_update_rgblight(uint32_t val); void eeconfig_update_rgblight_default(void); void eeconfig_debug_rgblight(void); +void rgb_matrix_increase(void); +void rgb_matrix_decrease(void); + void sethsv(uint16_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1); void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1); + void rgblight_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val); +void rgblight_mode_noeeprom(uint8_t mode); +void rgblight_toggle_noeeprom(void); +void rgblight_enable_noeeprom(void); +void rgblight_disable_noeeprom(void); + +void rgblight_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom); +void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom); + #define EZ_RGB(val) rgblight_show_solid_color((val >> 16) & 0xFF, (val >> 8) & 0xFF, val & 0xFF) void rgblight_show_solid_color(uint8_t r, uint8_t g, uint8_t b); @@ -144,5 +161,6 @@ void rgblight_effect_rainbow_swirl(uint8_t interval); void rgblight_effect_snake(uint8_t interval); void rgblight_effect_knight(uint8_t interval); void rgblight_effect_christmas(void); +void rgblight_effect_rgbcyclic(void); #endif diff --git a/keyboards/helix/serial.c b/keyboards/helix/serial.c index e918ab6ee6..51ab67fb3d 100644 --- a/keyboards/helix/serial.c +++ b/keyboards/helix/serial.c @@ -16,7 +16,7 @@ // Serial pulse period in microseconds. Its probably a bad idea to lower this // value. -#define SERIAL_DELAY 24 +#define SERIAL_DELAY 30 uint8_t volatile serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH] = {0}; uint8_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0}; |