]> git.donarmstrong.com Git - qmk_firmware.git/blobdiff - quantum/quantum.c
Keyboard: fixed build break (size overflow) HelixPico with Backlight or Underglow...
[qmk_firmware.git] / quantum / quantum.c
index e1bc8b242eba51079dc12e0bc7d4827cabf4931b..9c6ed3330e5a068134ea428df41161782d4359ce 100644 (file)
@@ -312,8 +312,16 @@ bool process_record_quantum(keyrecord_t *record) {
   #endif
   #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
   case RGB_TOG:
+    // Split keyboards need to trigger on key-up for edge-case issue
+    #ifndef SPLIT_KEYBOARD
     if (record->event.pressed) {
+    #else
+    if (!record->event.pressed) {
+    #endif
       rgblight_toggle();
+      #ifdef SPLIT_KEYBOARD
+          RGB_DIRTY = true;
+      #endif
     }
     return false;
   case RGB_MODE_FORWARD:
@@ -325,6 +333,9 @@ bool process_record_quantum(keyrecord_t *record) {
       else {
         rgblight_step();
       }
+      #ifdef SPLIT_KEYBOARD
+          RGB_DIRTY = true;
+      #endif
     }
     return false;
   case RGB_MODE_REVERSE:
@@ -336,41 +347,105 @@ bool process_record_quantum(keyrecord_t *record) {
       else {
         rgblight_step_reverse();
       }
+      #ifdef SPLIT_KEYBOARD
+          RGB_DIRTY = true;
+      #endif
     }
     return false;
   case RGB_HUI:
+    // Split keyboards need to trigger on key-up for edge-case issue
+    #ifndef SPLIT_KEYBOARD
     if (record->event.pressed) {
+    #else
+    if (!record->event.pressed) {
+    #endif
       rgblight_increase_hue();
+      #ifdef SPLIT_KEYBOARD
+          RGB_DIRTY = true;
+      #endif
     }
     return false;
   case RGB_HUD:
+    // Split keyboards need to trigger on key-up for edge-case issue
+    #ifndef SPLIT_KEYBOARD
     if (record->event.pressed) {
+    #else
+    if (!record->event.pressed) {
+    #endif
       rgblight_decrease_hue();
+      #ifdef SPLIT_KEYBOARD
+          RGB_DIRTY = true;
+      #endif
     }
     return false;
   case RGB_SAI:
+    // Split keyboards need to trigger on key-up for edge-case issue
+    #ifndef SPLIT_KEYBOARD
     if (record->event.pressed) {
+    #else
+    if (!record->event.pressed) {
+    #endif
       rgblight_increase_sat();
+      #ifdef SPLIT_KEYBOARD
+          RGB_DIRTY = true;
+      #endif
     }
     return false;
   case RGB_SAD:
+    // Split keyboards need to trigger on key-up for edge-case issue
+    #ifndef SPLIT_KEYBOARD
     if (record->event.pressed) {
+    #else
+    if (!record->event.pressed) {
+    #endif
       rgblight_decrease_sat();
+      #ifdef SPLIT_KEYBOARD
+          RGB_DIRTY = true;
+      #endif
     }
     return false;
   case RGB_VAI:
+    // Split keyboards need to trigger on key-up for edge-case issue
+    #ifndef SPLIT_KEYBOARD
     if (record->event.pressed) {
+    #else
+    if (!record->event.pressed) {
+    #endif
       rgblight_increase_val();
+      #ifdef SPLIT_KEYBOARD
+          RGB_DIRTY = true;
+      #endif
     }
     return false;
   case RGB_VAD:
+    // Split keyboards need to trigger on key-up for edge-case issue
+    #ifndef SPLIT_KEYBOARD
     if (record->event.pressed) {
+    #else
+    if (!record->event.pressed) {
+    #endif
       rgblight_decrease_val();
+      #ifdef SPLIT_KEYBOARD
+          RGB_DIRTY = true;
+      #endif
+    }
+    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);
+      #ifdef SPLIT_KEYBOARD
+          RGB_DIRTY = true;
+      #endif
     }
     return false;
   case RGB_MODE_BREATHE:
@@ -432,7 +507,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) {
@@ -839,7 +919,7 @@ void matrix_init_quantum() {
     audio_init();
   #endif
   #ifdef RGB_MATRIX_ENABLE
-    rgb_matrix_init_drivers();
+    rgb_matrix_init();
   #endif
   matrix_init_kb();
 }
@@ -883,14 +963,29 @@ static const uint8_t backlight_pin = BACKLIGHT_PIN;
 
 // depending on the pin, we use a different output compare unit
 #if BACKLIGHT_PIN == B7
-#  define COM1x1 COM1C1
-#  define OCR1x  OCR1C
+#  define TCCRxA TCCR1A
+#  define TCCRxB TCCR1B
+#  define COMxx1 COM1C1
+#  define OCRxx  OCR1C
+#  define ICRx   ICR1
 #elif BACKLIGHT_PIN == B6
-#  define COM1x1 COM1B1
-#  define OCR1x  OCR1B
+#  define TCCRxA TCCR1A
+#  define TCCRxB TCCR1B
+#  define COMxx1 COM1B1
+#  define OCRxx  OCR1B
+#  define ICRx   ICR1
 #elif BACKLIGHT_PIN == B5
-#  define COM1x1 COM1A1
-#  define OCR1x  OCR1A
+#  define TCCRxA TCCR1A
+#  define TCCRxB TCCR1B
+#  define COMxx1 COM1A1
+#  define OCRxx  OCR1A
+#  define ICRx   ICR1
+#elif BACKLIGHT_PIN == C6
+#  define TCCRxA TCCR3A
+#  define TCCRxB TCCR3B
+#  define COMxx1 COM1A1
+#  define OCRxx  OCR3A
+#  define ICRx   ICR3
 #else
 #  define NO_HARDWARE_PWM
 #endif
@@ -972,7 +1067,7 @@ 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
@@ -983,10 +1078,10 @@ 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));
@@ -1134,11 +1229,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
@@ -1158,6 +1252,10 @@ void backlight_set(uint8_t level) {}
 
 #endif // backlight
 
+#ifdef HD44780_ENABLED
+#include "hd44780.h"
+#endif
+
 
 // Functions for spitting out values
 //