Browse Source

Clean up some u8g code (#12476)

pull/1/head
Scott Lahteine 6 years ago
committed by GitHub
parent
commit
88c57eaf55
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 38
      Marlin/src/lcd/dogm/lcdprint_u8g.cpp
  2. 1
      Marlin/src/lcd/dogm/ultralcd_DOGM.cpp

38
Marlin/src/lcd/dogm/lcdprint_u8g.cpp

@ -12,9 +12,7 @@
#if HAS_GRAPHICAL_LCD #if HAS_GRAPHICAL_LCD
#include <U8glib.h> #include <U8glib.h>
extern U8GLIB *pu8g; extern U8GLIB u8g;
#define _lcd_write(a) pu8g->print(a)
#define _lcd_setcursor(col, row) pu8g->setPrintPos((col), (row));
#include "../ultralcd.h" #include "../ultralcd.h"
#include "../../Marlin.h" #include "../../Marlin.h"
@ -23,40 +21,40 @@ extern U8GLIB *pu8g;
#include "u8g_fontutf8.h" #include "u8g_fontutf8.h"
#include "../lcdprint.h" #include "../lcdprint.h"
int lcd_glyph_height(void) { return u8g_GetFontBBXHeight(pu8g->getU8g()); } int lcd_glyph_height(void) { return u8g_GetFontBBXHeight(u8g.getU8g()); }
void lcd_moveto(const uint8_t col, const uint8_t row) { _lcd_setcursor(col, row); } void lcd_moveto(const uint8_t col, const uint8_t row) { u8g.setPrintPos(col, row); }
void lcd_put_int(const int i) { pu8g->print(i); } void lcd_put_int(const int i) { u8g.print(i); }
// return < 0 on error // return < 0 on error
// return the advanced pixels // return the advanced pixels
int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) { int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) {
if (c < 256) { if (c < 256) {
_lcd_write((char)c); u8g.print((char)c);
return u8g_GetFontBBXWidth(pu8g->getU8g()); return u8g_GetFontBBXWidth(u8g.getU8g());
} }
unsigned int x = pu8g->getPrintCol(), unsigned int x = u8g.getPrintCol(),
y = pu8g->getPrintRow(), y = u8g.getPrintRow(),
ret = uxg_DrawWchar(pu8g->getU8g(), x, y, c, max_length); ret = uxg_DrawWchar(u8g.getU8g(), x, y, c, max_length);
pu8g->setPrintPos(x + ret, y); u8g.setPrintPos(x + ret, y);
return ret; return ret;
} }
int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length) { int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length) {
unsigned int x = pu8g->getPrintCol(), unsigned int x = u8g.getPrintCol(),
y = pu8g->getPrintRow(), y = u8g.getPrintRow(),
ret = uxg_DrawUtf8Str(pu8g->getU8g(), x, y, utf8_str, max_length); ret = uxg_DrawUtf8Str(u8g.getU8g(), x, y, utf8_str, max_length);
pu8g->setPrintPos(x + ret, y); u8g.setPrintPos(x + ret, y);
return ret; return ret;
} }
int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length) { int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length) {
unsigned int x = pu8g->getPrintCol(), unsigned int x = u8g.getPrintCol(),
y = pu8g->getPrintRow(), y = u8g.getPrintRow(),
ret = uxg_DrawUtf8StrP(pu8g->getU8g(), x, y, utf8_str_P, max_length); ret = uxg_DrawUtf8StrP(u8g.getU8g(), x, y, utf8_str_P, max_length);
pu8g->setPrintPos(x + ret, y); u8g.setPrintPos(x + ret, y);
return ret; return ret;
} }

1
Marlin/src/lcd/dogm/ultralcd_DOGM.cpp

@ -68,7 +68,6 @@
#endif #endif
U8G_CLASS u8g(U8G_PARAM); U8G_CLASS u8g(U8G_PARAM);
U8GLIB *pu8g = &u8g;
#include LANGUAGE_DATA_INCL(LCD_LANGUAGE) #include LANGUAGE_DATA_INCL(LCD_LANGUAGE)

Loading…
Cancel
Save