From 658cc9588569af9cba054ad6f1b1e92204961d20 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Mon, 21 Nov 2022 00:14:52 -0500 Subject: remove some sprintf putsxy calls in favor of putsxyf we now have putsxyf in screens[] so no need for a separate buffer in these cases Change-Id: Ife0738e731f03d255f512bab3d5bb07b8be8693d --- apps/gui/color_picker.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'apps/gui/color_picker.c') diff --git a/apps/gui/color_picker.c b/apps/gui/color_picker.c index a32f1ee179..ef17c0a230 100644 --- a/apps/gui/color_picker.c +++ b/apps/gui/color_picker.c @@ -154,7 +154,6 @@ static void draw_screen(struct screen *display, char *title, { unsigned text_color = LCD_BLACK; unsigned background_color = LCD_WHITE; - char buf[32]; int i, char_height, line_height; int max_label_width; int text_x, text_top; @@ -253,17 +252,16 @@ static void draw_screen(struct screen *display, char *title, set_drawinfo(display, mode, fg, bg); /* Draw label */ - buf[0] = str(LANG_COLOR_RGB_LABELS)[i]; - buf[1] = '\0'; vp.flags &= ~VP_FLAG_ALIGNMENT_MASK; - display->putsxy(text_x, text_top, buf); + display->putsxyf(text_x, text_top, "%c", str(LANG_COLOR_RGB_LABELS)[i]); /* Draw color value */ + vp.flags |= VP_FLAG_ALIGN_RIGHT; if (display->depth >= 24) - snprintf(buf, 4, "%03d", rgb->rgb_val[i] & 0xFF); + display->putsxyf(text_x, text_top, "%03d", rgb->rgb_val[i] & 0xFF); else - snprintf(buf, 3, "%02d", rgb->rgb_val[i] & 0x3F); - vp.flags |= VP_FLAG_ALIGN_RIGHT; - display->putsxy(text_x, text_top, buf); + display->putsxyf(text_x, text_top, "%02d", rgb->rgb_val[i] & 0x3F); + + /* Draw scrollbar */ gui_scrollbar_draw(display, /* screen */ @@ -280,9 +278,6 @@ static void draw_screen(struct screen *display, char *title, text_top += line_height; } /* end for */ - /* Format RGB: #rrggbb */ - snprintf(buf, sizeof(buf), str(LANG_COLOR_RGB_VALUE), - rgb->red, rgb->green, rgb->blue); vp.flags |= VP_FLAG_ALIGN_CENTER; if (display->depth >= 16) { @@ -301,8 +296,9 @@ static void draw_screen(struct screen *display, char *title, /* Draw RGB: #rrggbb in middle of swatch */ set_drawinfo(display, DRMODE_FG, get_black_or_white(rgb), background_color); - - display->putsxy(0, top + (height - char_height) / 2, buf); + /* Format RGB: #rrggbb */ + display->putsxyf(0, top + (height - char_height) / 2, + str(LANG_COLOR_RGB_VALUE), rgb->red, rgb->green, rgb->blue); /* Draw border around the rect */ set_drawinfo(display, DRMODE_SOLID, text_color, background_color); @@ -318,7 +314,9 @@ static void draw_screen(struct screen *display, char *title, if (height >= char_height) { set_drawinfo(display, DRMODE_SOLID, text_color, background_color); - display->putsxy(0, top + (height - char_height) / 2, buf); + /* Format RGB: #rrggbb */ + display->putsxyf(0, top + (height - char_height) / 2, + str(LANG_COLOR_RGB_VALUE), rgb->red, rgb->green, rgb->blue); } } -- cgit v1.2.3