Improve oled_task_kb based on review

Co-authored-by: Drashna Jaelre <drashna@live.com>
This commit is contained in:
mawaeg 2025-03-09 20:17:28 +01:00
parent ad2eb9aa21
commit b1c22b2107

View File

@ -16,6 +16,7 @@
#include "quantum.h" #include "quantum.h"
#include <ctype.h> #include <ctype.h>
#include <lib/lib8tion/lib8tion.h>
#include <rgb_matrix.h> #include <rgb_matrix.h>
#if defined(RGB_MATRIX_EFFECT) #if defined(RGB_MATRIX_EFFECT)
@ -83,7 +84,7 @@ bool oled_task_kb(void) {
static uint16_t key_timer = 0; static uint16_t key_timer = 0;
static uint8_t start_index = 0; static uint8_t start_index = 0;
uint8_t speedPercentage = (uint8_t)(((float)rgb_matrix_get_speed() / 255.0) * 100.0); uint8_t speedPercentage = scale8(rgb_matrix_get_speed(), 100);
bool is_timer_elapsed = timer_elapsed(key_timer) > 200; bool is_timer_elapsed = timer_elapsed(key_timer) > 200;
if (last_effect != rgb_matrix_get_mode() || last_speed != speedPercentage || is_timer_elapsed) { if (last_effect != rgb_matrix_get_mode() || last_speed != speedPercentage || is_timer_elapsed) {
@ -116,9 +117,7 @@ bool oled_task_kb(void) {
oled_set_cursor(0, 2); oled_set_cursor(0, 2);
oled_write_ln_P(PSTR("RGB Speed: "), false); oled_write_ln_P(PSTR("RGB Speed: "), false);
char speedBuffer[4]; oled_write(get_u8_str(speedPercentage, ' '), false);
sprintf(speedBuffer, "%d", speedPercentage);
oled_write(speedBuffer, false);
oled_write("%", false); oled_write("%", false);
} }