Просмотр исходного кода

Get G29's P1 (Automated Probing) working again.

Incorrect optimizations of data types and ternary operators caused some
issues.
Roxy-3D 8 лет назад
Родитель
Сommit
d8724bb546
2 измененных файлов: 34 добавлений и 27 удалений
  1. 13
    16
      Marlin/UBL_G29.cpp
  2. 21
    11
      Marlin/ultralcd.cpp

+ 13
- 16
Marlin/UBL_G29.cpp Просмотреть файл

33
   #include "planner.h"
33
   #include "planner.h"
34
   #include "ultralcd.h"
34
   #include "ultralcd.h"
35
 
35
 
36
-  #include <avr/io.h>
36
+  #include <math.h>
37
 
37
 
38
   void lcd_babystep_z();
38
   void lcd_babystep_z();
39
   void lcd_return_to_status();
39
   void lcd_return_to_status();
300
 
300
 
301
   int ubl_eeprom_start = -1;
301
   int ubl_eeprom_start = -1;
302
   bool ubl_has_control_of_lcd_panel = false;
302
   bool ubl_has_control_of_lcd_panel = false;
303
-  volatile uint8_t ubl_encoderDiff = 0; // Volatile because it's changed by Temperature ISR button update
303
+  volatile int8_t ubl_encoderDiff = 0; // Volatile because it's changed by Temperature ISR button update
304
 
304
 
305
   // The simple parameter flags and values are 'static' so parameter parsing can be in a support routine.
305
   // The simple parameter flags and values are 'static' so parameter parsing can be in a support routine.
306
   static int g29_verbose_level = 0, phase_value = -1, repetition_cnt = 1,
306
   static int g29_verbose_level = 0, phase_value = -1, repetition_cnt = 1,
496
           SERIAL_ECHO_START;
496
           SERIAL_ECHO_START;
497
           SERIAL_ECHOLNPGM("Checking G29 has control of LCD Panel:");
497
           SERIAL_ECHOLNPGM("Checking G29 has control of LCD Panel:");
498
           wait_for_user = true;
498
           wait_for_user = true;
499
-          while (wait_for_user) {
499
+          while (!ubl_lcd_clicked()) {
500
             safe_delay(250);
500
             safe_delay(250);
501
             SERIAL_ECHO((int)ubl_encoderDiff);
501
             SERIAL_ECHO((int)ubl_encoderDiff);
502
             ubl_encoderDiff = 0;
502
             ubl_encoderDiff = 0;
1310
 
1310
 
1311
 	  if (far_flag) {                                    // If doing the far_flag action, we want to be as far as possible
1311
 	  if (far_flag) {                                    // If doing the far_flag action, we want to be as far as possible
1312
             for (k = 0; k < UBL_MESH_NUM_X_POINTS; k++) {    // from the starting point and from any other probed points.  We
1312
             for (k = 0; k < UBL_MESH_NUM_X_POINTS; k++) {    // from the starting point and from any other probed points.  We
1313
-              for (l = 0; j < UBL_MESH_NUM_Y_POINTS; l++) {  // want the next point spread out and filling in any blank spaces
1313
+              for (l = 0; l < UBL_MESH_NUM_Y_POINTS; l++) {  // want the next point spread out and filling in any blank spaces
1314
                 if ( !isnan(z_values[k][l])) {               // in the mesh.   So we add in some of the distance to every probed 
1314
                 if ( !isnan(z_values[k][l])) {               // in the mesh.   So we add in some of the distance to every probed 
1315
                   distance += (i-k)*(i-k)*MESH_X_DIST*.05;   // point we can find.
1315
                   distance += (i-k)*(i-k)*MESH_X_DIST*.05;   // point we can find.
1316
                   distance += (j-l)*(j-l)*MESH_Y_DIST*.05;
1316
                   distance += (j-l)*(j-l)*MESH_Y_DIST*.05;
1366
 
1366
 
1367
       do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);    // Move the nozzle to where we are going to edit
1367
       do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);    // Move the nozzle to where we are going to edit
1368
       do_blocking_move_to_xy(xProbe, yProbe);
1368
       do_blocking_move_to_xy(xProbe, yProbe);
1369
-      float new_z = z_values[location.x_index][location.y_index] + 0.001;
1370
-
1371
-      round_off = (int32_t)(new_z * 1000.0 + 2.5); // we chop off the last digits just to be clean. We are rounding to the
1372
-      round_off -= (round_off % 5L); // closest 0 or 5 at the 3rd decimal place.
1369
+      float new_z = z_values[location.x_index][location.y_index];
1370
+      
1371
+      round_off = (int32_t)(new_z * 1000.0);    // we chop off the last digits just to be clean. We are rounding to the
1373
       new_z = float(round_off) / 1000.0;
1372
       new_z = float(round_off) / 1000.0;
1374
 
1373
 
1375
-      //SERIAL_ECHOPGM("Mesh Point Currently At:  ");
1376
-      //SERIAL_PROTOCOL_F(new_z, 6);
1377
-      //SERIAL_EOL;
1374
+      ubl_has_control_of_lcd_panel = true;
1378
 
1375
 
1379
       lcd_implementation_clear();
1376
       lcd_implementation_clear();
1380
       lcd_mesh_edit_setup(new_z);
1377
       lcd_mesh_edit_setup(new_z);
1383
       do {
1380
       do {
1384
         new_z = lcd_mesh_edit();
1381
         new_z = lcd_mesh_edit();
1385
         idle();
1382
         idle();
1386
-      } while (wait_for_user);
1383
+      } while (!ubl_lcd_clicked());
1387
 
1384
 
1388
       lcd_return_to_status();
1385
       lcd_return_to_status();
1389
 
1386
 
1390
-      ubl_has_control_of_lcd_panel++; // There is a race condition for the Encoder Wheel getting clicked.
1391
-                                      // It could get detected in lcd_mesh_edit (actually _lcd_mesh_fine_tune)
1392
-                                      // or here.
1387
+      ubl_has_control_of_lcd_panel = true; // There is a race condition for the Encoder Wheel getting clicked.
1388
+                                           // It could get detected in lcd_mesh_edit (actually _lcd_mesh_fine_tune)
1389
+                                           // or here.
1393
 
1390
 
1394
       const millis_t nxt = millis() + 1500UL;
1391
       const millis_t nxt = millis() + 1500UL;
1395
       while (ubl_lcd_clicked()) { // debounce and watch for abort
1392
       while (ubl_lcd_clicked()) { // debounce and watch for abort
1396
         idle();
1393
         idle();
1397
         if (ELAPSED(millis(), nxt)) {
1394
         if (ELAPSED(millis(), nxt)) {
1398
           lcd_return_to_status();
1395
           lcd_return_to_status();
1399
-          SERIAL_PROTOCOLLNPGM("\nFine Tuning of Mesh Stopped.");
1396
+//        SERIAL_PROTOCOLLNPGM("\nFine Tuning of Mesh Stopped.");
1400
           do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
1397
           do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
1401
           lcd_setstatus("Mesh Editing Stopped", true);
1398
           lcd_setstatus("Mesh Editing Stopped", true);
1402
 
1399
 

+ 21
- 11
Marlin/ultralcd.cpp Просмотреть файл

125
 
125
 
126
   #if ENABLED(AUTO_BED_LEVELING_UBL)
126
   #if ENABLED(AUTO_BED_LEVELING_UBL)
127
     extern bool ubl_has_control_of_lcd_panel;
127
     extern bool ubl_has_control_of_lcd_panel;
128
-    extern uint8_t ubl_encoderDiff;
128
+    extern int8_t ubl_encoderDiff;
129
   #endif
129
   #endif
130
 
130
 
131
   #if HAS_POWER_SWITCH
131
   #if HAS_POWER_SWITCH
859
     static int ubl_encoderPosition = 0;
859
     static int ubl_encoderPosition = 0;
860
 
860
 
861
     static void _lcd_mesh_fine_tune(const char* msg) {
861
     static void _lcd_mesh_fine_tune(const char* msg) {
862
-      static millis_t next_click = 0;
862
+//    static millis_t next_click = 0;             // We are going to accelerate the number speed when the wheel
863
+//                                                // turns fast.   But that isn't implemented yet
863
       int16_t last_digit;
864
       int16_t last_digit;
864
       int32_t rounded;
865
       int32_t rounded;
865
 
866
 
866
       defer_return_to_status = true;
867
       defer_return_to_status = true;
867
       if (ubl_encoderDiff) {
868
       if (ubl_encoderDiff) {
868
-        // If moving the Encoder wheel very slowly, move by just 1 position
869
-        ubl_encoderPosition = ELAPSED(millis(), next_click)
870
-          ? ubl_encoderDiff > 0 ? 1 : -1
871
-          : ubl_encoderDiff * 2;
869
+        if ( ubl_encoderDiff > 0 ) 
870
+          ubl_encoderPosition = 1;
871
+        else {
872
+          ubl_encoderPosition = -1;
873
+        }
872
 
874
 
873
         ubl_encoderDiff = 0;
875
         ubl_encoderDiff = 0;
874
-        next_click = millis() + 200L;
876
+//      next_click = millis();
875
 
877
 
876
-        mesh_edit_accumulator += float((int32_t)ubl_encoderPosition) * .005 / 2.0;
878
+        mesh_edit_accumulator += ( (float) (ubl_encoderPosition)) * .005 / 2.0 ;
877
         mesh_edit_value = mesh_edit_accumulator;
879
         mesh_edit_value = mesh_edit_accumulator;
878
         encoderPosition = 0;
880
         encoderPosition = 0;
879
         lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
881
         lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
881
         rounded = (int32_t)(mesh_edit_value * 1000.0);
883
         rounded = (int32_t)(mesh_edit_value * 1000.0);
882
         last_digit = rounded % 5L; //10L;
884
         last_digit = rounded % 5L; //10L;
883
         rounded -= last_digit;
885
         rounded -= last_digit;
884
-        last_digit = rounded % 5L; //10L;
885
         mesh_edit_value = float(rounded) / 1000.0;
886
         mesh_edit_value = float(rounded) / 1000.0;
886
       }
887
       }
887
 
888
 
890
     }
891
     }
891
 
892
 
892
 
893
 
894
+    void _lcd_mesh_edit_NOP() {
895
+      defer_return_to_status = true;
896
+    }
897
+
898
+
893
     void _lcd_mesh_edit() {
899
     void _lcd_mesh_edit() {
894
       _lcd_mesh_fine_tune(PSTR("Mesh Editor: "));
900
       _lcd_mesh_fine_tune(PSTR("Mesh Editor: "));
895
       defer_return_to_status = true;
901
       defer_return_to_status = true;
896
     }
902
     }
897
 
903
 
898
     float lcd_mesh_edit() {
904
     float lcd_mesh_edit() {
899
-      lcd_goto_screen(_lcd_mesh_edit);
905
+      lcd_goto_screen(_lcd_mesh_edit_NOP);
906
+      _lcd_mesh_fine_tune(PSTR("Mesh Editor: "));
907
+      defer_return_to_status = true;
900
       return mesh_edit_value;
908
       return mesh_edit_value;
901
     }
909
     }
902
 
910
 
903
     void lcd_mesh_edit_setup(float initial) {
911
     void lcd_mesh_edit_setup(float initial) {
904
       mesh_edit_value = mesh_edit_accumulator = initial;
912
       mesh_edit_value = mesh_edit_accumulator = initial;
905
-      lcd_goto_screen(_lcd_mesh_edit);
913
+      lcd_goto_screen(_lcd_mesh_edit_NOP);
914
+      mesh_edit_value = mesh_edit_accumulator = initial;
915
+      defer_return_to_status = true; 
906
     }
916
     }
907
 
917
 
908
     void _lcd_z_offset_edit() {
918
     void _lcd_z_offset_edit() {

Загрузка…
Отмена
Сохранить