summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--keyboards/planck/rules.mk4
-rw-r--r--keyboards/preonic/rules.mk4
-rw-r--r--quantum/quantum.c59
-rw-r--r--quantum/quantum.h1
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)
56CONSOLE_ENABLE ?= no # Console for debug(+400) 56CONSOLE_ENABLE ?= no # Console for debug(+400)
57COMMAND_ENABLE ?= no # Commands for debug and configuration 57COMMAND_ENABLE ?= no # Commands for debug and configuration
58NKRO_ENABLE ?= no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work 58NKRO_ENABLE ?= no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
59BACKLIGHT_ENABLE ?= no # Enable keyboard backlight functionality 59BACKLIGHT_ENABLE ?= yes # Enable keyboard backlight functionality
60MIDI_ENABLE ?= yes # MIDI controls 60MIDI_ENABLE ?= yes # MIDI controls
61AUDIO_ENABLE ?= yes # Audio output on port C6 61AUDIO_ENABLE ?= yes # Audio output on port C6
62UNICODE_ENABLE ?= no # Unicode 62UNICODE_ENABLE ?= no # Unicode
63BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID 63BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID
64RGBLIGHT_ENABLE ?= no # Enable WS2812 RGB underlight. 64RGBLIGHT_ENABLE ?= no # Enable WS2812 RGB underlight.
65API_SYSEX_ENABLE = yes 65API_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
68SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend 68SLEEP_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)
58CONSOLE_ENABLE ?= no # Console for debug(+400) 58CONSOLE_ENABLE ?= no # Console for debug(+400)
59COMMAND_ENABLE ?= no # Commands for debug and configuration 59COMMAND_ENABLE ?= no # Commands for debug and configuration
60NKRO_ENABLE ?= no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work 60NKRO_ENABLE ?= no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
61BACKLIGHT_ENABLE ?= no # Enable keyboard backlight functionality 61BACKLIGHT_ENABLE ?= yes # Enable keyboard backlight functionality
62MIDI_ENABLE ?= yes # MIDI controls 62MIDI_ENABLE ?= yes # MIDI controls
63AUDIO_ENABLE ?= yes # Audio output on port C6 63AUDIO_ENABLE ?= yes # Audio output on port C6
64UNICODE_ENABLE ?= no # Unicode 64UNICODE_ENABLE ?= no # Unicode
65BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID 65BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID
66RGBLIGHT_ENABLE ?= no # Enable WS2812 RGB underlight. 66RGBLIGHT_ENABLE ?= no # Enable WS2812 RGB underlight.
67API_SYSEX_ENABLE ?= yes 67API_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
70SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend \ No newline at end of file 70SLEEP_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"
11extern 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))
668void backlight_set(uint8_t level) 675void 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
721uint8_t backlight_tick = 0;
722
723void 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
105void backlight_init_ports(void); 105void backlight_init_ports(void);
106void backlight_task(void);
106 107
107#ifdef BACKLIGHT_BREATHING 108#ifdef BACKLIGHT_BREATHING
108void breathing_enable(void); 109void breathing_enable(void);