1
0
Fork 0
forked from forks/qmk_firmware

Scale brigthness for VIA (#17352)

Co-authored-by: yiancar <yiancar@gmail.com>
This commit is contained in:
yiancar 2022-06-11 01:20:01 +01:00 committed by GitHub
parent d05a1deb7c
commit 0fd08da806
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -64,6 +64,7 @@ void via_qmk_rgblight_get_value(uint8_t *data);
#endif #endif
#if defined(VIA_QMK_RGB_MATRIX_ENABLE) #if defined(VIA_QMK_RGB_MATRIX_ENABLE)
# include <lib/lib8tion/lib8tion.h>
void via_qmk_rgb_matrix_set_value(uint8_t *data); void via_qmk_rgb_matrix_set_value(uint8_t *data);
void via_qmk_rgb_matrix_get_value(uint8_t *data); void via_qmk_rgb_matrix_get_value(uint8_t *data);
void eeconfig_update_rgb_matrix(void); void eeconfig_update_rgb_matrix(void);
@ -421,7 +422,7 @@ void via_qmk_backlight_get_value(uint8_t *data) {
switch (*value_id) { switch (*value_id) {
case id_qmk_backlight_brightness: { case id_qmk_backlight_brightness: {
// level / BACKLIGHT_LEVELS * 255 // level / BACKLIGHT_LEVELS * 255
value_data[0] = ((uint16_t)get_backlight_level()) * 255 / BACKLIGHT_LEVELS; value_data[0] = ((uint16_t)get_backlight_level() * UINT8_MAX) / BACKLIGHT_LEVELS;
break; break;
} }
case id_qmk_backlight_effect: { case id_qmk_backlight_effect: {
@ -441,7 +442,7 @@ void via_qmk_backlight_set_value(uint8_t *data) {
switch (*value_id) { switch (*value_id) {
case id_qmk_backlight_brightness: { case id_qmk_backlight_brightness: {
// level / 255 * BACKLIGHT_LEVELS // level / 255 * BACKLIGHT_LEVELS
backlight_level_noeeprom(((uint16_t)value_data[0]) * BACKLIGHT_LEVELS / 255); backlight_level_noeeprom(((uint16_t)value_data[0] * BACKLIGHT_LEVELS) / UINT8_MAX);
break; break;
} }
case id_qmk_backlight_effect: { case id_qmk_backlight_effect: {
@ -466,7 +467,7 @@ void via_qmk_rgblight_get_value(uint8_t *data) {
uint8_t *value_data = &(data[1]); uint8_t *value_data = &(data[1]);
switch (*value_id) { switch (*value_id) {
case id_qmk_rgblight_brightness: { case id_qmk_rgblight_brightness: {
value_data[0] = rgblight_get_val(); value_data[0] = ((uint16_t)rgblight_get_val() * UINT8_MAX) / RGBLIGHT_LIMIT_VAL;
break; break;
} }
case id_qmk_rgblight_effect: { case id_qmk_rgblight_effect: {
@ -490,7 +491,7 @@ void via_qmk_rgblight_set_value(uint8_t *data) {
uint8_t *value_data = &(data[1]); uint8_t *value_data = &(data[1]);
switch (*value_id) { switch (*value_id) {
case id_qmk_rgblight_brightness: { case id_qmk_rgblight_brightness: {
rgblight_sethsv_noeeprom(rgblight_get_hue(), rgblight_get_sat(), value_data[0]); rgblight_sethsv_noeeprom(rgblight_get_hue(), rgblight_get_sat(), ((uint16_t)value_data[0] * RGBLIGHT_LIMIT_VAL) / UINT8_MAX;
break; break;
} }
case id_qmk_rgblight_effect: { case id_qmk_rgblight_effect: {
@ -557,7 +558,7 @@ void via_qmk_rgb_matrix_get_value(uint8_t *data) {
uint8_t *value_data = &(data[1]); uint8_t *value_data = &(data[1]);
switch (*value_id) { switch (*value_id) {
case id_qmk_rgblight_brightness: case id_qmk_rgblight_brightness:
value_data[0] = rgb_matrix_get_val(); value_data[0] = ((uint16_t)rgb_matrix_get_val() * UINT8_MAX) / RGB_MATRIX_MAXIMUM_BRIGHTNESS;
break; break;
case id_qmk_rgblight_effect: case id_qmk_rgblight_effect:
value_data[0] = rgb_matrix_get_mode(); value_data[0] = rgb_matrix_get_mode();
@ -577,7 +578,7 @@ void via_qmk_rgb_matrix_set_value(uint8_t *data) {
uint8_t *value_data = &(data[1]); uint8_t *value_data = &(data[1]);
switch (*value_id) { switch (*value_id) {
case id_qmk_rgblight_brightness: case id_qmk_rgblight_brightness:
rgb_matrix_sethsv_noeeprom(rgb_matrix_get_hue(), rgb_matrix_get_sat(), value_data[0]); rgb_matrix_sethsv_noeeprom(rgb_matrix_get_hue(), rgb_matrix_get_sat(), scale8(value_data[0], RGB_MATRIX_MAXIMUM_BRIGHTNESS));
break; break;
case id_qmk_rgblight_effect: case id_qmk_rgblight_effect:
rgb_matrix_mode_noeeprom(value_data[0]); rgb_matrix_mode_noeeprom(value_data[0]);