Browse Source

Fix up boot screen code

Followup to #15125

Co-Authored-By: Ludy <ludy87@users.noreply.github.com>
Scott Lahteine 5 years ago
parent
commit
7ad5208267
1 changed files with 16 additions and 16 deletions
  1. 16
    16
      Marlin/src/lcd/dogm/ultralcd_DOGM.cpp

+ 16
- 16
Marlin/src/lcd/dogm/ultralcd_DOGM.cpp View File

159
     }
159
     }
160
   #endif // SHOW_CUSTOM_BOOTSCREEN
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
   // Draw the static Marlin bootscreen from a u8g loop
165
   // Draw the static Marlin bootscreen from a u8g loop
163
   // or the animated boot screen within its own u8g loop
166
   // or the animated boot screen within its own u8g loop
164
   void MarlinUI::draw_marlin_bootscreen(const bool line2/*=false*/) {
167
   void MarlinUI::draw_marlin_bootscreen(const bool line2/*=false*/) {
168
+
165
     // Determine text space needed
169
     // Determine text space needed
166
     constexpr u8g_uint_t text_width_1 = u8g_uint_t((sizeof(SHORT_BUILD_VERSION) - 1) * (MENU_FONT_WIDTH)),
170
     constexpr u8g_uint_t text_width_1 = u8g_uint_t((sizeof(SHORT_BUILD_VERSION) - 1) * (MENU_FONT_WIDTH)),
167
                          text_width_2 = u8g_uint_t((sizeof(MARLIN_WEBSITE_URL) - 1) * (MENU_FONT_WIDTH)),
171
                          text_width_2 = u8g_uint_t((sizeof(MARLIN_WEBSITE_URL) - 1) * (MENU_FONT_WIDTH)),
169
                          text_total_height = (MENU_FONT_HEIGHT) * 2,
173
                          text_total_height = (MENU_FONT_HEIGHT) * 2,
170
                          width = LCD_PIXEL_WIDTH, height = LCD_PIXEL_HEIGHT,
174
                          width = LCD_PIXEL_WIDTH, height = LCD_PIXEL_HEIGHT,
171
                          rspace = width - (START_BMPWIDTH);
175
                          rspace = width - (START_BMPWIDTH);
172
-    constexpr bool two_part = (height - (START_BMPHEIGHT)) < ((MENU_FONT_ASCENT) * 2);
173
 
176
 
174
     u8g_int_t offx, offy, txt_base, txt_offx_1, txt_offx_2;
177
     u8g_int_t offx, offy, txt_base, txt_offx_1, txt_offx_2;
175
 
178
 
192
     NOLESS(offx, 0);
195
     NOLESS(offx, 0);
193
     NOLESS(offy, 0);
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
       u8g.drawBitmapP(offx, offy, START_BMP_BYTEWIDTH, START_BMPHEIGHT, bitmap);
199
       u8g.drawBitmapP(offx, offy, START_BMP_BYTEWIDTH, START_BMPHEIGHT, bitmap);
197
       set_font(FONT_MENU);
200
       set_font(FONT_MENU);
198
       if (!two_part || !line2) lcd_put_u8str_P(txt_offx_1, txt_base - (MENU_FONT_HEIGHT), PSTR(SHORT_BUILD_VERSION));
201
       if (!two_part || !line2) lcd_put_u8str_P(txt_offx_1, txt_base - (MENU_FONT_HEIGHT), PSTR(SHORT_BUILD_VERSION));
199
       if (!two_part || line2) lcd_put_u8str_P(txt_offx_2, txt_base, PSTR(MARLIN_WEBSITE_URL));
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
     #if DISABLED(BOOT_MARLIN_LOGO_ANIMATED)
209
     #if DISABLED(BOOT_MARLIN_LOGO_ANIMATED)
203
       draw_bootscreen_bmp(start_bmp);
210
       draw_bootscreen_bmp(start_bmp);
204
     #else
211
     #else
205
       constexpr millis_t d = MARLIN_BOOTSCREEN_FRAME_TIME;
212
       constexpr millis_t d = MARLIN_BOOTSCREEN_FRAME_TIME;
206
       LOOP_L_N(f, COUNT(marlin_bootscreen_animation)) {
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
         if (d) safe_delay(d);
216
         if (d) safe_delay(d);
213
       }
217
       }
214
     #endif
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
   void MarlinUI::show_marlin_bootscreen() {
222
   void MarlinUI::show_marlin_bootscreen() {
219
     #ifndef BOOTSCREEN_TIMEOUT
223
     #ifndef BOOTSCREEN_TIMEOUT
220
       #define BOOTSCREEN_TIMEOUT 2500
224
       #define BOOTSCREEN_TIMEOUT 2500
221
     #endif
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
 

Loading…
Cancel
Save