diff options
| -rw-r--r-- | keyboards/planck/rules.mk | 4 | ||||
| -rw-r--r-- | keyboards/preonic/rules.mk | 4 | ||||
| -rw-r--r-- | quantum/quantum.c | 59 | ||||
| -rw-r--r-- | quantum/quantum.h | 1 |
4 files changed, 50 insertions, 18 deletions
diff --git a/keyboards/planck/rules.mk b/keyboards/planck/rules.mk index 4423d422f6..6776062f6d 100644 --- a/keyboards/planck/rules.mk +++ b/keyboards/planck/rules.mk | |||
| @@ -56,13 +56,13 @@ EXTRAKEY_ENABLE ?= yes # Audio control and System control(+450) | |||
| 56 | CONSOLE_ENABLE ?= no # Console for debug(+400) | 56 | CONSOLE_ENABLE ?= no # Console for debug(+400) |
| 57 | COMMAND_ENABLE ?= no # Commands for debug and configuration | 57 | COMMAND_ENABLE ?= no # Commands for debug and configuration |
| 58 | NKRO_ENABLE ?= no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | 58 | NKRO_ENABLE ?= no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work |
| 59 | BACKLIGHT_ENABLE ?= no # Enable keyboard backlight functionality | 59 | BACKLIGHT_ENABLE ?= yes # Enable keyboard backlight functionality |
| 60 | MIDI_ENABLE ?= yes # MIDI controls | 60 | MIDI_ENABLE ?= yes # MIDI controls |
| 61 | AUDIO_ENABLE ?= yes # Audio output on port C6 | 61 | AUDIO_ENABLE ?= yes # Audio output on port C6 |
| 62 | UNICODE_ENABLE ?= no # Unicode | 62 | UNICODE_ENABLE ?= no # Unicode |
| 63 | BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID | 63 | BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID |
| 64 | RGBLIGHT_ENABLE ?= no # Enable WS2812 RGB underlight. | 64 | RGBLIGHT_ENABLE ?= no # Enable WS2812 RGB underlight. |
| 65 | API_SYSEX_ENABLE = yes | 65 | API_SYSEX_ENABLE = no |
| 66 | 66 | ||
| 67 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | 67 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE |
| 68 | SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend | 68 | SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend |
diff --git a/keyboards/preonic/rules.mk b/keyboards/preonic/rules.mk index 62473e3564..6be5b55bcd 100644 --- a/keyboards/preonic/rules.mk +++ b/keyboards/preonic/rules.mk | |||
| @@ -58,13 +58,13 @@ EXTRAKEY_ENABLE ?= yes # Audio control and System control(+450) | |||
| 58 | CONSOLE_ENABLE ?= no # Console for debug(+400) | 58 | CONSOLE_ENABLE ?= no # Console for debug(+400) |
| 59 | COMMAND_ENABLE ?= no # Commands for debug and configuration | 59 | COMMAND_ENABLE ?= no # Commands for debug and configuration |
| 60 | NKRO_ENABLE ?= no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | 60 | NKRO_ENABLE ?= no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work |
| 61 | BACKLIGHT_ENABLE ?= no # Enable keyboard backlight functionality | 61 | BACKLIGHT_ENABLE ?= yes # Enable keyboard backlight functionality |
| 62 | MIDI_ENABLE ?= yes # MIDI controls | 62 | MIDI_ENABLE ?= yes # MIDI controls |
| 63 | AUDIO_ENABLE ?= yes # Audio output on port C6 | 63 | AUDIO_ENABLE ?= yes # Audio output on port C6 |
| 64 | UNICODE_ENABLE ?= no # Unicode | 64 | UNICODE_ENABLE ?= no # Unicode |
| 65 | BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID | 65 | BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID |
| 66 | RGBLIGHT_ENABLE ?= no # Enable WS2812 RGB underlight. | 66 | RGBLIGHT_ENABLE ?= no # Enable WS2812 RGB underlight. |
| 67 | API_SYSEX_ENABLE ?= yes | 67 | API_SYSEX_ENABLE ?= no |
| 68 | 68 | ||
| 69 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | 69 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE |
| 70 | SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend \ No newline at end of file | 70 | SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend \ No newline at end of file |
diff --git a/quantum/quantum.c b/quantum/quantum.c index 4a6d0355fa..582f8920b1 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
| @@ -7,6 +7,9 @@ | |||
| 7 | #define TAPPING_TERM 200 | 7 | #define TAPPING_TERM 200 |
| 8 | #endif | 8 | #endif |
| 9 | 9 | ||
| 10 | #include "backlight.h" | ||
| 11 | extern backlight_config_t backlight_config; | ||
| 12 | |||
| 10 | #ifdef FAUXCLICKY_ENABLE | 13 | #ifdef FAUXCLICKY_ENABLE |
| 11 | #include "fauxclicky.h" | 14 | #include "fauxclicky.h" |
| 12 | #endif | 15 | #endif |
| @@ -601,6 +604,10 @@ void matrix_scan_quantum() { | |||
| 601 | matrix_scan_combo(); | 604 | matrix_scan_combo(); |
| 602 | #endif | 605 | #endif |
| 603 | 606 | ||
| 607 | #if defined(BACKLIGHT_ENABLE) && defined(BACKLIGHT_PIN) | ||
| 608 | backlight_task(); | ||
| 609 | #endif | ||
| 610 | |||
| 604 | matrix_scan_kb(); | 611 | matrix_scan_kb(); |
| 605 | } | 612 | } |
| 606 | 613 | ||
| @@ -668,13 +675,13 @@ __attribute__ ((weak)) | |||
| 668 | void backlight_set(uint8_t level) | 675 | void backlight_set(uint8_t level) |
| 669 | { | 676 | { |
| 670 | // Prevent backlight blink on lowest level | 677 | // Prevent backlight blink on lowest level |
| 671 | #if BACKLIGHT_ON_STATE == 0 | 678 | // #if BACKLIGHT_ON_STATE == 0 |
| 672 | // PORTx &= ~n | 679 | // // PORTx &= ~n |
| 673 | _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF); | 680 | // _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF); |
| 674 | #else | 681 | // #else |
| 675 | // PORTx |= n | 682 | // // PORTx |= n |
| 676 | _SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF); | 683 | // _SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF); |
| 677 | #endif | 684 | // #endif |
| 678 | 685 | ||
| 679 | if ( level == 0 ) { | 686 | if ( level == 0 ) { |
| 680 | #ifndef NO_BACKLIGHT_CLOCK | 687 | #ifndef NO_BACKLIGHT_CLOCK |
| @@ -682,13 +689,13 @@ void backlight_set(uint8_t level) | |||
| 682 | TCCR1A &= ~(_BV(COM1x1)); | 689 | TCCR1A &= ~(_BV(COM1x1)); |
| 683 | OCR1x = 0x0; | 690 | OCR1x = 0x0; |
| 684 | #else | 691 | #else |
| 685 | #if BACKLIGHT_ON_STATE == 0 | 692 | // #if BACKLIGHT_ON_STATE == 0 |
| 686 | // PORTx |= n | 693 | // // PORTx |= n |
| 687 | _SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF); | 694 | // _SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF); |
| 688 | #else | 695 | // #else |
| 689 | // PORTx &= ~n | 696 | // // PORTx &= ~n |
| 690 | _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF); | 697 | // _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF); |
| 691 | #endif | 698 | // #endif |
| 692 | #endif | 699 | #endif |
| 693 | } | 700 | } |
| 694 | #ifndef NO_BACKLIGHT_CLOCK | 701 | #ifndef NO_BACKLIGHT_CLOCK |
| @@ -711,6 +718,30 @@ void backlight_set(uint8_t level) | |||
| 711 | #endif | 718 | #endif |
| 712 | } | 719 | } |
| 713 | 720 | ||
| 721 | uint8_t backlight_tick = 0; | ||
| 722 | |||
| 723 | void backlight_task(void) { | ||
| 724 | #ifdef NO_BACKLIGHT_CLOCK | ||
| 725 | if ((0xFFFF >> ((BACKLIGHT_LEVELS - backlight_config.level) * ((BACKLIGHT_LEVELS + 1) / 2))) & (1 << backlight_tick)) { | ||
| 726 | #if BACKLIGHT_ON_STATE == 0 | ||
| 727 | // PORTx &= ~n | ||
| 728 | _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF); | ||
| 729 | #else | ||
| 730 | // PORTx |= n | ||
| 731 | _SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF); | ||
| 732 | #endif | ||
| 733 | } else { | ||
| 734 | #if BACKLIGHT_ON_STATE == 0 | ||
| 735 | // PORTx |= n | ||
| 736 | _SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF); | ||
| 737 | #else | ||
| 738 | // PORTx &= ~n | ||
| 739 | _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF); | ||
| 740 | #endif | ||
| 741 | } | ||
| 742 | backlight_tick = (backlight_tick + 1) % 16; | ||
| 743 | #endif | ||
| 744 | } | ||
| 714 | 745 | ||
| 715 | #ifdef BACKLIGHT_BREATHING | 746 | #ifdef BACKLIGHT_BREATHING |
| 716 | 747 | ||
diff --git a/quantum/quantum.h b/quantum/quantum.h index 580d51202a..259bac3697 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h | |||
| @@ -103,6 +103,7 @@ void unregister_code16 (uint16_t code); | |||
| 103 | 103 | ||
| 104 | #ifdef BACKLIGHT_ENABLE | 104 | #ifdef BACKLIGHT_ENABLE |
| 105 | void backlight_init_ports(void); | 105 | void backlight_init_ports(void); |
| 106 | void backlight_task(void); | ||
| 106 | 107 | ||
| 107 | #ifdef BACKLIGHT_BREATHING | 108 | #ifdef BACKLIGHT_BREATHING |
| 108 | void breathing_enable(void); | 109 | void breathing_enable(void); |
