Skip to content

Commit

Permalink
implement lcd_put_int and use it in game renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
shadow578 authored Apr 29, 2024
1 parent 4c88165 commit 465bfbc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
16 changes: 6 additions & 10 deletions Marlin/src/lcd/e3v2/marlinui/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion Marlin/src/lcd/e3v2/marlinui/lcdprint_dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 465bfbc

Please sign in to comment.