Quellcode durchsuchen

Fix up boot screen code

Followup to #15125

Co-Authored-By: Ludy <ludy87@users.noreply.github.com>
Scott Lahteine vor 5 Jahren
Ursprung
Commit
7ad5208267
1 geänderte Dateien mit 16 neuen und 16 gelöschten Zeilen
  1. 16
    16
      Marlin/src/lcd/dogm/ultralcd_DOGM.cpp

+ 16
- 16
Marlin/src/lcd/dogm/ultralcd_DOGM.cpp Datei anzeigen

@@ -159,9 +159,13 @@ bool MarlinUI::detected() { return true; }
159 159
     }
160 160
   #endif // SHOW_CUSTOM_BOOTSCREEN
161 161
 
162
+  // Two-part needed to display all info
163
+  constexpr bool two_part = ((LCD_PIXEL_HEIGHT) - (START_BMPHEIGHT)) < ((MENU_FONT_ASCENT) * 2);
164
+
162 165
   // Draw the static Marlin bootscreen from a u8g loop
163 166
   // or the animated boot screen within its own u8g loop
164 167
   void MarlinUI::draw_marlin_bootscreen(const bool line2/*=false*/) {
168
+
165 169
     // Determine text space needed
166 170
     constexpr u8g_uint_t text_width_1 = u8g_uint_t((sizeof(SHORT_BUILD_VERSION) - 1) * (MENU_FONT_WIDTH)),
167 171
                          text_width_2 = u8g_uint_t((sizeof(MARLIN_WEBSITE_URL) - 1) * (MENU_FONT_WIDTH)),
@@ -169,7 +173,6 @@ bool MarlinUI::detected() { return true; }
169 173
                          text_total_height = (MENU_FONT_HEIGHT) * 2,
170 174
                          width = LCD_PIXEL_WIDTH, height = LCD_PIXEL_HEIGHT,
171 175
                          rspace = width - (START_BMPWIDTH);
172
-    constexpr bool two_part = (height - (START_BMPHEIGHT)) < ((MENU_FONT_ASCENT) * 2);
173 176
 
174 177
     u8g_int_t offx, offy, txt_base, txt_offx_1, txt_offx_2;
175 178
 
@@ -192,41 +195,38 @@ bool MarlinUI::detected() { return true; }
192 195
     NOLESS(offx, 0);
193 196
     NOLESS(offy, 0);
194 197
 
195
-    auto draw_bootscreen_bmp = [&](const uint8_t *bitmap) {
198
+    auto _draw_bootscreen_bmp = [&](const uint8_t *bitmap) {
196 199
       u8g.drawBitmapP(offx, offy, START_BMP_BYTEWIDTH, START_BMPHEIGHT, bitmap);
197 200
       set_font(FONT_MENU);
198 201
       if (!two_part || !line2) lcd_put_u8str_P(txt_offx_1, txt_base - (MENU_FONT_HEIGHT), PSTR(SHORT_BUILD_VERSION));
199 202
       if (!two_part || line2) lcd_put_u8str_P(txt_offx_2, txt_base, PSTR(MARLIN_WEBSITE_URL));
200 203
     };
201 204
 
205
+    auto draw_bootscreen_bmp = [&](const uint8_t *bitmap) {
206
+      u8g.firstPage(); do { _draw_bootscreen_bmp(bitmap); } while (u8g.nextPage());
207
+    };
208
+
202 209
     #if DISABLED(BOOT_MARLIN_LOGO_ANIMATED)
203 210
       draw_bootscreen_bmp(start_bmp);
204 211
     #else
205 212
       constexpr millis_t d = MARLIN_BOOTSCREEN_FRAME_TIME;
206 213
       LOOP_L_N(f, COUNT(marlin_bootscreen_animation)) {
207
-        u8g.firstPage();
208
-        do {
209
-          const u8g_pgm_uint8_t * const bmp = (u8g_pgm_uint8_t*)pgm_read_ptr(&marlin_bootscreen_animation[f]);
210
-          draw_bootscreen_bmp(bmp);
211
-        } while (u8g.nextPage());
214
+        const u8g_pgm_uint8_t * const bmp = (u8g_pgm_uint8_t*)pgm_read_ptr(&marlin_bootscreen_animation[f]);
215
+        draw_bootscreen_bmp(bmp);
212 216
         if (d) safe_delay(d);
213 217
       }
214 218
     #endif
215 219
   }
216 220
 
217
-  // Shows the Marlin bootscreen, with the u8g loop and delays
221
+  // Show the Marlin bootscreen, with the u8g loop and delays
218 222
   void MarlinUI::show_marlin_bootscreen() {
219 223
     #ifndef BOOTSCREEN_TIMEOUT
220 224
       #define BOOTSCREEN_TIMEOUT 2500
221 225
     #endif
222
-    for (uint8_t q = 2; q--;) {
223
-      #if DISABLED(BOOT_MARLIN_LOGO_ANIMATED)
224
-        u8g.firstPage();
225
-        do { draw_marlin_bootscreen(q == 0); } while (u8g.nextPage());
226
-      #else
227
-        draw_marlin_bootscreen(q == 0);
228
-      #endif
229
-      safe_delay((BOOTSCREEN_TIMEOUT) / 2);
226
+    constexpr uint8_t pages = two_part ? 2 : 1;
227
+    for (uint8_t q = pages; q--;) {
228
+      draw_marlin_bootscreen(q == 0);
229
+      safe_delay((BOOTSCREEN_TIMEOUT) / pages);
230 230
     }
231 231
   }
232 232
 

Laden…
Abbrechen
Speichern