|
@@ -244,11 +244,11 @@ static char *strchr_pointer; ///< A pointer to find chars in the command string
|
244
|
244
|
const char* queued_commands_P= NULL; /* pointer to the current line in the active sequence of commands, or NULL when none */
|
245
|
245
|
const int sensitive_pins[] = SENSITIVE_PINS; ///< Sensitive pin list for M42
|
246
|
246
|
// Inactivity shutdown
|
247
|
|
-unsigned long previous_millis_cmd = 0;
|
248
|
|
-static unsigned long max_inactive_time = 0;
|
249
|
|
-static unsigned long stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME*1000l;
|
250
|
|
-unsigned long starttime = 0; ///< Print job start time
|
251
|
|
-unsigned long stoptime = 0; ///< Print job stop time
|
|
247
|
+millis_t previous_cmd_ms = 0;
|
|
248
|
+static millis_t max_inactive_time = 0;
|
|
249
|
+static millis_t stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME * 1000L;
|
|
250
|
+millis_t starttime = 0; ///< Print job start time
|
|
251
|
+millis_t stoptime = 0; ///< Print job stop time
|
252
|
252
|
static uint8_t target_extruder;
|
253
|
253
|
bool CooldownNoWait = true;
|
254
|
254
|
bool target_direction;
|
|
@@ -425,7 +425,7 @@ static bool drain_queued_commands_P() {
|
425
|
425
|
char c;
|
426
|
426
|
while((c = cmd[i]) && c != '\n') i++; // find the end of this gcode command
|
427
|
427
|
cmd[i] = '\0';
|
428
|
|
- if (enquecommand(cmd)) { // buffer was not full (else we will retry later)
|
|
428
|
+ if (enqueuecommand(cmd)) { // buffer was not full (else we will retry later)
|
429
|
429
|
if (c)
|
430
|
430
|
queued_commands_P += i + 1; // move to next command
|
431
|
431
|
else
|
|
@@ -437,7 +437,7 @@ static bool drain_queued_commands_P() {
|
437
|
437
|
//Record one or many commands to run from program memory.
|
438
|
438
|
//Aborts the current queue, if any.
|
439
|
439
|
//Note: drain_queued_commands_P() must be called repeatedly to drain the commands afterwards
|
440
|
|
-void enquecommands_P(const char* pgcode) {
|
|
440
|
+void enqueuecommands_P(const char* pgcode) {
|
441
|
441
|
queued_commands_P = pgcode;
|
442
|
442
|
drain_queued_commands_P(); // first command executed asap (when possible)
|
443
|
443
|
}
|
|
@@ -446,7 +446,7 @@ void enquecommands_P(const char* pgcode) {
|
446
|
446
|
//that is really done in a non-safe way.
|
447
|
447
|
//needs overworking someday
|
448
|
448
|
//Returns false if it failed to do so
|
449
|
|
-bool enquecommand(const char *cmd)
|
|
449
|
+bool enqueuecommand(const char *cmd)
|
450
|
450
|
{
|
451
|
451
|
if(*cmd==';')
|
452
|
452
|
return false;
|
|
@@ -666,33 +666,30 @@ void loop() {
|
666
|
666
|
lcd_update();
|
667
|
667
|
}
|
668
|
668
|
|
669
|
|
-void get_command()
|
670
|
|
-{
|
671
|
|
- if (drain_queued_commands_P()) // priority is given to non-serial commands
|
672
|
|
- return;
|
|
669
|
+void get_command() {
|
|
670
|
+
|
|
671
|
+ if (drain_queued_commands_P()) return; // priority is given to non-serial commands
|
673
|
672
|
|
674
|
|
- while( MYSERIAL.available() > 0 && buflen < BUFSIZE) {
|
|
673
|
+ while (MYSERIAL.available() > 0 && buflen < BUFSIZE) {
|
675
|
674
|
serial_char = MYSERIAL.read();
|
676
|
|
- if(serial_char == '\n' ||
|
677
|
|
- serial_char == '\r' ||
|
678
|
|
- serial_count >= (MAX_CMD_SIZE - 1) )
|
679
|
|
- {
|
|
675
|
+ if (serial_char == '\n' || serial_char == '\r' ||
|
|
676
|
+ serial_count >= (MAX_CMD_SIZE - 1)
|
|
677
|
+ ) {
|
680
|
678
|
// end of line == end of comment
|
681
|
679
|
comment_mode = false;
|
682
|
680
|
|
683
|
|
- if(!serial_count) {
|
684
|
|
- // short cut for empty lines
|
685
|
|
- return;
|
686
|
|
- }
|
687
|
|
- cmdbuffer[bufindw][serial_count] = 0; //terminate string
|
|
681
|
+ if (!serial_count) return; // shortcut for empty lines
|
|
682
|
+
|
|
683
|
+ cmdbuffer[bufindw][serial_count] = 0; // terminate string
|
|
684
|
+
|
688
|
685
|
#ifdef SDSUPPORT
|
689
|
|
- fromsd[bufindw] = false;
|
690
|
|
- #endif //!SDSUPPORT
|
691
|
|
- if(strchr(cmdbuffer[bufindw], 'N') != NULL)
|
692
|
|
- {
|
|
686
|
+ fromsd[bufindw] = false;
|
|
687
|
+ #endif
|
|
688
|
+
|
|
689
|
+ if (strchr(cmdbuffer[bufindw], 'N') != NULL) {
|
693
|
690
|
strchr_pointer = strchr(cmdbuffer[bufindw], 'N');
|
694
|
691
|
gcode_N = (strtol(strchr_pointer + 1, NULL, 10));
|
695
|
|
- if(gcode_N != gcode_LastN+1 && (strstr_P(cmdbuffer[bufindw], PSTR("M110")) == NULL) ) {
|
|
692
|
+ if (gcode_N != gcode_LastN + 1 && strstr_P(cmdbuffer[bufindw], PSTR("M110")) == NULL) {
|
696
|
693
|
SERIAL_ERROR_START;
|
697
|
694
|
SERIAL_ERRORPGM(MSG_ERR_LINE_NO);
|
698
|
695
|
SERIAL_ERRORLN(gcode_LastN);
|
|
@@ -702,14 +699,13 @@ void get_command()
|
702
|
699
|
return;
|
703
|
700
|
}
|
704
|
701
|
|
705
|
|
- if(strchr(cmdbuffer[bufindw], '*') != NULL)
|
706
|
|
- {
|
|
702
|
+ if (strchr(cmdbuffer[bufindw], '*') != NULL) {
|
707
|
703
|
byte checksum = 0;
|
708
|
704
|
byte count = 0;
|
709
|
|
- while(cmdbuffer[bufindw][count] != '*') checksum = checksum^cmdbuffer[bufindw][count++];
|
|
705
|
+ while (cmdbuffer[bufindw][count] != '*') checksum ^= cmdbuffer[bufindw][count++];
|
710
|
706
|
strchr_pointer = strchr(cmdbuffer[bufindw], '*');
|
711
|
707
|
|
712
|
|
- if(strtol(strchr_pointer + 1, NULL, 10) != checksum) {
|
|
708
|
+ if (strtol(strchr_pointer + 1, NULL, 10) != checksum) {
|
713
|
709
|
SERIAL_ERROR_START;
|
714
|
710
|
SERIAL_ERRORPGM(MSG_ERR_CHECKSUM_MISMATCH);
|
715
|
711
|
SERIAL_ERRORLN(gcode_LastN);
|
|
@@ -719,8 +715,7 @@ void get_command()
|
719
|
715
|
}
|
720
|
716
|
//if no errors, continue parsing
|
721
|
717
|
}
|
722
|
|
- else
|
723
|
|
- {
|
|
718
|
+ else {
|
724
|
719
|
SERIAL_ERROR_START;
|
725
|
720
|
SERIAL_ERRORPGM(MSG_ERR_NO_CHECKSUM);
|
726
|
721
|
SERIAL_ERRORLN(gcode_LastN);
|
|
@@ -732,10 +727,8 @@ void get_command()
|
732
|
727
|
gcode_LastN = gcode_N;
|
733
|
728
|
//if no errors, continue parsing
|
734
|
729
|
}
|
735
|
|
- else // if we don't receive 'N' but still see '*'
|
736
|
|
- {
|
737
|
|
- if((strchr(cmdbuffer[bufindw], '*') != NULL))
|
738
|
|
- {
|
|
730
|
+ else { // if we don't receive 'N' but still see '*'
|
|
731
|
+ if ((strchr(cmdbuffer[bufindw], '*') != NULL)) {
|
739
|
732
|
SERIAL_ERROR_START;
|
740
|
733
|
SERIAL_ERRORPGM(MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM);
|
741
|
734
|
SERIAL_ERRORLN(gcode_LastN);
|
|
@@ -743,111 +736,99 @@ void get_command()
|
743
|
736
|
return;
|
744
|
737
|
}
|
745
|
738
|
}
|
746
|
|
- if((strchr(cmdbuffer[bufindw], 'G') != NULL)){
|
|
739
|
+
|
|
740
|
+ if (strchr(cmdbuffer[bufindw], 'G') != NULL) {
|
747
|
741
|
strchr_pointer = strchr(cmdbuffer[bufindw], 'G');
|
748
|
|
- switch(strtol(strchr_pointer + 1, NULL, 10)){
|
749
|
|
- case 0:
|
750
|
|
- case 1:
|
751
|
|
- case 2:
|
752
|
|
- case 3:
|
753
|
|
- if (IsStopped()) {
|
754
|
|
- SERIAL_ERRORLNPGM(MSG_ERR_STOPPED);
|
755
|
|
- LCD_MESSAGEPGM(MSG_STOPPED);
|
756
|
|
- }
|
757
|
|
- break;
|
758
|
|
- default:
|
759
|
|
- break;
|
|
742
|
+ switch (strtol(strchr_pointer + 1, NULL, 10)) {
|
|
743
|
+ case 0:
|
|
744
|
+ case 1:
|
|
745
|
+ case 2:
|
|
746
|
+ case 3:
|
|
747
|
+ if (IsStopped()) {
|
|
748
|
+ SERIAL_ERRORLNPGM(MSG_ERR_STOPPED);
|
|
749
|
+ LCD_MESSAGEPGM(MSG_STOPPED);
|
|
750
|
+ }
|
|
751
|
+ break;
|
|
752
|
+ default:
|
|
753
|
+ break;
|
760
|
754
|
}
|
761
|
|
-
|
762
|
755
|
}
|
763
|
756
|
|
764
|
|
- //If command was e-stop process now
|
765
|
|
- if(strcmp(cmdbuffer[bufindw], "M112") == 0)
|
766
|
|
- kill();
|
|
757
|
+ // If command was e-stop process now
|
|
758
|
+ if (strcmp(cmdbuffer[bufindw], "M112") == 0) kill();
|
767
|
759
|
|
768
|
|
- bufindw = (bufindw + 1)%BUFSIZE;
|
|
760
|
+ bufindw = (bufindw + 1) % BUFSIZE;
|
769
|
761
|
buflen += 1;
|
770
|
762
|
|
771
|
763
|
serial_count = 0; //clear buffer
|
772
|
764
|
}
|
773
|
|
- else if(serial_char == '\\') { //Handle escapes
|
774
|
|
-
|
775
|
|
- if(MYSERIAL.available() > 0 && buflen < BUFSIZE) {
|
776
|
|
- // if we have one more character, copy it over
|
777
|
|
- serial_char = MYSERIAL.read();
|
778
|
|
- cmdbuffer[bufindw][serial_count++] = serial_char;
|
779
|
|
- }
|
780
|
|
-
|
781
|
|
- //otherwise do nothing
|
|
765
|
+ else if (serial_char == '\\') { // Handle escapes
|
|
766
|
+ if (MYSERIAL.available() > 0 && buflen < BUFSIZE) {
|
|
767
|
+ // if we have one more character, copy it over
|
|
768
|
+ serial_char = MYSERIAL.read();
|
|
769
|
+ cmdbuffer[bufindw][serial_count++] = serial_char;
|
|
770
|
+ }
|
|
771
|
+ // otherwise do nothing
|
782
|
772
|
}
|
783
|
773
|
else { // its not a newline, carriage return or escape char
|
784
|
|
- if(serial_char == ';') comment_mode = true;
|
785
|
|
- if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
|
|
774
|
+ if (serial_char == ';') comment_mode = true;
|
|
775
|
+ if (!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
|
786
|
776
|
}
|
787
|
777
|
}
|
788
|
|
- #ifdef SDSUPPORT
|
789
|
|
- if(!card.sdprinting || serial_count!=0){
|
790
|
|
- return;
|
791
|
|
- }
|
792
|
778
|
|
793
|
|
- //'#' stops reading from SD to the buffer prematurely, so procedural macro calls are possible
|
794
|
|
- // if it occurs, stop_buffering is triggered and the buffer is ran dry.
|
795
|
|
- // this character _can_ occur in serial com, due to checksums. however, no checksums are used in SD printing
|
796
|
|
-
|
797
|
|
- static bool stop_buffering=false;
|
798
|
|
- if(buflen==0) stop_buffering=false;
|
799
|
|
-
|
800
|
|
- while( !card.eof() && buflen < BUFSIZE && !stop_buffering) {
|
801
|
|
- int16_t n=card.get();
|
802
|
|
- serial_char = (char)n;
|
803
|
|
- if(serial_char == '\n' ||
|
804
|
|
- serial_char == '\r' ||
|
805
|
|
- (serial_char == '#' && comment_mode == false) ||
|
806
|
|
- (serial_char == ':' && comment_mode == false) ||
|
807
|
|
- serial_count >= (MAX_CMD_SIZE - 1)||n==-1)
|
808
|
|
- {
|
809
|
|
- if(card.eof()){
|
810
|
|
- SERIAL_PROTOCOLLNPGM(MSG_FILE_PRINTED);
|
811
|
|
- stoptime=millis();
|
812
|
|
- char time[30];
|
813
|
|
- unsigned long t=(stoptime-starttime)/1000;
|
814
|
|
- int hours, minutes;
|
815
|
|
- minutes=(t/60)%60;
|
816
|
|
- hours=t/60/60;
|
817
|
|
- sprintf_P(time, PSTR("%i "MSG_END_HOUR" %i "MSG_END_MINUTE),hours, minutes);
|
818
|
|
- SERIAL_ECHO_START;
|
819
|
|
- SERIAL_ECHOLN(time);
|
820
|
|
- lcd_setstatus(time, true);
|
821
|
|
- card.printingHasFinished();
|
822
|
|
- card.checkautostart(true);
|
|
779
|
+ #ifdef SDSUPPORT
|
823
|
780
|
|
824
|
|
- }
|
825
|
|
- if(serial_char=='#')
|
826
|
|
- stop_buffering=true;
|
|
781
|
+ if (!card.sdprinting || serial_count) return;
|
|
782
|
+
|
|
783
|
+ // '#' stops reading from SD to the buffer prematurely, so procedural macro calls are possible
|
|
784
|
+ // if it occurs, stop_buffering is triggered and the buffer is ran dry.
|
|
785
|
+ // this character _can_ occur in serial com, due to checksums. however, no checksums are used in SD printing
|
|
786
|
+
|
|
787
|
+ static bool stop_buffering = false;
|
|
788
|
+ if (buflen == 0) stop_buffering = false;
|
|
789
|
+
|
|
790
|
+ while (!card.eof() && buflen < BUFSIZE && !stop_buffering) {
|
|
791
|
+ int16_t n = card.get();
|
|
792
|
+ serial_char = (char)n;
|
|
793
|
+ if (serial_char == '\n' || serial_char == '\r' ||
|
|
794
|
+ ((serial_char == '#' || serial_char == ':') && !comment_mode) ||
|
|
795
|
+ serial_count >= (MAX_CMD_SIZE - 1) || n == -1
|
|
796
|
+ ) {
|
|
797
|
+ if (card.eof()) {
|
|
798
|
+ SERIAL_PROTOCOLLNPGM(MSG_FILE_PRINTED);
|
|
799
|
+ stoptime = millis();
|
|
800
|
+ char time[30];
|
|
801
|
+ millis_t t = (stoptime - starttime) / 1000;
|
|
802
|
+ int hours = t / 60 / 60, minutes = (t / 60) % 60;
|
|
803
|
+ sprintf_P(time, PSTR("%i " MSG_END_HOUR " %i " MSG_END_MINUTE), hours, minutes);
|
|
804
|
+ SERIAL_ECHO_START;
|
|
805
|
+ SERIAL_ECHOLN(time);
|
|
806
|
+ lcd_setstatus(time, true);
|
|
807
|
+ card.printingHasFinished();
|
|
808
|
+ card.checkautostart(true);
|
|
809
|
+ }
|
|
810
|
+ if (serial_char == '#') stop_buffering = true;
|
827
|
811
|
|
828
|
|
- if(!serial_count)
|
829
|
|
- {
|
830
|
|
- comment_mode = false; //for new command
|
831
|
|
- return; //if empty line
|
832
|
|
- }
|
833
|
|
- cmdbuffer[bufindw][serial_count] = 0; //terminate string
|
834
|
|
-// if(!comment_mode){
|
|
812
|
+ if (!serial_count) {
|
|
813
|
+ comment_mode = false; //for new command
|
|
814
|
+ return; //if empty line
|
|
815
|
+ }
|
|
816
|
+ cmdbuffer[bufindw][serial_count] = 0; //terminate string
|
|
817
|
+ // if (!comment_mode) {
|
835
|
818
|
fromsd[bufindw] = true;
|
836
|
819
|
buflen += 1;
|
837
|
820
|
bufindw = (bufindw + 1)%BUFSIZE;
|
838
|
|
-// }
|
839
|
|
- comment_mode = false; //for new command
|
840
|
|
- serial_count = 0; //clear buffer
|
841
|
|
- }
|
842
|
|
- else
|
843
|
|
- {
|
844
|
|
- if(serial_char == ';') comment_mode = true;
|
845
|
|
- if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
|
|
821
|
+ // }
|
|
822
|
+ comment_mode = false; //for new command
|
|
823
|
+ serial_count = 0; //clear buffer
|
|
824
|
+ }
|
|
825
|
+ else {
|
|
826
|
+ if (serial_char == ';') comment_mode = true;
|
|
827
|
+ if (!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
|
|
828
|
+ }
|
846
|
829
|
}
|
847
|
|
- }
|
848
|
|
-
|
849
|
|
- #endif //SDSUPPORT
|
850
|
830
|
|
|
831
|
+ #endif // SDSUPPORT
|
851
|
832
|
}
|
852
|
833
|
|
853
|
834
|
float code_has_value() {
|
|
@@ -923,7 +904,7 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR);
|
923
|
904
|
static float inactive_extruder_x_pos = X2_MAX_POS; // used in mode 0 & 1
|
924
|
905
|
static bool active_extruder_parked = false; // used in mode 1 & 2
|
925
|
906
|
static float raised_parked_position[NUM_AXIS]; // used in mode 1
|
926
|
|
- static unsigned long delayed_move_time = 0; // used in mode 1
|
|
907
|
+ static millis_t delayed_move_time = 0; // used in mode 1
|
927
|
908
|
static float duplicate_extruder_x_offset = DEFAULT_DUPLICATION_X_OFFSET; // used in mode 2
|
928
|
909
|
static float duplicate_extruder_temp_offset = 0; // used in mode 2
|
929
|
910
|
bool extruder_duplication_enabled = false; // used in mode 2
|
|
@@ -1111,7 +1092,7 @@ inline void set_destination_to_current() { memcpy(destination, current_position,
|
1111
|
1092
|
// move down slowly until you find the bed
|
1112
|
1093
|
feedrate = homing_feedrate[Z_AXIS] / 4;
|
1113
|
1094
|
destination[Z_AXIS] = -10;
|
1114
|
|
- prepare_move_raw();
|
|
1095
|
+ prepare_move_raw(); // this will also set_current_to_destination
|
1115
|
1096
|
st_synchronize();
|
1116
|
1097
|
endstops_hit_on_purpose(); // clear endstop hit flags
|
1117
|
1098
|
|
|
@@ -1157,7 +1138,8 @@ inline void set_destination_to_current() { memcpy(destination, current_position,
|
1157
|
1138
|
}
|
1158
|
1139
|
|
1159
|
1140
|
/**
|
1160
|
|
- *
|
|
1141
|
+ * Plan a move to (X, Y, Z) and set the current_position
|
|
1142
|
+ * The final current_position may not be the one that was requested
|
1161
|
1143
|
*/
|
1162
|
1144
|
static void do_blocking_move_to(float x, float y, float z) {
|
1163
|
1145
|
float oldFeedRate = feedrate;
|
|
@@ -1169,7 +1151,7 @@ inline void set_destination_to_current() { memcpy(destination, current_position,
|
1169
|
1151
|
destination[X_AXIS] = x;
|
1170
|
1152
|
destination[Y_AXIS] = y;
|
1171
|
1153
|
destination[Z_AXIS] = z;
|
1172
|
|
- prepare_move_raw();
|
|
1154
|
+ prepare_move_raw(); // this will also set_current_to_destination
|
1173
|
1155
|
st_synchronize();
|
1174
|
1156
|
|
1175
|
1157
|
#else
|
|
@@ -1233,17 +1215,17 @@ inline void set_destination_to_current() { memcpy(destination, current_position,
|
1233
|
1215
|
destination[X_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_X;
|
1234
|
1216
|
destination[Y_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_Y;
|
1235
|
1217
|
destination[Z_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_Z;
|
1236
|
|
- prepare_move_raw();
|
|
1218
|
+ prepare_move_raw(); // this will also set_current_to_destination
|
1237
|
1219
|
|
1238
|
1220
|
// Home X to touch the belt
|
1239
|
1221
|
feedrate = homing_feedrate[X_AXIS]/10;
|
1240
|
1222
|
destination[X_AXIS] = 0;
|
1241
|
|
- prepare_move_raw();
|
|
1223
|
+ prepare_move_raw(); // this will also set_current_to_destination
|
1242
|
1224
|
|
1243
|
1225
|
// Home Y for safety
|
1244
|
1226
|
feedrate = homing_feedrate[X_AXIS]/2;
|
1245
|
1227
|
destination[Y_AXIS] = 0;
|
1246
|
|
- prepare_move_raw();
|
|
1228
|
+ prepare_move_raw(); // this will also set_current_to_destination
|
1247
|
1229
|
|
1248
|
1230
|
st_synchronize();
|
1249
|
1231
|
|
|
@@ -1275,7 +1257,7 @@ inline void set_destination_to_current() { memcpy(destination, current_position,
|
1275
|
1257
|
if (servo_endstops[Z_AXIS] >= 0) {
|
1276
|
1258
|
|
1277
|
1259
|
#if Z_RAISE_AFTER_PROBING > 0
|
1278
|
|
- do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + Z_RAISE_AFTER_PROBING);
|
|
1260
|
+ do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + Z_RAISE_AFTER_PROBING); // this also updates current_position
|
1279
|
1261
|
st_synchronize();
|
1280
|
1262
|
#endif
|
1281
|
1263
|
|
|
@@ -1296,29 +1278,29 @@ inline void set_destination_to_current() { memcpy(destination, current_position,
|
1296
|
1278
|
// Move up for safety
|
1297
|
1279
|
feedrate = homing_feedrate[X_AXIS];
|
1298
|
1280
|
destination[Z_AXIS] = current_position[Z_AXIS] + Z_RAISE_AFTER_PROBING;
|
1299
|
|
- prepare_move_raw();
|
|
1281
|
+ prepare_move_raw(); // this will also set_current_to_destination
|
1300
|
1282
|
|
1301
|
1283
|
// Move to the start position to initiate retraction
|
1302
|
1284
|
destination[X_AXIS] = Z_PROBE_ALLEN_KEY_STOW_X;
|
1303
|
1285
|
destination[Y_AXIS] = Z_PROBE_ALLEN_KEY_STOW_Y;
|
1304
|
1286
|
destination[Z_AXIS] = Z_PROBE_ALLEN_KEY_STOW_Z;
|
1305
|
|
- prepare_move_raw();
|
|
1287
|
+ prepare_move_raw(); // this will also set_current_to_destination
|
1306
|
1288
|
|
1307
|
1289
|
// Move the nozzle down to push the probe into retracted position
|
1308
|
1290
|
feedrate = homing_feedrate[Z_AXIS]/10;
|
1309
|
1291
|
destination[Z_AXIS] = current_position[Z_AXIS] - Z_PROBE_ALLEN_KEY_STOW_DEPTH;
|
1310
|
|
- prepare_move_raw();
|
|
1292
|
+ prepare_move_raw(); // this will also set_current_to_destination
|
1311
|
1293
|
|
1312
|
1294
|
// Move up for safety
|
1313
|
1295
|
feedrate = homing_feedrate[Z_AXIS]/2;
|
1314
|
1296
|
destination[Z_AXIS] = current_position[Z_AXIS] + Z_PROBE_ALLEN_KEY_STOW_DEPTH * 2;
|
1315
|
|
- prepare_move_raw();
|
|
1297
|
+ prepare_move_raw(); // this will also set_current_to_destination
|
1316
|
1298
|
|
1317
|
1299
|
// Home XY for safety
|
1318
|
1300
|
feedrate = homing_feedrate[X_AXIS]/2;
|
1319
|
1301
|
destination[X_AXIS] = 0;
|
1320
|
1302
|
destination[Y_AXIS] = 0;
|
1321
|
|
- prepare_move_raw();
|
|
1303
|
+ prepare_move_raw(); // this will also set_current_to_destination
|
1322
|
1304
|
|
1323
|
1305
|
st_synchronize();
|
1324
|
1306
|
|
|
@@ -1352,8 +1334,8 @@ inline void set_destination_to_current() { memcpy(destination, current_position,
|
1352
|
1334
|
// Probe bed height at position (x,y), returns the measured z value
|
1353
|
1335
|
static float probe_pt(float x, float y, float z_before, ProbeAction retract_action=ProbeDeployAndStow, int verbose_level=1) {
|
1354
|
1336
|
// move to right place
|
1355
|
|
- do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z_before);
|
1356
|
|
- do_blocking_move_to(x - X_PROBE_OFFSET_FROM_EXTRUDER, y - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]);
|
|
1337
|
+ do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z_before); // this also updates current_position
|
|
1338
|
+ do_blocking_move_to(x - X_PROBE_OFFSET_FROM_EXTRUDER, y - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]); // this also updates current_position
|
1357
|
1339
|
|
1358
|
1340
|
#if !defined(Z_PROBE_SLED) && !defined(Z_PROBE_ALLEN_KEY)
|
1359
|
1341
|
if (retract_action & ProbeDeploy) deploy_z_probe();
|
|
@@ -1364,7 +1346,7 @@ inline void set_destination_to_current() { memcpy(destination, current_position,
|
1364
|
1346
|
|
1365
|
1347
|
#if Z_RAISE_BETWEEN_PROBINGS > 0
|
1366
|
1348
|
if (retract_action == ProbeStay) {
|
1367
|
|
- do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS);
|
|
1349
|
+ do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS); // this also updates current_position
|
1368
|
1350
|
st_synchronize();
|
1369
|
1351
|
}
|
1370
|
1352
|
#endif
|
|
@@ -1643,12 +1625,12 @@ static void homeaxis(AxisEnum axis) {
|
1643
|
1625
|
}
|
1644
|
1626
|
|
1645
|
1627
|
if (dock) {
|
1646
|
|
- do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset, current_position[Y_AXIS], current_position[Z_AXIS]);
|
|
1628
|
+ do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset, current_position[Y_AXIS], current_position[Z_AXIS]); // this also updates current_position
|
1647
|
1629
|
digitalWrite(SERVO0_PIN, LOW); // turn off magnet
|
1648
|
1630
|
} else {
|
1649
|
1631
|
float z_loc = current_position[Z_AXIS];
|
1650
|
1632
|
if (z_loc < Z_RAISE_BEFORE_PROBING + 5) z_loc = Z_RAISE_BEFORE_PROBING;
|
1651
|
|
- do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset, Y_PROBE_OFFSET_FROM_EXTRUDER, z_loc);
|
|
1633
|
+ do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset, Y_PROBE_OFFSET_FROM_EXTRUDER, z_loc); // this also updates current_position
|
1652
|
1634
|
digitalWrite(SERVO0_PIN, HIGH); // turn on magnet
|
1653
|
1635
|
}
|
1654
|
1636
|
}
|
|
@@ -1700,7 +1682,7 @@ inline void gcode_G2_G3(bool clockwise) {
|
1700
|
1682
|
* G4: Dwell S<seconds> or P<milliseconds>
|
1701
|
1683
|
*/
|
1702
|
1684
|
inline void gcode_G4() {
|
1703
|
|
- unsigned long codenum = 0;
|
|
1685
|
+ millis_t codenum = 0;
|
1704
|
1686
|
|
1705
|
1687
|
LCD_MESSAGEPGM(MSG_DWELL);
|
1706
|
1688
|
|
|
@@ -1709,7 +1691,7 @@ inline void gcode_G4() {
|
1709
|
1691
|
|
1710
|
1692
|
st_synchronize();
|
1711
|
1693
|
refresh_cmd_timeout();
|
1712
|
|
- codenum += previous_millis_cmd; // keep track of when we started waiting
|
|
1694
|
+ codenum += previous_cmd_ms; // keep track of when we started waiting
|
1713
|
1695
|
while (millis() < codenum) {
|
1714
|
1696
|
manage_heater();
|
1715
|
1697
|
manage_inactivity();
|
|
@@ -2096,7 +2078,7 @@ inline void gcode_G28() {
|
2096
|
2078
|
case MeshStart:
|
2097
|
2079
|
mbl.reset();
|
2098
|
2080
|
probe_point = 0;
|
2099
|
|
- enquecommands_P(PSTR("G28\nG29 S2"));
|
|
2081
|
+ enqueuecommands_P(PSTR("G28\nG29 S2"));
|
2100
|
2082
|
break;
|
2101
|
2083
|
|
2102
|
2084
|
case MeshNext:
|
|
@@ -2135,7 +2117,7 @@ inline void gcode_G28() {
|
2135
|
2117
|
SERIAL_PROTOCOLLNPGM("Mesh probing done.");
|
2136
|
2118
|
probe_point = -1;
|
2137
|
2119
|
mbl.active = 1;
|
2138
|
|
- enquecommands_P(PSTR("G28"));
|
|
2120
|
+ enqueuecommands_P(PSTR("G28"));
|
2139
|
2121
|
}
|
2140
|
2122
|
break;
|
2141
|
2123
|
|
|
@@ -2517,7 +2499,7 @@ inline void gcode_G28() {
|
2517
|
2499
|
#endif
|
2518
|
2500
|
|
2519
|
2501
|
#ifdef Z_PROBE_END_SCRIPT
|
2520
|
|
- enquecommands_P(PSTR(Z_PROBE_END_SCRIPT));
|
|
2502
|
+ enqueuecommands_P(PSTR(Z_PROBE_END_SCRIPT));
|
2521
|
2503
|
st_synchronize();
|
2522
|
2504
|
#endif
|
2523
|
2505
|
}
|
|
@@ -2579,7 +2561,7 @@ inline void gcode_G92() {
|
2579
|
2561
|
inline void gcode_M0_M1() {
|
2580
|
2562
|
char *src = strchr_pointer + 2;
|
2581
|
2563
|
|
2582
|
|
- unsigned long codenum = 0;
|
|
2564
|
+ millis_t codenum = 0;
|
2583
|
2565
|
bool hasP = false, hasS = false;
|
2584
|
2566
|
if (code_seen('P')) {
|
2585
|
2567
|
codenum = code_value_short(); // milliseconds to wait
|
|
@@ -2605,7 +2587,7 @@ inline void gcode_G92() {
|
2605
|
2587
|
st_synchronize();
|
2606
|
2588
|
refresh_cmd_timeout();
|
2607
|
2589
|
if (codenum > 0) {
|
2608
|
|
- codenum += previous_millis_cmd; // keep track of when we started waiting
|
|
2590
|
+ codenum += previous_cmd_ms; // keep track of when we started waiting
|
2609
|
2591
|
while(millis() < codenum && !lcd_clicked()) {
|
2610
|
2592
|
manage_heater();
|
2611
|
2593
|
manage_inactivity();
|
|
@@ -2747,7 +2729,7 @@ inline void gcode_M17() {
|
2747
|
2729
|
*/
|
2748
|
2730
|
inline void gcode_M31() {
|
2749
|
2731
|
stoptime = millis();
|
2750
|
|
- unsigned long t = (stoptime - starttime) / 1000;
|
|
2732
|
+ millis_t t = (stoptime - starttime) / 1000;
|
2751
|
2733
|
int min = t / 60, sec = t % 60;
|
2752
|
2734
|
char time[30];
|
2753
|
2735
|
sprintf_P(time, PSTR("%i min, %i sec"), min, sec);
|
|
@@ -2980,11 +2962,11 @@ inline void gcode_M42() {
|
2980
|
2962
|
if (deploy_probe_for_each_reading) stow_z_probe();
|
2981
|
2963
|
|
2982
|
2964
|
for (uint8_t n=0; n < n_samples; n++) {
|
2983
|
|
-
|
2984
|
|
- do_blocking_move_to(X_probe_location, Y_probe_location, Z_start_location); // Make sure we are at the probe location
|
|
2965
|
+ // Make sure we are at the probe location
|
|
2966
|
+ do_blocking_move_to(X_probe_location, Y_probe_location, Z_start_location); // this also updates current_position
|
2985
|
2967
|
|
2986
|
2968
|
if (n_legs) {
|
2987
|
|
- unsigned long ms = millis();
|
|
2969
|
+ millis_t ms = millis();
|
2988
|
2970
|
double radius = ms % (X_MAX_LENGTH / 4), // limit how far out to go
|
2989
|
2971
|
theta = RADIANS(ms % 360L);
|
2990
|
2972
|
float dir = (ms & 0x0001) ? 1 : -1; // clockwise or counter clockwise
|
|
@@ -3011,11 +2993,12 @@ inline void gcode_M42() {
|
3011
|
2993
|
SERIAL_EOL;
|
3012
|
2994
|
}
|
3013
|
2995
|
|
3014
|
|
- do_blocking_move_to(X_current, Y_current, Z_current);
|
|
2996
|
+ do_blocking_move_to(X_current, Y_current, Z_current); // this also updates current_position
|
3015
|
2997
|
|
3016
|
2998
|
} // n_legs loop
|
3017
|
2999
|
|
3018
|
|
- do_blocking_move_to(X_probe_location, Y_probe_location, Z_start_location); // Go back to the probe location
|
|
3000
|
+ // Go back to the probe location
|
|
3001
|
+ do_blocking_move_to(X_probe_location, Y_probe_location, Z_start_location); // this also updates current_position
|
3019
|
3002
|
|
3020
|
3003
|
} // n_legs
|
3021
|
3004
|
|
|
@@ -3221,7 +3204,7 @@ inline void gcode_M109() {
|
3221
|
3204
|
|
3222
|
3205
|
setWatch();
|
3223
|
3206
|
|
3224
|
|
- unsigned long timetemp = millis();
|
|
3207
|
+ millis_t temp_ms = millis();
|
3225
|
3208
|
|
3226
|
3209
|
/* See if we are heating up or cooling down */
|
3227
|
3210
|
target_direction = isHeatingHotend(target_extruder); // true if heating, false if cooling
|
|
@@ -3229,26 +3212,26 @@ inline void gcode_M109() {
|
3229
|
3212
|
cancel_heatup = false;
|
3230
|
3213
|
|
3231
|
3214
|
#ifdef TEMP_RESIDENCY_TIME
|
3232
|
|
- long residencyStart = -1;
|
|
3215
|
+ long residency_start_ms = -1;
|
3233
|
3216
|
/* continue to loop until we have reached the target temp
|
3234
|
3217
|
_and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */
|
3235
|
|
- while((!cancel_heatup)&&((residencyStart == -1) ||
|
3236
|
|
- (residencyStart >= 0 && (((unsigned int) (millis() - residencyStart)) < (TEMP_RESIDENCY_TIME * 1000UL)))) )
|
|
3218
|
+ while((!cancel_heatup)&&((residency_start_ms == -1) ||
|
|
3219
|
+ (residency_start_ms >= 0 && (((unsigned int) (millis() - residency_start_ms)) < (TEMP_RESIDENCY_TIME * 1000UL)))) )
|
3237
|
3220
|
#else
|
3238
|
3221
|
while ( target_direction ? (isHeatingHotend(target_extruder)) : (isCoolingHotend(target_extruder)&&(CooldownNoWait==false)) )
|
3239
|
3222
|
#endif //TEMP_RESIDENCY_TIME
|
3240
|
3223
|
|
3241
|
3224
|
{ // while loop
|
3242
|
|
- if (millis() > timetemp + 1000UL) { //Print temp & remaining time every 1s while waiting
|
|
3225
|
+ if (millis() > temp_ms + 1000UL) { //Print temp & remaining time every 1s while waiting
|
3243
|
3226
|
SERIAL_PROTOCOLPGM("T:");
|
3244
|
3227
|
SERIAL_PROTOCOL_F(degHotend(target_extruder),1);
|
3245
|
3228
|
SERIAL_PROTOCOLPGM(" E:");
|
3246
|
3229
|
SERIAL_PROTOCOL((int)target_extruder);
|
3247
|
3230
|
#ifdef TEMP_RESIDENCY_TIME
|
3248
|
3231
|
SERIAL_PROTOCOLPGM(" W:");
|
3249
|
|
- if (residencyStart > -1) {
|
3250
|
|
- timetemp = ((TEMP_RESIDENCY_TIME * 1000UL) - (millis() - residencyStart)) / 1000UL;
|
3251
|
|
- SERIAL_PROTOCOLLN( timetemp );
|
|
3232
|
+ if (residency_start_ms > -1) {
|
|
3233
|
+ temp_ms = ((TEMP_RESIDENCY_TIME * 1000UL) - (millis() - residency_start_ms)) / 1000UL;
|
|
3234
|
+ SERIAL_PROTOCOLLN(temp_ms);
|
3252
|
3235
|
}
|
3253
|
3236
|
else {
|
3254
|
3237
|
SERIAL_PROTOCOLLNPGM("?");
|
|
@@ -3256,7 +3239,7 @@ inline void gcode_M109() {
|
3256
|
3239
|
#else
|
3257
|
3240
|
SERIAL_EOL;
|
3258
|
3241
|
#endif
|
3259
|
|
- timetemp = millis();
|
|
3242
|
+ temp_ms = millis();
|
3260
|
3243
|
}
|
3261
|
3244
|
manage_heater();
|
3262
|
3245
|
manage_inactivity();
|
|
@@ -3264,18 +3247,18 @@ inline void gcode_M109() {
|
3264
|
3247
|
#ifdef TEMP_RESIDENCY_TIME
|
3265
|
3248
|
// start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
|
3266
|
3249
|
// or when current temp falls outside the hysteresis after target temp was reached
|
3267
|
|
- if ((residencyStart == -1 && target_direction && (degHotend(target_extruder) >= (degTargetHotend(target_extruder)-TEMP_WINDOW))) ||
|
3268
|
|
- (residencyStart == -1 && !target_direction && (degHotend(target_extruder) <= (degTargetHotend(target_extruder)+TEMP_WINDOW))) ||
|
3269
|
|
- (residencyStart > -1 && labs(degHotend(target_extruder) - degTargetHotend(target_extruder)) > TEMP_HYSTERESIS) )
|
|
3250
|
+ if ((residency_start_ms == -1 && target_direction && (degHotend(target_extruder) >= (degTargetHotend(target_extruder)-TEMP_WINDOW))) ||
|
|
3251
|
+ (residency_start_ms == -1 && !target_direction && (degHotend(target_extruder) <= (degTargetHotend(target_extruder)+TEMP_WINDOW))) ||
|
|
3252
|
+ (residency_start_ms > -1 && labs(degHotend(target_extruder) - degTargetHotend(target_extruder)) > TEMP_HYSTERESIS) )
|
3270
|
3253
|
{
|
3271
|
|
- residencyStart = millis();
|
|
3254
|
+ residency_start_ms = millis();
|
3272
|
3255
|
}
|
3273
|
3256
|
#endif //TEMP_RESIDENCY_TIME
|
3274
|
3257
|
}
|
3275
|
3258
|
|
3276
|
3259
|
LCD_MESSAGEPGM(MSG_HEATING_COMPLETE);
|
3277
|
3260
|
refresh_cmd_timeout();
|
3278
|
|
- starttime = previous_millis_cmd;
|
|
3261
|
+ starttime = previous_cmd_ms;
|
3279
|
3262
|
}
|
3280
|
3263
|
|
3281
|
3264
|
#if HAS_TEMP_BED
|
|
@@ -3290,15 +3273,15 @@ inline void gcode_M109() {
|
3290
|
3273
|
if (CooldownNoWait || code_seen('R'))
|
3291
|
3274
|
setTargetBed(code_value());
|
3292
|
3275
|
|
3293
|
|
- unsigned long timetemp = millis();
|
|
3276
|
+ millis_t temp_ms = millis();
|
3294
|
3277
|
|
3295
|
3278
|
cancel_heatup = false;
|
3296
|
3279
|
target_direction = isHeatingBed(); // true if heating, false if cooling
|
3297
|
3280
|
|
3298
|
3281
|
while ( (target_direction)&&(!cancel_heatup) ? (isHeatingBed()) : (isCoolingBed()&&(CooldownNoWait==false)) ) {
|
3299
|
|
- unsigned long ms = millis();
|
3300
|
|
- if (ms > timetemp + 1000UL) { //Print Temp Reading every 1 second while heating up.
|
3301
|
|
- timetemp = ms;
|
|
3282
|
+ millis_t ms = millis();
|
|
3283
|
+ if (ms > temp_ms + 1000UL) { //Print Temp Reading every 1 second while heating up.
|
|
3284
|
+ temp_ms = ms;
|
3302
|
3285
|
float tt = degHotend(active_extruder);
|
3303
|
3286
|
SERIAL_PROTOCOLPGM("T:");
|
3304
|
3287
|
SERIAL_PROTOCOL(tt);
|
|
@@ -3974,14 +3957,14 @@ inline void gcode_M226() {
|
3974
|
3957
|
|
3975
|
3958
|
#endif // NUM_SERVOS > 0
|
3976
|
3959
|
|
3977
|
|
-#if defined(LARGE_FLASH) && (BEEPER > 0 || defined(ULTRALCD) || defined(LCD_USE_I2C_BUZZER))
|
|
3960
|
+#if BEEPER > 0 || defined(ULTRALCD) || defined(LCD_USE_I2C_BUZZER)
|
3978
|
3961
|
|
3979
|
3962
|
/**
|
3980
|
3963
|
* M300: Play beep sound S<frequency Hz> P<duration ms>
|
3981
|
3964
|
*/
|
3982
|
3965
|
inline void gcode_M300() {
|
3983
|
|
- int beepS = code_seen('S') ? code_value() : 110;
|
3984
|
|
- int beepP = code_seen('P') ? code_value() : 1000;
|
|
3966
|
+ uint16_t beepS = code_seen('S') ? code_value_short() : 110;
|
|
3967
|
+ uint32_t beepP = code_seen('P') ? code_value_long() : 1000;
|
3985
|
3968
|
if (beepS > 0) {
|
3986
|
3969
|
#if BEEPER > 0
|
3987
|
3970
|
tone(BEEPER, beepS);
|
|
@@ -3998,7 +3981,7 @@ inline void gcode_M226() {
|
3998
|
3981
|
}
|
3999
|
3982
|
}
|
4000
|
3983
|
|
4001
|
|
-#endif // LARGE_FLASH && (BEEPER>0 || ULTRALCD || LCD_USE_I2C_BUZZER)
|
|
3984
|
+#endif // BEEPER>0 || ULTRALCD || LCD_USE_I2C_BUZZER
|
4002
|
3985
|
|
4003
|
3986
|
#ifdef PIDTEMP
|
4004
|
3987
|
|
|
@@ -4472,24 +4455,10 @@ inline void gcode_M503() {
|
4472
|
4455
|
LCD_ALERTMESSAGEPGM(MSG_FILAMENTCHANGE);
|
4473
|
4456
|
uint8_t cnt = 0;
|
4474
|
4457
|
while (!lcd_clicked()) {
|
4475
|
|
- cnt++;
|
|
4458
|
+ if (++cnt == 0) lcd_quick_feedback(); // every 256th frame till the lcd is clicked
|
4476
|
4459
|
manage_heater();
|
4477
|
4460
|
manage_inactivity(true);
|
4478
|
4461
|
lcd_update();
|
4479
|
|
- if (cnt == 0) {
|
4480
|
|
- #if BEEPER > 0
|
4481
|
|
- OUT_WRITE(BEEPER,HIGH);
|
4482
|
|
- delay(3);
|
4483
|
|
- WRITE(BEEPER,LOW);
|
4484
|
|
- delay(3);
|
4485
|
|
- #else
|
4486
|
|
- #if !defined(LCD_FEEDBACK_FREQUENCY_HZ) || !defined(LCD_FEEDBACK_FREQUENCY_DURATION_MS)
|
4487
|
|
- lcd_buzz(1000/6, 100);
|
4488
|
|
- #else
|
4489
|
|
- lcd_buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
|
4490
|
|
- #endif
|
4491
|
|
- #endif
|
4492
|
|
- }
|
4493
|
4462
|
} // while(!lcd_clicked)
|
4494
|
4463
|
|
4495
|
4464
|
//return to normal
|
|
@@ -5078,11 +5047,11 @@ void process_commands() {
|
5078
|
5047
|
break;
|
5079
|
5048
|
#endif // NUM_SERVOS > 0
|
5080
|
5049
|
|
5081
|
|
- #if defined(LARGE_FLASH) && (BEEPER > 0 || defined(ULTRALCD) || defined(LCD_USE_I2C_BUZZER))
|
|
5050
|
+ #if BEEPER > 0 || defined(ULTRALCD) || defined(LCD_USE_I2C_BUZZER)
|
5082
|
5051
|
case 300: // M300 - Play beep tone
|
5083
|
5052
|
gcode_M300();
|
5084
|
5053
|
break;
|
5085
|
|
- #endif // LARGE_FLASH && (BEEPER>0 || ULTRALCD || LCD_USE_I2C_BUZZER)
|
|
5054
|
+ #endif // BEEPER > 0 || ULTRALCD || LCD_USE_I2C_BUZZER
|
5086
|
5055
|
|
5087
|
5056
|
#ifdef PIDTEMP
|
5088
|
5057
|
case 301: // M301
|
|
@@ -5289,25 +5258,23 @@ void get_arc_coordinates() {
|
5289
|
5258
|
offset[1] = code_seen('J') ? code_value() : 0;
|
5290
|
5259
|
}
|
5291
|
5260
|
|
5292
|
|
-void clamp_to_software_endstops(float target[3])
|
5293
|
|
-{
|
|
5261
|
+void clamp_to_software_endstops(float target[3]) {
|
5294
|
5262
|
if (min_software_endstops) {
|
5295
|
|
- if (target[X_AXIS] < min_pos[X_AXIS]) target[X_AXIS] = min_pos[X_AXIS];
|
5296
|
|
- if (target[Y_AXIS] < min_pos[Y_AXIS]) target[Y_AXIS] = min_pos[Y_AXIS];
|
|
5263
|
+ NOLESS(target[X_AXIS], min_pos[X_AXIS]);
|
|
5264
|
+ NOLESS(target[Y_AXIS], min_pos[Y_AXIS]);
|
5297
|
5265
|
|
5298
|
5266
|
float negative_z_offset = 0;
|
5299
|
5267
|
#ifdef ENABLE_AUTO_BED_LEVELING
|
5300
|
|
- if (Z_PROBE_OFFSET_FROM_EXTRUDER < 0) negative_z_offset = negative_z_offset + Z_PROBE_OFFSET_FROM_EXTRUDER;
|
5301
|
|
- if (home_offset[Z_AXIS] < 0) negative_z_offset = negative_z_offset + home_offset[Z_AXIS];
|
|
5268
|
+ if (Z_PROBE_OFFSET_FROM_EXTRUDER < 0) negative_z_offset += Z_PROBE_OFFSET_FROM_EXTRUDER;
|
|
5269
|
+ if (home_offset[Z_AXIS] < 0) negative_z_offset += home_offset[Z_AXIS];
|
5302
|
5270
|
#endif
|
5303
|
|
-
|
5304
|
|
- if (target[Z_AXIS] < min_pos[Z_AXIS]+negative_z_offset) target[Z_AXIS] = min_pos[Z_AXIS]+negative_z_offset;
|
|
5271
|
+ NOLESS(target[Z_AXIS], min_pos[Z_AXIS] + negative_z_offset);
|
5305
|
5272
|
}
|
5306
|
5273
|
|
5307
|
5274
|
if (max_software_endstops) {
|
5308
|
|
- if (target[X_AXIS] > max_pos[X_AXIS]) target[X_AXIS] = max_pos[X_AXIS];
|
5309
|
|
- if (target[Y_AXIS] > max_pos[Y_AXIS]) target[Y_AXIS] = max_pos[Y_AXIS];
|
5310
|
|
- if (target[Z_AXIS] > max_pos[Z_AXIS]) target[Z_AXIS] = max_pos[Z_AXIS];
|
|
5275
|
+ NOMORE(target[X_AXIS], max_pos[X_AXIS]);
|
|
5276
|
+ NOMORE(target[Y_AXIS], max_pos[Y_AXIS]);
|
|
5277
|
+ NOMORE(target[Z_AXIS], max_pos[Z_AXIS]);
|
5311
|
5278
|
}
|
5312
|
5279
|
}
|
5313
|
5280
|
|
|
@@ -5522,7 +5489,7 @@ void prepare_move() {
|
5522
|
5489
|
//SERIAL_ECHOPGM("delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]);
|
5523
|
5490
|
//SERIAL_ECHOPGM("delta[Z_AXIS]="); SERIAL_ECHOLN(delta[Z_AXIS]);
|
5524
|
5491
|
|
5525
|
|
- plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder);
|
|
5492
|
+ plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate/60*feedmultiply/100.0, active_extruder);
|
5526
|
5493
|
}
|
5527
|
5494
|
|
5528
|
5495
|
#endif // SCARA
|
|
@@ -5549,7 +5516,7 @@ void prepare_move() {
|
5549
|
5516
|
#ifdef ENABLE_AUTO_BED_LEVELING
|
5550
|
5517
|
adjust_delta(destination);
|
5551
|
5518
|
#endif
|
5552
|
|
- plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder);
|
|
5519
|
+ plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate/60*feedmultiply/100.0, active_extruder);
|
5553
|
5520
|
}
|
5554
|
5521
|
|
5555
|
5522
|
#endif // DELTA
|
|
@@ -5573,7 +5540,7 @@ void prepare_move() {
|
5573
|
5540
|
// (so it can be used as the start of the next non-travel move)
|
5574
|
5541
|
if (delayed_move_time != 0xFFFFFFFFUL) {
|
5575
|
5542
|
set_current_to_destination();
|
5576
|
|
- if (destination[Z_AXIS] > raised_parked_position[Z_AXIS]) raised_parked_position[Z_AXIS] = destination[Z_AXIS];
|
|
5543
|
+ NOLESS(raised_parked_position[Z_AXIS], destination[Z_AXIS]);
|
5577
|
5544
|
delayed_move_time = millis();
|
5578
|
5545
|
return;
|
5579
|
5546
|
}
|
|
@@ -5621,11 +5588,11 @@ void prepare_arc_move(char isclockwise) {
|
5621
|
5588
|
|
5622
|
5589
|
#if HAS_CONTROLLERFAN
|
5623
|
5590
|
|
5624
|
|
-unsigned long lastMotor = 0; // Last time a motor was turned on
|
5625
|
|
-unsigned long lastMotorCheck = 0; // Last time the state was checked
|
|
5591
|
+millis_t lastMotor = 0; // Last time a motor was turned on
|
|
5592
|
+millis_t lastMotorCheck = 0; // Last time the state was checked
|
5626
|
5593
|
|
5627
|
5594
|
void controllerFan() {
|
5628
|
|
- uint32_t ms = millis();
|
|
5595
|
+ millis_t ms = millis();
|
5629
|
5596
|
if (ms >= lastMotorCheck + 2500) { // Not a time critical function, so we only check every 2500ms
|
5630
|
5597
|
lastMotorCheck = ms;
|
5631
|
5598
|
if (X_ENABLE_READ == X_ENABLE_ON || Y_ENABLE_READ == Y_ENABLE_ON || Z_ENABLE_READ == Z_ENABLE_ON || soft_pwm_bed > 0
|
|
@@ -5732,36 +5699,28 @@ void calculate_delta(float cartesian[3]){
|
5732
|
5699
|
#endif
|
5733
|
5700
|
|
5734
|
5701
|
#ifdef TEMP_STAT_LEDS
|
5735
|
|
-static bool blue_led = false;
|
5736
|
|
-static bool red_led = false;
|
5737
|
|
-static uint32_t stat_update = 0;
|
5738
|
|
-
|
5739
|
|
-void handle_status_leds(void) {
|
5740
|
|
- float max_temp = 0.0;
|
5741
|
|
- if(millis() > stat_update) {
|
5742
|
|
- stat_update += 500; // Update every 0.5s
|
5743
|
|
- for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) {
|
5744
|
|
- max_temp = max(max_temp, degHotend(cur_extruder));
|
5745
|
|
- max_temp = max(max_temp, degTargetHotend(cur_extruder));
|
5746
|
|
- }
|
5747
|
|
- #if HAS_TEMP_BED
|
5748
|
|
- max_temp = max(max_temp, degTargetBed());
|
5749
|
|
- max_temp = max(max_temp, degBed());
|
5750
|
|
- #endif
|
5751
|
|
- if((max_temp > 55.0) && (red_led == false)) {
|
5752
|
|
- digitalWrite(STAT_LED_RED, 1);
|
5753
|
|
- digitalWrite(STAT_LED_BLUE, 0);
|
5754
|
|
- red_led = true;
|
5755
|
|
- blue_led = false;
|
5756
|
|
- }
|
5757
|
|
- if((max_temp < 54.0) && (blue_led == false)) {
|
5758
|
|
- digitalWrite(STAT_LED_RED, 0);
|
5759
|
|
- digitalWrite(STAT_LED_BLUE, 1);
|
5760
|
|
- red_led = false;
|
5761
|
|
- blue_led = true;
|
|
5702
|
+
|
|
5703
|
+ static bool red_led = false;
|
|
5704
|
+ static millis_t next_status_led_update_ms = 0;
|
|
5705
|
+
|
|
5706
|
+ void handle_status_leds(void) {
|
|
5707
|
+ float max_temp = 0.0;
|
|
5708
|
+ if (millis() > next_status_led_update_ms) {
|
|
5709
|
+ next_status_led_update_ms += 500; // Update every 0.5s
|
|
5710
|
+ for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder)
|
|
5711
|
+ max_temp = max(max(max_temp, degHotend(cur_extruder)), degTargetHotend(cur_extruder));
|
|
5712
|
+ #if HAS_TEMP_BED
|
|
5713
|
+ max_temp = max(max(max_temp, degTargetBed()), degBed());
|
|
5714
|
+ #endif
|
|
5715
|
+ bool new_led = (max_temp > 55.0) ? true : (max_temp < 54.0) ? false : red_led;
|
|
5716
|
+ if (new_led != red_led) {
|
|
5717
|
+ red_led = new_led;
|
|
5718
|
+ digitalWrite(STAT_LED_RED, new_led ? HIGH : LOW);
|
|
5719
|
+ digitalWrite(STAT_LED_BLUE, new_led ? LOW : HIGH);
|
|
5720
|
+ }
|
5762
|
5721
|
}
|
5763
|
5722
|
}
|
5764
|
|
-}
|
|
5723
|
+
|
5765
|
5724
|
#endif
|
5766
|
5725
|
|
5767
|
5726
|
void enable_all_steppers() {
|
|
@@ -5805,11 +5764,11 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
|
5805
|
5764
|
|
5806
|
5765
|
if (buflen < BUFSIZE - 1) get_command();
|
5807
|
5766
|
|
5808
|
|
- unsigned long ms = millis();
|
|
5767
|
+ millis_t ms = millis();
|
5809
|
5768
|
|
5810
|
|
- if (max_inactive_time && ms > previous_millis_cmd + max_inactive_time) kill();
|
|
5769
|
+ if (max_inactive_time && ms > previous_cmd_ms + max_inactive_time) kill();
|
5811
|
5770
|
|
5812
|
|
- if (stepper_inactive_time && ms > previous_millis_cmd + stepper_inactive_time
|
|
5771
|
+ if (stepper_inactive_time && ms > previous_cmd_ms + stepper_inactive_time
|
5813
|
5772
|
&& !ignore_stepper_queue && !blocks_queued())
|
5814
|
5773
|
disable_all_steppers();
|
5815
|
5774
|
|
|
@@ -5845,7 +5804,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
|
5845
|
5804
|
const int HOME_DEBOUNCE_DELAY = 750;
|
5846
|
5805
|
if (!READ(HOME_PIN)) {
|
5847
|
5806
|
if (!homeDebounceCount) {
|
5848
|
|
- enquecommands_P(PSTR("G28"));
|
|
5807
|
+ enqueuecommands_P(PSTR("G28"));
|
5849
|
5808
|
LCD_ALERTMESSAGEPGM(MSG_AUTO_HOME);
|
5850
|
5809
|
}
|
5851
|
5810
|
if (homeDebounceCount < HOME_DEBOUNCE_DELAY)
|
|
@@ -5860,7 +5819,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
|
5860
|
5819
|
#endif
|
5861
|
5820
|
|
5862
|
5821
|
#ifdef EXTRUDER_RUNOUT_PREVENT
|
5863
|
|
- if (ms > previous_millis_cmd + EXTRUDER_RUNOUT_SECONDS * 1000)
|
|
5822
|
+ if (ms > previous_cmd_ms + EXTRUDER_RUNOUT_SECONDS * 1000)
|
5864
|
5823
|
if (degHotend(active_extruder) > EXTRUDER_RUNOUT_MINTEMP) {
|
5865
|
5824
|
bool oldstatus;
|
5866
|
5825
|
switch(active_extruder) {
|
|
@@ -5894,7 +5853,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
|
5894
|
5853
|
current_position[E_AXIS] = oldepos;
|
5895
|
5854
|
destination[E_AXIS] = oldedes;
|
5896
|
5855
|
plan_set_e_position(oldepos);
|
5897
|
|
- previous_millis_cmd = ms; // refresh_cmd_timeout()
|
|
5856
|
+ previous_cmd_ms = ms; // refresh_cmd_timeout()
|
5898
|
5857
|
st_synchronize();
|
5899
|
5858
|
switch(active_extruder) {
|
5900
|
5859
|
case 0:
|
|
@@ -5964,7 +5923,7 @@ void kill()
|
5964
|
5923
|
{
|
5965
|
5924
|
if filrunoutEnqued == false {
|
5966
|
5925
|
filrunoutEnqued = true;
|
5967
|
|
- enquecommand("M600");
|
|
5926
|
+ enqueuecommand("M600");
|
5968
|
5927
|
}
|
5969
|
5928
|
}
|
5970
|
5929
|
#endif
|