mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-09-10 17:15:43 +00:00
Compare commits
36 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc146e32dc | ||
|
|
68fad7b777 | ||
|
|
7c2bee8b88 | ||
|
|
1e1b55fbdf | ||
|
|
d7754a19b9 | ||
|
|
3a3de84e40 | ||
|
|
c22f3ba3a2 | ||
|
|
7d8c629939 | ||
|
|
562c0d702a | ||
|
|
503e02db79 | ||
|
|
10cc423515 | ||
|
|
d30d5eeb27 | ||
|
|
039dde3a51 | ||
|
|
7cb8d3c7a7 | ||
|
|
b5b119544a | ||
|
|
cce8dfab39 | ||
|
|
14ed96aa06 | ||
|
|
5b7fc758d7 | ||
|
|
574fc6444b | ||
|
|
4d8733591f | ||
|
|
123608fb31 | ||
|
|
d0b691df0e | ||
|
|
3949ab322d | ||
|
|
39ca330f10 | ||
|
|
c9ba618654 | ||
|
|
d977daa8dc | ||
|
|
2bb2977c13 | ||
|
|
47c91fc7f7 | ||
|
|
a55c838961 | ||
|
|
e8e6268765 | ||
|
|
4db27a2c76 | ||
|
|
3cf7f7322c | ||
|
|
ac9b88e8cc | ||
|
|
714e0da960 | ||
|
|
c796944354 | ||
|
|
2758158a4b |
31
.github/ISSUE_TEMPLATE/bug_report.md
vendored
31
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -2,30 +2,31 @@
|
||||
name: Bug report
|
||||
about: Create a report to help us improve the QMK Firmware
|
||||
---
|
||||
<!-- Provide a general summary of the bug in the Title above -->
|
||||
<!-- Provide a general summary of the bug in the title above. -->
|
||||
|
||||
<!-- This template is entirely option and can be removed, but is here to help both you and us. -->
|
||||
<!-- This text and anything on lines wrapped like this one will not show up in the final text. This text is to help us and you. -->
|
||||
<!--- This template is entirely optional and can be removed, but is here to help both you and us. -->
|
||||
<!--- Anything on lines wrapped in comments like these will not show up in the final text. -->
|
||||
|
||||
**Describe the bug**
|
||||
## Describe the Bug
|
||||
|
||||
<!-- A clear and concise description of what the bug is. -->
|
||||
|
||||
**System Information**
|
||||
## System Information
|
||||
|
||||
- Keyboard:
|
||||
- Revision (if applicable):
|
||||
- Operating System:
|
||||
- avr-gcc version:
|
||||
<!-- Run `avr-gcc --version` to find out -->
|
||||
- arm gcc version:
|
||||
<!-- Run `arm-none-eabi-gcc --version` to find out -->
|
||||
- Operating system:
|
||||
- AVR GCC version:
|
||||
<!-- Run `avr-gcc --version` to find this out. -->
|
||||
- ARM GCC version:
|
||||
<!-- Run `arm-none-eabi-gcc --version` to find this out. -->
|
||||
- QMK Firmware version:
|
||||
<!-- You can run `git describe --abbrev=0 --tags` to find this out -->
|
||||
<!-- Run `git describe --abbrev=0 --tags` to find this out. -->
|
||||
- Any keyboard related software installed?
|
||||
- [ ] Auto Hot Key
|
||||
- [ ] AutoHotKey
|
||||
- [ ] Karabiner
|
||||
- [ ] Other
|
||||
- [ ] Other:
|
||||
|
||||
**Additional context**
|
||||
## Additional Context
|
||||
|
||||
<!-- Add any other context about the problem here. -->
|
||||
<!-- Add any other relevant information about the problem here. -->
|
||||
|
||||
16
.github/ISSUE_TEMPLATE/feature_request.md
vendored
16
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -2,18 +2,18 @@
|
||||
name: Feature request
|
||||
about: Suggest a new feature or changes to existing features
|
||||
---
|
||||
<!--- Provide a general summary of the changes you want in the Title above -->
|
||||
<!--- Provide a general summary of the changes you want in the title above. -->
|
||||
|
||||
<!-- This template is entirely option and can be removed, but is here to help both you and us. -->
|
||||
<!-- This text and anything on lines wrapped like this one will not show up in the final text. This text is to help us and you. -->
|
||||
<!--- This template is entirely optional and can be removed, but is here to help both you and us. -->
|
||||
<!--- Anything on lines wrapped in comments like these will not show up in the final text. -->
|
||||
|
||||
## Feature Request Type
|
||||
|
||||
- [ ] Core Functionality
|
||||
- [ ] Add-on hardware support (e.g. audio, RGB, OLED screen, etc.)
|
||||
- [ ] Alteration (enhancement/optimization) of existing Feature(s)
|
||||
- [ ] Core functionality
|
||||
- [ ] Add-on hardware support (eg. audio, RGB, OLED screen, etc.)
|
||||
- [ ] Alteration (enhancement/optimization) of existing feature(s)
|
||||
- [ ] New behavior
|
||||
|
||||
## Description
|
||||
## Description
|
||||
|
||||
<!-- A few sentences describing what it is that you'd like to see. Additional information (such as links to spec sheets, licensing info, other related issues or PR's, etc) would be helpful. -->
|
||||
<!-- A few sentences describing what it is that you'd like to see in QMK. Additional information (such as links to spec sheets, licensing info, other related issues or PRs, etc) would be helpful. -->
|
||||
|
||||
6
.github/ISSUE_TEMPLATE/other_issues.md
vendored
6
.github/ISSUE_TEMPLATE/other_issues.md
vendored
@@ -2,8 +2,8 @@
|
||||
name: Other issues
|
||||
about: Anything else that doesn't fall into the above categories.
|
||||
---
|
||||
<!--- Provide a general summary of the changes you want in the Title above -->
|
||||
<!--- Provide a general summary of the changes you want in the title above. -->
|
||||
|
||||
<!-- This text and anything on lines wrapped like this one will not show up in the final text. This text is to help us and you. -->
|
||||
<!--- Anything on lines wrapped in comments like these will not show up in the final text. -->
|
||||
|
||||
<!-- Please check https://docs.qmk.fm/#/support for additional resources first. If that doesn't answer your question, check the bug report option, as that may be more appropriate. -->
|
||||
<!-- Please check https://docs.qmk.fm/#/support for additional resources first. If that doesn't answer your question, choose the bug report template instead, as that may be more appropriate. -->
|
||||
|
||||
28
.github/PULL_REQUEST_TEMPLATE.md
vendored
28
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -1,32 +1,34 @@
|
||||
<!--- Provide a general summary of your changes in the Title above -->
|
||||
<!--- Provide a general summary of your changes in the title above. -->
|
||||
|
||||
<!--- This template is entirely option and can be removed, but is here to help both you and us. -->
|
||||
<!--- This text and anything on lines wrapped like this one will not show up in the final text. This text is to help us and you. -->
|
||||
<!--- This template is entirely optional and can be removed, but is here to help both you and us. -->
|
||||
<!--- Anything on lines wrapped in comments like these will not show up in the final text. -->
|
||||
|
||||
## Description
|
||||
<!--- Describe your changes in detail -->
|
||||
|
||||
## Types of changes
|
||||
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
|
||||
<!--- Describe your changes in detail here. -->
|
||||
|
||||
## Types of Changes
|
||||
|
||||
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply. -->
|
||||
- [ ] Core
|
||||
- [ ] Bugfix
|
||||
- [ ] New Feature
|
||||
- [ ] Enhancement/Optimization
|
||||
- [ ] New feature
|
||||
- [ ] Enhancement/optimization
|
||||
- [ ] Keyboard (addition or update)
|
||||
- [ ] Keymap/Layout/Userspace (addition or update)
|
||||
- [ ] Keymap/layout/userspace (addition or update)
|
||||
- [ ] Documentation
|
||||
|
||||
|
||||
## Issues Fixed or Closed by this PR
|
||||
## Issues Fixed or Closed by This PR
|
||||
|
||||
*
|
||||
|
||||
## Checklist:
|
||||
## Checklist
|
||||
|
||||
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
|
||||
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
|
||||
- [ ] My code follows the code style of this project.
|
||||
- [ ] My change requires a change to the documentation.
|
||||
- [ ] I have updated the documentation accordingly.
|
||||
- [ ] I have read the **CONTRIBUTING** document. (https://docs.qmk.fm/#/contributing)
|
||||
- [ ] I have read the [**CONTRIBUTING** document](https://docs.qmk.fm/#/contributing).
|
||||
- [ ] I have added tests to cover my changes.
|
||||
- [ ] I have tested the changes and verified that they work and don't break anything (as well as I can manage).
|
||||
|
||||
@@ -282,10 +282,20 @@ ifneq ($(strip $(CUSTOM_MATRIX)), yes)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Include the standard debounce code if needed
|
||||
ifneq ($(strip $(CUSTOM_DEBOUNCE)), yes)
|
||||
QUANTUM_SRC += $(QUANTUM_DIR)/debounce.c
|
||||
DEBOUNCE_DIR:= $(QUANTUM_DIR)/debounce
|
||||
# Debounce Modules. If implemented in matrix.c, don't use these.
|
||||
DEBOUNCE_TYPE?= sym_g
|
||||
VALID_DEBOUNCE_TYPES := sym_g eager_pk custom
|
||||
ifeq ($(filter $(DEBOUNCE_TYPE),$(VALID_DEBOUNCE_TYPES)),)
|
||||
$(error DEBOUNCE_TYPE="$(DEBOUNCE_TYPE)" is not a valid debounce algorithm)
|
||||
endif
|
||||
ifeq ($(strip $(DEBOUNCE_TYPE)), sym_g)
|
||||
QUANTUM_SRC += $(DEBOUNCE_DIR)/debounce_sym_g.c
|
||||
else ifeq ($(strip $(DEBOUNCE_TYPE)), eager_pk)
|
||||
QUANTUM_SRC += $(DEBOUNCE_DIR)/debounce_eager_pk.c
|
||||
endif
|
||||
|
||||
|
||||
|
||||
ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
|
||||
OPT_DEFS += -DSPLIT_KEYBOARD
|
||||
|
||||
46
docs/feature_debounce_type.md
Normal file
46
docs/feature_debounce_type.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# Debounce algorithm
|
||||
|
||||
QMK supports multiple debounce algorithms through its debounce API.
|
||||
|
||||
The underlying debounce algorithm is determined by which matrix.c file you are using.
|
||||
|
||||
The logic for which debounce method called is below. It checks various defines that you have set in rules.mk
|
||||
|
||||
```
|
||||
DEBOUNCE_TYPE?= sym_g
|
||||
VALID_DEBOUNCE_TYPES := sym_g eager_pk custom
|
||||
ifeq ($(filter $(DEBOUNCE_TYPE),$(VALID_DEBOUNCE_TYPES)),)
|
||||
$(error DEBOUNCE_TYPE="$(DEBOUNCE_TYPE)" is not a valid debounce algorithm)
|
||||
endif
|
||||
ifeq ($(strip $(DEBOUNCE_TYPE)), sym_g)
|
||||
QUANTUM_SRC += $(DEBOUNCE_DIR)/debounce_sym_g.c
|
||||
else ifeq ($(strip $(DEBOUNCE_TYPE)), eager_pk)
|
||||
QUANTUM_SRC += $(DEBOUNCE_DIR)/debounce_eager_pk.c
|
||||
endif
|
||||
```
|
||||
|
||||
# Debounce selection
|
||||
|
||||
| DEBOUNCE_ALGO | Description | What to do |
|
||||
| ------------- | --------------------------------------------------- | ----------------------------- |
|
||||
| Not defined | You are using the included matrix.c and debounce.c | Nothing. Debounce_sym_g will be compiled, and used if necessary |
|
||||
| custom | Use your own debounce.c | ```SRC += debounce.c``` add your own debounce.c and implement necessary functions |
|
||||
| sym_g / eager_pk | You are using the included matrix.c and debounce.c | Use an alternative debounce algorithm |
|
||||
|
||||
**Regarding split keyboards**:
|
||||
The debounce code is compatible with split keyboards.
|
||||
|
||||
# Use your own debouncing code
|
||||
* Set ```DEBOUNCE_TYPE = custom ```.
|
||||
* Add ```SRC += debounce.c```
|
||||
* Add your own ```debounce.c```. Look at included ```debounce_sym_g.c```s for sample implementations.
|
||||
* Debouncing occurs after every raw matrix scan.
|
||||
* Use num_rows rather than MATRIX_ROWS, so that split keyboards are supported correctly.
|
||||
|
||||
# Changing between included debouncing methods
|
||||
You can either use your own code, by including your own debounce.c, or switch to another included one.
|
||||
Included debounce methods are:
|
||||
* debounce_eager_pk - debouncing per key. On any state change, response is immediate, followed by ```DEBOUNCE_DELAY``` millseconds of no further input for that key
|
||||
* debounce_sym_g - debouncing per keyboard. On any state change, a global timer is set. When ```DEBOUNCE_DELAY``` milliseconds of no changes has occured, all input changes are pushed.
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ or `keymap.c`:
|
||||
} else {
|
||||
tap_code(KC_PGUP);
|
||||
}
|
||||
} else if (index == 2) {
|
||||
} else if (index == 1) { /* Second encoder
|
||||
if (clockwise) {
|
||||
tap_code(KC_UP);
|
||||
} else {
|
||||
|
||||
@@ -12,9 +12,8 @@ BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
|
||||
MIDI_ENABLE = no # MIDI controls
|
||||
AUDIO_ENABLE = no # Audio output on port C6
|
||||
UNICODE_ENABLE = no # Unicode
|
||||
UNICODEMAP_ENABLE = yes
|
||||
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
|
||||
RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight.
|
||||
RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight.
|
||||
PS2_USE_USART = yes
|
||||
API_SYSEX_ENABLE = no
|
||||
|
||||
|
||||
@@ -58,7 +58,6 @@ BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
|
||||
MIDI_ENABLE = no # MIDI controls
|
||||
AUDIO_ENABLE = no # Audio output on port C6
|
||||
UNICODE_ENABLE = no # Unicode
|
||||
UNICODEMAP_ENABLE = yes
|
||||
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
|
||||
RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight.
|
||||
PS2_USE_USART = yes
|
||||
|
||||
@@ -22,7 +22,6 @@ BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
|
||||
MIDI_ENABLE = no # MIDI controls
|
||||
AUDIO_ENABLE = no # Audio output on port C6
|
||||
UNICODE_ENABLE = no # Unicode
|
||||
UNICODEMAP_ENABLE = no
|
||||
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
|
||||
RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight.
|
||||
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
|
||||
|
||||
@@ -22,7 +22,6 @@ BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
|
||||
MIDI_ENABLE = no # MIDI controls
|
||||
AUDIO_ENABLE = no # Audio output on port C6
|
||||
UNICODE_ENABLE = no # Unicode
|
||||
UNICODEMAP_ENABLE = yes
|
||||
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
|
||||
RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight.
|
||||
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
|
||||
|
||||
@@ -68,7 +68,7 @@ SUBPROJECT_rev1 = yes
|
||||
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
|
||||
|
||||
CUSTOM_MATRIX = no
|
||||
CUSTOM_DEBOUNCE = yes
|
||||
DEBOUNCE_TYPE = custom
|
||||
|
||||
LAYOUTS = split60
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#include "rev1.h"
|
||||
|
||||
void led_set_kb(uint8_t usb_led) {
|
||||
// put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
|
||||
// put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
|
||||
if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) {
|
||||
writePinHigh(B2);
|
||||
} else {
|
||||
writePinLow(B2);
|
||||
} else {
|
||||
writePinHigh(B2);
|
||||
}
|
||||
|
||||
led_set_user(usb_led);
|
||||
led_set_user(usb_led);
|
||||
}
|
||||
|
||||
void matrix_init_kb(void) {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#include "rev2.h"
|
||||
|
||||
void led_set_kb(uint8_t usb_led) {
|
||||
// put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
|
||||
// put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
|
||||
if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) {
|
||||
writePinHigh(B2);
|
||||
} else {
|
||||
writePinLow(B2);
|
||||
} else {
|
||||
writePinHigh(B2);
|
||||
}
|
||||
|
||||
led_set_user(usb_led);
|
||||
led_set_user(usb_led);
|
||||
}
|
||||
|
||||
void matrix_init_kb(void) {
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
|
||||
#include "matrix.h"
|
||||
#include "timer.h"
|
||||
#include "quantum.h"
|
||||
|
||||
#ifndef DEBOUNCING_DELAY
|
||||
# define DEBOUNCING_DELAY 5
|
||||
#endif
|
||||
|
||||
void debounce_init(uint8_t num_rows) {
|
||||
}
|
||||
|
||||
#if DEBOUNCING_DELAY > 0
|
||||
|
||||
static bool debouncing = false;
|
||||
|
||||
void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
|
||||
static uint16_t debouncing_time;
|
||||
|
||||
if (changed) {
|
||||
debouncing = true;
|
||||
debouncing_time = timer_read();
|
||||
}
|
||||
|
||||
if (debouncing && (timer_elapsed(debouncing_time) > DEBOUNCING_DELAY)) {
|
||||
for (uint8_t i = 0; i < num_rows; i++) {
|
||||
cooked[i] = raw[i];
|
||||
}
|
||||
debouncing = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool debounce_active(void) {
|
||||
return debouncing;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// no debounce
|
||||
void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
|
||||
if (changed)
|
||||
{
|
||||
for (uint8_t i = 0; i < num_rows; i++) {
|
||||
cooked[i] = raw[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool debounce_active(void) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@@ -8,4 +8,4 @@ void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool
|
||||
|
||||
bool debounce_active(void);
|
||||
|
||||
void debounce_init(uint8_t num_rows);
|
||||
void debounce_init(uint8_t num_rows);
|
||||
|
||||
121
quantum/debounce/debounce_eager_pk.c
Normal file
121
quantum/debounce/debounce_eager_pk.c
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
Copyright 2017 Alex Ong<the.onga@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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
Basic per-key algorithm. Uses an 8-bit counter per key.
|
||||
After pressing a key, it immediately changes state, and sets a counter.
|
||||
No further inputs are accepted until DEBOUNCE milliseconds have occurred.
|
||||
*/
|
||||
|
||||
#include "matrix.h"
|
||||
#include "timer.h"
|
||||
#include "quantum.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef DEBOUNCE
|
||||
#define DEBOUNCE 5
|
||||
#endif
|
||||
|
||||
|
||||
#if (MATRIX_COLS <= 8)
|
||||
# define ROW_SHIFTER ((uint8_t)1)
|
||||
#elif (MATRIX_COLS <= 16)
|
||||
# define ROW_SHIFTER ((uint16_t)1)
|
||||
#elif (MATRIX_COLS <= 32)
|
||||
# define ROW_SHIFTER ((uint32_t)1)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define debounce_counter_t uint8_t
|
||||
|
||||
static debounce_counter_t *debounce_counters;
|
||||
|
||||
#define DEBOUNCE_ELAPSED 251
|
||||
#define MAX_DEBOUNCE (DEBOUNCE_ELAPSED - 1)
|
||||
|
||||
void update_debounce_counters(uint8_t num_rows, uint8_t current_time);
|
||||
void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t current_time);
|
||||
|
||||
//we use num_rows rather than MATRIX_ROWS to support split keyboards
|
||||
void debounce_init(uint8_t num_rows)
|
||||
{
|
||||
debounce_counters = (debounce_counter_t*)malloc(num_rows*MATRIX_COLS * sizeof(debounce_counter_t));
|
||||
int i = 0;
|
||||
for (uint8_t r = 0; r < num_rows; r++)
|
||||
{
|
||||
for (uint8_t c = 0; c < MATRIX_COLS; c++)
|
||||
{
|
||||
debounce_counters[i++] = DEBOUNCE_ELAPSED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed)
|
||||
{
|
||||
uint8_t current_time = timer_read() % MAX_DEBOUNCE;
|
||||
update_debounce_counters(num_rows, current_time);
|
||||
transfer_matrix_values(raw, cooked, num_rows, current_time);
|
||||
}
|
||||
|
||||
//If the current time is > debounce counter, set the counter to enable input.
|
||||
void update_debounce_counters(uint8_t num_rows, uint8_t current_time)
|
||||
{
|
||||
debounce_counter_t *debounce_pointer = debounce_counters;
|
||||
for (uint8_t row = 0; row < num_rows; row++)
|
||||
{
|
||||
for (uint8_t col = 0; col < MATRIX_COLS; col++)
|
||||
{
|
||||
if (*debounce_pointer != DEBOUNCE_ELAPSED)
|
||||
{
|
||||
if (TIMER_DIFF(current_time, *debounce_pointer, MAX_DEBOUNCE) >= DEBOUNCE) {
|
||||
*debounce_pointer = DEBOUNCE_ELAPSED;
|
||||
}
|
||||
}
|
||||
debounce_pointer++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// upload from raw_matrix to final matrix;
|
||||
void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t current_time)
|
||||
{
|
||||
debounce_counter_t *debounce_pointer = debounce_counters;
|
||||
for (uint8_t row = 0; row < num_rows; row++)
|
||||
{
|
||||
matrix_row_t existing_row = cooked[row];
|
||||
matrix_row_t raw_row = raw[row];
|
||||
|
||||
for (uint8_t col = 0; col < MATRIX_COLS; col++)
|
||||
{
|
||||
matrix_row_t col_mask = (ROW_SHIFTER << col);
|
||||
bool final_value = raw_row & col_mask;
|
||||
bool existing_value = existing_row & col_mask;
|
||||
if (*debounce_pointer == DEBOUNCE_ELAPSED &&
|
||||
(existing_value != final_value))
|
||||
{
|
||||
*debounce_pointer = current_time;
|
||||
existing_row ^= col_mask; //flip the bit.
|
||||
}
|
||||
debounce_pointer++;
|
||||
}
|
||||
cooked[row] = existing_row;
|
||||
}
|
||||
}
|
||||
|
||||
bool debounce_active(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
57
quantum/debounce/debounce_sym_g.c
Normal file
57
quantum/debounce/debounce_sym_g.c
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
Copyright 2017 Alex Ong<the.onga@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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
Basic global debounce algorithm. Used in 99% of keyboards at time of implementation
|
||||
When no state changes have occured for DEBOUNCE milliseconds, we push the state.
|
||||
*/
|
||||
#include "matrix.h"
|
||||
#include "timer.h"
|
||||
#include "quantum.h"
|
||||
#ifndef DEBOUNCE
|
||||
#define DEBOUNCE 5
|
||||
#endif
|
||||
|
||||
void debounce_init(uint8_t num_rows) {}
|
||||
static bool debouncing = false;
|
||||
|
||||
#if DEBOUNCE > 0
|
||||
static uint16_t debouncing_time;
|
||||
void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed)
|
||||
{
|
||||
if (changed) {
|
||||
debouncing = true;
|
||||
debouncing_time = timer_read();
|
||||
}
|
||||
|
||||
if (debouncing && timer_elapsed(debouncing_time) > DEBOUNCE) {
|
||||
for (int i = 0; i < num_rows; i++) {
|
||||
cooked[i] = raw[i];
|
||||
}
|
||||
debouncing = false;
|
||||
}
|
||||
}
|
||||
#else //no debouncing.
|
||||
void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed)
|
||||
{
|
||||
for (int i = 0; i < num_rows; i++) {
|
||||
cooked[i] = raw[i];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
bool debounce_active(void) {
|
||||
return debouncing;
|
||||
}
|
||||
|
||||
28
quantum/debounce/readme.md
Normal file
28
quantum/debounce/readme.md
Normal file
@@ -0,0 +1,28 @@
|
||||
Debounce algorithms belong in this folder.
|
||||
Here are a few ideas
|
||||
|
||||
1) Global vs Per-Key vs Per-Row
|
||||
* Global - one timer for all keys. Any key change state affects global timer
|
||||
* Per key - one timer per key
|
||||
* Per row - one timer per row
|
||||
|
||||
2) Eager vs symmetric vs assymetric
|
||||
* Eager - any key change is reported immediately. All further inputs for DEBOUNCE ms are ignored.
|
||||
* Symmetric - wait for no changes for DEBOUNCE ms before reporting change
|
||||
* Assymetric - wait for different times depending on key-down/key-up. E.g. Eager key-down, DEBOUNCE ms key up.
|
||||
|
||||
3) Timestamp vs cycles
|
||||
* old old old code waits n cycles, decreasing count by one each matrix_scan
|
||||
* newer code stores the millisecond the change occurred, and does subraction to figure out time elapsed.
|
||||
* Timestamps are superior, i don't think cycles will ever be used again once upgraded.
|
||||
|
||||
The default algorithm is symmetric and global.
|
||||
Here are a few that could be implemented:
|
||||
|
||||
debounce_sym_g.c
|
||||
debounce_sym_pk.c
|
||||
debounce_sym_pr.c
|
||||
debounce_sym_pr_cycles.c //currently used in ergo-dox
|
||||
debounce_eager_g.c
|
||||
debounce_eager_pk.c
|
||||
debounce_eager_pr.c //could be used in ergo-dox!
|
||||
@@ -51,10 +51,8 @@ static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
|
||||
#endif
|
||||
|
||||
/* matrix state(1:on, 0:off) */
|
||||
static matrix_row_t raw_matrix[MATRIX_ROWS];
|
||||
|
||||
static matrix_row_t matrix[MATRIX_ROWS];
|
||||
|
||||
static matrix_row_t raw_matrix[MATRIX_ROWS]; //raw values
|
||||
static matrix_row_t matrix[MATRIX_ROWS]; //debounced values
|
||||
|
||||
#if (DIODE_DIRECTION == COL2ROW)
|
||||
static void init_cols(void);
|
||||
@@ -108,30 +106,6 @@ uint8_t matrix_cols(void) {
|
||||
return MATRIX_COLS;
|
||||
}
|
||||
|
||||
// void matrix_power_up(void) {
|
||||
// #if (DIODE_DIRECTION == COL2ROW)
|
||||
// for (int8_t r = MATRIX_ROWS - 1; r >= 0; --r) {
|
||||
// /* DDRxn */
|
||||
// _SFR_IO8((row_pins[r] >> 4) + 1) |= _BV(row_pins[r] & 0xF);
|
||||
// toggle_row(r);
|
||||
// }
|
||||
// for (int8_t c = MATRIX_COLS - 1; c >= 0; --c) {
|
||||
// /* PORTxn */
|
||||
// _SFR_IO8((col_pins[c] >> 4) + 2) |= _BV(col_pins[c] & 0xF);
|
||||
// }
|
||||
// #elif (DIODE_DIRECTION == ROW2COL)
|
||||
// for (int8_t c = MATRIX_COLS - 1; c >= 0; --c) {
|
||||
// /* DDRxn */
|
||||
// _SFR_IO8((col_pins[c] >> 4) + 1) |= _BV(col_pins[c] & 0xF);
|
||||
// toggle_col(c);
|
||||
// }
|
||||
// for (int8_t r = MATRIX_ROWS - 1; r >= 0; --r) {
|
||||
// /* PORTxn */
|
||||
// _SFR_IO8((row_pins[r] >> 4) + 2) |= _BV(row_pins[r] & 0xF);
|
||||
// }
|
||||
// #endif
|
||||
// }
|
||||
|
||||
void matrix_init(void) {
|
||||
|
||||
// initialize row and col
|
||||
@@ -175,6 +149,7 @@ uint8_t matrix_scan(void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
//Deprecated.
|
||||
bool matrix_is_modified(void)
|
||||
{
|
||||
if (debounce_active()) return false;
|
||||
|
||||
@@ -17,9 +17,6 @@
|
||||
#include "process_unicodemap.h"
|
||||
#include "process_unicode_common.h"
|
||||
|
||||
__attribute__((weak))
|
||||
const uint32_t PROGMEM unicode_map[] = {};
|
||||
|
||||
void register_hex32(uint32_t hex) {
|
||||
bool onzerostart = true;
|
||||
for(int i = 7; i >= 0; i--) {
|
||||
|
||||
@@ -19,5 +19,7 @@
|
||||
#include "quantum.h"
|
||||
#include "process_unicode_common.h"
|
||||
|
||||
extern const uint32_t PROGMEM unicode_map[];
|
||||
|
||||
void unicodemap_input_error(void);
|
||||
bool process_unicodemap(uint16_t keycode, keyrecord_t *record);
|
||||
|
||||
@@ -58,6 +58,7 @@ const uint16_t RGBLED_GRADIENT_RANGES[] PROGMEM = {360, 240, 180, 120, 90};
|
||||
#endif
|
||||
|
||||
rgblight_config_t rgblight_config;
|
||||
bool is_rgblight_initialized = false;
|
||||
|
||||
LED_TYPE led[RGBLED_NUM];
|
||||
bool rgblight_timer_enabled = false;
|
||||
@@ -123,6 +124,35 @@ void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1) {
|
||||
(*led1).b = b;
|
||||
}
|
||||
|
||||
void rgblight_check_config(void) {
|
||||
/* Add some out of bound checks for RGB light config */
|
||||
|
||||
if (rgblight_config.mode < RGBLIGHT_MODE_STATIC_LIGHT) {
|
||||
rgblight_config.mode = RGBLIGHT_MODE_STATIC_LIGHT;
|
||||
}
|
||||
else if (rgblight_config.mode > RGBLIGHT_MODES) {
|
||||
rgblight_config.mode = RGBLIGHT_MODES;
|
||||
}
|
||||
|
||||
if (rgblight_config.hue < 0) {
|
||||
rgblight_config.hue = 0;
|
||||
} else if (rgblight_config.hue > 360) {
|
||||
rgblight_config.hue %= 360;
|
||||
}
|
||||
|
||||
if (rgblight_config.sat < 0) {
|
||||
rgblight_config.sat = 0;
|
||||
} else if (rgblight_config.sat > 255) {
|
||||
rgblight_config.sat = 255;
|
||||
}
|
||||
|
||||
if (rgblight_config.val < 0) {
|
||||
rgblight_config.val = 0;
|
||||
} else if (rgblight_config.val > RGBLIGHT_LIMIT_VAL) {
|
||||
rgblight_config.val = RGBLIGHT_LIMIT_VAL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
uint32_t eeconfig_read_rgblight(void) {
|
||||
#if defined(__AVR__) || defined(STM32_EEPROM_ENABLE) || defined(PROTOCOL_ARM_ATSAM) || defined(EEPROM_SIZE)
|
||||
@@ -131,13 +161,14 @@ uint32_t eeconfig_read_rgblight(void) {
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void eeconfig_update_rgblight(uint32_t val) {
|
||||
#if defined(__AVR__) || defined(STM32_EEPROM_ENABLE) || defined(PROTOCOL_ARM_ATSAM) || defined(EEPROM_SIZE)
|
||||
if (eeconfig_read_rgblight() != val) {
|
||||
rgblight_check_config();
|
||||
eeprom_update_dword(EECONFIG_RGBLIGHT, val);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void eeconfig_update_rgblight_default(void) {
|
||||
//dprintf("eeconfig_update_rgblight_default\n");
|
||||
rgblight_config.enable = 1;
|
||||
@@ -148,6 +179,7 @@ void eeconfig_update_rgblight_default(void) {
|
||||
rgblight_config.speed = 0;
|
||||
eeconfig_update_rgblight(rgblight_config.raw);
|
||||
}
|
||||
|
||||
void eeconfig_debug_rgblight(void) {
|
||||
dprintf("rgblight_config eprom\n");
|
||||
dprintf("rgblight_config.enable = %d\n", rgblight_config.enable);
|
||||
@@ -159,6 +191,11 @@ void eeconfig_debug_rgblight(void) {
|
||||
}
|
||||
|
||||
void rgblight_init(void) {
|
||||
/* if already initialized, don't do it again.
|
||||
If you must do it again, extern this and set to false, first.
|
||||
This is a dirty, dirty hack until proper hooks can be added for keyboard startup. */
|
||||
if (is_rgblight_initialized) { return; }
|
||||
|
||||
debug_enable = 1; // Debug ON!
|
||||
dprintf("rgblight_init called.\n");
|
||||
dprintf("rgblight_init start!\n");
|
||||
@@ -173,6 +210,8 @@ void rgblight_init(void) {
|
||||
eeconfig_update_rgblight_default();
|
||||
rgblight_config.raw = eeconfig_read_rgblight();
|
||||
}
|
||||
rgblight_check_config();
|
||||
|
||||
eeconfig_debug_rgblight(); // display current eeprom values
|
||||
|
||||
#ifdef RGBLIGHT_USE_TIMER
|
||||
@@ -182,6 +221,9 @@ void rgblight_init(void) {
|
||||
if (rgblight_config.enable) {
|
||||
rgblight_mode_noeeprom(rgblight_config.mode);
|
||||
}
|
||||
|
||||
is_rgblight_initialized = true;
|
||||
|
||||
}
|
||||
|
||||
void rgblight_update_dword(uint32_t dword) {
|
||||
|
||||
@@ -146,6 +146,7 @@ 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_RGBTEST_INTERVALS[1] PROGMEM;
|
||||
extern bool is_rgblight_initialized;
|
||||
|
||||
typedef union {
|
||||
uint32_t raw;
|
||||
|
||||
@@ -39,9 +39,13 @@ include $(STARTUP_MK)
|
||||
# HAL-OSAL files (optional).
|
||||
include $(CHIBIOS)/os/hal/hal.mk
|
||||
|
||||
PLATFORM_MK = $(CHIBIOS)/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)/platform.mk
|
||||
ifeq ("$(PLATFORM_NAME)","")
|
||||
PLATFORM_NAME = platform
|
||||
endif
|
||||
|
||||
PLATFORM_MK = $(CHIBIOS)/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)/$(PLATFORM_NAME).mk
|
||||
ifeq ("$(wildcard $(PLATFORM_MK))","")
|
||||
PLATFORM_MK = $(CHIBIOS_CONTRIB)/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)/platform.mk
|
||||
PLATFORM_MK = $(CHIBIOS_CONTRIB)/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)/$(PLATFORM_NAME).mk
|
||||
endif
|
||||
include $(PLATFORM_MK)
|
||||
|
||||
|
||||
@@ -252,9 +252,6 @@ void keyboard_init(void) {
|
||||
void keyboard_task(void)
|
||||
{
|
||||
static matrix_row_t matrix_prev[MATRIX_ROWS];
|
||||
#ifdef MATRIX_HAS_GHOST
|
||||
// static matrix_row_t matrix_ghost[MATRIX_ROWS];
|
||||
#endif
|
||||
static uint8_t led_status = 0;
|
||||
matrix_row_t matrix_row = 0;
|
||||
matrix_row_t matrix_change = 0;
|
||||
@@ -263,24 +260,14 @@ void keyboard_task(void)
|
||||
#endif
|
||||
|
||||
matrix_scan();
|
||||
|
||||
if (is_keyboard_master()) {
|
||||
for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
|
||||
matrix_row = matrix_get_row(r);
|
||||
matrix_change = matrix_row ^ matrix_prev[r];
|
||||
if (matrix_change) {
|
||||
#ifdef MATRIX_HAS_GHOST
|
||||
if (has_ghost_in_row(r, matrix_row)) {
|
||||
/* Keep track of whether ghosted status has changed for
|
||||
* debugging. But don't update matrix_prev until un-ghosted, or
|
||||
* the last key would be lost.
|
||||
*/
|
||||
//if (debug_matrix && matrix_ghost[r] != matrix_row) {
|
||||
// matrix_print();
|
||||
//}
|
||||
//matrix_ghost[r] = matrix_row;
|
||||
continue;
|
||||
}
|
||||
//matrix_ghost[r] = matrix_row;
|
||||
if (has_ghost_in_row(r, matrix_row)) { continue; }
|
||||
#endif
|
||||
if (debug_matrix) matrix_print();
|
||||
for (uint8_t c = 0; c < MATRIX_COLS; c++) {
|
||||
|
||||
Reference in New Issue
Block a user