mirror of
https://github.com/Keychron/qmk_firmware.git
synced 2024-12-26 02:58:06 +06:00
Scale brigthness for VIA (#17352)
Co-authored-by: yiancar <yiancar@gmail.com>
This commit is contained in:
parent
d05a1deb7c
commit
0fd08da806
@ -64,6 +64,7 @@ void via_qmk_rgblight_get_value(uint8_t *data);
|
||||
#endif
|
||||
|
||||
#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_get_value(uint8_t *data);
|
||||
void eeconfig_update_rgb_matrix(void);
|
||||
@ -421,7 +422,7 @@ void via_qmk_backlight_get_value(uint8_t *data) {
|
||||
switch (*value_id) {
|
||||
case id_qmk_backlight_brightness: {
|
||||
// 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;
|
||||
}
|
||||
case id_qmk_backlight_effect: {
|
||||
@ -441,7 +442,7 @@ void via_qmk_backlight_set_value(uint8_t *data) {
|
||||
switch (*value_id) {
|
||||
case id_qmk_backlight_brightness: {
|
||||
// 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;
|
||||
}
|
||||
case id_qmk_backlight_effect: {
|
||||
@ -466,7 +467,7 @@ void via_qmk_rgblight_get_value(uint8_t *data) {
|
||||
uint8_t *value_data = &(data[1]);
|
||||
switch (*value_id) {
|
||||
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;
|
||||
}
|
||||
case id_qmk_rgblight_effect: {
|
||||
@ -490,7 +491,7 @@ void via_qmk_rgblight_set_value(uint8_t *data) {
|
||||
uint8_t *value_data = &(data[1]);
|
||||
switch (*value_id) {
|
||||
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;
|
||||
}
|
||||
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]);
|
||||
switch (*value_id) {
|
||||
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;
|
||||
case id_qmk_rgblight_effect:
|
||||
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]);
|
||||
switch (*value_id) {
|
||||
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;
|
||||
case id_qmk_rgblight_effect:
|
||||
rgb_matrix_mode_noeeprom(value_data[0]);
|
||||
|
Loading…
Reference in New Issue
Block a user