diff options
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/audio/voices.c | 42 | ||||
| -rw-r--r-- | quantum/rgblight.c | 6 | ||||
| -rw-r--r-- | quantum/template/Makefile | 46 | ||||
| -rw-r--r-- | quantum/template/template.c | 61 | ||||
| -rw-r--r-- | quantum/template/template.h | 5 |
5 files changed, 121 insertions, 39 deletions
diff --git a/quantum/audio/voices.c b/quantum/audio/voices.c index 0921bd593..d2316ba1b 100644 --- a/quantum/audio/voices.c +++ b/quantum/audio/voices.c | |||
| @@ -54,28 +54,28 @@ float voice_envelope(float frequency) { | |||
| 54 | } | 54 | } |
| 55 | break; | 55 | break; |
| 56 | 56 | ||
| 57 | case octave_crunch: | 57 | // case octave_crunch: |
| 58 | polyphony_rate = 0; | 58 | // polyphony_rate = 0; |
| 59 | switch (compensated_index) { | 59 | // switch (compensated_index) { |
| 60 | case 0 ... 9: | 60 | // case 0 ... 9: |
| 61 | case 20 ... 24: | 61 | // case 20 ... 24: |
| 62 | case 30 ... 32: | 62 | // case 30 ... 32: |
| 63 | frequency = frequency / 2; | 63 | // frequency = frequency / 2; |
| 64 | note_timbre = TIMBRE_12; | 64 | // note_timbre = TIMBRE_12; |
| 65 | break; | 65 | // break; |
| 66 | 66 | ||
| 67 | case 10 ... 19: | 67 | // case 10 ... 19: |
| 68 | case 25 ... 29: | 68 | // case 25 ... 29: |
| 69 | case 33 ... 35: | 69 | // case 33 ... 35: |
| 70 | frequency = frequency * 2; | 70 | // frequency = frequency * 2; |
| 71 | note_timbre = TIMBRE_12; | 71 | // note_timbre = TIMBRE_12; |
| 72 | break; | 72 | // break; |
| 73 | 73 | ||
| 74 | default: | 74 | // default: |
| 75 | note_timbre = TIMBRE_12; | 75 | // note_timbre = TIMBRE_12; |
| 76 | break; | 76 | // break; |
| 77 | } | 77 | // } |
| 78 | break; | 78 | // break; |
| 79 | 79 | ||
| 80 | case duty_osc: | 80 | case duty_osc: |
| 81 | // This slows the loop down a substantial amount, so higher notes may freeze | 81 | // This slows the loop down a substantial amount, so higher notes may freeze |
diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 5623c65de..8c9ad7736 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c | |||
| @@ -190,7 +190,7 @@ void rgblight_mode(uint8_t mode) { | |||
| 190 | rgblight_config.mode = mode; | 190 | rgblight_config.mode = mode; |
| 191 | } | 191 | } |
| 192 | eeconfig_update_rgblight(rgblight_config.raw); | 192 | eeconfig_update_rgblight(rgblight_config.raw); |
| 193 | dprintf("rgblight mode: %u\n", rgblight_config.mode); | 193 | xprintf("rgblight mode: %u\n", rgblight_config.mode); |
| 194 | if (rgblight_config.mode == 1) { | 194 | if (rgblight_config.mode == 1) { |
| 195 | rgblight_timer_disable(); | 195 | rgblight_timer_disable(); |
| 196 | } else if (rgblight_config.mode >=2 && rgblight_config.mode <=23) { | 196 | } else if (rgblight_config.mode >=2 && rgblight_config.mode <=23) { |
| @@ -207,7 +207,7 @@ void rgblight_mode(uint8_t mode) { | |||
| 207 | void rgblight_toggle(void) { | 207 | void rgblight_toggle(void) { |
| 208 | rgblight_config.enable ^= 1; | 208 | rgblight_config.enable ^= 1; |
| 209 | eeconfig_update_rgblight(rgblight_config.raw); | 209 | eeconfig_update_rgblight(rgblight_config.raw); |
| 210 | dprintf("rgblight toggle: rgblight_config.enable = %u\n", rgblight_config.enable); | 210 | xprintf("rgblight toggle: rgblight_config.enable = %u\n", rgblight_config.enable); |
| 211 | if (rgblight_config.enable) { | 211 | if (rgblight_config.enable) { |
| 212 | rgblight_mode(rgblight_config.mode); | 212 | rgblight_mode(rgblight_config.mode); |
| 213 | } else { | 213 | } else { |
| @@ -300,7 +300,7 @@ void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val){ | |||
| 300 | rgblight_config.sat = sat; | 300 | rgblight_config.sat = sat; |
| 301 | rgblight_config.val = val; | 301 | rgblight_config.val = val; |
| 302 | eeconfig_update_rgblight(rgblight_config.raw); | 302 | eeconfig_update_rgblight(rgblight_config.raw); |
| 303 | dprintf("rgblight set hsv [EEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val); | 303 | xprintf("rgblight set hsv [EEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val); |
| 304 | } | 304 | } |
| 305 | } | 305 | } |
| 306 | 306 | ||
diff --git a/quantum/template/Makefile b/quantum/template/Makefile index 4fa195468..1a535ef2c 100644 --- a/quantum/template/Makefile +++ b/quantum/template/Makefile | |||
| @@ -111,23 +111,41 @@ OPT_DEFS += -DBOOTLOADER_SIZE=512 | |||
| 111 | 111 | ||
| 112 | 112 | ||
| 113 | # Build Options | 113 | # Build Options |
| 114 | # comment out to disable the options. | 114 | # change yes to no to disable |
| 115 | # | 115 | # |
| 116 | BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) | 116 | BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) |
| 117 | MOUSEKEY_ENABLE = yes # Mouse keys(+4700) | 117 | MOUSEKEY_ENABLE = yes # Mouse keys(+4700) |
| 118 | EXTRAKEY_ENABLE = yes # Audio control and System control(+450) | 118 | EXTRAKEY_ENABLE = yes # Audio control and System control(+450) |
| 119 | CONSOLE_ENABLE = yes # Console for debug(+400) | 119 | CONSOLE_ENABLE = yes # Console for debug(+400) |
| 120 | COMMAND_ENABLE = yes # Commands for debug and configuration | 120 | COMMAND_ENABLE = yes # Commands for debug and configuration |
| 121 | KEYBOARD_LOCK_ENABLE = yes # Allow locking of keyboard via magic key | 121 | KEYBOARD_LOCK_ENABLE = yes # Allow locking of keyboard via magic key |
| 122 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | 122 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE |
| 123 | # SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend | 123 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend |
| 124 | #NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | 124 | # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work |
| 125 | # BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality | 125 | NKRO_ENABLE = no # USB Nkey Rollover |
| 126 | # MIDI_ENABLE = YES # MIDI controls | 126 | BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality |
| 127 | # UNICODE_ENABLE = YES # Unicode | 127 | MIDI_ENABLE = no # MIDI controls |
| 128 | # BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID | 128 | UNICODE_ENABLE = no # Unicode |
| 129 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID | ||
| 130 | AUDIO_ENABLE = no # Audio output on port C6 | ||
| 129 | 131 | ||
| 130 | 132 | ||
| 133 | ifdef KEYMAP | ||
| 134 | |||
| 135 | ifeq ("$(wildcard keymaps/$(KEYMAP).c)","") | ||
| 136 | ifneq ("$(wildcard keymaps/$(KEYMAP)/makefile.mk)","") | ||
| 137 | include keymaps/$(KEYMAP)/makefile.mk | ||
| 138 | endif | ||
| 139 | endif | ||
| 140 | |||
| 141 | else | ||
| 142 | |||
| 143 | ifneq ("$(wildcard keymaps/default/makefile.mk)","") | ||
| 144 | include keymaps/default/makefile.mk | ||
| 145 | endif | ||
| 146 | |||
| 147 | endif | ||
| 148 | |||
| 131 | # Optimize size but this may cause error "relocation truncated to fit" | 149 | # Optimize size but this may cause error "relocation truncated to fit" |
| 132 | #EXTRALDFLAGS = -Wl,--relax | 150 | #EXTRALDFLAGS = -Wl,--relax |
| 133 | 151 | ||
diff --git a/quantum/template/template.c b/quantum/template/template.c index cc52e496f..6050a2d20 100644 --- a/quantum/template/template.c +++ b/quantum/template/template.c | |||
| @@ -46,3 +46,64 @@ void led_set_kb(uint8_t usb_led) { | |||
| 46 | 46 | ||
| 47 | led_set_user(usb_led); | 47 | led_set_user(usb_led); |
| 48 | } | 48 | } |
| 49 | |||
| 50 | #ifdef BACKLIGHT_ENABLE | ||
| 51 | #define CHANNEL OCR1C | ||
| 52 | |||
| 53 | void backlight_init_ports() | ||
| 54 | { | ||
| 55 | |||
| 56 | // Setup PB7 as output and output low. | ||
| 57 | DDRB |= (1<<7); | ||
| 58 | PORTB &= ~(1<<7); | ||
| 59 | |||
| 60 | // Use full 16-bit resolution. | ||
| 61 | ICR1 = 0xFFFF; | ||
| 62 | |||
| 63 | // I could write a wall of text here to explain... but TL;DW | ||
| 64 | // Go read the ATmega32u4 datasheet. | ||
| 65 | // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on | ||
| 66 | |||
| 67 | // Pin PB7 = OCR1C (Timer 1, Channel C) | ||
| 68 | // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0 | ||
| 69 | // (i.e. start high, go low when counter matches.) | ||
| 70 | // WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0 | ||
| 71 | // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1 | ||
| 72 | |||
| 73 | TCCR1A = _BV(COM1C1) | _BV(WGM11); // = 0b00001010; | ||
| 74 | TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001; | ||
| 75 | |||
| 76 | backlight_init(); | ||
| 77 | } | ||
| 78 | |||
| 79 | void backlight_set(uint8_t level) | ||
| 80 | { | ||
| 81 | if ( level == 0 ) | ||
| 82 | { | ||
| 83 | // Turn off PWM control on PB7, revert to output low. | ||
| 84 | TCCR1A &= ~(_BV(COM1C1)); | ||
| 85 | CHANNEL = 0x0; | ||
| 86 | // Prevent backlight blink on lowest level | ||
| 87 | PORTB &= ~(_BV(PORTB7)); | ||
| 88 | } | ||
| 89 | else if ( level == BACKLIGHT_LEVELS ) | ||
| 90 | { | ||
| 91 | // Prevent backlight blink on lowest level | ||
| 92 | PORTB &= ~(_BV(PORTB7)); | ||
| 93 | // Turn on PWM control of PB7 | ||
| 94 | TCCR1A |= _BV(COM1C1); | ||
| 95 | // Set the brightness | ||
| 96 | CHANNEL = 0xFFFF; | ||
| 97 | } | ||
| 98 | else | ||
| 99 | { | ||
| 100 | // Prevent backlight blink on lowest level | ||
| 101 | PORTB &= ~(_BV(PORTB7)); | ||
| 102 | // Turn on PWM control of PB7 | ||
| 103 | TCCR1A |= _BV(COM1C1); | ||
| 104 | // Set the brightness | ||
| 105 | CHANNEL = 0xFFFF >> ((BACKLIGHT_LEVELS - level) * ((BACKLIGHT_LEVELS + 1) / 2)); | ||
| 106 | } | ||
| 107 | } | ||
| 108 | |||
| 109 | #endif \ No newline at end of file | ||
diff --git a/quantum/template/template.h b/quantum/template/template.h index b1c34d3cb..22742105a 100644 --- a/quantum/template/template.h +++ b/quantum/template/template.h | |||
| @@ -3,7 +3,10 @@ | |||
| 3 | 3 | ||
| 4 | #include "matrix.h" | 4 | #include "matrix.h" |
| 5 | #include "keymap_common.h" | 5 | #include "keymap_common.h" |
| 6 | #include "backlight.h" | 6 | #ifdef BACKLIGHT_ENABLE |
| 7 | #include "backlight.h" | ||
| 8 | #endif | ||
| 9 | #include <avr/io.h> | ||
| 7 | #include <stddef.h> | 10 | #include <stddef.h> |
| 8 | 11 | ||
| 9 | // This a shortcut to help you visually see your layout. | 12 | // This a shortcut to help you visually see your layout. |
