Browse Source

Get UBL up and running again

All the changes to get the code into compliance with Marlin coding
standards made UBL sick.   This pretty much gets UBL back up and
running.
Roxy-3D 7 years ago
parent
commit
b8e4a6970b
3 changed files with 57 additions and 50 deletions
  1. 22
    5
      Marlin/Marlin_main.cpp
  2. 34
    44
      Marlin/UBL_G29.cpp
  3. 1
    1
      Marlin/stepper.cpp

+ 22
- 5
Marlin/Marlin_main.cpp View File

@@ -2266,7 +2266,7 @@ static void clean_up_after_endstop_or_probe_move() {
2266 2266
 
2267 2267
 #endif // HAS_BED_PROBE
2268 2268
 
2269
-#if PLANNER_LEVELING
2269
+#if PLANNER_LEVELING || ENABLED(AUTO_BED_LEVELING_UBL)
2270 2270
   /**
2271 2271
    * Turn bed leveling on or off, fixing the current
2272 2272
    * position as-needed.
@@ -2309,10 +2309,7 @@ static void clean_up_after_endstop_or_probe_move() {
2309 2309
           planner.unapply_leveling(current_position);
2310 2310
       }
2311 2311
     #elif ENABLED(AUTO_BED_LEVELING_UBL)
2312
-      if (ubl.state.eeprom_storage_slot == 0)  {
2313 2312
         ubl.state.active = enable;
2314
-        ubl.store_state();
2315
-      }  
2316 2313
     #endif
2317 2314
   }
2318 2315
 
@@ -2363,6 +2360,8 @@ static void clean_up_after_endstop_or_probe_move() {
2363 2360
         for (uint8_t x = 0; x < ABL_GRID_MAX_POINTS_X; x++)
2364 2361
           for (uint8_t y = 0; y < ABL_GRID_MAX_POINTS_Y; y++)
2365 2362
             bed_level_grid[x][y] = UNPROBED;
2363
+      #elif ENABLED(AUTO_BED_LEVELING_UBL)
2364
+        ubl.reset();
2366 2365
       #endif
2367 2366
     #endif
2368 2367
   }
@@ -3482,6 +3481,11 @@ inline void gcode_G4() {
3482 3481
  *
3483 3482
  */
3484 3483
 inline void gcode_G28() {
3484
+  #if ENABLED(AUTO_BED_LEVELING_UBL)
3485
+  bool bed_leveling_state_at_entry=0;
3486
+    bed_leveling_state_at_entry = ubl.state.active;
3487
+    set_bed_leveling_enabled(false);
3488
+  #endif
3485 3489
 
3486 3490
   #if ENABLED(DEBUG_LEVELING_FEATURE)
3487 3491
     if (DEBUGGING(LEVELING)) {
@@ -3638,6 +3642,10 @@ inline void gcode_G28() {
3638 3642
   #endif
3639 3643
 
3640 3644
   // Enable mesh leveling again
3645
+  #if ENABLED(AUTO_BED_LEVELING_UBL)
3646
+      set_bed_leveling_enabled(bed_leveling_state_at_entry);
3647
+  #endif
3648
+
3641 3649
   #if ENABLED(MESH_BED_LEVELING)
3642 3650
     if (mbl.reactivate()) {
3643 3651
       set_bed_leveling_enabled(true);
@@ -5060,6 +5068,10 @@ inline void gcode_M42() {
5060 5068
    * regenerated.
5061 5069
    */
5062 5070
   inline void gcode_M48() {
5071
+  #if ENABLED(AUTO_BED_LEVELING_UBL)
5072
+  bool bed_leveling_state_at_entry=0;
5073
+    bed_leveling_state_at_entry = ubl.state.active;
5074
+  #endif
5063 5075
 
5064 5076
     if (axis_unhomed_error(true, true, true)) return;
5065 5077
 
@@ -5283,6 +5295,11 @@ inline void gcode_M42() {
5283 5295
       set_bed_leveling_enabled(abl_was_enabled);
5284 5296
     #endif
5285 5297
 
5298
+    #if ENABLED(AUTO_BED_LEVELING_UBL)
5299
+      set_bed_leveling_enabled(bed_leveling_state_at_entry);
5300
+      ubl.state.active = bed_leveling_state_at_entry;
5301
+    #endif
5302
+
5286 5303
     report_current_position();
5287 5304
   }
5288 5305
 
@@ -8511,7 +8528,7 @@ void process_next_command() {
8511 8528
         gcode_G28();
8512 8529
         break;
8513 8530
 
8514
-      #if PLANNER_LEVELING
8531
+      #if PLANNER_LEVELING || HAS_ABL
8515 8532
         case 29: // G29 Detailed Z probe, probes the bed at 3 or more points,
8516 8533
                  // or provides access to the UBL System if enabled.
8517 8534
           gcode_G29();

+ 34
- 44
Marlin/UBL_G29.cpp View File

@@ -96,8 +96,7 @@
96 96
    *                    specified height, no correction is applied and natural printer kenimatics take over. If no
97 97
    *                    number is specified for the command, 10mm is assumed to be reasonable.
98 98
    *
99
-   *   G #   Grid   *   Perform a Grid Based Leveling of the current Mesh using a grid with n points on
100
-   *   a side.
99
+   *   G #   Grid   *   Perform a Grid Based Leveling of the current Mesh using a grid with n points on a side.
101 100
    *
102 101
    *   H #   Height     Specify the Height to raise the nozzle after each manual probe of the bed. The
103 102
    *                    default is 5mm.
@@ -267,12 +266,6 @@
267 266
    *   of the mesh, you are limited to 3-Point and Grid Leveling. (G29 P0 T and G29 P0 G
268 267
    *   respectively.)
269 268
    *
270
-   *   Z-Probe Sleds are not currently fully supported. There were too many complications caused
271
-   *   by them to support them in the Unified Bed Leveling code. Support for them will be handled
272
-   *   better in the upcoming Z-Probe Object that will happen during the Code Clean Up phase. (That
273
-   *   is what they really are:  A special case of the Z-Probe.)  When a Z-Probe Object appears, it
274
-   *   should slip in under the Unified Bed Leveling code without major trauma.
275
-   *
276 269
    *   When you do a G28 and then a G29 P1 to automatically build your first mesh, you are going to notice
277 270
    *   the Unified Bed Leveling probes points further and further away from the starting location. (The
278 271
    *   starting location defaults to the center of the bed.)   The original Grid and Mesh leveling used
@@ -1076,11 +1069,6 @@
1076 1069
     ubl.state.active = ubl_state_at_invocation;
1077 1070
   }
1078 1071
 
1079
-  void g29_print_line(bool longer=false) {
1080
-    SERIAL_PROTOCOLPGM("  -------------------------------------");
1081
-    if (longer) SERIAL_PROTOCOLPGM("-------------------");
1082
-    SERIAL_PROTOCOLLNPGM("       <----<<<");
1083
-  }
1084 1072
 
1085 1073
   /**
1086 1074
    * Much of the 'What?' command can be eliminated. But until we are fully debugged, it is
@@ -1090,70 +1078,85 @@
1090 1078
     int k = E2END - ubl_eeprom_start;
1091 1079
     statistics_flag++;
1092 1080
 
1093
-    SERIAL_PROTOCOLLNPGM("Version #4: 10/30/2016 branch");
1094
-    SERIAL_PROTOCOLPGM("Unified Bed Leveling System ");
1081
+    SERIAL_PROTOCOLPGM("Unified Bed Leveling System Version 1.00 ");
1095 1082
     if (ubl.state.active)
1096
-      SERIAL_PROTOCOLPGM("Active.");
1083
+      SERIAL_PROTOCOLPGM("Active.\n");
1097 1084
     else
1098
-      SERIAL_PROTOCOLPGM("Inactive.");
1099
-    g29_print_line(); // These are just to help me find this info buried in the clutter
1085
+      SERIAL_PROTOCOLPGM("Inactive.\n");
1086
+    SERIAL_EOL;
1087
+    delay(50);
1100 1088
 
1101 1089
     if (ubl.state.eeprom_storage_slot == 0xFFFF) {
1102 1090
       SERIAL_PROTOCOLPGM("No Mesh Loaded.");
1103
-      g29_print_line(); // These are just to help me find this info buried in the clutter
1104 1091
     }
1105 1092
     else {
1106 1093
       SERIAL_PROTOCOLPGM("Mesh: ");
1107 1094
       prt_hex_word(ubl.state.eeprom_storage_slot);
1108 1095
       SERIAL_PROTOCOLPGM(" Loaded. ");
1109
-      g29_print_line(true); // These are just to help me find this info buried in the clutter
1110 1096
     }
1111 1097
 
1112
-    SERIAL_PROTOCOLPAIR("\ng29_correction_fade_height : ", ubl.state.g29_correction_fade_height );
1113
-    g29_print_line(); // These are just to help me find this info buried in the clutter
1098
+    SERIAL_EOL;
1099
+    delay(50);
1100
+
1101
+    SERIAL_PROTOCOLPAIR("g29_correction_fade_height : ", ubl.state.g29_correction_fade_height );
1102
+    SERIAL_EOL;
1114 1103
 
1115 1104
     idle();
1116 1105
 
1117 1106
     SERIAL_PROTOCOLPGM("z_offset: ");
1118 1107
     SERIAL_PROTOCOL_F(ubl.state.z_offset, 6);
1119
-    g29_print_line(true); // These are just to help me find this info buried in the clutter
1108
+    SERIAL_EOL;
1120 1109
 
1121 1110
     SERIAL_PROTOCOLPGM("X-Axis Mesh Points at: ");
1122 1111
     for (uint8_t i = 0; i < UBL_MESH_NUM_X_POINTS; i++) {
1123 1112
       SERIAL_PROTOCOL_F( ubl.map_x_index_to_bed_location(i), 1);
1124 1113
       SERIAL_PROTOCOLPGM("  ");
1114
+      delay(10);
1125 1115
     }
1126 1116
     SERIAL_EOL;
1117
+    delay(50);
1118
+    idle();
1119
+
1127 1120
     SERIAL_PROTOCOLPGM("Y-Axis Mesh Points at: ");
1128 1121
     for (uint8_t i = 0; i < UBL_MESH_NUM_Y_POINTS; i++) {
1129 1122
       SERIAL_PROTOCOL_F( ubl.map_y_index_to_bed_location(i), 1);
1130 1123
       SERIAL_PROTOCOLPGM("  ");
1124
+      delay(10);
1131 1125
     }
1132 1126
     SERIAL_EOL;
1127
+    delay(50);
1128
+    idle();
1133 1129
 
1134 1130
     #if HAS_KILL
1135 1131
       SERIAL_PROTOCOLPAIR("Kill pin on :", KILL_PIN);
1136 1132
       SERIAL_PROTOCOLLNPAIR("  state:", READ(KILL_PIN));
1137 1133
     #endif
1134
+    delay(50);
1135
+    idle();
1136
+    SERIAL_EOL;
1138 1137
 
1139 1138
     SERIAL_PROTOCOLLNPAIR("ubl_state_at_invocation :", ubl_state_at_invocation);
1139
+    SERIAL_EOL;
1140 1140
     SERIAL_PROTOCOLLNPAIR("ubl_state_recursion_chk :", ubl_state_recursion_chk);
1141
-
1142 1141
     SERIAL_EOL;
1143 1142
     SERIAL_PROTOCOLPGM("Free EEPROM space starts at: 0x");
1144 1143
     prt_hex_word(ubl_eeprom_start);
1145 1144
     SERIAL_EOL;
1145
+    delay(50);
1146 1146
     idle();
1147 1147
 
1148 1148
     SERIAL_PROTOCOLPGM("end of EEPROM              : ");
1149 1149
     prt_hex_word(E2END);
1150 1150
     SERIAL_EOL;
1151
+    delay(50);
1151 1152
     idle();
1152 1153
 
1153 1154
     SERIAL_PROTOCOLLNPAIR("sizeof(ubl) :  ", (int)sizeof(ubl));
1154 1155
     SERIAL_EOL;
1155 1156
     SERIAL_PROTOCOLLNPAIR("z_value[][] size: ", (int)sizeof(z_values));
1156 1157
     SERIAL_EOL;
1158
+    delay(50);
1159
+    idle();
1157 1160
 
1158 1161
     SERIAL_PROTOCOLPGM("EEPROM free for UBL: 0x");
1159 1162
     prt_hex_word(k);
@@ -1162,41 +1165,28 @@
1162 1165
 
1163 1166
     SERIAL_PROTOCOLPGM("EEPROM can hold 0x");
1164 1167
     prt_hex_word(k / sizeof(z_values));
1165
-    SERIAL_PROTOCOLLNPGM(" meshes.");
1168
+    SERIAL_PROTOCOLLNPGM(" meshes.\n");
1169
+    delay(50);
1166 1170
 
1167
-    SERIAL_PROTOCOLPGM("sizeof(stat)     :");
1171
+    SERIAL_PROTOCOLPGM("sizeof(ubl.state) :");
1168 1172
     prt_hex_word(sizeof(ubl.state));
1169
-    SERIAL_EOL;
1170 1173
     idle();
1171 1174
 
1172 1175
     SERIAL_PROTOCOLPAIR("\nUBL_MESH_NUM_X_POINTS  ", UBL_MESH_NUM_X_POINTS);
1173 1176
     SERIAL_PROTOCOLPAIR("\nUBL_MESH_NUM_Y_POINTS  ", UBL_MESH_NUM_Y_POINTS);
1174 1177
     SERIAL_PROTOCOLPAIR("\nUBL_MESH_MIN_X         ", UBL_MESH_MIN_X);
1178
+    delay(50);
1179
+    idle();
1175 1180
     SERIAL_PROTOCOLPAIR("\nUBL_MESH_MIN_Y         ", UBL_MESH_MIN_Y);
1176 1181
     SERIAL_PROTOCOLPAIR("\nUBL_MESH_MAX_X         ", UBL_MESH_MAX_X);
1177 1182
     SERIAL_PROTOCOLPAIR("\nUBL_MESH_MAX_Y         ", UBL_MESH_MAX_Y);
1183
+    delay(50);
1184
+    idle();
1178 1185
     SERIAL_PROTOCOLPGM("\nMESH_X_DIST        ");
1179 1186
     SERIAL_PROTOCOL_F(MESH_X_DIST, 6);
1180 1187
     SERIAL_PROTOCOLPGM("\nMESH_Y_DIST        ");
1181 1188
     SERIAL_PROTOCOL_F(MESH_Y_DIST, 6);
1182 1189
     SERIAL_EOL;
1183
-    idle();
1184
-
1185
-    SERIAL_PROTOCOLPAIR("\nsizeof(block_t): ", (int)sizeof(block_t));
1186
-    SERIAL_PROTOCOLPAIR("\nsizeof(planner.block_buffer): ", (int)sizeof(planner.block_buffer));
1187
-    SERIAL_PROTOCOLPAIR("\nsizeof(char): ", (int)sizeof(char));
1188
-    SERIAL_PROTOCOLPAIR("   sizeof(unsigned char): ", (int)sizeof(unsigned char));
1189
-    SERIAL_PROTOCOLPAIR("\nsizeof(int): ", (int)sizeof(int));
1190
-    SERIAL_PROTOCOLPAIR("   sizeof(unsigned int): ", (int)sizeof(unsigned int));
1191
-    SERIAL_PROTOCOLPAIR("\nsizeof(long): ", (int)sizeof(long));
1192
-    SERIAL_PROTOCOLPAIR("   sizeof(unsigned long int): ", (int)sizeof(unsigned long int));
1193
-    SERIAL_PROTOCOLPAIR("\nsizeof(float): ", (int)sizeof(float));
1194
-    SERIAL_PROTOCOLPAIR("   sizeof(double): ", (int)sizeof(double));
1195
-    SERIAL_PROTOCOLPAIR("\nsizeof(void *): ", (int)sizeof(void *));
1196
-    struct pf { void *p_f(); } ptr_func;
1197
-    SERIAL_PROTOCOLPAIR("   sizeof(struct pf): ", (int)sizeof(pf));
1198
-    SERIAL_PROTOCOLPAIR("   sizeof(void *()): ", (int)sizeof(ptr_func));
1199
-    SERIAL_EOL;
1200 1190
 
1201 1191
     idle();
1202 1192
 

+ 1
- 1
Marlin/stepper.cpp View File

@@ -1263,7 +1263,7 @@ void Stepper::report_positions() {
1263 1263
         old_pin = _READ_DIR(X);
1264 1264
         #if STEP_PULSE_CYCLES > CYCLES_EATEN_BY_BABYSTEP
1265 1265
           pulse_start = TCNT0;
1266
-        #endif \
1266
+        #endif 
1267 1267
         START_BABYSTEP_AXIS(X, false);
1268 1268
         #if STEP_PULSE_CYCLES > CYCLES_EATEN_BY_BABYSTEP
1269 1269
           while ((uint32_t)(TCNT0 - pulse_start) < STEP_PULSE_CYCLES - CYCLES_EATEN_BY_BABYSTEP) { /* nada */ }

Loading…
Cancel
Save