瀏覽代碼

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 8 年之前
父節點
當前提交
b8e4a6970b
共有 3 個檔案被更改,包括 57 行新增50 行删除
  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 查看文件

2266
 
2266
 
2267
 #endif // HAS_BED_PROBE
2267
 #endif // HAS_BED_PROBE
2268
 
2268
 
2269
-#if PLANNER_LEVELING
2269
+#if PLANNER_LEVELING || ENABLED(AUTO_BED_LEVELING_UBL)
2270
   /**
2270
   /**
2271
    * Turn bed leveling on or off, fixing the current
2271
    * Turn bed leveling on or off, fixing the current
2272
    * position as-needed.
2272
    * position as-needed.
2309
           planner.unapply_leveling(current_position);
2309
           planner.unapply_leveling(current_position);
2310
       }
2310
       }
2311
     #elif ENABLED(AUTO_BED_LEVELING_UBL)
2311
     #elif ENABLED(AUTO_BED_LEVELING_UBL)
2312
-      if (ubl.state.eeprom_storage_slot == 0)  {
2313
         ubl.state.active = enable;
2312
         ubl.state.active = enable;
2314
-        ubl.store_state();
2315
-      }  
2316
     #endif
2313
     #endif
2317
   }
2314
   }
2318
 
2315
 
2363
         for (uint8_t x = 0; x < ABL_GRID_MAX_POINTS_X; x++)
2360
         for (uint8_t x = 0; x < ABL_GRID_MAX_POINTS_X; x++)
2364
           for (uint8_t y = 0; y < ABL_GRID_MAX_POINTS_Y; y++)
2361
           for (uint8_t y = 0; y < ABL_GRID_MAX_POINTS_Y; y++)
2365
             bed_level_grid[x][y] = UNPROBED;
2362
             bed_level_grid[x][y] = UNPROBED;
2363
+      #elif ENABLED(AUTO_BED_LEVELING_UBL)
2364
+        ubl.reset();
2366
       #endif
2365
       #endif
2367
     #endif
2366
     #endif
2368
   }
2367
   }
3482
  *
3481
  *
3483
  */
3482
  */
3484
 inline void gcode_G28() {
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
   #if ENABLED(DEBUG_LEVELING_FEATURE)
3490
   #if ENABLED(DEBUG_LEVELING_FEATURE)
3487
     if (DEBUGGING(LEVELING)) {
3491
     if (DEBUGGING(LEVELING)) {
3638
   #endif
3642
   #endif
3639
 
3643
 
3640
   // Enable mesh leveling again
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
   #if ENABLED(MESH_BED_LEVELING)
3649
   #if ENABLED(MESH_BED_LEVELING)
3642
     if (mbl.reactivate()) {
3650
     if (mbl.reactivate()) {
3643
       set_bed_leveling_enabled(true);
3651
       set_bed_leveling_enabled(true);
5060
    * regenerated.
5068
    * regenerated.
5061
    */
5069
    */
5062
   inline void gcode_M48() {
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
     if (axis_unhomed_error(true, true, true)) return;
5076
     if (axis_unhomed_error(true, true, true)) return;
5065
 
5077
 
5283
       set_bed_leveling_enabled(abl_was_enabled);
5295
       set_bed_leveling_enabled(abl_was_enabled);
5284
     #endif
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
     report_current_position();
5303
     report_current_position();
5287
   }
5304
   }
5288
 
5305
 
8511
         gcode_G28();
8528
         gcode_G28();
8512
         break;
8529
         break;
8513
 
8530
 
8514
-      #if PLANNER_LEVELING
8531
+      #if PLANNER_LEVELING || HAS_ABL
8515
         case 29: // G29 Detailed Z probe, probes the bed at 3 or more points,
8532
         case 29: // G29 Detailed Z probe, probes the bed at 3 or more points,
8516
                  // or provides access to the UBL System if enabled.
8533
                  // or provides access to the UBL System if enabled.
8517
           gcode_G29();
8534
           gcode_G29();

+ 34
- 44
Marlin/UBL_G29.cpp 查看文件

96
    *                    specified height, no correction is applied and natural printer kenimatics take over. If no
96
    *                    specified height, no correction is applied and natural printer kenimatics take over. If no
97
    *                    number is specified for the command, 10mm is assumed to be reasonable.
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
    *   H #   Height     Specify the Height to raise the nozzle after each manual probe of the bed. The
101
    *   H #   Height     Specify the Height to raise the nozzle after each manual probe of the bed. The
103
    *                    default is 5mm.
102
    *                    default is 5mm.
267
    *   of the mesh, you are limited to 3-Point and Grid Leveling. (G29 P0 T and G29 P0 G
266
    *   of the mesh, you are limited to 3-Point and Grid Leveling. (G29 P0 T and G29 P0 G
268
    *   respectively.)
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
    *   When you do a G28 and then a G29 P1 to automatically build your first mesh, you are going to notice
269
    *   When you do a G28 and then a G29 P1 to automatically build your first mesh, you are going to notice
277
    *   the Unified Bed Leveling probes points further and further away from the starting location. (The
270
    *   the Unified Bed Leveling probes points further and further away from the starting location. (The
278
    *   starting location defaults to the center of the bed.)   The original Grid and Mesh leveling used
271
    *   starting location defaults to the center of the bed.)   The original Grid and Mesh leveling used
1076
     ubl.state.active = ubl_state_at_invocation;
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
    * Much of the 'What?' command can be eliminated. But until we are fully debugged, it is
1074
    * Much of the 'What?' command can be eliminated. But until we are fully debugged, it is
1090
     int k = E2END - ubl_eeprom_start;
1078
     int k = E2END - ubl_eeprom_start;
1091
     statistics_flag++;
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
     if (ubl.state.active)
1082
     if (ubl.state.active)
1096
-      SERIAL_PROTOCOLPGM("Active.");
1083
+      SERIAL_PROTOCOLPGM("Active.\n");
1097
     else
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
     if (ubl.state.eeprom_storage_slot == 0xFFFF) {
1089
     if (ubl.state.eeprom_storage_slot == 0xFFFF) {
1102
       SERIAL_PROTOCOLPGM("No Mesh Loaded.");
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
     else {
1092
     else {
1106
       SERIAL_PROTOCOLPGM("Mesh: ");
1093
       SERIAL_PROTOCOLPGM("Mesh: ");
1107
       prt_hex_word(ubl.state.eeprom_storage_slot);
1094
       prt_hex_word(ubl.state.eeprom_storage_slot);
1108
       SERIAL_PROTOCOLPGM(" Loaded. ");
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
     idle();
1104
     idle();
1116
 
1105
 
1117
     SERIAL_PROTOCOLPGM("z_offset: ");
1106
     SERIAL_PROTOCOLPGM("z_offset: ");
1118
     SERIAL_PROTOCOL_F(ubl.state.z_offset, 6);
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
     SERIAL_PROTOCOLPGM("X-Axis Mesh Points at: ");
1110
     SERIAL_PROTOCOLPGM("X-Axis Mesh Points at: ");
1122
     for (uint8_t i = 0; i < UBL_MESH_NUM_X_POINTS; i++) {
1111
     for (uint8_t i = 0; i < UBL_MESH_NUM_X_POINTS; i++) {
1123
       SERIAL_PROTOCOL_F( ubl.map_x_index_to_bed_location(i), 1);
1112
       SERIAL_PROTOCOL_F( ubl.map_x_index_to_bed_location(i), 1);
1124
       SERIAL_PROTOCOLPGM("  ");
1113
       SERIAL_PROTOCOLPGM("  ");
1114
+      delay(10);
1125
     }
1115
     }
1126
     SERIAL_EOL;
1116
     SERIAL_EOL;
1117
+    delay(50);
1118
+    idle();
1119
+
1127
     SERIAL_PROTOCOLPGM("Y-Axis Mesh Points at: ");
1120
     SERIAL_PROTOCOLPGM("Y-Axis Mesh Points at: ");
1128
     for (uint8_t i = 0; i < UBL_MESH_NUM_Y_POINTS; i++) {
1121
     for (uint8_t i = 0; i < UBL_MESH_NUM_Y_POINTS; i++) {
1129
       SERIAL_PROTOCOL_F( ubl.map_y_index_to_bed_location(i), 1);
1122
       SERIAL_PROTOCOL_F( ubl.map_y_index_to_bed_location(i), 1);
1130
       SERIAL_PROTOCOLPGM("  ");
1123
       SERIAL_PROTOCOLPGM("  ");
1124
+      delay(10);
1131
     }
1125
     }
1132
     SERIAL_EOL;
1126
     SERIAL_EOL;
1127
+    delay(50);
1128
+    idle();
1133
 
1129
 
1134
     #if HAS_KILL
1130
     #if HAS_KILL
1135
       SERIAL_PROTOCOLPAIR("Kill pin on :", KILL_PIN);
1131
       SERIAL_PROTOCOLPAIR("Kill pin on :", KILL_PIN);
1136
       SERIAL_PROTOCOLLNPAIR("  state:", READ(KILL_PIN));
1132
       SERIAL_PROTOCOLLNPAIR("  state:", READ(KILL_PIN));
1137
     #endif
1133
     #endif
1134
+    delay(50);
1135
+    idle();
1136
+    SERIAL_EOL;
1138
 
1137
 
1139
     SERIAL_PROTOCOLLNPAIR("ubl_state_at_invocation :", ubl_state_at_invocation);
1138
     SERIAL_PROTOCOLLNPAIR("ubl_state_at_invocation :", ubl_state_at_invocation);
1139
+    SERIAL_EOL;
1140
     SERIAL_PROTOCOLLNPAIR("ubl_state_recursion_chk :", ubl_state_recursion_chk);
1140
     SERIAL_PROTOCOLLNPAIR("ubl_state_recursion_chk :", ubl_state_recursion_chk);
1141
-
1142
     SERIAL_EOL;
1141
     SERIAL_EOL;
1143
     SERIAL_PROTOCOLPGM("Free EEPROM space starts at: 0x");
1142
     SERIAL_PROTOCOLPGM("Free EEPROM space starts at: 0x");
1144
     prt_hex_word(ubl_eeprom_start);
1143
     prt_hex_word(ubl_eeprom_start);
1145
     SERIAL_EOL;
1144
     SERIAL_EOL;
1145
+    delay(50);
1146
     idle();
1146
     idle();
1147
 
1147
 
1148
     SERIAL_PROTOCOLPGM("end of EEPROM              : ");
1148
     SERIAL_PROTOCOLPGM("end of EEPROM              : ");
1149
     prt_hex_word(E2END);
1149
     prt_hex_word(E2END);
1150
     SERIAL_EOL;
1150
     SERIAL_EOL;
1151
+    delay(50);
1151
     idle();
1152
     idle();
1152
 
1153
 
1153
     SERIAL_PROTOCOLLNPAIR("sizeof(ubl) :  ", (int)sizeof(ubl));
1154
     SERIAL_PROTOCOLLNPAIR("sizeof(ubl) :  ", (int)sizeof(ubl));
1154
     SERIAL_EOL;
1155
     SERIAL_EOL;
1155
     SERIAL_PROTOCOLLNPAIR("z_value[][] size: ", (int)sizeof(z_values));
1156
     SERIAL_PROTOCOLLNPAIR("z_value[][] size: ", (int)sizeof(z_values));
1156
     SERIAL_EOL;
1157
     SERIAL_EOL;
1158
+    delay(50);
1159
+    idle();
1157
 
1160
 
1158
     SERIAL_PROTOCOLPGM("EEPROM free for UBL: 0x");
1161
     SERIAL_PROTOCOLPGM("EEPROM free for UBL: 0x");
1159
     prt_hex_word(k);
1162
     prt_hex_word(k);
1162
 
1165
 
1163
     SERIAL_PROTOCOLPGM("EEPROM can hold 0x");
1166
     SERIAL_PROTOCOLPGM("EEPROM can hold 0x");
1164
     prt_hex_word(k / sizeof(z_values));
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
     prt_hex_word(sizeof(ubl.state));
1172
     prt_hex_word(sizeof(ubl.state));
1169
-    SERIAL_EOL;
1170
     idle();
1173
     idle();
1171
 
1174
 
1172
     SERIAL_PROTOCOLPAIR("\nUBL_MESH_NUM_X_POINTS  ", UBL_MESH_NUM_X_POINTS);
1175
     SERIAL_PROTOCOLPAIR("\nUBL_MESH_NUM_X_POINTS  ", UBL_MESH_NUM_X_POINTS);
1173
     SERIAL_PROTOCOLPAIR("\nUBL_MESH_NUM_Y_POINTS  ", UBL_MESH_NUM_Y_POINTS);
1176
     SERIAL_PROTOCOLPAIR("\nUBL_MESH_NUM_Y_POINTS  ", UBL_MESH_NUM_Y_POINTS);
1174
     SERIAL_PROTOCOLPAIR("\nUBL_MESH_MIN_X         ", UBL_MESH_MIN_X);
1177
     SERIAL_PROTOCOLPAIR("\nUBL_MESH_MIN_X         ", UBL_MESH_MIN_X);
1178
+    delay(50);
1179
+    idle();
1175
     SERIAL_PROTOCOLPAIR("\nUBL_MESH_MIN_Y         ", UBL_MESH_MIN_Y);
1180
     SERIAL_PROTOCOLPAIR("\nUBL_MESH_MIN_Y         ", UBL_MESH_MIN_Y);
1176
     SERIAL_PROTOCOLPAIR("\nUBL_MESH_MAX_X         ", UBL_MESH_MAX_X);
1181
     SERIAL_PROTOCOLPAIR("\nUBL_MESH_MAX_X         ", UBL_MESH_MAX_X);
1177
     SERIAL_PROTOCOLPAIR("\nUBL_MESH_MAX_Y         ", UBL_MESH_MAX_Y);
1182
     SERIAL_PROTOCOLPAIR("\nUBL_MESH_MAX_Y         ", UBL_MESH_MAX_Y);
1183
+    delay(50);
1184
+    idle();
1178
     SERIAL_PROTOCOLPGM("\nMESH_X_DIST        ");
1185
     SERIAL_PROTOCOLPGM("\nMESH_X_DIST        ");
1179
     SERIAL_PROTOCOL_F(MESH_X_DIST, 6);
1186
     SERIAL_PROTOCOL_F(MESH_X_DIST, 6);
1180
     SERIAL_PROTOCOLPGM("\nMESH_Y_DIST        ");
1187
     SERIAL_PROTOCOLPGM("\nMESH_Y_DIST        ");
1181
     SERIAL_PROTOCOL_F(MESH_Y_DIST, 6);
1188
     SERIAL_PROTOCOL_F(MESH_Y_DIST, 6);
1182
     SERIAL_EOL;
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
     idle();
1191
     idle();
1202
 
1192
 

+ 1
- 1
Marlin/stepper.cpp 查看文件

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

Loading…
取消
儲存