Clean up some u8g code (#12476)

This commit is contained in:
Scott Lahteine 2018-11-19 01:33:59 -06:00 committed by GitHub
parent 1f93d2bcf7
commit 88c57eaf55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 21 deletions

View File

@ -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;
} }

View File

@ -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)