aboutsummaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
Diffstat (limited to 'quantum')
-rw-r--r--quantum/audio/song_list.h27
-rw-r--r--quantum/quantum.c67
-rw-r--r--quantum/quantum.h1
-rw-r--r--quantum/quantum_keycodes.h3
4 files changed, 73 insertions, 25 deletions
diff --git a/quantum/audio/song_list.h b/quantum/audio/song_list.h
index 8022ca672..400915db9 100644
--- a/quantum/audio/song_list.h
+++ b/quantum/audio/song_list.h
@@ -122,4 +122,31 @@
122 E__NOTE(_E5), \ 122 E__NOTE(_E5), \
123 E__NOTE(_D5), 123 E__NOTE(_D5),
124 124
125#define COIN_SOUND \
126 E__NOTE(_A5 ), \
127 HD_NOTE(_E6 ),
128
129#define ONE_UP_SOUND \
130 Q__NOTE(_E6 ), \
131 Q__NOTE(_G6 ), \
132 Q__NOTE(_E7 ), \
133 Q__NOTE(_C7 ), \
134 Q__NOTE(_D7 ), \
135 Q__NOTE(_G7 ),
136
137#define SONIC_RING \
138 E__NOTE(_E6), \
139 E__NOTE(_G6), \
140 HD_NOTE(_C7),
141
142#define ZELDA_PUZZLE \
143 Q__NOTE(_G5), \
144 Q__NOTE(_FS5), \
145 Q__NOTE(_DS5), \
146 Q__NOTE(_A4), \
147 Q__NOTE(_GS4), \
148 Q__NOTE(_E5), \
149 Q__NOTE(_GS5), \
150 HD_NOTE(_C6),
151
125#endif 152#endif
diff --git a/quantum/quantum.c b/quantum/quantum.c
index 4a6d0355f..807a7084a 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
@@ -291,14 +294,6 @@ bool process_record_quantum(keyrecord_t *record) {
291 return false; 294 return false;
292 break; 295 break;
293 #endif 296 #endif
294 #ifdef ADAFRUIT_BLE_ENABLE
295 case OUT_BLE:
296 if (record->event.pressed) {
297 set_output(OUTPUT_ADAFRUIT_BLE);
298 }
299 return false;
300 break;
301 #endif
302 #endif 297 #endif
303 case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_NKRO: 298 case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_NKRO:
304 if (record->event.pressed) { 299 if (record->event.pressed) {
@@ -601,6 +596,10 @@ void matrix_scan_quantum() {
601 matrix_scan_combo(); 596 matrix_scan_combo();
602 #endif 597 #endif
603 598
599 #if defined(BACKLIGHT_ENABLE) && defined(BACKLIGHT_PIN)
600 backlight_task();
601 #endif
602
604 matrix_scan_kb(); 603 matrix_scan_kb();
605} 604}
606 605
@@ -668,13 +667,13 @@ __attribute__ ((weak))
668void backlight_set(uint8_t level) 667void backlight_set(uint8_t level)
669{ 668{
670 // Prevent backlight blink on lowest level 669 // Prevent backlight blink on lowest level
671 #if BACKLIGHT_ON_STATE == 0 670 // #if BACKLIGHT_ON_STATE == 0
672 // PORTx &= ~n 671 // // PORTx &= ~n
673 _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF); 672 // _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF);
674 #else 673 // #else
675 // PORTx |= n 674 // // PORTx |= n
676 _SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF); 675 // _SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF);
677 #endif 676 // #endif
678 677
679 if ( level == 0 ) { 678 if ( level == 0 ) {
680 #ifndef NO_BACKLIGHT_CLOCK 679 #ifndef NO_BACKLIGHT_CLOCK
@@ -682,13 +681,13 @@ void backlight_set(uint8_t level)
682 TCCR1A &= ~(_BV(COM1x1)); 681 TCCR1A &= ~(_BV(COM1x1));
683 OCR1x = 0x0; 682 OCR1x = 0x0;
684 #else 683 #else
685 #if BACKLIGHT_ON_STATE == 0 684 // #if BACKLIGHT_ON_STATE == 0
686 // PORTx |= n 685 // // PORTx |= n
687 _SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF); 686 // _SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF);
688 #else 687 // #else
689 // PORTx &= ~n 688 // // PORTx &= ~n
690 _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF); 689 // _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF);
691 #endif 690 // #endif
692 #endif 691 #endif
693 } 692 }
694 #ifndef NO_BACKLIGHT_CLOCK 693 #ifndef NO_BACKLIGHT_CLOCK
@@ -711,6 +710,30 @@ void backlight_set(uint8_t level)
711 #endif 710 #endif
712} 711}
713 712
713uint8_t backlight_tick = 0;
714
715void backlight_task(void) {
716 #ifdef NO_BACKLIGHT_CLOCK
717 if ((0xFFFF >> ((BACKLIGHT_LEVELS - backlight_config.level) * ((BACKLIGHT_LEVELS + 1) / 2))) & (1 << backlight_tick)) {
718 #if BACKLIGHT_ON_STATE == 0
719 // PORTx &= ~n
720 _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF);
721 #else
722 // PORTx |= n
723 _SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF);
724 #endif
725 } else {
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 }
734 backlight_tick = (backlight_tick + 1) % 16;
735 #endif
736}
714 737
715#ifdef BACKLIGHT_BREATHING 738#ifdef BACKLIGHT_BREATHING
716 739
diff --git a/quantum/quantum.h b/quantum/quantum.h
index 580d51202..259bac369 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);
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h
index 903d57f1e..78b02a0de 100644
--- a/quantum/quantum_keycodes.h
+++ b/quantum/quantum_keycodes.h
@@ -159,9 +159,6 @@ enum quantum_keycodes {
159#ifdef BLUETOOTH_ENABLE 159#ifdef BLUETOOTH_ENABLE
160 OUT_BT, 160 OUT_BT,
161#endif 161#endif
162#ifdef ADAFRUIT_BLE_ENABLE
163 OUT_BLE,
164#endif
165 162
166 // always leave at the end 163 // always leave at the end
167 SAFE_RANGE 164 SAFE_RANGE