소스 검색

Distribute GLCD screen updates in time

Currently we draw and send the screens for a graphical LCD all at once.
We draw in two or four parts but draw them directly behind each other.
For the tested status screen this takes 59-62ms in a single block.
During this time nothing else (except the interrupts) can be done.
When printing a sequence of very short moves the buffer drains - sometimes until it's empty.

This PR splits the screen update into parts.
Currently we have 10 time slots. During the first one the complete screen is drawn. (60,0,0,0,0,0,0,0,0,0,0)
Here i introduce pauses for doing other things. (30,30,0,0,0,0,0,0) or (15,15,15,15,0,0,0,0,0,0)
Drawing in consecutive time slots prevents from lagging too much. Even with a 4 stripe display all the drawing is done after 400ms.
Previous experiments with a even better distribution of the time slots like
(30,0,0,0,0,30,0,0,0,0) and (15,0,15,0,15,0,15,0,0,0) did not feel good when using the menu, because of too much lag.

Because of the previous PRs to speed up the display updates and especially reducing the difference between drawing 2 or 4 stripes,
it now makes sense for the REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER to go from 2 to 4 stripes. This costs about 1-2ms per complete
screen update, but is payed back by having partial updates lasting only the half time and two additional brakes. Also ~256 byte of
framebuffer are saved in RAM.

13:45:59.213 : echo: #:17 >:13 s:30;   #:16 >:13 s:29;   S#:33 S>:26 S:59
13:46:00.213 : echo: #:16 >:14 s:30;   #:17 >:13 s:30;   S#:33 S>:27 S:60
13:46:01.215 : echo: #:17 >:13 s:30;   #:16 >:13 s:29;   S#:33 S>:26 S:59
13:46:02.215 : echo: #:16 >:13 s:29;   #:16 >:14 s:30;   S#:32 S>:27 S:59
13:46:03.214 : echo: #:17 >:13 s:30;   #:17 >:13 s:30;   S#:34 S>:26 S:60
13:46:04.214 : echo: #:16 >:13 s:29;   #:16 >:14 s:30;   S#:32 S>:27 S:59
13:46:05.212 : echo: #:16 >:14 s:30;   #:17 >:13 s:30;   S#:33 S>:27 S:60
13:46:06.212 : echo: #:17 >:13 s:30;   #:16 >:13 s:29;   S#:33 S>:26 S:59

03:30:36.779 : echo: #:8 >:7 s:15;   #:10 >:7 s:17;   #:8 >:6 s:14;   #:8 >:7 s:15;   S#:34 S>:27 S:61
03:30:37.778 : echo: #:8 >:6 s:14;   #:10 >:7 s:17;   #:9 >:7 s:16;   #:8 >:6 s:14;   S#:35 S>:26 S:61
03:30:38.778 : echo: #:8 >:6 s:14;   #:11 >:7 s:18;   #:8 >:6 s:14;   #:8 >:7 s:15;   S#:35 S>:26 S:61
03:30:39.777 : echo: #:8 >:6 s:14;   #:10 >:7 s:17;   #:8 >:8 s:16;   #:8 >:6 s:14;   S#:34 S>:27 S:61
03:30:40.780 : echo: #:8 >:6 s:14;   #:11 >:7 s:18;   #:8 >:6 s:14;   #:8 >:6 s:14;   S#:35 S>:25 S:60
03:30:41.780 : echo: #:9 >:6 s:15;   #:10 >:7 s:17;   #:8 >:6 s:14;   #:9 >:6 s:15;   S#:36 S>:25 S:61
03:30:42.779 : echo: #:8 >:6 s:14;   #:10 >:8 s:18;   #:8 >:6 s:14;   #:8 >:6 s:14;   S#:34 S>:26 S:60
03:30:43.778 : echo: #:9 >:6 s:15;   #:10 >:7 s:17;   #:8 >:7 s:15;   #:9 >:6 s:15;   S#:36 S>:26 S:62

#: draw a stripe
>: transfer a stripe
s: sum of of draw and transfer for one stripe
S#: sum of draws for a complete screen
S>: sum of transfers for a complete screen
S: time to draw and transfer a complete screen
AnHardt 7 년 전
부모
커밋
a6fbd4a5d8
3개의 변경된 파일59개의 추가작업 그리고 43개의 파일을 삭제
  1. 56
    40
      Marlin/ultralcd.cpp
  2. 1
    1
      Marlin/ultralcd_impl_DOGM.h
  3. 2
    2
      Marlin/ultralcd_st7920_u8glib_rrd.h

+ 56
- 40
Marlin/ultralcd.cpp 파일 보기

64
 millis_t next_lcd_update_ms;
64
 millis_t next_lcd_update_ms;
65
 
65
 
66
 uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to draw, decrements after every draw. Set to 2 in LCD routines so the LCD gets at least 1 full redraw (first redraw is partial)
66
 uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to draw, decrements after every draw. Set to 2 in LCD routines so the LCD gets at least 1 full redraw (first redraw is partial)
67
+#if ENABLED(DOGLCD)
68
+  bool drawing_screen = false;
69
+#endif
67
 
70
 
68
 #if ENABLED(DAC_STEPPER_CURRENT)
71
 #if ENABLED(DAC_STEPPER_CURRENT)
69
   #include "stepper_dac.h" //was dac_mcp4728.h MarlinMain uses stepper dac for the m-codes
72
   #include "stepper_dac.h" //was dac_mcp4728.h MarlinMain uses stepper dac for the m-codes
413
       #endif
416
       #endif
414
       lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
417
       lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
415
       screen_changed = true;
418
       screen_changed = true;
419
+      #if ENABLED(DOGLCD)
420
+        drawing_screen = false;
421
+      #endif
416
     }
422
     }
417
   }
423
   }
418
 
424
 
2832
 
2838
 
2833
           encoderPosition += (encoderDiff * encoderMultiplier) / ENCODER_PULSES_PER_STEP;
2839
           encoderPosition += (encoderDiff * encoderMultiplier) / ENCODER_PULSES_PER_STEP;
2834
           encoderDiff = 0;
2840
           encoderDiff = 0;
2841
+          #if ENABLED(DOGLCD)
2842
+            drawing_screen = false;  // refresh the complete screen for a encoder change (different menu-item/value)
2843
+          #endif
2835
         }
2844
         }
2836
         return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS;
2845
         return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS;
2837
         lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
2846
         lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
2864
 
2873
 
2865
     if (LCD_HANDLER_CONDITION) {
2874
     if (LCD_HANDLER_CONDITION) {
2866
 
2875
 
2867
-      if (lcdDrawUpdate) {
2868
-
2869
-        switch (lcdDrawUpdate) {
2870
-          case LCDVIEW_CALL_NO_REDRAW:
2871
-            lcdDrawUpdate = LCDVIEW_NONE;
2872
-            break;
2873
-          case LCDVIEW_CLEAR_CALL_REDRAW: // set by handlers, then altered after (rarely occurs here)
2874
-          case LCDVIEW_CALL_REDRAW_NEXT:  // set by handlers, then altered after (never occurs here?)
2875
-            lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
2876
-          case LCDVIEW_REDRAW_NOW:        // set above, or by a handler through LCDVIEW_CALL_REDRAW_NEXT
2877
-          case LCDVIEW_NONE:
2878
-            break;
2879
-        } // switch
2880
-
2876
+      #if ENABLED(DOGLCD)
2877
+        if (lcdDrawUpdate || drawing_screen)
2878
+      #else
2879
+        if (lcdDrawUpdate)
2880
+      #endif
2881
+      {
2882
+        #if ENABLED(DOGLCD)
2883
+          if (!drawing_screen)
2884
+        #endif
2885
+          {
2886
+            switch (lcdDrawUpdate) {
2887
+              case LCDVIEW_CALL_NO_REDRAW:
2888
+                lcdDrawUpdate = LCDVIEW_NONE;
2889
+                break;
2890
+              case LCDVIEW_CLEAR_CALL_REDRAW: // set by handlers, then altered after (rarely occurs here)
2891
+              case LCDVIEW_CALL_REDRAW_NEXT:  // set by handlers, then altered after (never occurs here?)
2892
+                lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
2893
+              case LCDVIEW_REDRAW_NOW:        // set above, or by a handler through LCDVIEW_CALL_REDRAW_NEXT
2894
+              case LCDVIEW_NONE:
2895
+                break;
2896
+            } // switch
2897
+          }
2881
         #if ENABLED(ULTIPANEL)
2898
         #if ENABLED(ULTIPANEL)
2882
           #define CURRENTSCREEN() (*currentScreen)(), lcd_clicked = false
2899
           #define CURRENTSCREEN() (*currentScreen)(), lcd_clicked = false
2883
         #else
2900
         #else
2885
         #endif
2902
         #endif
2886
 
2903
 
2887
         #if ENABLED(DOGLCD)  // Changes due to different driver architecture of the DOGM display
2904
         #if ENABLED(DOGLCD)  // Changes due to different driver architecture of the DOGM display
2888
-          static int8_t dot_color = 0;
2889
-          dot_color = 1 - dot_color;
2890
-          u8g.firstPage();
2891
-          do {
2892
-            lcd_setFont(FONT_MENU);
2893
-            u8g.setPrintPos(125, 0);
2894
-            u8g.setColorIndex(dot_color); // Set color for the alive dot
2895
-            u8g.drawPixel(127, 63); // draw alive dot
2896
-            u8g.setColorIndex(1); // black on white
2897
-            CURRENTSCREEN();
2898
-          } while (u8g.nextPage());
2905
+          if (!drawing_screen) {
2906
+            u8g.firstPage();
2907
+            drawing_screen = 1;
2908
+          }
2909
+          lcd_setFont(FONT_MENU);
2910
+          CURRENTSCREEN();
2911
+          if (drawing_screen && (drawing_screen = u8g.nextPage())) return;
2899
         #else
2912
         #else
2900
           CURRENTSCREEN();
2913
           CURRENTSCREEN();
2901
         #endif
2914
         #endif
2911
 
2924
 
2912
       #endif // ULTIPANEL
2925
       #endif // ULTIPANEL
2913
 
2926
 
2914
-      switch (lcdDrawUpdate) {
2915
-        case LCDVIEW_CLEAR_CALL_REDRAW:
2916
-          lcd_implementation_clear();
2917
-        case LCDVIEW_CALL_REDRAW_NEXT:
2918
-          lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
2919
-          break;
2920
-        case LCDVIEW_REDRAW_NOW:
2921
-          lcdDrawUpdate = LCDVIEW_NONE;
2922
-          break;
2923
-        case LCDVIEW_NONE:
2924
-          break;
2925
-      } // switch
2926
-
2927
+      #if ENABLED(DOGLCD)
2928
+        if (!drawing_screen)
2929
+      #endif
2930
+        {
2931
+          switch (lcdDrawUpdate) {
2932
+            case LCDVIEW_CLEAR_CALL_REDRAW:
2933
+              lcd_implementation_clear();
2934
+            case LCDVIEW_CALL_REDRAW_NEXT:
2935
+              lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
2936
+              break;
2937
+            case LCDVIEW_REDRAW_NOW:
2938
+              lcdDrawUpdate = LCDVIEW_NONE;
2939
+              break;
2940
+            case LCDVIEW_NONE:
2941
+              break;
2942
+          } // switch
2943
+        }
2927
     } // LCD_HANDLER_CONDITION
2944
     } // LCD_HANDLER_CONDITION
2928
-
2929
-  }
2945
+  } // ELAPSED(ms, next_lcd_update_ms)
2930
 }
2946
 }
2931
 
2947
 
2932
 void set_utf_strlen(char* s, uint8_t n) {
2948
 void set_utf_strlen(char* s, uint8_t n) {

+ 1
- 1
Marlin/ultralcd_impl_DOGM.h 파일 보기

145
 #elif ENABLED(U8GLIB_ST7920)
145
 #elif ENABLED(U8GLIB_ST7920)
146
   //U8GLIB_ST7920_128X64_4X u8g(LCD_PINS_D4, LCD_PINS_ENABLE, LCD_PINS_RS); // Original u8glib device. 2 stripes
146
   //U8GLIB_ST7920_128X64_4X u8g(LCD_PINS_D4, LCD_PINS_ENABLE, LCD_PINS_RS); // Original u8glib device. 2 stripes
147
                                                                             // No 4 stripe device available from u8glib.
147
                                                                             // No 4 stripe device available from u8glib.
148
-  //U8GLIB_ST7920_128X64 u8g(LCD_PINS_D4, LCD_PINS_ENABLE, LCD_PINS_RS);    // Original u8glib device. 8 stripes
148
+  //U8GLIB_ST7920_128X64_1X u8g(LCD_PINS_D4, LCD_PINS_ENABLE, LCD_PINS_RS);    // Original u8glib device. 8 stripes
149
   U8GLIB_ST7920_128X64_RRD u8g(0); // Number of stripes can be adjusted in ultralcd_st7920_u8glib_rrd.h with PAGE_HEIGHT
149
   U8GLIB_ST7920_128X64_RRD u8g(0); // Number of stripes can be adjusted in ultralcd_st7920_u8glib_rrd.h with PAGE_HEIGHT
150
 #elif ENABLED(CARTESIO_UI)
150
 #elif ENABLED(CARTESIO_UI)
151
   // The CartesioUI display
151
   // The CartesioUI display

+ 2
- 2
Marlin/ultralcd_st7920_u8glib_rrd.h 파일 보기

32
 #define ST7920_CS_PIN   LCD_PINS_RS
32
 #define ST7920_CS_PIN   LCD_PINS_RS
33
 
33
 
34
 //#define PAGE_HEIGHT 8   //128 byte framebuffer
34
 //#define PAGE_HEIGHT 8   //128 byte framebuffer
35
-//#define PAGE_HEIGHT 16  //256 byte framebuffer
36
-#define PAGE_HEIGHT 32  //512 byte framebuffer
35
+#define PAGE_HEIGHT 16  //256 byte framebuffer
36
+//#define PAGE_HEIGHT 32  //512 byte framebuffer
37
 
37
 
38
 #define LCD_PIXEL_WIDTH 128
38
 #define LCD_PIXEL_WIDTH 128
39
 #define LCD_PIXEL_HEIGHT 64
39
 #define LCD_PIXEL_HEIGHT 64

Loading…
취소
저장