|
@@ -284,7 +284,7 @@
|
284
|
284
|
|
285
|
285
|
#if ENABLED(M100_FREE_MEMORY_WATCHER)
|
286
|
286
|
void gcode_M100();
|
287
|
|
- void M100_dump_routine( char *title, char *start, char *end);
|
|
287
|
+ void M100_dump_routine(const char * const title, const char *start, const char *end);
|
288
|
288
|
#endif
|
289
|
289
|
|
290
|
290
|
#if ENABLED(SDSUPPORT)
|
|
@@ -1091,7 +1091,7 @@ inline void get_serial_commands() {
|
1091
|
1091
|
if (IsStopped()) {
|
1092
|
1092
|
char* gpos = strchr(command, 'G');
|
1093
|
1093
|
if (gpos) {
|
1094
|
|
- int codenum = strtol(gpos + 1, NULL, 10);
|
|
1094
|
+ const int codenum = strtol(gpos + 1, NULL, 10);
|
1095
|
1095
|
switch (codenum) {
|
1096
|
1096
|
case 0:
|
1097
|
1097
|
case 1:
|
|
@@ -4167,17 +4167,25 @@ inline void gcode_G28() {
|
4167
|
4167
|
#define ABL_VAR
|
4168
|
4168
|
#endif
|
4169
|
4169
|
|
4170
|
|
- ABL_VAR int verbose_level, abl_probe_index;
|
|
4170
|
+ ABL_VAR int verbose_level;
|
4171
|
4171
|
ABL_VAR float xProbe, yProbe, measured_z;
|
4172
|
4172
|
ABL_VAR bool dryrun, abl_should_enable;
|
4173
|
4173
|
|
|
4174
|
+ #if ENABLED(PROBE_MANUALLY) || ENABLED(AUTO_BED_LEVELING_LINEAR)
|
|
4175
|
+ ABL_VAR int abl_probe_index;
|
|
4176
|
+ #endif
|
|
4177
|
+
|
4174
|
4178
|
#if HAS_SOFTWARE_ENDSTOPS
|
4175
|
4179
|
ABL_VAR bool enable_soft_endstops = true;
|
4176
|
4180
|
#endif
|
4177
|
4181
|
|
4178
|
4182
|
#if ABL_GRID
|
4179
|
|
- ABL_VAR uint8_t PR_OUTER_VAR;
|
4180
|
|
- ABL_VAR int8_t PR_INNER_VAR;
|
|
4183
|
+
|
|
4184
|
+ #if ENABLED(PROBE_MANUALLY)
|
|
4185
|
+ ABL_VAR uint8_t PR_OUTER_VAR;
|
|
4186
|
+ ABL_VAR int8_t PR_INNER_VAR;
|
|
4187
|
+ #endif
|
|
4188
|
+
|
4181
|
4189
|
ABL_VAR int left_probe_bed_position, right_probe_bed_position, front_probe_bed_position, back_probe_bed_position;
|
4182
|
4190
|
ABL_VAR float xGridSpacing, yGridSpacing;
|
4183
|
4191
|
|
|
@@ -4186,13 +4194,18 @@ inline void gcode_G28() {
|
4186
|
4194
|
#if ABL_PLANAR
|
4187
|
4195
|
ABL_VAR uint8_t abl_grid_points_x = GRID_MAX_POINTS_X,
|
4188
|
4196
|
abl_grid_points_y = GRID_MAX_POINTS_Y;
|
4189
|
|
- ABL_VAR int abl2;
|
4190
|
4197
|
ABL_VAR bool do_topography_map;
|
4191
|
4198
|
#else // 3-point
|
4192
|
4199
|
uint8_t constexpr abl_grid_points_x = GRID_MAX_POINTS_X,
|
4193
|
4200
|
abl_grid_points_y = GRID_MAX_POINTS_Y;
|
|
4201
|
+ #endif
|
4194
|
4202
|
|
4195
|
|
- int constexpr abl2 = ABL_GRID_MAX;
|
|
4203
|
+ #if ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(PROBE_MANUALLY)
|
|
4204
|
+ #if ABL_PLANAR
|
|
4205
|
+ ABL_VAR int abl2;
|
|
4206
|
+ #else // 3-point
|
|
4207
|
+ int constexpr abl2 = ABL_GRID_MAX;
|
|
4208
|
+ #endif
|
4196
|
4209
|
#endif
|
4197
|
4210
|
|
4198
|
4211
|
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
|
@@ -4224,7 +4237,10 @@ inline void gcode_G28() {
|
4224
|
4237
|
*/
|
4225
|
4238
|
if (!g29_in_progress) {
|
4226
|
4239
|
|
4227
|
|
- abl_probe_index = 0;
|
|
4240
|
+ #if ENABLED(PROBE_MANUALLY) || ENABLED(AUTO_BED_LEVELING_LINEAR)
|
|
4241
|
+ abl_probe_index = 0;
|
|
4242
|
+ #endif
|
|
4243
|
+
|
4228
|
4244
|
abl_should_enable = planner.abl_enabled;
|
4229
|
4245
|
|
4230
|
4246
|
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
|
@@ -4284,7 +4300,7 @@ inline void gcode_G28() {
|
4284
|
4300
|
return;
|
4285
|
4301
|
}
|
4286
|
4302
|
|
4287
|
|
- dryrun = code_seen('D') ? code_value_bool() : false;
|
|
4303
|
+ dryrun = code_seen('D') && code_value_bool();
|
4288
|
4304
|
|
4289
|
4305
|
#if ENABLED(AUTO_BED_LEVELING_LINEAR)
|
4290
|
4306
|
|
|
@@ -4455,7 +4471,7 @@ inline void gcode_G28() {
|
4455
|
4471
|
g29_in_progress = true;
|
4456
|
4472
|
|
4457
|
4473
|
if (abl_probe_index == 0) {
|
4458
|
|
- // For the initial G29 S2 save software endstop state
|
|
4474
|
+ // For the initial G29 save software endstop state
|
4459
|
4475
|
#if HAS_SOFTWARE_ENDSTOPS
|
4460
|
4476
|
enable_soft_endstops = soft_endstops_enabled;
|
4461
|
4477
|
#endif
|
|
@@ -4586,7 +4602,6 @@ inline void gcode_G28() {
|
4586
|
4602
|
|
4587
|
4603
|
#else // !PROBE_MANUALLY
|
4588
|
4604
|
|
4589
|
|
-
|
4590
|
4605
|
bool stow_probe_after_each = code_seen('E');
|
4591
|
4606
|
|
4592
|
4607
|
#if ABL_GRID
|
|
@@ -4927,14 +4942,12 @@ inline void gcode_G28() {
|
4927
|
4942
|
* S = Stows the probe if 1 (default=1)
|
4928
|
4943
|
*/
|
4929
|
4944
|
inline void gcode_G30() {
|
4930
|
|
- float X_probe_location = code_seen('X') ? code_value_linear_units() : current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER,
|
4931
|
|
- Y_probe_location = code_seen('Y') ? code_value_linear_units() : current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER;
|
|
4945
|
+ const float xpos = code_seen('X') ? code_value_linear_units() : current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER,
|
|
4946
|
+ ypos = code_seen('Y') ? code_value_linear_units() : current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER,
|
|
4947
|
+ pos[XYZ] = { xpos, ypos, LOGICAL_Z_POSITION(0) };
|
4932
|
4948
|
|
4933
|
|
- float pos[XYZ] = { X_probe_location, Y_probe_location, LOGICAL_Z_POSITION(0) };
|
4934
|
4949
|
if (!position_is_reachable(pos, true)) return;
|
4935
|
4950
|
|
4936
|
|
- bool stow = code_seen('S') ? code_value_bool() : true;
|
4937
|
|
-
|
4938
|
4951
|
// Disable leveling so the planner won't mess with us
|
4939
|
4952
|
#if PLANNER_LEVELING
|
4940
|
4953
|
set_bed_leveling_enabled(false);
|
|
@@ -4942,14 +4955,11 @@ inline void gcode_G28() {
|
4942
|
4955
|
|
4943
|
4956
|
setup_for_endstop_or_probe_move();
|
4944
|
4957
|
|
4945
|
|
- float measured_z = probe_pt(X_probe_location, Y_probe_location, stow, 1);
|
|
4958
|
+ const float measured_z = probe_pt(xpos, ypos, !code_seen('S') || code_value_bool(), 1);
|
4946
|
4959
|
|
4947
|
|
- SERIAL_PROTOCOLPGM("Bed X: ");
|
4948
|
|
- SERIAL_PROTOCOL(FIXFLOAT(X_probe_location));
|
4949
|
|
- SERIAL_PROTOCOLPGM(" Y: ");
|
4950
|
|
- SERIAL_PROTOCOL(FIXFLOAT(Y_probe_location));
|
4951
|
|
- SERIAL_PROTOCOLPGM(" Z: ");
|
4952
|
|
- SERIAL_PROTOCOLLN(FIXFLOAT(measured_z));
|
|
4960
|
+ SERIAL_PROTOCOLPAIR("Bed X: ", FIXFLOAT(xpos));
|
|
4961
|
+ SERIAL_PROTOCOLPAIR(" Y: ", FIXFLOAT(ypos));
|
|
4962
|
+ SERIAL_PROTOCOLLNPAIR(" Z: ", FIXFLOAT(measured_z));
|
4953
|
4963
|
|
4954
|
4964
|
clean_up_after_endstop_or_probe_move();
|
4955
|
4965
|
|
|
@@ -5466,7 +5476,7 @@ inline void gcode_G92() {
|
5466
|
5476
|
* M1: Conditional stop - Wait for user button press on LCD
|
5467
|
5477
|
*/
|
5468
|
5478
|
inline void gcode_M0_M1() {
|
5469
|
|
- char* args = current_command_args;
|
|
5479
|
+ const char * const args = current_command_args;
|
5470
|
5480
|
|
5471
|
5481
|
millis_t codenum = 0;
|
5472
|
5482
|
bool hasP = false, hasS = false;
|
|
@@ -5524,7 +5534,7 @@ inline void gcode_G92() {
|
5524
|
5534
|
KEEPALIVE_STATE(IN_HANDLER);
|
5525
|
5535
|
}
|
5526
|
5536
|
|
5527
|
|
-#endif // EMERGENCY_PARSER || ULTIPANEL
|
|
5537
|
+#endif // HAS_RESUME_CONTINUE
|
5528
|
5538
|
|
5529
|
5539
|
/**
|
5530
|
5540
|
* M17: Enable power on all stepper motors
|
|
@@ -5806,70 +5816,94 @@ inline void gcode_M42() {
|
5806
|
5816
|
#include "pinsDebug.h"
|
5807
|
5817
|
|
5808
|
5818
|
inline void toggle_pins() {
|
5809
|
|
- int pin, j;
|
5810
|
|
-
|
5811
|
|
- bool I_flag = code_seen('I') ? code_value_bool() : false;
|
5812
|
|
-
|
5813
|
|
- int repeat = code_seen('R') ? code_value_int() : 1,
|
5814
|
|
- start = code_seen('S') ? code_value_int() : 0,
|
5815
|
|
- end = code_seen('E') ? code_value_int() : NUM_DIGITAL_PINS - 1,
|
5816
|
|
- wait = code_seen('W') ? code_value_int() : 500;
|
|
5819
|
+ const bool I_flag = code_seen('I') && code_value_bool();
|
|
5820
|
+ const int repeat = code_seen('R') ? code_value_int() : 1,
|
|
5821
|
+ start = code_seen('S') ? code_value_int() : 0,
|
|
5822
|
+ end = code_seen('E') ? code_value_int() : NUM_DIGITAL_PINS - 1,
|
|
5823
|
+ wait = code_seen('W') ? code_value_int() : 500;
|
5817
|
5824
|
|
5818
|
|
- for (pin = start; pin <= end; pin++) {
|
5819
|
|
- if (!I_flag && pin_is_protected(pin)) {
|
5820
|
|
- SERIAL_ECHOPAIR("Sensitive Pin: ", pin);
|
5821
|
|
- SERIAL_ECHOPGM(" untouched.\n");
|
5822
|
|
- }
|
5823
|
|
- else {
|
5824
|
|
- SERIAL_ECHOPAIR("Pulsing Pin: ", pin);
|
5825
|
|
- pinMode(pin, OUTPUT);
|
5826
|
|
- for(j = 0; j < repeat; j++) {
|
5827
|
|
- digitalWrite(pin, 0);
|
5828
|
|
- safe_delay(wait);
|
5829
|
|
- digitalWrite(pin, 1);
|
5830
|
|
- safe_delay(wait);
|
5831
|
|
- digitalWrite(pin, 0);
|
5832
|
|
- safe_delay(wait);
|
5833
|
|
- }
|
|
5825
|
+ for (uint8_t pin = start; pin <= end; pin++) {
|
|
5826
|
+ if (!I_flag && pin_is_protected(pin)) {
|
|
5827
|
+ SERIAL_ECHOPAIR("Sensitive Pin: ", pin);
|
|
5828
|
+ SERIAL_ECHOLNPGM(" untouched.");
|
|
5829
|
+ }
|
|
5830
|
+ else {
|
|
5831
|
+ SERIAL_ECHOPAIR("Pulsing Pin: ", pin);
|
|
5832
|
+ pinMode(pin, OUTPUT);
|
|
5833
|
+ for (int16_t j = 0; j < repeat; j++) {
|
|
5834
|
+ digitalWrite(pin, 0);
|
|
5835
|
+ safe_delay(wait);
|
|
5836
|
+ digitalWrite(pin, 1);
|
|
5837
|
+ safe_delay(wait);
|
|
5838
|
+ digitalWrite(pin, 0);
|
|
5839
|
+ safe_delay(wait);
|
5834
|
5840
|
}
|
5835
|
|
- SERIAL_ECHOPGM("\n");
|
|
5841
|
+ }
|
|
5842
|
+ SERIAL_CHAR('\n');
|
5836
|
5843
|
}
|
5837
|
|
- SERIAL_ECHOPGM("Done\n");
|
|
5844
|
+ SERIAL_ECHOLNPGM("Done.");
|
|
5845
|
+
|
5838
|
5846
|
} // toggle_pins
|
5839
|
5847
|
|
5840
|
|
- inline void servo_probe_test(){
|
5841
|
|
- #if !(NUM_SERVOS >= 1 && HAS_SERVO_0)
|
|
5848
|
+ inline void servo_probe_test() {
|
|
5849
|
+ #if !(NUM_SERVOS > 0 && HAS_SERVO_0)
|
|
5850
|
+
|
5842
|
5851
|
SERIAL_ERROR_START;
|
5843
|
5852
|
SERIAL_ERRORLNPGM("SERVO not setup");
|
|
5853
|
+
|
5844
|
5854
|
#elif !HAS_Z_SERVO_ENDSTOP
|
|
5855
|
+
|
5845
|
5856
|
SERIAL_ERROR_START;
|
5846
|
5857
|
SERIAL_ERRORLNPGM("Z_ENDSTOP_SERVO_NR not setup");
|
|
5858
|
+
|
5847
|
5859
|
#else
|
5848
|
|
- uint8_t probe_index = code_seen('P') ? code_value_byte() : Z_ENDSTOP_SERVO_NR;
|
|
5860
|
+
|
|
5861
|
+ #if !defined(z_servo_angle)
|
|
5862
|
+ const int z_servo_angle[2] = Z_SERVO_ANGLES;
|
|
5863
|
+ #endif
|
|
5864
|
+
|
|
5865
|
+ const uint8_t probe_index = code_seen('P') ? code_value_byte() : Z_ENDSTOP_SERVO_NR;
|
|
5866
|
+
|
5849
|
5867
|
SERIAL_PROTOCOLLNPGM("Servo probe test");
|
5850
|
5868
|
SERIAL_PROTOCOLLNPAIR(". using index: ", probe_index);
|
5851
|
5869
|
SERIAL_PROTOCOLLNPAIR(". deploy angle: ", z_servo_angle[0]);
|
5852
|
5870
|
SERIAL_PROTOCOLLNPAIR(". stow angle: ", z_servo_angle[1]);
|
|
5871
|
+
|
5853
|
5872
|
bool probe_inverting;
|
|
5873
|
+
|
5854
|
5874
|
#if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
|
|
5875
|
+
|
5855
|
5876
|
#define PROBE_TEST_PIN Z_MIN_PIN
|
|
5877
|
+
|
5856
|
5878
|
SERIAL_PROTOCOLLNPAIR(". probe uses Z_MIN pin: ", PROBE_TEST_PIN);
|
5857
|
5879
|
SERIAL_PROTOCOLLNPGM(". uses Z_MIN_ENDSTOP_INVERTING (ignores Z_MIN_PROBE_ENDSTOP_INVERTING)");
|
5858
|
5880
|
SERIAL_PROTOCOLPGM(". Z_MIN_ENDSTOP_INVERTING: ");
|
5859
|
|
- if (Z_MIN_ENDSTOP_INVERTING) SERIAL_PROTOCOLLNPGM("true");
|
5860
|
|
- else SERIAL_PROTOCOLLNPGM("false");
|
|
5881
|
+
|
|
5882
|
+ #if Z_MIN_ENDSTOP_INVERTING
|
|
5883
|
+ SERIAL_PROTOCOLLNPGM("true");
|
|
5884
|
+ #else
|
|
5885
|
+ SERIAL_PROTOCOLLNPGM("false");
|
|
5886
|
+ #endif
|
|
5887
|
+
|
5861
|
5888
|
probe_inverting = Z_MIN_ENDSTOP_INVERTING;
|
|
5889
|
+
|
5862
|
5890
|
#elif ENABLED(Z_MIN_PROBE_ENDSTOP)
|
|
5891
|
+
|
5863
|
5892
|
#define PROBE_TEST_PIN Z_MIN_PROBE_PIN
|
5864
|
5893
|
SERIAL_PROTOCOLLNPAIR(". probe uses Z_MIN_PROBE_PIN: ", PROBE_TEST_PIN);
|
5865
|
5894
|
SERIAL_PROTOCOLLNPGM(". uses Z_MIN_PROBE_ENDSTOP_INVERTING (ignores Z_MIN_ENDSTOP_INVERTING)");
|
5866
|
5895
|
SERIAL_PROTOCOLPGM(". Z_MIN_PROBE_ENDSTOP_INVERTING: ");
|
5867
|
|
- if (Z_MIN_PROBE_ENDSTOP_INVERTING) SERIAL_PROTOCOLLNPGM("true");
|
5868
|
|
- else SERIAL_PROTOCOLLNPGM("false");
|
|
5896
|
+
|
|
5897
|
+ #if Z_MIN_PROBE_ENDSTOP_INVERTING
|
|
5898
|
+ SERIAL_PROTOCOLLNPGM("true");
|
|
5899
|
+ #else
|
|
5900
|
+ SERIAL_PROTOCOLLNPGM("false");
|
|
5901
|
+ #endif
|
|
5902
|
+
|
5869
|
5903
|
probe_inverting = Z_MIN_PROBE_ENDSTOP_INVERTING;
|
5870
|
|
- #else
|
5871
|
|
- #error "ERROR - probe pin not defined - strange, SANITY_CHECK should have caught this"
|
|
5904
|
+
|
5872
|
5905
|
#endif
|
|
5906
|
+
|
5873
|
5907
|
SERIAL_PROTOCOLLNPGM(". deploy & stow 4 times");
|
5874
|
5908
|
pinMode(PROBE_TEST_PIN, INPUT_PULLUP);
|
5875
|
5909
|
bool deploy_state;
|
|
@@ -5883,7 +5917,9 @@ inline void gcode_M42() {
|
5883
|
5917
|
stow_state = digitalRead(PROBE_TEST_PIN);
|
5884
|
5918
|
}
|
5885
|
5919
|
if (probe_inverting != deploy_state) SERIAL_PROTOCOLLNPGM("WARNING - INVERTING setting probably backwards");
|
|
5920
|
+
|
5886
|
5921
|
refresh_cmd_timeout();
|
|
5922
|
+
|
5887
|
5923
|
if (deploy_state != stow_state) {
|
5888
|
5924
|
SERIAL_PROTOCOLLNPGM("BLTouch clone detected");
|
5889
|
5925
|
if (deploy_state) {
|
|
@@ -5900,32 +5936,43 @@ inline void gcode_M42() {
|
5900
|
5936
|
|
5901
|
5937
|
}
|
5902
|
5938
|
else { // measure active signal length
|
5903
|
|
- servo[probe_index].move(z_servo_angle[0]); //deploy
|
|
5939
|
+ servo[probe_index].move(z_servo_angle[0]); // deploy
|
5904
|
5940
|
safe_delay(500);
|
5905
|
5941
|
SERIAL_PROTOCOLLNPGM("please trigger probe");
|
5906
|
5942
|
uint16_t probe_counter = 0;
|
5907
|
|
- for (uint16_t j = 0; j < 500*30 && probe_counter == 0 ; j++) { // allow 30 seconds max for operator to trigger probe
|
|
5943
|
+
|
|
5944
|
+ // Allow 30 seconds max for operator to trigger probe
|
|
5945
|
+ for (uint16_t j = 0; j < 500 * 30 && probe_counter == 0 ; j++) {
|
|
5946
|
+
|
5908
|
5947
|
safe_delay(2);
|
5909
|
|
- if ( 0 == j%(500*1)) {refresh_cmd_timeout(); watchdog_reset();} // beat the dog every 45 seconds
|
5910
|
|
- if (deploy_state != digitalRead(PROBE_TEST_PIN)) { // probe triggered
|
5911
|
|
- for (probe_counter = 1; probe_counter < 50 && (deploy_state != digitalRead(PROBE_TEST_PIN)); probe_counter ++) {
|
|
5948
|
+
|
|
5949
|
+ if (0 == j % (500 * 1)) // keep cmd_timeout happy
|
|
5950
|
+ refresh_cmd_timeout();
|
|
5951
|
+
|
|
5952
|
+ if (deploy_state != digitalRead(PROBE_TEST_PIN)) { // probe triggered
|
|
5953
|
+
|
|
5954
|
+ for (probe_counter = 1; probe_counter < 50 && deploy_state != digitalRead(PROBE_TEST_PIN); ++probe_counter)
|
5912
|
5955
|
safe_delay(2);
|
5913
|
|
- }
|
5914
|
|
- if (probe_counter == 50) {
|
5915
|
|
- SERIAL_PROTOCOLLNPGM("Z Servo Probe detected"); // >= 100mS active time
|
5916
|
|
- }
|
5917
|
|
- else if (probe_counter >= 2 ) {
|
5918
|
|
- SERIAL_PROTOCOLLNPAIR("BLTouch compatible probe detected - pulse width (+/- 4mS): ", probe_counter * 2 ); // allow 4 - 100mS pulse
|
5919
|
|
- }
|
5920
|
|
- else {
|
5921
|
|
- SERIAL_PROTOCOLLNPGM("noise detected - please re-run test"); // less than 2mS pulse
|
5922
|
|
- }
|
|
5956
|
+
|
|
5957
|
+ if (probe_counter == 50)
|
|
5958
|
+ SERIAL_PROTOCOLLNPGM("Z Servo Probe detected"); // >= 100mS active time
|
|
5959
|
+ else if (probe_counter >= 2)
|
|
5960
|
+ SERIAL_PROTOCOLLNPAIR("BLTouch compatible probe detected - pulse width (+/- 4mS): ", probe_counter * 2); // allow 4 - 100mS pulse
|
|
5961
|
+ else
|
|
5962
|
+ SERIAL_PROTOCOLLNPGM("noise detected - please re-run test"); // less than 2mS pulse
|
|
5963
|
+
|
5923
|
5964
|
servo[probe_index].move(z_servo_angle[1]); //stow
|
|
5965
|
+
|
5924
|
5966
|
} // pulse detected
|
5925
|
|
- } // for loop waiting for trigger
|
|
5967
|
+
|
|
5968
|
+ } // for loop waiting for trigger
|
|
5969
|
+
|
5926
|
5970
|
if (probe_counter == 0) SERIAL_PROTOCOLLNPGM("trigger not detected");
|
5927
|
|
- } // measure active signal length
|
|
5971
|
+
|
|
5972
|
+ } // measure active signal length
|
|
5973
|
+
|
5928
|
5974
|
#endif
|
|
5975
|
+
|
5929
|
5976
|
} // servo_probe_test
|
5930
|
5977
|
|
5931
|
5978
|
/**
|
|
@@ -5977,39 +6024,43 @@ inline void gcode_M42() {
|
5977
|
6024
|
}
|
5978
|
6025
|
|
5979
|
6026
|
// Get the range of pins to test or watch
|
5980
|
|
- int first_pin = 0, last_pin = NUM_DIGITAL_PINS - 1;
|
5981
|
|
- if (code_seen('P')) {
|
5982
|
|
- first_pin = last_pin = code_value_byte();
|
5983
|
|
- if (first_pin > NUM_DIGITAL_PINS - 1) return;
|
5984
|
|
- }
|
|
6027
|
+ const uint8_t first_pin = code_seen('P') ? code_value_byte() : 0,
|
|
6028
|
+ last_pin = code_seen('P') ? first_pin : NUM_DIGITAL_PINS - 1;
|
5985
|
6029
|
|
5986
|
|
- bool ignore_protection = code_seen('I') ? code_value_bool() : false;
|
|
6030
|
+ if (first_pin > last_pin) return;
|
|
6031
|
+
|
|
6032
|
+ const bool ignore_protection = code_seen('I') && code_value_bool();
|
5987
|
6033
|
|
5988
|
6034
|
// Watch until click, M108, or reset
|
5989
|
|
- if (code_seen('W') && code_value_bool()) { // watch digital pins
|
|
6035
|
+ if (code_seen('W') && code_value_bool()) {
|
5990
|
6036
|
SERIAL_PROTOCOLLNPGM("Watching pins");
|
5991
|
6037
|
byte pin_state[last_pin - first_pin + 1];
|
5992
|
6038
|
for (int8_t pin = first_pin; pin <= last_pin; pin++) {
|
5993
|
6039
|
if (pin_is_protected(pin) && !ignore_protection) continue;
|
5994
|
6040
|
pinMode(pin, INPUT_PULLUP);
|
5995
|
|
- // if (IS_ANALOG(pin))
|
5996
|
|
- // pin_state[pin - first_pin] = analogRead(pin - analogInputToDigitalPin(0)); // int16_t pin_state[...]
|
5997
|
|
- // else
|
5998
|
|
- pin_state[pin - first_pin] = digitalRead(pin);
|
|
6041
|
+ /*
|
|
6042
|
+ if (IS_ANALOG(pin))
|
|
6043
|
+ pin_state[pin - first_pin] = analogRead(pin - analogInputToDigitalPin(0)); // int16_t pin_state[...]
|
|
6044
|
+ else
|
|
6045
|
+ //*/
|
|
6046
|
+ pin_state[pin - first_pin] = digitalRead(pin);
|
5999
|
6047
|
}
|
6000
|
6048
|
|
6001
|
6049
|
#if HAS_RESUME_CONTINUE
|
6002
|
6050
|
wait_for_user = true;
|
|
6051
|
+ KEEPALIVE_STATE(PAUSED_FOR_USER);
|
6003
|
6052
|
#endif
|
6004
|
6053
|
|
6005
|
|
- for(;;) {
|
|
6054
|
+ for (;;) {
|
6006
|
6055
|
for (int8_t pin = first_pin; pin <= last_pin; pin++) {
|
6007
|
6056
|
if (pin_is_protected(pin)) continue;
|
6008
|
|
- byte val;
|
6009
|
|
- // if (IS_ANALOG(pin))
|
6010
|
|
- // val = analogRead(pin - analogInputToDigitalPin(0)); // int16_t val
|
6011
|
|
- // else
|
6012
|
|
- val = digitalRead(pin);
|
|
6057
|
+ const byte val =
|
|
6058
|
+ /*
|
|
6059
|
+ IS_ANALOG(pin)
|
|
6060
|
+ ? analogRead(pin - analogInputToDigitalPin(0)) : // int16_t val
|
|
6061
|
+ :
|
|
6062
|
+ //*/
|
|
6063
|
+ digitalRead(pin);
|
6013
|
6064
|
if (val != pin_state[pin - first_pin]) {
|
6014
|
6065
|
report_pin_state(pin);
|
6015
|
6066
|
pin_state[pin - first_pin] = val;
|
|
@@ -6017,7 +6068,10 @@ inline void gcode_M42() {
|
6017
|
6068
|
}
|
6018
|
6069
|
|
6019
|
6070
|
#if HAS_RESUME_CONTINUE
|
6020
|
|
- if (!wait_for_user) break;
|
|
6071
|
+ if (!wait_for_user) {
|
|
6072
|
+ KEEPALIVE_STATE(IN_HANDLER);
|
|
6073
|
+ break;
|
|
6074
|
+ }
|
6021
|
6075
|
#endif
|
6022
|
6076
|
|
6023
|
6077
|
safe_delay(500);
|
|
@@ -9571,8 +9625,8 @@ void process_next_command() {
|
9571
|
9625
|
SERIAL_ECHO_START;
|
9572
|
9626
|
SERIAL_ECHOLN(current_command);
|
9573
|
9627
|
#if ENABLED(M100_FREE_MEMORY_WATCHER)
|
9574
|
|
- SERIAL_ECHOPAIR("slot:", cmd_queue_index_r);
|
9575
|
|
- M100_dump_routine( " Command Queue:", &command_queue[0][0], &command_queue[BUFSIZE][MAX_CMD_SIZE] );
|
|
9628
|
+ SERIAL_ECHOPAIR("slot:", cmd_queue_index_r);
|
|
9629
|
+ M100_dump_routine(" Command Queue:", &command_queue[0][0], &command_queue[BUFSIZE][MAX_CMD_SIZE]);
|
9576
|
9630
|
#endif
|
9577
|
9631
|
}
|
9578
|
9632
|
|
|
@@ -11166,19 +11220,20 @@ void prepare_move_to_destination() {
|
11166
|
11220
|
*/
|
11167
|
11221
|
void plan_arc(
|
11168
|
11222
|
float logical[XYZE], // Destination position
|
11169
|
|
- float* offset, // Center of rotation relative to current_position
|
11170
|
|
- uint8_t clockwise // Clockwise?
|
|
11223
|
+ float *offset, // Center of rotation relative to current_position
|
|
11224
|
+ uint8_t clockwise // Clockwise?
|
11171
|
11225
|
) {
|
11172
|
11226
|
|
11173
|
|
- float radius = HYPOT(offset[X_AXIS], offset[Y_AXIS]),
|
11174
|
|
- center_X = current_position[X_AXIS] + offset[X_AXIS],
|
11175
|
|
- center_Y = current_position[Y_AXIS] + offset[Y_AXIS],
|
11176
|
|
- linear_travel = logical[Z_AXIS] - current_position[Z_AXIS],
|
11177
|
|
- extruder_travel = logical[E_AXIS] - current_position[E_AXIS],
|
11178
|
|
- r_X = -offset[X_AXIS], // Radius vector from center to current location
|
11179
|
|
- r_Y = -offset[Y_AXIS],
|
11180
|
|
- rt_X = logical[X_AXIS] - center_X,
|
11181
|
|
- rt_Y = logical[Y_AXIS] - center_Y;
|
|
11227
|
+ float r_X = -offset[X_AXIS], // Radius vector from center to current location
|
|
11228
|
+ r_Y = -offset[Y_AXIS];
|
|
11229
|
+
|
|
11230
|
+ const float radius = HYPOT(r_X, r_Y),
|
|
11231
|
+ center_X = current_position[X_AXIS] - r_X,
|
|
11232
|
+ center_Y = current_position[Y_AXIS] - r_Y,
|
|
11233
|
+ rt_X = logical[X_AXIS] - center_X,
|
|
11234
|
+ rt_Y = logical[Y_AXIS] - center_Y,
|
|
11235
|
+ linear_travel = logical[Z_AXIS] - current_position[Z_AXIS],
|
|
11236
|
+ extruder_travel = logical[E_AXIS] - current_position[E_AXIS];
|
11182
|
11237
|
|
11183
|
11238
|
// CCW angle of rotation between position and target from the circle center. Only one atan2() trig computation required.
|
11184
|
11239
|
float angular_travel = atan2(r_X * rt_Y - r_Y * rt_X, r_X * rt_X + r_Y * rt_Y);
|
|
@@ -11222,12 +11277,12 @@ void prepare_move_to_destination() {
|
11222
|
11277
|
* This is important when there are successive arc motions.
|
11223
|
11278
|
*/
|
11224
|
11279
|
// Vector rotation matrix values
|
11225
|
|
- float arc_target[XYZE],
|
11226
|
|
- theta_per_segment = angular_travel / segments,
|
11227
|
|
- linear_per_segment = linear_travel / segments,
|
11228
|
|
- extruder_per_segment = extruder_travel / segments,
|
11229
|
|
- sin_T = theta_per_segment,
|
11230
|
|
- cos_T = 1 - 0.5 * sq(theta_per_segment); // Small angle approximation
|
|
11280
|
+ float arc_target[XYZE];
|
|
11281
|
+ const float theta_per_segment = angular_travel / segments,
|
|
11282
|
+ linear_per_segment = linear_travel / segments,
|
|
11283
|
+ extruder_per_segment = extruder_travel / segments,
|
|
11284
|
+ sin_T = theta_per_segment,
|
|
11285
|
+ cos_T = 1 - 0.5 * sq(theta_per_segment); // Small angle approximation
|
11231
|
11286
|
|
11232
|
11287
|
// Initialize the linear axis
|
11233
|
11288
|
arc_target[Z_AXIS] = current_position[Z_AXIS];
|
|
@@ -11235,7 +11290,7 @@ void prepare_move_to_destination() {
|
11235
|
11290
|
// Initialize the extruder axis
|
11236
|
11291
|
arc_target[E_AXIS] = current_position[E_AXIS];
|
11237
|
11292
|
|
11238
|
|
- float fr_mm_s = MMS_SCALED(feedrate_mm_s);
|
|
11293
|
+ const float fr_mm_s = MMS_SCALED(feedrate_mm_s);
|
11239
|
11294
|
|
11240
|
11295
|
millis_t next_idle_ms = millis() + 200UL;
|
11241
|
11296
|
|
|
@@ -11250,7 +11305,7 @@ void prepare_move_to_destination() {
|
11250
|
11305
|
|
11251
|
11306
|
if (++count < N_ARC_CORRECTION) {
|
11252
|
11307
|
// Apply vector rotation matrix to previous r_X / 1
|
11253
|
|
- float r_new_Y = r_X * sin_T + r_Y * cos_T;
|
|
11308
|
+ const float r_new_Y = r_X * sin_T + r_Y * cos_T;
|
11254
|
11309
|
r_X = r_X * cos_T - r_Y * sin_T;
|
11255
|
11310
|
r_Y = r_new_Y;
|
11256
|
11311
|
}
|
|
@@ -11259,8 +11314,8 @@ void prepare_move_to_destination() {
|
11259
|
11314
|
// Compute exact location by applying transformation matrix from initial radius vector(=-offset).
|
11260
|
11315
|
// To reduce stuttering, the sin and cos could be computed at different times.
|
11261
|
11316
|
// For now, compute both at the same time.
|
11262
|
|
- float cos_Ti = cos(i * theta_per_segment),
|
11263
|
|
- sin_Ti = sin(i * theta_per_segment);
|
|
11317
|
+ const float cos_Ti = cos(i * theta_per_segment),
|
|
11318
|
+ sin_Ti = sin(i * theta_per_segment);
|
11264
|
11319
|
r_X = -offset[X_AXIS] * cos_Ti + offset[Y_AXIS] * sin_Ti;
|
11265
|
11320
|
r_Y = -offset[X_AXIS] * sin_Ti - offset[Y_AXIS] * cos_Ti;
|
11266
|
11321
|
count = 0;
|
|
@@ -11774,30 +11829,15 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
|
11774
|
11829
|
enable_E0();
|
11775
|
11830
|
#else // !SWITCHING_EXTRUDER
|
11776
|
11831
|
switch (active_extruder) {
|
11777
|
|
- case 0:
|
11778
|
|
- oldstatus = E0_ENABLE_READ;
|
11779
|
|
- enable_E0();
|
11780
|
|
- break;
|
|
11832
|
+ case 0: oldstatus = E0_ENABLE_READ; enable_E0(); break;
|
11781
|
11833
|
#if E_STEPPERS > 1
|
11782
|
|
- case 1:
|
11783
|
|
- oldstatus = E1_ENABLE_READ;
|
11784
|
|
- enable_E1();
|
11785
|
|
- break;
|
|
11834
|
+ case 1: oldstatus = E1_ENABLE_READ; enable_E1(); break;
|
11786
|
11835
|
#if E_STEPPERS > 2
|
11787
|
|
- case 2:
|
11788
|
|
- oldstatus = E2_ENABLE_READ;
|
11789
|
|
- enable_E2();
|
11790
|
|
- break;
|
|
11836
|
+ case 2: oldstatus = E2_ENABLE_READ; enable_E2(); break;
|
11791
|
11837
|
#if E_STEPPERS > 3
|
11792
|
|
- case 3:
|
11793
|
|
- oldstatus = E3_ENABLE_READ;
|
11794
|
|
- enable_E3();
|
11795
|
|
- break;
|
|
11838
|
+ case 3: oldstatus = E3_ENABLE_READ; enable_E3(); break;
|
11796
|
11839
|
#if E_STEPPERS > 4
|
11797
|
|
- case 4:
|
11798
|
|
- oldstatus = E4_ENABLE_READ;
|
11799
|
|
- enable_E4();
|
11800
|
|
- break;
|
|
11840
|
+ case 4: oldstatus = E4_ENABLE_READ; enable_E4(); break;
|
11801
|
11841
|
#endif // E_STEPPERS > 4
|
11802
|
11842
|
#endif // E_STEPPERS > 3
|
11803
|
11843
|
#endif // E_STEPPERS > 2
|
|
@@ -11817,25 +11857,15 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
|
11817
|
11857
|
E0_ENABLE_WRITE(oldstatus);
|
11818
|
11858
|
#else
|
11819
|
11859
|
switch (active_extruder) {
|
11820
|
|
- case 0:
|
11821
|
|
- E0_ENABLE_WRITE(oldstatus);
|
11822
|
|
- break;
|
|
11860
|
+ case 0: E0_ENABLE_WRITE(oldstatus); break;
|
11823
|
11861
|
#if E_STEPPERS > 1
|
11824
|
|
- case 1:
|
11825
|
|
- E1_ENABLE_WRITE(oldstatus);
|
11826
|
|
- break;
|
|
11862
|
+ case 1: E1_ENABLE_WRITE(oldstatus); break;
|
11827
|
11863
|
#if E_STEPPERS > 2
|
11828
|
|
- case 2:
|
11829
|
|
- E2_ENABLE_WRITE(oldstatus);
|
11830
|
|
- break;
|
|
11864
|
+ case 2: E2_ENABLE_WRITE(oldstatus); break;
|
11831
|
11865
|
#if E_STEPPERS > 3
|
11832
|
|
- case 3:
|
11833
|
|
- E3_ENABLE_WRITE(oldstatus);
|
11834
|
|
- break;
|
|
11866
|
+ case 3: E3_ENABLE_WRITE(oldstatus); break;
|
11835
|
11867
|
#if E_STEPPERS > 4
|
11836
|
|
- case 4:
|
11837
|
|
- E4_ENABLE_WRITE(oldstatus);
|
11838
|
|
- break;
|
|
11868
|
+ case 4: E4_ENABLE_WRITE(oldstatus); break;
|
11839
|
11869
|
#endif // E_STEPPERS > 4
|
11840
|
11870
|
#endif // E_STEPPERS > 3
|
11841
|
11871
|
#endif // E_STEPPERS > 2
|