diff options
-rw-r--r-- | builddefs/common_features.mk | 4 | ||||
-rw-r--r-- | builddefs/generic_features.mk | 1 | ||||
-rw-r--r-- | docs/_summary.md | 1 | ||||
-rw-r--r-- | docs/feature_rgblight.md | 30 | ||||
-rw-r--r-- | docs/feature_velocikey.md | 29 | ||||
-rw-r--r-- | docs/ja/_summary.md | 1 | ||||
-rw-r--r-- | docs/ja/feature_velocikey.md | 34 | ||||
-rw-r--r-- | docs/zh-cn/_summary.md | 1 | ||||
-rw-r--r-- | quantum/eeconfig.c | 2 | ||||
-rw-r--r-- | quantum/eeconfig.h | 2 | ||||
-rw-r--r-- | quantum/keyboard.c | 9 | ||||
-rw-r--r-- | quantum/quantum.c | 10 | ||||
-rw-r--r-- | quantum/rgblight/rgblight.c | 81 | ||||
-rw-r--r-- | quantum/rgblight/rgblight.h | 19 | ||||
-rw-r--r-- | quantum/velocikey.c | 40 | ||||
-rw-r--r-- | quantum/velocikey.h | 10 |
16 files changed, 124 insertions, 150 deletions
diff --git a/builddefs/common_features.mk b/builddefs/common_features.mk index 8e07c25c24..973cfba394 100644 --- a/builddefs/common_features.mk +++ b/builddefs/common_features.mk @@ -342,6 +342,10 @@ ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) ifeq ($(strip $(RGBLIGHT_DRIVER)), apa102) APA102_DRIVER_REQUIRED := yes endif + + ifeq ($(strip $(VELOCIKEY_ENABLE)), yes) + OPT_DEFS += -DVELOCIKEY_ENABLE + endif endif # Deprecated driver names - do not use diff --git a/builddefs/generic_features.mk b/builddefs/generic_features.mk index 4e058dcd26..afd8bbd276 100644 --- a/builddefs/generic_features.mk +++ b/builddefs/generic_features.mk @@ -37,7 +37,6 @@ GENERIC_FEATURES = \ SPACE_CADET \ SWAP_HANDS \ TAP_DANCE \ - VELOCIKEY \ WPM \ DYNAMIC_TAPPING_TERM \ TRI_LAYER diff --git a/docs/_summary.md b/docs/_summary.md index 28460f5ba9..722c5f9c5d 100644 --- a/docs/_summary.md +++ b/docs/_summary.md @@ -126,7 +126,6 @@ * [PS/2 Mouse](feature_ps2_mouse.md) * [Split Keyboard](feature_split_keyboard.md) * [Stenography](feature_stenography.md) - * [Velocikey](feature_velocikey.md) * Keyboard Building * [Easy Maker for One Offs](easy_maker.md) diff --git a/docs/feature_rgblight.md b/docs/feature_rgblight.md index 2bdfe6a7cf..f5c8d56e4e 100644 --- a/docs/feature_rgblight.md +++ b/docs/feature_rgblight.md @@ -552,3 +552,33 @@ In addition to setting the Clipping Range, you can use `RGBLIGHT_LED_MAP` togeth ## Hardware Modification If your keyboard lacks onboard underglow LEDs, you may often be able to solder on an RGB LED strip yourself. You will need to find an unused pin to wire to the data pin of your LED strip. Some keyboards may break out unused pins from the MCU to make soldering easier. The other two pins, VCC and GND, must also be connected to the appropriate power pins. + +## Velocikey + +Velocikey is a feature that lets you control the speed of lighting effects (like the Rainbow Swirl effect) with the speed of your typing. The faster you type, the faster the lights will go! + +### Usage +For Velocikey to take effect, there are two steps. First, when compiling your keyboard, you'll need to set `VELOCIKEY_ENABLE=yes` in `rules.mk`, e.g.: + +``` +MOUSEKEY_ENABLE = no +STENO_ENABLE = no +EXTRAKEY_ENABLE = yes +VELOCIKEY_ENABLE = yes +``` + +Then, while using your keyboard, you need to also turn it on with the `VK_TOGG` keycode, which toggles the feature on and off. + +The following light effects will all be controlled by Velocikey when it is enabled: + - RGB Breathing + - RGB Rainbow Mood + - RGB Rainbow Swirl + - RGB Snake + - RGB Knight + +Support for LED breathing effects is planned but not available yet. + + As long as Velocikey is enabled, it will control the speed regardless of any other speed setting that your RGB lights are currently on. + + ### Configuration + Velocikey doesn't currently support any configuration via keyboard settings. If you want to adjust something like the speed increase or decay rate, you would need to edit `velocikey.c` and adjust the values there to achieve the kinds of speeds that you like. diff --git a/docs/feature_velocikey.md b/docs/feature_velocikey.md deleted file mode 100644 index aeb1865e8a..0000000000 --- a/docs/feature_velocikey.md +++ /dev/null @@ -1,29 +0,0 @@ -# Velocikey - -Velocikey is a feature that lets you control the speed of lighting effects (like the Rainbow Swirl effect) with the speed of your typing. The faster you type, the faster the lights will go! - -## Usage -For Velocikey to take effect, there are two steps. First, when compiling your keyboard, you'll need to set `VELOCIKEY_ENABLE=yes` in `rules.mk`, e.g.: - -``` -MOUSEKEY_ENABLE = no -STENO_ENABLE = no -EXTRAKEY_ENABLE = yes -VELOCIKEY_ENABLE = yes -``` - -Then, while using your keyboard, you need to also turn it on with the `VK_TOGG` keycode, which toggles the feature on and off. - -The following light effects will all be controlled by Velocikey when it is enabled: - - RGB Breathing - - RGB Rainbow Mood - - RGB Rainbow Swirl - - RGB Snake - - RGB Knight - -Support for LED breathing effects is planned but not available yet. - - As long as Velocikey is enabled, it will control the speed regardless of any other speed setting that your RGB lights are currently on. - - ## Configuration - Velocikey doesn't currently support any configuration via keyboard settings. If you want to adjust something like the speed increase or decay rate, you would need to edit `velocikey.c` and adjust the values there to achieve the kinds of speeds that you like. diff --git a/docs/ja/_summary.md b/docs/ja/_summary.md index 4d6f2348d5..f26665e614 100644 --- a/docs/ja/_summary.md +++ b/docs/ja/_summary.md @@ -112,7 +112,6 @@ * [分割キーボード](ja/feature_split_keyboard.md) * [速記](ja/feature_stenography.md) * [感熱式プリンタ](ja/feature_thermal_printer.md) - * [Velocikey](ja/feature_velocikey.md) * QMK の開発 * [PR チェックリスト](ja/pr_checklist.md) diff --git a/docs/ja/feature_velocikey.md b/docs/ja/feature_velocikey.md deleted file mode 100644 index b13969a195..0000000000 --- a/docs/ja/feature_velocikey.md +++ /dev/null @@ -1,34 +0,0 @@ -# Velocikey - -<!--- - original document: 0.8.147:docs/feature_velocikey.md - git diff 0.8.147 HEAD -- docs/feature_velocikey.md | cat ---> - -Velocikey は入力の速度を使って(レインボー渦巻効果のような)ライト効果の速度を制御できる機能です。速く入力すればするほどライトが速くなります! - -## 使用法 -Velocikey を使うためには、2つのステップがあります。最初に、キーボードをコンパイルする時に、`rules.mk` に `VELOCIKEY_ENABLE=yes` を設定する必要があります。例えば: - -``` -MOUSEKEY_ENABLE = no -STENO_ENABLE = no -EXTRAKEY_ENABLE = yes -VELOCIKEY_ENABLE = yes -``` - -次に、キーボードの使用中に、VLK_TOG キーコードを使って Velocikey を有効にする必要もあります。これは機能をオンおよびオフにします。 - -以下の全てのライト効果が、Velocikey を有効にすることで制御されます: -- RGB 明滅動作 -- RGB レインボームード -- RGB レインボー渦巻 -- RGB スネーク -- RGB ナイト - -LED 明滅動作の効果のサポートは計画されていますがまだ利用できません。 - -Velocikey が有効になっている限り、現在オンになっている RGB ライトの他の全ての速度設定に関係なく、速度が制御されます。 - -## 設定 -Velocikey は現在のところキーボード設定を介したどのような設定もサポートしません。速度の増加あるいは減少率などを調整したい場合は、`velocikey.c` を編集し、そこで値を調整して、好みの速度を実現する必要があります。 diff --git a/docs/zh-cn/_summary.md b/docs/zh-cn/_summary.md index 0fc92e33d3..a076f1a8c6 100644 --- a/docs/zh-cn/_summary.md +++ b/docs/zh-cn/_summary.md @@ -121,7 +121,6 @@ * [分体式键盘](zh-cn/feature_split_keyboard.md) * [速记](zh-cn/feature_stenography.md) * [热敏打印机](zh-cn/feature_thermal_printer.md) - * [Velocikey](zh-cn/feature_velocikey.md) * QMK开发 * [PR Checklist](zh-cn/pr_checklist.md) diff --git a/quantum/eeconfig.c b/quantum/eeconfig.c index 4579d67c28..d9eea13758 100644 --- a/quantum/eeconfig.c +++ b/quantum/eeconfig.c @@ -57,7 +57,7 @@ void eeconfig_init_quantum(void) { eeprom_update_byte(EECONFIG_AUDIO, 0xFF); // On by default eeprom_update_dword(EECONFIG_RGBLIGHT, 0); eeprom_update_byte(EECONFIG_RGBLIGHT_EXTENDED, 0); - eeprom_update_byte(EECONFIG_VELOCIKEY, 0); + eeprom_update_byte(EECONFIG_UNUSED, 0); eeprom_update_byte(EECONFIG_UNICODEMODE, 0); eeprom_update_byte(EECONFIG_STENOMODE, 0); uint64_t dummy = 0; diff --git a/quantum/eeconfig.h b/quantum/eeconfig.h index 85e80226b6..34d85cb91e 100644 --- a/quantum/eeconfig.h +++ b/quantum/eeconfig.h @@ -39,7 +39,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define EECONFIG_HANDEDNESS (uint8_t *)14 #define EECONFIG_KEYBOARD (uint32_t *)15 #define EECONFIG_USER (uint32_t *)19 -#define EECONFIG_VELOCIKEY (uint8_t *)23 +#define EECONFIG_UNUSED (uint8_t *)23 // Mutually exclusive #define EECONFIG_LED_MATRIX (uint32_t *)24 #define EECONFIG_RGB_MATRIX (uint64_t *)24 diff --git a/quantum/keyboard.c b/quantum/keyboard.c index cf3361dff9..86a1a9fea3 100644 --- a/quantum/keyboard.c +++ b/quantum/keyboard.c @@ -99,9 +99,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #ifdef ST7565_ENABLE # include "st7565.h" #endif -#ifdef VELOCIKEY_ENABLE -# include "velocikey.h" -#endif #ifdef VIA_ENABLE # include "via.h" #endif @@ -708,12 +705,6 @@ void keyboard_task(void) { midi_task(); #endif -#ifdef VELOCIKEY_ENABLE - if (velocikey_enabled()) { - velocikey_decelerate(); - } -#endif - #ifdef JOYSTICK_ENABLE joystick_task(); #endif diff --git a/quantum/quantum.c b/quantum/quantum.c index 3323a5adb6..f721ab0a1f 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -68,10 +68,6 @@ # include "process_unicode_common.h" #endif -#ifdef VELOCIKEY_ENABLE -# include "velocikey.h" -#endif - #ifdef AUDIO_ENABLE # ifndef GOODBYE_SONG # define GOODBYE_SONG SONG(GOODBYE_SOUND) @@ -288,9 +284,9 @@ bool process_record_quantum(keyrecord_t *record) { } #endif -#ifdef VELOCIKEY_ENABLE - if (velocikey_enabled() && record->event.pressed) { - velocikey_accelerate(); +#ifdef RGBLIGHT_ENABLE + if (record->event.pressed) { + preprocess_rgblight(); } #endif diff --git a/quantum/rgblight/rgblight.c b/quantum/rgblight/rgblight.c index d6dd432c83..aea0ae44cb 100644 --- a/quantum/rgblight/rgblight.c +++ b/quantum/rgblight/rgblight.c @@ -27,9 +27,6 @@ #ifdef EEPROM_ENABLE # include "eeprom.h" #endif -#ifdef VELOCIKEY_ENABLE -# include "velocikey.h" -#endif #ifdef RGBLIGHT_SPLIT /* for split keyboard */ @@ -198,12 +195,13 @@ void eeconfig_update_rgblight_current(void) { } void eeconfig_update_rgblight_default(void) { - rgblight_config.enable = 1; - rgblight_config.mode = RGBLIGHT_DEFAULT_MODE; - rgblight_config.hue = RGBLIGHT_DEFAULT_HUE; - rgblight_config.sat = RGBLIGHT_DEFAULT_SAT; - rgblight_config.val = RGBLIGHT_DEFAULT_VAL; - rgblight_config.speed = RGBLIGHT_DEFAULT_SPD; + rgblight_config.enable = 1; + rgblight_config.velocikey = 0; + rgblight_config.mode = RGBLIGHT_DEFAULT_MODE; + rgblight_config.hue = RGBLIGHT_DEFAULT_HUE; + rgblight_config.sat = RGBLIGHT_DEFAULT_SAT; + rgblight_config.val = RGBLIGHT_DEFAULT_VAL; + rgblight_config.speed = RGBLIGHT_DEFAULT_SPD; RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS; eeconfig_update_rgblight(rgblight_config.raw); } @@ -211,6 +209,7 @@ void eeconfig_update_rgblight_default(void) { void eeconfig_debug_rgblight(void) { dprintf("rgblight_config EEPROM:\n"); dprintf("rgblight_config.enable = %d\n", rgblight_config.enable); + dprintf("rgblight_config.velocikey = %d\n", rgblight_config.velocikey); dprintf("rghlight_config.mode = %d\n", rgblight_config.mode); dprintf("rgblight_config.hue = %d\n", rgblight_config.hue); dprintf("rgblight_config.sat = %d\n", rgblight_config.sat); @@ -689,9 +688,9 @@ void rgblight_sethsv_at(uint8_t hue, uint8_t sat, uint8_t val, uint8_t index) { static uint8_t get_interval_time(const uint8_t *default_interval_address, uint8_t velocikey_min, uint8_t velocikey_max) { return # ifdef VELOCIKEY_ENABLE - velocikey_enabled() ? velocikey_match_speed(velocikey_min, velocikey_max) : + rgblight_velocikey_enabled() ? rgblight_velocikey_match_speed(velocikey_min, velocikey_max) : # endif - pgm_read_byte(default_interval_address); + pgm_read_byte(default_interval_address); } #endif @@ -1049,7 +1048,7 @@ static void rgblight_effect_dummy(animation_status_t *anim) { **/ } -void rgblight_task(void) { +void rgblight_timer_task(void) { if (rgblight_status.timer_enabled) { effect_func_t effect_func = rgblight_effect_dummy; uint16_t interval_time = 2000; // dummy interval @@ -1519,3 +1518,61 @@ void rgblight_effect_twinkle(animation_status_t *anim) { rgblight_set(); } #endif + +void preprocess_rgblight(void) { +#ifdef VELOCIKEY_ENABLE + if (rgblight_velocikey_enabled()) { + rgblight_velocikey_accelerate(); + } +#endif +} + +void rgblight_task(void) { +#ifdef RGBLIGHT_USE_TIMER + rgblight_timer_task(); +#endif + +#ifdef VELOCIKEY_ENABLE + if (rgblight_velocikey_enabled()) { + rgblight_velocikey_decelerate(); + } +#endif +} + +#ifdef VELOCIKEY_ENABLE +# define TYPING_SPEED_MAX_VALUE 200 + +static uint8_t typing_speed = 0; + +bool rgblight_velocikey_enabled(void) { + return rgblight_config.velocikey; +} + +void rgblight_velocikey_toggle(void) { + dprintf("rgblight velocikey toggle [EEPROM]: rgblight_config.velocikey = %u\n", !rgblight_config.velocikey); + rgblight_config.velocikey = !rgblight_config.velocikey; + eeconfig_update_rgblight_current(); +} + +void rgblight_velocikey_accelerate(void) { + if (typing_speed < TYPING_SPEED_MAX_VALUE) typing_speed += (TYPING_SPEED_MAX_VALUE / 100); +} + +void rgblight_velocikey_decelerate(void) { + static uint16_t decay_timer = 0; + + if (timer_elapsed(decay_timer) > 500 || decay_timer == 0) { + if (typing_speed > 0) typing_speed -= 1; + // Decay a little faster at half of max speed + if (typing_speed > TYPING_SPEED_MAX_VALUE / 2) typing_speed -= 1; + // Decay even faster at 3/4 of max speed + if (typing_speed > TYPING_SPEED_MAX_VALUE / 4 * 3) typing_speed -= 2; + decay_timer = timer_read(); + } +} + +uint8_t rgblight_velocikey_match_speed(uint8_t minValue, uint8_t maxValue) { + return MAX(minValue, maxValue - (maxValue - minValue) * ((float)typing_speed / TYPING_SPEED_MAX_VALUE)); +} + +#endif
\ No newline at end of file diff --git a/quantum/rgblight/rgblight.h b/quantum/rgblight/rgblight.h index 450caf603e..a222ab6b9f 100644 --- a/quantum/rgblight/rgblight.h +++ b/quantum/rgblight/rgblight.h @@ -248,7 +248,8 @@ typedef union { uint64_t raw; struct { bool enable : 1; - uint8_t mode : 7; + bool velocikey : 1; + uint8_t mode : 6; uint8_t hue : 8; uint8_t sat : 8; uint8_t val : 8; @@ -385,14 +386,15 @@ 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); -#ifdef RGBLIGHT_USE_TIMER +void preprocess_rgblight(void); void rgblight_task(void); + +#ifdef RGBLIGHT_USE_TIMER void rgblight_timer_init(void); void rgblight_timer_enable(void); void rgblight_timer_disable(void); void rgblight_timer_toggle(void); #else -# define rgblight_task() # define rgblight_timer_init() # define rgblight_timer_enable() # define rgblight_timer_disable() @@ -446,3 +448,14 @@ void rgblight_effect_alternating(animation_status_t *anim); void rgblight_effect_twinkle(animation_status_t *anim); #endif + +#ifdef VELOCIKEY_ENABLE +bool rgblight_velocikey_enabled(void); +void rgblight_velocikey_toggle(void); +void rgblight_velocikey_accelerate(void); +void rgblight_velocikey_decelerate(void); +uint8_t rgblight_velocikey_match_speed(uint8_t minValue, uint8_t maxValue); + +# define velocikey_enabled rgblight_velocikey_enabled +# define velocikey_toggle rgblight_velocikey_toggle +#endif diff --git a/quantum/velocikey.c b/quantum/velocikey.c deleted file mode 100644 index 03e91911f6..0000000000 --- a/quantum/velocikey.c +++ /dev/null @@ -1,40 +0,0 @@ -#include "velocikey.h" -#include "timer.h" -#include "eeconfig.h" -#include "eeprom.h" -#include "util.h" - -#define TYPING_SPEED_MAX_VALUE 200 -uint8_t typing_speed = 0; - -bool velocikey_enabled(void) { - return eeprom_read_byte(EECONFIG_VELOCIKEY) == 1; -} - -void velocikey_toggle(void) { - if (velocikey_enabled()) - eeprom_update_byte(EECONFIG_VELOCIKEY, 0); - else - eeprom_update_byte(EECONFIG_VELOCIKEY, 1); -} - -void velocikey_accelerate(void) { - if (typing_speed < TYPING_SPEED_MAX_VALUE) typing_speed += (TYPING_SPEED_MAX_VALUE / 100); -} - -void velocikey_decelerate(void) { - static uint16_t decay_timer = 0; - - if (timer_elapsed(decay_timer) > 500 || decay_timer == 0) { - if (typing_speed > 0) typing_speed -= 1; - // Decay a little faster at half of max speed - if (typing_speed > TYPING_SPEED_MAX_VALUE / 2) typing_speed -= 1; - // Decay even faster at 3/4 of max speed - if (typing_speed > TYPING_SPEED_MAX_VALUE / 4 * 3) typing_speed -= 2; - decay_timer = timer_read(); - } -} - -uint8_t velocikey_match_speed(uint8_t minValue, uint8_t maxValue) { - return MAX(minValue, maxValue - (maxValue - minValue) * ((float)typing_speed / TYPING_SPEED_MAX_VALUE)); -} diff --git a/quantum/velocikey.h b/quantum/velocikey.h deleted file mode 100644 index c375f82f71..0000000000 --- a/quantum/velocikey.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -#include <stdint.h> -#include <stdbool.h> - -bool velocikey_enabled(void); -void velocikey_toggle(void); -void velocikey_accelerate(void); -void velocikey_decelerate(void); -uint8_t velocikey_match_speed(uint8_t minValue, uint8_t maxValue); |