diff --git a/Firmware/configuration_prusa.h.orig b/Firmware/configuration_prusa.h.orig deleted file mode 100644 index f47a17dc1..000000000 --- a/Firmware/configuration_prusa.h.orig +++ /dev/null @@ -1,623 +0,0 @@ -#ifndef CONFIGURATION_PRUSA_H -#define CONFIGURATION_PRUSA_H - -/*------------------------------------ - GENERAL SETTINGS - *------------------------------------*/ - -// Printer revision -#define PRINTER_TYPE PRINTER_MK3 -#define FILAMENT_SIZE "1_75mm_MK3" -#define NOZZLE_TYPE "E3Dv6full" - -// Developer flag -#define DEVELOPER - -// Printer name -#define CUSTOM_MENDEL_NAME "Prusa i3 MK3" - -// Electronics -#define MOTHERBOARD BOARD_EINSY_1_0a -#define STEEL_SHEET -#define HAS_SECOND_SERIAL_PORT - - -// Uncomment the below for the E3D PT100 temperature sensor (with or without PT100 Amplifier) -//#define E3D_PT100_EXTRUDER_WITH_AMP -//#define E3D_PT100_EXTRUDER_NO_AMP -//#define E3D_PT100_BED_WITH_AMP -//#define E3D_PT100_BED_NO_AMP - - -/*------------------------------------ - AXIS SETTINGS - *------------------------------------*/ - -// Steps per unit {X,Y,Z,E} -//#define DEFAULT_AXIS_STEPS_PER_UNIT {100,100,3200/8,140} -#define DEFAULT_AXIS_STEPS_PER_UNIT {100,100,3200/8,280} -//#define DEFAULT_AXIS_STEPS_PER_UNIT {100,100,3200/8,560} - -// Endstop inverting -#define X_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop. -#define Y_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop. -#define Z_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop. - -// Direction inverting -#define INVERT_X_DIR 1 // for Mendel set to 0, for Orca set to 1 -#define INVERT_Y_DIR 0 // for Mendel set to 1, for Orca set to 0 -#define INVERT_Z_DIR 1 // for Mendel set to 0, for Orca set to 1 -#define INVERT_E0_DIR 0 // for direct drive extruder v9 set to 1, for geared extruder set to 0 -#define INVERT_E1_DIR 0 // for direct drive extruder v9 set to 1, for geared extruder set to 0 -#define INVERT_E2_DIR 0 // for direct drive extruder v9 set to 1, for geared extruder set to 0 - -// Home position -#define MANUAL_X_HOME_POS 0 -#define MANUAL_Y_HOME_POS -2.2 -#define MANUAL_Z_HOME_POS 0.2 - -// Travel limits after homing -#define X_MAX_POS 255 -#define X_MIN_POS 0 -#define Y_MAX_POS 212.5 -#define Y_MIN_POS -4 //orig -4 -#define Z_MAX_POS 210 -#define Z_MIN_POS 0.15 - -// Canceled home position -#define X_CANCEL_POS 50 -#define Y_CANCEL_POS 190 - -//Pause print position -#define X_PAUSE_POS 50 -#define Y_PAUSE_POS 190 -#define Z_PAUSE_LIFT 20 - -#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E -#define HOMING_FEEDRATE {3000, 3000, 800, 0} // set the homing speeds (mm/min) // 3000 is also valid for stallGuard homing. Valid range: 2200 - 3000 - -//#define DEFAULT_Y_OFFSET 4.f // Default distance of Y_MIN_POS point from endstop, when the printer is not calibrated. -/** - * [0,0] steel sheet print area point X coordinate in bed print area coordinates - */ -#define SHEET_PRINT_ZERO_REF_X 0.f -/** - * [0,0] steel sheet print area point Y coordinate in bed print area coordinates - */ -#define SHEET_PRINT_ZERO_REF_Y -2.f - -#define DEFAULT_MAX_FEEDRATE {200, 200, 12, 120} // (mm/sec) max feedrate (M203) -#define DEFAULT_MAX_FEEDRATE_SILENT {100, 100, 12, 120} // (mm/sec) max feedrate (M203), silent mode - -#define DEFAULT_MAX_ACCELERATION {1000, 1000, 200, 5000} // (mm/sec^2) max acceleration (M201) -#define DEFAULT_MAX_ACCELERATION_SILENT {960, 960, 200, 5000} // (mm/sec^2) max acceleration (M201), silent mode - - -#define DEFAULT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for printing moves (M204S) -#define DEFAULT_RETRACT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for retracts (M204T) - -#define MANUAL_FEEDRATE {2700, 2700, 1000, 100} // set the speeds for manual moves (mm/min) - -//Silent mode limits -#define SILENT_MAX_ACCEL_XY 960ul // max acceleration in silent mode in mm/s^2 -#define SILENT_MAX_FEEDRATE_XY 100 // max feedrate in mm/s - -//Normal mode limits -#define NORMAL_MAX_ACCEL_XY 2500ul // max acceleration in normal mode in mm/s^2 -#define NORMAL_MAX_FEEDRATE_XY 200 // max feedrate in mm/s - -//number of bytes from end of the file to start check -#define END_FILE_SECTION 20000 - -#define Z_AXIS_ALWAYS_ON 1 - -//Crash detection -#define CRASHDET_TIMER 45 //seconds -#define CRASHDET_COUNTER_MAX 3 - -// New XYZ calibration -#define NEW_XYZCAL - -// Watchdog support -#define WATCHDOG - -// Power panic -#define UVLO_SUPPORT - -// Fan check -#define FANCHECK - -// Safety timer -#define SAFETYTIMER -#define DEFAULT_SAFETYTIMER_TIME_MINS 30 - -// Filament sensor -#define PAT9125 -#define FILAMENT_SENSOR - -// Backlash - -//#define BACKLASH_X -//#define BACKLASH_Y - - -// Minimum ambient temperature limit to start triggering MINTEMP errors [C] -// this value is litlebit higher that real limit, because ambient termistor is on the board and is temperated from it, -// temperature inside the case is around 31C for ambient temperature 25C, when the printer is powered on long time and idle -// the real limit is 15C (same as MINTEMP limit), this is because 15C is end of scale for both used thermistors (bed, heater) -#define MINTEMP_MINAMBIENT 25 -#define MINTEMP_MINAMBIENT_RAW 978 - -#define DEBUG_DCODE3 - -//#define DEBUG_BUILD -//#define DEBUG_SEC_LANG //secondary language debug output at startup -//#define DEBUG_W25X20CL //debug external spi flash -#ifdef DEBUG_BUILD -//#define _NO_ASM -#define DEBUG_DCODES //D codes -#define DEBUG_STACK_MONITOR //Stack monitor in stepper ISR -//#define DEBUG_FSENSOR_LOG //Reports fsensor status to serial -//#define DEBUG_CRASHDET_COUNTERS //Display crash-detection counters on LCD -//#define DEBUG_RESUME_PRINT //Resume/save print debug enable -//#define DEBUG_UVLO_AUTOMATIC_RECOVER // Power panic automatic recovery debug output -//#define DEBUG_DISABLE_XMINLIMIT //x min limit ignored -//#define DEBUG_DISABLE_XMAXLIMIT //x max limit ignored -//#define DEBUG_DISABLE_YMINLIMIT //y min limit ignored -//#define DEBUG_DISABLE_YMAXLIMIT //y max limit ignored -//#define DEBUG_DISABLE_ZMINLIMIT //z min limit ignored -//#define DEBUG_DISABLE_ZMAXLIMIT //z max limit ignored -#define DEBUG_DISABLE_STARTMSGS //no startup messages -//#define DEBUG_DISABLE_MINTEMP //mintemp error ignored -//#define DEBUG_DISABLE_SWLIMITS //sw limits ignored -//#define DEBUG_DISABLE_LCD_STATUS_LINE //empty four lcd line -//#define DEBUG_DISABLE_PREVENT_EXTRUDER //cold extrusion and long extrusion allowed -//#define DEBUG_DISABLE_PRUSA_STATISTICS //disable prusa_statistics() mesages -//#define DEBUG_DISABLE_FORCE_SELFTEST //disable force selftest -//#define DEBUG_XSTEP_DUP_PIN 21 //duplicate x-step output to pin 21 (SCL on P3) -//#define DEBUG_YSTEP_DUP_PIN 21 //duplicate y-step output to pin 21 (SCL on P3) -//#define DEBUG_DISABLE_FANCHECK //disable fan check (no ISR INT7, check disabled) -//#define DEBUG_DISABLE_FSENSORCHECK //disable fsensor check (no ISR INT7, check disabled) -#define DEBUG_DUMP_TO_2ND_SERIAL //dump received characters to 2nd serial line -#define DEBUG_STEPPER_TIMER_MISSED // Stop on stepper timer overflow, beep and display a message. -#define PLANNER_DIAGNOSTICS // Show the planner queue status on printer display. -#define CMD_DIAGNOSTICS //Show cmd queue length on printer display -#endif /* DEBUG_BUILD */ - -#define FSENSOR_QUALITY - - -#define LINEARITY_CORRECTION -#define TMC2130_LINEARITY_CORRECTION -#define TMC2130_LINEARITY_CORRECTION_XYZ -//#define TMC2130_VARIABLE_RESOLUTION - - - -/*------------------------------------ - TMC2130 default settings - *------------------------------------*/ - -#define TMC2130_FCLK 12000000 // fclk = 12MHz - -#define TMC2130_USTEPS_XY 16 // microstep resolution for XY axes -#define TMC2130_USTEPS_Z 16 // microstep resolution for Z axis -#define TMC2130_USTEPS_E 32 // microstep resolution for E axis -#define TMC2130_INTPOL_XY 1 // extrapolate 256 for XY axes -#define TMC2130_INTPOL_Z 1 // extrapolate 256 for Z axis -#define TMC2130_INTPOL_E 1 // extrapolate 256 for E axis - -#define TMC2130_PWM_GRAD_X 2 // PWMCONF -#define TMC2130_PWM_AMPL_X 230 // PWMCONF -#define TMC2130_PWM_AUTO_X 1 // PWMCONF -#define TMC2130_PWM_FREQ_X 2 // PWMCONF - -#define TMC2130_PWM_GRAD_Y 2 // PWMCONF -#define TMC2130_PWM_AMPL_Y 235 // PWMCONF -#define TMC2130_PWM_AUTO_Y 1 // PWMCONF -#define TMC2130_PWM_FREQ_Y 2 // PWMCONF - -#define TMC2130_PWM_GRAD_Z 4 // PWMCONF -#define TMC2130_PWM_AMPL_Z 200 // PWMCONF -#define TMC2130_PWM_AUTO_Z 1 // PWMCONF -#define TMC2130_PWM_FREQ_Z 2 // PWMCONF - -#define TMC2130_PWM_GRAD_E 4 // PWMCONF -#define TMC2130_PWM_AMPL_E 240 // PWMCONF -#define TMC2130_PWM_AUTO_E 1 // PWMCONF -#define TMC2130_PWM_FREQ_E 2 // PWMCONF - -#define TMC2130_TOFF_XYZ 3 // CHOPCONF // fchop = 27.778kHz -#define TMC2130_TOFF_E 3 // CHOPCONF // fchop = 27.778kHz -//#define TMC2130_TOFF_E 4 // CHOPCONF // fchop = 21.429kHz -//#define TMC2130_TOFF_E 5 // CHOPCONF // fchop = 17.442kHz - -//#define TMC2130_STEALTH_E // Extruder stealthChop mode -//#define TMC2130_CNSTOFF_E // Extruder constant-off-time mode (similar to MK2) - -//#define TMC2130_PWM_DIV 683 // PWM frequency divider (1024, 683, 512, 410) -#define TMC2130_PWM_DIV 512 // PWM frequency divider (1024, 683, 512, 410) -#define TMC2130_PWM_CLK (2 * TMC2130_FCLK / TMC2130_PWM_DIV) // PWM frequency (23.4kHz, 35.1kHz, 46.9kHz, 58.5kHz for 12MHz fclk) - -#define TMC2130_TPWMTHRS 0 // TPWMTHRS - Sets the switching speed threshold based on TSTEP from stealthChop to spreadCycle mode -#define TMC2130_THIGH 0 // THIGH - unused - -//#define TMC2130_TCOOLTHRS_X 450 // TCOOLTHRS - coolstep treshold -//#define TMC2130_TCOOLTHRS_Y 450 // TCOOLTHRS - coolstep treshold -#define TMC2130_TCOOLTHRS_X 430 // TCOOLTHRS - coolstep treshold -#define TMC2130_TCOOLTHRS_Y 430 // TCOOLTHRS - coolstep treshold -#define TMC2130_TCOOLTHRS_Z 500 // TCOOLTHRS - coolstep treshold -#define TMC2130_TCOOLTHRS_E 500 // TCOOLTHRS - coolstep treshold - -#define TMC2130_SG_HOMING 1 // stallguard homing -#define TMC2130_SG_THRS_X 3 // stallguard sensitivity for X axis -#define TMC2130_SG_THRS_Y 3 // stallguard sensitivity for Y axis -#define TMC2130_SG_THRS_Z 4 // stallguard sensitivity for Z axis -#define TMC2130_SG_THRS_E 3 // stallguard sensitivity for E axis - -//new settings is possible for vsense = 1, running current value > 31 set vsense to zero and shift both currents by 1 bit right (Z axis only) -#define TMC2130_CURRENTS_H {16, 20, 35, 30} // default holding currents for all axes -#define TMC2130_CURRENTS_R {16, 20, 35, 30} // default running currents for all axes -#define TMC2130_UNLOAD_CURRENT_R 12 // lowe current for M600 to protect filament sensor - -#define TMC2130_STEALTH_Z - -//#define TMC2130_DEBUG -//#define TMC2130_DEBUG_WR -//#define TMC2130_DEBUG_RD - - -/*------------------------------------ - EXTRUDER SETTINGS - *------------------------------------*/ - -// Mintemps -#define HEATER_0_MINTEMP 15 -#define HEATER_1_MINTEMP 5 -#define HEATER_2_MINTEMP 5 -#define BED_MINTEMP 15 - -// Maxtemps -#if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP) -#define HEATER_0_MAXTEMP 410 -#else -#define HEATER_0_MAXTEMP 305 -#endif -#define HEATER_1_MAXTEMP 305 -#define HEATER_2_MAXTEMP 305 -#define BED_MAXTEMP 125 - -#if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP) -// Define PID constants for extruder with PT100 -#define DEFAULT_Kp 21.70 -#define DEFAULT_Ki 1.60 -#define DEFAULT_Kd 73.76 -#else -// Define PID constants for extruder -//#define DEFAULT_Kp 40.925 -//#define DEFAULT_Ki 4.875 -//#define DEFAULT_Kd 86.085 -#define DEFAULT_Kp 16.13 -#define DEFAULT_Ki 1.1625 -#define DEFAULT_Kd 56.23 -#endif - -// Extrude mintemp -#define EXTRUDE_MINTEMP 175 - -// Extruder cooling fans -#define EXTRUDER_0_AUTO_FAN_PIN 8 -#define EXTRUDER_1_AUTO_FAN_PIN -1 -#define EXTRUDER_2_AUTO_FAN_PIN -1 -#define EXTRUDER_AUTO_FAN_TEMPERATURE 50 -#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed - - - -/*------------------------------------ - LOAD/UNLOAD FILAMENT SETTINGS - *------------------------------------*/ - -// Load filament commands -#define LOAD_FILAMENT_0 "M83" -#define LOAD_FILAMENT_1 "G1 E70 F400" -#define LOAD_FILAMENT_2 "G1 E40 F100" - -// Unload filament commands -#define UNLOAD_FILAMENT_0 "M83" -#define UNLOAD_FILAMENT_1 "G1 E-80 F7000" - -/*------------------------------------ - CHANGE FILAMENT SETTINGS - *------------------------------------*/ - -// Filament change configuration -#define FILAMENTCHANGEENABLE -#ifdef FILAMENTCHANGEENABLE -#define FILAMENTCHANGE_XPOS 211 -#define FILAMENTCHANGE_YPOS 0 -#define FILAMENTCHANGE_ZADD 2 -#define FILAMENTCHANGE_FIRSTRETRACT -2 -#define FILAMENTCHANGE_FINALRETRACT -80 - -#define FILAMENTCHANGE_FIRSTFEED 70 -#define FILAMENTCHANGE_FINALFEED 50 -#define FILAMENTCHANGE_RECFEED 5 - -#define FILAMENTCHANGE_XYFEED 50 -#define FILAMENTCHANGE_EFEED 20 -//#define FILAMENTCHANGE_RFEED 400 -#define FILAMENTCHANGE_RFEED 7000 / 60 -#define FILAMENTCHANGE_EXFEED 2 -#define FILAMENTCHANGE_ZFEED 15 - -#endif - -/*------------------------------------ - ADDITIONAL FEATURES SETTINGS - *------------------------------------*/ - -// Define Prusa filament runout sensor -//#define FILAMENT_RUNOUT_SUPPORT - -#ifdef FILAMENT_RUNOUT_SUPPORT -#define FILAMENT_RUNOUT_SENSOR 1 -#endif - -// temperature runaway -#define TEMP_RUNAWAY_BED_HYSTERESIS 5 -#define TEMP_RUNAWAY_BED_TIMEOUT 360 - -#define TEMP_RUNAWAY_EXTRUDER_HYSTERESIS 15 -#define TEMP_RUNAWAY_EXTRUDER_TIMEOUT 45 - -/*------------------------------------ - MOTOR CURRENT SETTINGS - *------------------------------------*/ - -// Motor Current setting for BIG RAMBo -#define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A) -#define DIGIPOT_MOTOR_CURRENT_LOUD {135,135,135,135,135} - -// Motor Current settings for RAMBo mini PWM value = MotorCurrentSetting * 255 / range -#if MOTHERBOARD == BOARD_RAMBO_MINI_1_0 || MOTHERBOARD == BOARD_RAMBO_MINI_1_3 -#define MOTOR_CURRENT_PWM_RANGE 2000 -#define DEFAULT_PWM_MOTOR_CURRENT {400, 750, 750} // {XY,Z,E} -#define DEFAULT_PWM_MOTOR_CURRENT_LOUD {400, 750, 750} // {XY,Z,E} -#endif - -/*------------------------------------ - BED SETTINGS - *------------------------------------*/ - -// Define Mesh Bed Leveling system to enable it -#define MESH_BED_LEVELING -#ifdef MESH_BED_LEVELING - -#define MBL_Z_STEP 0.01 - -// Mesh definitions -#define MESH_MIN_X 35 -#define MESH_MAX_X 238 -#define MESH_MIN_Y 6 -#define MESH_MAX_Y 202 - -// Mesh upsample definition -#define MESH_NUM_X_POINTS 7 -#define MESH_NUM_Y_POINTS 7 -// Mesh measure definition -#define MESH_MEAS_NUM_X_POINTS 3 -#define MESH_MEAS_NUM_Y_POINTS 3 - -#define MESH_HOME_Z_CALIB 0.2 -#define MESH_HOME_Z_SEARCH 5 //Z lift for homing, mesh bed leveling etc. - -#define X_PROBE_OFFSET_FROM_EXTRUDER 23 // Z probe to nozzle X offset: -left +right -#define Y_PROBE_OFFSET_FROM_EXTRUDER 5 // Z probe to nozzle Y offset: -front +behind -#define Z_PROBE_OFFSET_FROM_EXTRUDER -0.4 // Z probe to nozzle Z offset: -below (always!) -#endif - -// Bed Temperature Control -// Select PID or bang-bang with PIDTEMPBED. If bang-bang, BED_LIMIT_SWITCHING will enable hysteresis -// -// Uncomment this to enable PID on the bed. It uses the same frequency PWM as the extruder. -// If your PID_dT above is the default, and correct for your hardware/configuration, that means 7.689Hz, -// which is fine for driving a square wave into a resistive load and does not significantly impact you FET heating. -// This also works fine on a Fotek SSR-10DA Solid State Relay into a 250W heater. -// If your configuration is significantly different than this and you don't understand the issues involved, you probably -// shouldn't use bed PID until someone else verifies your hardware works. -// If this is enabled, find your own PID constants below. -#define PIDTEMPBED -// -//#define BED_LIMIT_SWITCHING - -// This sets the max power delivered to the bed, and replaces the HEATER_BED_DUTY_CYCLE_DIVIDER option. -// all forms of bed control obey this (PID, bang-bang, bang-bang with hysteresis) -// setting this to anything other than 255 enables a form of PWM to the bed just like HEATER_BED_DUTY_CYCLE_DIVIDER did, -// so you shouldn't use it unless you are OK with PWM on your bed. (see the comment on enabling PIDTEMPBED) -#define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current - -// Bed temperature compensation settings -#define BED_OFFSET 10 -#define BED_OFFSET_START 40 -#define BED_OFFSET_CENTER 50 - - -#ifdef PIDTEMPBED -//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) -//from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10) -#if defined(E3D_PT100_BED_WITH_AMP) || defined(E3D_PT100_BED_NO_AMP) -// Define PID constants for extruder with PT100 -#define DEFAULT_bedKp 21.70 -#define DEFAULT_bedKi 1.60 -#define DEFAULT_bedKd 73.76 -#else -#define DEFAULT_bedKp 126.13 -#define DEFAULT_bedKi 4.30 -#define DEFAULT_bedKd 924.76 -#endif - -//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) -//from pidautotune -// #define DEFAULT_bedKp 97.1 -// #define DEFAULT_bedKi 1.41 -// #define DEFAULT_bedKd 1675.16 - -// FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles. -#endif // PIDTEMPBED - -//connect message when communication with monitoring broken -//#define FARM_CONNECT_MESSAGE - -/*----------------------------------- - PREHEAT SETTINGS - *------------------------------------*/ - -#define FARM_PREHEAT_HOTEND_TEMP 250 -#define FARM_PREHEAT_HPB_TEMP 60 -#define FARM_PREHEAT_FAN_SPEED 0 - -#define PLA_PREHEAT_HOTEND_TEMP 215 -#define PLA_PREHEAT_HPB_TEMP 60 -#define PLA_PREHEAT_FAN_SPEED 0 - -#define ABS_PREHEAT_HOTEND_TEMP 255 -#define ABS_PREHEAT_HPB_TEMP 100 -#define ABS_PREHEAT_FAN_SPEED 0 - -#define HIPS_PREHEAT_HOTEND_TEMP 220 -#define HIPS_PREHEAT_HPB_TEMP 100 -#define HIPS_PREHEAT_FAN_SPEED 0 - -#define PP_PREHEAT_HOTEND_TEMP 254 -#define PP_PREHEAT_HPB_TEMP 100 -#define PP_PREHEAT_FAN_SPEED 0 - -#define PET_PREHEAT_HOTEND_TEMP 230 -#define PET_PREHEAT_HPB_TEMP 85 -#define PET_PREHEAT_FAN_SPEED 0 - -#define FLEX_PREHEAT_HOTEND_TEMP 240 -#define FLEX_PREHEAT_HPB_TEMP 50 -#define FLEX_PREHEAT_FAN_SPEED 0 - -/*------------------------------------ - THERMISTORS SETTINGS - *------------------------------------*/ - -// -//--NORMAL IS 4.7kohm PULLUP!-- 1kohm pullup can be used on hotend sensor, using correct resistor and table -// -//// Temperature sensor settings: -// -2 is thermocouple with MAX6675 (only for sensor 0) -// -1 is thermocouple with AD595 -// 0 is not used -// 1 is 100k thermistor - best choice for EPCOS 100k (4.7k pullup) -// 2 is 200k thermistor - ATC Semitec 204GT-2 (4.7k pullup) -// 3 is Mendel-parts thermistor (4.7k pullup) -// 4 is 10k thermistor !! do not use it for a hotend. It gives bad resolution at high temp. !! -// 5 is 100K thermistor - ATC Semitec 104GT-2 (Used in ParCan & J-Head) (4.7k pullup) -// 6 is 100k EPCOS - Not as accurate as table 1 (created using a fluke thermocouple) (4.7k pullup) -// 7 is 100k Honeywell thermistor 135-104LAG-J01 (4.7k pullup) -// 71 is 100k Honeywell thermistor 135-104LAF-J01 (4.7k pullup) -// 8 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) -// 9 is 100k GE Sensing AL03006-58.2K-97-G1 (4.7k pullup) -// 10 is 100k RS thermistor 198-961 (4.7k pullup) -// 11 is 100k beta 3950 1% thermistor (4.7k pullup) -// 12 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed) -// 13 is 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE" -// 20 is the PT100 circuit found in the Ultimainboard V2.x -// 60 is 100k Maker's Tool Works Kapton Bed Thermistor beta=3950 -// -// 1k ohm pullup tables - This is not normal, you would have to have changed out your 4.7k for 1k -// (but gives greater accuracy and more stable PID) -// 51 is 100k thermistor - EPCOS (1k pullup) -// 52 is 200k thermistor - ATC Semitec 204GT-2 (1k pullup) -// 55 is 100k thermistor - ATC Semitec 104GT-2 (Used in ParCan & J-Head) (1k pullup) -// -// 1047 is Pt1000 with 4k7 pullup -// 1010 is Pt1000 with 1k pullup (non standard) -// 147 is Pt100 with 4k7 pullup -// 148 is E3D Pt100 with 4k7 pullup and no PT100 Amplifier on a MiniRambo 1.3a -// 247 is Pt100 with 4k7 pullup and PT100 Amplifier -// 110 is Pt100 with 1k pullup (non standard) - -#if defined(E3D_PT100_EXTRUDER_WITH_AMP) -#define TEMP_SENSOR_0 247 -#elif defined(E3D_PT100_EXTRUDER_NO_AMP) -#define TEMP_SENSOR_0 148 -#else -#define TEMP_SENSOR_0 5 -#endif -#define TEMP_SENSOR_1 0 -#define TEMP_SENSOR_2 0 -#if defined(E3D_PT100_BED_WITH_AMP) -#define TEMP_SENSOR_BED 247 -#elif defined(E3D_PT100_BED_NO_AMP) -#define TEMP_SENSOR_BED 148 -#else -#define TEMP_SENSOR_BED 1 -#endif -#define TEMP_SENSOR_PINDA 1 -#define TEMP_SENSOR_AMBIENT 2000 - -#define STACK_GUARD_TEST_VALUE 0xA2A2 - -#define MAX_BED_TEMP_CALIBRATION 50 -#define MAX_HOTEND_TEMP_CALIBRATION 50 - -#define MAX_E_STEPS_PER_UNIT 250 -#define MIN_E_STEPS_PER_UNIT 100 - -#define Z_BABYSTEP_MIN -3999 -#define Z_BABYSTEP_MAX 0 - -#define PINDA_PREHEAT_X 20 -#define PINDA_PREHEAT_Y 60 -#define PINDA_PREHEAT_Z 0.15 -/* -#define PINDA_PREHEAT_X 70 -#define PINDA_PREHEAT_Y -3 -#define PINDA_PREHEAT_Z 1*/ -#define PINDA_HEAT_T 120 //time in s - -#define PINDA_MIN_T 50 -#define PINDA_STEP_T 10 -#define PINDA_MAX_T 100 - -#define PING_TIME 60 //time in s -#define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid 0 triggering when dealing with long gcodes -#define PING_ALLERT_PERIOD 60 //time in s - -#define NC_TIME 10 //time in s for periodic important status messages sending which needs reponse from monitoring -#define NC_BUTTON_LONG_PRESS 15 //time in s - -#define LONG_PRESS_TIME 1000 //time in ms for button long press -#define BUTTON_BLANKING_TIME 200 //time in ms for blanking after button release - -#define DEFAULT_PID_TEMP 210 - -#define MIN_PRINT_FAN_SPEED 75 - - -// How much shall the print head be lifted on power panic? -// Ideally the Z axis will reach a zero phase of the stepper driver on power outage. To simplify this, -// UVLO_Z_AXIS_SHIFT shall be an integer multiply of the stepper driver cycle, that is 4x full step. -// For example, the Prusa i3 MK2 with 16 microsteps per full step has Z stepping of 400 microsteps per mm. -// At 400 microsteps per mm, a full step lifts the Z axis by 0.04mm, and a stepper driver cycle is 0.16mm. -// The following example, 12 * (4 * 16 / 400) = 12 * 0.16mm = 1.92mm. -//#define UVLO_Z_AXIS_SHIFT 1.92 -#define UVLO_Z_AXIS_SHIFT 0.64 -// If power panic occured, and the current temperature is higher then target temperature before interrupt minus this offset, print will be recovered automatically. -#define AUTOMATIC_UVLO_BED_TEMP_OFFSET 5 - -#define HEATBED_V2 - -#define M600_TIMEOUT 600 //seconds - -//#define SUPPORT_VERBOSITY - -#define MMU_REQUIRED_FW_BUILDNR 83 -#define MMU_HWRESET -//#define MMU_DEBUG //print communication between MMU2 and printer on serial - -#endif //__CONFIGURATION_PRUSA_H diff --git a/Firmware/fsensor.cpp.orig b/Firmware/fsensor.cpp.orig deleted file mode 100644 index 4f2c4b30c..000000000 --- a/Firmware/fsensor.cpp.orig +++ /dev/null @@ -1,545 +0,0 @@ -//! @file - -#include "Marlin.h" - -#include "fsensor.h" -#include -#include "pat9125.h" -#include "stepper.h" -#include "planner.h" -#include "fastio.h" -#include "cmdqueue.h" -#include "ultralcd.h" -#include "ConfigurationStore.h" -#include "mmu.h" - -//! @name Basic parameters -//! @{ -#define FSENSOR_CHUNK_LEN 0.64F //!< filament sensor chunk length 0.64mm -#define FSENSOR_ERR_MAX 17 //!< filament sensor maximum error count for runout detection -//! @} - -//! @name Optical quality measurement parameters -//! @{ -#define FSENSOR_OQ_MAX_ES 6 //!< maximum error sum while loading (length ~64mm = 100chunks) -#define FSENSOR_OQ_MAX_EM 2 //!< maximum error counter value while loading -#define FSENSOR_OQ_MIN_YD 2 //!< minimum yd per chunk (applied to avg value) -#define FSENSOR_OQ_MAX_YD 200 //!< maximum yd per chunk (applied to avg value) -#define FSENSOR_OQ_MAX_PD 4 //!< maximum positive deviation (= yd_max/yd_avg) -#define FSENSOR_OQ_MAX_ND 5 //!< maximum negative deviation (= yd_avg/yd_min) -#define FSENSOR_OQ_MAX_SH 13 //!< maximum shutter value -//! @} - -const char ERRMSG_PAT9125_NOT_RESP[] PROGMEM = "PAT9125 not responding (%d)!\n"; - -#define FSENSOR_INT_PIN 63 //!< filament sensor interrupt pin PK1 -#define FSENSOR_INT_PIN_MSK 0x02 //!< filament sensor interrupt pin mask (bit1) - -//uint8_t fsensor_int_pin = FSENSOR_INT_PIN; -uint8_t fsensor_int_pin_old = 0; -int16_t fsensor_chunk_len = 0; - -//! enabled = initialized and sampled every chunk event -bool fsensor_enabled = true; -//! runout watching is done in fsensor_update (called from main loop) -bool fsensor_watch_runout = true; -//! not responding - is set if any communication error occurred during initialization or readout -bool fsensor_not_responding = false; -//! printing saved -bool fsensor_printing_saved = false; -//! enable/disable quality meassurement -bool fsensor_oq_meassure_enabled = false; - -//! number of errors, updated in ISR -uint8_t fsensor_err_cnt = 0; -//! variable for accumulating step count (updated callbacks from stepper and ISR) -int16_t fsensor_st_cnt = 0; -//! last dy value from pat9125 sensor (used in ISR) -int16_t fsensor_dy_old = 0; - -//! log flag: 0=log disabled, 1=log enabled -uint8_t fsensor_log = 1; - - -//! @name filament autoload variables -//! @{ - -//! autoload feature enabled -bool fsensor_autoload_enabled = true; -//! autoload watching enable/disable flag -bool fsensor_watch_autoload = false; -// -uint16_t fsensor_autoload_y; -// -uint8_t fsensor_autoload_c; -// -uint32_t fsensor_autoload_last_millis; -// -uint8_t fsensor_autoload_sum; -//! @} - - -//! @name filament optical quality measurement variables -//! @{ - -//! Measurement enable/disable flag -bool fsensor_oq_meassure = false; -//! skip-chunk counter, for accurate measurement is necessary to skip first chunk... -uint8_t fsensor_oq_skipchunk; -//! number of samples from start of measurement -uint8_t fsensor_oq_samples; -//! sum of steps in positive direction movements -uint16_t fsensor_oq_st_sum; -//! sum of deltas in positive direction movements -uint16_t fsensor_oq_yd_sum; -//! sum of errors during measurement -uint16_t fsensor_oq_er_sum; -//! max error counter value during measurement -uint8_t fsensor_oq_er_max; -//! minimum delta value -int16_t fsensor_oq_yd_min; -//! maximum delta value -int16_t fsensor_oq_yd_max; -//! sum of shutter value -uint16_t fsensor_oq_sh_sum; -//! @} - -void fsensor_stop_and_save_print(void) -{ - printf_P(PSTR("fsensor_stop_and_save_print\n")); - stop_and_save_print_to_ram(0, 0); //XYZE - no change -} - -void fsensor_restore_print_and_continue(void) -{ - printf_P(PSTR("fsensor_restore_print_and_continue\n")); - fsensor_watch_runout = true; - fsensor_err_cnt = 0; - restore_print_from_ram_and_continue(0); //XYZ = orig, E - no change -} - -void fsensor_init(void) -{ - uint8_t pat9125 = pat9125_init(); - printf_P(PSTR("PAT9125_init:%hhu\n"), pat9125); - uint8_t fsensor = eeprom_read_byte((uint8_t*)EEPROM_FSENSOR); - fsensor_autoload_enabled=eeprom_read_byte((uint8_t*)EEPROM_FSENS_AUTOLOAD_ENABLED); - uint8_t oq_meassure_enabled = eeprom_read_byte((uint8_t*)EEPROM_FSENS_OQ_MEASS_ENABLED); - fsensor_oq_meassure_enabled = (oq_meassure_enabled == 1)?true:false; - fsensor_chunk_len = (int16_t)(FSENSOR_CHUNK_LEN * cs.axis_steps_per_unit[E_AXIS]); - - if (!pat9125) - { - fsensor = 0; //disable sensor - fsensor_not_responding = true; - } - else - fsensor_not_responding = false; - if (fsensor) - fsensor_enable(); - else - fsensor_disable(); - printf_P(PSTR("FSensor %S\n"), (fsensor_enabled?PSTR("ENABLED"):PSTR("DISABLED\n"))); -} - -bool fsensor_enable(void) -{ - if (mmu_enabled == false) { //filament sensor is pat9125, enable only if it is working - uint8_t pat9125 = pat9125_init(); - printf_P(PSTR("PAT9125_init:%hhu\n"), pat9125); - if (pat9125) - fsensor_not_responding = false; - else - fsensor_not_responding = true; - fsensor_enabled = pat9125 ? true : false; - fsensor_watch_runout = true; - fsensor_oq_meassure = false; - fsensor_err_cnt = 0; - fsensor_dy_old = 0; - eeprom_update_byte((uint8_t*)EEPROM_FSENSOR, fsensor_enabled ? 0x01 : 0x00); - FSensorStateMenu = fsensor_enabled ? 1 : 0; - } - else //filament sensor is FINDA, always enable - { - /** - * Enabling fsensor for load detection (hopfully jams as well) - */ - uint8_t pat9125 = pat9125_init(); - printf_P(PSTR("PAT9125_init:%hhu\n"), pat9125); - if (pat9125) - fsensor_not_responding = false; - else - fsensor_not_responding = true; - fsensor_enabled = true; - fsensor_autoload_set(true); - fsensor_oq_meassure = false; - fsensor_err_cnt = 0; - fsensor_dy_old = 0; - eeprom_update_byte((uint8_t*)EEPROM_FSENSOR, fsensor_enabled ? 0x01 : 0x00); - FSensorStateMenu = fsensor_enabled ? 1 : 0; - } - return fsensor_enabled; -} - -void fsensor_disable(void) -{ - fsensor_enabled = false; - eeprom_update_byte((uint8_t*)EEPROM_FSENSOR, 0x00); - FSensorStateMenu = 0; -} - -void fsensor_autoload_set(bool State) -{ - fsensor_autoload_enabled = State; - eeprom_update_byte((unsigned char *)EEPROM_FSENS_AUTOLOAD_ENABLED, fsensor_autoload_enabled); -} - -void pciSetup(byte pin) -{ - *digitalPinToPCMSK(pin) |= bit (digitalPinToPCMSKbit(pin)); // enable pin - PCIFR |= bit (digitalPinToPCICRbit(pin)); // clear any outstanding interrupt - PCICR |= bit (digitalPinToPCICRbit(pin)); // enable interrupt for the group -} - -void fsensor_autoload_check_start(void) -{ -// puts_P(_N("fsensor_autoload_check_start\n")); - if (!fsensor_enabled) return; - if (!fsensor_autoload_enabled) return; - if (fsensor_watch_autoload) return; - if (!pat9125_update_y()) //update sensor - { - fsensor_disable(); - fsensor_not_responding = true; - fsensor_watch_autoload = false; - printf_P(ERRMSG_PAT9125_NOT_RESP, 3); - return; - } - puts_P(_N("fsensor_autoload_check_start - autoload ENABLED\n")); - fsensor_autoload_y = pat9125_y; //save current y value - fsensor_autoload_c = 0; //reset number of changes counter - fsensor_autoload_sum = 0; - fsensor_autoload_last_millis = millis(); - fsensor_watch_runout = false; - fsensor_watch_autoload = true; - fsensor_err_cnt = 0; -} - -void fsensor_autoload_check_stop(void) -{ -// puts_P(_N("fsensor_autoload_check_stop\n")); - if (!fsensor_enabled) return; -// puts_P(_N("fsensor_autoload_check_stop 1\n")); - if (!fsensor_autoload_enabled) return; -// puts_P(_N("fsensor_autoload_check_stop 2\n")); - if (!fsensor_watch_autoload) return; - puts_P(_N("fsensor_autoload_check_stop - autoload DISABLED\n")); - fsensor_autoload_sum = 0; - fsensor_watch_autoload = false; - fsensor_watch_runout = true; - fsensor_err_cnt = 0; -} - -bool fsensor_check_autoload(void) -{ - if (!fsensor_enabled) return false; - if (!fsensor_autoload_enabled) return false; - if (!fsensor_watch_autoload) - { - fsensor_autoload_check_start(); - return false; - } -#if 0 - uint8_t fsensor_autoload_c_old = fsensor_autoload_c; -#endif - if ((millis() - fsensor_autoload_last_millis) < 25) return false; - fsensor_autoload_last_millis = millis(); - if (!pat9125_update_y()) //update sensor - { - fsensor_disable(); - fsensor_not_responding = true; - printf_P(ERRMSG_PAT9125_NOT_RESP, 2); - return false; - } - int16_t dy = pat9125_y - fsensor_autoload_y; - if (dy) //? dy value is nonzero - { - if (dy > 0) //? delta-y value is positive (inserting) - { - fsensor_autoload_sum += dy; - fsensor_autoload_c += 3; //increment change counter by 3 - } - else if (fsensor_autoload_c > 1) - fsensor_autoload_c -= 2; //decrement change counter by 2 - fsensor_autoload_y = pat9125_y; //save current value - } - else if (fsensor_autoload_c > 0) - fsensor_autoload_c--; - if (fsensor_autoload_c == 0) fsensor_autoload_sum = 0; -#if 0 - puts_P(_N("fsensor_check_autoload\n")); - if (fsensor_autoload_c != fsensor_autoload_c_old) - printf_P(PSTR("fsensor_check_autoload dy=%d c=%d sum=%d\n"), dy, fsensor_autoload_c, fsensor_autoload_sum); -#endif -// if ((fsensor_autoload_c >= 15) && (fsensor_autoload_sum > 30)) - if ((fsensor_autoload_c >= 12) && (fsensor_autoload_sum > 20)) - { - puts_P(_N("fsensor_check_autoload = true !!!\n")); - //if (mmu_enabled) { - mmuFilamentMK3Moving = true; - fsensor_autoload_check_stop(); - //} - return true; - } - return false; -} - -void fsensor_oq_meassure_set(bool State) -{ - fsensor_oq_meassure_enabled = State; - eeprom_update_byte((unsigned char *)EEPROM_FSENS_OQ_MEASS_ENABLED, fsensor_oq_meassure_enabled); -} - -void fsensor_oq_meassure_start(uint8_t skip) -{ - if (!fsensor_enabled) return; - if (!fsensor_oq_meassure_enabled) return; - printf_P(PSTR("fsensor_oq_meassure_start\n")); - fsensor_oq_skipchunk = skip; - fsensor_oq_samples = 0; - fsensor_oq_st_sum = 0; - fsensor_oq_yd_sum = 0; - fsensor_oq_er_sum = 0; - fsensor_oq_er_max = 0; - fsensor_oq_yd_min = FSENSOR_OQ_MAX_YD; - fsensor_oq_yd_max = 0; - fsensor_oq_sh_sum = 0; - pat9125_update(); - pat9125_y = 0; - fsensor_watch_runout = false; - fsensor_oq_meassure = true; -} - -void fsensor_oq_meassure_stop(void) -{ - if (!fsensor_enabled) return; - if (!fsensor_oq_meassure_enabled) return; - printf_P(PSTR("fsensor_oq_meassure_stop, %hhu samples\n"), fsensor_oq_samples); - printf_P(_N(" st_sum=%u yd_sum=%u er_sum=%u er_max=%hhu\n"), fsensor_oq_st_sum, fsensor_oq_yd_sum, fsensor_oq_er_sum, fsensor_oq_er_max); - printf_P(_N(" yd_min=%u yd_max=%u yd_avg=%u sh_avg=%u\n"), fsensor_oq_yd_min, fsensor_oq_yd_max, (uint16_t)((uint32_t)fsensor_oq_yd_sum * fsensor_chunk_len / fsensor_oq_st_sum), (uint16_t)(fsensor_oq_sh_sum / fsensor_oq_samples)); - fsensor_oq_meassure = false; - fsensor_watch_runout = true; - fsensor_err_cnt = 0; -} - -const char _OK[] PROGMEM = "OK"; -const char _NG[] PROGMEM = "NG!"; - -bool fsensor_oq_result(void) -{ - if (!fsensor_enabled) return true; - if (!fsensor_oq_meassure_enabled) return true; - printf_P(_N("fsensor_oq_result\n")); - bool res_er_sum = (fsensor_oq_er_sum <= FSENSOR_OQ_MAX_ES); - printf_P(_N(" er_sum = %u %S\n"), fsensor_oq_er_sum, (res_er_sum?_OK:_NG)); - bool res_er_max = (fsensor_oq_er_max <= FSENSOR_OQ_MAX_EM); - printf_P(_N(" er_max = %hhu %S\n"), fsensor_oq_er_max, (res_er_max?_OK:_NG)); - uint8_t yd_avg = ((uint32_t)fsensor_oq_yd_sum * fsensor_chunk_len / fsensor_oq_st_sum); - bool res_yd_avg = (yd_avg >= FSENSOR_OQ_MIN_YD) && (yd_avg <= FSENSOR_OQ_MAX_YD); - printf_P(_N(" yd_avg = %hhu %S\n"), yd_avg, (res_yd_avg?_OK:_NG)); - bool res_yd_max = (fsensor_oq_yd_max <= (yd_avg * FSENSOR_OQ_MAX_PD)); - printf_P(_N(" yd_max = %u %S\n"), fsensor_oq_yd_max, (res_yd_max?_OK:_NG)); - bool res_yd_min = (fsensor_oq_yd_min >= (yd_avg / FSENSOR_OQ_MAX_ND)); - printf_P(_N(" yd_min = %u %S\n"), fsensor_oq_yd_min, (res_yd_min?_OK:_NG)); - - uint16_t yd_dev = (fsensor_oq_yd_max - yd_avg) + (yd_avg - fsensor_oq_yd_min); - printf_P(_N(" yd_dev = %u\n"), yd_dev); - - uint16_t yd_qua = 10 * yd_avg / (yd_dev + 1); - printf_P(_N(" yd_qua = %u %S\n"), yd_qua, ((yd_qua >= 8)?_OK:_NG)); - - uint8_t sh_avg = (fsensor_oq_sh_sum / fsensor_oq_samples); - bool res_sh_avg = (sh_avg <= FSENSOR_OQ_MAX_SH); - if (yd_qua >= 8) res_sh_avg = true; - - printf_P(_N(" sh_avg = %hhu %S\n"), sh_avg, (res_sh_avg?_OK:_NG)); - bool res = res_er_sum && res_er_max && res_yd_avg && res_yd_max && res_yd_min && res_sh_avg; - printf_P(_N("fsensor_oq_result %S\n"), (res?_OK:_NG)); - return res; -} - -ISR(PCINT2_vect) -{ - if (!((fsensor_int_pin_old ^ PINK) & FSENSOR_INT_PIN_MSK)) return; - fsensor_int_pin_old = PINK; - static bool _lock = false; - if (_lock) return; - _lock = true; - int st_cnt = fsensor_st_cnt; - fsensor_st_cnt = 0; - sei(); - uint8_t old_err_cnt = fsensor_err_cnt; - uint8_t pat9125_res = fsensor_oq_meassure?pat9125_update():pat9125_update_y(); - if (!pat9125_res) - { - fsensor_disable(); - fsensor_not_responding = true; - printf_P(ERRMSG_PAT9125_NOT_RESP, 1); - } - if (st_cnt != 0) - { //movement - if (st_cnt > 0) //positive movement - { - if (pat9125_y < 0) - { - if (fsensor_err_cnt) - fsensor_err_cnt += 2; - else - fsensor_err_cnt++; - } - else if (pat9125_y > 0) - { - if (fsensor_err_cnt) - fsensor_err_cnt--; - } - else //(pat9125_y == 0) - if (((fsensor_dy_old <= 0) || (fsensor_err_cnt)) && (st_cnt > (fsensor_chunk_len >> 1))) - fsensor_err_cnt++; - if (fsensor_oq_meassure) - { - if (fsensor_oq_skipchunk) - { - fsensor_oq_skipchunk--; - fsensor_err_cnt = 0; - } - else - { - if (st_cnt == fsensor_chunk_len) - { - if (pat9125_y > 0) if (fsensor_oq_yd_min > pat9125_y) fsensor_oq_yd_min = (fsensor_oq_yd_min + pat9125_y) / 2; - if (pat9125_y >= 0) if (fsensor_oq_yd_max < pat9125_y) fsensor_oq_yd_max = (fsensor_oq_yd_max + pat9125_y) / 2; - } - fsensor_oq_samples++; - fsensor_oq_st_sum += st_cnt; - if (pat9125_y > 0) fsensor_oq_yd_sum += pat9125_y; - if (fsensor_err_cnt > old_err_cnt) - fsensor_oq_er_sum += (fsensor_err_cnt - old_err_cnt); - if (fsensor_oq_er_max < fsensor_err_cnt) - fsensor_oq_er_max = fsensor_err_cnt; - fsensor_oq_sh_sum += pat9125_s; - } - } - } - else //negative movement - { - } - } - else - { //no movement - } - -#ifdef DEBUG_FSENSOR_LOG - if (fsensor_log) - { - printf_P(_N("FSENSOR cnt=%d dy=%d err=%hhu %S\n"), st_cnt, pat9125_y, fsensor_err_cnt, (fsensor_err_cnt > old_err_cnt)?_N("NG!"):_N("OK")); - if (fsensor_oq_meassure) printf_P(_N("FSENSOR st_sum=%u yd_sum=%u er_sum=%u er_max=%hhu yd_max=%u\n"), fsensor_oq_st_sum, fsensor_oq_yd_sum, fsensor_oq_er_sum, fsensor_oq_er_max, fsensor_oq_yd_max); - } -#endif //DEBUG_FSENSOR_LOG - - fsensor_dy_old = pat9125_y; - pat9125_y = 0; - - _lock = false; - return; -} - -void fsensor_st_block_begin(block_t* bl) -{ - if (!fsensor_enabled) return; - if (((fsensor_st_cnt > 0) && (bl->direction_bits & 0x8)) || - ((fsensor_st_cnt < 0) && !(bl->direction_bits & 0x8))) - { - if (_READ(63)) _WRITE(63, LOW); - else _WRITE(63, HIGH); - } -} - -void fsensor_st_block_chunk(block_t* bl, int cnt) -{ - if (!fsensor_enabled) return; - fsensor_st_cnt += (bl->direction_bits & 0x8)?-cnt:cnt; - if ((fsensor_st_cnt >= fsensor_chunk_len) || (fsensor_st_cnt <= -fsensor_chunk_len)) - { - if (_READ(63)) _WRITE(63, LOW); - else _WRITE(63, HIGH); - } -} - -//! @brief filament sensor update (perform M600 on filament runout) -//! -//! Works only if filament sensor is enabled. -//! When the filament sensor error count is larger then FSENSOR_ERR_MAX, pauses print, tries to move filament back and forth. -//! If there is still no plausible signal from filament sensor plans M600 (Filament change). -void fsensor_update(void) -{ - if (fsensor_enabled && fsensor_watch_runout && (fsensor_err_cnt > FSENSOR_ERR_MAX)) - { - bool autoload_enabled_tmp = fsensor_autoload_enabled; - fsensor_autoload_enabled = false; - bool oq_meassure_enabled_tmp = fsensor_oq_meassure_enabled; - fsensor_oq_meassure_enabled = true; - - fsensor_stop_and_save_print(); - - fsensor_err_cnt = 0; - fsensor_oq_meassure_start(0); - - enquecommand_front_P((PSTR("G1 E-3 F200"))); - process_commands(); - KEEPALIVE_STATE(IN_HANDLER); - cmdqueue_pop_front(); - st_synchronize(); - - enquecommand_front_P((PSTR("G1 E3 F200"))); - process_commands(); - KEEPALIVE_STATE(IN_HANDLER); - cmdqueue_pop_front(); - st_synchronize(); - - uint8_t err_cnt = fsensor_err_cnt; - fsensor_oq_meassure_stop(); - - bool err = false; - err |= (err_cnt > 1); - - err |= (fsensor_oq_er_sum > 2); - err |= (fsensor_oq_yd_sum < (4 * FSENSOR_OQ_MIN_YD)); - - if (!err) - { - printf_P(PSTR("fsensor_err_cnt = 0\n")); - fsensor_restore_print_and_continue(); - } - else - { - printf_P(PSTR("fsensor_update - M600\n")); - eeprom_update_byte((uint8_t*)EEPROM_FERROR_COUNT, eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT) + 1); - eeprom_update_word((uint16_t*)EEPROM_FERROR_COUNT_TOT, eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT) + 1); - enquecommand_front_P(PSTR("FSENSOR_RECOVER")); - enquecommand_front_P((PSTR("M600"))); - fsensor_watch_runout = false; - } - fsensor_autoload_enabled = autoload_enabled_tmp; - fsensor_oq_meassure_enabled = oq_meassure_enabled_tmp; - } -} - -void fsensor_setup_interrupt(void) -{ - - pinMode(FSENSOR_INT_PIN, OUTPUT); - digitalWrite(FSENSOR_INT_PIN, LOW); - fsensor_int_pin_old = 0; - - pciSetup(FSENSOR_INT_PIN); -} diff --git a/Firmware/mmu.cpp.orig b/Firmware/mmu.cpp.orig deleted file mode 100644 index 729691249..000000000 --- a/Firmware/mmu.cpp.orig +++ /dev/null @@ -1,1352 +0,0 @@ -//mmu.cpp - -#include "mmu.h" -#include "planner.h" -#include "language.h" -#include "lcd.h" -#include "uart2.h" -#include "temperature.h" -#include "Configuration_prusa.h" -#include "fsensor.h" -#include "cardreader.h" -#include "ultralcd.h" -#include "sound.h" -#include "printers.h" -#include - -#define CHECK_FINDA ((IS_SD_PRINTING || is_usb_printing) && (mcode_in_progress != 600) && !saved_printing && e_active()) - -#define MMU_TODELAY 100 -#define MMU_TIMEOUT 10 -#define MMU_CMD_TIMEOUT 300000ul //5min timeout for mmu commands (except P0) -#define MMU_P0_TIMEOUT 3000ul //timeout for P0 command: 3seconds - -#ifdef MMU_HWRESET -#define MMU_RST_PIN 76 -#endif //MMU_HWRESET - -bool mmu_enabled = false; - -bool mmu_ready = false; - -bool mmuFilamentMK3Moving = false; -bool mmuFSensorLoading = false; -bool singleLog = true; -int lastLoadedFilament = -10; - -int8_t mmu_state = 0; -int8_t last_state = -10; - -uint8_t mmu_cmd = 0; -bool ack_received = false; - -uint8_t mmu_extruder = 0; - -//! This variable probably has no meaning and is planed to be removed -uint8_t tmp_extruder = 0; - -int8_t mmu_finda = -1; - -int16_t mmu_version = -1; - -int16_t mmu_buildnr = -1; - -uint32_t mmu_last_request = 0; -uint32_t mmu_last_response = 0; - -//clear rx buffer -void mmu_clr_rx_buf(void) -{ - while (fgetc(uart2io) >= 0); -} - -//send command - puts -int mmu_puts_P(const char* str) -{ - mmu_clr_rx_buf(); //clear rx buffer - int r = fputs_P(str, uart2io); //send command - mmu_last_request = millis(); - return r; -} - -//send command - printf -int mmu_printf_P(const char* format, ...) -{ - va_list args; - va_start(args, format); - mmu_clr_rx_buf(); //clear rx buffer - int r = vfprintf_P(uart2io, format, args); //send command - va_end(args); - mmu_last_request = millis(); - return r; -} - -//check 'sensing Filament at Boot' response -int8_t mmu_rx_echo(void) -{ - int8_t res = 0; - switch (mmu_cmd) - { - case MMU_CMD_T0: // T0 - res = uart2_rx_str_P(PSTR("T0\n")); - break; - case MMU_CMD_T1: // T1 - res = uart2_rx_str_P(PSTR("T1\n")); - break; - case MMU_CMD_T2: // T2 - res = uart2_rx_str_P(PSTR("T2\n")); - break; - case MMU_CMD_T3: // T3 - res = uart2_rx_str_P(PSTR("T3\n")); - break; - case MMU_CMD_T4: // T4 - res = uart2_rx_str_P(PSTR("T4\n")); - break; - case MMU_CMD_L0: // L0 - res = uart2_rx_str_P(PSTR("L0\n")); - break; - case MMU_CMD_L1: // L1 - res = uart2_rx_str_P(PSTR("L1\n")); - break; - case MMU_CMD_L2: // L2 - res = uart2_rx_str_P(PSTR("L2\n")); - break; - case MMU_CMD_L3: // L3 - res = uart2_rx_str_P(PSTR("L3\n")); - break; - case MMU_CMD_L4: // L4 - res = uart2_rx_str_P(PSTR("L4\n")); - break; - case MMU_CMD_C0: // C0 - res = uart2_rx_str_P(PSTR("C0\n")); - break; - case MMU_CMD_U0: // U0 - res = uart2_rx_str_P(PSTR("U0\n")); - break; - case MMU_CMD_E0: // E0 - res = uart2_rx_str_P(PSTR("E0\n")); - break; - case MMU_CMD_E1: // E1 - res = uart2_rx_str_P(PSTR("E1\n")); - break; - case MMU_CMD_E2: // E2 - res = uart2_rx_str_P(PSTR("E2\n")); - break; - case MMU_CMD_E3: // E3 - res = uart2_rx_str_P(PSTR("E3\n")); - break; - case MMU_CMD_E4: // E4 - res = uart2_rx_str_P(PSTR("E4\n")); - break; - case MMU_CMD_R0: // R0 - res = uart2_rx_str_P(PSTR("R0\n")); - break; - } - if (res == 0) puts_P(PSTR("MMU Didn't see CMD and ECHO")); - if (res == 1) mmu_last_response = millis(); - return res; -} - -//check 'ok' response -int8_t mmu_rx_ok(void) -{ - int8_t res = uart2_rx_str_P(PSTR("ok\n")); - if (res == 1) mmu_last_response = millis(); - return res; -} - -//check ' not ok' response -int8_t mmu_rx_not_ok(void) -{ - int8_t res = uart2_rx_str_P(PSTR("not_ok\n")); - if (res == 1) mmu_last_response = millis(); - return res; -} - -//check 'start' response -int8_t mmu_rx_start(void) -{ - int8_t res = uart2_rx_str_P(PSTR("start\n")); - if (res == 1) mmu_last_response = millis(); - return res; -} - -//initialize mmu2 unit - first part - should be done at begining of startup process -void mmu_init(void) -{ -#ifdef MMU_HWRESET - digitalWrite(MMU_RST_PIN, HIGH); - pinMode(MMU_RST_PIN, OUTPUT); //setup reset pin -#endif //MMU_HWRESET - uart2_init(); //init uart2 - _delay_ms(10); //wait 10ms for sure - mmu_reset(); //reset mmu (HW or SW), do not wait for response - mmu_state = -1; -} - -//mmu main loop - state machine processing -/** - * MMU States - * -1 >> -2 MMURX Start, respond with S1 (30s timeout to disabled state) - * -2 >> -3 MMURX ok, respond with S2 - * -3 >> -4 MMURX ok, respond with P0(READ FINDA) if MK3 and goto -4 - * -5 respond with M1(MODE STEALTH) if MK2.5 and goto -5 - * -4 >> 1 MMURX ok, mmu_ready - * -5 >> 1 MMURX ok, mmu_ready - * 1 >> ? MMU CMD Request from MK3 - * 2 >> 1 MMURX ok, Finda State - * 3 >> 1 MMURX ok, mmu commands response - * 10 >> 3 MMUECHO, confirm receipt of cmd (timeout 500ms to resend) - */ - -void mmu_loop(void) -{ - int filament = 0; - if (last_state != mmu_state) printf_P(PSTR("MMU loop, state=%d\n"), mmu_state); - last_state = mmu_state; - switch (mmu_state) - { - case 0: - return; - case -1: - if (mmu_rx_start() > 0) - { -#ifdef MMU_DEBUG - puts_P(PSTR("MMU => 'start'")); - puts_P(PSTR("MMU <= 'S1'")); -#endif //MMU_DEBUG - mmu_puts_P(PSTR("S1\n")); //send 'read version' request - mmu_state = -2; - } - else if (millis() > 30000) //30sec after reset disable mmu - { - puts_P(PSTR("MMU not responding - DISABLED")); - mmu_state = 0; - } - return; - case -2: - if (mmu_rx_ok() > 0) - { - fscanf_P(uart2io, PSTR("%u"), &mmu_version); //scan version from buffer -#ifdef MMU_DEBUG - printf_P(PSTR("MMU => '%dok'\n"), mmu_version); - puts_P(PSTR("MMU <= 'S2'")); -#endif //MMU_DEBUG - mmu_puts_P(PSTR("S2\n")); //send 'read buildnr' request - mmu_state = -3; - } - return; - case -3: - if (mmu_rx_ok() > 0) - { - fscanf_P(uart2io, PSTR("%u"), &mmu_buildnr); //scan buildnr from buffer -#ifdef MMU_DEBUG - printf_P(PSTR("MMU => '%dok'\n"), mmu_buildnr); -#endif //MMU_DEBUG - bool version_valid = mmu_check_version(); - if (!version_valid) mmu_show_warning(); - else puts_P(PSTR("MMU version valid")); - - if ((PRINTER_TYPE == PRINTER_MK3) || (PRINTER_TYPE == PRINTER_MK3_SNMM)) - { -#ifdef MMU_DEBUG - puts_P(PSTR("MMU <= 'P0'")); -#endif //MMU_DEBUG - mmu_puts_P(PSTR("P0\n")); //send 'read finda' request - mmu_state = -4; - } - else - { -#ifdef MMU_DEBUG - puts_P(PSTR("MMU <= 'M1'")); -#endif //MMU_DEBUG - mmu_puts_P(PSTR("M1\n")); //set mmu mode to stealth - mmu_state = -5; - } - - } - return; - case -5: - if (mmu_rx_ok() > 0) - { -#ifdef MMU_DEBUG - puts_P(PSTR("MMU <= 'P0'")); -#endif //MMU_DEBUG - mmu_puts_P(PSTR("P0\n")); //send 'read finda' request - mmu_state = -4; - } - return; - case -4: - if (mmu_rx_ok() > 0) - { - fscanf_P(uart2io, PSTR("%hhu"), &mmu_finda); //scan finda from buffer -#ifdef MMU_DEBUG - printf_P(PSTR("MMU => '%dok'\n"), mmu_finda); -#endif //MMU_DEBUG - puts_P(PSTR("MMU - ENABLED")); - mmu_enabled = true; - mmu_state = 1; - } - return; - case 1: - if (mmu_cmd && !ack_received) //command request ? - { - switch (mmu_cmd) { - case MMU_CMD_T0: - mmu_puts_P(PSTR("T0\n")); - break; - case MMU_CMD_T1: - mmu_puts_P(PSTR("T1\n")); - break; - case MMU_CMD_T2: - mmu_puts_P(PSTR("T2\n")); - break; - case MMU_CMD_T3: - mmu_puts_P(PSTR("T3\n")); - break; - case MMU_CMD_T4: - mmu_puts_P(PSTR("T4\n")); - break; - case MMU_CMD_L0: - mmu_puts_P(PSTR("L0\n")); - break; - case MMU_CMD_L1: - mmu_puts_P(PSTR("L1\n")); - break; - case MMU_CMD_L2: - mmu_puts_P(PSTR("L2\n")); - break; - case MMU_CMD_L3: - mmu_puts_P(PSTR("L3\n")); - break; - case MMU_CMD_L4: - mmu_puts_P(PSTR("L4\n")); - break; - case MMU_CMD_C0: - mmu_puts_P(PSTR("C0\n")); - break; - case MMU_CMD_U0: - mmu_puts_P(PSTR("U0\n")); - break; - case MMU_CMD_E0: - mmu_puts_P(PSTR("E0\n")); - break; - case MMU_CMD_E1: - mmu_puts_P(PSTR("E1\n")); - break; - case MMU_CMD_E2: - mmu_puts_P(PSTR("E2\n")); - break; - case MMU_CMD_E3: - mmu_puts_P(PSTR("E3\n")); - break; - case MMU_CMD_E4: - mmu_puts_P(PSTR("E4\n")); - break; - case MMU_CMD_R0: - mmu_puts_P(PSTR("R0\n")); - break; - } - mmu_state = 10; - } else if (mmu_cmd && ack_received) { - ack_received = false; - if ((mmu_cmd >= MMU_CMD_T0) && (mmu_cmd <= MMU_CMD_T4)) - { - filament = mmu_cmd - MMU_CMD_T0; - if (lastLoadedFilament != filament) { - fsensor_enable(); // RMM:TODO Not sure if this is the best place to ensure enabled - printf_P(PSTR("MMU <= 'T%d'\n"), filament); - mmu_puts_P(PSTR("EE\n")); // Advise MMU CMD is correct, execute - //mmu_printf_P(PSTR("T%d\n"), filament); - mmu_state = 3; // wait for response - fsensor_autoload_check_start(); - mmuFSensorLoading = true; - fsensor_autoload_enabled = true; - mmuFilamentMK3Moving = false; - } - lastLoadedFilament = filament; - } - else if ((mmu_cmd >= MMU_CMD_L0) && (mmu_cmd <= MMU_CMD_L4)) - { - filament = mmu_cmd - MMU_CMD_L0; - printf_P(PSTR("MMU <= 'L%d'\n"), filament); - mmu_puts_P(PSTR("EE\n")); // Advise MMU CMD is correct, execute - //mmu_printf_P(PSTR("L%d\n"), filament); - mmu_state = 3; // wait for response - } - else if (mmu_cmd == MMU_CMD_C0) - { - printf_P(PSTR("MMU <= 'C0'\n")); - delay(100); - //mmu_puts_P(PSTR("C0\n")); //send 'continue loading' - mmu_puts_P(PSTR("EE\n")); // Advise MMU CMD is correct, execute - mmu_state = 3; - } - else if (mmu_cmd == MMU_CMD_U0) - { - printf_P(PSTR("MMU <= 'U0'\n")); - //mmu_puts_P(PSTR("U0\n")); //send 'unload current filament' - mmu_puts_P(PSTR("EE\n")); // Advise MMU CMD is correct, execute - lastLoadedFilament = -10; - mmu_state = 3; - } - else if ((mmu_cmd >= MMU_CMD_E0) && (mmu_cmd <= MMU_CMD_E4)) - { - int filament = mmu_cmd - MMU_CMD_E0; - printf_P(PSTR("MMU <= 'E%d'\n"), filament); - //mmu_printf_P(PSTR("E%d\n"), filament); //send eject filament - mmu_puts_P(PSTR("EE\n")); // Advise MMU CMD is correct, execute - mmu_state = 3; // wait for response - } - else if (mmu_cmd == MMU_CMD_R0) - { - printf_P(PSTR("MMU <= 'R0'\n")); - //mmu_puts_P(PSTR("R0\n")); //send recover after eject - mmu_puts_P(PSTR("EE\n")); // Advise MMU CMD is correct, execute - mmu_state = 3; // wait for response - } - mmu_cmd = 0; - } - else if ((mmu_last_response + 300) < millis()) //request every 300ms - { - mmu_puts_P(PSTR("P0\n")); //send 'read finda' request - mmu_state = 2; - } - return; - case 2: //response to command P0 - if (mmu_rx_ok() > 0) - { - fscanf_P(uart2io, PSTR("%hhu"), &mmu_finda); //scan finda from buffer - //printf_P(PSTR("MMU => '%dok'\n"), mmu_finda); - if (!mmu_finda && CHECK_FINDA && fsensor_enabled) { - fsensor_stop_and_save_print(); - enquecommand_front_P(PSTR("FSENSOR_RECOVER")); //then recover - if (lcd_autoDeplete) enquecommand_front_P(PSTR("M600 AUTO")); //save print and run M600 command - else enquecommand_front_P(PSTR("M600")); //save print and run M600 command - } - mmu_state = 1; - if (mmu_cmd == 0) - mmu_ready = true; - } - else if ((mmu_last_request + MMU_P0_TIMEOUT) < millis()) - { //resend request after timeout (30s) - mmu_state = 1; - } - return; - case 3: //response to mmu commands - if (mmu_rx_ok() > 0) - { - if (mmuFSensorLoading == false) { - delay(100); - printf_P(PSTR("MMU => 'ok'\n")); - mmu_ready = true; - mmu_state = 1; - } else if (mmuFilamentMK3Moving == true) { - //mmu_puts_P(PSTR("FS\n")); - mmu_printf_P(PSTR("FS%d\n"), 1); - printf_P(PSTR("MMU <= 'Filament seen at extruder'\n")); - mmuFSensorLoading = false; - singleLog = true; - } else { - if (singleLog) { - printf_P(PSTR("MMU => 'waiting for filament @ MK3 Sensor'\n")); - singleLog = false; - } - } - } else if (mmu_rx_not_ok() > 0) { - printf_P(PSTR("MMU => 'Error State, do something here??'\n")); - } - /*else if ((mmu_last_request + MMU_CMD_TIMEOUT) < millis()) - { //resend request after timeout (5 min) - mmu_state = 1; - }*/ - return; - case 10: //echo response, comms confirmation - if (mmu_rx_echo() > 0) - { - printf_P(PSTR("MMU => 'CMD ACK'\n")); - //mmu_puts_P(PSTR("EE\n")); // Advise MMU CMD is correct, execute - ack_received = true; - mmu_state = 1; // Do normal Await command completion confirmation - } else if ((mmu_last_request + 250) < millis()) { // Timeout if echo doesn't match request, resend cmd - mmu_state = 1; - } - return; - } -} - - -void mmu_reset(void) -{ -#ifdef MMU_HWRESET //HW - pulse reset pin - digitalWrite(MMU_RST_PIN, LOW); - _delay_us(100); - digitalWrite(MMU_RST_PIN, HIGH); -#else //SW - send X0 command - mmu_puts_P(PSTR("X0\n")); -#endif -} - -int8_t mmu_set_filament_type(uint8_t extruder, uint8_t filament) -{ - printf_P(PSTR("MMU <= 'F%d %d'\n"), extruder, filament); - mmu_printf_P(PSTR("F%d %d\n"), extruder, filament); - unsigned char timeout = MMU_TIMEOUT; //10x100ms - while ((mmu_rx_ok() <= 0) && (--timeout)) - delay_keep_alive(MMU_TODELAY); - return timeout?1:0; -} - -void mmu_command(uint8_t cmd) -{ - mmu_cmd = cmd; - mmu_ready = false; -} - -bool mmu_get_response(void) -{ -// printf_P(PSTR("mmu_get_response - begin\n")); - KEEPALIVE_STATE(IN_PROCESS); - while (mmu_cmd != 0) - { -// mmu_loop(); - delay_keep_alive(150); - } - while (!mmu_ready) - { -// mmu_loop(); - if (mmu_state != 3 || mmu_state != 10) - break; - delay_keep_alive(150); - } - bool ret = mmu_ready; - mmu_ready = false; -// printf_P(PSTR("mmu_get_response - end %d\n"), ret?1:0); - return ret; -} - -void manage_response(bool move_axes, bool turn_off_nozzle) -{ - bool response = false; - mmu_print_saved = false; - bool lcd_update_was_enabled = false; - float hotend_temp_bckp = degTargetHotend(active_extruder); - float z_position_bckp = current_position[Z_AXIS]; - float x_position_bckp = current_position[X_AXIS]; - float y_position_bckp = current_position[Y_AXIS]; - while(!response) - { - response = mmu_get_response(); //wait for "ok" from mmu - if (!response) { //no "ok" or "echo" was received in reserved time frame, user will fix the issue on mmu unit - if (!mmu_print_saved) { //first occurence, we are saving current position, park print head in certain position and disable nozzle heater - if (lcd_update_enabled) { - lcd_update_was_enabled = true; - lcd_update_enable(false); - } - st_synchronize(); - mmu_print_saved = true; - printf_P(PSTR("MMU not responding\n")); - hotend_temp_bckp = degTargetHotend(active_extruder); - if (move_axes) { - z_position_bckp = current_position[Z_AXIS]; - x_position_bckp = current_position[X_AXIS]; - y_position_bckp = current_position[Y_AXIS]; - - //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); - 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); - st_synchronize(); - } - if (turn_off_nozzle) { - //set nozzle target temperature to 0 - setAllTargetHotends(0); - } - } - lcd_display_message_fullscreen_P(_i("MMU needs user attention. Fix the issue and then press button on MMU unit.")); - delay_keep_alive(1000); - } - else if (mmu_print_saved) { - printf_P(PSTR("MMU starts responding\n")); - if (turn_off_nozzle) - { - lcd_clear(); - setTargetHotend(hotend_temp_bckp, active_extruder); - lcd_display_message_fullscreen_P(_i("MMU OK. Resuming temperature...")); - delay_keep_alive(3000); - while ((degTargetHotend(active_extruder) - degHotend(active_extruder)) > 5) - { - delay_keep_alive(1000); - lcd_wait_for_heater(); - } - } - if (move_axes) { - lcd_clear(); - 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); - 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); - st_synchronize(); - } - else { - lcd_clear(); - lcd_display_message_fullscreen_P(_i("MMU OK. Resuming...")); - delay_keep_alive(1000); //delay just for showing MMU OK message for a while in case that there are no xyz movements - } - } - } - 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() -{ - st_synchronize(); - - bool saved_e_relative_mode = axis_relative_modes[E_AXIS]; - if (!saved_e_relative_mode) axis_relative_modes[E_AXIS] = true; - 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); - 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); - 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); - 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); - st_synchronize(); - if (!saved_e_relative_mode) axis_relative_modes[E_AXIS] = false; -} - -void mmu_M600_wait_and_beep() { - //Beep and wait for user to remove old filament and prepare new filament for load - - KEEPALIVE_STATE(PAUSED_FOR_USER); - - int counterBeep = 0; - lcd_display_message_fullscreen_P(_i("Remove old filament and press the knob to start loading new filament.")); - bool bFirst=true; - - while (!lcd_clicked()) { - manage_heater(); - manage_inactivity(true); - -#if BEEPER > 0 - if (counterBeep == 500) { - counterBeep = 0; - } - SET_OUTPUT(BEEPER); - if (counterBeep == 0) { - if((eSoundMode==e_SOUND_MODE_LOUD)||((eSoundMode==e_SOUND_MODE_ONCE)&&bFirst)) - { - bFirst=false; - WRITE(BEEPER, HIGH); - } - } - if (counterBeep == 20) { - WRITE(BEEPER, LOW); - } - - counterBeep++; -#endif //BEEPER > 0 - - delay_keep_alive(4); - } - WRITE(BEEPER, LOW); -} - -void mmu_M600_load_filament(bool automatic) -{ - //load filament for mmu v2 - tmp_extruder = mmu_extruder; - if (!automatic) { -#ifdef MMU_M600_SWITCH_EXTRUDER - bool yes = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Do you want to switch extruder?"), false); - if(yes) tmp_extruder = choose_extruder_menu(); -#endif //MMU_M600_SWITCH_EXTRUDER - } - else { - tmp_extruder = (tmp_extruder+1)%5; - } - lcd_update_enable(false); - lcd_clear(); - lcd_set_cursor(0, 1); - lcd_puts_P(_T(MSG_LOADING_FILAMENT)); - lcd_print(" "); - lcd_print(tmp_extruder + 1); - snmm_filaments_used |= (1 << tmp_extruder); //for stop print - -// 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); - - manage_response(false, true); - mmu_command(MMU_CMD_C0); - mmu_extruder = tmp_extruder; //filament change is finished - - mmu_load_to_nozzle(); - - - st_synchronize(); - 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], 2, active_extruder); -} - - -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); - set_extrude_min_temp(EXTRUDE_MINTEMP); -} - - -void change_extr(int -#ifdef SNMM - extr -#endif //SNMM - ) { //switches multiplexer for extruders -#ifdef SNMM - st_synchronize(); - delay(100); - - disable_e0(); - disable_e1(); - disable_e2(); - - mmu_extruder = extr; - - pinMode(E_MUX0_PIN, OUTPUT); - pinMode(E_MUX1_PIN, OUTPUT); - - switch (extr) { - case 1: - WRITE(E_MUX0_PIN, HIGH); - WRITE(E_MUX1_PIN, LOW); - - break; - case 2: - WRITE(E_MUX0_PIN, LOW); - WRITE(E_MUX1_PIN, HIGH); - - break; - case 3: - WRITE(E_MUX0_PIN, HIGH); - WRITE(E_MUX1_PIN, HIGH); - - break; - default: - WRITE(E_MUX0_PIN, LOW); - WRITE(E_MUX1_PIN, LOW); - - break; - } - delay(100); -#endif -} - -int get_ext_nr() -{ //reads multiplexer input pins and return current extruder number (counted from 0) -#ifndef SNMM - return(mmu_extruder); //update needed -#else - return(2 * READ(E_MUX1_PIN) + READ(E_MUX0_PIN)); -#endif -} - - -void display_loading() -{ - switch (mmu_extruder) - { - case 1: - lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T1)); - break; - case 2: - lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T2)); - break; - case 3: - lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T3)); - break; - default: - lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T0)); - break; - } -} - -void extr_adj(int extruder) //loading filament for SNMM -{ -#ifndef SNMM - uint8_t cmd = MMU_CMD_L0 + extruder; - if (cmd > MMU_CMD_L4) - { - printf_P(PSTR("Filament out of range %d \n"),extruder); - return; - } - mmu_command(cmd); - - //show which filament is currently loaded - - lcd_update_enable(false); - lcd_clear(); - lcd_set_cursor(0, 1); - lcd_puts_P(_T(MSG_LOADING_FILAMENT)); - //if(strlen(_T(MSG_LOADING_FILAMENT))>18) lcd.setCursor(0, 1); - //else lcd.print(" "); - lcd_print(" "); - lcd_print(extruder + 1); - - // get response - manage_response(false, false); - - lcd_update_enable(true); - - - //lcd_return_to_status(); -#else - - bool correct; - max_feedrate[E_AXIS] =80; - //max_feedrate[E_AXIS] = 50; -START: - lcd_clear(); - lcd_set_cursor(0, 0); - switch (extruder) { - case 1: - lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T1)); - break; - case 2: - lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T2)); - break; - case 3: - lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T3)); - break; - default: - lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T0)); - break; - } - KEEPALIVE_STATE(PAUSED_FOR_USER); - do { - extr_mov(0.001,1000); - delay_keep_alive(2); - } while (!lcd_clicked()); - //delay_keep_alive(500); - KEEPALIVE_STATE(IN_HANDLER); - st_synchronize(); - //correct = lcd_show_fullscreen_message_yes_no_and_wait_P(MSG_FIL_LOADED_CHECK, false); - //if (!correct) goto START; - //extr_mov(BOWDEN_LENGTH/2.f, 500); //dividing by 2 is there because of max. extrusion length limitation (x_max + y_max) - //extr_mov(BOWDEN_LENGTH/2.f, 500); - extr_mov(bowden_length[extruder], 500); - lcd_clear(); - lcd_set_cursor(0, 0); - lcd_puts_P(_T(MSG_LOADING_FILAMENT)); - if(strlen(_T(MSG_LOADING_FILAMENT))>18) lcd_set_cursor(0, 1); - else lcd_print(" "); - lcd_print(mmu_extruder + 1); - lcd_set_cursor(0, 2); - lcd_puts_P(_T(MSG_PLEASE_WAIT)); - st_synchronize(); - max_feedrate[E_AXIS] = 50; - lcd_update_enable(true); - lcd_return_to_status(); - lcdDrawUpdate = 2; -#endif -} - -struct E_step -{ - float extrude; //!< extrude distance in mm - float feed_rate; //!< feed rate in mm/s -}; -static const E_step ramming_sequence[] PROGMEM = -{ - {1.0, 1000.0/60}, - {1.0, 1500.0/60}, - {2.0, 2000.0/60}, - {1.5, 3000.0/60}, - {2.5, 4000.0/60}, - {-15.0, 5000.0/60}, - {-14.0, 1200.0/60}, - {-6.0, 600.0/60}, - {10.0, 700.0/60}, - {-10.0, 400.0/60}, - {-50.0, 2000.0/60}, -}; - -//! @brief Unload sequence to optimize shape of the tip of the unloaded filament -static void 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); - st_synchronize(); - } -} - -void extr_unload() -{ //unload just current filament for multimaterial printers -#ifdef SNMM - float tmp_motor[3] = DEFAULT_PWM_MOTOR_CURRENT; - float tmp_motor_loud[3] = DEFAULT_PWM_MOTOR_CURRENT_LOUD; - uint8_t SilentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT); -#endif - - if (degHotend0() > EXTRUDE_MINTEMP) - { -#ifndef SNMM - st_synchronize(); - - //show which filament is currently unloaded - lcd_update_enable(false); - lcd_clear(); - lcd_set_cursor(0, 1); - lcd_puts_P(_T(MSG_UNLOADING_FILAMENT)); - lcd_print(" "); - lcd_print(mmu_extruder + 1); - - filament_ramming(); - - mmu_command(MMU_CMD_U0); - // get response - manage_response(false, true); - - lcd_update_enable(true); -#else //SNMM - - lcd_clear(); - lcd_display_message_fullscreen_P(PSTR("")); - max_feedrate[E_AXIS] = 50; - lcd_set_cursor(0, 0); - lcd_puts_P(_T(MSG_UNLOADING_FILAMENT)); - lcd_print(" "); - lcd_print(mmu_extruder + 1); - 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); - } - - 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); - 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); - 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); - 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); - } - 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); - 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); - 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); - /*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 - 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*/ - 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); - 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); - st_synchronize(); - //st_current_init(); - if (SilentMode != SILENT_MODE_OFF) st_current_set(2, tmp_motor[2]); //set back to normal operation currents - else st_current_set(2, tmp_motor_loud[2]); - lcd_update_enable(true); - lcd_return_to_status(); - max_feedrate[E_AXIS] = 50; -#endif //SNMM - } - else - { - lcd_clear(); - lcd_set_cursor(0, 0); - lcd_puts_P(_T(MSG_ERROR)); - lcd_set_cursor(0, 2); - lcd_puts_P(_T(MSG_PREHEAT_NOZZLE)); - delay(2000); - lcd_clear(); - } - //lcd_return_to_status(); -} - -void extr_unload_at_boot() -{ //unload just current filament for multimaterial printers -#ifdef SNMM - float tmp_motor[3] = DEFAULT_PWM_MOTOR_CURRENT; - float tmp_motor_loud[3] = DEFAULT_PWM_MOTOR_CURRENT_LOUD; - uint8_t SilentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT); -#endif - - if (degHotend0() > EXTRUDE_MINTEMP) - { -#ifndef SNMM - st_synchronize(); - - //show which filament is currently unloaded - lcd_update_enable(false); - lcd_clear(); - lcd_set_cursor(0, 1); - lcd_puts_P(_T(MSG_UNLOADING_FILAMENT)); - lcd_print(" "); - lcd_print(mmu_extruder + 1); - - filament_ramming(); - - //mmu_command(MMU_CMD_U0); - // get response - manage_response(false, true); - - lcd_update_enable(true); -#else //SNMM - - lcd_clear(); - lcd_display_message_fullscreen_P(PSTR("")); - max_feedrate[E_AXIS] = 50; - lcd_set_cursor(0, 0); - lcd_puts_P(_T(MSG_UNLOADING_FILAMENT)); - lcd_print(" "); - lcd_print(mmu_extruder + 1); - 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); - } - - 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); - 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); - 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); - 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); - } - 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); - 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); - 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); - /*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 - 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*/ - 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); - 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); - st_synchronize(); - //st_current_init(); - if (SilentMode != SILENT_MODE_OFF) st_current_set(2, tmp_motor[2]); //set back to normal operation currents - else st_current_set(2, tmp_motor_loud[2]); - lcd_update_enable(true); - lcd_return_to_status(); - max_feedrate[E_AXIS] = 50; -#endif //SNMM - } - else - { - lcd_clear(); - lcd_set_cursor(0, 0); - lcd_puts_P(_T(MSG_ERROR)); - lcd_set_cursor(0, 2); - lcd_puts_P(_T(MSG_PREHEAT_NOZZLE)); - delay(2000); - lcd_clear(); - } - //lcd_return_to_status(); -} - -//wrapper functions for loading filament -void extr_adj_0() -{ -#ifndef SNMM - enquecommand_P(PSTR("M701 E0")); -#else - change_extr(0); - extr_adj(0); -#endif -} - -void extr_adj_1() -{ -#ifndef SNMM - enquecommand_P(PSTR("M701 E1")); -#else - change_extr(1); - extr_adj(1); -#endif -} - -void extr_adj_2() -{ -#ifndef SNMM - enquecommand_P(PSTR("M701 E2")); -#else - change_extr(2); - extr_adj(2); -#endif -} - -void extr_adj_3() -{ -#ifndef SNMM - enquecommand_P(PSTR("M701 E3")); -#else - change_extr(3); - extr_adj(3); -#endif -} - -void extr_adj_4() -{ -#ifndef SNMM - enquecommand_P(PSTR("M701 E4")); -#else - change_extr(4); - extr_adj(4); -#endif -} - -void mmu_eject_fil_0() -{ - mmu_eject_filament(0, true); -} - -void mmu_eject_fil_1() -{ - mmu_eject_filament(1, true); -} - -void mmu_eject_fil_2() -{ - mmu_eject_filament(2, true); -} - -void mmu_eject_fil_3() -{ - mmu_eject_filament(3, true); -} - -void mmu_eject_fil_4() -{ - mmu_eject_filament(4, true); -} - -void load_all() -{ -#ifndef SNMM - enquecommand_P(PSTR("M701 E0")); - enquecommand_P(PSTR("M701 E1")); - enquecommand_P(PSTR("M701 E2")); - enquecommand_P(PSTR("M701 E3")); - enquecommand_P(PSTR("M701 E4")); -#else - for (int i = 0; i < 4; i++) - { - change_extr(i); - extr_adj(i); - } -#endif -} - -//wrapper functions for changing extruders -void extr_change_0() -{ - change_extr(0); - lcd_return_to_status(); -} - -void extr_change_1() -{ - change_extr(1); - lcd_return_to_status(); -} - -void extr_change_2() -{ - change_extr(2); - lcd_return_to_status(); -} - -void extr_change_3() -{ - change_extr(3); - lcd_return_to_status(); -} - -//wrapper functions for unloading filament -void extr_unload_all() -{ - if (degHotend0() > EXTRUDE_MINTEMP) - { - for (int i = 0; i < 4; i++) - { - change_extr(i); - extr_unload(); - } - } - else - { - lcd_clear(); - lcd_set_cursor(0, 0); - lcd_puts_P(_T(MSG_ERROR)); - lcd_set_cursor(0, 2); - lcd_puts_P(_T(MSG_PREHEAT_NOZZLE)); - delay(2000); - lcd_clear(); - lcd_return_to_status(); - } -} - -//unloading just used filament (for snmm) -void extr_unload_used() -{ - if (degHotend0() > EXTRUDE_MINTEMP) { - for (int i = 0; i < 4; i++) { - if (snmm_filaments_used & (1 << i)) { - change_extr(i); - extr_unload(); - } - } - snmm_filaments_used = 0; - } - else { - lcd_clear(); - lcd_set_cursor(0, 0); - lcd_puts_P(_T(MSG_ERROR)); - lcd_set_cursor(0, 2); - lcd_puts_P(_T(MSG_PREHEAT_NOZZLE)); - delay(2000); - lcd_clear(); - lcd_return_to_status(); - } -} - -void extr_unload_0() -{ - change_extr(0); - extr_unload(); -} - -void extr_unload_1() -{ - change_extr(1); - extr_unload(); -} - -void extr_unload_2() -{ - change_extr(2); - extr_unload(); -} - -void extr_unload_3() -{ - change_extr(3); - extr_unload(); -} - -void extr_unload_4() -{ - change_extr(4); - extr_unload(); -} - -bool mmu_check_version() -{ - return (mmu_buildnr >= MMU_REQUIRED_FW_BUILDNR); -} - -void mmu_show_warning() -{ - printf_P(PSTR("MMU2 firmware version invalid. Required version: build number %d or higher."), MMU_REQUIRED_FW_BUILDNR); - kill(_i("Please update firmware in your MMU2. Waiting for reset.")); -} - -void mmu_eject_filament(uint8_t filament, bool recover) -{ - if (filament < 5) - { - - if (degHotend0() > EXTRUDE_MINTEMP) - { - st_synchronize(); - - { - LcdUpdateDisabler disableLcdUpdate; - lcd_clear(); - lcd_set_cursor(0, 1); - lcd_puts_P(_i("Ejecting filament")); - current_position[E_AXIS] -= 80; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2500 / 60, active_extruder); - st_synchronize(); - mmu_command(MMU_CMD_E0 + filament); - manage_response(false, false); - if (recover) - { - lcd_show_fullscreen_message_and_wait_P(_i("Please remove filament and then press the knob.")); - mmu_command(MMU_CMD_R0); - manage_response(false, false); - } - - } - } - else - { - lcd_clear(); - lcd_set_cursor(0, 0); - lcd_puts_P(_T(MSG_ERROR)); - lcd_set_cursor(0, 2); - lcd_puts_P(_T(MSG_PREHEAT_NOZZLE)); - delay(2000); - lcd_clear(); - } - } - else - { - puts_P(PSTR("Filament nr out of range!")); - } -} diff --git a/Firmware/mmu.h.orig b/Firmware/mmu.h.orig deleted file mode 100644 index 266210f0b..000000000 --- a/Firmware/mmu.h.orig +++ /dev/null @@ -1,104 +0,0 @@ -//mmu.h - -#include - - -extern bool mmu_enabled; -extern int8_t mmu_state; - -extern uint8_t mmu_extruder; - -extern uint8_t tmp_extruder; - -extern int8_t mmu_finda; - -extern int16_t mmu_version; -extern int16_t mmu_buildnr; - - -#define MMU_CMD_NONE 0 -#define MMU_CMD_T0 0x10 -#define MMU_CMD_T1 0x11 -#define MMU_CMD_T2 0x12 -#define MMU_CMD_T3 0x13 -#define MMU_CMD_T4 0x14 -#define MMU_CMD_L0 0x20 -#define MMU_CMD_L1 0x21 -#define MMU_CMD_L2 0x22 -#define MMU_CMD_L3 0x23 -#define MMU_CMD_L4 0x24 -#define MMU_CMD_C0 0x30 -#define MMU_CMD_U0 0x40 -#define MMU_CMD_E0 0x50 -#define MMU_CMD_E1 0x51 -#define MMU_CMD_E2 0x52 -#define MMU_CMD_E3 0x53 -#define MMU_CMD_E4 0x54 -#define MMU_CMD_R0 0x60 - - -extern int mmu_puts_P(const char* str); - -extern int mmu_printf_P(const char* format, ...); - -extern int8_t mmu_rx_echo(void); - -extern int8_t mmu_rx_ok(void); - -extern int8_t mmu_rx_not_ok(void); - -extern int8_t mmu_rx_sensFilatBoot(void); - -extern void mmu_init(void); - -extern void mmu_loop(void); - - -extern void mmu_reset(void); - -extern int8_t mmu_set_filament_type(uint8_t extruder, uint8_t filament); - -extern void mmu_command(uint8_t cmd); - -extern bool mmu_get_response(void); - -extern void manage_response(bool move_axes, bool turn_off_nozzle); - -extern void mmu_load_to_nozzle(); - -extern void mmu_M600_load_filament(bool automatic); -extern void mmu_M600_wait_and_beep(); - -extern void extr_mov(float shift, float feed_rate); -extern void change_extr(int extr); -extern int get_ext_nr(); -extern void display_loading(); -extern void extr_adj(int extruder); -extern void extr_unload(); -extern void extr_unload_at_boot(); -extern void extr_adj_0(); -extern void extr_adj_1(); -extern void extr_adj_2(); -extern void extr_adj_3(); -extern void extr_adj_4(); -extern void load_all(); -extern void extr_change_0(); -extern void extr_change_1(); -extern void extr_change_2(); -extern void extr_change_3(); -extern void extr_unload_all(); -extern void extr_unload_used(); -extern void extr_unload_0(); -extern void extr_unload_1(); -extern void extr_unload_2(); -extern void extr_unload_3(); -extern void extr_unload_4(); - -extern bool mmu_check_version(); -extern void mmu_show_warning(); -extern void mmu_eject_filament(uint8_t filament, bool recover); -extern void mmu_eject_fil_0(); -extern void mmu_eject_fil_1(); -extern void mmu_eject_fil_2(); -extern void mmu_eject_fil_3(); -extern void mmu_eject_fil_4();