mirror of
https://github.com/qmk/qmk_firmware
synced 2024-11-17 17:35:30 +00:00
Merge branch 'led-support' into master
This commit is contained in:
commit
e123ff5feb
5 changed files with 84 additions and 3 deletions
|
@ -236,7 +236,8 @@ QUANTUM_SRC:= \
|
||||||
$(QUANTUM_DIR)/quantum.c \
|
$(QUANTUM_DIR)/quantum.c \
|
||||||
$(QUANTUM_DIR)/keymap_common.c \
|
$(QUANTUM_DIR)/keymap_common.c \
|
||||||
$(QUANTUM_DIR)/keycode_config.c \
|
$(QUANTUM_DIR)/keycode_config.c \
|
||||||
$(QUANTUM_DIR)/process_keycode/process_leader.c
|
$(QUANTUM_DIR)/process_keycode/process_leader.c \
|
||||||
|
$(QUANTUM_DIR)/momentum.c
|
||||||
|
|
||||||
ifndef CUSTOM_MATRIX
|
ifndef CUSTOM_MATRIX
|
||||||
ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
|
ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
|
||||||
|
|
46
quantum/momentum.c
Normal file
46
quantum/momentum.c
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
#include "momentum.h"
|
||||||
|
#include "timer.h"
|
||||||
|
#include "eeconfig.h"
|
||||||
|
#include "eeprom.h"
|
||||||
|
|
||||||
|
#ifndef MIN
|
||||||
|
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||||
|
#endif
|
||||||
|
#ifndef MAX
|
||||||
|
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define TYPING_SPEED_MAX_VALUE 200
|
||||||
|
uint8_t typing_speed = 0;
|
||||||
|
|
||||||
|
bool momentum_enabled() {
|
||||||
|
return eeprom_read_byte(EECONFIG_MOMENTUM) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void momentum_toggle() {
|
||||||
|
if (momentum_enabled())
|
||||||
|
eeprom_update_byte(EECONFIG_MOMENTUM, 0);
|
||||||
|
else
|
||||||
|
eeprom_update_byte(EECONFIG_MOMENTUM, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void momentum_accelerate() {
|
||||||
|
if (typing_speed < TYPING_SPEED_MAX_VALUE) typing_speed += (TYPING_SPEED_MAX_VALUE / 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
void momentum_decay_task() {
|
||||||
|
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 -= 3;
|
||||||
|
decay_timer = timer_read();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t match_momentum(uint8_t minValue, uint8_t maxValue) {
|
||||||
|
return MAX(minValue, maxValue - (maxValue - minValue) * ((float)typing_speed / TYPING_SPEED_MAX_VALUE));
|
||||||
|
}
|
13
quantum/momentum.h
Normal file
13
quantum/momentum.h
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#ifndef MOMENTUM_H
|
||||||
|
#define MOMENTUM_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
bool momentum_enabled(void);
|
||||||
|
void momentum_toggle(void);
|
||||||
|
void momentum_accelerate(void);
|
||||||
|
void momentum_decay_task(void);
|
||||||
|
uint8_t match_momentum(uint8_t minValue, uint8_t maxValue);
|
||||||
|
|
||||||
|
#endif
|
|
@ -1201,7 +1201,10 @@ static inline uint16_t scale_backlight(uint16_t v) {
|
||||||
*/
|
*/
|
||||||
ISR(TIMER1_OVF_vect)
|
ISR(TIMER1_OVF_vect)
|
||||||
{
|
{
|
||||||
uint16_t interval = (uint16_t) breathing_period * 244 / BREATHING_STEPS;
|
uint16_t interval = momentum_enabled()
|
||||||
|
? match_momentum(1, 10)
|
||||||
|
: (uint16_t) breathing_period * 244 / BREATHING_STEPS;
|
||||||
|
|
||||||
// resetting after one period to prevent ugly reset at overflow.
|
// resetting after one period to prevent ugly reset at overflow.
|
||||||
breathing_counter = (breathing_counter + 1) % (breathing_period * 244);
|
breathing_counter = (breathing_counter + 1) % (breathing_period * 244);
|
||||||
uint8_t index = breathing_counter / interval % BREATHING_STEPS;
|
uint8_t index = breathing_counter / interval % BREATHING_STEPS;
|
||||||
|
|
20
readme.md
20
readme.md
|
@ -1,4 +1,22 @@
|
||||||
# Quantum Mechanical Keyboard Firmware
|
# Quantum Mechanical Keyboard Firmware - chrislewisdev fork
|
||||||
|
|
||||||
|
## Typing Speed -> RGB Animation Control
|
||||||
|
|
||||||
|
This fork of qmk_firmware contains the code I whipped up to make your keyboard's RGB animation speed match your typing speed. As of writing, this is a "first draft" version, aka the simplest implementation I could think of with the quickest/hackiest code. Beware hard-coding :)
|
||||||
|
|
||||||
|
Regardless, I'm happy to share the code and discuss improvements with anyone who'd like to contribute. I'll do my best to facilitate it in my spare time.
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
My original change amounts to several lines in `quantum.h`, `quantum.c` and `rgblight.c`. To see the details it's probably easiest if you look at [this commit](https://github.com/chrislewisdev/qmk_firmware/commit/2d3fbc5d0ad70309ede5cdeb9cf84380fd69baae) which contains all the changes.
|
||||||
|
|
||||||
|
I've created GitHub Issues for the most pressing things that need to be addressed before this could be merged into QMK - if you're interested in helping out, please do take a look!
|
||||||
|
|
||||||
|
To test it, I've just been using my DZ60 keyboard, building the firmware with `make dz60:default` and flashing with qmk_toolbox. If you're not familiar with how to do that, it's probably best you consult the [QMK documentation](https://docs.qmk.fm/#/).
|
||||||
|
|
||||||
|
Below is the original QMK readme:
|
||||||
|
|
||||||
|
# QMK
|
||||||
|
|
||||||
[![Current Version](https://img.shields.io/github/tag/qmk/qmk_firmware.svg)](https://github.com/qmk/qmk_firmware/tags)
|
[![Current Version](https://img.shields.io/github/tag/qmk/qmk_firmware.svg)](https://github.com/qmk/qmk_firmware/tags)
|
||||||
[![Build Status](https://travis-ci.org/qmk/qmk_firmware.svg?branch=master)](https://travis-ci.org/qmk/qmk_firmware)
|
[![Build Status](https://travis-ci.org/qmk/qmk_firmware.svg?branch=master)](https://travis-ci.org/qmk/qmk_firmware)
|
||||||
|
|
Loading…
Reference in a new issue