aboutsummaryrefslogtreecommitdiff
path: root/quantum/template
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/template')
-rw-r--r--quantum/template/Makefile24
-rw-r--r--quantum/template/config.h6
-rw-r--r--quantum/template/keymaps/default/Makefile21
-rw-r--r--quantum/template/keymaps/default/config.h8
-rw-r--r--quantum/template/keymaps/default/keymap.c20
-rw-r--r--quantum/template/keymaps/default/readme.md1
-rw-r--r--quantum/template/readme.md (renamed from quantum/template/README.md)14
-rw-r--r--quantum/template/template.c84
-rw-r--r--quantum/template/template.h13
9 files changed, 75 insertions, 116 deletions
diff --git a/quantum/template/Makefile b/quantum/template/Makefile
index 87e4c2d2b..3f6d133c9 100644
--- a/quantum/template/Makefile
+++ b/quantum/template/Makefile
@@ -53,20 +53,20 @@ OPT_DEFS += -DBOOTLOADER_SIZE=512
53# Build Options 53# Build Options
54# change yes to no to disable 54# change yes to no to disable
55# 55#
56BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) 56BOOTMAGIC_ENABLE ?= no # Virtual DIP switch configuration(+1000)
57MOUSEKEY_ENABLE = yes # Mouse keys(+4700) 57MOUSEKEY_ENABLE ?= yes # Mouse keys(+4700)
58EXTRAKEY_ENABLE = yes # Audio control and System control(+450) 58EXTRAKEY_ENABLE ?= yes # Audio control and System control(+450)
59CONSOLE_ENABLE = yes # Console for debug(+400) 59CONSOLE_ENABLE ?= yes # Console for debug(+400)
60COMMAND_ENABLE = yes # Commands for debug and configuration 60COMMAND_ENABLE ?= yes # Commands for debug and configuration
61# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE 61# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
62SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend 62SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend
63# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work 63# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
64NKRO_ENABLE = no # USB Nkey Rollover 64NKRO_ENABLE ?= no # USB Nkey Rollover
65BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality on B7 by default 65BACKLIGHT_ENABLE ?= no # Enable keyboard backlight functionality on B7 by default
66MIDI_ENABLE = no # MIDI controls 66MIDI_ENABLE ?= no # MIDI controls
67UNICODE_ENABLE = no # Unicode 67UNICODE_ENABLE ?= no # Unicode
68BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID 68BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID
69AUDIO_ENABLE = no # Audio output on port C6 69AUDIO_ENABLE ?= no # Audio output on port C6
70 70
71ifndef QUANTUM_DIR 71ifndef QUANTUM_DIR
72 include ../../Makefile 72 include ../../Makefile
diff --git a/quantum/template/config.h b/quantum/template/config.h
index cad3e3260..b02f0c7eb 100644
--- a/quantum/template/config.h
+++ b/quantum/template/config.h
@@ -48,6 +48,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
48 48
49/* COL2ROW or ROW2COL */ 49/* COL2ROW or ROW2COL */
50#define DIODE_DIRECTION COL2ROW 50#define DIODE_DIRECTION COL2ROW
51
52// #define BACKLIGHT_PIN B7
53// #define BACKLIGHT_BREATHING
54// #define BACKLIGHT_LEVELS 3
55
51 56
52/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ 57/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
53#define DEBOUNCING_DELAY 5 58#define DEBOUNCING_DELAY 5
@@ -56,7 +61,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
56//#define MATRIX_HAS_GHOST 61//#define MATRIX_HAS_GHOST
57 62
58/* number of backlight levels */ 63/* number of backlight levels */
59#define BACKLIGHT_LEVELS 3
60 64
61/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ 65/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
62#define LOCKING_SUPPORT_ENABLE 66#define LOCKING_SUPPORT_ENABLE
diff --git a/quantum/template/keymaps/default/Makefile b/quantum/template/keymaps/default/Makefile
new file mode 100644
index 000000000..f4671a9d1
--- /dev/null
+++ b/quantum/template/keymaps/default/Makefile
@@ -0,0 +1,21 @@
1# Build Options
2# change to "no" to disable the options, or define them in the Makefile in
3# the appropriate keymap folder that will get included automatically
4#
5BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
6MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
7EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
8CONSOLE_ENABLE = no # Console for debug(+400)
9COMMAND_ENABLE = yes # Commands for debug and configuration
10NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
11BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
12MIDI_ENABLE = no # MIDI controls
13AUDIO_ENABLE = no # Audio output on port C6
14UNICODE_ENABLE = no # Unicode
15BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
16RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time.
17SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
18
19ifndef QUANTUM_DIR
20 include ../../../../Makefile
21endif \ No newline at end of file
diff --git a/quantum/template/keymaps/default/config.h b/quantum/template/keymaps/default/config.h
new file mode 100644
index 000000000..df06a2620
--- /dev/null
+++ b/quantum/template/keymaps/default/config.h
@@ -0,0 +1,8 @@
1#ifndef CONFIG_USER_H
2#define CONFIG_USER_H
3
4#include "../../config.h"
5
6// place overrides here
7
8#endif \ No newline at end of file
diff --git a/quantum/template/keymaps/default/keymap.c b/quantum/template/keymaps/default/keymap.c
index 4121fd860..e28a4723e 100644
--- a/quantum/template/keymaps/default/keymap.c
+++ b/quantum/template/keymaps/default/keymap.c
@@ -1,6 +1,3 @@
1// This is the canonical layout file for the Quantum project. If you want to add another keyboard,
2// this is the style you want to emulate.
3
4#include "%KEYBOARD%.h" 1#include "%KEYBOARD%.h"
5 2
6const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 3const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
@@ -28,3 +25,20 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
28 } 25 }
29 return MACRO_NONE; 26 return MACRO_NONE;
30}; 27};
28
29
30void matrix_init_user(void) {
31
32}
33
34void matrix_scan_user(void) {
35
36}
37
38bool process_record_user(uint16_t keycode, keyrecord_t *record) {
39 return true;
40}
41
42void led_set_user(uint8_t usb_led) {
43
44} \ No newline at end of file
diff --git a/quantum/template/keymaps/default/readme.md b/quantum/template/keymaps/default/readme.md
new file mode 100644
index 000000000..21aa663d5
--- /dev/null
+++ b/quantum/template/keymaps/default/readme.md
@@ -0,0 +1 @@
# The default keymap for %KEYBOARD% \ No newline at end of file
diff --git a/quantum/template/README.md b/quantum/template/readme.md
index d6b0ac936..b2fb4dd98 100644
--- a/quantum/template/README.md
+++ b/quantum/template/readme.md
@@ -3,7 +3,7 @@
3 3
4## Quantum MK Firmware 4## Quantum MK Firmware
5 5
6For the full Quantum feature list, see [the parent README.md](/doc/README.md). 6For the full Quantum feature list, see [the parent readme.md](/doc/readme.md).
7 7
8## Building 8## Building
9 9
@@ -12,13 +12,17 @@ Download or clone the whole firmware and navigate to the keyboards/%KEYBOARD% fo
12Depending on which keymap you would like to use, you will have to compile slightly differently. 12Depending on which keymap you would like to use, you will have to compile slightly differently.
13 13
14### Default 14### Default
15
15To build with the default keymap, simply run `make`. 16To build with the default keymap, simply run `make`.
16 17
17### Other Keymaps 18### Other Keymaps
18Several version of keymap are available in advance but you are recommended to define your favorite layout yourself. To define your own keymap create file named `<name>.c` in the keymaps folder, and see keymap document (you can find in top README.md) and existent keymap files.
19 19
20To build the firmware binary hex file with a keymap just do `make` with `KEYMAP` option like: 20Several version of keymap are available in advance but you are recommended to define your favorite layout yourself. To define your own keymap create a folder with the name of your keymap in the keymaps folder, and see keymap documentation (you can find in top readme.md) and existant keymap files.
21
22To build the firmware binary hex file with a keymap just do `make` with `keymap` option like:
23
21``` 24```
22$ make KEYMAP=[default|jack|<name>] 25$ make keymap=[default|jack|<name>]
23``` 26```
24Keymaps follow the format **__\<name\>.c__** and are stored in the `keymaps` folder. \ No newline at end of file 27
28Keymaps follow the format **__keymap.c__** and are stored in folders in the `keymaps` folder, eg `keymaps/my_keymap/` \ No newline at end of file
diff --git a/quantum/template/template.c b/quantum/template/template.c
index 649072eb2..dcc4b0a22 100644
--- a/quantum/template/template.c
+++ b/quantum/template/template.c
@@ -1,26 +1,5 @@
1#include "%KEYBOARD%.h" 1#include "%KEYBOARD%.h"
2 2
3__attribute__ ((weak))
4void matrix_init_user(void) {
5 // leave this function blank - it can be defined in a keymap file
6};
7
8__attribute__ ((weak))
9void matrix_scan_user(void) {
10 // leave this function blank - it can be defined in a keymap file
11}
12
13__attribute__ ((weak))
14bool process_action_user(keyrecord_t *record) {
15 // leave this function blank - it can be defined in a keymap file
16 return true;
17}
18
19__attribute__ ((weak))
20void led_set_user(uint8_t usb_led) {
21 // leave this function blank - it can be defined in a keymap file
22}
23
24void matrix_init_kb(void) { 3void matrix_init_kb(void) {
25 // put your keyboard start-up code here 4 // put your keyboard start-up code here
26 // runs once when the firmware starts up 5 // runs once when the firmware starts up
@@ -35,7 +14,7 @@ void matrix_scan_kb(void) {
35 matrix_scan_user(); 14 matrix_scan_user();
36} 15}
37 16
38bool process_action_kb(keyrecord_t *record) { 17bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
39 // put your per-action keyboard code here 18 // put your per-action keyboard code here
40 // runs for every action, just before processing by the firmware 19 // runs for every action, just before processing by the firmware
41 20
@@ -47,64 +26,3 @@ void led_set_kb(uint8_t usb_led) {
47 26
48 led_set_user(usb_led); 27 led_set_user(usb_led);
49} 28}
50
51#ifdef BACKLIGHT_ENABLE
52#define CHANNEL OCR1C
53
54void backlight_init_ports()
55{
56
57 // Setup PB7 as output and output low.
58 DDRB |= (1<<7);
59 PORTB &= ~(1<<7);
60
61 // Use full 16-bit resolution.
62 ICR1 = 0xFFFF;
63
64 // I could write a wall of text here to explain... but TL;DW
65 // Go read the ATmega32u4 datasheet.
66 // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on
67
68 // Pin PB7 = OCR1C (Timer 1, Channel C)
69 // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0
70 // (i.e. start high, go low when counter matches.)
71 // WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0
72 // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1
73
74 TCCR1A = _BV(COM1C1) | _BV(WGM11); // = 0b00001010;
75 TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;
76
77 backlight_init();
78}
79
80void backlight_set(uint8_t level)
81{
82 if ( level == 0 )
83 {
84 // Turn off PWM control on PB7, revert to output low.
85 TCCR1A &= ~(_BV(COM1C1));
86 CHANNEL = 0x0;
87 // Prevent backlight blink on lowest level
88 PORTB &= ~(_BV(PORTB7));
89 }
90 else if ( level == BACKLIGHT_LEVELS )
91 {
92 // Prevent backlight blink on lowest level
93 PORTB &= ~(_BV(PORTB7));
94 // Turn on PWM control of PB7
95 TCCR1A |= _BV(COM1C1);
96 // Set the brightness
97 CHANNEL = 0xFFFF;
98 }
99 else
100 {
101 // Prevent backlight blink on lowest level
102 PORTB &= ~(_BV(PORTB7));
103 // Turn on PWM control of PB7
104 TCCR1A |= _BV(COM1C1);
105 // Set the brightness
106 CHANNEL = 0xFFFF >> ((BACKLIGHT_LEVELS - level) * ((BACKLIGHT_LEVELS + 1) / 2));
107 }
108}
109
110#endif \ No newline at end of file
diff --git a/quantum/template/template.h b/quantum/template/template.h
index b8e7a0456..cd78a54e3 100644
--- a/quantum/template/template.h
+++ b/quantum/template/template.h
@@ -1,13 +1,7 @@
1#ifndef %KEYBOARD_UPPERCASE%_H 1#ifndef %KEYBOARD_UPPERCASE%_H
2#define %KEYBOARD_UPPERCASE%_H 2#define %KEYBOARD_UPPERCASE%_H
3 3
4#include "matrix.h" 4#include "quantum.h"
5#include "keymap.h"
6#ifdef BACKLIGHT_ENABLE
7 #include "backlight.h"
8#endif
9#include <avr/io.h>
10#include <stddef.h>
11 5
12// This a shortcut to help you visually see your layout. 6// This a shortcut to help you visually see your layout.
13// The following is an example using the Planck MIT layout 7// The following is an example using the Planck MIT layout
@@ -22,9 +16,4 @@
22 { k10, KC_NO, k11 }, \ 16 { k10, KC_NO, k11 }, \
23} 17}
24 18
25void matrix_init_user(void);
26void matrix_scan_user(void);
27bool process_action_user(keyrecord_t *record);
28void led_set_user(uint8_t usb_led);
29
30#endif 19#endif