]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Addition of hard brigtness limit for RGB_Matrix (#3299)
authoryiancar <yiangosyiangou@cytanet.com.cy>
Tue, 3 Jul 2018 16:52:04 +0000 (19:52 +0300)
committerJack Humbert <jack.humb@gmail.com>
Tue, 3 Jul 2018 16:52:04 +0000 (12:52 -0400)
* Addition of hard brigtness limit for RGB_Matrix

- Added a define "RGB_MATRIX_MAXIMUM_BRIGHTNESS" to enable hard limiting the maximum brightness for rgb_matrix
- Used the above define to limit the maximum brigthness of HS60 for better stability

* Added docs for new rgb_matrix define

* Addition of check for maximum brightness

docs/feature_rgb_matrix.md
keyboards/hs60/config.h
quantum/rgb_matrix.c

index 5d2db3b9709c5a7a529049dc8b736578d095a5f4..cb7aa666cf4e50e74a51ea14c137a41a2e85e843 100644 (file)
@@ -119,6 +119,7 @@ A similar function works in the keymap as `rgb_matrix_indicators_user`.
        #define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
        #define RGB_DISABLE_WHEN_USB_SUSPENDED false // turn off effects when suspended
     #define RGB_MATRIX_SKIP_FRAMES 1 // number of frames to skip when displaying animations (0 is full effect) if not defined defaults to 1
+    #define RGB_MATRIX_MAXIMUM_BRIGHTNESS 200 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255
 
 ## EEPROM storage
 
index d37fc8990d414b8498b4eaaae68e827276c0458d..31f7c0790176f94e4cbac57429edf49b84fd08e4 100644 (file)
@@ -127,6 +127,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
 #define RGB_DISABLE_WHEN_USB_SUSPENDED false // turn off effects when suspended
 #define RGB_MATRIX_SKIP_FRAMES 0
+#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 215
 
 #define DRIVER_ADDR_1 0b1110100
 #define DRIVER_ADDR_2 0b1110101
index 8c41fc54d21ba628bb4ae91ecb0c468aa9a1be78..b7424d63723ed8cbc28105bf7b65eb5386937fb5 100644 (file)
@@ -41,6 +41,10 @@ rgb_config_t rgb_matrix_config;
     #define EECONFIG_RGB_MATRIX EECONFIG_RGBLIGHT
 #endif
 
+#if !defined(RGB_MATRIX_MAXIMUM_BRIGHTNESS) || RGB_MATRIX_MAXIMUM_BRIGHTNESS > 255
+    #define RGB_MATRIX_MAXIMUM_BRIGHTNESS 255
+#endif
+
 bool g_suspend_state = false;
 
 // Global tick at 20 Hz
@@ -68,7 +72,7 @@ void eeconfig_update_rgb_matrix_default(void) {
   rgb_matrix_config.mode = RGB_MATRIX_CYCLE_LEFT_RIGHT;
   rgb_matrix_config.hue = 0;
   rgb_matrix_config.sat = 255;
-  rgb_matrix_config.val = 255;
+  rgb_matrix_config.val = RGB_MATRIX_MAXIMUM_BRIGHTNESS;
   rgb_matrix_config.speed = 0;
   eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
 }
@@ -858,12 +862,12 @@ void rgblight_decrease_sat(void) {
 }
 
 void rgblight_increase_val(void) {
-    rgb_matrix_config.val = increment( rgb_matrix_config.val, 8, 0, 255 );
+    rgb_matrix_config.val = increment( rgb_matrix_config.val, 8, 0, RGB_MATRIX_MAXIMUM_BRIGHTNESS );
     eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
 }
 
 void rgblight_decrease_val(void) {
-    rgb_matrix_config.val = decrement( rgb_matrix_config.val, 8, 0, 255 );
+    rgb_matrix_config.val = decrement( rgb_matrix_config.val, 8, 0, RGB_MATRIX_MAXIMUM_BRIGHTNESS );
     eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
 }