From 3c13aac6407c3224e69610e97b0a1e19eba165bb Mon Sep 17 00:00:00 2001 From: Voinea Date: Sun, 7 Apr 2019 10:48:41 +0200 Subject: [PATCH] Disable MMU from menu Signed-off-by: Przemek Grondek --- Firmware/Marlin_main.cpp | 1009 +++++++++++++++++++------------------- Firmware/eeprom.h | 3 +- Firmware/mmu.cpp | 4 +- Firmware/ultralcd.cpp | 34 ++ Firmware/ultralcd.h | 1 + 5 files changed, 547 insertions(+), 504 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 266c193f..2676dde7 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -144,7 +144,7 @@ //Macro for print fan speed #define FAN_PULSE_WIDTH_LIMIT ((fanSpeed > 100) ? 3 : 4) //time in ms -//filament types +//filament types #define FILAMENT_DEFAULT 0 #define FILAMENT_FLEX 1 #define FILAMENT_PVA 2 @@ -300,7 +300,7 @@ float saved_start_position[NUM_AXIS] = {SAVED_START_POSITION_UNSET, 0, 0, 0}; uint16_t saved_segment_idx = 0; -// save/restore printing in case that mmu was not responding +// save/restore printing in case that mmu was not responding bool mmu_print_saved = false; // storing estimated time to end of print counted by slicer @@ -395,14 +395,14 @@ class AutoReportFeatures { uint8_t auto_report_period; public: LongTimer auto_report_timer; - AutoReportFeatures():auto_report_period(0){ + AutoReportFeatures():auto_report_period(0){ #if defined(AUTO_REPORT) - arFunctionsActive.byte = 0xff; + arFunctionsActive.byte = 0xff; #else arFunctionsActive.byte = 0; #endif //AUTO_REPORT } - + inline bool Temp()const { return arFunctionsActive.bits.temp != 0; } inline void SetTemp(uint8_t v){ arFunctionsActive.bits.temp = v; } @@ -411,9 +411,9 @@ public: inline bool Pos()const { return arFunctionsActive.bits.pos != 0; } inline void SetPos(uint8_t v){ arFunctionsActive.bits.pos = v; } - + inline void SetMask(uint8_t mask){ arFunctionsActive.byte = mask; } - + /// sets the autoreporting timer's period /// setting it to zero stops the timer void SetPeriod(uint8_t p){ @@ -424,7 +424,7 @@ public: auto_report_timer.stop(); } } - + inline void TimerStart() { auto_report_timer.start(); } inline bool TimerRunning()const { return auto_report_timer.running(); } inline bool TimerExpired() { return auto_report_timer.expired(auto_report_period * 1000ul); } @@ -834,7 +834,7 @@ void lcd_splash() } -void factory_reset() +void factory_reset() { KEEPALIVE_STATE(PAUSED_FOR_USER); if (!READ(BTN_ENC)) @@ -1088,7 +1088,7 @@ static void xflash_err_msg() } // "Setup" function is called by the Arduino framework on startup. -// Before startup, the Timers-functions (PWM)/Analog RW and HardwareSerial provided by the Arduino-code +// Before startup, the Timers-functions (PWM)/Analog RW and HardwareSerial provided by the Arduino-code // are initialized by the main() routine provided by the Arduino framework. void setup() { @@ -1096,7 +1096,12 @@ void setup() timer2_init(); // enables functional millis - mmu_init(); + MMU_Disabled_from_menu = eeprom_read_byte((uint8_t*)EEPROM_MMU_DISABLED_FROM_MENU); + if (MMU_Disabled_from_menu == 255) { + MMU_Disabled_from_menu = 0; + eeprom_write_byte((uint8_t*)EEPROM_MMU_DISABLED_FROM_MENU, MMU_Disabled_from_menu); + } + mmu_init(); ultralcd_init(); @@ -1280,13 +1285,13 @@ void setup() SERIAL_ECHOLN((int)sizeof(block_t)*BLOCK_BUFFER_SIZE); //lcd_update_enable(false); // why do we need this?? - andre // loads data from EEPROM if available else uses defaults (and resets step acceleration rate) - - bool previous_settings_retrieved = false; + + bool previous_settings_retrieved = false; uint8_t hw_changed = check_printer_version(); if (!(hw_changed & 0b10)) { //if printer version wasn't changed, check for eeprom version and retrieve settings from eeprom in case that version wasn't changed previous_settings_retrieved = Config_RetrieveSettings(); - } - else { //printer version was changed so use default settings + } + else { //printer version was changed so use default settings Config_ResetDefault(); } @@ -1373,7 +1378,7 @@ void setup() #endif //TMC2130 st_init(); // Initialize stepper, this enables interrupts! - + #ifdef TMC2130 tmc2130_mode = silentMode?TMC2130_MODE_SILENT:TMC2130_MODE_NORMAL; update_mode_profile(); @@ -1382,7 +1387,7 @@ void setup() #ifdef PSU_Delta init_force_z(); // ! important for correct Z-axis initialization #endif // PSU_Delta - + setup_photpin(); #if 0 @@ -1417,14 +1422,14 @@ void setup() enable_z(); #endif - // The farm monitoring SW may accidentally expect + // The farm monitoring SW may accidentally expect // 2 messages of "printer started" to consider a printer working. prusa_statistics(8); // Enable Toshiba FlashAir SD card / WiFi enahanced card. card.ToshibaFlashAir_enable(eeprom_read_byte((unsigned char*)EEPROM_TOSHIBA_FLASH_AIR_COMPATIBLITY) == 1); - // Force SD card update. Otherwise the SD card update is done from loop() on card.checkautostart(false), + // Force SD card update. Otherwise the SD card update is done from loop() on card.checkautostart(false), // but this times out if a blocking dialog is shown in setup(). card.initsd(); #ifdef DEBUG_SD_SPEED_TEST @@ -1545,25 +1550,25 @@ void setup() if (!farm_mode) { check_if_fw_is_on_right_printer(); #if 0 - show_fw_version_warnings(); + show_fw_version_warnings(); #endif } - switch (hw_changed) { + switch (hw_changed) { //if motherboard or printer type was changed inform user as it can indicate flashing wrong firmware version //if user confirms with knob, new hw version (printer and/or motherboard) is written to eeprom and message will be not shown next time - case(0b01): + case(0b01): lcd_show_fullscreen_message_and_wait_P(_i("Warning: motherboard type changed.")); ////MSG_CHANGED_MOTHERBOARD c=20 r=4 - eeprom_write_word((uint16_t*)EEPROM_BOARD_TYPE, MOTHERBOARD); + eeprom_write_word((uint16_t*)EEPROM_BOARD_TYPE, MOTHERBOARD); break; - case(0b10): + case(0b10): lcd_show_fullscreen_message_and_wait_P(_i("Warning: printer type changed.")); ////MSG_CHANGED_PRINTER c=20 r=4 - eeprom_write_word((uint16_t*)EEPROM_PRINTER_TYPE, PRINTER_TYPE); + eeprom_write_word((uint16_t*)EEPROM_PRINTER_TYPE, PRINTER_TYPE); break; - case(0b11): + case(0b11): lcd_show_fullscreen_message_and_wait_P(_i("Warning: both printer type and motherboard type changed.")); ////MSG_CHANGED_BOTH c=20 r=4 eeprom_write_word((uint16_t*)EEPROM_PRINTER_TYPE, PRINTER_TYPE); - eeprom_write_word((uint16_t*)EEPROM_BOARD_TYPE, MOTHERBOARD); + eeprom_write_word((uint16_t*)EEPROM_BOARD_TYPE, MOTHERBOARD); break; default: break; //no change, show no message } @@ -1664,27 +1669,27 @@ void setup() lcd_setstatuspgm(MSG_WELCOME); } */ - manage_heater(); // Update temperatures -#ifdef DEBUG_UVLO_AUTOMATIC_RECOVER + manage_heater(); // Update temperatures +#ifdef DEBUG_UVLO_AUTOMATIC_RECOVER printf_P(_N("Power panic detected!\nCurrent bed temp:%d\nSaved bed temp:%d\n"), (int)degBed(), eeprom_read_byte((uint8_t*)EEPROM_UVLO_TARGET_BED)); #endif - if ( degBed() > ( (float)eeprom_read_byte((uint8_t*)EEPROM_UVLO_TARGET_BED) - AUTOMATIC_UVLO_BED_TEMP_OFFSET) ){ - #ifdef DEBUG_UVLO_AUTOMATIC_RECOVER - puts_P(_N("Automatic recovery!")); + if ( degBed() > ( (float)eeprom_read_byte((uint8_t*)EEPROM_UVLO_TARGET_BED) - AUTOMATIC_UVLO_BED_TEMP_OFFSET) ){ + #ifdef DEBUG_UVLO_AUTOMATIC_RECOVER + puts_P(_N("Automatic recovery!")); #endif - recover_print(1); - } - else{ - #ifdef DEBUG_UVLO_AUTOMATIC_RECOVER - puts_P(_N("Normal recovery!")); - #endif - if ( lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_RECOVER_PRINT), false) ) recover_print(0); - else { - eeprom_update_byte((uint8_t*)EEPROM_UVLO, 0); - lcd_update_enable(true); - lcd_update(2); - lcd_setstatuspgm(MSG_WELCOME); - } + recover_print(1); + } + else{ + #ifdef DEBUG_UVLO_AUTOMATIC_RECOVER + puts_P(_N("Normal recovery!")); + #endif + if ( lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_RECOVER_PRINT), false) ) recover_print(0); + else { + eeprom_update_byte((uint8_t*)EEPROM_UVLO, 0); + lcd_update_enable(true); + lcd_update(2); + lcd_setstatuspgm(MSG_WELCOME); + } } } @@ -1818,13 +1823,13 @@ void loop() else if (usb_timer.expired(10000)) { //just need to check if it expired. Nothing else is needed to be done. ; } - + #ifdef PRUSA_M28 if (prusa_sd_card_upload) { //we read byte-by byte serial_read_stream(); - } + } else #endif { @@ -1862,7 +1867,7 @@ void loop() if (! cmdbuffer_front_already_processed && buflen) { // ptr points to the start of the block currently being processed. - // The first character in the block is the block type. + // The first character in the block is the block type. char *ptr = cmdbuffer + bufindr; if (*ptr == CMDBUFFER_CURRENT_TYPE_SDCARD) { // To support power panic, move the lenght of the command on the SD card to a planner buffer. @@ -1891,8 +1896,8 @@ void loop() sei(); } } - else if((*ptr == CMDBUFFER_CURRENT_TYPE_USB_WITH_LINENR) && !IS_SD_PRINTING){ - + else if((*ptr == CMDBUFFER_CURRENT_TYPE_USB_WITH_LINENR) && !IS_SD_PRINTING){ + cli(); *ptr ++ = CMDBUFFER_CURRENT_TYPE_TO_BE_REMOVED; // and one for each command to previous block in the planner queue. @@ -1900,7 +1905,7 @@ void loop() sei(); } // Now it is safe to release the already processed command block. If interrupted by the power panic now, - // this block's SD card length will not be counted twice as its command type has been replaced + // this block's SD card length will not be counted twice as its command type has been replaced // by CMDBUFFER_CURRENT_TYPE_TO_BE_REMOVED. cmdqueue_pop_front(); } @@ -1964,7 +1969,7 @@ static int setup_for_endstop_move(bool enable_endstops_now = true) { int l_feedmultiply = feedmultiply; feedmultiply = 100; previous_millis_cmd.start(); - + enable_endstops(enable_endstops_now); return l_feedmultiply; } @@ -1974,7 +1979,7 @@ static void clean_up_after_endstop_move(int original_feedmultiply) { #ifdef ENDSTOPS_ONLY_FOR_HOMING enable_endstops(false); #endif - + feedrate = saved_feedrate; feedmultiply = original_feedmultiply; previous_millis_cmd.start(); @@ -2150,7 +2155,7 @@ inline void gcode_M900() { bool check_commands() { bool end_command_found = false; - + while (buflen) { if ((code_seen_P(PSTR("M84"))) || (code_seen_P(PSTR("M 84")))) end_command_found = true; @@ -2159,7 +2164,7 @@ bool check_commands() { cmdbuffer_front_already_processed = false; } return end_command_found; - + } @@ -2375,7 +2380,7 @@ void homeaxis(uint8_t axis, uint8_t cnt) { #ifdef TMC2130 FORCE_HIGH_POWER_START; -#endif +#endif int axis_home_dir = home_dir(axis); current_position[axis] = 0; plan_set_position_curposXYZE(); @@ -2405,7 +2410,7 @@ void homeaxis(uint8_t axis, uint8_t cnt) axis_known_position[axis] = true; #ifdef TMC2130 FORCE_HIGH_POWER_END; -#endif +#endif } enable_endstops(endstops_enabled); } @@ -2615,9 +2620,9 @@ static void gcode_G28(bool home_x_axis, long home_x_value, bool home_y_axis, lon #ifdef ENABLE_AUTO_BED_LEVELING plan_bed_level_matrix.set_to_identity(); //Reset the plane ("erase" all leveling data) #endif //ENABLE_AUTO_BED_LEVELING - + // Reset world2machine_rotation_and_skew and world2machine_shift, therefore - // the planner will not perform any adjustments in the XY plane. + // the planner will not perform any adjustments in the XY plane. // Wait for the motors to stop and update the current position with the absolute values. world2machine_revert_to_uncorrected(); @@ -2682,7 +2687,7 @@ static void gcode_G28(bool home_x_axis, long home_x_value, bool home_y_axis, lon } #endif /* QUICK_HOME */ -#ifdef TMC2130 +#ifdef TMC2130 if(home_x) { if (!calib) @@ -2804,7 +2809,7 @@ static void gcode_G28(bool home_x_axis, long home_x_value, bool home_y_axis, lon if(home_z) current_position[Z_AXIS] += cs.zprobe_zoffset; //Add Z_Probe offset (the distance is negative) #endif - + // Set the planner and stepper routine positions. // At this point the mesh bed leveling and world2machine corrections are disabled and current_position // contains the machine coordinates. @@ -3293,9 +3298,9 @@ bool gcode_M45(bool onlyZ, int8_t verbosity_level) #ifdef TMC2130 FORCE_HIGH_POWER_START; #endif // TMC2130 - + FORCE_BL_ON_START; - + // Only Z calibration? if (!onlyZ) { @@ -3309,7 +3314,7 @@ bool gcode_M45(bool onlyZ, int8_t verbosity_level) // Let the planner use the uncorrected coordinates. mbl.reset(); // Reset world2machine_rotation_and_skew and world2machine_shift, therefore - // the planner will not perform any adjustments in the XY plane. + // the planner will not perform any adjustments in the XY plane. // Wait for the motors to stop and update the current position with the absolute values. world2machine_revert_to_uncorrected(); // Reset the baby step value applied without moving the axes. @@ -3339,7 +3344,7 @@ bool gcode_M45(bool onlyZ, int8_t verbosity_level) if (lcd_calibrate_z_end_stop_manual(onlyZ)) { #endif //TMC2130 - + lcd_show_fullscreen_message_and_wait_P(_T(MSG_CONFIRM_NOZZLE_CLEAN)); if(onlyZ){ lcd_display_message_fullscreen_P(_T(MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE1)); @@ -3369,7 +3374,7 @@ bool gcode_M45(bool onlyZ, int8_t verbosity_level) lcd_display_message_fullscreen_P(_T(MSG_FIND_BED_OFFSET_AND_SKEW_LINE1)); lcd_puts_at_P(0,3,_n("1/4")); } - + bool endstops_enabled = enable_endstops(false); current_position[Z_AXIS] -= 1; //move 1mm down with disabled endstop plan_buffer_line_curposXYZE(homing_feedrate[Z_AXIS] / 40); @@ -3444,7 +3449,7 @@ bool gcode_M45(bool onlyZ, int8_t verbosity_level) current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; plan_buffer_line_curposXYZE(homing_feedrate[Z_AXIS] / 40); st_synchronize(); - // if (result >= 0) babystep_apply(); + // if (result >= 0) babystep_apply(); #endif //HEATBED_V2 } //#endif //NEW_XYZCAL @@ -3479,9 +3484,9 @@ bool gcode_M45(bool onlyZ, int8_t verbosity_level) #ifdef TMC2130 FORCE_HIGH_POWER_END; #endif // TMC2130 - + FORCE_BL_ON_END; - + return final_result; } @@ -3513,7 +3518,7 @@ void gcode_M123() } #endif //FANCHECK and TACH_0 or TACH_1 -//! extracted code to compute z_shift for M600 in case of filament change operation +//! extracted code to compute z_shift for M600 in case of filament change operation //! requested from fsensors. //! The function ensures, that the printhead lifts to at least 25mm above the heat bed //! unlike the previous implementation, which was adding 25mm even when the head was @@ -3537,7 +3542,7 @@ static T gcode_M600_filament_change_z_shift() #else return T(0); #endif -} +} static void gcode_M600(bool automatic, float x_position, float y_position, float z_shift, float e_shift, float /*e_shift_late*/) { @@ -3670,7 +3675,7 @@ void gcode_M701() prusa_statistics(22); - if (mmu_enabled) + if (mmu_enabled) { extr_adj(tmp_extruder);//loads current extruder mmu_extruder = tmp_extruder; @@ -3695,7 +3700,7 @@ void gcode_M701() raise_z_above(MIN_Z_FOR_LOAD, false); current_position[E_AXIS] += feed_mm_before_raising; plan_buffer_line_curposXYZE(FILAMENTCHANGE_EFEED_FIRST); //fast sequence - + load_filament_final_feed(); //slow sequence st_synchronize(); @@ -3732,7 +3737,7 @@ void gcode_M701() * * Send command ;S to serial port 0 to retrieve serial number stored in 32U2 processor, * reply is stored in *SN. - * Operation takes typically 23 ms. If no valid SN can be retrieved within the 250ms window, the function aborts + * Operation takes typically 23 ms. If no valid SN can be retrieved within the 250ms window, the function aborts * and returns a general failure flag. * The command will fail if the 32U2 processor is unpowered via USB since it is isolated from the rest of the electronics. * In that case the value that is stored in the EEPROM should be used instead. @@ -3750,7 +3755,7 @@ static uint8_t get_PRUSA_SN(char* SN) selectedSerialPort = 0; timeout.start(); - + while (!SN_valid) { rxIndex = 0; @@ -3813,7 +3818,7 @@ static void gcode_PRUSA_BadRAMBoFanTest(){ if( tach1max < tachMeasure ) tach1max = tachMeasure; //printf_P(PSTR("TACH_1: %d: capacitor check time=%lu us\n"), (int)tach1cntr, tachMeasure); - } + } //printf_P(PSTR("TACH_1: max=%lu us\n"), tach1max); SERIAL_PROTOCOLPGM("RAMBo FAN "); if( tach1max > 500 ){ @@ -3905,10 +3910,10 @@ extern uint8_t st_backlash_y; //! look here for descriptions of G-codes: https://reprap.org/wiki/G-code //! //! -//! Implemented Codes +//! Implemented Codes //! ------------------- //! -//! * _This list is not updated. Current documentation is maintained inside the process_cmd function._ +//! * _This list is not updated. Current documentation is maintained inside the process_cmd function._ //! //!@n PRUSA CODES //!@n P F - Returns FW versions @@ -4043,7 +4048,7 @@ extern uint8_t st_backlash_y; /** \ingroup GCodes */ -//! _This is a list of currently implemented G Codes in Prusa firmware (dynamically generated from doxygen)._ +//! _This is a list of currently implemented G Codes in Prusa firmware (dynamically generated from doxygen)._ /** They are shown in order of appearance in the code. There are reasons why some G Codes aren't in numerical order. @@ -4062,7 +4067,7 @@ void process_commands() SERIAL_ECHO(buflen); SERIAL_ECHOLNPGM(""); #endif /* CMDBUFFER_DEBUG */ - + unsigned long codenum; //throw away variable char *starpos = NULL; #ifdef ENABLE_AUTO_BED_LEVELING @@ -4104,10 +4109,10 @@ void process_commands() #### Usage M0 [P] [string] - M1 [P] [S] [string] + M1 [P] [S] [string] #### Parameters - + - `P` - Expire time, in milliseconds - `S` - Expire time, in seconds - `string` - Must for M1 and optional for M0 message to display on the LCD @@ -4135,7 +4140,7 @@ void process_commands() // farmers want to abuse a bug from the previous firmware releases // - they need to see the filename on the status screen instead of "Wait for user..." // So we won't update the message in farm mode... - if( ! farm_mode){ + if( ! farm_mode){ LCD_MESSAGERPGM(_i("Wait for user..."));////MSG_USERWAIT c=20 } else { custom_message_type = CustomMsg::Status; // let the lcd display the name of the printed G-code file in farm mode @@ -4189,8 +4194,8 @@ void process_commands() } else if (strncmp_P(CMDBUFFER_CURRENT_STRING, PSTR("TMC_"), 4) == 0) { - - // ### TMC_SET_WAVE_ + + // ### TMC_SET_WAVE_ // -------------------- if (strncmp_P(CMDBUFFER_CURRENT_STRING + 4, PSTR("SET_WAVE_"), 9) == 0) { @@ -4202,7 +4207,7 @@ void process_commands() tmc2130_set_wave(axis, 247, fac); } } - + // ### TMC_SET_STEP_ // ------------------ else if (strncmp_P(CMDBUFFER_CURRENT_STRING + 4, PSTR("SET_STEP_"), 9) == 0) @@ -4270,29 +4275,29 @@ void process_commands() } #endif //BACKLASH_Y #endif //TMC2130 - else if(code_seen_P(PSTR("PRUSA"))){ + else if(code_seen_P(PSTR("PRUSA"))){ /*! --------------------------------------------------------------------------------- ### PRUSA - Internal command set G98: Activate farm mode - Notes - + Set of internal PRUSA commands #### Usage PRUSA [ PRN | FAN | thx | uvlo | MMURES | RESET | fv | M28 | SN | Fir | Rev | Lang | Lz | FR ] - + #### Parameters - `PRN` - Prints revision of the printer - `FAN` - Prints fan details - - `thx` - - `uvlo` + - `thx` + - `uvlo` - `MMURES` - Reset MMU - `RESET` - (Careful!) - `fv` - ? - - `M28` - - `SN` + - `M28` + - `SN` - `Fir` - Prints firmware version - `Rev`- Prints filament size, elelectronics, nozzle type - `Lang` - Reset the language - - `Lz` + - `Lz` - `FR` - Full factory reset - `nozzle set ` - set nozzle diameter (farm mode only), e.g. `PRUSA nozzle set 0.4` - `nozzle D` - check the nozzle diameter (farm mode only), works like M862.1 P, e.g. `PRUSA nozzle D0.4` @@ -4307,8 +4312,8 @@ void process_commands() printf_P(_N("E0:%d RPM\nPRN0:%d RPM\n"), 60*fan_speed[0], 60*fan_speed[1]); } else if (code_seen_P(PSTR("uvlo"))) { // PRUSA uvlo - eeprom_update_byte((uint8_t*)EEPROM_UVLO,0); - enquecommand_P(PSTR("M24")); + eeprom_update_byte((uint8_t*)EEPROM_UVLO,0); + enquecommand_P(PSTR("M24")); } else if (code_seen_P(PSTR("MMURES"))) // PRUSA MMURES { @@ -4425,7 +4430,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); gcode_level_check(nGcodeLevel); else SERIAL_PROTOCOLLN(GCODE_LEVEL); */ - } + } //else if (code_seen('Cal')) { // lcd_calibration(); // } @@ -4496,20 +4501,20 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); /*! --------------------------------------------------------------------------------- # G Codes - ### G0, G1 - Coordinated movement X Y Z E G0 & G1: Move + ### G0, G1 - Coordinated movement X Y Z E G0 & G1: Move In Prusa Firmware G0 and G1 are the same. #### Usage - + G0 [ X | Y | Z | E | F | S ] G1 [ X | Y | Z | E | F | S ] - + #### Parameters - `X` - The position to move to on the X axis - `Y` - The position to move to on the Y axis - `Z` - The position to move to on the Z axis - `E` - The amount to extrude between the starting point and ending point - `F` - The feedrate per minute of the move between the starting point and ending point (if supplied) - + */ case 0: // G0 -> G1 case 1: // G1 @@ -4543,14 +4548,14 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); /*! ### G2, G3 - Controlled Arc Move G2 & G3: Controlled Arc Move - + These commands don't propperly work with MBL enabled. The compensation only happens at the end of the move, so avoid long arcs. - + #### Usage - + G2 [ X | Y | I | E | F ] (Clockwise Arc) G3 [ X | Y | I | E | F ] (Counter-Clockwise Arc) - + #### Parameters - `X` - The position to move to on the X axis - `Y` - The position to move to on the Y axis @@ -4559,7 +4564,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); - `J` - The point in Y space from the current Y position to maintain a constant distance from - `E` - The amount to extrude between the starting point and ending point - `F` - The feedrate per minute of the move between the starting point and ending point (if supplied) - + */ case 2: case 3: @@ -4576,24 +4581,24 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); offset[0] = code_seen('I') ? code_value() : 0.f; offset[1] = code_seen('J') ? code_value() : 0.f; - + prepare_arc_move((gcode_in_progress == 2), start_segment_idx); } break; /*! ### G4 - Dwell G4: Dwell Pause the machine for a period of time. - + #### Usage - + G4 [ P | S ] - + #### Parameters - `P` - Time to wait, in milliseconds - `S` - Time to wait, in seconds - + */ - case 4: + case 4: codenum = 0; if(code_seen('P')) codenum = code_value(); // milliseconds to wait if(code_seen('S')) codenum = code_value() * 1000; // seconds to wait @@ -4620,7 +4625,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); ### G10 - Retract G10: Retract Retracts filament according to settings of `M207` */ - case 10: + case 10: #if EXTRUDERS > 1 retracted_swap[active_extruder]=(code_seen('S') && code_value_long() == 1); // checks for swap retract argument retract(true,retracted_swap[active_extruder]); @@ -4634,7 +4639,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); ### G11 - Retract recover G11: Unretract Unretracts/recovers filament according to settings of `M208` */ - case 11: + case 11: #if EXTRUDERS > 1 retract(false,retracted_swap[active_extruder]); #else @@ -4648,17 +4653,17 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); ### G21 - Sets Units to Millimters G21: Set Units to Millimeters Units are in millimeters. Prusa doesn't support inches. */ - case 21: + case 21: break; //Doing nothing. This is just to prevent serial UNKOWN warnings. - + /*! ### G28 - Home all Axes one at a time G28: Move to Origin (Home) Using `G28` without any parameters will perfom homing of all axes AND mesh bed leveling, while `G28 W` will just home all axes (no mesh bed leveling). #### Usage - + G28 [ X | Y | Z | W | C ] - + #### Parameters - `X` - Flag to go back to the X axis origin - `Y` - Flag to go back to the Y axis origin @@ -4666,7 +4671,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); - `W` - Suppress mesh bed leveling if `X`, `Y` or `Z` are not provided - `C` - Calibrate X and Y origin (home) - Only on MK3/s */ - case 28: + case 28: { long home_x_value = 0; long home_y_value = 0; @@ -4693,15 +4698,15 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); } #ifdef ENABLE_AUTO_BED_LEVELING - + /*! ### G29 - Detailed Z-Probe G29: Detailed Z-Probe In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code. - + See `G81` */ - case 29: + case 29: { #if Z_MIN_PIN == -1 #error "You must have a Z_MIN endstop in order to enable Auto Bed Leveling feature! Z_MIN_PIN must point to a valid hardware pin." @@ -4849,7 +4854,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); ### G30 - Single Z Probe G30: Single Z-Probe In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code. */ - case 30: + case 30: { st_synchronize(); // TODO: make sure the bed_level_rotation_matrix is identity or the planner will get set incorectly @@ -4876,7 +4881,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); ### G31 - Dock the sled G31: Dock Z Probe sled In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code. */ - case 31: + case 31: dock_sled(true); break; @@ -4885,12 +4890,12 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); ### G32 - Undock the sled G32: Undock Z Probe sled In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code. */ - case 32: + case 32: dock_sled(false); break; #endif // Z_PROBE_SLED #endif // ENABLE_AUTO_BED_LEVELING - + #ifdef MESH_BED_LEVELING /*! @@ -4898,7 +4903,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); Sensor must be over the bed. The maximum travel distance before an error is triggered is 10mm. */ - case 30: + case 30: { st_synchronize(); homing_flag = true; @@ -4916,7 +4921,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); homing_flag = false; } break; - + /*! ### G75 - Print temperature interpolation G75: Print temperature interpolation Show/print PINDA temperature interpolating. @@ -4933,7 +4938,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); This G-code is used to calibrate the temperature drift of the PINDA (inductive Sensor). The PINDAv2 sensor has a built-in thermistor which has the advantage that the calibration can be done once for all materials. - + The Original i3 Prusa MK2/s uses PINDAv1 and this calibration improves the temperature drift, but not as good as the PINDAv2. superPINDA sensor has internal temperature compensation and no thermistor output. There is no point of doing temperature calibration in such case. @@ -4941,17 +4946,17 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); This can be caused also if PINDA thermistor connection is broken or PINDA temperature is lower than PINDA_MINTEMP. #### Example - + ``` G76 - + echo PINDA probe calibration start echo start temperature: 35.0° echo ... echo PINDA temperature -- Z shift (mm): 0.--- ``` */ - case 76: + case 76: { #ifdef PINDA_THERMISTOR if (!has_temperature_compensation()) @@ -5132,18 +5137,18 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); current_position[Z_AXIS] = PINDA_PREHEAT_Z; plan_buffer_line_curposXYZE(3000 / 60); st_synchronize(); - + while (fabs(degBed() - PINDA_MIN_T) > 1) { delay_keep_alive(1000); serialecho_temperatures(); } - + //enquecommand_P(PSTR("M190 S50")); for (int i = 0; i < PINDA_HEAT_T; i++) { delay_keep_alive(1000); serialecho_temperatures(); } - eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 0); //invalidate temp. calibration in case that in will be aborted during the calibration process + eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 0); //invalidate temp. calibration in case that in will be aborted during the calibration process current_position[Z_AXIS] = 5; plan_buffer_line_curposXYZE(3000 / 60); @@ -5152,7 +5157,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); current_position[Y_AXIS] = BED_Y0; plan_buffer_line_curposXYZE(3000 / 60); st_synchronize(); - + find_bed_induction_sensor_point_z(-1.f); zero_z = current_position[Z_AXIS]; @@ -5189,8 +5194,8 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); printf_P(_N("\nTemperature: %d Z shift (mm): %.3f\n"), t_c, current_position[Z_AXIS] - zero_z); eeprom_update_word((uint16_t*)EEPROM_PROBE_TEMP_SHIFT + i, z_shift); - - + + } custom_message_type = CustomMsg::Status; @@ -5206,9 +5211,9 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); lcd_show_fullscreen_message_and_wait_P(_T(MSG_PINDA_CALIBRATION_DONE)); eeprom_update_byte((unsigned char *)EEPROM_TEMP_CAL_ACTIVE, 1); lcd_update_enable(true); - lcd_update(2); + lcd_update(2); + - #endif //PINDA_THERMISTOR } break; @@ -5218,14 +5223,14 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); ### G80 - Mesh-based Z probe G80: Mesh-based Z probe Default 3x3 grid can be changed on MK2.5/s and MK3/s to 7x7 grid. #### Usage - + G80 [ N | R | V | L | R | F | B ] - + #### Parameters - `N` - Number of mesh points on x axis. Default is 3. Valid values are 3 and 7. - `R` - Probe retries. Default 3 max. 10 - `V` - Verbosity level 1=low, 10=mid, 20=high. It only can be used if the firmware has been compiled with SUPPORT_VERBOSITY active. - + Using the following parameters enables additional "manual" bed leveling correction. Valid values are -100 microns to 100 microns. #### Additional Parameters - `L` - Left Bed Level correct value in um. @@ -5233,7 +5238,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); - `F` - Front Bed Level correct value in um. - `B` - Back Bed Level correct value in um. */ - + /* * Probes a grid and produces a mesh to compensate for variable bed height * The S0 report the points as below @@ -5272,11 +5277,11 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); else SERIAL_PROTOCOLLNPGM("Mesh bed leveling not active."); break; - + #if 0 /*! ### G82: Single Z probe at current location - Not active G82: Single Z probe at current location - + WARNING! USE WITH CAUTION! If you'll try to probe where is no leveling pad, nasty things can happen! In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code. */ @@ -5298,7 +5303,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); { int babystepz = code_seen('S') ? code_value() : 0; int BabyPosition = code_seen('P') ? code_value() : 0; - + if (babystepz != 0) { //FIXME Vojtech: What shall be the index of the axis Z: 3 or 4? // Is the axis indexed starting with zero or one? @@ -5311,9 +5316,9 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); // adjust the Z babystepsTodoZadd(babystepLoadZ); } - + } - + } break; /*! @@ -5324,7 +5329,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); babystepsTodoZsubtract(babystepLoadZ); // babystepLoadZ = 0; break; - + /*! ### G85: Pick best babystep - Not active G85: Pick best babystep In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code. @@ -5333,21 +5338,21 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); lcd_pick_babystep(); break; #endif - + /*! ### G86 - Disable babystep correction after home G86: Disable babystep correction after home - + This G-code will be performed at the start of a calibration script. (Prusa3D specific) */ case 86: calibration_status_clear(CALIBRATION_STATUS_LIVE_ADJUST); break; - + /*! ### G87 - Enable babystep correction after home G87: Enable babystep correction after home - + This G-code will be performed at the end of a calibration script. (Prusa3D specific) */ @@ -5357,8 +5362,8 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); /*! ### G88 - Reserved G88: Reserved - - Currently has no effect. + + Currently has no effect. */ // Prusa3D specific: Don't know what it is for, it is in V2Calibration.gcode @@ -5368,7 +5373,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); #endif // ENABLE_MESH_BED_LEVELING - + /*! ### G90 - Switch off relative mode G90: Set to Absolute Positioning @@ -5390,22 +5395,22 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); /*! ### G92 - Set position G92: Set Position - + It is used for setting the current position of each axis. The parameters are always absolute to the origin. If a parameter is omitted, that axis will not be affected. If `X`, `Y`, or `Z` axis are specified, the move afterwards might stutter because of Mesh Bed Leveling. `E` axis is not affected if the target position is 0 (`G92 E0`). A G92 without coordinates will reset all axes to zero on some firmware. This is not the case for Prusa-Firmware! - + #### Usage - + G92 [ X | Y | Z | E ] - + #### Parameters - `X` - new X axis position - `Y` - new Y axis position - `Z` - new Z axis position - `E` - new extruder position - + */ case 92: { gcode_G92(); @@ -5442,7 +5447,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); /*! --------------------------------------------------------------------------------- # M Commands - + */ else if(code_seen('M')) @@ -5450,7 +5455,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); int index; for (index = 1; *(strchr_pointer + index) == ' ' || *(strchr_pointer + index) == '\t'; index++); - + /*for (++strchr_pointer; *strchr_pointer == ' ' || *strchr_pointer == '\t'; ++strchr_pointer);*/ if (*(strchr_pointer+index) < '0' || *(strchr_pointer+index) > '9') { printf_P(PSTR("Invalid M code: %s\n"), cmdbuffer + bufindr + CMDHDRSIZE); @@ -5482,7 +5487,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); /*! ### M20 - SD Card file list M20: List SD card #### Usage - + M20 [ L | T ] #### Parameters - `T` - Report timestamps as well. The value is one uint32_t encoded as hex. Requires host software parsing (Cap:EXTENDED_M20). @@ -5505,18 +5510,18 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); /*! ### M22 - Release SD card M22: Release SD card */ - case 22: + case 22: card.release(); break; /*! ### M23 - Select file M23: Select SD file #### Usage - + M23 [filename] - + */ - case 23: + case 23: starpos = (strchr(strchr_pointer + 4,'*')); if(starpos!=NULL) *(starpos)='\0'; @@ -5552,13 +5557,13 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); This command is expected to be called after M23 and before M24. Otherwise effect of this command is undefined. #### Usage - + M26 [ S ] - + #### Parameters - `S` - Index in bytes */ - case 26: + case 26: if(card.cardOK && code_seen('S')) { long index = code_value_long(); card.setIndex(index); @@ -5571,9 +5576,9 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); /*! ### M27 - Get SD status M27: Report SD print status #### Usage - + M27 [ P ] - + #### Parameters - `P` - Show full SFN path instead of LFN only. */ @@ -5584,7 +5589,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); /*! ### M28 - Start SD write M28: Begin write to SD card */ - case 28: + case 28: starpos = (strchr(strchr_pointer + 4,'*')); if(starpos != NULL){ char* npos = strchr(CMDBUFFER_CURRENT_STRING, 'N'); @@ -5605,9 +5610,9 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); /*! ### M30 - Delete file M30: Delete a file on the SD card #### Usage - + M30 [filename] - + */ case 30: if (card.cardOK){ @@ -5676,11 +5681,11 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); /*! ### M928 - Start SD logging M928: Start SD logging #### Usage - + M928 [filename] - + */ - case 928: + case 928: starpos = (strchr(strchr_pointer + 5,'*')); if(starpos != NULL){ char* npos = strchr(CMDBUFFER_CURRENT_STRING, 'N'); @@ -5714,13 +5719,13 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); /*! ### M42 - Set pin state M42: Switch I/O pin #### Usage - + M42 [ P | S ] - + #### Parameters - `P` - Pin number. - `S` - Pin value. If the pin is analog, values are from 0 to 255. If the pin is digital, values are from 0 to 1. - + */ case 42: if (code_seen('S')) @@ -5765,7 +5770,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); reset_bed_offset_and_skew(); // Reset world2machine_rotation_and_skew and world2machine_shift, therefore - // the planner will not perform any adjustments in the XY plane. + // the planner will not perform any adjustments in the XY plane. // Wait for the motors to stop and update the current position with the absolute values. world2machine_revert_to_uncorrected(); break; @@ -5773,7 +5778,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); /*! ### M45 - Bed skew and offset with manual Z up M45: Bed skew and offset with manual Z up #### Usage - + M45 [ V ] #### Parameters - `V` - Verbosity level 1, 10 and 20 (low, mid, high). Only when SUPPORT_VERBOSITY is defined. Optional. @@ -5813,10 +5818,10 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); SERIAL_PROTOCOL('.'); SERIAL_PROTOCOLLN(uint8_t(ip[3])); } else { - SERIAL_PROTOCOLPGM("?Toshiba FlashAir GetIP failed\n"); + SERIAL_PROTOCOLPGM("?Toshiba FlashAir GetIP failed\n"); } } else { - SERIAL_PROTOCOLLNPGM("n/a"); + SERIAL_PROTOCOLLNPGM("n/a"); } break; } @@ -5825,7 +5830,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); ### M47 - Show end stops dialog on the display M47: Show end stops dialog on the display */ case 47: - + KEEPALIVE_STATE(PAUSED_FOR_USER); lcd_diag_show_end_stops(); KEEPALIVE_STATE(IN_HANDLER); @@ -5839,7 +5844,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); // Let the planner use the uncorrected coordinates. mbl.reset(); // Reset world2machine_rotation_and_skew and world2machine_shift, therefore - // the planner will not perform any adjustments in the XY plane. + // the planner will not perform any adjustments in the XY plane. // Wait for the motors to stop and update the current position with the absolute values. world2machine_revert_to_uncorrected(); // Move the print head close to the bed. @@ -5869,20 +5874,20 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); #ifdef ENABLE_AUTO_BED_LEVELING -#ifdef Z_PROBE_REPEATABILITY_TEST +#ifdef Z_PROBE_REPEATABILITY_TEST /*! ### M48 - Z-Probe repeatability measurement function M48: Measure Z-Probe repeatability - + This function assumes the bed has been homed. Specifically, that a G28 command as been issued prior to invoking the M48 Z-Probe repeatability measurement function. Any information generated by a prior G29 Bed leveling command will be lost and needs to be regenerated. - + The number of samples will default to 10 if not specified. You can use upper or lower case letters for any of the options EXCEPT n. n must be in lower case because Marlin uses a capital N for its communication protocol and will get horribly confused if you send it a capital N. @todo Why would you check for both uppercase and lowercase? Seems wasteful. - + #### Usage - + M48 [ n | X | Y | V | L ] - + #### Parameters - `n` - Number of samples. Valid values 4-50 - `X` - X position for samples @@ -5896,14 +5901,14 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); #error "You must have a Z_MIN endstop in order to enable calculation of Z-Probe repeatability." #endif - double sum=0.0; - double mean=0.0; + double sum=0.0; + double mean=0.0; double sigma=0.0; double sample_set[50]; int verbose_level=1, n=0, j, n_samples = 10, n_legs=0; double X_current, Y_current, Z_current; double X_probe_location, Y_probe_location, Z_start_location, ext_position; - + if (code_seen('V') || code_seen('v')) { verbose_level = code_value(); if (verbose_level<0 || verbose_level>4 ) { @@ -5949,7 +5954,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); if (code_seen('L') || code_seen('l') ) { n_legs = code_value(); - if ( n_legs==1 ) + if ( n_legs==1 ) n_legs = 2; if ( n_legs<0 || n_legs>15 ) { SERIAL_PROTOCOLPGM("?Specified number of legs in movement not plausable.\n"); @@ -5971,10 +5976,10 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); // // Now get everything to the specified probe point So we can safely do a probe to -// get us close to the bed. If the Z-Axis is far from the bed, we don't want to +// get us close to the bed. If the Z-Axis is far from the bed, we don't want to // use that as a starting point for each probe. // - if (verbose_level > 2) + if (verbose_level > 2) SERIAL_PROTOCOL("Positioning probe for the test.\n"); plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, @@ -5988,7 +5993,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); current_position[Z_AXIS] = Z_current = st_get_position_mm(Z_AXIS); current_position[E_AXIS] = ext_position = st_get_position_mm(E_AXIS); -// +// // OK, do the inital probe to get us close to the bed. // Then retrace the right amount and use that in subsequent probes // @@ -6015,7 +6020,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); int rotational_direction, l; rotational_direction = (unsigned long) _millis() & 0x0001; // clockwise or counter clockwise - radius = (unsigned long) _millis() % (long) (X_MAX_LENGTH/4); // limit how far out to go + radius = (unsigned long) _millis() % (long) (X_MAX_LENGTH/4); // limit how far out to go theta = (float) ((unsigned long) _millis() % (long) 360) / (360./(2*3.1415926)); // turn into radians //SERIAL_ECHOPAIR("starting radius: ",radius); @@ -6065,7 +6070,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); // // Get the current mean for the data points we have so far // - sum=0.0; + sum=0.0; for( j=0; j<=n; j++) { sum = sum + sample_set[j]; } @@ -6075,7 +6080,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); // data points we have so far // - sum=0.0; + sum=0.0; for( j=0; j<=n; j++) { sum = sum + (sample_set[j]-mean) * (sample_set[j]-mean); } @@ -6097,10 +6102,10 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); SERIAL_PROTOCOL_F(sigma,6); } - if (verbose_level > 0) + if (verbose_level > 0) SERIAL_PROTOCOLPGM("\n"); - plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, + plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, current_position[E_AXIS], homing_feedrate[Z_AXIS]/60, active_extruder); st_synchronize(); @@ -6125,13 +6130,13 @@ SERIAL_PROTOCOLPGM("\n\n"); Sigma_Exit: break; } -#endif // Z_PROBE_REPEATABILITY_TEST +#endif // Z_PROBE_REPEATABILITY_TEST #endif // ENABLE_AUTO_BED_LEVELING /*! ### M73 - Set/get print progress M73: Set/Get build percentage #### Usage - + M73 [ P | R | Q | S | C | D ] #### Parameters @@ -6166,9 +6171,9 @@ Sigma_Exit: /*! ### M104 - Set hotend temperature M104: Set Extruder Temperature #### Usage - + M104 [ S ] - + #### Parameters - `S` - Target temperature */ @@ -6189,27 +6194,27 @@ Sigma_Exit: ### M112 - Emergency stop M112: Full (Emergency) Stop It is processed much earlier as to bypass the cmdqueue. */ - case 112: + case 112: kill(MSG_M112_KILL, 3); break; /*! ### M140 - Set bed temperature M140: Set Bed Temperature (Fast) #### Usage - + M140 [ S ] - + #### Parameters - `S` - Target temperature */ - case 140: + case 140: if (code_seen('S')) setTargetBed(code_value()); break; /*! ### M105 - Report temperatures M105: Get Extruder Temperature Prints temperatures: - + - `T:` - Hotend (actual / target) - `B:` - Bed (actual / target) - `Tx:` - x Tool (actual / target) @@ -6217,11 +6222,11 @@ Sigma_Exit: - `B@:` - Bed power - `P:` - PINDAv2 actual (only MK2.5/s and MK3/s) - `A:` - Ambient actual (only MK3/s) - + _Example:_ - + ok T:20.2 /0.0 B:19.1 /0.0 T0:20.2 /0.0 @:0 B@:0 P:19.8 A:26.4 - + */ case 105: { @@ -6229,13 +6234,13 @@ Sigma_Exit: if(setTargetedHotend(105, extruder)){ break; } - + SERIAL_PROTOCOLPGM("ok "); gcode_M105(extruder); - + cmdqueue_pop_front(); //prevent an ok after the command since this command uses an ok at the beginning. cmdbuffer_front_already_processed = true; - + break; } @@ -6243,11 +6248,11 @@ Sigma_Exit: /*! ### M155 - Automatically send status M155: Automatically send temperatures #### Usage - + M155 [ S ] [ C ] - + #### Parameters - + - `S` - Set autoreporting interval in seconds. 0 to disable. Maximum: 255 - `C` - Activate auto-report function (bit mask). Default is temperature. @@ -6277,15 +6282,15 @@ Sigma_Exit: /*! ### M109 - Wait for extruder temperature M109: Set Extruder Temperature and Wait #### Usage - + M104 [ B | R | S ] - + #### Parameters (not mandatory) - + - `S` - Set extruder temperature - `R` - Set extruder temperature - `B` - Set max. extruder temperature, while `S` is min. temperature. Not active in default, only if AUTOTEMP is defined in source code. - + Parameters S and R are treated identically. Command always waits for both cool down and heat up. If no parameters are supplied waits for previously set extruder temperature. @@ -6330,7 +6335,7 @@ Sigma_Exit: LCD_MESSAGERPGM(_T(MSG_HEATING_COMPLETE)); heating_status = HeatingStatus::EXTRUDER_HEATING_COMPLETE; prusa_statistics(2); - + //starttime=_millis(); previous_millis_cmd.start(); } @@ -6339,34 +6344,34 @@ Sigma_Exit: /*! ### M190 - Wait for bed temperature M190: Wait for bed temperature to reach target temp #### Usage - + M190 [ R | S ] - + #### Parameters (not mandatory) - + - `S` - Set extruder temperature and wait for heating - `R` - Set extruder temperature and wait for heating or cooling - + If no parameter is supplied, waits for heating or cooling to previously set temperature. */ - case 190: + case 190: #if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1 { bool CooldownNoWait = false; LCD_MESSAGERPGM(_T(MSG_BED_HEATING)); heating_status = HeatingStatus::BED_HEATING; prusa_statistics(1); - if (code_seen('S')) + if (code_seen('S')) { setTargetBed(code_value()); CooldownNoWait = true; - } - else if (code_seen('R')) + } + else if (code_seen('R')) { setTargetBed(code_value()); } codenum = _millis(); - + cancel_heatup = false; target_direction = isHeatingBed(); // true if heating, false if cooling @@ -6385,7 +6390,7 @@ Sigma_Exit: SERIAL_PROTOCOLLN(); } codenum = _millis(); - + } manage_heater(); manage_inactivity(); @@ -6404,9 +6409,9 @@ Sigma_Exit: /*! ### M106 - Set fan speed M106: Fan On #### Usage - + M106 [ S ] - + #### Parameters - `S` - Specifies the duty cycle of the print fan. Allowed values are 0-255. If it's omitted, a value of 255 is used. */ @@ -6454,7 +6459,7 @@ Sigma_Exit: ### M81 - Turn off Power Supply M81: ATX Power Off Only works if the firmware is compiled with PS_ON_PIN defined. */ - case 81: + case 81: disable_heater(); st_synchronize(); disable_e0(); @@ -6496,11 +6501,11 @@ Sigma_Exit: ### M84 - Disable steppers M84: Stop idle hold This command can be used to set the stepper inactivity timeout (`S`) or to disable steppers (`X`,`Y`,`Z`,`E`) This command can be used without any additional parameters. In that case all steppers are disabled. - + The file completeness check uses this parameter to detect an incomplete file. It has to be present at the end of a file with no parameters. - + M84 [ S | X | Y | Z | E ] - + - `S` - Seconds - `X` - X axis - `Y` - Y axis @@ -6546,9 +6551,9 @@ Sigma_Exit: /*! ### M85 - Set max inactive time M85: Set Inactivity Shutdown Timer #### Usage - + M85 [ S ] - + #### Parameters - `S` - specifies the time in seconds. If a value of 0 is specified, the timer is disabled. */ @@ -6560,16 +6565,16 @@ Sigma_Exit: #ifdef SAFETYTIMER /*! - ### M86 - Set safety timer expiration time M86: Set Safety Timer expiration time + ### M86 - Set safety timer expiration time M86: Set Safety Timer expiration time When safety timer expires, heatbed and nozzle target temperatures are set to zero. #### Usage - + M86 [ S ] - + #### Parameters - `S` - specifies the time in seconds. If a value of 0 is specified, the timer is disabled. */ - case 86: + case 86: if (code_seen('S')) { safetytimer_inactive_time = code_value() * 1000; safetyTimer.start(); @@ -6581,9 +6586,9 @@ Sigma_Exit: ### M92 Set Axis steps-per-unit M92: Set axis_steps_per_unit Allows programming of steps per unit (usually mm) for motor drives. These values are reset to firmware defaults on power on, unless saved to EEPROM if available (M500 in Marlin) #### Usage - + M92 [ X | Y | Z | E ] - + #### Parameters - `X` - Steps per unit for the X drive - `Y` - Steps per unit for the Y drive @@ -6620,9 +6625,9 @@ Sigma_Exit: ### M110 - Set Line number M110: Set Current Line Number Sets the line number in G-code #### Usage - + M110 [ N ] - + #### Parameters - `N` - Line number */ @@ -6635,9 +6640,9 @@ Sigma_Exit: ### M113 - Get or set host keep-alive interval M113: Host Keepalive During some lengthy processes, such as G29, Marlin may appear to the host to have “gone away.” The “host keepalive” feature will send messages to the host when Marlin is busy or waiting for user response so the host won’t try to reconnect (or disconnect). #### Usage - + M113 [ S ] - + #### Parameters - `S` - Seconds. Default is 2 seconds between "busy" messages */ @@ -6658,27 +6663,27 @@ Sigma_Exit: Print the firmware info and capabilities Without any arguments, prints Prusa firmware version number, machine type, extruder count and UUID. `M115 U` Checks the firmware version provided. If the firmware version provided by the U code is higher than the currently running firmware, it will pause the print for 30s and ask the user to upgrade the firmware. - + _Examples:_ - + `M115` results: - + `FIRMWARE_NAME:Prusa-Firmware 3.8.1 based on Marlin FIRMWARE_URL:https://github.com/prusa3d/Prusa-Firmware PROTOCOL_VERSION:1.0 MACHINE_TYPE:Prusa i3 MK3S EXTRUDER_COUNT:1 UUID:00000000-0000-0000-0000-000000000000` - + `M115 V` results: - + `3.8.1` - + `M115 U3.8.2-RC1` results on LCD display for 30s or user interaction: - + `New firmware version available: 3.8.2-RC1 Please upgrade.` #### Usage - + M115 [ V | U ] - + #### Parameters - V - Report current installed firmware version - - U - Firmware version provided by G-code to be compared to current one. + - U - Firmware version provided by G-code to be compared to current one. */ case 115: // M115 if (code_seen('V')) { @@ -6694,10 +6699,10 @@ Sigma_Exit: SERIAL_ECHOPGM(" based on Marlin FIRMWARE_URL:https://github.com/prusa3d/Prusa-Firmware PROTOCOL_VERSION:"); SERIAL_ECHOPGM(PROTOCOL_VERSION); SERIAL_ECHOPGM(" MACHINE_TYPE:"); - SERIAL_ECHOPGM(CUSTOM_MENDEL_NAME); - SERIAL_ECHOPGM(" EXTRUDER_COUNT:"); - SERIAL_ECHOPGM(STRINGIFY(EXTRUDERS)); - SERIAL_ECHOPGM(" UUID:"); + SERIAL_ECHOPGM(CUSTOM_MENDEL_NAME); + SERIAL_ECHOPGM(" EXTRUDER_COUNT:"); + SERIAL_ECHOPGM(STRINGIFY(EXTRUDERS)); + SERIAL_ECHOPGM(" UUID:"); SERIAL_ECHOLNPGM(MACHINE_UUID); #ifdef EXTENDED_CAPABILITIES_REPORT extended_capabilities_report(); @@ -6712,7 +6717,7 @@ Sigma_Exit: gcode_M114(); break; - + /* M117 moved up to get the high priority @@ -6808,7 +6813,7 @@ Sigma_Exit: ### M123 - Tachometer value M123: Tachometer value This command is used to report fan speeds and fan pwm values. #### Usage - + M123 - E0: - Hotend fan speed in RPM @@ -6831,9 +6836,9 @@ Sigma_Exit: ### M150 - Set RGB(W) Color M150: Set LED color In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code by defining BLINKM and its dependencies. #### Usage - + M150 [ R | U | B ] - + #### Parameters - `R` - Red color value - `U` - Green color value. It is NOT `G`! @@ -6857,9 +6862,9 @@ Sigma_Exit: /*! ### M200 - Set filament diameter M200: Set filament diameter #### Usage - + M200 [ D | T ] - + #### Parameters - `D` - Diameter in mm - `T` - Number of extruder (MMUs) @@ -6991,18 +6996,18 @@ Sigma_Exit: #### Old format: ##### Usage - + M204 [ S | T ] - + ##### Parameters - `S` - normal moves - `T` - filmanent only moves - + #### New format: ##### Usage - + M204 [ P | R | T ] - + ##### Parameters - `P` - printing moves - `R` - filmanent only moves @@ -7034,9 +7039,9 @@ Sigma_Exit: ### M205 - Set advanced settings M205: Advanced settings Set some advanced settings related to movement. #### Usage - + M205 [ S | T | B | X | Y | Z | E ] - + #### Parameters - `S` - Minimum feedrate for print moves (unit/s) - `T` - Minimum feedrate for travel moves (units/s) @@ -7046,7 +7051,7 @@ Sigma_Exit: - `Z` - Maximum Z jerk (units/s) - `E` - Maximum E jerk (units/s) */ - case 205: + case 205: { if(code_seen('S')) cs.minimumfeedrate = code_value(); if(code_seen('T')) cs.mintravelfeedrate = code_value(); @@ -7068,9 +7073,9 @@ Sigma_Exit: /*! ### M206 - Set additional homing offsets M206: Offset axes #### Usage - + M206 [ X | Y | Z ] - + #### Parameters - `X` - X axis offset - `Y` - Y axis offset @@ -7088,9 +7093,9 @@ Sigma_Exit: /*! ### M207 - Set firmware retraction M207: Set retract length #### Usage - + M207 [ S | F | Z ] - + #### Parameters - `S` - positive length to retract, in mm - `F` - retraction feedrate, in mm/min @@ -7115,9 +7120,9 @@ Sigma_Exit: /*! ### M208 - Set retract recover length M208: Set unretract length #### Usage - + M208 [ S | F ] - + #### Parameters - `S` - positive length surplus to the M207 Snnn, in mm - `F` - feedrate, in mm/sec @@ -7138,9 +7143,9 @@ Sigma_Exit: ### M209 - Enable/disable automatict retract M209: Enable automatic retract This boolean value S 1=true or 0=false enables automatic retract detect if the slicer did not support G10/G11: every normal extrude-only move will be classified as retract depending on the direction. #### Usage - + M209 [ S ] - + #### Parameters - `S` - 1=true or 0=false */ @@ -7150,7 +7155,7 @@ Sigma_Exit: { switch(code_value_uint8()) { - case 0: + case 0: { cs.autoretract_enabled=false; retracted[0]=false; @@ -7161,7 +7166,7 @@ Sigma_Exit: retracted[2]=false; #endif }break; - case 1: + case 1: { cs.autoretract_enabled=true; retracted[0]=false; @@ -7227,9 +7232,9 @@ Sigma_Exit: ### M218 - Set hotend offset M218: Set Hotend Offset In Prusa Firmware this G-code is only active if `EXTRUDERS` is higher then 1 in the source code. On Original i3 Prusa MK2/s MK2.5/s MK3/s it is not active. #### Usage - + M218 [ X | Y ] - + #### Parameters - `X` - X offset - `Y` - Y offset @@ -7264,9 +7269,9 @@ Sigma_Exit: /*! ### M220 Set feedrate percentage M220: Set speed factor override percentage #### Usage - + M220 [ B | S | R ] - + #### Parameters - `B` - Backup current speed factor - `S` - Speed factor override percentage (0..100 or higher) @@ -7300,9 +7305,9 @@ Sigma_Exit: /*! ### M221 - Set extrude factor override percentage M221: Set extrude factor override percentage #### Usage - + M221 [ S | T ] - + #### Parameters - `S` - Extrude factor override percentage (0..100 or higher), default 100% - `T` - Extruder drive number (Prusa Firmware only), default 0 if not set. @@ -7336,9 +7341,9 @@ Sigma_Exit: ### M226 - Wait for Pin state M226: Wait for pin state Wait until the specified pin reaches the state required #### Usage - + M226 [ P | S ] - + #### Parameters - `P` - pin number - `S` - pin state @@ -7401,9 +7406,9 @@ Sigma_Exit: ### M280 - Set/Get servo position M280: Set servo position In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code. #### Usage - + M280 [ P | S ] - + #### Parameters - `P` - Servo index (id) - `S` - Target position @@ -7449,9 +7454,9 @@ Sigma_Exit: ### M300 - Play tone M300: Play beep sound In Prusa Firmware the defaults are `100Hz` and `1000ms`, so that `M300` without parameters will beep for a second. #### Usage - + M300 [ S | P ] - + #### Parameters - `S` - frequency in Hz. Not all firmware versions support this parameter - `P` - duration in milliseconds @@ -7482,9 +7487,9 @@ Sigma_Exit: Sets Proportional (P), Integral (I) and Derivative (D) values for hot end. See also PID Tuning. #### Usage - + M301 [ P | I | D ] - + #### Parameters - `P` - proportional (Kp) - `I` - integral (Ki) @@ -7515,9 +7520,9 @@ Sigma_Exit: Sets Proportional (P), Integral (I) and Derivative (D) values for bed. See also PID Tuning. #### Usage - + M304 [ P | I | D ] - + #### Parameters - `P` - proportional (Kp) - `I` - integral (Ki) @@ -7543,22 +7548,22 @@ Sigma_Exit: /*! ### M240 - Trigger camera M240: Trigger camera - + In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code. - + You need to (re)define and assign `CHDK` or `PHOTOGRAPH_PIN` the correct pin number to be able to use the feature. */ case 240: // M240 Triggers a camera by emulating a Canon RC-1 : http://www.doc-diy.net/photo/rc-1_hacked/ { #ifdef CHDK - + SET_OUTPUT(CHDK); WRITE(CHDK, HIGH); chdkHigh = _millis(); chdkActive = true; - + #else - + #if defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1 const uint8_t NUM_PULSES=16; const float PULSE_LENGTH=0.01524; @@ -7585,9 +7590,9 @@ Sigma_Exit: ### M302 - Allow cold extrude, or set minimum extrude temperature M302: Allow cold extrudes This tells the printer to allow movement of the extruder motor above a certain temperature, or if disabled, to allow extruder movement when the hotend is below a safe printing temperature. #### Usage - + M302 [ S ] - + #### Parameters - `S` - Cold extrude minimum temperature */ @@ -7604,9 +7609,9 @@ Sigma_Exit: ### M303 - PID autotune M303: Run PID tuning PID Tuning refers to a control algorithm used in some repraps to tune heating behavior for hot ends and heated beds. This command generates Proportional (Kp), Integral (Ki), and Derivative (Kd) values for the hotend or bed. Send the appropriate code and wait for the output to update the firmware values. #### Usage - + M303 [ E | S | C ] - + #### Parameters - `E` - Extruder, default `E0`. Use `E-1` to calibrate the bed PID - `S` - Target temperature, default `210°C` for hotend, 70 for bed @@ -7702,7 +7707,7 @@ Sigma_Exit: } break; #endif - + /*! ### M400 - Wait for all moves to finish M400: Wait for current moves to finish Finishes all current moves and and thus clears the buffer. @@ -7716,12 +7721,12 @@ Sigma_Exit: /*! ### M403 - Set filament type (material) for particular extruder and notify the MMU M403 - Set filament type (material) for particular extruder and notify the MMU - Currently three different materials are needed (default, flex and PVA). + Currently three different materials are needed (default, flex and PVA). And storing this information for different load/unload profiles etc. in the future firmware does not have to wait for "ok" from MMU. #### Usage - + M403 [ E | F ] - + #### Parameters - `E` - Extruder number. 0-indexed. - `F` - Filament type @@ -7800,9 +7805,9 @@ Sigma_Exit: ### M540 - Abort print on endstop hit (enable/disable) M540 in Marlin: Enable/Disable "Stop SD Print on Endstop Hit" In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code. You must define `ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED`. #### Usage - + M540 [ S ] - + #### Parameters - `S` - disabled=0, enabled=1 */ @@ -7819,9 +7824,9 @@ Sigma_Exit: Sets the Z-probe Z offset. This offset is used to determine the actual Z position of the nozzle when using a probe to home Z with G28. This value may also be used by G81 (Prusa) / G29 (Marlin) to apply correction to the Z position. This value represents the distance from nozzle to the bed surface at the point where the probe is triggered. This value will be negative for typical switch probes, inductive probes, and setups where the nozzle makes a circuit with a raised metal contact. This setting will be greater than zero on machines where the nozzle itself is used as the probe, pressing down on the bed to press a switch. (This is a common setup on delta machines.) #### Usage - + M851 [ Z ] - + #### Parameters - `Z` - Z offset probe to nozzle. */ @@ -7868,9 +7873,9 @@ Sigma_Exit: If P is not specified nothing happens. If the structure of the IP address is invalid, 0.0.0.0 is assumed and nothing is shown on the screen in the Support menu. #### Usage - + M552 [ P ] - + #### Parameters - `P` - The IP address in xxx.xxx.xxx.xxx format. Eg: P192.168.1.14 */ @@ -7886,7 +7891,7 @@ Sigma_Exit: ((uint8_t*)&IP_address)[valCnt] = code_value_short(); valCnt++; } while ((valCnt < 4) && code_seen('.')); - + if (valCnt != 4) IP_address = 0; } @@ -7899,9 +7904,9 @@ Sigma_Exit: Initiates Filament change, it is also used during Filament Runout Sensor process. If the `M600` is triggered under 25mm it will do a Z-lift of 25mm to prevent a filament blob. #### Usage - + M600 [ X | Y | Z | E | L | AUTO ] - + - `X` - X position, default 211 - `Y` - Y position, default 0 - `Z` - relative lift Z, default 2. @@ -7919,7 +7924,7 @@ Sigma_Exit: float e_shift_init = 0; float e_shift_late = 0; bool automatic = false; - + //Retract extruder if(code_seen('E')) { @@ -7932,7 +7937,7 @@ Sigma_Exit: #endif } - //currently don't work as we are using the same unload sequence as in M702, needs re-work + //currently don't work as we are using the same unload sequence as in M702, needs re-work if (code_seen('L')) { e_shift_late = code_value(); @@ -7941,7 +7946,7 @@ Sigma_Exit: { #ifdef FILAMENTCHANGE_FINALRETRACT e_shift_late = FILAMENTCHANGE_FINALRETRACT; - #endif + #endif } //Lift Z @@ -7979,7 +7984,7 @@ Sigma_Exit: automatic = true; gcode_M600(automatic, x_position, y_position, z_shift, e_shift_init, e_shift_late); - + } break; #endif //FILAMENTCHANGEENABLE @@ -8027,13 +8032,13 @@ Sigma_Exit: ### M860 - Wait for extruder temperature (PINDA) M860 Wait for Probe Temperature Wait for PINDA thermistor to reach target temperature #### Usage - + M860 [ S ] - + #### Parameters - `S` - Target temperature */ - case 860: + case 860: { int set_target_pinda = 0; @@ -8074,14 +8079,14 @@ Sigma_Exit: break; } - + /*! ### M861 - Set/Get PINDA temperature compensation offsets M861 Set Probe Thermal Compensation Set compensation ustep value `S` for compensation table index `I`. #### Usage - + M861 [ ? | ! | Z | S | I ] - + #### Parameters - `?` - Print current EEPROM offset values - `!` - Set factory default values @@ -8165,41 +8170,41 @@ Sigma_Exit: } break; #endif //PINDA_THERMISTOR - + /*! ### M862 - Print checking M862: Print checking Checks the parameters of the printer and gcode and performs compatibility check - + - M862.1 { P | Q } 0.25/0.40/0.60 - M862.2 { P | Q } - M862.3 { P"" | Q } - M862.4 { P | Q } - M862.5 { P | Q } - + When run with P<> argument, the check is performed against the input value. When run with Q argument, the current value is shown. - + M862.3 accepts text identifiers of printer types too. The syntax of M862.3 is (note the quotes around the type): - + M862.3 P "MK3S" - + Accepted printer type identifiers and their numeric counterparts: - + - MK1 (100) - - MK2 (200) - - MK2MM (201) - - MK2S (202) - - MK2SMM (203) - - MK2.5 (250) - - MK2.5MMU2 (20250) - - MK2.5S (252) + - MK2 (200) + - MK2MM (201) + - MK2S (202) + - MK2SMM (203) + - MK2.5 (250) + - MK2.5MMU2 (20250) + - MK2.5S (252) - MK2.5SMMU2S (20252) - MK3 (300) - MK3MMU2 (20300) - MK3S (302) - MK3SMMU2S (20302) - + */ case 862: // M862: print checking float nDummy; @@ -8257,9 +8262,9 @@ Sigma_Exit: ### M900 - Set Linear advance options M900 Set Linear Advance Scaling Factors Sets the advance extrusion factors for Linear Advance. If any of the R, W, H, or D parameters are set to zero the ratio will be computed dynamically during printing. #### Usage - + M900 [ K | R | W | H | D] - + #### Parameters - `K` - Advance K factor - `R` - Set ratio directly (overrides WH/D) @@ -8277,9 +8282,9 @@ Sigma_Exit: Set digital trimpot motor current using axis codes (X, Y, Z, E, B, S). M907 has no effect when the experimental Extruder motor current scaling mode is active (that applies to farm printing as well) #### Usage - + M907 [ X | Y | Z | E | B | S ] - + #### Parameters - `X` - X motor driver - `Y` - Y motor driver @@ -8329,9 +8334,9 @@ Sigma_Exit: ### M908 - Control digital trimpot directly M908: Control digital trimpot directly In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code. Not usable on Prusa printers. #### Usage - + M908 [ P | S ] - + #### Parameters - `P` - channel - `S` - current @@ -8352,7 +8357,7 @@ Sigma_Exit: /*! ### M910 - TMC2130 init M910: TMC2130 init Not active in default, only if `TMC2130_SERVICE_CODES_M910_M918` is defined in source code. - + */ case 910: { @@ -8364,16 +8369,16 @@ Sigma_Exit: ### M911 - Set TMC2130 holding currents M911: Set TMC2130 holding currents Not active in default, only if `TMC2130_SERVICE_CODES_M910_M918` is defined in source code. #### Usage - + M911 [ X | Y | Z | E ] - + #### Parameters - `X` - X stepper driver holding current value - `Y` - Y stepper driver holding current value - `Z` - Z stepper driver holding current value - `E` - Extruder stepper driver holding current value */ - case 911: + case 911: { if (code_seen('X')) tmc2130_set_current_h(0, code_value()); if (code_seen('Y')) tmc2130_set_current_h(1, code_value()); @@ -8386,16 +8391,16 @@ Sigma_Exit: ### M912 - Set TMC2130 running currents M912: Set TMC2130 running currents Not active in default, only if `TMC2130_SERVICE_CODES_M910_M918` is defined in source code. #### Usage - + M912 [ X | Y | Z | E ] - + #### Parameters - `X` - X stepper driver running current value - `Y` - Y stepper driver running current value - `Z` - Z stepper driver running current value - `E` - Extruder stepper driver running current value */ - case 912: + case 912: { if (code_seen('X')) tmc2130_set_current_r(0, code_value()); if (code_seen('Y')) tmc2130_set_current_r(1, code_value()); @@ -8443,9 +8448,9 @@ Sigma_Exit: ### M916 - Set TMC2130 Stallguard sensitivity threshold M916: Set TMC2130 Stallguard sensitivity threshold Not active in default, only if `TMC2130_SERVICE_CODES_M910_M918` is defined in source code. #### Usage - + M916 [ X | Y | Z | E ] - + #### Parameters - `X` - X stepper driver stallguard sensitivity threshold value - `Y` - Y stepper driver stallguard sensitivity threshold value @@ -8467,9 +8472,9 @@ Sigma_Exit: ### M917 - Set TMC2130 PWM amplitude offset (pwm_ampl) M917: Set TMC2130 PWM amplitude offset (pwm_ampl) Not active in default, only if `TMC2130_SERVICE_CODES_M910_M918` is defined in source code. #### Usage - + M917 [ X | Y | Z | E ] - + #### Parameters - `X` - X stepper driver PWM amplitude offset value - `Y` - Y stepper driver PWM amplitude offset value @@ -8489,9 +8494,9 @@ Sigma_Exit: ### M918 - Set TMC2130 PWM amplitude gradient (pwm_grad) M918: Set TMC2130 PWM amplitude gradient (pwm_grad) Not active in default, only if `TMC2130_SERVICE_CODES_M910_M918` is defined in source code. #### Usage - + M918 [ X | Y | Z | E ] - + #### Parameters - `X` - X stepper driver PWM amplitude gradient value - `Y` - Y stepper driver PWM amplitude gradient value @@ -8514,23 +8519,23 @@ Sigma_Exit: Printers with TMC2130 drivers have `X`, `Y`, `Z` and `E` as options. The steps-per-unit value is updated accordingly. Not all resolutions are valid! Printers without TMC2130 drivers also have `B` and `S` options. In this case, the steps-per-unit value in not changed! #### Usage - + M350 [ X | Y | Z | E | B | S ] - + #### Parameters - `X` - X new resolution - `Y` - Y new resolution - `Z` - Z new resolution - `E` - E new resolution - + Only valid for MK2.5(S) or printers without TMC2130 drivers - `B` - Second extruder new resolution - `S` - All axes new resolution */ - case 350: + case 350: { #ifdef TMC2130 - for (uint_least8_t i=0; iM351: Toggle MS1 MS2 pins directly Toggle MS1 MS2 pins directly. #### Usage - + M351 [B<0|1>] [E<0|1>] S<1|2> [X<0|1>] [Y<0|1>] [Z<0|1>] - + #### Parameters - `X` - Update X axis - `Y` - Update Y axis @@ -8634,9 +8639,9 @@ Sigma_Exit: /*! ### M702 - Unload filament G32: Undock Z Probe sled #### Usage - + M702 [ C ] - + #### Parameters - `C` - Unload just current filament - without any parameters unload all filaments @@ -8656,7 +8661,7 @@ Sigma_Exit: /*! #### End of M-Commands */ - default: + default: printf_P(MSG_UNKNOWN_CODE, 'M', cmdbuffer + bufindr + CMDHDRSIZE); } // printf_P(_N("END M-CODE=%u\n"), mcode_in_progress); @@ -8677,7 +8682,7 @@ Sigma_Exit: else if(code_seen('T')) { static const char duplicate_Tcode_ignored[] PROGMEM = "Duplicate T-code ignored."; - + int index; bool load_to_nozzle = false; for (index = 1; *(strchr_pointer + index) == ' ' || *(strchr_pointer + index) == '\t'; index++); @@ -8704,7 +8709,7 @@ Sigma_Exit: } } else if (*(strchr_pointer + index) == 'c') { //load to from bondtech gears to nozzle (nozzle should be preheated) - if (mmu_enabled) + if (mmu_enabled) { st_synchronize(); mmu_continue_loading(usb_timer.running() || (lcd_commands_type == LcdCommands::Layer1Cal)); @@ -8831,9 +8836,9 @@ Sigma_Exit: /*! ### D0 - Reset D0: Reset #### Usage - + D0 [ B ] - + #### Parameters - `B` - Bootloader */ @@ -8843,9 +8848,9 @@ Sigma_Exit: /*! * ### D1 - Clear EEPROM and RESET D1: Clear EEPROM and RESET - + D1 - + * */ case 1: @@ -8857,9 +8862,9 @@ Sigma_Exit: ### D2 - Read/Write RAM D3: Read/Write RAM This command can be used without any additional parameters. It will read the entire RAM. #### Usage - + D2 [ A | C | X ] - + #### Parameters - `A` - Address (x0000-x1fff) - `C` - Count (1-8192) @@ -8867,9 +8872,9 @@ Sigma_Exit: #### Notes - The hex address needs to be lowercase without the 0 before the x - - Count is decimal + - Count is decimal - The hex data needs to be lowercase - + */ case 2: dcode_2(); break; @@ -8880,19 +8885,19 @@ Sigma_Exit: ### D3 - Read/Write EEPROM D3: Read/Write EEPROM This command can be used without any additional parameters. It will read the entire eeprom. #### Usage - + D3 [ A | C | X ] - + #### Parameters - `A` - Address (x0000-x0fff) - `C` - Count (1-4096) - `X` - Data (hex) - + #### Notes - The hex address needs to be lowercase without the 0 before the x - - Count is decimal + - Count is decimal - The hex data needs to be lowercase - + */ case 3: dcode_3(); break; @@ -8900,13 +8905,13 @@ Sigma_Exit: #ifdef DEBUG_DCODES /*! - + ### D4 - Read/Write PIN D4: Read/Write PIN To read the digital value of a pin you need only to define the pin number. #### Usage - + D4 [ P | F | V ] - + #### Parameters - `P` - Pin (0-255) - `F` - Function in/out (0/1) @@ -8921,20 +8926,20 @@ Sigma_Exit: ### D5 - Read/Write FLASH D5: Read/Write Flash This command can be used without any additional parameters. It will read the 1kb FLASH. #### Usage - + D5 [ A | C | X | E ] - + #### Parameters - `A` - Address (x00000-x3ffff) - `C` - Count (1-8192) - `X` - Data (hex) - `E` - Erase - + #### Notes - The hex address needs to be lowercase without the 0 before the x - - Count is decimal + - Count is decimal - The hex data needs to be lowercase - + */ case 5: dcode_5(); break; @@ -8960,9 +8965,9 @@ Sigma_Exit: /*! ### D8 - Read/Write PINDA D8: Read/Write PINDA #### Usage - + D8 [ ? | ! | P | Z ] - + #### Parameters - `?` - Read PINDA temperature shift values - `!` - Reset PINDA temperature shift values to default @@ -8975,11 +8980,11 @@ Sigma_Exit: /*! ### D9 - Read ADC D9: Read ADC #### Usage - + D9 [ I | V ] - + #### Parameters - - `I` - ADC channel index + - `I` - ADC channel index - `0` - Heater 0 temperature - `1` - Heater 1 temperature - `2` - Bed temperature @@ -9093,9 +9098,9 @@ Sigma_Exit: ### D80 - Bed check D80: Bed check This command will log data to SD card file "mesh.txt". #### Usage - + D80 [ E | F | G | H | I | J ] - + #### Parameters - `E` - Dimension X (default 40) - `F` - Dimention Y (default 40) @@ -9111,9 +9116,9 @@ Sigma_Exit: ### D81 - Bed analysis D80: Bed analysis This command will log data to SD card file "wldsd.txt". #### Usage - + D81 [ E | F | G | H | I | J ] - + #### Parameters - `E` - Dimension X (default 40) - `F` - Dimention Y (default 40) @@ -9124,7 +9129,7 @@ Sigma_Exit: */ case 81: dcode_81(); break; - + #endif //HEATBED_ANALYSIS #ifdef DEBUG_DCODES @@ -9138,11 +9143,11 @@ Sigma_Exit: /*! ### D2130 - Trinamic stepper controller D2130: Trinamic stepper controller @todo Please review by owner of the code. RepRap Wiki Gcode needs to be updated after review of owner as well. - + #### Usage - + D2130 [ Axis | Command | Subcommand | Value ] - + #### Parameters - Axis - `X` - X stepper driver @@ -9171,21 +9176,21 @@ Sigma_Exit: - `0, 180 --> 250` - Off - `0.9 --> 1.25` - Valid values (recommended is 1.1) - `@` - Home calibrate axis - + Examples: - + D2130E?wave - + Print extruder microstep linearity compensation curve - + D2130E!wave0 - + Disable extruder linearity compensation curve, (sine curve is used) - + D2130E!wave220 - + (sin(x))^1.1 extruder microstep compensation curve used - + Notes: For more information see https://www.trinamic.com/fileadmin/assets/Products/ICs_Documents/TMC2130_datasheet.pdf * @@ -9199,9 +9204,9 @@ Sigma_Exit: /*! ### D9125 - PAT9125 filament sensor D9125: PAT9125 filament sensor #### Usage - + D9125 [ ? | ! | R | X | Y | L ] - + #### Parameters - `?` - Print values - `!` - Print values @@ -9236,7 +9241,7 @@ Sigma_Exit: #### End of D-Codes */ -/** @defgroup GCodes G-Code List +/** @defgroup GCodes G-Code List */ // --------------------------------------------------- @@ -9262,17 +9267,17 @@ void update_currents() { float current_high[3] = DEFAULT_PWM_MOTOR_CURRENT_LOUD; float current_low[3] = DEFAULT_PWM_MOTOR_CURRENT; float tmp_motor[3]; - + //SERIAL_ECHOLNPGM("Currents updated: "); if (destination[Z_AXIS] < Z_SILENT) { //SERIAL_ECHOLNPGM("LOW"); for (uint8_t i = 0; i < 3; i++) { - st_current_set(i, current_low[i]); + st_current_set(i, current_low[i]); /*MYSERIAL.print(int(i)); SERIAL_ECHOPGM(": "); MYSERIAL.println(current_low[i]);*/ - } + } } else if (destination[Z_AXIS] > Z_HIGH_POWER) { //SERIAL_ECHOLNPGM("HIGH"); @@ -9281,13 +9286,13 @@ void update_currents() { /*MYSERIAL.print(int(i)); SERIAL_ECHOPGM(": "); MYSERIAL.println(current_high[i]);*/ - } + } } else { for (uint8_t i = 0; i < 3; i++) { float q = current_low[i] - Z_SILENT*((current_high[i] - current_low[i]) / (Z_HIGH_POWER - Z_SILENT)); tmp_motor[i] = ((current_high[i] - current_low[i]) / (Z_HIGH_POWER - Z_SILENT))*destination[Z_AXIS] + q; - st_current_set(i, tmp_motor[i]); + st_current_set(i, tmp_motor[i]); /*MYSERIAL.print(int(i)); SERIAL_ECHOPGM(": "); MYSERIAL.println(tmp_motor[i]);*/ @@ -9327,7 +9332,7 @@ void get_coordinates() { if(next_feedrate > 0.0) feedrate = next_feedrate; if (!seen[0] && !seen[1] && !seen[2] && seen[3]) { -// float e_max_speed = +// float e_max_speed = // printf_P(PSTR("E MOVE speed %7.3f\n"), feedrate / 60) } } @@ -9405,7 +9410,7 @@ void mesh_plan_buffer_line(const float &x, const float &y, const float &z, const plan_buffer_line(x, y, z, e, feed_rate, extruder, current_position); } #endif // MESH_BED_LEVELING - + void prepare_move(uint16_t start_segment_idx) { clamp_to_software_endstops(destination); @@ -9567,7 +9572,7 @@ static uint16_t nFSCheckCount=0; // avoiding floating point operations, thus computing in raw if( current_voltage_raw_IR > maxVolt )maxVolt = current_voltage_raw_IR; if( current_voltage_raw_IR < minVolt )minVolt = current_voltage_raw_IR; - + #if 0 // Start: IR Sensor debug info { // debug print static uint16_t lastVolt = ~0U; @@ -9581,21 +9586,21 @@ static uint16_t nFSCheckCount=0; //! to be detected as the new fsensor //! We can either fake it by extending the detection window to a looooong time //! or do some other countermeasures - + //! what we want to detect: //! if minvolt gets below ~0.3V, it means there is an old fsensor //! if maxvolt gets above 4.6V, it means we either have an old fsensor or broken cables/fsensor //! So I'm waiting for a situation, when minVolt gets to range <0, 1.5> and maxVolt gets into range <3.0, 5> //! If and only if minVolt is in range <0.3, 1.5> and maxVolt is in range <3.0, 4.6>, I'm considering a situation with the new fsensor - if( minVolt >= IRsensor_Ldiode_TRESHOLD && minVolt <= IRsensor_Lmax_TRESHOLD + if( minVolt >= IRsensor_Ldiode_TRESHOLD && minVolt <= IRsensor_Lmax_TRESHOLD && maxVolt >= IRsensor_Hmin_TRESHOLD && maxVolt <= IRsensor_Hopen_TRESHOLD ){ manage_inactivity_IR_ANALOG_Check(nFSCheckCount, ClFsensorPCB::_Old, ClFsensorPCB::_Rev04, _i("FS v0.4 or newer") ); ////MSG_FS_V_04_OR_NEWER c=18 - } + } //! If and only if minVolt is in range <0.0, 0.3> and maxVolt is in range <4.6, 5.0V>, I'm considering a situation with the old fsensor //! Note, we are not relying on one voltage here - getting just +5V can mean an old fsensor or a broken new sensor - that's why //! we need to have both voltages detected correctly to allow switching back to the old fsensor. - else if( minVolt < IRsensor_Ldiode_TRESHOLD + else if( minVolt < IRsensor_Ldiode_TRESHOLD && maxVolt > IRsensor_Hopen_TRESHOLD && maxVolt <= IRsensor_VMax_TRESHOLD ){ manage_inactivity_IR_ANALOG_Check(nFSCheckCount, ClFsensorPCB::_Rev04, oFsensorPCB=ClFsensorPCB::_Old, _i("FS v0.3 or older")); ////MSG_FS_V_03_OR_OLDER c=18 @@ -9652,7 +9657,7 @@ if(0) static int killCount = 0; // make the inactivity button a bit less responsive const int KILL_DELAY = 10000; #endif - + if(buflen < (BUFSIZE-1)){ get_command(); } @@ -9673,7 +9678,7 @@ if(0) } } } - + #ifdef CHDK //Check if pin should be set to LOW after M240 set it to HIGH if (chdkActive && (_millis() - chdkHigh > CHDK_DELAY)) { @@ -9681,9 +9686,9 @@ if(0) WRITE(CHDK, LOW); } #endif - + #if defined(KILL_PIN) && KILL_PIN > -1 - + // Check if the kill button was pressed and wait just in case it was an accidental // key kill key press // ------------------------------------------------------------------------------- @@ -9703,7 +9708,7 @@ if(0) kill(NULL, 5); } #endif - + #if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1 controllerFan(); //Check if fan should be turned on to cool stepper drivers down #endif @@ -9777,7 +9782,7 @@ void kill(const char *full_screen_message, unsigned char id) sei(); // enable interrupts for ( int i=5; i--; lcd_update(0)) { - _delay(200); + _delay(200); } cli(); // disable interrupts suicide(); @@ -9787,7 +9792,7 @@ void kill(const char *full_screen_message, unsigned char id) wdt_reset(); #endif //WATCHDOG /* Intentionally left empty */ - + } // Wait for reset } @@ -10134,12 +10139,12 @@ void check_babystep() s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].z_offset)), babystep_z); lcd_show_fullscreen_message_and_wait_P(PSTR("Z live adjust out of range. Setting to 0. Click to continue.")); - lcd_update_enable(true); - } + lcd_update_enable(true); + } } #ifdef HEATBED_ANALYSIS void d_setup() -{ +{ pinMode(D_DATACLOCK, INPUT_PULLUP); pinMode(D_DATA, INPUT_PULLUP); pinMode(D_REQUIRE, OUTPUT); @@ -10208,7 +10213,7 @@ void bed_check(float x_dimension, float y_dimension, int x_points_num, int y_poi int iy = 0; const char* filename_wldsd = "mesh.txt"; - char data_wldsd[x_points_num * 7 + 1]; //6 chars(" -A.BCD")for each measurement + null + char data_wldsd[x_points_num * 7 + 1]; //6 chars(" -A.BCD")for each measurement + null char numb_wldsd[8]; // (" -A.BCD" + null) #ifdef MICROMETER_LOGGING d_setup(); @@ -10292,24 +10297,24 @@ void bed_check(float x_dimension, float y_dimension, int x_points_num, int y_poi //strcat(data_wldsd, numb_wldsd); - + //MYSERIAL.println(data_wldsd); //delay(1000); //delay(3000); //t1 = millis(); - + //while (digitalRead(D_DATACLOCK) == LOW) {} //while (digitalRead(D_DATACLOCK) == HIGH) {} memset(digit, 0, sizeof(digit)); //cli(); - digitalWrite(D_REQUIRE, LOW); - + digitalWrite(D_REQUIRE, LOW); + for (int i = 0; i<13; i++) { //t1 = millis(); for (int j = 0; j < 4; j++) { - while (digitalRead(D_DATACLOCK) == LOW) {} + while (digitalRead(D_DATACLOCK) == LOW) {} while (digitalRead(D_DATACLOCK) == HIGH) {} //printf_P(PSTR("Done %d\n"), j); bitWrite(digit[i], j, digitalRead(D_DATA)); @@ -10325,11 +10330,11 @@ void bed_check(float x_dimension, float y_dimension, int x_points_num, int y_poi mergeOutput[0] = '\0'; output = 0; for (int r = 5; r <= 10; r++) //Merge digits - { + { sprintf(str, "%d", digit[r]); strcat(mergeOutput, str); } - + output = atof(mergeOutput); if (digit[4] == 8) //Handle sign @@ -10341,16 +10346,16 @@ void bed_check(float x_dimension, float y_dimension, int x_points_num, int y_poi { output *= 0.1; } - + //output = d_ReadData(); //row[ix] = current_position[Z_AXIS]; - + //row[ix] = d_ReadData(); - + row[ix] = output; if (iy % 2 == 1 ? ix == 0 : ix == x_points_num - 1) { @@ -10408,7 +10413,7 @@ void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_ // Push the commands to the front of the message queue in the reverse order! // There shall be always enough space reserved for these commands. repeatcommand_front(); // repeat G80 with all its parameters - + enquecommand_front_P(G28W0); enquecommand_front_P((PSTR("G1 Z5"))); return; @@ -10460,7 +10465,7 @@ void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_ plan_buffer_line_curposXYZE(XY_AXIS_FEEDRATE, active_extruder); st_synchronize(); - if (!find_bed_induction_sensor_point_z(-10.f)) { //if we have data from z calibration max allowed difference is 1mm for each point, if we dont have data max difference is 10mm from initial point + if (!find_bed_induction_sensor_point_z(-10.f)) { //if we have data from z calibration max allowed difference is 1mm for each point, if we dont have data max difference is 10mm from initial point break; card.closefile(); } @@ -10471,24 +10476,24 @@ void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_ //strcat(data_wldsd, numb_wldsd); - + //MYSERIAL.println(data_wldsd); //_delay(1000); //_delay(3000); //t1 = _millis(); - + //while (digitalRead(D_DATACLOCK) == LOW) {} //while (digitalRead(D_DATACLOCK) == HIGH) {} memset(digit, 0, sizeof(digit)); //cli(); - digitalWrite(D_REQUIRE, LOW); - + digitalWrite(D_REQUIRE, LOW); + for (int i = 0; i<13; i++) { //t1 = _millis(); for (int j = 0; j < 4; j++) { - while (digitalRead(D_DATACLOCK) == LOW) {} + while (digitalRead(D_DATACLOCK) == LOW) {} while (digitalRead(D_DATACLOCK) == HIGH) {} bitWrite(digit[i], j, digitalRead(D_DATA)); } @@ -10502,11 +10507,11 @@ void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_ mergeOutput[0] = '\0'; output = 0; for (int r = 5; r <= 10; r++) //Merge digits - { + { sprintf(str, "%d", digit[r]); strcat(mergeOutput, str); } - + output = atof(mergeOutput); if (digit[4] == 8) //Handle sign @@ -10518,7 +10523,7 @@ void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_ { output *= 0.1; } - + //output = d_ReadData(); @@ -10539,9 +10544,9 @@ void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_ //strcat(data_wldsd, ";"); card.write_command(data_wldsd); - + //row[ix] = d_ReadData(); - + row[ix] = output; // current_position[Z_AXIS]; if (iy % 2 == 1 ? ix == 0 : ix == x_points_num - 1) { @@ -10565,7 +10570,7 @@ void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_ #ifndef PINDA_THERMISTOR static void temp_compensation_start() { - + custom_message_type = CustomMsg::TempCompPreheat; custom_message_state = PINDA_HEAT_T + 1; lcd_update(2); @@ -10573,7 +10578,7 @@ static void temp_compensation_start() { current_position[E_AXIS] -= default_retraction; } plan_buffer_line_curposXYZE(400); - + current_position[X_AXIS] = PINDA_PREHEAT_X; current_position[Y_AXIS] = PINDA_PREHEAT_Y; current_position[Z_AXIS] = PINDA_PREHEAT_Z; @@ -10586,7 +10591,7 @@ static void temp_compensation_start() { custom_message_state = PINDA_HEAT_T - i; if (custom_message_state == 99 || custom_message_state == 9) lcd_update(2); //force whole display redraw if number of digits changed else lcd_update(1); - } + } custom_message_type = CustomMsg::Status; custom_message_state = 0; } @@ -10610,7 +10615,7 @@ static void temp_compensation_apply() { st_synchronize(); plan_set_z_position(current_position[Z_AXIS]); } - else { + else { //we have no temp compensation data } } @@ -10762,7 +10767,7 @@ void uvlo_() #endif //LCD_BL_PIN disable_x(); disable_y(); - + #ifdef TMC2130 tmc2130_set_current_h(Z_AXIS, 20); tmc2130_set_current_r(Z_AXIS, 20); @@ -10902,7 +10907,7 @@ void uvlo_() eeprom_update_float((float*)(EEPROM_UVLO_SAVED_START_POSITION+1*4), saved_start_position[Y_AXIS]); eeprom_update_float((float*)(EEPROM_UVLO_SAVED_START_POSITION+2*4), saved_start_position[Z_AXIS]); eeprom_update_float((float*)(EEPROM_UVLO_SAVED_START_POSITION+3*4), saved_start_position[E_AXIS]); - + eeprom_update_word((uint16_t*)EEPROM_UVLO_SAVED_SEGMENT_IDX, saved_segment_idx); #ifdef LIN_ADVANCE @@ -11030,7 +11035,7 @@ ISR(INT7_vect) { if ((millis_nc() - t_fan_rising_edge) >= FAN_PULSE_WIDTH_LIMIT) {//this pulse was from sensor and not from pwm fan_edge_counter[1] += 2; //we are currently counting all edges so lets count two edges for one pulse } - } + } EICRB ^= (1 << 6); //change edge } @@ -11057,9 +11062,9 @@ void setup_uvlo_interrupt() { } ISR(INT4_vect) { - EIMSK &= ~(1 << 4); //disable INT4 interrupt to make sure that this code will be executed just once + EIMSK &= ~(1 << 4); //disable INT4 interrupt to make sure that this code will be executed just once SERIAL_ECHOLNPGM("INT4"); - //fire normal uvlo only in case where EEPROM_UVLO is 0 or if IS_SD_PRINTING is 1. + //fire normal uvlo only in case where EEPROM_UVLO is 0 or if IS_SD_PRINTING is 1. if(printer_active() && (!(eeprom_read_byte((uint8_t*)EEPROM_UVLO)))) uvlo_(); if(eeprom_read_byte((uint8_t*)EEPROM_UVLO)) uvlo_tiny(); } @@ -11177,7 +11182,7 @@ bool recover_machine_state_after_power_panic() saved_start_position[Y_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_SAVED_START_POSITION+1*4)); saved_start_position[Z_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_SAVED_START_POSITION+2*4)); saved_start_position[E_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_SAVED_START_POSITION+3*4)); - + saved_segment_idx = eeprom_read_word((uint16_t*)EEPROM_UVLO_SAVED_SEGMENT_IDX); #ifdef LIN_ADVANCE @@ -11205,7 +11210,7 @@ void restore_print_from_eeprom(bool mbl_was_active) { MYSERIAL.println(feedmultiply_rec); depth = eeprom_read_byte((uint8_t*)EEPROM_DIR_DEPTH); - + MYSERIAL.println(int(depth)); for (uint8_t i = 0; i < depth; i++) { for (uint8_t j = 0; j < 8; j++) { @@ -11277,7 +11282,7 @@ void restore_print_from_eeprom(bool mbl_was_active) { // Set a position in the file. sprintf_P(cmd, PSTR("M26 S%lu"), position); enquecommand(cmd); - enquecommand_P(PSTR("G4 S0")); + enquecommand_P(PSTR("G4 S0")); enquecommand_P(PSTR("PRUSA uvlo")); } #endif //UVLO_SUPPORT @@ -11300,7 +11305,7 @@ void stop_and_save_print_to_ram(float z_move, float e_move) unsigned char nlines; uint16_t sdlen_planner; uint16_t sdlen_cmdqueue; - + cli(); if (card.sdprinting) { @@ -11318,7 +11323,7 @@ void stop_and_save_print_to_ram(float z_move, float e_move) else if (usb_timer.running()) { //reuse saved_sdpos for storing line number saved_sdpos = gcode_LastN; //start with line number of command added recently to cmd queue //reuse planner_calc_sd_length function for getting number of lines of commands in planner: - nlines = planner_calc_sd_length(); //number of lines of commands in planner + nlines = planner_calc_sd_length(); //number of lines of commands in planner saved_sdpos -= nlines; saved_sdpos -= buflen; //number of blocks in cmd buffer saved_printing_type = PRINTING_TYPE_USB; @@ -11386,7 +11391,7 @@ void stop_and_save_print_to_ram(float z_move, float e_move) if (cmdbuffer[_bufindr] == CMDBUFFER_CURRENT_TYPE_SDCARD) { sdlen_single.lohi.lo = cmdbuffer[_bufindr + 1]; sdlen_single.lohi.hi = cmdbuffer[_bufindr + 2]; - } + } SERIAL_ECHOPGM("Buffer line (from buffer): "); MYSERIAL.print(int(iline), DEC); SERIAL_ECHOPGM(", type: "); @@ -11498,13 +11503,13 @@ void stop_and_save_print_to_ram(float z_move, float e_move) void restore_print_from_ram_and_continue(float e_move) { if (!saved_printing) return; - + #ifdef FANCHECK // Do not allow resume printing if fans are still not ok if ((fan_check_error != EFCE_OK) && (fan_check_error != EFCE_FIXED)) return; if (fan_check_error == EFCE_FIXED) fan_check_error = EFCE_OK; //reenable serial stream processing if printing from usb #endif - + // restore bed temperature (bed can be disabled during a thermal warning) if (degBed() != saved_bed_temperature) setTargetBed(saved_bed_temperature); @@ -11522,7 +11527,7 @@ void restore_print_from_ram_and_continue(float e_move) axis_relative_modes ^= (-saved_extruder_relative_mode ^ axis_relative_modes) & E_AXIS_MASK; float e = saved_pos[E_AXIS] - e_move; plan_set_e_position(e); - + #ifdef FANCHECK fans_check_enabled = false; #endif @@ -11559,7 +11564,7 @@ void restore_print_from_ram_and_continue(float e_move) } else if (saved_printing_type == PRINTING_TYPE_USB) { //was usb printing gcode_LastN = saved_sdpos; //saved_sdpos was reused for storing line number when usb printing - serial_count = 0; + serial_count = 0; FlushSerialRequestResend(); } else { @@ -11716,10 +11721,10 @@ void M600_wait_for_user(float HotendTempBckp) { if (counterBeep == 20) { WRITE(BEEPER, LOW); } - + counterBeep++; #endif //BEEPER > 0 - + switch (wait_for_user_state) { case 0: //nozzle is hot, waiting for user to press the knob to unload filament delay_keep_alive(4); @@ -11736,7 +11741,7 @@ void M600_wait_for_user(float HotendTempBckp) { break; case 1: //nozzle target temperature is set to zero, waiting for user to start nozzle preheat delay_keep_alive(4); - + if (lcd_clicked()) { setTargetHotend(HotendTempBckp, active_extruder); lcd_wait_for_heater(); diff --git a/Firmware/eeprom.h b/Firmware/eeprom.h index 3e5c6be1..9c6e1877 100644 --- a/Firmware/eeprom.h +++ b/Firmware/eeprom.h @@ -595,9 +595,10 @@ static Sheets * const EEPROM_Sheets_base = (Sheets*)(EEPROM_SHEETS_BASE); #define EEPROM_TEMP_MODEL_D (EEPROM_TEMP_MODEL_V-4) //float #define EEPROM_TEMP_MODEL_L (EEPROM_TEMP_MODEL_D-2) //uint16_t #define EEPROM_TEMP_MODEL_VER (EEPROM_TEMP_MODEL_L-1) //uint8_t +#define EEPROM_MMU_DISABLED_FROM_MENU (EEPROM_TEMP_MODEL_VER-1) //This is supposed to point to last item to allow EEPROM overrun check. Please update when adding new items. -#define EEPROM_LAST_ITEM EEPROM_TEMP_MODEL_VER +#define EEPROM_LAST_ITEM EEPROM_MMU_DISABLED_FROM_MENU // !!!!! // !!!!! this is end of EEPROM section ... all updates MUST BE inserted before this mark !!!!! // !!!!! diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 8962eece..18b2119f 100755 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -160,7 +160,9 @@ void mmu_init(void) WRITE(MMU_RST_PIN, 1); SET_OUTPUT(MMU_RST_PIN); //setup reset pin #endif //MMU_HWRESET - uart2_init(); //init uart2 + if (!MMU_Disabled_from_menu) { + 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 = S::Init; diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index ea5e300c..5202bf6e 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -67,6 +67,7 @@ uint8_t scrollstuff = 0; int8_t SilentModeMenu = SILENT_MODE_OFF; uint8_t SilentModeMenu_MMU = 1; //activate mmu unit stealth mode +uint8_t MMU_Disabled_from_menu = 0; int8_t FSensorStateMenu = 1; @@ -1772,6 +1773,8 @@ static void lcd_support_menu() lcd_puts_P(_i("unknown")); ////MSG_UNKNOWN c=13 } } + else if (MMU_Disabled_from_menu) + MENU_ITEM_BACK_P(PSTR("MMU2 disabled")); else MENU_ITEM_BACK_P(PSTR("MMU2 N/A")); @@ -1844,6 +1847,35 @@ void lcd_set_fan_check() { #endif //FANCHECK } +static void disable_mmu_switch() +{ + MMU_Disabled_from_menu = !MMU_Disabled_from_menu; + eeprom_update_byte((unsigned char *)EEPROM_MMU_DISABLED_FROM_MENU, MMU_Disabled_from_menu); +} + +static bool settingsDisableMMUFromMenu() +{ + if (mmu_enabled || MMU_Disabled_from_menu) + { + if (!MMU_Disabled_from_menu) + { + if (menu_item_function_P(_i("MMU [ENABLED]"), disable_mmu_switch)) return true; + } + else + { + if (menu_item_function_P(_i("MMU [DISABLED]"), disable_mmu_switch)) return true; + } + } + return false; +} + +#define SETTINGS_DISABLE_MMU_FROM_MENU \ +do\ +{\ + if(settingsDisableMMUFromMenu()) return;\ +}\ +while(0)\ + #ifdef MMU_HAS_CUTTER void lcd_cutter_enabled() { @@ -4953,6 +4985,8 @@ static void lcd_settings_menu() SETTINGS_AUTO_DEPLETE; + SETTINGS_DISABLE_MMU_FROM_MENU; + SETTINGS_CUTTER; MENU_ITEM_TOGGLE_P(_T(MSG_FANS_CHECK), fans_check_enabled ? _T(MSG_ON) : _T(MSG_OFF), lcd_set_fan_check); diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index dafd2906..2ae1509a 100755 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -163,6 +163,7 @@ void printf_IRSensorAnalogBoardChange(); extern int8_t SilentModeMenu; extern uint8_t SilentModeMenu_MMU; +extern uint8_t MMU_Disabled_from_menu; extern bool cancel_heatup; extern bool isPrintPaused;