Browse Source

Merge branch 'led-support' into master

pull/3754/head
Chris Lewis 5 years ago
committed by GitHub
parent
commit
e123ff5feb
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 84 additions and 3 deletions
  1. +2
    -1
      common_features.mk
  2. +46
    -0
      quantum/momentum.c
  3. +13
    -0
      quantum/momentum.h
  4. +4
    -1
      quantum/quantum.c
  5. +19
    -1
      readme.md

+ 2
- 1
common_features.mk View File

@ -236,7 +236,8 @@ QUANTUM_SRC:= \
$(QUANTUM_DIR)/quantum.c \
$(QUANTUM_DIR)/keymap_common.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
ifeq ($(strip $(SPLIT_KEYBOARD)), yes)


+ 46
- 0
quantum/momentum.c View 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
- 0
quantum/momentum.h View 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

+ 4
- 1
quantum/quantum.c View File

@ -1201,7 +1201,10 @@ static inline uint16_t scale_backlight(uint16_t v) {
*/
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.
breathing_counter = (breathing_counter + 1) % (breathing_period * 244);
uint8_t index = breathing_counter / interval % BREATHING_STEPS;


+ 19
- 1
readme.md View File

@ -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)
[![Build Status](https://travis-ci.org/qmk/qmk_firmware.svg?branch=master)](https://travis-ci.org/qmk/qmk_firmware)


Loading…
Cancel
Save