Compare commits

..

34 Commits

Author SHA1 Message Date
d7754a19b9 Remove problematic unicode_map stub definition in process_unicodemap.c (#5110)
* Remove problematic unicode_map stub definition in process_unicodemap.c

* Add unicode_map declaration to process_unicodemap.h

* Disable UNICODEMAP on converter boards that don't use it
2019-02-14 20:55:31 -08:00
3a3de84e40 Tweak issue templates (capitalisation mostly) (#5133)
* Tweak issue templates (capitalisation mostly)

* Consistent headings
2019-02-14 20:44:27 -08:00
c22f3ba3a2 Debounce refactor / API (#3720)
* Added xeal60 via clone of lets split

* Delete removed other keymaps

* Basic keymap (no FN). Compiles.

* Removed NP_STAR and NP_SLSH.

* Removed "debounce_algo = manual" in all keyboards with CUSTOM_MATRIX = yes.

* Changed order of rules in TMK. Documented feature.

* Fixed missing whitespace in debounce documentation

Table wasn't working due to missing newline.

* Added bold in a few areas.

* DO NOT USE - Removed debounce from TMK.

* Remove accidental xeal60 commit

* DO NOT USE - debounce successfully compiled.

* DO NOT USE Revert back to original API to support split_keyboards.

* Working eager_pk

* Whitespace cleanup.

* Restored debounce.h since there wasnt any real change.

* Moved debouncing_time variable  to inside #if debounce

* Removed check for custom_matrix. We can safely include the debounce file for compilation when custom_matrix is used.

* Removed #include "matrix.h" from debounce.h

* Bug fix - was using MATRIX_ROWS instead of num_rows

* Fixed compilation error with debounce_sym_g

* Renamed DEBOUNCE_ALGO to DEBOUNCE_TYPE

* Malloc array in debounce_eager_pk, since split keyboards only use MATRIX_ROWS/2.

* Fix compile error in debounce_eager_pk

* Stricter, leaner DEBOUNCE_TYPE section in common_features.mk. Cleanup debounce_type.mk
2019-02-14 20:36:20 -08:00
cc5c6b449a Add kb and user level keyboard initialization functions (#3113)
* Add suspend functions

* Disable RGB code if it's disabled

* Add keyboard_init functions

* Change where references so it will compile

* Wrong command chained in wake up kb function

* Fix non-feature file changes

* Add documentation

* Re-add matrix init docs

* add rgblight code to example

* Remove suspend code

* Clean up docs

* Fix docs

* Fix suspend code

* more doc fixes

* change function to startup_* rather than keyboard_init_

* fix spelling error

* fix up docs to finish removing keyboard_init

* Use Pre and Post init functions

* Update Documenation

* Remove changes to my keymap and userspace code

* Cleanup

* Revert changes to extra files

* Forgot a semicolon

* Make sure all protocols call keyboard_setup

* Cleanup functions

* Unset startup_user

* Remove changes from division keyboard

* Readd startup_user function

* Remove all to startup_user

* Update docs/custom_quantum_functions.md

Co-Authored-By: drashna <drashna@live.com>

* Update docs/custom_quantum_functions.md

Co-Authored-By: drashna <drashna@live.com>

* Add suggestion line

* Rebase fixes

* Update documentation to be more useful/accurate

* Cleanup of documentation

* Fix spacing inconsistency

* Revert unexpected change to keymap
2019-02-14 20:18:54 -08:00
40e67a3074 Add a mechanism for force building a particular community layout (#5027)
* Add a mechanism for force building a particular community layout

* Add docs for FORCE_LAYOUT argument

* Update output name when FORCE_LAYOUT is enabled
2019-02-14 20:14:26 -08:00
7d8c629939 Stricter, leaner DEBOUNCE_TYPE section in common_features.mk. Cleanup debounce_type.mk 2019-01-27 07:23:15 +11:00
562c0d702a Fix compile error in debounce_eager_pk 2019-01-27 00:10:14 +11:00
503e02db79 Merge branch 'debounce_refactor' of https://github.com/alex-ong/qmk_firmware into debounce_refactor 2019-01-26 23:21:27 +11:00
10cc423515 Malloc array in debounce_eager_pk, since split keyboards only use MATRIX_ROWS/2. 2019-01-26 23:18:24 +11:00
d30d5eeb27 Renamed DEBOUNCE_ALGO to DEBOUNCE_TYPE 2019-01-26 23:01:07 +11:00
039dde3a51 Fixed compilation error with debounce_sym_g 2019-01-26 22:57:39 +11:00
7cb8d3c7a7 Bug fix - was using MATRIX_ROWS instead of num_rows 2019-01-26 22:45:25 +11:00
b5b119544a Removed #include "matrix.h" from debounce.h 2019-01-26 22:44:33 +11:00
cce8dfab39 Removed check for custom_matrix. We can safely include the debounce file for compilation when custom_matrix is used. 2019-01-26 20:37:47 +11:00
14ed96aa06 Moved debouncing_time variable to inside #if debounce 2019-01-26 18:26:49 +11:00
5b7fc758d7 Restored debounce.h since there wasnt any real change. 2019-01-26 17:46:27 +11:00
574fc6444b Whitespace cleanup. 2019-01-26 17:38:52 +11:00
4d8733591f Working eager_pk 2019-01-26 17:29:02 +11:00
123608fb31 DO NOT USE Revert back to original API to support split_keyboards. 2019-01-26 17:10:27 +11:00
d0b691df0e DO NOT USE - debounce successfully compiled. 2019-01-26 17:03:46 +11:00
3949ab322d Remove accidental xeal60 commit 2019-01-26 16:59:02 +11:00
39ca330f10 DO NOT USE - Removed debounce from TMK. 2019-01-26 16:56:01 +11:00
c9ba618654 DO NOT USE Merge branch 'master' into debounce_refactor
Merged, however now there are two debounce.h and debounce.c to mess around with and coalesce.
# Conflicts:
#	quantum/matrix.c
2019-01-26 12:13:19 +11:00
d977daa8dc Merge branch 'master' of https://github.com/qmk/qmk_firmware 2019-01-26 11:36:28 +11:00
2bb2977c13 Merge branch 'master' into debounce_refactor
# Conflicts:
#	tmk_core/common/keyboard.c
2019-01-04 19:43:45 +11:00
47c91fc7f7 Merge branch 'master' of https://github.com/qmk/qmk_firmware 2019-01-04 19:39:14 +11:00
a55c838961 Added bold in a few areas. 2018-08-29 10:49:53 +10:00
e8e6268765 Fixed missing whitespace in debounce documentation
Table wasn't working due to missing newline.
2018-08-29 10:48:11 +10:00
4db27a2c76 Changed order of rules in TMK. Documented feature. 2018-08-29 10:45:53 +10:00
3cf7f7322c Removed "debounce_algo = manual" in all keyboards with CUSTOM_MATRIX = yes. 2018-08-29 10:19:36 +10:00
ac9b88e8cc Removed NP_STAR and NP_SLSH. 2018-08-12 21:39:55 +10:00
714e0da960 Basic keymap (no FN). Compiles. 2018-08-12 21:27:51 +10:00
c796944354 Delete removed other keymaps 2018-08-12 18:25:50 +10:00
2758158a4b Added xeal60 via clone of lets split 2018-08-12 17:23:58 +10:00
29 changed files with 484 additions and 175 deletions

View File

@ -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. -->

View File

@ -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. -->

View File

@ -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. -->

View File

@ -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).

View File

@ -135,6 +135,10 @@ ifeq ($(strip $(CONVERT_TO_PROTON_C)), yes)
OPT_DEFS += -DCONVERT_TO_PROTON_C
endif
ifneq ($(FORCE_LAYOUT),)
TARGET := $(TARGET)_$(FORCE_LAYOUT)
endif
include quantum/mcu_selection.mk
ifdef MCU_FAMILY

View File

@ -15,4 +15,13 @@ define SEARCH_LAYOUTS
$$(foreach LAYOUTS_REPO,$$(LAYOUTS_REPOS),$$(eval $$(call SEARCH_LAYOUTS_REPO)))
endef
ifneq ($(FORCE_LAYOUT),)
ifneq (,$(findstring $(FORCE_LAYOUT),$(LAYOUTS)))
$(info Forcing layout: $(FORCE_LAYOUT))
LAYOUTS := $(FORCE_LAYOUT)
else
$(error Forced layout does not exist)
endif
endif
$(foreach LAYOUT,$(LAYOUTS),$(eval $(call SEARCH_LAYOUTS)))

View File

@ -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

View File

@ -165,18 +165,35 @@ In addition, it is possible to specify the brightness level of all LEDs with `er
Ergodox boards also define `LED_BRIGHTNESS_LO` for the lowest brightness and `LED_BRIGHTNESS_HI` for the highest brightness (which is the default).
# Matrix Initialization Code
# Keyboard Initialization Code
Before a keyboard can be used the hardware must be initialized. QMK handles initialization of the keyboard matrix itself, but if you have other hardware like LEDs or i&#xb2;c controllers you will need to set up that hardware before it can be used.
There are several steps in the keyboard initialization process. Depending on what you want to do, it will influence which function you should use.
These are the three main initialization functions, listed in the order that they're called.
### Example `matrix_init_user()` Implementation
* `keyboard_pre_init_*` - Happens before most anything is started. Good for hardware setup that you want running very early.
* `matrix_init_*` - Happens midway through the firmware's startup process. Hardware is initialized, but features may not be yet.
* `keyboard_post_init_*` - Happens at the end of the firmware's startup process. This is where you'd want to put "customization" code, for the most part.
!> For most people, the `keyboard_post_init_user` function is what you want to call. For instance, this is where you want to set up things for RGB Underglow.
## Keyboard Pre Initialization code
This runs very early during startup, even before the USB has been started.
Shortly after this, the matrix is initialized.
For most users, this shouldn't be used, as it's primarily for hardware oriented initialization.
However, if you have hardware stuff that you need initialized, this is the best place for it (such as initializing LED pins).
### Example `keyboard_pre_init_user()` Implementation
This example, at the keyboard level, sets up B1, B2, and B3 as LED pins.
```c
void matrix_init_user(void) {
// Call the keymap level matrix init.
void keyboard_pre_init_user(void) {
// Call the keyboard pre init code.
// Set our LED pins as output
DDRB |= (1<<1);
@ -185,11 +202,47 @@ void matrix_init_user(void) {
}
```
### `keyboard_pre_init_*` Function Documentation
* Keyboard/Revision: `void keyboard_pre_init_kb(void)`
* Keymap: `void keyboard_pre_init_user(void)`
## Matrix Initialization Code
This is called when the matrix is initialized, and after some of the hardware has been set up, but before many of the features have been initialized.
This is useful for setting up stuff that you may need elsewhere, but isn't hardware related nor is dependant on where it's started.
### `matrix_init_*` Function Documentation
* Keyboard/Revision: `void matrix_init_kb(void)`
* Keymap: `void matrix_init_user(void)`
## Keyboard Post Initialization code
This is ran as the very last task in the keyboard initialization process. This is useful if you want to make changes to certain features, as they should be initialized by this point.
### Example `keyboard_post_init_user()` Implementation
This example, running after everything else has initialized, sets up the rgb underglow configuration.
```c
void keyboard_post_init_user(void) {
// Call the post init code.
rgblight_enable_noeeprom(); // enables Rgb, without saving settings
rgblight_sethsv_noeeprom(180, 255, 255): // sets the color to teal/cyan without saving
rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING + 3); // sets mode to Fast breathing without saving
}
```
### `keyboard_post_init_*` Function Documentation
* Keyboard/Revision: `void keyboard_post_init_kb(void)`
* Keymap: `void keyboard_post_init_user(void)`
# Matrix Scanning Code
Whenever possible you should customize your keyboard by using `process_record_*()` and hooking into events that way, to ensure that your code does not have a negative performance impact on your keyboard. However, in rare cases it is necessary to hook into the matrix scanning. Be extremely careful with the performance of code in these functions, as it will be called at least 10 times per second.
@ -229,10 +282,9 @@ void suspend_wakeup_init_user(void)
{
rgb_matrix_set_suspend_state(false);
}
```
### `keyboard_init_*` Function Documentation
### Keyboard suspend/wake Function Documentation
* Keyboard/Revision: `void suspend_power_down_kb(void)` and `void suspend_wakeup_init_user(void)`
* Keymap: `void suspend_power_down_kb(void)` and `void suspend_wakeup_init_user(void)`
@ -285,7 +337,7 @@ Keep in mind that EEPROM has a limited number of writes. While this is very high
* If you don't understand the example, then you may want to avoid using this feature, as it is rather complicated.
### Example Implementation
### Example Implementation
This is an example of how to add settings, and read and write it. We're using the user keymap for the example here. This is a complex function, and has a lot going on. In fact, it uses a lot of the above functions to work!

View 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.

View File

@ -51,6 +51,35 @@ The folder name must be added to the keyboard's `rules.mk`:
but the `LAYOUT_<layout>` variable must be defined in `<folder>.h` as well.
## Building a Keymap
You should be able to build the keyboard keymap with a command in this format:
make <keyboard>:<layout>
### Conflicting layouts
When a keyboard supports multiple layout options,
LAYOUTS = ortho_4x4 ortho_4x12
And a layout exists for both options,
```
layouts/
+ community/
| + ortho_4x4/
| | + <layout>/
| | | + ...
| + ortho_4x12/
| | + <layout>/
| | | + ...
| + ...
```
The FORCE_LAYOUT argument can be used to specify which layout to build
make <keyboard>:<layout> FORCE_LAYOUT=ortho_4x4
make <keyboard>:<layout> FORCE_LAYOUT=ortho_4x12
## Tips for Making Layouts Keyboard-Agnostic
### Includes

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);

View 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;
}

View 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;
}

View 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!

View File

@ -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;

View File

@ -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--) {

View File

@ -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);

View File

@ -142,20 +142,20 @@ static void power_down(uint8_t wdto) {
#endif
suspend_power_down_kb();
// TODO: more power saving
// See PicoPower application note
// - I/O port input with pullup
// - prescale clock
// - BOD disable
// - Power Reduction Register PRR
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
sei();
sleep_cpu();
sleep_disable();
// TODO: more power saving
// See PicoPower application note
// - I/O port input with pullup
// - prescale clock
// - BOD disable
// - Power Reduction Register PRR
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
sei();
sleep_cpu();
sleep_disable();
// Disable watchdog after sleep
wdt_disable();
// Disable watchdog after sleep
wdt_disable();
}
#endif

View File

@ -139,6 +139,40 @@ __attribute__ ((weak))
void matrix_setup(void) {
}
/** \brief keyboard_pre_init_user
*
* FIXME: needs doc
*/
__attribute__ ((weak))
void keyboard_pre_init_user(void) { }
/** \brief keyboard_pre_init_kb
*
* FIXME: needs doc
*/
__attribute__ ((weak))
void keyboard_pre_init_kb(void) {
keyboard_pre_init_user();
}
/** \brief keyboard_post_init_user
*
* FIXME: needs doc
*/
__attribute__ ((weak))
void keyboard_post_init_user() {}
/** \brief keyboard_post_init_kb
*
* FIXME: needs doc
*/
__attribute__ ((weak))
void keyboard_post_init_kb(void) {
keyboard_post_init_user();
}
/** \brief keyboard_setup
*
* FIXME: needs doc
@ -146,6 +180,7 @@ void matrix_setup(void) {
void keyboard_setup(void) {
disable_jtag();
matrix_setup();
keyboard_pre_init_kb();
}
/** \brief is_keyboard_master
@ -199,6 +234,7 @@ void keyboard_init(void) {
#if defined(NKRO_ENABLE) && defined(FORCE_NKRO)
keymap_config.nkro = 1;
#endif
keyboard_post_init_kb(); /* Always keep this last */
}
/** \brief Keyboard task: Do keyboard routine jobs
@ -216,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;
@ -227,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++) {

View File

@ -70,6 +70,11 @@ void keyboard_set_leds(uint8_t leds);
/* it runs whenever code has to behave differently on a slave */
bool is_keyboard_master(void);
void keyboard_pre_init_kb(void);
void keyboard_pre_init_user(void);
void keyboard_post_init_kb(void);
void keyboard_post_init_user(void);
#ifdef __cplusplus
}
#endif

View File

@ -42,13 +42,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
int main(void)
{
{
CPU_PRESCALE(0);
// DDRD = _BV(PD5);
// DDRB = _BV(PB0);
// PORTD = _BV(PD5);
// PORTB = _BV(PB0);
@ -59,22 +59,23 @@ int main(void)
// while (!usb_configured()) /* wait */
keyboard_setup();
dprintf("Initializing keyboard...\n");
keyboard_init();
// This implementation is pretty simplistic... if the USB connection
// is not configured, choose the Bluefruit, otherwise use USB
// Definitely would prefer to have this driven by an input pin and make
// it switch dynamically - BCG
// if (!usb_configured()) {
// // Send power to Bluefruit... Adafruit says it takes 27 mA, I think
// // the pins should provide 40 mA, but just in case I switch the
// // the pins should provide 40 mA, but just in case I switch the
// // Bluefruit using a transistor - BCG
// DDRB = _BV(PB6);
// PORTB |= _BV(PB6);
dprintf("Setting host driver to bluefruit...\n");
host_set_driver(bluefruit_driver());
@ -131,7 +132,7 @@ int main(void)
// usb_remote_wakeup();
// }
// }
// keyboard_task();
// keyboard_task();
// }
// }

View File

@ -119,6 +119,8 @@ int main(void) {
// TESTING
// chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
keyboard_setup();
/* Init USB */
init_usb_driver(&USB_DRIVER);

View File

@ -56,6 +56,7 @@ int main(void)
#ifndef NO_UART
uart_init(UART_BAUD_RATE);
#endif
keyboard_setup();
keyboard_init();
host_set_driver(vusb_driver());