Browse Source

Get G29's Interactive Mesh Editor running

G29 P4 R O  should work now.
Roxy-3D 8 years ago
parent
commit
3fd74b121f
1 changed files with 18 additions and 16 deletions
  1. 18
    16
      Marlin/ultralcd.cpp

+ 18
- 16
Marlin/ultralcd.cpp View File

819
 
819
 
820
     float Mesh_Edit_Value, Mesh_Edit_Accumulator; // We round Mesh_Edit_Value to 2.5 decimal places.  So we keep a
820
     float Mesh_Edit_Value, Mesh_Edit_Accumulator; // We round Mesh_Edit_Value to 2.5 decimal places.  So we keep a
821
                                                   // seperate value that doesn't lose precision.
821
                                                   // seperate value that doesn't lose precision.
822
-    static int loop_cnt=0, last_seen_bits;
822
+       static int loop_cnt=0, last_seen_bits, UBL_encoderPosition=0;
823
 
823
 
824
     static void _lcd_mesh_fine_tune( const char* msg) {
824
     static void _lcd_mesh_fine_tune( const char* msg) {
825
       static unsigned long last_click=0;
825
       static unsigned long last_click=0;
827
       long int rounded;
827
       long int rounded;
828
 
828
 
829
       defer_return_to_status = true;
829
       defer_return_to_status = true;
830
-      if (encoderPosition) {                     // If moving the Encoder wheel very slowly, we just go
831
-        if ( (millis() - last_click) > 500L) {   // up or down by 1 position
832
-          if ( ((int32_t)encoderPosition) > 0 ) {
833
-            encoderPosition = 1;
834
-          }
830
+
831
+      if (G29_encoderDiff) {                     // If moving the Encoder wheel very slowly, we just go
832
+        if ( (millis() - last_click) > 200L) {   // up or down by 1 position
833
+          if ( G29_encoderDiff > 0 ) 
834
+            UBL_encoderPosition = 1;
835
           else {
835
           else {
836
-            encoderPosition = (uint32_t) -1;
836
+            UBL_encoderPosition = -1;
837
           }
837
           }
838
-        }
838
+        } else 
839
+            UBL_encoderPosition = G29_encoderDiff * 2;
840
+
841
+        G29_encoderDiff = 0;
839
         last_click = millis();
842
         last_click = millis();
840
 
843
 
841
-        Mesh_Edit_Accumulator += ( (float) ((int32_t)encoderPosition)) * .005 / 2.0 ;
844
+        Mesh_Edit_Accumulator += ( (float) (UBL_encoderPosition)) * .005 / 2.0 ;
842
         Mesh_Edit_Value       = Mesh_Edit_Accumulator;
845
         Mesh_Edit_Value       = Mesh_Edit_Accumulator;
843
         encoderPosition       = 0;
846
         encoderPosition       = 0;
844
-        lcdDrawUpdate       = LCDVIEW_REDRAW_NOW;
847
+        lcdDrawUpdate         = LCDVIEW_REDRAW_NOW;
845
 
848
 
846
         rounded    = (long int) (Mesh_Edit_Value * 1000.0);
849
         rounded    = (long int) (Mesh_Edit_Value * 1000.0);
847
         last_digit = rounded % 5L; //10L;
850
         last_digit = rounded % 5L; //10L;
853
       if (lcdDrawUpdate) {
856
       if (lcdDrawUpdate) {
854
         lcd_implementation_drawedit(msg, ftostr43sign( (float) Mesh_Edit_Value  ));
857
         lcd_implementation_drawedit(msg, ftostr43sign( (float) Mesh_Edit_Value  ));
855
       }
858
       }
856
-
857
-      if ( !UBL_has_control_of_LCD_Panel && LCD_CLICKED ) {
858
-        UBL_has_control_of_LCD_Panel=1;   // We need to lock the normal LCD Panel System outbecause G29 (and G26) are looking for
859
-        lcd_return_to_status();           // long presses of the Encoder Wheel and the LCD System goes spastic when that happens.
860
-                                          // We will give back control from those routines when the switch is debounced.
861
-      }
862
     }
859
     }
863
 
860
 
864
 
861
 
865
     void _lcd_mesh_edit() {
862
     void _lcd_mesh_edit() {
866
       _lcd_mesh_fine_tune( PSTR("Mesh Editor: "));
863
       _lcd_mesh_fine_tune( PSTR("Mesh Editor: "));
864
+      defer_return_to_status = true;
867
     }
865
     }
868
 
866
 
869
     float lcd_mesh_edit() {
867
     float lcd_mesh_edit() {
870
       lcd_goto_screen(_lcd_mesh_edit);
868
       lcd_goto_screen(_lcd_mesh_edit);
869
+      defer_return_to_status = true;
871
       return Mesh_Edit_Value;
870
       return Mesh_Edit_Value;
872
     }
871
     }
873
 
872
 
875
       Mesh_Edit_Value       = inital;
874
       Mesh_Edit_Value       = inital;
876
       Mesh_Edit_Accumulator = inital;
875
       Mesh_Edit_Accumulator = inital;
877
       lcd_goto_screen(_lcd_mesh_edit);
876
       lcd_goto_screen(_lcd_mesh_edit);
877
+      defer_return_to_status = true;
878
       return ;
878
       return ;
879
     }
879
     }
880
 
880
 
884
 
884
 
885
     float lcd_z_offset_edit() {
885
     float lcd_z_offset_edit() {
886
       lcd_goto_screen(_lcd_z_offset_edit);
886
       lcd_goto_screen(_lcd_z_offset_edit);
887
+      defer_return_to_status = true;
887
       return Mesh_Edit_Value;
888
       return Mesh_Edit_Value;
888
     }
889
     }
889
 
890
 
891
       Mesh_Edit_Value       = inital;
892
       Mesh_Edit_Value       = inital;
892
       Mesh_Edit_Accumulator = inital;
893
       Mesh_Edit_Accumulator = inital;
893
       lcd_goto_screen(_lcd_z_offset_edit);
894
       lcd_goto_screen(_lcd_z_offset_edit);
895
+      defer_return_to_status = true;
894
       return ;
896
       return ;
895
     }
897
     }
896
 
898
 

Loading…
Cancel
Save