Browse Source

Draw content in display loop only when needed

Example for splash screen.
AnHardt 9 years ago
parent
commit
bf04a92cc0
1 changed files with 20 additions and 13 deletions
  1. 20
    13
      Marlin/dogm_lcd_implementation.h

+ 20
- 13
Marlin/dogm_lcd_implementation.h View File

@@ -186,7 +186,7 @@ char lcd_printPGM(const char* str) {
186 186
   return n;
187 187
 }
188 188
 
189
-static int8_t show_splashscreed = 2;
189
+int8_t show_splashscreen = 2;
190 190
 
191 191
 static void lcd_implementation_init()
192 192
 {
@@ -221,18 +221,25 @@ static void lcd_implementation_init()
221 221
 
222 222
 	u8g.firstPage();
223 223
 	do {
224
-    if (show_splashscreed) {
225
-      u8g.drawBitmapP(offx, offy, START_BMPBYTEWIDTH, START_BMPHEIGHT, start_bmp);
226
-      lcd_setFont(FONT_MENU);
227
-      #ifndef STRING_SPLASH_LINE2
228
-        u8g.drawStr(txt1X, u8g.getHeight() - DOG_CHAR_HEIGHT, STRING_SPLASH_LINE1);
229
-      #else
230
-        int txt2X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE2) - 1)*DOG_CHAR_WIDTH) / 2;
231
-        u8g.drawStr(txt1X, u8g.getHeight() - DOG_CHAR_HEIGHT*3/2, STRING_SPLASH_LINE1);
232
-        u8g.drawStr(txt2X, u8g.getHeight() - DOG_CHAR_HEIGHT*1/2, STRING_SPLASH_LINE2);
233
-      #endif
234
-      show_splashscreed--;
235
-    }
224
+    switch (show_splashscreen) {
225
+      case 2 : {
226
+        u8g.drawBitmapP(offx, offy, START_BMPBYTEWIDTH, START_BMPHEIGHT, start_bmp);
227
+        break;
228
+      }
229
+      case 1 : {
230
+        lcd_setFont(FONT_MENU);
231
+        #ifndef STRING_SPLASH_LINE2
232
+          u8g.drawStr(txt1X, u8g.getHeight() - DOG_CHAR_HEIGHT, STRING_SPLASH_LINE1);
233
+        #else
234
+          int txt2X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE2) - 1)*DOG_CHAR_WIDTH) / 2;
235
+          u8g.drawStr(txt1X, u8g.getHeight() - DOG_CHAR_HEIGHT*3/2, STRING_SPLASH_LINE1);
236
+          u8g.drawStr(txt2X, u8g.getHeight() - DOG_CHAR_HEIGHT*1/2, STRING_SPLASH_LINE2);
237
+        #endif
238
+        break;
239
+      }
240
+      break;  
241
+    }  
242
+    if (show_splashscreen) show_splashscreen--;
236 243
 	} while (u8g.nextPage());
237 244
 }
238 245
 

Loading…
Cancel
Save