瀏覽代碼

Delay U8glib init using U8glib-HAL 0.4.4 (#21496)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
Victor Oliveira 3 年之前
父節點
當前提交
7124326808
沒有連結到貢獻者的電子郵件帳戶。
共有 3 個檔案被更改,包括 59 行新增38 行删除
  1. 50
    36
      Marlin/src/lcd/dogm/HAL_LCD_class_defines.h
  2. 8
    1
      Marlin/src/lcd/dogm/marlinui_DOGM.cpp
  3. 1
    1
      ini/features.ini

+ 50
- 36
Marlin/src/lcd/dogm/HAL_LCD_class_defines.h 查看文件

@@ -30,12 +30,15 @@ extern u8g_dev_t u8g_dev_st7565_64128n_HAL_2x_hw_spi;
30 30
 
31 31
 class U8GLIB_64128N_2X_HAL : public U8GLIB {
32 32
 public:
33
-  U8GLIB_64128N_2X_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE)
34
-    : U8GLIB(&u8g_dev_st7565_64128n_HAL_2x_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset)
35
-    { }
36
-  U8GLIB_64128N_2X_HAL(pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE)
37
-    : U8GLIB(&u8g_dev_st7565_64128n_HAL_2x_hw_spi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset)
38
-    { }
33
+  U8GLIB_64128N_2X_HAL() : U8GLIB() { }
34
+  U8GLIB_64128N_2X_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) { init(sck, mosi, cs, a0, reset); }
35
+  U8GLIB_64128N_2X_HAL(pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) { init(cs, a0, reset); }
36
+  void init(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) {
37
+    U8GLIB::init(&u8g_dev_st7565_64128n_HAL_2x_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset);
38
+  }
39
+  void init(pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) {
40
+    U8GLIB::init(&u8g_dev_st7565_64128n_HAL_2x_hw_spi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset);
41
+  }
39 42
 };
40 43
 
41 44
 extern u8g_dev_t u8g_dev_st7920_128x64_HAL_4x_sw_spi;
@@ -43,12 +46,15 @@ extern u8g_dev_t u8g_dev_st7920_128x64_HAL_4x_hw_spi;
43 46
 
44 47
 class U8GLIB_ST7920_128X64_4X_HAL : public U8GLIB {
45 48
 public:
46
-  U8GLIB_ST7920_128X64_4X_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t reset = U8G_PIN_NONE)
47
-    : U8GLIB(&u8g_dev_st7920_128x64_HAL_4x_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, U8G_PIN_NONE, (uint8_t)reset)    // a0 = U8G_PIN_NONE
48
-    { }
49
-  U8GLIB_ST7920_128X64_4X_HAL(pin_t cs, pin_t reset = U8G_PIN_NONE)
50
-    : U8GLIB(&u8g_dev_st7920_128x64_HAL_4x_hw_spi, (uint8_t)cs, U8G_PIN_NONE, (uint8_t)reset)   // a0 = U8G_PIN_NONE
51
-    { }
49
+  U8GLIB_ST7920_128X64_4X_HAL() : U8GLIB() { }
50
+  U8GLIB_ST7920_128X64_4X_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t reset = U8G_PIN_NONE) { init(sck, mosi, cs, reset); }
51
+  U8GLIB_ST7920_128X64_4X_HAL(pin_t cs, pin_t reset = U8G_PIN_NONE) { init(cs, reset); }
52
+  void init(pin_t sck, pin_t mosi, pin_t cs, pin_t reset = U8G_PIN_NONE) {
53
+    U8GLIB::init(&u8g_dev_st7920_128x64_HAL_4x_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, U8G_PIN_NONE, (uint8_t)reset); // a0 = U8G_PIN_NONE
54
+  }
55
+  void init(pin_t cs, pin_t reset = U8G_PIN_NONE) {
56
+    U8GLIB::init(&u8g_dev_st7920_128x64_HAL_4x_hw_spi, (uint8_t)cs, U8G_PIN_NONE, (uint8_t)reset); // a0 = U8G_PIN_NONE
57
+  }
52 58
 };
53 59
 
54 60
 //
@@ -59,27 +65,29 @@ extern u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi;
59 65
 
60 66
 class U8GLIB_ST7920_128X64_RRD : public U8GLIB {
61 67
 public:
62
-  U8GLIB_ST7920_128X64_RRD(pin_t sck, pin_t mosi, pin_t cs, pin_t reset = U8G_PIN_NONE)
63
-    : U8GLIB(&u8g_dev_st7920_128x64_rrd_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, U8G_PIN_NONE, (uint8_t)reset)   // a0 = U8G_PIN_NONE
64
-    { }
68
+  U8GLIB_ST7920_128X64_RRD() : U8GLIB() { }
69
+  U8GLIB_ST7920_128X64_RRD(pin_t sck, pin_t mosi, pin_t cs, pin_t reset = U8G_PIN_NONE) { init(sck, mosi, cs, reset); }
70
+  void init(pin_t sck, pin_t mosi, pin_t cs, pin_t reset = U8G_PIN_NONE) {
71
+    U8GLIB::init(&u8g_dev_st7920_128x64_rrd_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, U8G_PIN_NONE, (uint8_t)reset);   // a0 = U8G_PIN_NONE
72
+  }
65 73
 };
66 74
 
67 75
 extern u8g_dev_t u8g_dev_sh1106_128x64_2x_i2c_2_wire;
68 76
 
69 77
 class U8GLIB_SH1106_128X64_2X_I2C_2_WIRE : public U8GLIB {
70 78
 public:
71
-  U8GLIB_SH1106_128X64_2X_I2C_2_WIRE(uint8_t options = U8G_I2C_OPT_NONE)
72
-  : U8GLIB(&u8g_dev_sh1106_128x64_2x_i2c_2_wire, options)
73
-  {  }
79
+  U8GLIB_SH1106_128X64_2X_I2C_2_WIRE() : U8GLIB() { }
80
+  U8GLIB_SH1106_128X64_2X_I2C_2_WIRE(uint8_t options) { init(options); }
81
+  void init(uint8_t options = U8G_I2C_OPT_NONE) { U8GLIB::init(&u8g_dev_sh1106_128x64_2x_i2c_2_wire, options); }
74 82
 };
75 83
 
76 84
 extern u8g_dev_t u8g_dev_ssd1306_128x64_2x_i2c_2_wire;
77 85
 
78 86
 class U8GLIB_SSD1306_128X64_2X_I2C_2_WIRE : public U8GLIB {
79 87
 public:
80
-  U8GLIB_SSD1306_128X64_2X_I2C_2_WIRE(uint8_t options = U8G_I2C_OPT_NONE)
81
-  : U8GLIB(&u8g_dev_ssd1306_128x64_2x_i2c_2_wire, options)
82
-  {  }
88
+  U8GLIB_SSD1306_128X64_2X_I2C_2_WIRE() : U8GLIB() { }
89
+  U8GLIB_SSD1306_128X64_2X_I2C_2_WIRE(uint8_t options) { init(options); }
90
+  void init(uint8_t options = U8G_I2C_OPT_NONE) { U8GLIB::init(&u8g_dev_ssd1306_128x64_2x_i2c_2_wire, options); }
83 91
 };
84 92
 
85 93
 //
@@ -90,9 +98,9 @@ extern u8g_dev_t u8g_dev_tft_320x240_upscale_from_128x64;
90 98
 
91 99
 class U8GLIB_TFT_320X240_UPSCALE_FROM_128X64 : public U8GLIB {
92 100
 public:
93
-  U8GLIB_TFT_320X240_UPSCALE_FROM_128X64(uint8_t cs, uint8_t rs, uint8_t reset = U8G_PIN_NONE)
94
-  : U8GLIB(&u8g_dev_tft_320x240_upscale_from_128x64, cs, rs, reset)
95
-  { }
101
+  U8GLIB_TFT_320X240_UPSCALE_FROM_128X64() : U8GLIB() { }
102
+  U8GLIB_TFT_320X240_UPSCALE_FROM_128X64(uint8_t cs, uint8_t rs, uint8_t reset = U8G_PIN_NONE) { init(cs, rs, reset); }
103
+  void init(uint8_t cs, uint8_t rs, uint8_t reset = U8G_PIN_NONE) { U8GLIB::init(&u8g_dev_tft_320x240_upscale_from_128x64, cs, rs, reset); }
96 104
 };
97 105
 
98 106
 
@@ -100,12 +108,15 @@ extern u8g_dev_t u8g_dev_uc1701_mini12864_HAL_2x_sw_spi, u8g_dev_uc1701_mini1286
100 108
 
101 109
 class U8GLIB_MINI12864_2X_HAL : public U8GLIB {
102 110
 public:
103
-  U8GLIB_MINI12864_2X_HAL(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
104
-    : U8GLIB(&u8g_dev_uc1701_mini12864_HAL_2x_sw_spi, sck, mosi, cs, a0, reset)
105
-    { }
106
-  U8GLIB_MINI12864_2X_HAL(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
107
-    : U8GLIB(&u8g_dev_uc1701_mini12864_HAL_2x_hw_spi, cs, a0, reset)
108
-    { }
111
+  U8GLIB_MINI12864_2X_HAL() : U8GLIB() { }
112
+  U8GLIB_MINI12864_2X_HAL(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) { init(sck, mosi, cs, a0, reset); }
113
+  U8GLIB_MINI12864_2X_HAL(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) { init(cs, a0, reset); }
114
+  void init(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) {
115
+    U8GLIB::init(&u8g_dev_uc1701_mini12864_HAL_2x_sw_spi, sck, mosi, cs, a0, reset);
116
+  }
117
+  void init(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) {
118
+    U8GLIB::init(&u8g_dev_uc1701_mini12864_HAL_2x_hw_spi, cs, a0, reset);
119
+  }
109 120
 };
110 121
 
111 122
 extern u8g_dev_t u8g_dev_ssd1309_sw_spi;
@@ -113,10 +124,13 @@ extern u8g_dev_t u8g_dev_ssd1309_hw_spi;
113 124
 
114 125
 class U8GLIB_SSD1309_128X64_HAL : public U8GLIB {
115 126
 public:
116
-  U8GLIB_SSD1309_128X64_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE)
117
-    : U8GLIB(&u8g_dev_ssd1309_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset)
118
-    { }
119
-  U8GLIB_SSD1309_128X64_HAL(pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE)
120
-    : U8GLIB(&u8g_dev_ssd1309_hw_spi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset)
121
-    { }
127
+  U8GLIB_SSD1309_128X64_HAL() : U8GLIB() { }
128
+  U8GLIB_SSD1309_128X64_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) { init(sck, mosi, cs, a0, reset); }
129
+  U8GLIB_SSD1309_128X64_HAL(pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) { init(cs, a0, reset); }
130
+  void init(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) {
131
+    U8GLIB::init(&u8g_dev_ssd1309_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset);
132
+  }
133
+  void init(pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) {
134
+    U8GLIB::init(&u8g_dev_ssd1309_hw_spi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset);
135
+  }
122 136
 };

+ 8
- 1
Marlin/src/lcd/dogm/marlinui_DOGM.cpp 查看文件

@@ -76,7 +76,7 @@
76 76
   #define FONT_STATUSMENU_NAME MENU_FONT_NAME
77 77
 #endif
78 78
 
79
-U8G_CLASS u8g(U8G_PARAM);
79
+U8G_CLASS u8g;
80 80
 
81 81
 #include LANGUAGE_DATA_INCL(LCD_LANGUAGE)
82 82
 
@@ -252,6 +252,13 @@ bool MarlinUI::detected() { return true; }
252 252
 
253 253
 // Initialize or re-initialize the LCD
254 254
 void MarlinUI::init_lcd() {
255
+
256
+  static bool did_init_u8g = false;
257
+  if (!did_init_u8g) {
258
+    u8g.init(U8G_PARAM);
259
+    did_init_u8g = true;
260
+  }
261
+
255 262
   #if PIN_EXISTS(LCD_BACKLIGHT)
256 263
     OUT_WRITE(LCD_BACKLIGHT_PIN, DISABLED(DELAYED_BACKLIGHT_INIT)); // Illuminate after reset or right away
257 264
   #endif

+ 1
- 1
ini/features.ini 查看文件

@@ -35,7 +35,7 @@ USES_LIQUIDCRYSTAL_I2C  = marcoschwartz/LiquidCrystal_I2C@1.1.4
35 35
 USES_LIQUIDTWI2         = LiquidTWI2@1.2.7
36 36
 HAS_WIRED_LCD           = src_filter=+<src/lcd/lcdprint.cpp>
37 37
 HAS_MARLINUI_HD44780    = src_filter=+<src/lcd/HD44780>
38
-HAS_MARLINUI_U8GLIB     = U8glib-HAL@~0.4.1
38
+HAS_MARLINUI_U8GLIB     = U8glib-HAL@~0.4.4
39 39
                           src_filter=+<src/lcd/dogm>
40 40
 HAS_(FSMC|SPI|LTDC)_TFT = src_filter=+<src/HAL/STM32/tft> +<src/HAL/STM32F1/tft> +<src/lcd/tft_io>
41 41
 HAS_FSMC_TFT            = src_filter=+<src/HAL/STM32/tft/tft_fsmc.cpp> +<src/HAL/STM32F1/tft/tft_fsmc.cpp>

Loading…
取消
儲存