diff options
Diffstat (limited to 'quantum/template')
| -rw-r--r-- | quantum/template/Makefile | 24 | ||||
| -rw-r--r-- | quantum/template/config.h | 6 | ||||
| -rw-r--r-- | quantum/template/keymaps/default/Makefile | 21 | ||||
| -rw-r--r-- | quantum/template/keymaps/default/config.h | 8 | ||||
| -rw-r--r-- | quantum/template/keymaps/default/keymap.c | 20 | ||||
| -rw-r--r-- | quantum/template/keymaps/default/readme.md | 1 | ||||
| -rw-r--r-- | quantum/template/readme.md (renamed from quantum/template/README.md) | 14 | ||||
| -rw-r--r-- | quantum/template/template.c | 84 | ||||
| -rw-r--r-- | quantum/template/template.h | 13 |
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 | # |
| 56 | BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) | 56 | BOOTMAGIC_ENABLE ?= no # Virtual DIP switch configuration(+1000) |
| 57 | MOUSEKEY_ENABLE = yes # Mouse keys(+4700) | 57 | MOUSEKEY_ENABLE ?= yes # Mouse keys(+4700) |
| 58 | EXTRAKEY_ENABLE = yes # Audio control and System control(+450) | 58 | EXTRAKEY_ENABLE ?= yes # Audio control and System control(+450) |
| 59 | CONSOLE_ENABLE = yes # Console for debug(+400) | 59 | CONSOLE_ENABLE ?= yes # Console for debug(+400) |
| 60 | COMMAND_ENABLE = yes # Commands for debug and configuration | 60 | COMMAND_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 |
| 62 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | 62 | SLEEP_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 |
| 64 | NKRO_ENABLE = no # USB Nkey Rollover | 64 | NKRO_ENABLE ?= no # USB Nkey Rollover |
| 65 | BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality on B7 by default | 65 | BACKLIGHT_ENABLE ?= no # Enable keyboard backlight functionality on B7 by default |
| 66 | MIDI_ENABLE = no # MIDI controls | 66 | MIDI_ENABLE ?= no # MIDI controls |
| 67 | UNICODE_ENABLE = no # Unicode | 67 | UNICODE_ENABLE ?= no # Unicode |
| 68 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID | 68 | BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID |
| 69 | AUDIO_ENABLE = no # Audio output on port C6 | 69 | AUDIO_ENABLE ?= no # Audio output on port C6 |
| 70 | 70 | ||
| 71 | ifndef QUANTUM_DIR | 71 | ifndef 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 | # | ||
| 5 | BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) | ||
| 6 | MOUSEKEY_ENABLE = yes # Mouse keys(+4700) | ||
| 7 | EXTRAKEY_ENABLE = yes # Audio control and System control(+450) | ||
| 8 | CONSOLE_ENABLE = no # Console for debug(+400) | ||
| 9 | COMMAND_ENABLE = yes # Commands for debug and configuration | ||
| 10 | NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | ||
| 11 | BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality | ||
| 12 | MIDI_ENABLE = no # MIDI controls | ||
| 13 | AUDIO_ENABLE = no # Audio output on port C6 | ||
| 14 | UNICODE_ENABLE = no # Unicode | ||
| 15 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID | ||
| 16 | RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. | ||
| 17 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | ||
| 18 | |||
| 19 | ifndef QUANTUM_DIR | ||
| 20 | include ../../../../Makefile | ||
| 21 | endif \ 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 | ||
| 6 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | 3 | const 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 | |||
| 30 | void matrix_init_user(void) { | ||
| 31 | |||
| 32 | } | ||
| 33 | |||
| 34 | void matrix_scan_user(void) { | ||
| 35 | |||
| 36 | } | ||
| 37 | |||
| 38 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 39 | return true; | ||
| 40 | } | ||
| 41 | |||
| 42 | void 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 | ||
| 6 | For the full Quantum feature list, see [the parent README.md](/doc/README.md). | 6 | For 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 | |||
| 12 | Depending on which keymap you would like to use, you will have to compile slightly differently. | 12 | Depending on which keymap you would like to use, you will have to compile slightly differently. |
| 13 | 13 | ||
| 14 | ### Default | 14 | ### Default |
| 15 | |||
| 15 | To build with the default keymap, simply run `make`. | 16 | To build with the default keymap, simply run `make`. |
| 16 | 17 | ||
| 17 | ### Other Keymaps | 18 | ### Other Keymaps |
| 18 | Several 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 | ||
| 20 | To build the firmware binary hex file with a keymap just do `make` with `KEYMAP` option like: | 20 | Several 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 | |||
| 22 | To 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 | ``` |
| 24 | Keymaps follow the format **__\<name\>.c__** and are stored in the `keymaps` folder. \ No newline at end of file | 27 | |
| 28 | Keymaps 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)) | ||
| 4 | void matrix_init_user(void) { | ||
| 5 | // leave this function blank - it can be defined in a keymap file | ||
| 6 | }; | ||
| 7 | |||
| 8 | __attribute__ ((weak)) | ||
| 9 | void matrix_scan_user(void) { | ||
| 10 | // leave this function blank - it can be defined in a keymap file | ||
| 11 | } | ||
| 12 | |||
| 13 | __attribute__ ((weak)) | ||
| 14 | bool 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)) | ||
| 20 | void led_set_user(uint8_t usb_led) { | ||
| 21 | // leave this function blank - it can be defined in a keymap file | ||
| 22 | } | ||
| 23 | |||
| 24 | void matrix_init_kb(void) { | 3 | void 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 | ||
| 38 | bool process_action_kb(keyrecord_t *record) { | 17 | bool 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 | |||
| 54 | void 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 | |||
| 80 | void 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 | ||
| 25 | void matrix_init_user(void); | ||
| 26 | void matrix_scan_user(void); | ||
| 27 | bool process_action_user(keyrecord_t *record); | ||
| 28 | void led_set_user(uint8_t usb_led); | ||
| 29 | |||
| 30 | #endif | 19 | #endif |
