From 4282b6c42e3a53acbda182968faa8cfa8759bed0 Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 20 Aug 2021 15:56:17 +0200 Subject: [PATCH] Apply suggestions from code review 2 Firmware size optimization Co-authored-by: Drashna Jaelre --- .../plut0nium/0x3E/keymaps/default/keymap.c | 57 ++++++++++++++----- 1 file changed, 42 insertions(+), 15 deletions(-) diff --git a/keyboards/plut0nium/0x3E/keymaps/default/keymap.c b/keyboards/plut0nium/0x3E/keymaps/default/keymap.c index 9eb127499712..ed2c464e463e 100644 --- a/keyboards/plut0nium/0x3E/keymaps/default/keymap.c +++ b/keyboards/plut0nium/0x3E/keymaps/default/keymap.c @@ -52,37 +52,64 @@ static void render_logo(void) { } #ifdef RGBLIGHT_ENABLE -extern rgblight_config_t rgblight_config; void render_rgb_status(void) { oled_write_ln_P(PSTR("RGB"), false); - if (!rgblight_config.enable) { + if (!rgblight_is_enabled()) { oled_write_P(PSTR(" off\n\n\n"), false); } else { - static char led_buf[24] = {0}; - snprintf(led_buf, sizeof(led_buf), "M:%3dH:%3dS:%3dV:%3d", - (uint8_t)rgblight_config.mode, - (uint8_t)rgblight_config.hue, - (uint8_t)rgblight_config.sat, - (uint8_t)rgblight_config.val); - oled_write(led_buf, false); + static char string[4] = {0}; + oled_write_P(PSTR("M:"), false); + uint8_t n = rgblight_get_mode(); + string[3] = '\0'; + string[2] = '0' + n % 10; + string[1] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; + string[0] = n / 10 ? '0' + n / 10 : ' '; + oled_write(string, false); + + oled_write_P(PSTR("H:"), false); + n = rgblight_get_hue(); + string[3] = '\0'; + string[2] = '0' + n % 10; + string[1] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; + string[0] = n / 10 ? '0' + n / 10 : ' '; + oled_write(string, false); + + oled_write_P(PSTR("S:"), false); + n = rgblight_get_sat(); + string[3] = '\0'; + string[2] = '0' + n % 10; + string[1] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; + string[0] = n / 10 ? '0' + n / 10 : ' '; + oled_write(string, false); + + oled_write_P(PSTR("V:"), false); + n = rgblight_get_val()/RGBLIGHT_VAL_STEP; + string[3] = '\0'; + string[2] = '0' + n % 10; + string[1] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; + string[0] = n / 10 ? '0' + n / 10 : ' '; + oled_write(string, false); } } #endif -extern backlight_config_t backlight_config; void render_backlight_status(void) { oled_write_ln_P(PSTR("BKL"), false); - if (!backlight_config.enable) { + if (!is_backlight_enabled()) { oled_write_P(PSTR(" off"), false); } else { - static char bkl_buf[8] = {0}; - snprintf(bkl_buf, sizeof(bkl_buf), "L:%3d", - (uint8_t)backlight_config.level); - oled_write(bkl_buf, false); + char string[4]; + oled_write_P(PSTR("L:"), false); + uint8_t n = get_backlight_level(); + string[3] = '\0'; + string[2] = '0' + n % 10; + string[1] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; + string[0] = n / 10 ? '0' + n / 10 : ' '; + oled_write(string, false); } }