From 465bfbcbed9c5ae234b253e8906f1be3b6ea825d Mon Sep 17 00:00:00 2001 From: Chris <52449218+shadow578@users.noreply.github.com> Date: Mon, 29 Apr 2024 08:24:47 +0000 Subject: [PATCH] implement lcd_put_int and use it in game renderer --- Marlin/src/lcd/e3v2/marlinui/game.cpp | 16 ++++++---------- Marlin/src/lcd/e3v2/marlinui/lcdprint_dwin.cpp | 4 +++- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Marlin/src/lcd/e3v2/marlinui/game.cpp b/Marlin/src/lcd/e3v2/marlinui/game.cpp index 235879f6425d..2ee3349c7eb9 100644 --- a/Marlin/src/lcd/e3v2/marlinui/game.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/game.cpp @@ -214,17 +214,13 @@ int MarlinGame::draw_string(const game_dim_t x, const game_dim_t y, FSTR_P const } void MarlinGame::draw_int(const game_dim_t x, const game_dim_t y, const int value) { - // TODO: lcd_put_int doesn't seem to work ?! - char str[12]; - itoa(value, str, 10); - draw_string(x, y, str); + COUNT_DRAW_CALL(0); - COUNT_DRAW_CALL(1); + lcd_moveto_xy( + dwin_game::game_to_screen(x) + dwin_game::x_offset, + dwin_game::game_to_screen(y) + dwin_game::y_offset + ); - //lcd_put_int( - // dwin_game::game_to_screen(x) + dwin_game::x_offset, - // dwin_game::game_to_screen(y) + dwin_game::y_offset, - // value - //); + lcd_put_int(value); } #endif // IS_DWIN_MARLINUI && HAS_GAMES diff --git a/Marlin/src/lcd/e3v2/marlinui/lcdprint_dwin.cpp b/Marlin/src/lcd/e3v2/marlinui/lcdprint_dwin.cpp index f689a6ff698d..9fa75a700bc6 100644 --- a/Marlin/src/lcd/e3v2/marlinui/lcdprint_dwin.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/lcdprint_dwin.cpp @@ -52,7 +52,9 @@ void lcd_moveto(const lcd_uint_t col, const lcd_uint_t row) { inline void lcd_advance_cursor(const uint8_t len=1) { cursor.x += len * dwin_font.width; } void lcd_put_int(const int i) { - // TODO: Draw an int at the cursor position, advance the cursor + char buf[12]; // 10 digits + sign + null + itoa(i, buf, 10); + lcd_put_u8str_max(buf, PIXEL_LEN_NOLIMIT); } int lcd_put_dwin_string() {