Merge branch 'MK3' into MK3_Translations

This commit is contained in:
leptun 2019-08-29 12:08:48 +03:00
commit 5eea8d26fe
22 changed files with 550 additions and 375 deletions

View File

@ -16,8 +16,8 @@ extern uint16_t nPrinterType;
extern PGM_P sPrinterName;
// Firmware version
#define FW_VERSION "3.7.2"
#define FW_COMMIT_NR 2363
#define FW_VERSION "3.8.0-RC2"
#define FW_COMMIT_NR 2639
// FW_VERSION_UNKNOWN means this is an unofficial build.
// The firmware should only be checked into github with this symbol.
#define FW_DEV_VERSION FW_VERSION_UNKNOWN

View File

@ -524,24 +524,6 @@ bool fans_check_enabled = true;
#ifdef TMC2130
extern int8_t CrashDetectMenu;
void crashdet_enable()
{
tmc2130_sg_stop_on_crash = true;
eeprom_update_byte((uint8_t*)EEPROM_CRASH_DET, 0xFF);
CrashDetectMenu = 1;
}
void crashdet_disable()
{
tmc2130_sg_stop_on_crash = false;
tmc2130_sg_crash = 0;
eeprom_update_byte((uint8_t*)EEPROM_CRASH_DET, 0x00);
CrashDetectMenu = 0;
}
void crashdet_stop_and_save_print()
{
stop_and_save_print_to_ram(10, -default_retraction); //XY - no change, Z 10mm up, E -1mm retract
@ -631,7 +613,7 @@ void crashdet_detected(uint8_t mask)
void crashdet_recover()
{
crashdet_restore_print_and_continue();
tmc2130_sg_stop_on_crash = true;
if (lcd_crash_detect_enabled()) tmc2130_sg_stop_on_crash = true;
}
void crashdet_cancel()
@ -1262,15 +1244,15 @@ void setup()
uint8_t silentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
if (silentMode == 0xff) silentMode = 0;
tmc2130_mode = TMC2130_MODE_NORMAL;
uint8_t crashdet = eeprom_read_byte((uint8_t*)EEPROM_CRASH_DET);
if (crashdet && !farm_mode)
if (lcd_crash_detect_enabled() && !farm_mode)
{
crashdet_enable();
lcd_crash_detect_enable();
puts_P(_N("CrashDetect ENABLED!"));
}
else
{
crashdet_disable();
lcd_crash_detect_disable();
puts_P(_N("CrashDetect DISABLED"));
}
@ -2025,14 +2007,14 @@ static void do_blocking_move_to(float x, float y, float z) {
feedrate = homing_feedrate[Z_AXIS];
current_position[Z_AXIS] = z;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate/60, active_extruder);
plan_buffer_line_curposXYZE(feedrate/60, active_extruder);
st_synchronize();
feedrate = XY_TRAVEL_SPEED;
current_position[X_AXIS] = x;
current_position[Y_AXIS] = y;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate/60, active_extruder);
plan_buffer_line_curposXYZE(feedrate/60, active_extruder);
st_synchronize();
feedrate = oldFeedRate;
@ -2362,77 +2344,77 @@ void ramming() {
max_feedrate[E_AXIS] = 50;
//current_position[E_AXIS] -= 8;
//plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2100 / 60, active_extruder);
//plan_buffer_line_curposXYZE(2100 / 60, active_extruder);
//current_position[E_AXIS] += 8;
//plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2100 / 60, active_extruder);
//plan_buffer_line_curposXYZE(2100 / 60, active_extruder);
current_position[E_AXIS] += 5.4;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2800 / 60, active_extruder);
plan_buffer_line_curposXYZE(2800 / 60, active_extruder);
current_position[E_AXIS] += 3.2;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
plan_buffer_line_curposXYZE(3000 / 60, active_extruder);
current_position[E_AXIS] += 3;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3400 / 60, active_extruder);
plan_buffer_line_curposXYZE(3400 / 60, active_extruder);
st_synchronize();
max_feedrate[E_AXIS] = 80;
current_position[E_AXIS] -= 82;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 9500 / 60, active_extruder);
plan_buffer_line_curposXYZE(9500 / 60, active_extruder);
max_feedrate[E_AXIS] = 50;//tmp[E_AXIS];
current_position[E_AXIS] -= 20;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 1200 / 60, active_extruder);
plan_buffer_line_curposXYZE(1200 / 60, active_extruder);
current_position[E_AXIS] += 5;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400 / 60, active_extruder);
plan_buffer_line_curposXYZE(400 / 60, active_extruder);
current_position[E_AXIS] += 5;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 600 / 60, active_extruder);
plan_buffer_line_curposXYZE(600 / 60, active_extruder);
current_position[E_AXIS] -= 10;
st_synchronize();
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 600 / 60, active_extruder);
plan_buffer_line_curposXYZE(600 / 60, active_extruder);
current_position[E_AXIS] += 10;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 600 / 60, active_extruder);
plan_buffer_line_curposXYZE(600 / 60, active_extruder);
current_position[E_AXIS] -= 10;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 800 / 60, active_extruder);
plan_buffer_line_curposXYZE(800 / 60, active_extruder);
current_position[E_AXIS] += 10;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 800 / 60, active_extruder);
plan_buffer_line_curposXYZE(800 / 60, active_extruder);
current_position[E_AXIS] -= 10;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 800 / 60, active_extruder);
plan_buffer_line_curposXYZE(800 / 60, active_extruder);
st_synchronize();
}
else {
//ABS
max_feedrate[E_AXIS] = 50;
//current_position[E_AXIS] -= 8;
//plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2100 / 60, active_extruder);
//plan_buffer_line_curposXYZE(2100 / 60, active_extruder);
//current_position[E_AXIS] += 8;
//plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2100 / 60, active_extruder);
//plan_buffer_line_curposXYZE(2100 / 60, active_extruder);
current_position[E_AXIS] += 3.1;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2000 / 60, active_extruder);
plan_buffer_line_curposXYZE(2000 / 60, active_extruder);
current_position[E_AXIS] += 3.1;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2500 / 60, active_extruder);
plan_buffer_line_curposXYZE(2500 / 60, active_extruder);
current_position[E_AXIS] += 4;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
plan_buffer_line_curposXYZE(3000 / 60, active_extruder);
st_synchronize();
//current_position[X_AXIS] += 23; //delay
//plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 600/60, active_extruder); //delay
//plan_buffer_line_curposXYZE(600/60, active_extruder); //delay
//current_position[X_AXIS] -= 23; //delay
//plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 600/60, active_extruder); //delay
//plan_buffer_line_curposXYZE(600/60, active_extruder); //delay
_delay(4700);
max_feedrate[E_AXIS] = 80;
current_position[E_AXIS] -= 92;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 9900 / 60, active_extruder);
plan_buffer_line_curposXYZE(9900 / 60, active_extruder);
max_feedrate[E_AXIS] = 50;//tmp[E_AXIS];
current_position[E_AXIS] -= 5;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 800 / 60, active_extruder);
plan_buffer_line_curposXYZE(800 / 60, active_extruder);
current_position[E_AXIS] += 5;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400 / 60, active_extruder);
plan_buffer_line_curposXYZE(400 / 60, active_extruder);
current_position[E_AXIS] -= 5;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 600 / 60, active_extruder);
plan_buffer_line_curposXYZE(600 / 60, active_extruder);
st_synchronize();
current_position[E_AXIS] += 5;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 600 / 60, active_extruder);
plan_buffer_line_curposXYZE(600 / 60, active_extruder);
current_position[E_AXIS] -= 5;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 600 / 60, active_extruder);
plan_buffer_line_curposXYZE(600 / 60, active_extruder);
current_position[E_AXIS] += 5;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 600 / 60, active_extruder);
plan_buffer_line_curposXYZE(600 / 60, active_extruder);
current_position[E_AXIS] -= 5;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 600 / 60, active_extruder);
plan_buffer_line_curposXYZE(600 / 60, active_extruder);
st_synchronize();
}
@ -2491,7 +2473,7 @@ static void gcode_G28(bool home_x_axis, long home_x_value, bool home_y_axis, lon
if (home_all_axes) {
current_position[Z_AXIS] += MESH_HOME_Z_SEARCH;
feedrate = homing_feedrate[Z_AXIS];
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate / 60, active_extruder);
plan_buffer_line_curposXYZE(feedrate / 60, active_extruder);
st_synchronize();
}
#ifdef ENABLE_AUTO_BED_LEVELING
@ -2809,7 +2791,7 @@ bool gcode_M45(bool onlyZ, int8_t verbosity_level)
enable_endstops(false);
current_position[X_AXIS] += 5;
current_position[Y_AXIS] += 5;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[Z_AXIS] / 40, active_extruder);
plan_buffer_line_curposXYZE(homing_feedrate[Z_AXIS] / 40, active_extruder);
st_synchronize();
// Let the user move the Z axes up to the end stoppers.
@ -2859,7 +2841,7 @@ bool gcode_M45(bool onlyZ, int8_t verbosity_level)
bool endstops_enabled = enable_endstops(false);
current_position[Z_AXIS] -= 1; //move 1mm down with disabled endstop
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[Z_AXIS] / 40, active_extruder);
plan_buffer_line_curposXYZE(homing_feedrate[Z_AXIS] / 40, active_extruder);
st_synchronize();
// Move the print head close to the bed.
@ -2870,7 +2852,7 @@ bool gcode_M45(bool onlyZ, int8_t verbosity_level)
tmc2130_home_enter(Z_AXIS_MASK);
#endif //TMC2130
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[Z_AXIS] / 40, active_extruder);
plan_buffer_line_curposXYZE(homing_feedrate[Z_AXIS] / 40, active_extruder);
st_synchronize();
#ifdef TMC2130
@ -2910,7 +2892,7 @@ bool gcode_M45(bool onlyZ, int8_t verbosity_level)
clean_up_after_endstop_move(l_feedmultiply);
// Print head up.
current_position[Z_AXIS] = MESH_HOME_Z_SEARCH;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[Z_AXIS] / 40, active_extruder);
plan_buffer_line_curposXYZE(homing_feedrate[Z_AXIS] / 40, active_extruder);
st_synchronize();
//#ifndef NEW_XYZCAL
if (result >= 0)
@ -2930,7 +2912,7 @@ bool gcode_M45(bool onlyZ, int8_t verbosity_level)
clean_up_after_endstop_move(l_feedmultiply);
// Print head up.
current_position[Z_AXIS] = MESH_HOME_Z_SEARCH;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[Z_AXIS] / 40, active_extruder);
plan_buffer_line_curposXYZE(homing_feedrate[Z_AXIS] / 40, active_extruder);
st_synchronize();
// if (result >= 0) babystep_apply();
#endif //HEATBED_V2
@ -3040,21 +3022,18 @@ static void gcode_M600(bool automatic, float x_position, float y_position, float
//Retract E
current_position[E_AXIS] += e_shift;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS],
current_position[E_AXIS], FILAMENTCHANGE_RFEED, active_extruder);
plan_buffer_line_curposXYZE(FILAMENTCHANGE_RFEED, active_extruder);
st_synchronize();
//Lift Z
current_position[Z_AXIS] += z_shift;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS],
current_position[E_AXIS], FILAMENTCHANGE_ZFEED, active_extruder);
plan_buffer_line_curposXYZE(FILAMENTCHANGE_ZFEED, active_extruder);
st_synchronize();
//Move XY to side
current_position[X_AXIS] = x_position;
current_position[Y_AXIS] = y_position;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS],
current_position[E_AXIS], FILAMENTCHANGE_XYFEED, active_extruder);
plan_buffer_line_curposXYZE(FILAMENTCHANGE_XYFEED, active_extruder);
st_synchronize();
//Beep, manage nozzle heater and wait for user to start unload filament
@ -3079,8 +3058,7 @@ static void gcode_M600(bool automatic, float x_position, float y_position, float
lcd_set_cursor(0, 2);
lcd_puts_P(_T(MSG_PLEASE_WAIT));
current_position[X_AXIS] -= 100;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS],
current_position[E_AXIS], FILAMENTCHANGE_XYFEED, active_extruder);
plan_buffer_line_curposXYZE(FILAMENTCHANGE_XYFEED, active_extruder);
st_synchronize();
lcd_show_fullscreen_message_and_wait_P(_i("Please open idler and remove filament manually."));////MSG_CHECK_IDLER c=20 r=4
}
@ -3117,8 +3095,7 @@ static void gcode_M600(bool automatic, float x_position, float y_position, float
if (!automatic)
{
current_position[E_AXIS] += FILAMENTCHANGE_RECFEED;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS],
current_position[E_AXIS], FILAMENTCHANGE_EXFEED, active_extruder);
plan_buffer_line_curposXYZE(FILAMENTCHANGE_EXFEED, active_extruder);
}
//Move XY back
@ -3185,12 +3162,12 @@ void gcode_M701()
lcd_setstatuspgm(_T(MSG_LOADING_FILAMENT));
current_position[E_AXIS] += 40;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400 / 60, active_extruder); //fast sequence
plan_buffer_line_curposXYZE(400 / 60, active_extruder); //fast sequence
st_synchronize();
marlin_rise_z();
current_position[E_AXIS] += 30;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400 / 60, active_extruder); //fast sequence
plan_buffer_line_curposXYZE(400 / 60, active_extruder); //fast sequence
load_filament_final_feed(); //slow sequence
st_synchronize();
@ -3268,6 +3245,56 @@ static void gcode_PRUSA_SN()
puts_P(_N("Not in farm mode."));
}
}
//! Detection of faulty RAMBo 1.1b boards equipped with bigger capacitors
//! at the TACH_1 pin, which causes bad detection of print fan speed.
//! Warning: This function is not to be used by ordinary users, it is here only for automated testing purposes,
//! it may even interfere with other functions of the printer! You have been warned!
//! The test idea is to measure the time necessary to charge the capacitor.
//! So the algorithm is as follows:
//! 1. Set TACH_1 pin to INPUT mode and LOW
//! 2. Wait a few ms
//! 3. disable interrupts and measure the time until the TACH_1 pin reaches HIGH
//! Repeat 1.-3. several times
//! Good RAMBo's times are in the range of approx. 260-320 us
//! Bad RAMBo's times are approx. 260-1200 us
//! So basically we are interested in maximum time, the minima are mostly the same.
//! May be that's why the bad RAMBo's still produce some fan RPM reading, but not corresponding to reality
static void gcode_PRUSA_BadRAMBoFanTest(){
//printf_P(PSTR("Enter fan pin test\n"));
#if !defined(DEBUG_DISABLE_FANCHECK) && defined(FANCHECK) && defined(TACH_1) && TACH_1 >-1 && defined(IR_SENSOR)
fan_measuring = false; // prevent EXTINT7 breaking into the measurement
unsigned long tach1max = 0;
uint8_t tach1cntr = 0;
for( /* nothing */; tach1cntr < 100; ++tach1cntr){
//printf_P(PSTR("TACH_1: %d\n"), tach1cntr);
SET_OUTPUT(TACH_1);
WRITE(TACH_1, LOW);
_delay(20); // the delay may be lower
unsigned long tachMeasure = _micros();
cli();
SET_INPUT(TACH_1);
// just wait brutally in an endless cycle until we reach HIGH
// if this becomes a problem it may be improved to non-endless cycle
while( READ(TACH_1) == 0 ) ;
sei();
tachMeasure = _micros() - tachMeasure;
if( tach1max < tachMeasure )
tach1max = tachMeasure;
//printf_P(PSTR("TACH_1: %d: capacitor check time=%lu us\n"), (int)tach1cntr, tachMeasure);
}
//printf_P(PSTR("TACH_1: max=%lu us\n"), tach1max);
SERIAL_PROTOCOLPGM("RAMBo FAN ");
if( tach1max > 500 ){
// bad RAMBo
SERIAL_PROTOCOLLNPGM("BAD");
} else {
SERIAL_PROTOCOLLNPGM("OK");
}
// cleanup after the test function
SET_INPUT(TACH_1);
WRITE(TACH_1, HIGH);
#endif
}
#ifdef BACKLASH_X
extern uint8_t st_backlash_x;
@ -3625,7 +3652,9 @@ void process_commands()
else if (code_seen("PRN")) { // PRUSA PRN
printf_P(_N("%d"), status_number);
}else if (code_seen("FAN")) { // PRUSA FAN
} else if( code_seen("FANPINTST") ){
gcode_PRUSA_BadRAMBoFanTest();
}else if (code_seen("FAN")) { //! PRUSA FAN
printf_P(_N("E0:%d RPM\nPRN0:%d RPM\n"), 60*fan_speed[0], 60*fan_speed[1]);
}else if (code_seen("fn")) { // PRUSA fn
if (farm_mode) {
@ -4337,15 +4366,15 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
if (result)
{
current_position[Z_AXIS] = MESH_HOME_Z_SEARCH;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
plan_buffer_line_curposXYZE(3000 / 60, active_extruder);
current_position[Z_AXIS] = 50;
current_position[Y_AXIS] = 180;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
plan_buffer_line_curposXYZE(3000 / 60, active_extruder);
st_synchronize();
lcd_show_fullscreen_message_and_wait_P(_T(MSG_REMOVE_STEEL_SHEET));
current_position[Y_AXIS] = pgm_read_float(bed_ref_points_4 + 1);
current_position[X_AXIS] = pgm_read_float(bed_ref_points_4);
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
plan_buffer_line_curposXYZE(3000 / 60, active_extruder);
st_synchronize();
gcode_G28(false, false, true);
@ -4353,7 +4382,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
if ((current_temperature_pinda > 35) && (farm_mode == false)) {
//waiting for PIDNA probe to cool down in case that we are not in farm mode
current_position[Z_AXIS] = 100;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
plan_buffer_line_curposXYZE(3000 / 60, active_extruder);
if (lcd_wait_for_pinda(35) == false) { //waiting for PINDA probe to cool, if this takes more then time expected, temp. cal. fails
lcd_temp_cal_show_result(false);
break;
@ -4377,12 +4406,12 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
custom_message_state = 1;
lcd_setstatuspgm(_T(MSG_TEMP_CALIBRATION));
current_position[Z_AXIS] = MESH_HOME_Z_SEARCH;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
plan_buffer_line_curposXYZE(3000 / 60, active_extruder);
current_position[X_AXIS] = PINDA_PREHEAT_X;
current_position[Y_AXIS] = PINDA_PREHEAT_Y;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
plan_buffer_line_curposXYZE(3000 / 60, active_extruder);
current_position[Z_AXIS] = PINDA_PREHEAT_Z;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
plan_buffer_line_curposXYZE(3000 / 60, active_extruder);
st_synchronize();
while (current_temperature_pinda < start_temp)
@ -4394,10 +4423,10 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 0); //invalidate temp. calibration in case that in will be aborted during the calibration process
current_position[Z_AXIS] = MESH_HOME_Z_SEARCH;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
plan_buffer_line_curposXYZE(3000 / 60, active_extruder);
current_position[X_AXIS] = pgm_read_float(bed_ref_points_4);
current_position[Y_AXIS] = pgm_read_float(bed_ref_points_4 + 1);
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
plan_buffer_line_curposXYZE(3000 / 60, active_extruder);
st_synchronize();
bool find_z_result = find_bed_induction_sensor_point_z(-1.f);
@ -4425,12 +4454,12 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
setTargetBed(50 + 10 * (temp - 30) / 5);
// setTargetHotend(255, 0);
current_position[Z_AXIS] = MESH_HOME_Z_SEARCH;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
plan_buffer_line_curposXYZE(3000 / 60, active_extruder);
current_position[X_AXIS] = PINDA_PREHEAT_X;
current_position[Y_AXIS] = PINDA_PREHEAT_Y;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
plan_buffer_line_curposXYZE(3000 / 60, active_extruder);
current_position[Z_AXIS] = PINDA_PREHEAT_Z;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
plan_buffer_line_curposXYZE(3000 / 60, active_extruder);
st_synchronize();
while (current_temperature_pinda < temp)
{
@ -4438,10 +4467,10 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
serialecho_temperatures();
}
current_position[Z_AXIS] = MESH_HOME_Z_SEARCH;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
plan_buffer_line_curposXYZE(3000 / 60, active_extruder);
current_position[X_AXIS] = pgm_read_float(bed_ref_points_4);
current_position[Y_AXIS] = pgm_read_float(bed_ref_points_4 + 1);
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
plan_buffer_line_curposXYZE(3000 / 60, active_extruder);
st_synchronize();
find_z_result = find_bed_induction_sensor_point_z(-1.f);
if (find_z_result == false) {
@ -4481,7 +4510,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
current_position[X_AXIS] = PINDA_PREHEAT_X;
current_position[Y_AXIS] = PINDA_PREHEAT_Y;
current_position[Z_AXIS] = PINDA_PREHEAT_Z;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
plan_buffer_line_curposXYZE(3000 / 60, active_extruder);
st_synchronize();
while (abs(degBed() - PINDA_MIN_T) > 1) {
@ -4497,11 +4526,11 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 0); //invalidate temp. calibration in case that in will be aborted during the calibration process
current_position[Z_AXIS] = 5;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
plan_buffer_line_curposXYZE(3000 / 60, active_extruder);
current_position[X_AXIS] = BED_X0;
current_position[Y_AXIS] = BED_Y0;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
plan_buffer_line_curposXYZE(3000 / 60, active_extruder);
st_synchronize();
find_bed_induction_sensor_point_z(-1.f);
@ -4518,7 +4547,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
current_position[X_AXIS] = PINDA_PREHEAT_X;
current_position[Y_AXIS] = PINDA_PREHEAT_Y;
current_position[Z_AXIS] = PINDA_PREHEAT_Z;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
plan_buffer_line_curposXYZE(3000 / 60, active_extruder);
st_synchronize();
while (degBed() < t_c) {
delay_keep_alive(1000);
@ -4529,10 +4558,10 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
serialecho_temperatures();
}
current_position[Z_AXIS] = 5;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
plan_buffer_line_curposXYZE(3000 / 60, active_extruder);
current_position[X_AXIS] = BED_X0;
current_position[Y_AXIS] = BED_Y0;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
plan_buffer_line_curposXYZE(3000 / 60, active_extruder);
st_synchronize();
find_bed_induction_sensor_point_z(-1.f);
z_shift = (int)((current_position[Z_AXIS] - zero_z)*cs.axis_steps_per_unit[Z_AXIS]);
@ -4673,7 +4702,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
// Cycle through all points and probe them
// First move up. During this first movement, the babystepping will be reverted.
current_position[Z_AXIS] = MESH_HOME_Z_SEARCH;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[Z_AXIS] / 60, active_extruder);
plan_buffer_line_curposXYZE(homing_feedrate[Z_AXIS] / 60, active_extruder);
// The move to the first calibration point.
current_position[X_AXIS] = BED_X0;
current_position[Y_AXIS] = BED_Y0;
@ -4688,7 +4717,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]);
#endif //SUPPORT_VERBOSITY
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[X_AXIS] / 30, active_extruder);
plan_buffer_line_curposXYZE(homing_feedrate[X_AXIS] / 30, active_extruder);
// Wait until the move is finished.
st_synchronize();
@ -4740,7 +4769,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
if((ix == 0) && (iy == 0)) current_position[Z_AXIS] = MESH_HOME_Z_SEARCH;
else current_position[Z_AXIS] += 2.f / nMeasPoints; //use relative movement from Z coordinate where PINDa triggered on previous point. This makes calibration faster.
float init_z_bckp = current_position[Z_AXIS];
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], Z_LIFT_FEEDRATE, active_extruder);
plan_buffer_line_curposXYZE(Z_LIFT_FEEDRATE, active_extruder);
st_synchronize();
// Move to XY position of the sensor point.
@ -4761,7 +4790,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
#endif // SUPPORT_VERBOSITY
//printf_P(PSTR("after clamping: [%f;%f]\n"), current_position[X_AXIS], current_position[Y_AXIS]);
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], XY_AXIS_FEEDRATE, active_extruder);
plan_buffer_line_curposXYZE(XY_AXIS_FEEDRATE, active_extruder);
st_synchronize();
// Go down until endstop is hit
@ -4773,7 +4802,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
if (init_z_bckp - current_position[Z_AXIS] < 0.1f) { //broken cable or initial Z coordinate too low. Go to MESH_HOME_Z_SEARCH and repeat last step (z-probe) again to distinguish between these two cases.
//printf_P(PSTR("Another attempt! Current Z position: %f\n"), current_position[Z_AXIS]);
current_position[Z_AXIS] = MESH_HOME_Z_SEARCH;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], Z_LIFT_FEEDRATE, active_extruder);
plan_buffer_line_curposXYZE(Z_LIFT_FEEDRATE, active_extruder);
st_synchronize();
if (!find_bed_induction_sensor_point_z((has_z && mesh_point > 0) ? z0 - Z_CALIBRATION_THRESHOLD : -10.f, nProbeRetry)) { //if we have data from z calibration max allowed difference is 1mm for each point, if we dont have data max difference is 10mm from initial point
@ -4828,7 +4857,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
MYSERIAL.print(current_position[Z_AXIS], 5);
}
#endif // SUPPORT_VERBOSITY
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], Z_LIFT_FEEDRATE, active_extruder);
plan_buffer_line_curposXYZE(Z_LIFT_FEEDRATE, active_extruder);
st_synchronize();
if (mesh_point != nMeasPoints * nMeasPoints) {
Sound_MakeSound(e_SOUND_TYPE_StandardAlert);
@ -4845,14 +4874,14 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
// ~ Z-homing (can not be used "G28", because X & Y-homing would have been done before (Z-homing))
bState=enable_z_endstop(false);
current_position[Z_AXIS] -= 1;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[Z_AXIS] / 40, active_extruder);
plan_buffer_line_curposXYZE(homing_feedrate[Z_AXIS] / 40, active_extruder);
st_synchronize();
enable_z_endstop(true);
#ifdef TMC2130
tmc2130_home_enter(Z_AXIS_MASK);
#endif // TMC2130
current_position[Z_AXIS] = MESH_HOME_Z_SEARCH;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[Z_AXIS] / 40, active_extruder);
plan_buffer_line_curposXYZE(homing_feedrate[Z_AXIS] / 40, active_extruder);
st_synchronize();
#ifdef TMC2130
tmc2130_home_exit();
@ -4985,7 +5014,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
//unretract (after PINDA preheat retraction)
if (degHotend(active_extruder) > EXTRUDE_MINTEMP && temp_cal_active == true && calibration_status_pinda() == true && target_temperature_bed >= 50) {
current_position[E_AXIS] += default_retraction;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400, active_extruder);
plan_buffer_line_curposXYZE(400, active_extruder);
}
KEEPALIVE_STATE(NOT_BUSY);
// Restore custom message state
@ -5310,11 +5339,18 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
card.pauseSDPrint();
break;
//! ### M26 - Set SD index
//! ### M26 S\<index\> - Set SD index
//! Set position in SD card file to index in bytes.
//! This command is expected to be called after M23 and before M24.
//! Otherwise effect of this command is undefined.
// ----------------------------------
case 26:
if(card.cardOK && code_seen('S')) {
card.setIndex(code_value_long());
long index = code_value_long();
card.setIndex(index);
// We don't disable interrupt during update of sdpos_atomic
// as we expect, that SD card print is not active in this moment
sdpos_atomic = index;
}
break;
@ -7716,7 +7752,7 @@ Sigma_Exit:
if (mmu_enabled)
{
st_synchronize();
mmu_continue_loading(is_usb_printing);
mmu_continue_loading(is_usb_printing || (lcd_commands_type == LcdCommands::Layer1Cal));
mmu_extruder = tmp_extruder; //filament change is finished
mmu_load_to_nozzle();
}
@ -7760,7 +7796,7 @@ Sigma_Exit:
#endif //defined(MMU_HAS_CUTTER) && defined(MMU_ALWAYS_CUT)
mmu_command(MmuCmd::T0 + tmp_extruder);
manage_response(true, true, MMU_TCODE_MOVE);
mmu_continue_loading(is_usb_printing);
mmu_continue_loading(is_usb_printing || (lcd_commands_type == LcdCommands::Layer1Cal));
mmu_extruder = tmp_extruder; //filament change is finished
@ -8970,7 +9006,7 @@ void bed_check(float x_dimension, float y_dimension, int x_points_num, int y_poi
card.openFile(filename_wldsd, false);
/*destination[Z_AXIS] = mesh_home_z_search;
//plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], Z_LIFT_FEEDRATE, active_extruder);
//plan_buffer_line_curposXYZE(Z_LIFT_FEEDRATE, active_extruder);
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], Z_LIFT_FEEDRATE, active_extruder);
for(int8_t i=0; i < NUM_AXIS; i++) {
@ -9004,7 +9040,7 @@ void bed_check(float x_dimension, float y_dimension, int x_points_num, int y_poi
if (iy & 1) ix = (x_points_num - 1) - ix; // Zig zag
float z0 = 0.f;
/*destination[Z_AXIS] = mesh_home_z_search;
//plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], Z_LIFT_FEEDRATE, active_extruder);
//plan_buffer_line_curposXYZE(Z_LIFT_FEEDRATE, active_extruder);
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], Z_LIFT_FEEDRATE, active_extruder);
for(int8_t i=0; i < NUM_AXIS; i++) {
@ -9168,7 +9204,7 @@ void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_
card.openFile(filename_wldsd, false);
current_position[Z_AXIS] = mesh_home_z_search;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[Z_AXIS] / 60, active_extruder);
plan_buffer_line_curposXYZE(homing_feedrate[Z_AXIS] / 60, active_extruder);
int XY_AXIS_FEEDRATE = homing_feedrate[X_AXIS] / 20;
int Z_LIFT_FEEDRATE = homing_feedrate[Z_AXIS] / 40;
@ -9193,14 +9229,14 @@ void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_
if (iy & 1) ix = (x_points_num - 1) - ix; // Zig zag
float z0 = 0.f;
current_position[Z_AXIS] = mesh_home_z_search;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], Z_LIFT_FEEDRATE, active_extruder);
plan_buffer_line_curposXYZE(Z_LIFT_FEEDRATE, active_extruder);
st_synchronize();
current_position[X_AXIS] = 13.f + ix * (x_dimension / (x_points_num - 1)) - bed_zero_ref_x + shift_x;
current_position[Y_AXIS] = 6.4f + iy * (y_dimension / (y_points_num - 1)) - bed_zero_ref_y + shift_y;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], XY_AXIS_FEEDRATE, active_extruder);
plan_buffer_line_curposXYZE(XY_AXIS_FEEDRATE, active_extruder);
st_synchronize();
if (!find_bed_induction_sensor_point_z(-10.f)) { //if we have data from z calibration max allowed difference is 1mm for each point, if we dont have data max difference is 10mm from initial point
@ -9314,12 +9350,12 @@ void temp_compensation_start() {
if (degHotend(active_extruder) > EXTRUDE_MINTEMP) {
current_position[E_AXIS] -= default_retraction;
}
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400, active_extruder);
plan_buffer_line_curposXYZE(400, active_extruder);
current_position[X_AXIS] = PINDA_PREHEAT_X;
current_position[Y_AXIS] = PINDA_PREHEAT_Y;
current_position[Z_AXIS] = PINDA_PREHEAT_Z;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
plan_buffer_line_curposXYZE(3000 / 60, active_extruder);
st_synchronize();
while (fabs(degBed() - target_temperature_bed) > 1) delay_keep_alive(1000);
@ -9440,17 +9476,17 @@ void long_pause() //long pause print
//retract
current_position[E_AXIS] -= default_retraction;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400, active_extruder);
plan_buffer_line_curposXYZE(400, active_extruder);
//lift z
current_position[Z_AXIS] += Z_PAUSE_LIFT;
if (current_position[Z_AXIS] > Z_MAX_POS) current_position[Z_AXIS] = Z_MAX_POS;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 15, active_extruder);
plan_buffer_line_curposXYZE(15, active_extruder);
//Move XY to side
current_position[X_AXIS] = X_PAUSE_POS;
current_position[Y_AXIS] = Y_PAUSE_POS;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 50, active_extruder);
plan_buffer_line_curposXYZE(50, active_extruder);
// Turn off the print fan
fanSpeed = 0;
@ -9468,7 +9504,7 @@ void serialecho_temperatures() {
SERIAL_PROTOCOL_F(degBed(), 1);
SERIAL_PROTOCOLLN("");
}
extern uint32_t sdpos_atomic;
#ifdef UVLO_SUPPORT
void uvlo_()
@ -9555,7 +9591,6 @@ void uvlo_()
st_synchronize();
disable_e0();
disable_z();
// Move Z up to the next 0th full step.
// Write the file position.
eeprom_update_dword((uint32_t*)(EEPROM_FILE_POSITION), sd_position);
@ -9594,8 +9629,6 @@ void uvlo_()
st_synchronize();
printf_P(_N("stps%d\n"), tmc2130_rd_MSCNT(Z_AXIS));
disable_z();
// Increment power failure counter
eeprom_update_byte((uint8_t*)EEPROM_POWER_COUNT, eeprom_read_byte((uint8_t*)EEPROM_POWER_COUNT) + 1);
@ -9605,7 +9638,7 @@ void uvlo_()
#if 0
// Move the print head to the side of the print until all the power stored in the power supply capacitors is depleted.
current_position[X_AXIS] = (current_position[X_AXIS] < 0.5f * (X_MIN_POS + X_MAX_POS)) ? X_MIN_POS : X_MAX_POS;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 500, active_extruder);
plan_buffer_line_curposXYZE(500, active_extruder);
st_synchronize();
#endif
wdt_enable(WDTO_500MS);
@ -9634,7 +9667,6 @@ tmc2130_set_current_r(Z_AXIS, 20);
z_microsteps=tmc2130_rd_MSCNT(Z_TMC2130_CS);
#endif //TMC2130
planner_abort_hard();
disable_z();
//save current position only in case, where the printer is moving on Z axis, which is only when EEPROM_UVLO is 1
//EEPROM_UVLO is 1 after normal uvlo or after recover_print(), when the extruder is moving on Z axis after rehome
@ -10242,7 +10274,7 @@ static void print_time_remaining_init()
void load_filament_final_feed()
{
current_position[E_AXIS]+= FILAMENTCHANGE_FINALFEED;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], FILAMENTCHANGE_EFEED_FINAL, active_extruder);
plan_buffer_line_curposXYZE(FILAMENTCHANGE_EFEED_FINAL, active_extruder);
}
//! @brief Wait for user to check the state
@ -10372,22 +10404,22 @@ void M600_load_filament_movements()
do
{
current_position[E_AXIS] += 0.002;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 500, active_extruder);
plan_buffer_line_curposXYZE(500, active_extruder);
delay_keep_alive(2);
}
while (!lcd_clicked());
st_synchronize();
current_position[E_AXIS] += bowden_length[mmu_extruder];
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000, active_extruder);
plan_buffer_line_curposXYZE(3000, active_extruder);
current_position[E_AXIS] += FIL_LOAD_LENGTH - 60;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 1400, active_extruder);
plan_buffer_line_curposXYZE(1400, active_extruder);
current_position[E_AXIS] += 40;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400, active_extruder);
plan_buffer_line_curposXYZE(400, active_extruder);
current_position[E_AXIS] += 10;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 50, active_extruder);
plan_buffer_line_curposXYZE(50, active_extruder);
#else
current_position[E_AXIS]+= FILAMENTCHANGE_FIRSTFEED ;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], FILAMENTCHANGE_EFEED_FIRST, active_extruder);
plan_buffer_line_curposXYZE(FILAMENTCHANGE_EFEED_FIRST, active_extruder);
#endif
load_filament_final_feed();
lcd_loading_filament();
@ -10482,34 +10514,20 @@ if(!(bEnableForce_z||eeprom_read_byte((uint8_t*)EEPROM_SILENT)))
void disable_force_z()
{
uint16_t z_microsteps=0;
uint16_t z_microsteps=0;
if(!bEnableForce_z)
return; // motor already disabled (may be ;-p )
bEnableForce_z=false;
if(!bEnableForce_z) return; // motor already disabled (may be ;-p )
// alignment to full-step
bEnableForce_z=false;
// switching to silent mode
#ifdef TMC2130
z_microsteps=tmc2130_rd_MSCNT(Z_TMC2130_CS);
#endif // TMC2130
planner_abort_hard();
sei();
plan_buffer_line(
current_position[X_AXIS],
current_position[Y_AXIS],
current_position[Z_AXIS]+float((1024-z_microsteps+7)>>4)/cs.axis_steps_per_unit[Z_AXIS],
current_position[E_AXIS],
40, active_extruder);
st_synchronize();
// switching to silent mode
#ifdef TMC2130
tmc2130_mode=TMC2130_MODE_SILENT;
update_mode_profile();
tmc2130_init(true);
tmc2130_mode=TMC2130_MODE_SILENT;
update_mode_profile();
tmc2130_init(true);
#endif // TMC2130
axis_known_position[Z_AXIS]=false;
axis_known_position[Z_AXIS]=false;
}

View File

@ -224,9 +224,13 @@ void cmdqueue_dump_to_serial_single_line(int nr, const char *p)
SERIAL_ECHOPGM("Entry nr: ");
SERIAL_ECHO(nr);
SERIAL_ECHOPGM(", type: ");
SERIAL_ECHO(int(*p));
int type = *p;
SERIAL_ECHO(type);
SERIAL_ECHOPGM(", size: ");
unsigned int size = *(unsigned int*)(p + 1);
SERIAL_ECHO(size);
SERIAL_ECHOPGM(", cmd: ");
SERIAL_ECHO(p+1);
SERIAL_ECHO(p + CMDHDRSIZE);
SERIAL_ECHOLNPGM("");
}
@ -247,7 +251,7 @@ void cmdqueue_dump_to_serial()
for (const char *p = cmdbuffer + bufindr; p < cmdbuffer + bufindw; ++ nr) {
cmdqueue_dump_to_serial_single_line(nr, p);
// Skip the command.
for (++p; *p != 0; ++ p);
for (p += CMDHDRSIZE; *p != 0; ++ p);
// Skip the gaps.
for (++p; p < cmdbuffer + bufindw && *p == 0; ++ p);
}
@ -255,14 +259,14 @@ void cmdqueue_dump_to_serial()
for (const char *p = cmdbuffer + bufindr; p < cmdbuffer + sizeof(cmdbuffer); ++ nr) {
cmdqueue_dump_to_serial_single_line(nr, p);
// Skip the command.
for (++p; *p != 0; ++ p);
for (p += CMDHDRSIZE; *p != 0; ++ p);
// Skip the gaps.
for (++p; p < cmdbuffer + sizeof(cmdbuffer) && *p == 0; ++ p);
}
for (const char *p = cmdbuffer; p < cmdbuffer + bufindw; ++ nr) {
cmdqueue_dump_to_serial_single_line(nr, p);
// Skip the command.
for (++p; *p != 0; ++ p);
for (p += CMDHDRSIZE; *p != 0; ++ p);
// Skip the gaps.
for (++p; p < cmdbuffer + bufindw && *p == 0; ++ p);
}

View File

@ -45,6 +45,8 @@ extern bool cmdbuffer_front_already_processed;
// Debugging information will be sent to serial line.
//#define CMDBUFFER_DEBUG
extern uint32_t sdpos_atomic;
extern int serial_count;
extern boolean comment_mode;
extern char *strchr_pointer;

View File

@ -40,15 +40,26 @@ void lay1cal_preheat()
}
//! @brief Print intro line
//! @brief Load filament
//! @param cmd_buffer character buffer needed to format gcodes
//! @param filament filament to use (applies for MMU only)
void lay1cal_intro_line(char *cmd_buffer, uint8_t filament)
void lay1cal_load_filament(char *cmd_buffer, uint8_t filament)
{
static const char cmd_intro_mmu_0[] PROGMEM = "M83";
static const char cmd_intro_mmu_1[] PROGMEM = "G1 Y-3.0 F1000.0";
static const char cmd_intro_mmu_2[] PROGMEM = "G1 Z0.4 F1000.0";
static const char cmd_intro_mmu_3[] PROGMEM = "G1 X55.0 E32.0 F1073.0"; // call T code before
if (mmu_enabled)
{
enquecommand_P(PSTR("M83"));
enquecommand_P(PSTR("G1 Y-3.0 F1000.0"));
enquecommand_P(PSTR("G1 Z0.4 F1000.0"));
sprintf_P(cmd_buffer, PSTR("T%d"), filament);
enquecommand(cmd_buffer);
}
}
//! @brief Print intro line
void lay1cal_intro_line()
{
static const char cmd_intro_mmu_3[] PROGMEM = "G1 X55.0 E32.0 F1073.0";
static const char cmd_intro_mmu_4[] PROGMEM = "G1 X5.0 E32.0 F1800.0";
static const char cmd_intro_mmu_5[] PROGMEM = "G1 X55.0 E8.0 F2000.0";
static const char cmd_intro_mmu_6[] PROGMEM = "G1 Z0.3 F1000.0";
@ -61,10 +72,7 @@ void lay1cal_intro_line(char *cmd_buffer, uint8_t filament)
static const char * const intro_mmu_cmd[] PROGMEM =
{
cmd_intro_mmu_0,
cmd_intro_mmu_1,
cmd_intro_mmu_2,
cmd_intro_mmu_3, // call T code before
cmd_intro_mmu_3,
cmd_intro_mmu_4,
cmd_intro_mmu_5,
cmd_intro_mmu_6,
@ -80,11 +88,6 @@ void lay1cal_intro_line(char *cmd_buffer, uint8_t filament)
{
for (uint8_t i = 0; i < (sizeof(intro_mmu_cmd)/sizeof(intro_mmu_cmd[0])); ++i)
{
if (3 == i)
{
sprintf_P(cmd_buffer, PSTR("T%d"), filament);
enquecommand(cmd_buffer);
}
enquecommand_P(static_cast<char*>(pgm_read_ptr(&intro_mmu_cmd[i])));
}
}

View File

@ -7,7 +7,8 @@
#include <stdint.h>
void lay1cal_preheat();
void lay1cal_intro_line(char *cmd_buffer, uint8_t filament);
void lay1cal_load_filament(char *cmd_buffer, uint8_t filament);
void lay1cal_intro_line();
void lay1cal_before_meander();
void lay1cal_meander(char *cmd_buffer);
void lay1cal_square(char *cmd_buffer, uint8_t i);

View File

@ -19,91 +19,162 @@
// So the automaton runs atop of inner 8 (or 16) cycles.
// The finite automaton is running in the ISR(TIMER0_OVF_vect)
// 2019-08-14 update: the original algorithm worked very well, however there were 2 regressions:
// 1. 62kHz ISR requires considerable amount of processing power,
// USB transfer speed dropped by 20%, which was most notable when doing short G-code segments.
// 2. Some users reported TLed PSU started clicking when running at 120V/60Hz.
// This looks like the original algorithm didn't maintain base PWM 30Hz, but only 15Hz
// To address both issues, there is an improved approach based on the idea of leveraging
// different CLK prescalers in some automaton states - i.e. when holding LOW or HIGH on the output pin,
// we don't have to clock 62kHz, but we can increase the CLK prescaler for these states to 8 (or even 64).
// That shall result in the ISR not being called that much resulting in regained performance
// Theoretically this is relatively easy, however one must be very carefull handling the AVR's timer
// control registers correctly, especially setting them in a correct order.
// Some registers are double buffered, some changes are applied in next cycles etc.
// The biggest problem was with the CLK prescaler itself - this circuit is shared among almost all timers,
// we don't want to reset the prescaler counted value when transiting among automaton states.
// Resetting the prescaler would make the PWM more precise, right now there are temporal segments
// of variable period ranging from 0 to 7 62kHz ticks - that's logical, the timer must "sync"
// to the new slower CLK after setting the slower prescaler value.
// In our application, this isn't any significant problem and may be ignored.
// Doing changes in timer's registers non-correctly results in artefacts on the output pin
// - it can toggle unnoticed, which will result in bed clicking again.
// That's why there are special transition states ZERO_TO_RISE and ONE_TO_FALL, which enable the
// counter change its operation atomically and without artefacts on the output pin.
// The resulting signal on the output pin was checked with an osciloscope.
// If there are any change requirements in the future, the signal must be checked with an osciloscope again,
// ad-hoc changes may completely screw things up!
///! Definition off finite automaton states
enum class States : uint8_t {
ZERO = 0,
RISE = 1,
ONE = 2,
FALL = 3
};
///! State table for the inner part of the finite automaton
///! Basically it specifies what shall happen if the outer automaton is requesting setting the heat pin to 0 (OFF) or 1 (ON)
///! ZERO: steady 0 (OFF), no change for the whole period
///! RISE: 8 (16) fast PWM cycles with increasing duty up to steady ON
///! ONE: steady 1 (ON), no change for the whole period
///! FALL: 8 (16) fast PWM cycles with decreasing duty down to steady OFF
///! @@TODO move it into progmem
static States stateTable[4*2] = {
// off on
States::ZERO, States::RISE, // ZERO
States::FALL, States::ONE, // RISE
States::FALL, States::ONE, // ONE
States::ZERO, States::RISE // FALL
ZERO_START = 0,///< entry point of the automaton - reads the soft_pwm_bed value for the next whole PWM cycle
ZERO, ///< steady 0 (OFF), no change for the whole period
ZERO_TO_RISE, ///< metastate allowing the timer change its state atomically without artefacts on the output pin
RISE, ///< 16 fast PWM cycles with increasing duty up to steady ON
RISE_TO_ONE, ///< metastate allowing the timer change its state atomically without artefacts on the output pin
ONE, ///< steady 1 (ON), no change for the whole period
ONE_TO_FALL, ///< metastate allowing the timer change its state atomically without artefacts on the output pin
FALL, ///< 16 fast PWM cycles with decreasing duty down to steady OFF
FALL_TO_ZERO ///< metastate allowing the timer change its state atomically without artefacts on the output pin
};
///! Inner states of the finite automaton
static States state = States::ZERO;
static States state = States::ZERO_START;
///! Inner and outer PWM counters
static uint8_t outer = 0;
static uint8_t inner = 0;
///! Fast PWM counter is used in the RISE and FALL states (62.5kHz)
static uint8_t slowCounter = 0;
///! Slow PWM counter is used in the ZERO and ONE states (62.5kHz/8 or 64)
static uint8_t fastCounter = 0;
///! PWM counter for the whole cycle - a cache for soft_pwm_bed
static uint8_t pwm = 0;
///! the slow PWM duty for the next 30Hz cycle
///! The slow PWM duty for the next 30Hz cycle
///! Set in the whole firmware at various places
extern unsigned char soft_pwm_bed;
/// Fine tuning of automaton cycles
#if 1
static const uint8_t innerMax = 16;
static const uint8_t innerShift = 4;
#else
static const uint8_t innerMax = 8;
static const uint8_t innerShift = 5;
#endif
/// fastMax - how many fast PWM steps to do in RISE and FALL states
/// 16 is a good compromise between silenced bed ("smooth" edges)
/// and not burning the switching MOSFET
static const uint8_t fastMax = 16;
/// Scaler 16->256 for fast PWM
static const uint8_t fastShift = 4;
/// Increment slow PWM counter by slowInc every ZERO or ONE state
/// This allows for fine-tuning the basic PWM switching frequency
/// A possible further optimization - use a 64 prescaler (instead of 8)
/// increment slowCounter by 1
/// but use less bits of soft PWM - something like soft_pwm_bed >> 2
/// that may further reduce the CPU cycles required by the bed heating automaton
/// Due to the nature of bed heating the reduced PID precision may not be a major issue, however doing 8x less ISR(timer0_ovf) may significantly improve the performance
static const uint8_t slowInc = 1;
ISR(TIMER0_OVF_vect) // timer compare interrupt service routine
{
if( inner ){
switch(state){
case States::ZERO:
OCR0B = 255;
// Commenting the following code saves 6B, but it is left here for reference
// It is not necessary to set it all over again, because we can only get into the ZERO state from the FALL state (which sets this register)
// TCCR0A |= (1 << COM0B1) | (1 << COM0B0);
break;
case States::RISE:
OCR0B = (innerMax - inner) << innerShift;
// TCCR0A |= (1 << COM0B1); // this bit is always 1
TCCR0A &= ~(1 << COM0B0);
break;
case States::ONE:
OCR0B = 255;
// again - may be skipped, because we get into the ONE state only from RISE (which sets this register)
// TCCR0A |= (1 << COM0B1);
TCCR0A &= ~(1 << COM0B0);
break;
case States::FALL:
OCR0B = (innerMax - inner) << innerShift; // this is the same as in RISE, because now we are setting the zero part of duty due to inverting mode
// must switch to inverting mode already here, because it takes a whole PWM cycle and it would make a "1" at the end of this pwm cycle
TCCR0A |= /*(1 << COM0B1) |*/ (1 << COM0B0);
break;
switch(state){
case States::ZERO_START:
pwm = soft_pwm_bed << 1;// expecting soft_pwm_bed to be 7bit!
if( pwm != 0 ){
state = States::ZERO; // do nothing, let it tick once again after the 30Hz period
}
break;
case States::ZERO: // end of state ZERO - we'll either stay in ZERO or change to RISE
// In any case update our cache of pwm value for the next whole cycle from soft_pwm_bed
slowCounter += slowInc; // this does software timer_clk/256 or less (depends on slowInc)
if( slowCounter > pwm ){
return;
} // otherwise moving towards RISE
state = States::ZERO_TO_RISE; // and finalize the change in a transitional state RISE0
break;
// even though it may look like the ZERO state may be glued together with the ZERO_TO_RISE, don't do it
// the timer must tick once more in order to get rid of occasional output pin toggles.
case States::ZERO_TO_RISE: // special state for handling transition between prescalers and switching inverted->non-inverted fast-PWM without toggling the output pin.
// It must be done in consequent steps, otherwise the pin will get flipped up and down during one PWM cycle.
// Also beware of the correct sequence of the following timer control registers initialization - it really matters!
state = States::RISE; // prepare for standard RISE cycles
fastCounter = fastMax - 1;// we'll do 16-1 cycles of RISE
TCNT0 = 255; // force overflow on the next clock cycle
TCCR0B = (1 << CS00); // change prescaler to 1, i.e. 62.5kHz
TCCR0A &= ~(1 << COM0B0); // Clear OC0B on Compare Match, set OC0B at BOTTOM (non-inverting mode)
break;
case States::RISE:
OCR0B = (fastMax - fastCounter) << fastShift;
if( fastCounter ){
--fastCounter;
} else { // end of RISE cycles, changing into state ONE
state = States::RISE_TO_ONE;
OCR0B = 255; // full duty
TCNT0 = 254; // make the timer overflow in the next cycle
// @@TODO these constants are still subject to investigation
}
break;
case States::RISE_TO_ONE:
state = States::ONE;
OCR0B = 255; // full duty
TCNT0 = 255; // make the timer overflow in the next cycle
TCCR0B = (1 << CS01); // change prescaler to 8, i.e. 7.8kHz
break;
case States::ONE: // state ONE - we'll either stay in ONE or change to FALL
OCR0B = 255;
slowCounter += slowInc; // this does software timer_clk/256 or less
if( slowCounter < pwm ){
return;
}
if( (soft_pwm_bed << 1) >= (255 - slowInc - 1) ){ //@@TODO simplify & explain
// if slowInc==2, soft_pwm == 251 will be the first to do short drops to zero. 252 will keep full heating
return; // want full duty for the next ONE cycle again - so keep on heating and just wait for the next timer ovf
}
// otherwise moving towards FALL
// @@TODO it looks like ONE_TO_FALL isn't necessary, there are no artefacts at all
state = States::ONE;//_TO_FALL;
// TCCR0B = (1 << CS00); // change prescaler to 1, i.e. 62.5kHz
// break;
// case States::ONE_TO_FALL:
// OCR0B = 255; // zero duty
state=States::FALL;
fastCounter = fastMax - 1;// we'll do 16-1 cycles of RISE
TCNT0 = 255; // force overflow on the next clock cycle
TCCR0B = (1 << CS00); // change prescaler to 1, i.e. 62.5kHz
// must switch to inverting mode already here, because it takes a whole PWM cycle and it would make a "1" at the end of this pwm cycle
// COM0B1 remains set both in inverting and non-inverting mode
TCCR0A |= (1 << COM0B0); // inverting mode
break;
case States::FALL:
OCR0B = (fastMax - fastCounter) << fastShift; // this is the same as in RISE, because now we are setting the zero part of duty due to inverting mode
//TCCR0A |= (1 << COM0B0); // already set in ONE_TO_FALL
if( fastCounter ){
--fastCounter;
} else { // end of FALL cycles, changing into state ZERO
state = States::FALL_TO_ZERO;
TCNT0 = 128; //@@TODO again - need to wait long enough to propagate the timer state changes
OCR0B = 255;
}
break;
case States::FALL_TO_ZERO:
state = States::ZERO_START; // go to read new soft_pwm_bed value for the next cycle
TCNT0 = 128;
OCR0B = 255;
TCCR0B = (1 << CS01); // change prescaler to 8, i.e. 7.8kHz
break;
}
--inner;
} else {
if( ! outer ){ // at the end of 30Hz PWM period
// synchro is not needed (almost), soft_pwm_bed is just 1 byte, 1-byte write instruction is atomic
pwm = soft_pwm_bed << 1;
}
if( pwm > outer || pwm >= 254 ){
// soft_pwm_bed has a range of 0-127, that why a <<1 is done here. That also means that we may get only up to 254 which we want to be full-time 1 (ON)
state = stateTable[ uint8_t(state) * 2 + 1 ];
} else {
// switch OFF
state = stateTable[ uint8_t(state) * 2 + 0 ];
}
++outer;
inner = innerMax;
}
}

View File

@ -919,7 +919,7 @@ static inline void go_xy(float x, float y, float fr)
static inline void go_to_current(float fr)
{
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], fr, active_extruder);
plan_buffer_line_curposXYZE(fr, active_extruder);
st_synchronize();
}
@ -2769,7 +2769,7 @@ bool sample_z() {
//make space
current_position[Z_AXIS] += 150;
go_to_current(homing_feedrate[Z_AXIS] / 60);
//plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate, active_extruder););
//plan_buffer_line_curposXYZE(feedrate, active_extruder););
lcd_show_fullscreen_message_and_wait_P(_T(MSG_PLACE_STEEL_SHEET));

View File

@ -537,7 +537,7 @@ void mmu_command(MmuCmd cmd)
void mmu_load_step(bool synchronize)
{
current_position[E_AXIS] = current_position[E_AXIS] + MMU_LOAD_FEEDRATE * 0.1;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], MMU_LOAD_FEEDRATE, active_extruder);
plan_buffer_line_curposXYZE(MMU_LOAD_FEEDRATE, active_extruder);
if (synchronize) st_synchronize();
}
@ -602,7 +602,7 @@ bool mmu_get_response(uint8_t move)
{
printf_P(PSTR("Unload 1\n"));
current_position[E_AXIS] = current_position[E_AXIS] - MMU_LOAD_FEEDRATE * MMU_LOAD_TIME_MS*0.001;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], MMU_LOAD_FEEDRATE, active_extruder);
plan_buffer_line_curposXYZE(MMU_LOAD_FEEDRATE, active_extruder);
st_synchronize();
}
}
@ -620,7 +620,7 @@ bool mmu_get_response(uint8_t move)
{
printf_P(PSTR("Unload 2\n"));
current_position[E_AXIS] = current_position[E_AXIS] - MMU_LOAD_FEEDRATE * MMU_LOAD_TIME_MS*0.001;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], MMU_LOAD_FEEDRATE, active_extruder);
plan_buffer_line_curposXYZE(MMU_LOAD_FEEDRATE, active_extruder);
st_synchronize();
}
}
@ -698,13 +698,13 @@ void manage_response(bool move_axes, bool turn_off_nozzle, uint8_t move)
//lift z
current_position[Z_AXIS] += Z_PAUSE_LIFT;
if (current_position[Z_AXIS] > Z_MAX_POS) current_position[Z_AXIS] = Z_MAX_POS;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 15, active_extruder);
plan_buffer_line_curposXYZE(15, active_extruder);
st_synchronize();
//Move XY to side
current_position[X_AXIS] = X_PAUSE_POS;
current_position[Y_AXIS] = Y_PAUSE_POS;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 50, active_extruder);
plan_buffer_line_curposXYZE(50, active_extruder);
st_synchronize();
}
if (turn_off_nozzle) {
@ -762,10 +762,10 @@ void manage_response(bool move_axes, bool turn_off_nozzle, uint8_t move)
lcd_display_message_fullscreen_P(_i("MMU OK. Resuming position..."));
current_position[X_AXIS] = x_position_bckp;
current_position[Y_AXIS] = y_position_bckp;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 50, active_extruder);
plan_buffer_line_curposXYZE(50, active_extruder);
st_synchronize();
current_position[Z_AXIS] = z_position_bckp;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 15, active_extruder);
plan_buffer_line_curposXYZE(15, active_extruder);
st_synchronize();
}
else {
@ -804,19 +804,19 @@ void mmu_load_to_nozzle()
current_position[E_AXIS] += 7.2f;
}
float feedrate = 562;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate / 60, active_extruder);
plan_buffer_line_curposXYZE(feedrate / 60, active_extruder);
st_synchronize();
current_position[E_AXIS] += 14.4f;
feedrate = 871;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate / 60, active_extruder);
plan_buffer_line_curposXYZE(feedrate / 60, active_extruder);
st_synchronize();
current_position[E_AXIS] += 36.0f;
feedrate = 1393;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate / 60, active_extruder);
plan_buffer_line_curposXYZE(feedrate / 60, active_extruder);
st_synchronize();
current_position[E_AXIS] += 14.4f;
feedrate = 871;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate / 60, active_extruder);
plan_buffer_line_curposXYZE(feedrate / 60, active_extruder);
st_synchronize();
if (!saved_e_relative_mode) axis_relative_modes[E_AXIS] = false;
}
@ -889,7 +889,7 @@ void mmu_M600_load_filament(bool automatic, float nozzle_temp)
mmu_command(MmuCmd::T0 + tmp_extruder);
manage_response(false, true, MMU_LOAD_MOVE);
mmu_continue_loading(is_usb_printing);
mmu_continue_loading(is_usb_printing || (lcd_commands_type == LcdCommands::Layer1Cal));
mmu_extruder = tmp_extruder; //filament change is finished
mmu_load_to_nozzle();
@ -903,7 +903,7 @@ void extr_mov(float shift, float feed_rate)
{ //move extruder no matter what the current heater temperature is
set_extrude_min_temp(.0);
current_position[E_AXIS] += shift;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feed_rate, active_extruder);
plan_buffer_line_curposXYZE(feed_rate, active_extruder);
set_extrude_min_temp(EXTRUDE_MINTEMP);
}
#endif //SNMM
@ -1069,8 +1069,7 @@ void mmu_filament_ramming()
for(uint8_t i = 0; i < (sizeof(ramming_sequence)/sizeof(E_step));++i)
{
current_position[E_AXIS] += pgm_read_float(&(ramming_sequence[i].extrude));
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS],
current_position[E_AXIS], pgm_read_float(&(ramming_sequence[i].feed_rate)), active_extruder);
plan_buffer_line_curposXYZE(pgm_read_float(&(ramming_sequence[i].feed_rate)), active_extruder);
st_synchronize();
}
}
@ -1140,39 +1139,39 @@ void extr_unload()
lcd_set_cursor(0, 2); lcd_puts_P(_T(MSG_PLEASE_WAIT));
if (current_position[Z_AXIS] < 15) {
current_position[Z_AXIS] += 15; //lifting in Z direction to make space for extrusion
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 25, active_extruder);
plan_buffer_line_curposXYZE(25, active_extruder);
}
current_position[E_AXIS] += 10; //extrusion
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 10, active_extruder);
plan_buffer_line_curposXYZE(10, active_extruder);
st_current_set(2, E_MOTOR_HIGH_CURRENT);
if (current_temperature[0] < 230) { //PLA & all other filaments
current_position[E_AXIS] += 5.4;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2800 / 60, active_extruder);
plan_buffer_line_curposXYZE(2800 / 60, active_extruder);
current_position[E_AXIS] += 3.2;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
plan_buffer_line_curposXYZE(3000 / 60, active_extruder);
current_position[E_AXIS] += 3;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3400 / 60, active_extruder);
plan_buffer_line_curposXYZE(3400 / 60, active_extruder);
}
else { //ABS
current_position[E_AXIS] += 3.1;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2000 / 60, active_extruder);
plan_buffer_line_curposXYZE(2000 / 60, active_extruder);
current_position[E_AXIS] += 3.1;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2500 / 60, active_extruder);
plan_buffer_line_curposXYZE(2500 / 60, active_extruder);
current_position[E_AXIS] += 4;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
plan_buffer_line_curposXYZE(3000 / 60, active_extruder);
/*current_position[X_AXIS] += 23; //delay
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 600 / 60, active_extruder); //delay
plan_buffer_line_curposXYZE(600 / 60, active_extruder); //delay
current_position[X_AXIS] -= 23; //delay
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 600 / 60, active_extruder); //delay*/
plan_buffer_line_curposXYZE(600 / 60, active_extruder); //delay*/
delay_keep_alive(4700);
}
max_feedrate[E_AXIS] = 80;
current_position[E_AXIS] -= (bowden_length[mmu_extruder] + 60 + FIL_LOAD_LENGTH) / 2;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 500, active_extruder);
plan_buffer_line_curposXYZE(500, active_extruder);
current_position[E_AXIS] -= (bowden_length[mmu_extruder] + 60 + FIL_LOAD_LENGTH) / 2;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 500, active_extruder);
plan_buffer_line_curposXYZE(500, active_extruder);
st_synchronize();
//st_current_init();
if (SilentMode != SILENT_MODE_OFF) st_current_set(2, tmp_motor[2]); //set back to normal operation currents
@ -1465,11 +1464,9 @@ bFilamentAction=false; // NOT in "mmu_fil_eject_menu(
static bool can_load()
{
current_position[E_AXIS] += 60;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS],
current_position[E_AXIS], MMU_LOAD_FEEDRATE, active_extruder);
plan_buffer_line_curposXYZE(MMU_LOAD_FEEDRATE, active_extruder);
current_position[E_AXIS] -= 52;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS],
current_position[E_AXIS], MMU_LOAD_FEEDRATE, active_extruder);
plan_buffer_line_curposXYZE(MMU_LOAD_FEEDRATE, active_extruder);
st_synchronize();
uint_least8_t filament_detected_count = 0;
@ -1479,8 +1476,7 @@ static bool can_load()
for(uint_least8_t i = 0; i < steps; ++i)
{
current_position[E_AXIS] -= e_increment;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS],
current_position[E_AXIS], MMU_LOAD_FEEDRATE, active_extruder);
plan_buffer_line_curposXYZE(MMU_LOAD_FEEDRATE, active_extruder);
st_synchronize();
if(0 == PIN_GET(IR_SENSOR_PIN))
{
@ -1601,13 +1597,13 @@ void mmu_continue_loading(bool blocking)
//lift z
current_position[Z_AXIS] += Z_PAUSE_LIFT;
if (current_position[Z_AXIS] > Z_MAX_POS) current_position[Z_AXIS] = Z_MAX_POS;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 15, active_extruder);
plan_buffer_line_curposXYZE(15, active_extruder);
st_synchronize();
//Move XY to side
current_position[X_AXIS] = X_PAUSE_POS;
current_position[Y_AXIS] = Y_PAUSE_POS;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 50, active_extruder);
plan_buffer_line_curposXYZE(50, active_extruder);
st_synchronize();
mmu_command(MmuCmd::U0);

View File

@ -651,11 +651,15 @@ void planner_abort_hard()
waiting_inside_plan_buffer_line_print_aborted = true;
}
void plan_buffer_line_curposXYZE(float feed_rate, uint8_t extruder) {
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feed_rate, extruder );
}
float junction_deviation = 0.1;
// Add a new linear movement to the buffer. steps_x, _y and _z is the absolute position in
// mm. Microseconds specify how many microseconds the move should take to perform. To aid acceleration
// calculation the caller must also provide the physical length of the line in millimeters.
void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, const uint8_t &extruder)
void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, uint8_t extruder)
{
// Calculate the buffer head after we push this byte
int next_buffer_head = next_block_index(block_buffer_head);

View File

@ -140,7 +140,14 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate
// Get the position applying the bed level matrix if enabled
vector_3 plan_get_position();
#else
void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, const uint8_t &extruder);
/// Extracting common call of
/// plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], ...
/// saves almost 5KB.
/// The performance penalty is negligible, since these planned lines are usually maintenance moves with the extruder.
void plan_buffer_line_curposXYZE(float feed_rate, uint8_t extruder);
void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, uint8_t extruder);
//void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t &extruder);
#endif // ENABLE_AUTO_BED_LEVELING

View File

@ -26,7 +26,7 @@ void timer0_init(void)
OCR0B = 255;
// Set fast PWM mode and inverting mode.
TCCR0A = (1 << WGM01) | (1 << WGM00) | (1 << COM0B1) | (1 << COM0B0);
TCCR0B = (1 << CS00); // no clock prescaling
TCCR0B = (1 << CS01); // CLK/8 prescaling
TIMSK0 |= (1 << TOIE0); // enable timer overflow interrupt
// Everything, that used to be on timer0 was moved to timer2 (delay, beeping, millis etc.)

View File

@ -58,17 +58,9 @@ uint8_t SilentModeMenu_MMU = 1; //activate mmu unit stealth mode
int8_t FSensorStateMenu = 1;
int8_t CrashDetectMenu = 1;
extern bool fsensor_enable();
extern void fsensor_disable();
#ifdef TMC2130
extern void crashdet_enable();
extern void crashdet_disable();
#endif //TMC2130
#ifdef SDCARD_SORT_ALPHA
bool presort_flag = false;
@ -120,14 +112,7 @@ static void lcd_tune_menu();
//static void lcd_move_menu();
static void lcd_settings_menu();
static void lcd_calibration_menu();
#ifdef LINEARITY_CORRECTION
static void lcd_settings_menu_back();
#endif //LINEARITY_CORRECTION
static void lcd_control_temperature_menu();
static void lcd_control_temperature_preheat_pla_settings_menu();
static void lcd_control_temperature_preheat_abs_settings_menu();
static void lcd_control_motion_menu();
static void lcd_control_volumetric_menu();
static void lcd_settings_linearity_correction_menu_save();
static void prusa_stat_printerstatus(int _status);
static void prusa_stat_farm_number();
@ -1361,42 +1346,46 @@ void lcd_commands()
if(lcd_commands_step>1) lcd_timeoutToStatus.start(); //if user dont confirm live adjust Z value by pressing the knob, we are saving last value by timeout to status screen
if (!blocks_queued() && cmd_buffer_empty())
if (!blocks_queued() && cmd_buffer_empty() && !saved_printing)
{
switch(lcd_commands_step)
{
case 0:
lcd_commands_step = 10;
lcd_commands_step = 11;
break;
case 20:
filament = 0;
lcd_commands_step = 10;
lcd_commands_step = 11;
break;
case 21:
filament = 1;
lcd_commands_step = 10;
lcd_commands_step = 11;
break;
case 22:
filament = 2;
lcd_commands_step = 10;
lcd_commands_step = 11;
break;
case 23:
filament = 3;
lcd_commands_step = 10;
lcd_commands_step = 11;
break;
case 24:
filament = 4;
lcd_commands_step = 11;
break;
case 11:
lay1cal_preheat();
lcd_commands_step = 10;
break;
case 10:
lay1cal_preheat();
lay1cal_load_filament(cmd1, filament);
lcd_commands_step = 9;
break;
case 9:
lcd_clear();
menu_depth = 0;
menu_submenu(lcd_babystep_z);
lay1cal_intro_line(cmd1, filament);
lay1cal_intro_line();
lcd_commands_step = 8;
break;
case 8:
@ -1676,7 +1665,7 @@ static void lcd_move_menu_axis();
/* Menu implementation */
void lcd_preheat_farm()
static void lcd_preheat_farm()
{
setTargetHotend0(FARM_PREHEAT_HOTEND_TEMP);
setTargetBed(FARM_PREHEAT_HPB_TEMP);
@ -1685,7 +1674,7 @@ void lcd_preheat_farm()
setWatch(); // heater sanity check timer
}
void lcd_preheat_farm_nozzle()
static void lcd_preheat_farm_nozzle()
{
setTargetHotend0(FARM_PREHEAT_HOTEND_TEMP);
setTargetBed(0);
@ -1694,68 +1683,78 @@ void lcd_preheat_farm_nozzle()
setWatch(); // heater sanity check timer
}
void lcd_preheat_pla()
static void lcd_preheat_pla()
{
setTargetHotend0(PLA_PREHEAT_HOTEND_TEMP);
if (!wizard_active) setTargetBed(PLA_PREHEAT_HPB_TEMP);
fanSpeed = 0;
fanSpeed = PLA_PREHEAT_FAN_SPEED;
lcd_return_to_status();
setWatch(); // heater sanity check timer
if (wizard_active) lcd_wizard(WizState::Unload);
}
void lcd_preheat_abs()
static void lcd_preheat_asa()
{
setTargetHotend0(ASA_PREHEAT_HOTEND_TEMP);
if (!wizard_active) setTargetBed(ASA_PREHEAT_HPB_TEMP);
fanSpeed = ASA_PREHEAT_FAN_SPEED;
lcd_return_to_status();
setWatch(); // heater sanity check timer
if (wizard_active) lcd_wizard(WizState::Unload);
}
static void lcd_preheat_abs()
{
setTargetHotend0(ABS_PREHEAT_HOTEND_TEMP);
if (!wizard_active) setTargetBed(ABS_PREHEAT_HPB_TEMP);
fanSpeed = 0;
fanSpeed = ABS_PREHEAT_FAN_SPEED;
lcd_return_to_status();
setWatch(); // heater sanity check timer
if (wizard_active) lcd_wizard(WizState::Unload);
}
void lcd_preheat_pp()
static void lcd_preheat_pp()
{
setTargetHotend0(PP_PREHEAT_HOTEND_TEMP);
if (!wizard_active) setTargetBed(PP_PREHEAT_HPB_TEMP);
fanSpeed = 0;
fanSpeed = PP_PREHEAT_FAN_SPEED;
lcd_return_to_status();
setWatch(); // heater sanity check timer
if (wizard_active) lcd_wizard(WizState::Unload);
}
void lcd_preheat_pet()
static void lcd_preheat_pet()
{
setTargetHotend0(PET_PREHEAT_HOTEND_TEMP);
if (!wizard_active) setTargetBed(PET_PREHEAT_HPB_TEMP);
fanSpeed = 0;
fanSpeed = PET_PREHEAT_FAN_SPEED;
lcd_return_to_status();
setWatch(); // heater sanity check timer
if (wizard_active) lcd_wizard(WizState::Unload);
}
void lcd_preheat_hips()
static void lcd_preheat_hips()
{
setTargetHotend0(HIPS_PREHEAT_HOTEND_TEMP);
if (!wizard_active) setTargetBed(HIPS_PREHEAT_HPB_TEMP);
fanSpeed = 0;
fanSpeed = HIPS_PREHEAT_FAN_SPEED;
lcd_return_to_status();
setWatch(); // heater sanity check timer
if (wizard_active) lcd_wizard(WizState::Unload);
}
void lcd_preheat_flex()
static void lcd_preheat_flex()
{
setTargetHotend0(FLEX_PREHEAT_HOTEND_TEMP);
if (!wizard_active) setTargetBed(FLEX_PREHEAT_HPB_TEMP);
fanSpeed = 0;
fanSpeed = FLEX_PREHEAT_FAN_SPEED;
lcd_return_to_status();
setWatch(); // heater sanity check timer
if (wizard_active) lcd_wizard(WizState::Unload);
}
void lcd_cooldown()
static void lcd_cooldown()
{
setAllTargetHotends(0);
setTargetBed(0);
@ -2037,6 +2036,7 @@ static void lcd_preheat_menu()
} else {
MENU_ITEM_FUNCTION_P(PSTR("PLA - " STRINGIFY(PLA_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PLA_PREHEAT_HPB_TEMP)), lcd_preheat_pla);
MENU_ITEM_FUNCTION_P(PSTR("PET - " STRINGIFY(PET_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PET_PREHEAT_HPB_TEMP)), lcd_preheat_pet);
MENU_ITEM_FUNCTION_P(PSTR("ASA - " STRINGIFY(ASA_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(ASA_PREHEAT_HPB_TEMP)), lcd_preheat_asa);
MENU_ITEM_FUNCTION_P(PSTR("ABS - " STRINGIFY(ABS_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(ABS_PREHEAT_HPB_TEMP)), lcd_preheat_abs);
MENU_ITEM_FUNCTION_P(PSTR("HIPS - " STRINGIFY(HIPS_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(HIPS_PREHEAT_HPB_TEMP)), lcd_preheat_hips);
MENU_ITEM_FUNCTION_P(PSTR("PP - " STRINGIFY(PP_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PP_PREHEAT_HPB_TEMP)), lcd_preheat_pp);
@ -2486,6 +2486,12 @@ bFilamentPreheatState=false;
mFilamentItem(PET_PREHEAT_HOTEND_TEMP,PET_PREHEAT_HPB_TEMP);
}
static void mFilamentItem_ASA()
{
bFilamentPreheatState=false;
mFilamentItem(ASA_PREHEAT_HOTEND_TEMP,ASA_PREHEAT_HPB_TEMP);
}
static void mFilamentItem_ABS()
{
bFilamentPreheatState=false;
@ -2520,15 +2526,16 @@ if(eFilamentAction==FilamentAction::AutoLoad)
void mFilamentMenu()
{
MENU_BEGIN();
MENU_ITEM_FUNCTION_P(_T(MSG_MAIN),mFilamentBack);
MENU_ITEM_SUBMENU_P(PSTR("PLA - " STRINGIFY(PLA_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PLA_PREHEAT_HPB_TEMP)),mFilamentItem_PLA);
MENU_ITEM_SUBMENU_P(PSTR("PET - " STRINGIFY(PET_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PET_PREHEAT_HPB_TEMP)),mFilamentItem_PET);
MENU_ITEM_SUBMENU_P(PSTR("ABS - " STRINGIFY(ABS_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(ABS_PREHEAT_HPB_TEMP)),mFilamentItem_ABS);
MENU_ITEM_SUBMENU_P(PSTR("HIPS - " STRINGIFY(HIPS_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(HIPS_PREHEAT_HPB_TEMP)),mFilamentItem_HIPS);
MENU_ITEM_SUBMENU_P(PSTR("PP - " STRINGIFY(PP_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PP_PREHEAT_HPB_TEMP)),mFilamentItem_PP);
MENU_ITEM_SUBMENU_P(PSTR("FLEX - " STRINGIFY(FLEX_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(FLEX_PREHEAT_HPB_TEMP)),mFilamentItem_FLEX);
MENU_END();
MENU_BEGIN();
MENU_ITEM_FUNCTION_P(_T(MSG_MAIN),mFilamentBack);
MENU_ITEM_SUBMENU_P(PSTR("PLA - " STRINGIFY(PLA_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PLA_PREHEAT_HPB_TEMP)),mFilamentItem_PLA);
MENU_ITEM_SUBMENU_P(PSTR("PET - " STRINGIFY(PET_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PET_PREHEAT_HPB_TEMP)),mFilamentItem_PET);
MENU_ITEM_SUBMENU_P(PSTR("ASA - " STRINGIFY(ASA_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(ASA_PREHEAT_HPB_TEMP)),mFilamentItem_ASA);
MENU_ITEM_SUBMENU_P(PSTR("ABS - " STRINGIFY(ABS_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(ABS_PREHEAT_HPB_TEMP)),mFilamentItem_ABS);
MENU_ITEM_SUBMENU_P(PSTR("HIPS - " STRINGIFY(HIPS_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(HIPS_PREHEAT_HPB_TEMP)),mFilamentItem_HIPS);
MENU_ITEM_SUBMENU_P(PSTR("PP - " STRINGIFY(PP_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PP_PREHEAT_HPB_TEMP)),mFilamentItem_PP);
MENU_ITEM_SUBMENU_P(PSTR("FLEX - " STRINGIFY(FLEX_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(FLEX_PREHEAT_HPB_TEMP)),mFilamentItem_FLEX);
MENU_END();
}
void mFilamentItemForce()
@ -2896,7 +2903,7 @@ static void _lcd_move(const char *name, int axis, int min, int max)
if (max_software_endstops && current_position[axis] > max) current_position[axis] = max;
lcd_encoder = 0;
world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]);
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[axis] / 60, active_extruder);
plan_buffer_line_curposXYZE(manual_feedrate[axis] / 60, active_extruder);
lcd_draw_update = 1;
}
}
@ -2921,7 +2928,7 @@ static void lcd_move_e()
{
current_position[E_AXIS] += float((int)lcd_encoder) * move_menu_scale;
lcd_encoder = 0;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[E_AXIS] / 60, active_extruder);
plan_buffer_line_curposXYZE(manual_feedrate[E_AXIS] / 60, active_extruder);
lcd_draw_update = 1;
}
}
@ -3420,7 +3427,7 @@ bool lcd_calibrate_z_end_stop_manual(bool only_z)
// Only move up, whatever direction the user rotates the encoder.
current_position[Z_AXIS] += fabs(lcd_encoder);
lcd_encoder = 0;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[Z_AXIS] / 60, active_extruder);
plan_buffer_line_curposXYZE(manual_feedrate[Z_AXIS] / 60, active_extruder);
}
}
if (lcd_clicked()) {
@ -4440,24 +4447,25 @@ static void lcd_silent_mode_set() {
#endif //TMC2130
st_current_init();
#ifdef TMC2130
if (CrashDetectMenu && (SilentModeMenu != SILENT_MODE_NORMAL))
if (lcd_crash_detect_enabled() && (SilentModeMenu != SILENT_MODE_NORMAL))
menu_submenu(lcd_crash_mode_info2);
lcd_encoder_diff=0; // reset 'encoder buffer'
#endif //TMC2130
}
#ifdef TMC2130
static void lcd_crash_mode_set()
static void crash_mode_switch()
{
CrashDetectMenu = !CrashDetectMenu; //set also from crashdet_enable() and crashdet_disable()
if (CrashDetectMenu==0) {
crashdet_disable();
}else{
crashdet_enable();
if (lcd_crash_detect_enabled())
{
lcd_crash_detect_disable();
}
else
{
lcd_crash_detect_enable();
}
if (IS_SD_PRINTING || is_usb_printing || (lcd_commands_type == LcdCommands::Layer1Cal)) menu_goto(lcd_tune_menu, 9, true, true);
else menu_goto(lcd_settings_menu, 9, true, true);
}
#endif //TMC2130
@ -4613,7 +4621,7 @@ void lcd_calibrate_pinda() {
lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_PLEASE_WAIT));
current_position[E_AXIS] += e_shift_calibration;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate, active_extruder);
plan_buffer_line_curposXYZE(feedrate, active_extruder);
st_synchronize();
lcd_display_message_fullscreen_P(msg_e_cal_knob);
@ -4636,7 +4644,7 @@ void lcd_calibrate_pinda() {
if (!planner_queue_full()) {
current_position[E_AXIS] += float(abs((int)lcd_encoder)) * 0.01; //0.05
lcd_encoder = 0;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate, active_extruder);
plan_buffer_line_curposXYZE(feedrate, active_extruder);
}
}
@ -4756,7 +4764,7 @@ void lcd_language()
static void wait_preheat()
{
current_position[Z_AXIS] = 100; //move in z axis to make space for loading filament
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[Z_AXIS] / 60, active_extruder);
plan_buffer_line_curposXYZE(homing_feedrate[Z_AXIS] / 60, active_extruder);
delay_keep_alive(2000);
lcd_display_message_fullscreen_P(_T(MSG_WIZARD_HEATING));
lcd_set_custom_characters();
@ -5171,11 +5179,11 @@ do\
else MENU_ITEM_FUNCTION_P(_T(MSG_STEALTH_MODE_ON), lcd_silent_mode_set);\
if (SilentModeMenu == SILENT_MODE_NORMAL)\
{\
if (CrashDetectMenu == 0)\
if (lcd_crash_detect_enabled())\
{\
MENU_ITEM_FUNCTION_P(_T(MSG_CRASHDETECT_OFF), lcd_crash_mode_set);\
MENU_ITEM_FUNCTION_P(_T(MSG_CRASHDETECT_ON), crash_mode_switch);\
}\
else MENU_ITEM_FUNCTION_P(_T(MSG_CRASHDETECT_ON), lcd_crash_mode_set);\
else MENU_ITEM_FUNCTION_P(_T(MSG_CRASHDETECT_OFF), crash_mode_switch);\
}\
else MENU_ITEM_SUBMENU_P(_T(MSG_CRASHDETECT_NA), lcd_crash_mode_info);\
}\
@ -6207,13 +6215,13 @@ void unload_filament()
// extr_unload2();
current_position[E_AXIS] -= 45;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 5200 / 60, active_extruder);
plan_buffer_line_curposXYZE(5200 / 60, active_extruder);
st_synchronize();
current_position[E_AXIS] -= 15;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 1000 / 60, active_extruder);
plan_buffer_line_curposXYZE(1000 / 60, active_extruder);
st_synchronize();
current_position[E_AXIS] -= 20;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 1000 / 60, active_extruder);
plan_buffer_line_curposXYZE(1000 / 60, active_extruder);
st_synchronize();
lcd_display_message_fullscreen_P(_T(MSG_PULL_OUT_FILAMENT));
@ -6889,8 +6897,8 @@ static void lcd_tune_menu()
if (SilentModeMenu == SILENT_MODE_NORMAL)
{
if (CrashDetectMenu == 0) MENU_ITEM_FUNCTION_P(_T(MSG_CRASHDETECT_OFF), lcd_crash_mode_set);
else MENU_ITEM_FUNCTION_P(_T(MSG_CRASHDETECT_ON), lcd_crash_mode_set);
if (lcd_crash_detect_enabled()) MENU_ITEM_FUNCTION_P(_T(MSG_CRASHDETECT_ON), crash_mode_switch);
else MENU_ITEM_FUNCTION_P(_T(MSG_CRASHDETECT_OFF), crash_mode_switch);
}
else MENU_ITEM_SUBMENU_P(_T(MSG_CRASHDETECT_NA), lcd_crash_mode_info);
}
@ -7294,7 +7302,7 @@ bool lcd_selftest()
//homeaxis(X_AXIS);
//homeaxis(Y_AXIS);
current_position[Z_AXIS] = current_position[Z_AXIS] + 10;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
plan_buffer_line_curposXYZE(manual_feedrate[0] / 60, active_extruder);
st_synchronize();
_progress = lcd_selftest_screen(TestScreen::AxisZ, _progress, 3, true, 1500);
_result = lcd_selfcheck_axis(2, Z_MAX_POS);
@ -7308,7 +7316,7 @@ bool lcd_selftest()
if (_result)
{
current_position[Z_AXIS] = current_position[Z_AXIS] + 10;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
plan_buffer_line_curposXYZE(manual_feedrate[0] / 60, active_extruder);
st_synchronize();
_progress = lcd_selftest_screen(TestScreen::Home, 0, 2, true, 0);
bool bres = tmc2130_home_calibrate(X_AXIS);
@ -7392,7 +7400,7 @@ bool lcd_selftest()
static void reset_crash_det(unsigned char axis) {
current_position[axis] += 10;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
plan_buffer_line_curposXYZE(manual_feedrate[0] / 60, active_extruder);
st_synchronize();
if (eeprom_read_byte((uint8_t*)EEPROM_CRASH_DET)) tmc2130_sg_stop_on_crash = true;
}
@ -7416,7 +7424,7 @@ static bool lcd_selfcheck_axis_sg(unsigned char axis) {
if (axis == X_AXIS) { //there is collision between cables and PSU cover in X axis if Z coordinate is too low
current_position[Z_AXIS] += 17;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
plan_buffer_line_curposXYZE(manual_feedrate[0] / 60, active_extruder);
tmc2130_home_enter(Z_AXIS_MASK);
st_synchronize();
tmc2130_home_exit();
@ -7425,7 +7433,7 @@ static bool lcd_selfcheck_axis_sg(unsigned char axis) {
// first axis length measurement begin
current_position[axis] -= (axis_length + margin);
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
plan_buffer_line_curposXYZE(manual_feedrate[0] / 60, active_extruder);
st_synchronize();
@ -7435,11 +7443,11 @@ static bool lcd_selfcheck_axis_sg(unsigned char axis) {
current_position_init = st_get_position_mm(axis);
current_position[axis] += 2 * margin;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
plan_buffer_line_curposXYZE(manual_feedrate[0] / 60, active_extruder);
st_synchronize();
current_position[axis] += axis_length;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
plan_buffer_line_curposXYZE(manual_feedrate[0] / 60, active_extruder);
st_synchronize();
@ -7455,11 +7463,11 @@ static bool lcd_selfcheck_axis_sg(unsigned char axis) {
current_position[axis] -= margin;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
plan_buffer_line_curposXYZE(manual_feedrate[0] / 60, active_extruder);
st_synchronize();
current_position[axis] -= (axis_length + margin);
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
plan_buffer_line_curposXYZE(manual_feedrate[0] / 60, active_extruder);
st_synchronize();
@ -7528,13 +7536,13 @@ static bool lcd_selfcheck_axis(int _axis, int _travel)
if (_axis == X_AXIS) {
current_position[Z_AXIS] += 17;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
plan_buffer_line_curposXYZE(manual_feedrate[0] / 60, active_extruder);
}
do {
current_position[_axis] = current_position[_axis] - 1;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
plan_buffer_line_curposXYZE(manual_feedrate[0] / 60, active_extruder);
st_synchronize();
#ifdef TMC2130
if ((READ(Z_MIN_PIN) ^ (bool)Z_MIN_ENDSTOP_INVERTING))
@ -7588,7 +7596,7 @@ static bool lcd_selfcheck_axis(int _axis, int _travel)
//current_position[_axis] = current_position[_axis] + 15;
//plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
//plan_buffer_line_curposXYZE(manual_feedrate[0] / 60, active_extruder);
if (!_stepresult)
{
@ -7636,17 +7644,17 @@ static bool lcd_selfcheck_pulleys(int axis)
current_position_init = current_position[axis];
current_position[axis] += 2;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
plan_buffer_line_curposXYZE(manual_feedrate[0] / 60, active_extruder);
for (i = 0; i < 5; i++) {
refresh_cmd_timeout();
current_position[axis] = current_position[axis] + move;
st_current_set(0, 850); //set motor current higher
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], 200, active_extruder);
plan_buffer_line_curposXYZE(200, active_extruder);
st_synchronize();
if (SilentModeMenu != SILENT_MODE_OFF) st_current_set(0, tmp_motor[0]); //set back to normal operation currents
else st_current_set(0, tmp_motor_loud[0]); //set motor current back
current_position[axis] = current_position[axis] - move;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], 50, active_extruder);
plan_buffer_line_curposXYZE(50, active_extruder);
st_synchronize();
if (((READ(X_MIN_PIN) ^ X_MIN_ENDSTOP_INVERTING) == 1) ||
((READ(Y_MIN_PIN) ^ Y_MIN_ENDSTOP_INVERTING) == 1)) {
@ -7663,7 +7671,7 @@ static bool lcd_selfcheck_pulleys(int axis)
endstop_triggered = true;
if (current_position_init - 1 <= current_position[axis] && current_position_init + 1 >= current_position[axis]) {
current_position[axis] += (axis == X_AXIS) ? 13 : 9;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
plan_buffer_line_curposXYZE(manual_feedrate[0] / 60, active_extruder);
st_synchronize();
return(true);
}
@ -7674,7 +7682,7 @@ static bool lcd_selfcheck_pulleys(int axis)
}
else {
current_position[axis] -= 1;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
plan_buffer_line_curposXYZE(manual_feedrate[0] / 60, active_extruder);
st_synchronize();
if (_millis() > timeout_counter) {
lcd_selftest_error(TestError::Pulley, (axis == 0) ? "X" : "Y", "");
@ -7698,7 +7706,7 @@ static bool lcd_selfcheck_endstops()
if ((READ(Y_MIN_PIN) ^ Y_MIN_ENDSTOP_INVERTING) == 1) current_position[1] += 10;
if ((READ(Z_MIN_PIN) ^ Z_MIN_ENDSTOP_INVERTING) == 1) current_position[2] += 10;
}
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[0] / 60, active_extruder);
plan_buffer_line_curposXYZE(manual_feedrate[0] / 60, active_extruder);
_delay(500);
if (((READ(X_MIN_PIN) ^ X_MIN_ENDSTOP_INVERTING) == 1) ||
@ -8631,3 +8639,27 @@ void menu_lcd_lcdupdate_func(void)
lcd_send_status();
if (lcd_commands_type == LcdCommands::Layer1Cal) lcd_commands();
}
#ifdef TMC2130
//! @brief Is crash detection enabled?
//!
//! @retval true crash detection enabled
//! @retval false crash detection disabled
bool lcd_crash_detect_enabled()
{
return eeprom_read_byte((uint8_t*)EEPROM_CRASH_DET);
}
void lcd_crash_detect_enable()
{
tmc2130_sg_stop_on_crash = true;
eeprom_update_byte((uint8_t*)EEPROM_CRASH_DET, 0xFF);
}
void lcd_crash_detect_disable()
{
tmc2130_sg_stop_on_crash = false;
tmc2130_sg_crash = 0;
eeprom_update_byte((uint8_t*)EEPROM_CRASH_DET, 0x00);
}
#endif

View File

@ -53,6 +53,11 @@ void lcd_menu_statistics();
void lcd_menu_extruder_info(); // NOT static due to using inside "Marlin_main" module ("manage_inactivity()")
void lcd_menu_show_sensors_state(); // NOT static due to using inside "Marlin_main" module ("manage_inactivity()")
#ifdef TMC2130
bool lcd_crash_detect_enabled();
void lcd_crash_detect_enable();
void lcd_crash_detect_disable();
#endif
extern const char* lcd_display_message_fullscreen_P(const char *msg, uint8_t &nlines);
extern const char* lcd_display_message_fullscreen_P(const char *msg);

View File

@ -324,7 +324,11 @@ PREHEAT SETTINGS
#define PLA_PREHEAT_HOTEND_TEMP 215
#define PLA_PREHEAT_HPB_TEMP 55
#define PLA_PREHEAT_FAN_SPEED 0
#define PLA_PREHEAT_FAN_SPEED 0
#define ASA_PREHEAT_HOTEND_TEMP 260
#define ASA_PREHEAT_HPB_TEMP 105
#define ASA_PREHEAT_FAN_SPEED 0
#define ABS_PREHEAT_HOTEND_TEMP 255
#define ABS_PREHEAT_HPB_TEMP 100

View File

@ -325,6 +325,10 @@ PREHEAT SETTINGS
#define PLA_PREHEAT_HPB_TEMP 55
#define PLA_PREHEAT_FAN_SPEED 0
#define ASA_PREHEAT_HOTEND_TEMP 260
#define ASA_PREHEAT_HPB_TEMP 105
#define ASA_PREHEAT_FAN_SPEED 0
#define ABS_PREHEAT_HOTEND_TEMP 255
#define ABS_PREHEAT_HPB_TEMP 100
#define ABS_PREHEAT_FAN_SPEED 0

View File

@ -383,6 +383,10 @@
#define PLA_PREHEAT_HPB_TEMP 60
#define PLA_PREHEAT_FAN_SPEED 0
#define ASA_PREHEAT_HOTEND_TEMP 260
#define ASA_PREHEAT_HPB_TEMP 105
#define ASA_PREHEAT_FAN_SPEED 0
#define ABS_PREHEAT_HOTEND_TEMP 255
#define ABS_PREHEAT_HPB_TEMP 100
#define ABS_PREHEAT_FAN_SPEED 0

View File

@ -384,6 +384,10 @@
#define PLA_PREHEAT_HPB_TEMP 60
#define PLA_PREHEAT_FAN_SPEED 0
#define ASA_PREHEAT_HOTEND_TEMP 260
#define ASA_PREHEAT_HPB_TEMP 105
#define ASA_PREHEAT_FAN_SPEED 0
#define ABS_PREHEAT_HOTEND_TEMP 255
#define ABS_PREHEAT_HPB_TEMP 100
#define ABS_PREHEAT_FAN_SPEED 0

View File

@ -383,6 +383,10 @@
#define PLA_PREHEAT_HPB_TEMP 60
#define PLA_PREHEAT_FAN_SPEED 0
#define ASA_PREHEAT_HOTEND_TEMP 260
#define ASA_PREHEAT_HPB_TEMP 105
#define ASA_PREHEAT_FAN_SPEED 0
#define ABS_PREHEAT_HOTEND_TEMP 255
#define ABS_PREHEAT_HPB_TEMP 100
#define ABS_PREHEAT_FAN_SPEED 0

View File

@ -384,6 +384,10 @@
#define PLA_PREHEAT_HPB_TEMP 60
#define PLA_PREHEAT_FAN_SPEED 0
#define ASA_PREHEAT_HOTEND_TEMP 260
#define ASA_PREHEAT_HPB_TEMP 105
#define ASA_PREHEAT_FAN_SPEED 0
#define ABS_PREHEAT_HOTEND_TEMP 255
#define ABS_PREHEAT_HPB_TEMP 100
#define ABS_PREHEAT_FAN_SPEED 0

View File

@ -493,6 +493,10 @@
#define PLA_PREHEAT_HPB_TEMP 60
#define PLA_PREHEAT_FAN_SPEED 0
#define ASA_PREHEAT_HOTEND_TEMP 260
#define ASA_PREHEAT_HPB_TEMP 105
#define ASA_PREHEAT_FAN_SPEED 0
#define ABS_PREHEAT_HOTEND_TEMP 255
#define ABS_PREHEAT_HPB_TEMP 100
#define ABS_PREHEAT_FAN_SPEED 0

View File

@ -495,6 +495,10 @@
#define PLA_PREHEAT_HPB_TEMP 60
#define PLA_PREHEAT_FAN_SPEED 0
#define ASA_PREHEAT_HOTEND_TEMP 260
#define ASA_PREHEAT_HPB_TEMP 105
#define ASA_PREHEAT_FAN_SPEED 0
#define ABS_PREHEAT_HOTEND_TEMP 255
#define ABS_PREHEAT_HPB_TEMP 100
#define ABS_PREHEAT_FAN_SPEED 0