X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=quantum%2Fquantum.c;h=b9934aee8faeb906f9f8e581200108539d802a8b;hb=ffa119941cac14d6e81853da670f8223823112c3;hp=88617412c9c7b7de8d09b04c3fdf0fbb3975e425;hpb=4931510ad38aadb1769c9241bfad0c3d77ad687f;p=qmk_firmware.git diff --git a/quantum/quantum.c b/quantum/quantum.c index 88617412c..b9934aee8 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -34,6 +34,14 @@ extern backlight_config_t backlight_config; #include "fauxclicky.h" #endif +#ifdef API_ENABLE +#include "api.h" +#endif + +#ifdef MIDI_ENABLE +#include "process_midi.h" +#endif + #ifdef AUDIO_ENABLE #ifndef GOODBYE_SONG #define GOODBYE_SONG SONG(GOODBYE_SOUND) @@ -138,13 +146,13 @@ void reset_keyboard(void) { clear_keyboard(); #if defined(MIDI_ENABLE) && defined(MIDI_BASIC) process_midi_all_notes_off(); -#endif -#if defined(AUDIO_ENABLE) +#endif +#if defined(AUDIO_ENABLE) && !defined(NO_MUSIC_MODE) music_all_notes_off(); uint16_t timer_start = timer_read(); PLAY_SONG(goodbye_song); shutdown_user(); - while(timer_elapsed(timer_start) < 250) + while(timer_elapsed(timer_start) < 250) wait_ms(1); stop_all_notes(); #else @@ -209,12 +217,22 @@ bool process_record_quantum(keyrecord_t *record) { // return false; // } + #ifdef TAP_DANCE_ENABLE + preprocess_tap_dance(keycode, record); + #endif + if (!( #if defined(KEY_LOCK_ENABLE) // Must run first to be able to mask key_up events. process_key_lock(&keycode, record) && #endif + #if defined(AUDIO_ENABLE) && defined(AUDIO_CLICKY) + process_clicky(keycode, record) && + #endif //AUDIO_CLICKY process_record_kb(keycode, record) && + #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_KEYPRESSES) + process_rgb_matrix(keycode, record) && + #endif #if defined(MIDI_ENABLE) && defined(MIDI_ADVANCED) process_midi(keycode, record) && #endif @@ -224,7 +242,7 @@ bool process_record_quantum(keyrecord_t *record) { #ifdef STENO_ENABLE process_steno(keycode, record) && #endif - #if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC)) + #if ( defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))) && !defined(NO_MUSIC_MODE) process_music(keycode, record) && #endif #ifdef TAP_DANCE_ENABLE @@ -292,7 +310,7 @@ bool process_record_quantum(keyrecord_t *record) { } return false; #endif - #ifdef RGBLIGHT_ENABLE + #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) case RGB_TOG: if (record->event.pressed) { rgblight_toggle(); @@ -350,6 +368,16 @@ bool process_record_quantum(keyrecord_t *record) { rgblight_decrease_val(); } return false; + case RGB_SPI: + if (record->event.pressed) { + rgblight_increase_speed(); + } + return false; + case RGB_SPD: + if (record->event.pressed) { + rgblight_decrease_speed(); + } + return false; case RGB_MODE_PLAIN: if (record->event.pressed) { rgblight_mode(1); @@ -414,7 +442,12 @@ bool process_record_quantum(keyrecord_t *record) { } } return false; - #endif + case RGB_MODE_RGBTEST: + if (record->event.pressed) { + rgblight_mode(35); + } + return false; + #endif // defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) #ifdef PROTOCOL_LUFA case OUT_AUTO: if (record->event.pressed) { @@ -765,12 +798,14 @@ void set_single_persistent_default_layer(uint8_t default_layer) { default_layer_set(1U<> ((BACKLIGHT_LEVELS - get_backlight_level()) * ((BACKLIGHT_LEVELS + 1) / 2))) & (1 << backlight_tick)) { #if BACKLIGHT_ON_STATE == 0 @@ -903,11 +970,14 @@ void backlight_task(void) { _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF); #endif } - backlight_tick = backlight_tick + 1 % 16; + backlight_tick = (backlight_tick + 1) % 16; } +#endif #ifdef BACKLIGHT_BREATHING -#error "Backlight breathing only available with hardware PWM. Please disable." + #ifndef BACKLIGHT_CUSTOM_DRIVER + #error "Backlight breathing only available with hardware PWM. Please disable." + #endif #endif #else // pwm through timer @@ -932,9 +1002,10 @@ static uint16_t cie_lightness(uint16_t v) { // range for val is [0..TIMER_TOP]. PWM pin is high while the timer count is below val. static inline void set_pwm(uint16_t val) { - OCR1x = val; + OCRxx = val; } +#ifndef BACKLIGHT_CUSTOM_DRIVER __attribute__ ((weak)) void backlight_set(uint8_t level) { if (level > BACKLIGHT_LEVELS) @@ -942,16 +1013,17 @@ void backlight_set(uint8_t level) { if (level == 0) { // Turn off PWM control on backlight pin - TCCR1A &= ~(_BV(COM1x1)); + TCCRxA &= ~(_BV(COMxx1)); } else { // Turn on PWM control of backlight pin - TCCR1A |= _BV(COM1x1); + TCCRxA |= _BV(COMxx1); } // Set the brightness set_pwm(cie_lightness(TIMER_TOP * (uint32_t)level / BACKLIGHT_LEVELS)); } void backlight_task(void) {} +#endif // BACKLIGHT_CUSTOM_DRIVER #ifdef BACKLIGHT_BREATHING @@ -1092,11 +1164,10 @@ void backlight_init_ports(void) "In fast PWM mode, the compare units allow generation of PWM waveforms on the OCnx pins. Setting the COMnx1:0 bits to two will produce a non-inverted PWM [..]." "In fast PWM mode the counter is incremented until the counter value matches either one of the fixed values 0x00FF, 0x01FF, or 0x03FF (WGMn3:0 = 5, 6, or 7), the value in ICRn (WGMn3:0 = 14), or the value in OCRnA (WGMn3:0 = 15)." */ - - TCCR1A = _BV(COM1x1) | _BV(WGM11); // = 0b00001010; - TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001; + TCCRxA = _BV(COMxx1) | _BV(WGM11); // = 0b00001010; + TCCRxB = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001; // Use full 16-bit resolution. Counter counts to ICR1 before reset to 0. - ICR1 = TIMER_TOP; + ICRx = TIMER_TOP; backlight_init(); #ifdef BACKLIGHT_BREATHING