Merge remote-tracking branch 'upstream/MK3' into M600_change_extruder

This commit is contained in:
PavelSindler 2018-08-28 23:53:35 +02:00
commit b9808354c4
4 changed files with 203 additions and 154 deletions

View file

@ -394,7 +394,6 @@ uint8_t check_printer_version();
float temp_compensation_pinda_thermistor_offset(float temperature_pinda); float temp_compensation_pinda_thermistor_offset(float temperature_pinda);
#endif //PINDA_THERMISTOR #endif //PINDA_THERMISTOR
void wait_for_heater(long codenum);
void serialecho_temperatures(); void serialecho_temperatures();
bool check_commands(); bool check_commands();

View file

@ -543,8 +543,9 @@ static bool saved_extruder_relative_mode = false;
//=========================================================================== //===========================================================================
static void get_arc_coordinates(); static void get_arc_coordinates();
static bool setTargetedHotend(int code); static bool setTargetedHotend(int code, uint8_t &extruder);
static void print_time_remaining_init(); static void print_time_remaining_init();
static void wait_for_heater(long codenum, uint8_t extruder);
uint16_t gcode_in_progress = 0; uint16_t gcode_in_progress = 0;
uint16_t mcode_in_progress = 0; uint16_t mcode_in_progress = 0;
@ -1355,6 +1356,7 @@ void setup()
plan_init(); // Initialize planner; plan_init(); // Initialize planner;
factory_reset(); factory_reset();
lcd_encoder_diff=0;
#ifdef TMC2130 #ifdef TMC2130
uint8_t silentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT); uint8_t silentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
@ -5353,15 +5355,18 @@ Sigma_Exit:
break; break;
case 104: // M104 case 104: // M104
if(setTargetedHotend(104)){ {
uint8_t extruder;
if(setTargetedHotend(104,extruder)){
break; break;
} }
if (code_seen('S')) if (code_seen('S'))
{ {
setTargetHotendSafe(code_value(), tmp_extruder); setTargetHotendSafe(code_value(), extruder);
} }
setWatch(); setWatch();
break; break;
}
case 112: // M112 -Emergency Stop case 112: // M112 -Emergency Stop
kill(_n(""), 3); kill(_n(""), 3);
break; break;
@ -5369,14 +5374,16 @@ Sigma_Exit:
if (code_seen('S')) setTargetBed(code_value()); if (code_seen('S')) setTargetBed(code_value());
break; break;
case 105 : // M105 case 105 : // M105
if(setTargetedHotend(105)){ {
uint8_t extruder;
if(setTargetedHotend(105, extruder)){
break; break;
} }
#if defined(TEMP_0_PIN) && TEMP_0_PIN > -1 #if defined(TEMP_0_PIN) && TEMP_0_PIN > -1
SERIAL_PROTOCOLPGM("ok T:"); SERIAL_PROTOCOLPGM("ok T:");
SERIAL_PROTOCOL_F(degHotend(tmp_extruder),1); SERIAL_PROTOCOL_F(degHotend(extruder),1);
SERIAL_PROTOCOLPGM(" /"); SERIAL_PROTOCOLPGM(" /");
SERIAL_PROTOCOL_F(degTargetHotend(tmp_extruder),1); SERIAL_PROTOCOL_F(degTargetHotend(extruder),1);
#if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1 #if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1
SERIAL_PROTOCOLPGM(" B:"); SERIAL_PROTOCOLPGM(" B:");
SERIAL_PROTOCOL_F(degBed(),1); SERIAL_PROTOCOL_F(degBed(),1);
@ -5401,7 +5408,7 @@ Sigma_Exit:
SERIAL_PROTOCOL((EXTRUDER_WATTS * getHeaterPower(tmp_extruder))/127); SERIAL_PROTOCOL((EXTRUDER_WATTS * getHeaterPower(tmp_extruder))/127);
SERIAL_PROTOCOLPGM("W"); SERIAL_PROTOCOLPGM("W");
#else #else
SERIAL_PROTOCOL(getHeaterPower(tmp_extruder)); SERIAL_PROTOCOL(getHeaterPower(extruder));
#endif #endif
SERIAL_PROTOCOLPGM(" B@:"); SERIAL_PROTOCOLPGM(" B@:");
@ -5459,9 +5466,11 @@ Sigma_Exit:
KEEPALIVE_STATE(NOT_BUSY); KEEPALIVE_STATE(NOT_BUSY);
return; return;
break; break;
}
case 109: case 109:
{// M109 - Wait for extruder heater to reach target. {// M109 - Wait for extruder heater to reach target.
if(setTargetedHotend(109)){ uint8_t extruder;
if(setTargetedHotend(109, extruder)){
break; break;
} }
LCD_MESSAGERPGM(_T(MSG_HEATING)); LCD_MESSAGERPGM(_T(MSG_HEATING));
@ -5472,10 +5481,10 @@ Sigma_Exit:
autotemp_enabled=false; autotemp_enabled=false;
#endif #endif
if (code_seen('S')) { if (code_seen('S')) {
setTargetHotendSafe(code_value(), tmp_extruder); setTargetHotendSafe(code_value(), extruder);
CooldownNoWait = true; CooldownNoWait = true;
} else if (code_seen('R')) { } else if (code_seen('R')) {
setTargetHotendSafe(code_value(), tmp_extruder); setTargetHotendSafe(code_value(), extruder);
CooldownNoWait = false; CooldownNoWait = false;
} }
#ifdef AUTOTEMP #ifdef AUTOTEMP
@ -5492,13 +5501,13 @@ Sigma_Exit:
codenum = millis(); codenum = millis();
/* See if we are heating up or cooling down */ /* See if we are heating up or cooling down */
target_direction = isHeatingHotend(tmp_extruder); // true if heating, false if cooling target_direction = isHeatingHotend(extruder); // true if heating, false if cooling
KEEPALIVE_STATE(NOT_BUSY); KEEPALIVE_STATE(NOT_BUSY);
cancel_heatup = false; cancel_heatup = false;
wait_for_heater(codenum); //loops until target temperature is reached wait_for_heater(codenum, extruder); //loops until target temperature is reached
LCD_MESSAGERPGM(_T(MSG_HEATING_COMPLETE)); LCD_MESSAGERPGM(_T(MSG_HEATING_COMPLETE));
KEEPALIVE_STATE(IN_HANDLER); KEEPALIVE_STATE(IN_HANDLER);
@ -5819,10 +5828,10 @@ Sigma_Exit:
case 200: // M200 D<millimeters> set filament diameter and set E axis units to cubic millimeters (use S0 to set back to millimeters). case 200: // M200 D<millimeters> set filament diameter and set E axis units to cubic millimeters (use S0 to set back to millimeters).
{ {
tmp_extruder = active_extruder; uint8_t extruder = active_extruder;
if(code_seen('T')) { if(code_seen('T')) {
tmp_extruder = code_value(); extruder = code_value();
if(tmp_extruder >= EXTRUDERS) { if(extruder >= EXTRUDERS) {
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHO(_i("M200 Invalid extruder "));////MSG_M200_INVALID_EXTRUDER c=0 r=0 SERIAL_ECHO(_i("M200 Invalid extruder "));////MSG_M200_INVALID_EXTRUDER c=0 r=0
break; break;
@ -5836,7 +5845,7 @@ Sigma_Exit:
// for all extruders // for all extruders
volumetric_enabled = false; volumetric_enabled = false;
} else { } else {
filament_size[tmp_extruder] = (float)code_value(); filament_size[extruder] = (float)code_value();
// make sure all extruders have some sane value for the filament size // make sure all extruders have some sane value for the filament size
filament_size[0] = (filament_size[0] == 0.0 ? DEFAULT_NOMINAL_FILAMENT_DIA : filament_size[0]); filament_size[0] = (filament_size[0] == 0.0 ? DEFAULT_NOMINAL_FILAMENT_DIA : filament_size[0]);
#if EXTRUDERS > 1 #if EXTRUDERS > 1
@ -6024,25 +6033,26 @@ Sigma_Exit:
#if EXTRUDERS > 1 #if EXTRUDERS > 1
case 218: // M218 - set hotend offset (in mm), T<extruder_number> X<offset_on_X> Y<offset_on_Y> case 218: // M218 - set hotend offset (in mm), T<extruder_number> X<offset_on_X> Y<offset_on_Y>
{ {
if(setTargetedHotend(218)){ uint8_t extruder;
if(setTargetedHotend(218, extruder)){
break; break;
} }
if(code_seen('X')) if(code_seen('X'))
{ {
extruder_offset[X_AXIS][tmp_extruder] = code_value(); extruder_offset[X_AXIS][extruder] = code_value();
} }
if(code_seen('Y')) if(code_seen('Y'))
{ {
extruder_offset[Y_AXIS][tmp_extruder] = code_value(); extruder_offset[Y_AXIS][extruder] = code_value();
} }
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHORPGM(MSG_HOTEND_OFFSET); SERIAL_ECHORPGM(MSG_HOTEND_OFFSET);
for(tmp_extruder = 0; tmp_extruder < EXTRUDERS; tmp_extruder++) for(extruder = 0; extruder < EXTRUDERS; extruder++)
{ {
SERIAL_ECHO(" "); SERIAL_ECHO(" ");
SERIAL_ECHO(extruder_offset[X_AXIS][tmp_extruder]); SERIAL_ECHO(extruder_offset[X_AXIS][extruder]);
SERIAL_ECHO(","); SERIAL_ECHO(",");
SERIAL_ECHO(extruder_offset[Y_AXIS][tmp_extruder]); SERIAL_ECHO(extruder_offset[Y_AXIS][extruder]);
} }
SERIAL_ECHOLN(""); SERIAL_ECHOLN("");
}break; }break;
@ -6062,10 +6072,11 @@ Sigma_Exit:
int tmp_code = code_value(); int tmp_code = code_value();
if (code_seen('T')) if (code_seen('T'))
{ {
if(setTargetedHotend(221)){ uint8_t extruder;
if(setTargetedHotend(221, extruder)){
break; break;
} }
extruder_multiply[tmp_extruder] = tmp_code; extruder_multiply[extruder] = tmp_code;
} }
else else
{ {
@ -6797,7 +6808,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
st_synchronize(); st_synchronize();
for (index = 1; *(strchr_pointer + index) == ' ' || *(strchr_pointer + index) == '\t'; index++); for (index = 1; *(strchr_pointer + index) == ' ' || *(strchr_pointer + index) == '\t'; index++);
if ((*(strchr_pointer + index) < '0' || *(strchr_pointer + index) > '9') && *(strchr_pointer + index) != '?') { if ((*(strchr_pointer + index) < '0' || *(strchr_pointer + index) > '4') && *(strchr_pointer + index) != '?') {
SERIAL_ECHOLNPGM("Invalid T code."); SERIAL_ECHOLNPGM("Invalid T code.");
} }
else { else {
@ -6811,8 +6822,6 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
if (mmu_enabled) if (mmu_enabled)
{ {
//printf_P(PSTR("T code: %d \n"), tmp_extruder);
//mmu_printf_P(PSTR("T%d\n"), tmp_extruder);
mmu_command(MMU_CMD_T0 + tmp_extruder); mmu_command(MMU_CMD_T0 + tmp_extruder);
manage_response(true, true); manage_response(true, true);
@ -6820,8 +6829,10 @@ if (mmu_enabled)
mmu_extruder = tmp_extruder; //filament change is finished mmu_extruder = tmp_extruder; //filament change is finished
if (*(strchr_pointer + index) == '?')// for single material usage with mmu if (*(strchr_pointer + index) == '?')// for single material usage with mmu
{
mmu_load_to_nozzle(); mmu_load_to_nozzle();
} }
}
else else
{ {
#ifdef SNMM #ifdef SNMM
@ -7571,11 +7582,21 @@ void setPwmFrequency(uint8_t pin, int val)
} }
#endif //FAST_PWM_FAN #endif //FAST_PWM_FAN
bool setTargetedHotend(int code){ //! @brief Get and validate extruder number
tmp_extruder = active_extruder; //!
//! If it is not specified, active_extruder is returned in parameter extruder.
//! @param [in] code M code number
//! @param [out] extruder
//! @return error
//! @retval true Invalid extruder specified in T code
//! @retval false Valid extruder specified in T code, or not specifiead
bool setTargetedHotend(int code, uint8_t &extruder)
{
extruder = active_extruder;
if(code_seen('T')) { if(code_seen('T')) {
tmp_extruder = code_value(); extruder = code_value();
if(tmp_extruder >= EXTRUDERS) { if(extruder >= EXTRUDERS) {
SERIAL_ECHO_START; SERIAL_ECHO_START;
switch(code){ switch(code){
case 104: case 104:
@ -7594,7 +7615,7 @@ bool setTargetedHotend(int code){
SERIAL_ECHO(_i("M221 Invalid extruder "));////MSG_M221_INVALID_EXTRUDER c=0 r=0 SERIAL_ECHO(_i("M221 Invalid extruder "));////MSG_M221_INVALID_EXTRUDER c=0 r=0
break; break;
} }
SERIAL_PROTOCOLLN((int)tmp_extruder); SERIAL_PROTOCOLLN((int)extruder);
return true; return true;
} }
} }
@ -7659,7 +7680,7 @@ void delay_keep_alive(unsigned int ms)
} }
} }
void wait_for_heater(long codenum) { static void wait_for_heater(long codenum, uint8_t extruder) {
#ifdef TEMP_RESIDENCY_TIME #ifdef TEMP_RESIDENCY_TIME
long residencyStart; long residencyStart;
@ -7675,9 +7696,9 @@ void wait_for_heater(long codenum) {
{ //Print Temp Reading and remaining time every 1 second while heating up/cooling down { //Print Temp Reading and remaining time every 1 second while heating up/cooling down
if (!farm_mode) { if (!farm_mode) {
SERIAL_PROTOCOLPGM("T:"); SERIAL_PROTOCOLPGM("T:");
SERIAL_PROTOCOL_F(degHotend(tmp_extruder), 1); SERIAL_PROTOCOL_F(degHotend(extruder), 1);
SERIAL_PROTOCOLPGM(" E:"); SERIAL_PROTOCOLPGM(" E:");
SERIAL_PROTOCOL((int)tmp_extruder); SERIAL_PROTOCOL((int)extruder);
#ifdef TEMP_RESIDENCY_TIME #ifdef TEMP_RESIDENCY_TIME
SERIAL_PROTOCOLPGM(" W:"); SERIAL_PROTOCOLPGM(" W:");
@ -7702,9 +7723,9 @@ void wait_for_heater(long codenum) {
#ifdef TEMP_RESIDENCY_TIME #ifdef TEMP_RESIDENCY_TIME
/* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time /* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
or when current temp falls outside the hysteresis after target temp was reached */ or when current temp falls outside the hysteresis after target temp was reached */
if ((residencyStart == -1 && target_direction && (degHotend(tmp_extruder) >= (degTargetHotend(tmp_extruder) - TEMP_WINDOW))) || if ((residencyStart == -1 && target_direction && (degHotend(extruder) >= (degTargetHotend(extruder) - TEMP_WINDOW))) ||
(residencyStart == -1 && !target_direction && (degHotend(tmp_extruder) <= (degTargetHotend(tmp_extruder) + TEMP_WINDOW))) || (residencyStart == -1 && !target_direction && (degHotend(extruder) <= (degTargetHotend(extruder) + TEMP_WINDOW))) ||
(residencyStart > -1 && labs(degHotend(tmp_extruder) - degTargetHotend(tmp_extruder)) > TEMP_HYSTERESIS)) (residencyStart > -1 && labs(degHotend(extruder) - degTargetHotend(extruder)) > TEMP_HYSTERESIS))
{ {
residencyStart = millis(); residencyStart = millis();
} }

View file

@ -394,6 +394,12 @@ void manage_response(bool move_axes, bool turn_off_nozzle)
if (lcd_update_was_enabled) lcd_update_enable(true); if (lcd_update_was_enabled) lcd_update_enable(true);
} }
//! @brief load filament to nozzle of multimaterial printer
//!
//! This function is used only only after T? (user select filament) and M600 (change filament).
//! It is not used after T0 .. T4 command (select filament), in such case, gcode is responsible for loading
//! filament to nozzle.
//!
void mmu_load_to_nozzle() void mmu_load_to_nozzle()
{ {
st_synchronize(); st_synchronize();

View file

@ -3555,6 +3555,27 @@ void lcd_diag_show_end_stops()
lcd_return_to_status(); lcd_return_to_status();
} }
#ifdef TMC2130
static void lcd_show_pinda_state()
{
lcd_set_cursor(0, 0);
lcd_puts_P((PSTR("P.I.N.D.A. state")));
lcd_set_cursor(0, 2);
lcd_puts_P(READ(Z_MIN_PIN)?(PSTR("Z1 (LED off)")):(PSTR("Z0 (LED on) "))); // !!! both strings must have same length (due to dynamic refreshing)
}
static void menu_show_pinda_state()
{
lcd_timeoutToStatus.stop();
lcd_show_pinda_state();
if(LCD_CLICKED)
{
lcd_timeoutToStatus.start();
menu_back();
}
}
#endif // defined TMC2130
void prusa_statistics(int _message, uint8_t _fil_nr) { void prusa_statistics(int _message, uint8_t _fil_nr) {
@ -4792,7 +4813,9 @@ static void lcd_calibration_menu()
MENU_ITEM_SUBMENU_P(_i("Bed level correct"), lcd_adjust_bed);////MSG_BED_CORRECTION_MENU c=0 r=0 MENU_ITEM_SUBMENU_P(_i("Bed level correct"), lcd_adjust_bed);////MSG_BED_CORRECTION_MENU c=0 r=0
MENU_ITEM_SUBMENU_P(_i("PID calibration"), pid_extruder);////MSG_PID_EXTRUDER c=17 r=1 MENU_ITEM_SUBMENU_P(_i("PID calibration"), pid_extruder);////MSG_PID_EXTRUDER c=17 r=1
#ifndef TMC2130 #ifdef TMC2130
MENU_ITEM_SUBMENU_P(_i("Show pinda state"), menu_show_pinda_state);
#else
MENU_ITEM_SUBMENU_P(_i("Show end stops"), menu_show_end_stops);////MSG_SHOW_END_STOPS c=17 r=1 MENU_ITEM_SUBMENU_P(_i("Show end stops"), menu_show_end_stops);////MSG_SHOW_END_STOPS c=17 r=1
#endif #endif
#ifndef MK1BP #ifndef MK1BP