aboutsummaryrefslogtreecommitdiff
path: root/readme.md
diff options
context:
space:
mode:
authorIBNobody <ibnobody@gmail.com>2016-09-03 20:29:29 -0500
committerIBNobody <ibnobody@gmail.com>2016-09-03 20:29:29 -0500
commit7fd5b6581a660b2d1d6e1605533a6b6f8bda3472 (patch)
tree5e82fd5dc537389b11628b6af4e9b03ee98ccbb1 /readme.md
parentc20540984ed0e9d9f445a8e6cb82d97f52e7a352 (diff)
downloadqmk_firmware-7fd5b6581a660b2d1d6e1605533a6b6f8bda3472.tar.gz
qmk_firmware-7fd5b6581a660b2d1d6e1605533a6b6f8bda3472.zip
Updated readme to have better backlight breathing info.
Diffstat (limited to 'readme.md')
-rw-r--r--readme.md264
1 files changed, 104 insertions, 160 deletions
diff --git a/readme.md b/readme.md
index 70725bf81..371470bc3 100644
--- a/readme.md
+++ b/readme.md
@@ -54,11 +54,11 @@ Here are the steps
541. Install the Windows 10 subsystem for Linux, following [these instructions](http://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/). 541. Install the Windows 10 subsystem for Linux, following [these instructions](http://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/).
552. If you have previously cloned the repository using the normal Git bash, you will need to clean up the line endings. If you have cloned it after 20th of August 2016, you are likely fine. To clean up the line endings do the following 552. If you have previously cloned the repository using the normal Git bash, you will need to clean up the line endings. If you have cloned it after 20th of August 2016, you are likely fine. To clean up the line endings do the following
56 1. Make sure that you have no changes you haven't committed by running `git status`, if you do commit them first 56 1. Make sure that you have no changes you haven't committed by running `git status`, if you do commit them first
57 2. From within the Git bash run `git rm --cached -r .` 57 2. From within the Git bash run git rm --cached -r .`
58 3. Followed by `git reset --hard` 58 3. Followed by `git reset --hard`
593. Start the "Bash On Ubuntu On Windows" from the start menu 593. Start the "Bash On Ubuntu On Windows" from the start menu
604. With the bash open, navigate to your Git checkout. The harddisk can be accessed from `/mnt` for example `/mnt/c` for the `c:\` drive. 604. With the bash open, navigate to your git checkout. The harddisk can be accessed from `/mnt` for example `/mnt/c` for the `c:\` drive.
615. Run `sudo util/install_dependencies.sh`. 615. Run `sudo util/install_dependencies.sh`.
626. After a while the installation will finish, and you are good to go 626. After a while the installation will finish, and you are good to go
63 63
64**Note** From time to time, the dependencies might change, so just run `install_dependencies.sh` again if things are not working. 64**Note** From time to time, the dependencies might change, so just run `install_dependencies.sh` again if things are not working.
@@ -69,12 +69,11 @@ Here are the steps
69### Windows (Vista and later) 69### Windows (Vista and later)
701. If you have ever installed WinAVR, uninstall it. 701. If you have ever installed WinAVR, uninstall it.
712. Install [MHV AVR Tools](https://infernoembedded.com/sites/default/files/project/MHV_AVR_Tools_20131101.exe). Disable smatch, but **be sure to leave the option to add the tools to the PATH checked**. 712. Install [MHV AVR Tools](https://infernoembedded.com/sites/default/files/project/MHV_AVR_Tools_20131101.exe). Disable smatch, but **be sure to leave the option to add the tools to the PATH checked**.
723. If you are going to flash Infinity based keyboards you will need to install dfu-util, refer to the instructions by [Input Club](https://github.com/kiibohd/controller/wiki/Loading-DFU-Firmware). 723. Install [MinGW](https://sourceforge.net/projects/mingw/files/Installer/mingw-get-setup.exe/download). During installation, uncheck the option to install a graphical user interface. **DO NOT change the default installation folder.** The scripts depend on the default location.
734. Install [MinGW](https://sourceforge.net/projects/mingw/files/Installer/mingw-get-setup.exe/download). During installation, uncheck the option to install a graphical user interface. **DO NOT change the default installation folder.** The scripts depend on the default location. 734. Clone this repository. [This link will download it as a zip file, which you'll need to extract.](https://github.com/jackhumbert/qmk_firmware/archive/master.zip) Open the extracted folder in Windows Explorer.
745. Clone this repository. [This link will download it as a zip file, which you'll need to extract.](https://github.com/jackhumbert/qmk_firmware/archive/master.zip) Open the extracted folder in Windows Explorer. 745. Double-click on the 1-setup-path-win batch script to run it. You'll need to accept a User Account Control prompt. Press the spacebar to dismiss the success message in the command prompt that pops up.
756. Double-click on the 1-setup-path-win batch script to run it. You'll need to accept a User Account Control prompt. Press the spacebar to dismiss the success message in the command prompt that pops up. 756. Right-click on the 2-setup-environment-win batch script, select "Run as administrator", and accept the User Account Control prompt. This part may take a couple of minutes, and you'll need to approve a driver installation, but once it finishes, your environment is complete!
767. Right-click on the 2-setup-environment-win batch script, select "Run as administrator", and accept the User Account Control prompt. This part may take a couple of minutes, and you'll need to approve a driver installation, but once it finishes, your environment is complete! 767. Future build commands should be run from the MHV AVR Shell, which sets up an environment compatible with colorful build output. The standard Command Prompt will also work, but add `COLOR=false` to the end of all make commands when using it.
778. Future build commands should be run from the MHV AVR Shell, which sets up an environment compatible with colorful build output. The standard Command Prompt will also work, but add `COLOR=false` to the end of all make commands when using it.
78 77
79### Mac 78### Mac
80If you're using [homebrew,](http://brew.sh/) you can use the following commands: 79If you're using [homebrew,](http://brew.sh/) you can use the following commands:
@@ -91,13 +90,9 @@ You can also try these instructions:
912. Install the Command Line Tools from `Xcode->Preferences->Downloads`. 902. Install the Command Line Tools from `Xcode->Preferences->Downloads`.
923. Install [DFU-Programmer][dfu-prog]. 913. Install [DFU-Programmer][dfu-prog].
93 92
94If you are going to flash Infinity based keyboards you will also need dfu-util
95
96 brew install dfu-util
97
98### Linux 93### Linux
99 94
100To ensure you are always up to date, you can just run `sudo utils/install_dependencies.sh`. That should always install all the dependencies needed. 95To ensure you are always up to date, you can just run `sudo utils/install_dependencies.sh`. That should always install all the dependencies needed.
101 96
102You can also install things manually, but this documentation might not be always up to date with all requirements. 97You can also install things manually, but this documentation might not be always up to date with all requirements.
103 98
@@ -158,107 +153,47 @@ In every keymap folder, the following files are recommended:
158* `config.h` - the options to configure your keymap 153* `config.h` - the options to configure your keymap
159* `keymap.c` - all of your keymap code, required 154* `keymap.c` - all of your keymap code, required
160* `Makefile` - the features of QMK that are enabled, required to run `make` in your keymap folder 155* `Makefile` - the features of QMK that are enabled, required to run `make` in your keymap folder
161* `readme.md` - a description of your keymap, how others might use it, and explanations of features 156* `readme.md` - a description of your keymap, how others might use it, and explanations of features
162 157
163## The `make` command 158## The `make` command
164 159
165The `make` command is how you compile the firmware into a .hex file, which can be loaded by a dfu programmer (like dfu-progammer via `make dfu`) or the [Teensy loader](https://www.pjrc.com/teensy/loader.html) (only used with Teensys). 160The `make` command is how you compile the firmware into a .hex file, which can be loaded by a dfu programmer (like dfu-progammer via `make dfu`) or the [Teensy loader](https://www.pjrc.com/teensy/loader.html) (only used with Teensys). You can run `make` from the root (`/`), your keyboard folder (`/keyboards/<keyboard>/`), or your keymap folder (`/keyboards/<keyboard>/keymaps/<keymap>/`) if you have a `Makefile` there (see the example [here](/doc/keymap_makefile_example.mk)).
166
167**NOTE:** To abort a make command press `Ctrl-c`
168
169The following instruction refers to these folders.
170
171* The `root` (`/`) folder is the qmk_firmware folder, in which are `doc`, `keyboard`, `quantum`, etc.
172* The `keyboard` folder is any keyboard project's folder, like `/keyboards/planck`.
173* The `keymap` folder is any keymap's folder, like `/keyboards/planck/keymaps/default`.
174* The `subproject` folder is the subproject folder of a keyboard, like `/keyboards/ergodox/ez`
175
176### Simple instructions for building and uploading a keyboard
177
178**Most keyboards have more specific instructions in the keyboard specific readme.md file, so please check that first**
179
180If the `keymap` folder contains a file name `Makefile`
181
1821. Change the directory to the `keymap` folder
1832. Run `make <subproject>-<programmer>`
184
185Otherwise, if there's no `Makefile` in the `keymap` folder
186
1871. Enter the `keyboard` folder
1882. Run `make <subproject>-<keymap>-<programmer>`
189
190In the above commands, replace:
191
192* `<keymap>` with the name of your keymap
193* `<subproject>` with the name of the subproject (revision or sub-model of your keyboard). For example, for Ergodox it can be `ez` or `infinity`, and for Planck `rev3` or `rev4`.
194 * If the keyboard doesn't have a subproject, or if you are happy with the default (defined in `rules.mk` file of the `keyboard` folder), you can leave it out. But remember to also remove the dash (`-`) from the command.
195* `<programmer>` The programmer to use. Most keyboards use `dfu`, but some use `teensy`. Infinity keyboards use `dfu-util`. Check the readme file in the keyboard folder to find out which programmer to use.
196 * If you don't add `-<programmer` to the command line, the firmware will be still be compiled into a hex file, but the upload will be skipped.
197
198**NOTE:** Some operating systems will refuse to program unless you run the make command as root for example `sudo make dfu`
199
200### More detailed make instruction
201
202The full syntax of the `make` command is the following, but parts of the command can be left out if you run it from other directories than the `root` (as you might already have noticed by reading the simple instructions).
203
204`<keyboard>-<subproject>-<keymap>-<target>`, where:
205
206* `<keyboard>` is the name of the keyboard, for example `planck`
207 * Use `allkb` to compile all keyboards
208* `<subproject>` is the name of the subproject (revision or sub-model of the keyboard). For example, for Ergodox it can be `ez` or `infinity`, and for Planck `rev3` or `rev4`.
209 * If the keyboard doesn't have any subprojects, it can be left out
210 * To compile the default subproject, you can leave it out, or specify `defaultsp`
211 * Use `allsp` to compile all subprojects
212* `<keymap>` is the name of the keymap, for example `algernon`
213 * Use `allkm` to compile all keymaps
214* `<target>` will be explained in more detail below.
215 161
216**Note:** When you leave some parts of the command out, you should also remove the dash (`-`). 162By default, this will generate a `<keyboard>_<keymap>.hex` file in whichever folder you run `make` from. These files are ignored by git, so don't worry about deleting them when committing/creating pull requests.
217 163
218As mentioned above, there are some shortcuts, when you are in a: 164Below are some definitions that will be useful:
219 165
220* `keyboard` folder, the command will automatically fill the `<keyboard>` part. So you only need to type `<subproject>-<keymap>-<target>` 166* The "root" (`/`) folder is the qmk_firmware folder, in which are `doc`, `keyboard`, `quantum`, etc.
221* `subproject` folder, it will fill in both `<keyboard>` and `<subproject>` 167* The "keyboard" folder is any keyboard project's folder, like `/keyboards/planck`.
222* `keymap` folder, then `<keyboard>` and `<keymap>` will be filled in. If you need to specify the `<subproject>` use the following syntax `<subproject>-<target>` 168* The "keymap" folder is any keymap's folder, like `/keyboards/planck/keymaps/default`.
223 * Note in order to support this shortcut, the keymap needs its own Makefile (see the example [here](/doc/keymap_makefile_example.mk))
224* `keymap` folder of a `subproject`, then everything except the `<target>` will be filled in
225 169
226The `<target>` means the following 170Below is a list of the useful `make` commands in QMK:
227* If no target is given, then it's the same as `all` below
228* `all` compiles the keyboard and generates a `<keyboard>_<keymap>.hex` file in whichever folder you run `make` from. These files are ignored by git, so don't worry about deleting them when committing/creating pull requests.
229* `dfu`, `teensy` or `dfu-util`, compile and upload the firmware to the keyboard. If the compilation fails, then nothing will be uploaded. The programmer to use depends on the keyboard. For most keyboards it's `dfu`, but for Infinity keyboards you should use `dfu-util`, and `teensy` for standard Teensys. To find out which command you should use for your keyboard, check the keyboard specific readme. **Note** that some operating systems needs root access for these commands to work, so in that case you need to run for example `sudo make dfu`.
230* `clean`, cleans the build output folders to make sure that everything is built from scratch. Run this before normal compilation if you have some unexplainable problems.
231 171
232Some other targets are supported but, but not important enough to be documented here. Check the source code of the make files for more information. 172* `make` - builds your keyboard and keymap depending on which folder you're in. This defaults to the "default" layout (unless in a keymap folder), and Planck keyboard in the root folder
233 173 * `make keyboard=<keyboard>` - specifies the keyboard (only to be used in root)
234You can also add extra options at the end of the make command line, after the target 174 * `make keymap=<keymap>` - specifies the keymap (only to be used in root and keyboard folder - not needed when in keymap folder)
175* `make clean` - cleans the `.build` folder, ensuring that everything is re-built
176* `make dfu` - (requires dfu-programmer) builds and flashes the keymap to your keyboard once placed in reset/dfu mode (button or press `KC_RESET`). This does not work for Teensy-based keyboards like the ErgoDox EZ.
177 * `keyboard=` and `keymap=` are compatible with this
178* `make all-keyboards` - builds all keymaps for all keyboards and outputs status of each (use in root)
179* `make all-keyboards-default` - builds all default keymaps for all keyboards and outputs status of each (use in root)
180* `make all-keymaps [keyboard=<keyboard>]` - builds all of the keymaps for whatever keyboard folder you're in, or specified by `<keyboard>`
181* `make all-keyboards-*`, `make all-keyboards-default-*` and `make all-keymaps-* [keyboard=<keyboard>]` - like the normal "make-all-*" commands, but the last string aftter the `-` (for example clean) is passed to the keyboard make command.
182Other, less useful functionality:
235 183
236* `make COLOR=false` - turns off color output 184* `make COLOR=false` - turns off color output
237* `make SILENT=true` - turns off output besides errors/warnings 185* `make SILENT=true` - turns off output besides errors/warnings
238* `make VERBOSE=true` - outputs all of the gcc stuff (not interesting, unless you need to debug) 186* `make VERBOSE=true` - outputs all of the avr-gcc stuff (not interesting)
239
240The make command itself also has some additional options, type `make --help` for more information. The most useful is probably `-jx`, which specifies that you want to compile using more than one CPU, the `x` represents the number of CPUs that you want to use. Setting that can greatly reduce the compile times, especially if you are compiling many keyboards/keymaps. I usually set it to one less than the number of CPUs that I have, so that I have some left for doing other things while it's compiling. Note that not all operating systems and make versions supports that option.
241
242Here are some examples commands
243
244* `make allkb-allsp-allkm` builds everything (all keyboards, all subprojects, all keymaps). Running just `make` from the `root` will also run this.
245* `make` from within a `keyboard` directory, is the same as `make keyboard-allsp-allkm`, which compiles all subprojects and keymaps of the keyboard. **NOTE** that this behaviour has changed. Previously it compiled just the default keymap.
246* `make ergodox-infinity-algernon-clean` will clean the build output of the Ergodox Infinity keyboard. This example uses the full syntax and can be run from any folder with a `Makefile`
247* `make dfu COLOR=false` from within a keymap folder, builds and uploads the keymap, but without color output.
248 187
249## The `Makefile` 188## The `Makefile`
250 189
251There are 5 different `make` and `Makefile` locations: 190There are 3 different `make` and `Makefile` locations:
252 191
253* root (`/`) 192* root (`/`)
254* keyboard (`/keyboards/<keyboard>/`) 193* keyboard (`/keyboards/<keyboard>/`)
255* keymap (`/keyboards/<keyboard>/keymaps/<keymap>/`) 194* keymap (`/keyboards/<keyboard>/keymaps/<keymap>/`)
256* subproject (`/keyboards/<keyboard>/<subproject>`)
257* subproject keymap (`/keyboards/<keyboard>/<subproject>/keymaps/<keymap>`)
258 195
259The root contains the code used to automatically figure out which keymap or keymaps to compile based on your current directory and commandline arguments. It's considered stable, and shouldn't be modified. The keyboard one will contain the MCU set-up and default settings for your keyboard, and shouldn't be modified unless you are the producer of that keyboard. The keymap Makefile can be modified by users, and is optional. It is included automatically if it exists. You can see an example [here](/doc/keymap_makefile_example.mk) - the last few lines are the most important. The settings you set here will override any defaults set in the keyboard Makefile. **The file is required if you want to run `make` in the keymap folder.** 196The root contains the code used to automatically figure out which keymap or keymaps to compile based on your current directory and commandline arguments. It's considered stable, and shouldn't be modified. The keyboard one will contain the MCU set-up and default settings for your keyboard, and shouldn't be modified unless you are the producer of that keyboard. The keymap Makefile can be modified by users, and is optional. It is included automatically if it exists. You can see an example [here](/doc/keymap_makefile_example.mk) - the last few lines are the most important. The settings you set here will override any defaults set in the keyboard Makefile. **It is required if you want to run `make` in the keymap folder.**
260
261For keyboards and subprojects, the make files are split in two parts `Makefile` and `rules.mk`. All settings can be found in the `rules.mk` file, while the `Makefile` is just there for support and including the root `Makefile`. Keymaps contain just one `Makefile` for simplicity.
262 197
263### Makefile options 198### Makefile options
264 199
@@ -433,7 +368,7 @@ We've added shortcuts to make common modifier/tap (mod-tap) mappings more compac
433 368
434Steve Losh [described](http://stevelosh.com/blog/2012/10/a-modern-space-cadet/) the Space Cadet Shift quite well. Essentially, you hit the left Shift on its own, and you get an opening parenthesis; hit the right Shift on its own, and you get the closing one. When hit with other keys, the Shift key keeps working as it always does. Yes, it's as cool as it sounds. 369Steve Losh [described](http://stevelosh.com/blog/2012/10/a-modern-space-cadet/) the Space Cadet Shift quite well. Essentially, you hit the left Shift on its own, and you get an opening parenthesis; hit the right Shift on its own, and you get the closing one. When hit with other keys, the Shift key keeps working as it always does. Yes, it's as cool as it sounds.
435 370
436To use it, use `KC_LSPO` (Left Shift, Parens Open) for your left Shift on your keymap, and `KC_RSPC` (Right Shift, Parens Close) for your right Shift. 371To use it, use `KC_LSPO` (Left Shift, Parens Open) for your left Shift on your keymap, and `KC_RSPC` (Right Shift, Parens Close) for your right Shift.
437 372
438It's defaulted to work on US keyboards, but if your layout uses different keys for parenthesis, you can define those in your `config.h` like this: 373It's defaulted to work on US keyboards, but if your layout uses different keys for parenthesis, you can define those in your `config.h` like this:
439 374
@@ -530,11 +465,11 @@ For the sake of flexibility, tap-dance actions can be either a pair of keycodes,
530 465
531### Examples 466### Examples
532 467
533Here's a simple example for a single definition: 468Here's a simple example for a single definition:
534 469
5351. In your `makefile`, add `TAP_DANCE_ENABLE = yes` 4701. In your `makefile`, add `TAP_DANCE_ENABLE = yes`
5362. In your `config.h` (which you can copy from `qmk_firmware/keyboards/planck/config.h` to your keymap directory), add `#define TAPPING_TERM 200` 4712. In your `config.h` (which you can copy from `qmk_firmware/keyboards/planck/config.h` to your keymap directory), add `#define TAPPING_TERM 200`
5373. In your `keymap.c` file, define the variables and definitions, then add to your keymap: 4723. In your `keymap.c` file, define the variables and definitions, then add to your keymap:
538 473
539```c 474```c
540//Tap Dance Declarations 475//Tap Dance Declarations
@@ -550,10 +485,10 @@ qk_tap_dance_action_t tap_dance_actions[] = {
550}; 485};
551 486
552//In Layer declaration, add tap dance item in place of a key code 487//In Layer declaration, add tap dance item in place of a key code
553TD(TD_ESC_CAPS) 488TD(TD_ESC_CAPS)
554``` 489```
555 490
556Here's a more complex example involving custom actions: 491Here's a more complex example involving custom actions:
557 492
558```c 493```c
559enum { 494enum {
@@ -828,11 +763,11 @@ To enable them, first add a new element to the `planck_keycodes` enum -- `DYNAMI
828Afterwards create a new layer called `_DYN`: 763Afterwards create a new layer called `_DYN`:
829 764
830 #define _DYN 6 /* almost any other free number should be ok */ 765 #define _DYN 6 /* almost any other free number should be ok */
831 766
832Below these two modifications include the `dynamic_macro.h` header: 767Below these two modifications include the `dynamic_macro.h` header:
833 768
834 #include "dynamic_macro.h"` 769 #include "dynamic_macro.h"`
835 770
836Then define the `_DYN` layer with the following keys: `DYN_REC_START1`, `DYN_MACRO_PLAY1`,`DYN_REC_START2` and `DYN_MACRO_PLAY2`. It may also contain other keys, it doesn't matter apart from the fact that you won't be able to record these keys in the dynamic macros. 771Then define the `_DYN` layer with the following keys: `DYN_REC_START1`, `DYN_MACRO_PLAY1`,`DYN_REC_START2` and `DYN_MACRO_PLAY2`. It may also contain other keys, it doesn't matter apart from the fact that you won't be able to record these keys in the dynamic macros.
837 772
838 [_DYN]= { 773 [_DYN]= {
@@ -841,7 +776,7 @@ Then define the `_DYN` layer with the following keys: `DYN_REC_START1`, `DYN_MAC
841 {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}, 776 {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______},
842 {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______} 777 {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}
843 }, 778 },
844 779
845Add the following code to the very beginning of your `process_record_user()` function: 780Add the following code to the very beginning of your `process_record_user()` function:
846 781
847 if (!process_record_dynamic_macro(keycode, record)) { 782 if (!process_record_dynamic_macro(keycode, record)) {
@@ -1030,6 +965,66 @@ In the default script of AutoHotkey you can define custom hotkeys.
1030The hotkeys above are for the combination CtrlAltGui and CtrlAltGuiShift plus the letter a. 965The hotkeys above are for the combination CtrlAltGui and CtrlAltGuiShift plus the letter a.
1031AutoHotkey inserts the Text right of `Send, ` when this combination is pressed. 966AutoHotkey inserts the Text right of `Send, ` when this combination is pressed.
1032 967
968## Backlight Breathing
969
970In order to enable backlight breathing, the following line must be added to your config.h file.
971
972 #define BACKLIGHT_BREATHING
973
974The following function calls are used to control the breathing effect.
975
976* ```breathing_enable()``` - Enable the free-running breathing effect.
977* ```breathing_disable()``` - Disable the free-running breathing effect immediately.
978* ```breathing_self_disable()``` - Disable the free-running breathing effect after the current effect ends.
979* ```breathing_toggle()``` - Toggle the free-running breathing effect.
980* ```breathing_defaults()``` - Reset the speed and brightness settings of the breathing effect.
981
982The following function calls are used to control the maximum brightness of the breathing effect.
983
984* ```breathing_intensity_set(value)``` - Set the brightness of the breathing effect when it is at its max value.
985* ```breathing_intensity_default()``` - Reset the brightness of the breathing effect to the default value based on the current backlight intensity.
986
987The following function calls are used to control the cycling speed of the breathing effect.
988
989* ```breathing_speed_set(value)``` - Set the speed of the breathing effect - how fast it cycles.
990* ```breathing_speed_inc(value)``` - Increase the speed of the breathing effect by a fixed value.
991* ```breathing_speed_dec(value)``` - Decrease the speed of the breathing effect by a fixed value.
992* ```breathing_speed_default()``` - Reset the speed of the breathing effect to the default value.
993
994The following example shows how to enable the backlight breathing effect when the FUNCTION layer macro button is pressed:
995
996 case MACRO_FUNCTION:
997 if (record->event.pressed)
998 {
999 breathing_speed_set(3);
1000 breathing_enable();
1001 layer_on(LAYER_FUNCTION);
1002 }
1003 else
1004 {
1005 breathing_speed_set(1);
1006 breathing_self_disable();
1007 layer_off(LAYER_FUNCTION);
1008 }
1009 break;
1010
1011The following example shows how to pulse the backlight on-off-on when the RAISED layer macro button is pressed:
1012
1013 case MACRO_RAISED:
1014 if (record->event.pressed)
1015 {
1016 layer_on(LAYER_RAISED);
1017 breathing_speed_set(2);
1018 breathing_pulse();
1019 update_tri_layer(LAYER_LOWER, LAYER_RAISED, LAYER_ADJUST);
1020 }
1021 else
1022 {
1023 layer_off(LAYER_RAISED);
1024 update_tri_layer(LAYER_LOWER, LAYER_RAISED, LAYER_ADJUST);
1025 }
1026 break;
1027
1033## RGB Under Glow Mod 1028## RGB Under Glow Mod
1034 1029
1035![Planck with RGB Underglow](https://raw.githubusercontent.com/jackhumbert/qmk_firmware/master/keyboards/planck/keymaps/yang/planck-with-rgb-underglow.jpg) 1030![Planck with RGB Underglow](https://raw.githubusercontent.com/jackhumbert/qmk_firmware/master/keyboards/planck/keymaps/yang/planck-with-rgb-underglow.jpg)
@@ -1043,7 +1038,7 @@ For this mod, you need an unused pin wiring to DI of WS2812 strip. After wiring
1043In order to use the underglow timer functions, you need to have `#define RGBLIGHT_TIMER` in your `config.h`, and have audio disabled (`AUDIO_ENABLE = no` in your Makefile). 1038In order to use the underglow timer functions, you need to have `#define RGBLIGHT_TIMER` in your `config.h`, and have audio disabled (`AUDIO_ENABLE = no` in your Makefile).
1044 1039
1045Please add the following options into your config.h, and set them up according your hardware configuration. These settings are for the `F4` pin by default: 1040Please add the following options into your config.h, and set them up according your hardware configuration. These settings are for the `F4` pin by default:
1046 1041
1047 #define RGB_DI_PIN F4 // The pin your RGB strip is wired to 1042 #define RGB_DI_PIN F4 // The pin your RGB strip is wired to
1048 #define RGBLIGHT_TIMER // Require for fancier stuff (not compatible with audio) 1043 #define RGBLIGHT_TIMER // Require for fancier stuff (not compatible with audio)
1049 #define RGBLED_NUM 14 // Number of LEDs 1044 #define RGBLED_NUM 14 // Number of LEDs
@@ -1090,15 +1085,15 @@ If your keyboard is running an Atmega chip (atmega32u4 and others), it's pretty
1090 1085
1091The `USB Device descriptor parameter` block contains parameters are used to uniquely identify your keyboard, but they don't really matter to the machine. 1086The `USB Device descriptor parameter` block contains parameters are used to uniquely identify your keyboard, but they don't really matter to the machine.
1092 1087
1093Your `MATRIX_ROWS` and `MATRIX_COLS` are the numbers of rows and cols in your keyboard matrix - this may be different than the number of actual rows and columns on your keyboard. There are some tricks you can pull to increase the number of keys in a given matrix, but most keyboards are pretty straight-forward. 1088Your `MATRIX_ROWS` and `MATRIX_COLS` are the numbers of rows and cols in your keyboard matrix - this may be different than the number of actual rows and columns on your keyboard. There are some tricks you can pull to increase the number of keys in a given matrix, but most keyboards are pretty straight-forward.
1094 1089
1095The `MATRIX_ROW_PINS` and `MATRIX_COL_PINS` are the pins your MCU uses on each row/column. Your schematic (if you have one) will have this information on it, and the values will vary depending on your setup. This is one of the most important things to double-check in getting your keyboard setup correctly. 1090The `MATRIX_ROW_PINS` and `MATRIX_COL_PINS` are the pins your MCU uses on each row/column. Your schematic (if you have one) will have this information on it, and the values will vary depending on your setup. This is one of the most important things to double-check in getting your keyboard setup correctly.
1096 1091
1097For the `DIODE_DIRECTION`, most hand-wiring guides will instruct you to wire the diodes in the `COL2ROW` position, but it's possible that they are in the other - people coming from EasyAVR often use `ROW2COL`. Nothing will function if this is incorrect. 1092For the `DIODE_DIRECTION`, most hand-wiring guides will instruct you to wire the diodes in the `COL2ROW` position, but it's possible that they are in the other - people coming from EasyAVR often use `ROW2COL`. Nothing will function if this is incorrect.
1098 1093
1099`BACKLIGHT_PIN` is the pin that your PWM-controlled backlight (if one exists) is hooked-up to. Currently only B5, B6, and B7 are supported. 1094`BACKLIGHT_PIN` is the pin that your PWM-controlled backlight (if one exists) is hooked-up to. Currently only B5, B6, and B7 are supported.
1100 1095
1101`BACKLIGHT_BREATHING` is a fancier backlight feature, and uses one of the timers. 1096`BACKLIGHT_BREATHING` is a fancier backlight feature that adds breathing/pulsing/fading effects to the backlight. It uses the same timer as the normal backlight. These breathing effects must be called by code in your keymap.
1102 1097
1103`BACKLIGHT_LEVELS` is how many levels exist for your backlight - max is 15, and they are computed automatically from this number. 1098`BACKLIGHT_LEVELS` is how many levels exist for your backlight - max is 15, and they are computed automatically from this number.
1104 1099
@@ -1141,55 +1136,4 @@ Here is where you can (optionally) define your `KEYMAP` function to remap your m
1141} 1136}
1142``` 1137```
1143 1138
1144Each of the `kxx` variables needs to be unique, and usually follows the format `k<row><col>`. You can place `KC_NO` where your dead keys are in your matrix. 1139Each of the `kxx` variables needs to be unique, and usually follows the format `k<row><col>`. You can place `KC_NO` where your dead keys are in your matrix. \ No newline at end of file
1145
1146# Unit Testing
1147
1148If you are new to unit testing, then you can find many good resources on internet. However most of it is scattered around in small pieces here and there, and there's also many different opinions, so I won't give any recommendations.
1149
1150Instead I recommend these two books, explaining two different styles of Unit Testing in detail.
1151
1152* "Test Driven Development: By Example: Kent Beck"
1153* "Growing Object-Oriented Software, Guided By Tests: Steve Freeman, Nat Pryce"
1154
1155If you prefer videos there are Uncle Bob's [Clean Coders Videos](https://cleancoders.com/), which unfortunately cost quite a bit, especially if you want to watch many of them. But James Shore has a free [Let's Play](http://www.jamesshore.com/Blog/Lets-Play) video series.
1156
1157## Google Test and Google Mock
1158It's possible to Unit Test your code using [Google Test](https://github.com/google/googletest). The Google Test framework also includes another component for writing testing mocks and stubs, called "Google Mock". For information how to write the actual tests, please refer to the documentation on that site.
1159
1160## Use of C++
1161
1162Note that Google Test and therefore any test has to be written in C++, even if the rest of the QMK codebases is written in C. This should hopefully not be a problem even if you don't know any C++, since there's quite clear documentation and examples of the required C++ features, and you can write the rest of the test code almost as you would write normal C. Note that some compiler errors which you might get can look quite scary, but just read carefully what it says, and you should be ok.
1163
1164One thing to remember, is that you have to append `extern "C"` around all of your C file includes.
1165
1166## Adding tests for new or existing features
1167
1168If you want to unit test some feature, then take a look at the existing serial_link tests, in the `quantum/serial_link/tests folder`, and follow the steps below to create a similar structure.
1169
11701. If it doesn't already exist, add a test subfolder to the folder containing the feature.
11712. Create a `testlist.mk` and a `rules.mk` file in that folder.
11723. Include those files from the root folder `testlist.mk`and `build_test.mk` respectively.
11734. Add a new name for your testgroup to the `testlist.mk` file. Each group defined there will be a separate executable. And that's how you can support mocking out different parts. Note that it's worth adding some common prefix, just like it's done for the serial_link tests. The reason for that is that the make command allows substring filtering, so this way you can easily run a subset of the tests.
11745. Define the source files and required options in the `rules.mk` file.
1175 * `_SRC` for source files
1176 * `_DEFS` for additional defines
1177 * `_INC` for additional include folders
11786. Write the tests in a new cpp file inside the test folder you created. That file has to be one of the files included from the `rules.mk` file.
1179
1180Note how there's several different tests, each mocking out a separate part. Also note that each of them only compiles the very minimum that's needed for the tests. It's recommend that you try to do the same. For a relevant video check out [Matt Hargett "Advanced Unit Testing in C & C++](https://www.youtube.com/watch?v=Wmy6g-aVgZI)
1181
1182## Running the tests
1183
1184To run all the tests in the codebase, type `make test`. You can also run test matching a substring by typing `make test-matchingsubstring` Note that the tests are always compiled with the native compiler of your platform, so they are also run like any other program on your computer.
1185
1186## Debugging the tests
1187
1188If there are problems with the tests, you can find the executable in the `./build/test` folder. You should be able to run those with GDB or a similar debugger.
1189
1190## Full Integration tests
1191
1192It's not yet possible to do a full integration test, where you would compile the whole firmware and define a keymap that you are going to test. However there are plans for doing that, because writing tests that way would probably be easier, at least for people that are not used to unit testing.
1193
1194In that model you would emulate the input, and expect a certain output from the emulated keyboard.
1195