Browse Source

Adjust ENSURE_SMOOTH_MOVES coding style

Scott Lahteine 8 years ago
parent
commit
2cc32d85a3
2 changed files with 75 additions and 71 deletions
  1. 1
    1
      Marlin/planner.h
  2. 74
    70
      Marlin/ultralcd.cpp

+ 1
- 1
Marlin/planner.h View File

@@ -374,7 +374,7 @@ class Planner {
374 374
       static bool long_move() {
375 375
         if (blocks_queued()) {
376 376
           block_t* block = &block_buffer[block_buffer_tail];
377
-          return (block->segment_time > (LCD_UPDATE_THRESHOLD * 1000UL));
377
+          return block->segment_time > (LCD_UPDATE_THRESHOLD) * 1000UL;
378 378
         }
379 379
         else
380 380
           return true;

+ 74
- 70
Marlin/ultralcd.cpp View File

@@ -2707,90 +2707,94 @@ void lcd_update() {
2707 2707
       }
2708 2708
     #endif // ULTIPANEL
2709 2709
 
2710
-    // We arrive here every ~100ms when idling often enough.
2711
-    // Instead of tracking the changes simply redraw the Info Screen ~1 time a second.
2712
-    static int8_t lcd_status_update_delay = 1; // first update one loop delayed
2713
-    #if ENABLED(ENSURE_SMOOTH_MOVES) && ENABLED(ALWAYS_ALLOW_MENU)
2714
-      if (planner.long_move()) {
2715
-    #endif
2716
-        if (
2717
-          #if ENABLED(ULTIPANEL)
2718
-            currentScreen == lcd_status_screen &&
2719
-          #endif
2720
-            !lcd_status_update_delay--) {
2721
-          lcd_status_update_delay = 9;
2722
-          lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
2723
-        }
2724 2710
     #if ENABLED(ENSURE_SMOOTH_MOVES) && ENABLED(ALWAYS_ALLOW_MENU)
2725
-      }
2711
+      #define STATUS_UPDATE_CONDITION planner.long_move()
2712
+    #else
2713
+      #define STATUS_UPDATE_CONDITION true
2726 2714
     #endif
2727
-
2728 2715
     #if ENABLED(ENSURE_SMOOTH_MOVES) && DISABLED(ALWAYS_ALLOW_MENU)
2729
-      if (planner.long_move()) {
2716
+      #define LCD_HANDLER_CONDITION planner.long_move()
2717
+    #else
2718
+      #define LCD_HANDLER_CONDITION true
2730 2719
     #endif
2731
-    if (lcdDrawUpdate) {
2732
-
2733
-      switch (lcdDrawUpdate) {
2734
-        case LCDVIEW_CALL_NO_REDRAW:
2735
-          lcdDrawUpdate = LCDVIEW_NONE;
2736
-          break;
2737
-        case LCDVIEW_CLEAR_CALL_REDRAW: // set by handlers, then altered after (rarely occurs here)
2738
-        case LCDVIEW_CALL_REDRAW_NEXT:  // set by handlers, then altered after (never occurs here?)
2739
-          lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
2740
-        case LCDVIEW_REDRAW_NOW:        // set above, or by a handler through LCDVIEW_CALL_REDRAW_NEXT
2741
-        case LCDVIEW_NONE:
2742
-          break;
2743
-      }
2744 2720
 
2721
+    // We arrive here every ~100ms when idling often enough.
2722
+    // Instead of tracking the changes simply redraw the Info Screen ~1 time a second.
2723
+    static int8_t lcd_status_update_delay = 1; // first update one loop delayed
2724
+    if (STATUS_UPDATE_CONDITION &&
2745 2725
       #if ENABLED(ULTIPANEL)
2746
-        #define CURRENTSCREEN() (*currentScreen)(), lcd_clicked = false
2747
-      #else
2748
-        #define CURRENTSCREEN() lcd_status_screen()
2726
+        currentScreen == lcd_status_screen &&
2749 2727
       #endif
2728
+        !lcd_status_update_delay--
2729
+    ) {
2730
+      lcd_status_update_delay = 9;
2731
+      lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
2732
+    }
2733
+
2734
+    if (LCD_HANDLER_CONDITION) {
2750 2735
 
2751
-      #if ENABLED(DOGLCD)  // Changes due to different driver architecture of the DOGM display
2752
-        static int8_t dot_color = 0;
2753
-        dot_color = 1 - dot_color;
2754
-        u8g.firstPage();
2755
-        do {
2756
-          lcd_setFont(FONT_MENU);
2757
-          u8g.setPrintPos(125, 0);
2758
-          u8g.setColorIndex(dot_color); // Set color for the alive dot
2759
-          u8g.drawPixel(127, 63); // draw alive dot
2760
-          u8g.setColorIndex(1); // black on white
2736
+      if (lcdDrawUpdate) {
2737
+
2738
+        switch (lcdDrawUpdate) {
2739
+          case LCDVIEW_CALL_NO_REDRAW:
2740
+            lcdDrawUpdate = LCDVIEW_NONE;
2741
+            break;
2742
+          case LCDVIEW_CLEAR_CALL_REDRAW: // set by handlers, then altered after (rarely occurs here)
2743
+          case LCDVIEW_CALL_REDRAW_NEXT:  // set by handlers, then altered after (never occurs here?)
2744
+            lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
2745
+          case LCDVIEW_REDRAW_NOW:        // set above, or by a handler through LCDVIEW_CALL_REDRAW_NEXT
2746
+          case LCDVIEW_NONE:
2747
+            break;
2748
+        } // switch
2749
+
2750
+        #if ENABLED(ULTIPANEL)
2751
+          #define CURRENTSCREEN() (*currentScreen)(), lcd_clicked = false
2752
+        #else
2753
+          #define CURRENTSCREEN() lcd_status_screen()
2754
+        #endif
2755
+
2756
+        #if ENABLED(DOGLCD)  // Changes due to different driver architecture of the DOGM display
2757
+          static int8_t dot_color = 0;
2758
+          dot_color = 1 - dot_color;
2759
+          u8g.firstPage();
2760
+          do {
2761
+            lcd_setFont(FONT_MENU);
2762
+            u8g.setPrintPos(125, 0);
2763
+            u8g.setColorIndex(dot_color); // Set color for the alive dot
2764
+            u8g.drawPixel(127, 63); // draw alive dot
2765
+            u8g.setColorIndex(1); // black on white
2766
+            CURRENTSCREEN();
2767
+          } while (u8g.nextPage());
2768
+        #else
2761 2769
           CURRENTSCREEN();
2762
-        } while (u8g.nextPage());
2763
-      #else
2764
-        CURRENTSCREEN();
2765
-      #endif
2766
-    }
2770
+        #endif
2771
+      }
2767 2772
 
2768
-    #if ENABLED(ULTIPANEL)
2773
+      #if ENABLED(ULTIPANEL)
2769 2774
 
2770
-      // Return to Status Screen after a timeout
2771
-      if (currentScreen == lcd_status_screen || defer_return_to_status)
2772
-        return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS;
2773
-      else if (ELAPSED(ms, return_to_status_ms))
2774
-        lcd_return_to_status();
2775
+        // Return to Status Screen after a timeout
2776
+        if (currentScreen == lcd_status_screen || defer_return_to_status)
2777
+          return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS;
2778
+        else if (ELAPSED(ms, return_to_status_ms))
2779
+          lcd_return_to_status();
2775 2780
 
2776
-    #endif // ULTIPANEL
2781
+      #endif // ULTIPANEL
2777 2782
 
2778
-    switch (lcdDrawUpdate) {
2779
-      case LCDVIEW_CLEAR_CALL_REDRAW:
2780
-        lcd_implementation_clear();
2781
-      case LCDVIEW_CALL_REDRAW_NEXT:
2782
-        lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
2783
-        break;
2784
-      case LCDVIEW_REDRAW_NOW:
2785
-        lcdDrawUpdate = LCDVIEW_NONE;
2786
-        break;
2787
-      case LCDVIEW_NONE:
2788
-        break;
2789
-    }
2783
+      switch (lcdDrawUpdate) {
2784
+        case LCDVIEW_CLEAR_CALL_REDRAW:
2785
+          lcd_implementation_clear();
2786
+        case LCDVIEW_CALL_REDRAW_NEXT:
2787
+          lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
2788
+          break;
2789
+        case LCDVIEW_REDRAW_NOW:
2790
+          lcdDrawUpdate = LCDVIEW_NONE;
2791
+          break;
2792
+        case LCDVIEW_NONE:
2793
+          break;
2794
+      } // switch
2795
+
2796
+    } // LCD_HANDLER_CONDITION
2790 2797
 
2791
-    #if ENABLED(ENSURE_SMOOTH_MOVES) && DISABLED(ALWAYS_ALLOW_MENU)
2792
-      }
2793
-    #endif
2794 2798
   }
2795 2799
 }
2796 2800
 

Loading…
Cancel
Save