Browse Source

Merge pull request #5389 from thinkyhead/distribute_screen_updates

Distribute GLCD screen updates in time
Scott Lahteine 8 years ago
parent
commit
6253b765aa
3 changed files with 59 additions and 43 deletions
  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 View File

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 View File

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 View File

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…
Cancel
Save