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
This commit is contained in:
William Wilgus 2022-11-21 00:14:52 -05:00 committed by William Wilgus
parent eb9b3513fa
commit 658cc95885
3 changed files with 17 additions and 27 deletions

View file

@ -154,7 +154,6 @@ static void draw_screen(struct screen *display, char *title,
{ {
unsigned text_color = LCD_BLACK; unsigned text_color = LCD_BLACK;
unsigned background_color = LCD_WHITE; unsigned background_color = LCD_WHITE;
char buf[32];
int i, char_height, line_height; int i, char_height, line_height;
int max_label_width; int max_label_width;
int text_x, text_top; int text_x, text_top;
@ -253,17 +252,16 @@ static void draw_screen(struct screen *display, char *title,
set_drawinfo(display, mode, fg, bg); set_drawinfo(display, mode, fg, bg);
/* Draw label */ /* Draw label */
buf[0] = str(LANG_COLOR_RGB_LABELS)[i];
buf[1] = '\0';
vp.flags &= ~VP_FLAG_ALIGNMENT_MASK; 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 */ /* Draw color value */
if (display->depth >= 24)
snprintf(buf, 4, "%03d", rgb->rgb_val[i] & 0xFF);
else
snprintf(buf, 3, "%02d", rgb->rgb_val[i] & 0x3F);
vp.flags |= VP_FLAG_ALIGN_RIGHT; vp.flags |= VP_FLAG_ALIGN_RIGHT;
display->putsxy(text_x, text_top, buf); if (display->depth >= 24)
display->putsxyf(text_x, text_top, "%03d", rgb->rgb_val[i] & 0xFF);
else
display->putsxyf(text_x, text_top, "%02d", rgb->rgb_val[i] & 0x3F);
/* Draw scrollbar */ /* Draw scrollbar */
gui_scrollbar_draw(display, /* screen */ gui_scrollbar_draw(display, /* screen */
@ -280,9 +278,6 @@ static void draw_screen(struct screen *display, char *title,
text_top += line_height; text_top += line_height;
} /* end for */ } /* 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; vp.flags |= VP_FLAG_ALIGN_CENTER;
if (display->depth >= 16) if (display->depth >= 16)
{ {
@ -301,8 +296,9 @@ static void draw_screen(struct screen *display, char *title,
/* Draw RGB: #rrggbb in middle of swatch */ /* Draw RGB: #rrggbb in middle of swatch */
set_drawinfo(display, DRMODE_FG, get_black_or_white(rgb), set_drawinfo(display, DRMODE_FG, get_black_or_white(rgb),
background_color); background_color);
/* Format RGB: #rrggbb */
display->putsxy(0, top + (height - char_height) / 2, buf); display->putsxyf(0, top + (height - char_height) / 2,
str(LANG_COLOR_RGB_VALUE), rgb->red, rgb->green, rgb->blue);
/* Draw border around the rect */ /* Draw border around the rect */
set_drawinfo(display, DRMODE_SOLID, text_color, background_color); 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) if (height >= char_height)
{ {
set_drawinfo(display, DRMODE_SOLID, text_color, background_color); 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);
} }
} }

View file

@ -264,8 +264,7 @@ next:
else else
{ {
/* any other character here is an erroneous format string */ /* any other character here is an erroneous format string */
snprintf(tempbuf, sizeof(tempbuf), "<E:%c>", ch); display->putsxyf(xpos, y, "<E:%c>", ch);
display->putsxy(xpos, y, tempbuf);
/* Don't consider going forward, fix the caller */ /* Don't consider going forward, fix the caller */
return; return;
} }

View file

@ -590,7 +590,6 @@ int eq_menu_graphical(void)
int *setting; int *setting;
int current_band, x, y, step, fast_step, min, max; int current_band, x, y, step, fast_step, min, max;
enum eq_slider_mode mode; enum eq_slider_mode mode;
char buf[24];
int h, height, start_item, nb_eq_sliders[NB_SCREENS]; int h, height, start_item, nb_eq_sliders[NB_SCREENS];
FOR_NB_SCREENS(i) FOR_NB_SCREENS(i)
viewportmanager_theme_enable(i, false, NULL); viewportmanager_theme_enable(i, false, NULL);
@ -638,10 +637,8 @@ int eq_menu_graphical(void)
min = EQ_GAIN_MIN; min = EQ_GAIN_MIN;
max = EQ_GAIN_MAX; max = EQ_GAIN_MAX;
snprintf(buf, sizeof(buf), str(LANG_SYSFONT_EQUALIZER_EDIT_MODE), screens[i].putsxyf(0, 0, str(LANG_SYSFONT_EQUALIZER_EDIT_MODE),
str(LANG_SYSFONT_GAIN), "(dB)"); str(LANG_SYSFONT_GAIN), "(dB)");
screens[i].putsxy(0, 0, buf);
} else if (mode == CUTOFF) { } else if (mode == CUTOFF) {
/* cutoff */ /* cutoff */
setting = &global_settings.eq_band_settings[current_band].cutoff; setting = &global_settings.eq_band_settings[current_band].cutoff;
@ -651,10 +648,8 @@ int eq_menu_graphical(void)
min = EQ_CUTOFF_MIN; min = EQ_CUTOFF_MIN;
max = EQ_CUTOFF_MAX; max = EQ_CUTOFF_MAX;
snprintf(buf, sizeof(buf), str(LANG_SYSFONT_EQUALIZER_EDIT_MODE), screens[i].putsxyf(0, 0, str(LANG_SYSFONT_EQUALIZER_EDIT_MODE),
str(LANG_SYSFONT_EQUALIZER_BAND_CUTOFF), "(Hz)"); str(LANG_SYSFONT_EQUALIZER_BAND_CUTOFF), "(Hz)");
screens[i].putsxy(0, 0, buf);
} else { } else {
/* Q */ /* Q */
setting = &global_settings.eq_band_settings[current_band].q; setting = &global_settings.eq_band_settings[current_band].q;
@ -664,10 +659,8 @@ int eq_menu_graphical(void)
min = EQ_Q_MIN; min = EQ_Q_MIN;
max = EQ_Q_MAX; max = EQ_Q_MAX;
snprintf(buf, sizeof(buf), str(LANG_SYSFONT_EQUALIZER_EDIT_MODE), screens[i].putsxyf(0, 0, str(LANG_SYSFONT_EQUALIZER_EDIT_MODE),
str(LANG_SYSFONT_EQUALIZER_BAND_Q), ""); str(LANG_SYSFONT_EQUALIZER_BAND_Q), "");
screens[i].putsxy(0, 0, buf);
} }
/* Draw scrollbar if needed */ /* Draw scrollbar if needed */