From 0fd08da806711112147cd6c3b9bdee0250f9f103 Mon Sep 17 00:00:00 2001 From: yiancar Date: Sat, 11 Jun 2022 01:20:01 +0100 Subject: Scale brigthness for VIA (#17352) Co-authored-by: yiancar --- quantum/via.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'quantum/via.c') diff --git a/quantum/via.c b/quantum/via.c index 320bd5546d..a37bd38da8 100644 --- a/quantum/via.c +++ b/quantum/via.c @@ -64,6 +64,7 @@ void via_qmk_rgblight_get_value(uint8_t *data); #endif #if defined(VIA_QMK_RGB_MATRIX_ENABLE) +# include 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]); -- cgit v1.2.1 From 568924c76cb29620e2cb7d2f2f5b1beddf8cf623 Mon Sep 17 00:00:00 2001 From: Dasky <32983009+daskygit@users.noreply.github.com> Date: Sat, 11 Jun 2022 03:07:58 +0100 Subject: Add missing bracket for VIA brightness scaling (#17354) --- quantum/via.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'quantum/via.c') diff --git a/quantum/via.c b/quantum/via.c index a37bd38da8..1ded1f5fe8 100644 --- a/quantum/via.c +++ b/quantum/via.c @@ -491,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(), ((uint16_t)value_data[0] * RGBLIGHT_LIMIT_VAL) / UINT8_MAX; + 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: { -- cgit v1.2.1 From 80034a847fdfe91cf0d6ef9399d34d90c15d8a54 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 10 Jun 2022 22:01:46 -0700 Subject: Ensure that rgb+via compiles in all cases (#17355) --- quantum/via.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'quantum/via.c') diff --git a/quantum/via.c b/quantum/via.c index 1ded1f5fe8..d2ef0862cc 100644 --- a/quantum/via.c +++ b/quantum/via.c @@ -461,6 +461,9 @@ void via_qmk_backlight_set_value(uint8_t *data) { #endif // #if defined(VIA_QMK_BACKLIGHT_ENABLE) #if defined(VIA_QMK_RGBLIGHT_ENABLE) +# ifndef RGBLIGHT_LIMIT_VAL +# define RGBLIGHT_LIMIT_VAL 255 +# endif void via_qmk_rgblight_get_value(uint8_t *data) { uint8_t *value_id = &(data[0]); @@ -518,6 +521,11 @@ void via_qmk_rgblight_set_value(uint8_t *data) { #if defined(VIA_QMK_RGB_MATRIX_ENABLE) +# if !defined(RGB_MATRIX_MAXIMUM_BRIGHTNESS) || RGB_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX +# undef RGB_MATRIX_MAXIMUM_BRIGHTNESS +# define RGB_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX +# endif + // VIA supports only 4 discrete values for effect speed; map these to some // useful speed values for RGB Matrix. enum speed_values { -- cgit v1.2.1 From 4efe6330c49f076b9c01d3f609dea0cd9f9b0214 Mon Sep 17 00:00:00 2001 From: Wilba Date: Thu, 21 Jul 2022 09:53:42 +1000 Subject: VIA Encoder Map Support (#17734) --- quantum/via.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'quantum/via.c') diff --git a/quantum/via.c b/quantum/via.c index d2ef0862cc..37e2046a10 100644 --- a/quantum/via.c +++ b/quantum/via.c @@ -397,6 +397,18 @@ void raw_hid_receive(uint8_t *data, uint8_t length) { dynamic_keymap_set_buffer(offset, size, &command_data[3]); break; } +#ifdef ENCODER_MAP_ENABLE + case id_dynamic_keymap_get_encoder: { + uint16_t keycode = dynamic_keymap_get_encoder(command_data[0], command_data[1], command_data[2] != 0); + command_data[3] = keycode >> 8; + command_data[4] = keycode & 0xFF; + break; + } + case id_dynamic_keymap_set_encoder: { + dynamic_keymap_set_encoder(command_data[0], command_data[1], command_data[2] != 0, (command_data[3] << 8) | command_data[4]); + break; + } +#endif default: { // The command ID is not known // Return the unhandled state -- cgit v1.2.1