From 88c57eaf55f67648e494a6abda4d9a8b7989bad0 Mon Sep 17 00:00:00 2001
From: Scott Lahteine <thinkyhead@users.noreply.github.com>
Date: Mon, 19 Nov 2018 01:33:59 -0600
Subject: [PATCH] Clean up some u8g code (#12476)

---
 Marlin/src/lcd/dogm/lcdprint_u8g.cpp  | 38 +++++++++++++--------------
 Marlin/src/lcd/dogm/ultralcd_DOGM.cpp |  1 -
 2 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/Marlin/src/lcd/dogm/lcdprint_u8g.cpp b/Marlin/src/lcd/dogm/lcdprint_u8g.cpp
index 0b51e44571..cb09a146f0 100644
--- a/Marlin/src/lcd/dogm/lcdprint_u8g.cpp
+++ b/Marlin/src/lcd/dogm/lcdprint_u8g.cpp
@@ -12,9 +12,7 @@
 #if HAS_GRAPHICAL_LCD
 
 #include <U8glib.h>
-extern U8GLIB *pu8g;
-#define _lcd_write(a) pu8g->print(a)
-#define _lcd_setcursor(col, row) pu8g->setPrintPos((col), (row));
+extern U8GLIB u8g;
 
 #include "../ultralcd.h"
 #include "../../Marlin.h"
@@ -23,40 +21,40 @@ extern U8GLIB *pu8g;
 #include "u8g_fontutf8.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 the advanced pixels
 int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) {
   if (c < 256) {
-    _lcd_write((char)c);
-    return u8g_GetFontBBXWidth(pu8g->getU8g());
+    u8g.print((char)c);
+    return u8g_GetFontBBXWidth(u8g.getU8g());
   }
-  unsigned int x = pu8g->getPrintCol(),
-               y = pu8g->getPrintRow(),
-               ret = uxg_DrawWchar(pu8g->getU8g(), x, y, c, max_length);
-  pu8g->setPrintPos(x + ret, y);
+  unsigned int x = u8g.getPrintCol(),
+               y = u8g.getPrintRow(),
+               ret = uxg_DrawWchar(u8g.getU8g(), x, y, c, max_length);
+  u8g.setPrintPos(x + ret, y);
 
   return ret;
 }
 
 int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length) {
-  unsigned int x = pu8g->getPrintCol(),
-               y = pu8g->getPrintRow(),
-               ret = uxg_DrawUtf8Str(pu8g->getU8g(), x, y, utf8_str, max_length);
-  pu8g->setPrintPos(x + ret, y);
+  unsigned int x = u8g.getPrintCol(),
+               y = u8g.getPrintRow(),
+               ret = uxg_DrawUtf8Str(u8g.getU8g(), x, y, utf8_str, max_length);
+  u8g.setPrintPos(x + ret, y);
   return ret;
 }
 
 int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length) {
-  unsigned int x = pu8g->getPrintCol(),
-               y = pu8g->getPrintRow(),
-               ret = uxg_DrawUtf8StrP(pu8g->getU8g(), x, y, utf8_str_P, max_length);
-  pu8g->setPrintPos(x + ret, y);
+  unsigned int x = u8g.getPrintCol(),
+               y = u8g.getPrintRow(),
+               ret = uxg_DrawUtf8StrP(u8g.getU8g(), x, y, utf8_str_P, max_length);
+  u8g.setPrintPos(x + ret, y);
   return ret;
 }
 
diff --git a/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp b/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp
index 0095f96fd7..e397a9f8ba 100644
--- a/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp
+++ b/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp
@@ -68,7 +68,6 @@
 #endif
 
 U8G_CLASS u8g(U8G_PARAM);
-U8GLIB *pu8g = &u8g;
 
 #include LANGUAGE_DATA_INCL(LCD_LANGUAGE)