From 19589f02f18282289845d9d1da53b49597ce8a5c Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Fri, 26 Apr 2019 16:51:43 +0200 Subject: [PATCH 01/73] Remove an unused define --- Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h | 1 - Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h | 1 - 2 files changed, 2 deletions(-) diff --git a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h index 685d77c6b..9e97a7f2a 100644 --- a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h @@ -266,7 +266,6 @@ #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_CURRENTS_R_HOME {8, 10, 20, 18} // homing running currents for all axes -// #define TMC2130_UNLOAD_CURRENT_R 12 // lower current for M600 to protect filament sensor - Unused #define TMC2130_STEALTH_Z diff --git a/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h index 5ee149e75..35342ab2e 100644 --- a/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h @@ -268,7 +268,6 @@ #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_CURRENTS_R_HOME {8, 10, 20, 18} // homing running currents for all axes -// #define TMC2130_UNLOAD_CURRENT_R 12 // lower current for M600 to protect filament sensor - Unused #define TMC2130_STEALTH_Z From f923427dc1d83602cb52efadabf9694616ba5ed0 Mon Sep 17 00:00:00 2001 From: odaki Date: Sat, 4 Jan 2020 12:51:20 +0900 Subject: [PATCH 02/73] Show the FlashAir IP address Displays the FlashAir IP address in the "Support" menu if the card is available. If no IP address has been assigned yet, "0.0.0.0" will be displayed. --- Firmware/ultralcd.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 5d0abeac9..f9260d3e5 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -2192,11 +2192,14 @@ static void lcd_support_menu() // Menu was entered or SD card status has changed (plugged in or removed). // Initialize its status. _md->status = 1; - _md->is_flash_air = card.ToshibaFlashAir_isEnabled() && card.ToshibaFlashAir_GetIP(_md->ip); - if (_md->is_flash_air) + _md->is_flash_air = card.ToshibaFlashAir_isEnabled(); + if (_md->is_flash_air) { + card.ToshibaFlashAir_GetIP(_md->ip); // ip[4] filled with 0 if it failed + // Prepare IP string from ip[4] sprintf_P(_md->ip_str, PSTR("%d.%d.%d.%d"), _md->ip[0], _md->ip[1], _md->ip[2], _md->ip[3]); + } } else if (_md->is_flash_air && _md->ip[0] == 0 && _md->ip[1] == 0 && _md->ip[2] == 0 && _md->ip[3] == 0 && @@ -2256,7 +2259,11 @@ static void lcd_support_menu() if (_md->is_flash_air) { MENU_ITEM_BACK_P(STR_SEPARATOR); MENU_ITEM_BACK_P(PSTR("FlashAir IP Addr:")); //c=18 r=1 -///! MENU_ITEM(back_RAM, _md->ip_str, 0); + MENU_ITEM_BACK_P(PSTR(" ")); + if (((menu_item - 1) == menu_line) && lcd_draw_update) { + lcd_set_cursor(2, menu_row); + lcd_printf_P(PSTR("%s"), _md->ip_str); + } } #ifndef MK1BP From 2ca1bc0acb43f0ec88ee8f50f1b591380307bf99 Mon Sep 17 00:00:00 2001 From: odaki Date: Sat, 11 Jan 2020 21:47:16 +0900 Subject: [PATCH 03/73] Support W-04 firmware 4.0.0.01+ W-04 needs to use CMD17 instead of CMD48 to retrieve iSDIO register memories. To supporting both W-03 and W-04 card, I changed the readExt() code to use CMD48 first and use CMD17 if it returned some error. This method is from the FlashAir developer sample code. https://flashair-developers.github.io/website/docs/tutorials/arduino/2 --- Firmware/Sd2Card.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/Sd2Card.cpp b/Firmware/Sd2Card.cpp index 449590f17..5449fccd9 100644 --- a/Firmware/Sd2Card.cpp +++ b/Firmware/Sd2Card.cpp @@ -774,7 +774,7 @@ uint8_t Sd2Card::readExt(uint32_t arg, uint8_t* dst, uint16_t count) { uint16_t i; // send command and argument. - if (cardCommand(CMD48, arg)) { + if (cardCommand(CMD48, arg) && cardCommand(CMD17, arg)) { // CMD48 for W-03, CMD17 for W-04 error(SD_CARD_ERROR_CMD48); goto fail; } From 99545a006cc1f61f14c78d231142acb1ea3e4bdc Mon Sep 17 00:00:00 2001 From: odaki Date: Sun, 12 Jan 2020 12:45:43 +0900 Subject: [PATCH 04/73] M46 "Show the assigned IP address" activated According to the reprap wiki, M46 has been assigned to display its assigned IP address, but has been disabled. Now that Toshiba FlashAir IP address processing is working, I activate the M46 code so that I can read the IP address information via serial. --- Firmware/Marlin_main.cpp | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 4970091ea..fb0f1a1bb 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -5584,28 +5584,32 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) } break; - /* + //! ### M46 - Show the assigned IP address (Prusa specific) + // -------------------------------------------------------------------- case 46: { // M46: Prusa3D: Show the assigned IP address. - uint8_t ip[4]; - bool hasIP = card.ToshibaFlashAir_GetIP(ip); - if (hasIP) { - SERIAL_ECHOPGM("Toshiba FlashAir current IP: "); - SERIAL_ECHO(int(ip[0])); - SERIAL_ECHOPGM("."); - SERIAL_ECHO(int(ip[1])); - SERIAL_ECHOPGM("."); - SERIAL_ECHO(int(ip[2])); - SERIAL_ECHOPGM("."); - SERIAL_ECHO(int(ip[3])); - SERIAL_ECHOLNPGM(""); + if (card.ToshibaFlashAir_isEnabled()) { + uint8_t ip[4]; + bool hasIP = card.ToshibaFlashAir_GetIP(ip); + if (hasIP) { + // SERIAL_PROTOCOLPGM("Toshiba FlashAir current IP: "); + SERIAL_PROTOCOL(int(ip[0])); + SERIAL_PROTOCOLPGM("."); + SERIAL_PROTOCOL(int(ip[1])); + SERIAL_PROTOCOLPGM("."); + SERIAL_PROTOCOL(int(ip[2])); + SERIAL_PROTOCOLPGM("."); + SERIAL_PROTOCOL(int(ip[3])); + SERIAL_PROTOCOLPGM("\n"); + } else { + SERIAL_PROTOCOLPGM("?Toshiba FlashAir GetIP failed\n"); + } } else { - SERIAL_ECHOLNPGM("Toshiba FlashAir GetIP failed"); + SERIAL_PROTOCOLPGM("n/a\n"); } break; } - */ //! ### M47 - Show end stops dialog on the display (Prusa specific) // ---------------------------------------------------- From b09761ed712a8305ee459c6964b0ad01bf74c5fb Mon Sep 17 00:00:00 2001 From: odaki Date: Thu, 16 Jan 2020 21:38:39 +0900 Subject: [PATCH 05/73] Remove '/*' from M46 source I forgot to remove the unintended comment start mark when merge. It has been deleted. --- Firmware/Marlin_main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 8f232fb93..7c4a724f5 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -5829,8 +5829,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) /*! ### M46 - Show the assigned IP address M46: Show the assigned IP address. */ - /* - case 46: + case 46: { // M46: Prusa3D: Show the assigned IP address. if (card.ToshibaFlashAir_isEnabled()) { From 684b47e417ee75ce69f0f4e46f2f3c4e5f097468 Mon Sep 17 00:00:00 2001 From: odaki Date: Sun, 15 Mar 2020 19:04:02 +0900 Subject: [PATCH 06/73] Update reference URL There was an official website of Toshiba called "FlashAir Developers '', and there was information necessary for FlashAir development, but since it closed in September 2019. Instead, I will point an archive site for developers. --- Firmware/Sd2Card.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Firmware/Sd2Card.cpp b/Firmware/Sd2Card.cpp index 5449fccd9..d1d350563 100644 --- a/Firmware/Sd2Card.cpp +++ b/Firmware/Sd2Card.cpp @@ -767,6 +767,9 @@ uint8_t Sd2Card::waitStartBlock(void) { // Toshiba FlashAir support, copied from // https://flashair-developers.com/en/documents/tutorials/arduino/ +// However, the official website was closed in September 2019. +// There is an archived website (written in Japanese). +// https://flashair-developers.github.io/website/docs/tutorials/arduino/2.html //------------------------------------------------------------------------------ /** Perform Extention Read. */ From f8843b25b04723c8799ea64f07f7c2d266e1a7f7 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Wed, 1 Apr 2020 22:09:49 +0300 Subject: [PATCH 07/73] :sparkles: Progress bar for check_file() --- Firmware/ultralcd.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index daf9f0176..6b1409102 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -8760,20 +8760,33 @@ static void lcd_selftest_screen_step(int _row, int _col, int _state, const char static bool check_file(const char* filename) { if (farm_mode) return true; - bool result = false; - uint32_t filesize; card.openFile((char*)filename, true); - filesize = card.getFileSize(); + bool result = false; + const uint32_t filesize = card.getFileSize(); + uint32_t startPos = 0; + const uint16_t bytesToCheck = min(END_FILE_SECTION, filesize); if (filesize > END_FILE_SECTION) { - card.setIndex(filesize - END_FILE_SECTION); - + startPos = filesize - END_FILE_SECTION; + card.setIndex(startPos); } - - while (!card.eof() && !result) { + + lcd_clear(); + lcd_puts_at_P(0, 1, _i("Checking file"));////c=20 r=1 + printf_P(PSTR("startPos=%lu\n"), startPos); + while (!card.eof() && !result) { + lcd_set_cursor(0, 2); + for (int column = 0; column < 20; column++) { + const int8_t percent = ((card.get_sdpos() - startPos) * 100) / bytesToCheck; + if (column < (percent / 5)) + { + lcd_set_cursor(column, 2); + lcd_print('\xFF'); //simple progress bar + } + } + card.sdprinting = true; get_command(); result = check_commands(); - } card.printingHasFinished(); strncpy_P(lcd_status_message, _T(WELCOME_MSG), LCD_WIDTH); From 4c4b4c489cf632b9c7535e1971b96782f3b5f78e Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Tue, 7 Apr 2020 17:09:48 +0300 Subject: [PATCH 08/73] :bug::recycle: Update the feedrate percentage before drawing the screen --- Firmware/ultralcd.cpp | 60 +++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 62c410727..c60b6e425 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -997,6 +997,36 @@ void lcd_status_screen() // NOT static due to using ins } } +#ifdef ULTIPANEL_FEEDMULTIPLY + // Dead zone at 100% feedrate + if ((feedmultiply < 100 && (feedmultiply + int(lcd_encoder)) > 100) || + (feedmultiply > 100 && (feedmultiply + int(lcd_encoder)) < 100)) + { + lcd_encoder = 0; + feedmultiply = 100; + } + if (feedmultiply == 100 && int(lcd_encoder) > ENCODER_FEEDRATE_DEADZONE) + { + feedmultiply += int(lcd_encoder) - ENCODER_FEEDRATE_DEADZONE; + lcd_encoder = 0; + } + else if (feedmultiply == 100 && int(lcd_encoder) < -ENCODER_FEEDRATE_DEADZONE) + { + feedmultiply += int(lcd_encoder) + ENCODER_FEEDRATE_DEADZONE; + lcd_encoder = 0; + } + else if (feedmultiply != 100) + { + feedmultiply += int(lcd_encoder); + lcd_encoder = 0; + } +#endif //ULTIPANEL_FEEDMULTIPLY + + if (feedmultiply < 10) + feedmultiply = 10; + else if (feedmultiply > 999) + feedmultiply = 999; + if (lcd_status_update_delay) lcd_status_update_delay--; else @@ -1073,36 +1103,6 @@ void lcd_status_screen() // NOT static due to using ins menu_submenu(lcd_main_menu); lcd_refresh(); // to maybe revive the LCD if static electricity killed it. } - -#ifdef ULTIPANEL_FEEDMULTIPLY - // Dead zone at 100% feedrate - if ((feedmultiply < 100 && (feedmultiply + int(lcd_encoder)) > 100) || - (feedmultiply > 100 && (feedmultiply + int(lcd_encoder)) < 100)) - { - lcd_encoder = 0; - feedmultiply = 100; - } - if (feedmultiply == 100 && int(lcd_encoder) > ENCODER_FEEDRATE_DEADZONE) - { - feedmultiply += int(lcd_encoder) - ENCODER_FEEDRATE_DEADZONE; - lcd_encoder = 0; - } - else if (feedmultiply == 100 && int(lcd_encoder) < -ENCODER_FEEDRATE_DEADZONE) - { - feedmultiply += int(lcd_encoder) + ENCODER_FEEDRATE_DEADZONE; - lcd_encoder = 0; - } - else if (feedmultiply != 100) - { - feedmultiply += int(lcd_encoder); - lcd_encoder = 0; - } -#endif //ULTIPANEL_FEEDMULTIPLY - - if (feedmultiply < 10) - feedmultiply = 10; - else if (feedmultiply > 999) - feedmultiply = 999; } void lcd_commands() From 1bac0c176518a13a320d7dd69d400f21902927c7 Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Sat, 18 Apr 2020 16:39:04 +0200 Subject: [PATCH 09/73] Add dummy G21 to prevent UNKOWN warnings in serial And as Prusa firmware operates ONLY in milimeters it kind of does what G21 is supposed to do. --- Firmware/Marlin_main.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index e4e1e0b2b..d6955f89c 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -4276,6 +4276,14 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) #endif //FWRETRACT + /*! + ### G21 - Sets Units to Millimters G21: Set Units to Millimeters + Units are in millimeters. Prusa doesn't support inches. + */ + 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). From a0cf5714ceca7d60c5874c376898ecd8badd7d13 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Fri, 19 Jun 2020 15:39:16 +0300 Subject: [PATCH 10/73] M220 M221 --- Firmware/Marlin_main.cpp | 58 ++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 8dbc0d840..d4ed0c51b 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -7300,17 +7300,26 @@ Sigma_Exit: */ case 220: // M220 S- set speed factor override percentage { - if (code_seen('B')) //backup current speed factor - { - saved_feedmultiply_mm = feedmultiply; - } - if(code_seen('S')) - { - feedmultiply = code_value() ; - } - if (code_seen('R')) { //restore previous feedmultiply - feedmultiply = saved_feedmultiply_mm; - } + bool codesWereSeen = false; + if (code_seen('B')) //backup current speed factor + { + saved_feedmultiply_mm = feedmultiply; + codesWereSeen = true; + } + if (code_seen('S')) + { + feedmultiply = code_value(); + codesWereSeen = true; + } + if (code_seen('R')) //restore previous feedmultiply + { + feedmultiply = saved_feedmultiply_mm; + codesWereSeen = true; + } + if (!codesWereSeen) + { + printf_P(PSTR("%i%%\n"), feedmultiply); + } } break; @@ -7326,23 +7335,26 @@ Sigma_Exit: */ case 221: // M221 S- set extrude factor override percentage { - if(code_seen('S')) - { - int tmp_code = code_value(); - if (code_seen('T')) + if (code_seen('S')) { - uint8_t extruder; - if(setTargetedHotend(221, extruder)){ - break; - } - extruder_multiply[extruder] = tmp_code; + int tmp_code = code_value(); + if (code_seen('T')) + { + uint8_t extruder; + if (setTargetedHotend(221, extruder)) + break; + extruder_multiply[extruder] = tmp_code; + } + else + { + extrudemultiply = tmp_code ; + } } else { - extrudemultiply = tmp_code ; + printf_P(PSTR("%i%%\n"), extrudemultiply); } - } - calculate_extruder_multipliers(); + calculate_extruder_multipliers(); } break; From d53c55ce6493475e648cd779310fda83d27586de Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Tue, 23 Apr 2019 20:07:22 +0200 Subject: [PATCH 11/73] Disable filament checks inside the Move -> Extruder menu --- Firmware/Marlin_main.cpp | 2 +- Firmware/ultralcd.cpp | 2 +- Firmware/ultralcd.h | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 8dbc0d840..9bb62ba11 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -9496,7 +9496,7 @@ static uint16_t nFSCheckCount=0; bInhibitFlag=bInhibitFlag||bMenuFSDetect; // Settings::HWsetup::FSdetect menu active #endif // IR_SENSOR_ANALOG #endif // IR_SENSOR - if ((mcode_in_progress != 600) && (eFilamentAction != FilamentAction::AutoLoad) && (!bInhibitFlag)) //M600 not in progress, preHeat @ autoLoad menu not active, Support::ExtruderInfo/SensorInfo menu not active + if ((mcode_in_progress != 600) && (eFilamentAction != FilamentAction::AutoLoad) && (!bInhibitFlag) && (menu_menu != lcd_move_e)) //M600 not in progress, preHeat @ autoLoad menu not active, Support::ExtruderInfo/SensorInfo menu not active { if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LcdCommands::Layer1Cal) && ! eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE)) { diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 87266914f..b6c28e607 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -2929,7 +2929,7 @@ static void _lcd_move(const char *name, int axis, int min, int max) } -static void lcd_move_e() +void lcd_move_e() { if (degHotend0() > EXTRUDE_MINTEMP) { diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index 844c7c7d3..884007c3f 100755 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -205,6 +205,7 @@ void lcd_farm_sdcard_menu_w(); void lcd_wait_for_heater(); void lcd_wait_for_cool_down(); +void lcd_move_e(); // NOT static due to usage in Marlin_main void lcd_extr_cal_reset(); void lcd_temp_cal_show_result(bool result); From e2856ba4f579c51c6aa58e8614f71a498e021a6c Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Tue, 21 Jul 2020 12:52:04 +0300 Subject: [PATCH 12/73] Make the serial number available to the user --- Firmware/Marlin_main.cpp | 45 +++++++++++++++------------------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 8dbc0d840..49470ae12 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3286,37 +3286,26 @@ void gcode_M701() */ static void gcode_PRUSA_SN() { - if (farm_mode) { - selectedSerialPort = 0; - putchar(';'); - putchar('S'); - int numbersRead = 0; - ShortTimer timeout; - timeout.start(); + uint8_t selectedSerialPort_bak = selectedSerialPort; + selectedSerialPort = 0; + putchar(';'); + putchar('S'); + int numbersRead = 0; + ShortTimer timeout; + timeout.start(); - while (numbersRead < 19) { - while (MSerial.available() > 0) { - uint8_t serial_char = MSerial.read(); - selectedSerialPort = 1; - putchar(serial_char); - numbersRead++; - selectedSerialPort = 0; - } - if (timeout.expired(100u)) break; + while (numbersRead < 19) { + while (MSerial.available() > 0) { + uint8_t serial_char = MSerial.read(); + selectedSerialPort = selectedSerialPort_bak; + putchar(serial_char); + numbersRead++; + selectedSerialPort = 0; } - selectedSerialPort = 1; - putchar('\n'); -#if 0 - for (int b = 0; b < 3; b++) { - _tone(BEEPER, 110); - _delay(50); - _noTone(BEEPER); - _delay(50); - } -#endif - } else { - puts_P(_N("Not in farm mode.")); + if (timeout.expired(100u)) break; } + selectedSerialPort = selectedSerialPort_bak; + putchar('\n'); } //! Detection of faulty RAMBo 1.1b boards equipped with bigger capacitors //! at the TACH_1 pin, which causes bad detection of print fan speed. From d8fbd46cd28910f17e5c7c3947394a61c2c7ff50 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Thu, 23 Jul 2020 17:28:25 +0300 Subject: [PATCH 13/73] M155 --- Firmware/Configuration_adv.h | 5 + Firmware/Marlin_main.cpp | 214 +++++++++++++++++++++-------------- 2 files changed, 133 insertions(+), 86 deletions(-) diff --git a/Firmware/Configuration_adv.h b/Firmware/Configuration_adv.h index 5386c2815..18e7a11b9 100644 --- a/Firmware/Configuration_adv.h +++ b/Firmware/Configuration_adv.h @@ -62,6 +62,11 @@ // before setting a PWM value. (Does not work with software PWM for fan on Sanguinololu) #define FAN_KICKSTART_TIME 800 +/** + * Auto-report temperatures with M155 S + */ +#define AUTO_REPORT_TEMPERATURES + diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 8dbc0d840..53b04eee4 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -393,6 +393,11 @@ static int saved_fanSpeed = 0; //!< Print fan speed static int saved_feedmultiply_mm = 100; +#ifdef AUTO_REPORT_TEMPERATURES +static LongTimer auto_report_temp_timer; +static uint8_t auto_report_temp_period = 0; +#endif //AUTO_REPORT_TEMPERATURES + //=========================================================================== //=============================Routines====================================== //=========================================================================== @@ -402,6 +407,7 @@ static bool setTargetedHotend(int code, uint8_t &extruder); static void print_time_remaining_init(); static void wait_for_heater(long codenum, uint8_t extruder); static void gcode_G28(bool home_x_axis, bool home_y_axis, bool home_z_axis); +static void gcode_M115(uint8_t extruder); static void temp_compensation_start(); static void temp_compensation_apply(); @@ -1720,6 +1726,18 @@ void host_keepalive() { #endif //HOST_KEEPALIVE_FEATURE if (farm_mode) return; long ms = _millis(); + +#ifdef AUTO_REPORT_TEMPERATURES + if (auto_report_temp_timer.running()) + { + if (auto_report_temp_timer.expired(auto_report_temp_period * 1000ul)) + { + gcode_M115(active_extruder); + auto_report_temp_timer.start(); + } + } +#endif //AUTO_REPORT_TEMPERATURES + if (host_keepalive_interval && busy_state != NOT_BUSY) { if ((ms - prev_busy_signal_ms) < (long)(1000L * host_keepalive_interval)) return; switch (busy_state) { @@ -2523,6 +2541,96 @@ void force_high_power_mode(bool start_high_power_section) { } #endif //TMC2130 +void gcode_M115(uint8_t extruder) +{ +#if defined(TEMP_0_PIN) && TEMP_0_PIN > -1 + SERIAL_PROTOCOLPGM("T:"); + SERIAL_PROTOCOL_F(degHotend(extruder),1); + SERIAL_PROTOCOLPGM(" /"); + SERIAL_PROTOCOL_F(degTargetHotend(extruder),1); +#if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1 + SERIAL_PROTOCOLPGM(" B:"); + SERIAL_PROTOCOL_F(degBed(),1); + SERIAL_PROTOCOLPGM(" /"); + SERIAL_PROTOCOL_F(degTargetBed(),1); +#endif //TEMP_BED_PIN + for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) { + SERIAL_PROTOCOLPGM(" T"); + SERIAL_PROTOCOL(cur_extruder); + SERIAL_PROTOCOL(':'); + SERIAL_PROTOCOL_F(degHotend(cur_extruder),1); + SERIAL_PROTOCOLPGM(" /"); + SERIAL_PROTOCOL_F(degTargetHotend(cur_extruder),1); + } +#else + SERIAL_ERROR_START; + SERIAL_ERRORLNRPGM(_i("No thermistors - no temperature"));////MSG_ERR_NO_THERMISTORS +#endif + + SERIAL_PROTOCOLPGM(" @:"); +#ifdef EXTRUDER_WATTS + SERIAL_PROTOCOL((EXTRUDER_WATTS * getHeaterPower(tmp_extruder))/127); + SERIAL_PROTOCOLPGM("W"); +#else + SERIAL_PROTOCOL(getHeaterPower(extruder)); +#endif + + SERIAL_PROTOCOLPGM(" B@:"); +#ifdef BED_WATTS + SERIAL_PROTOCOL((BED_WATTS * getHeaterPower(-1))/127); + SERIAL_PROTOCOLPGM("W"); +#else + SERIAL_PROTOCOL(getHeaterPower(-1)); +#endif + +#ifdef PINDA_THERMISTOR + SERIAL_PROTOCOLPGM(" P:"); + SERIAL_PROTOCOL_F(current_temperature_pinda,1); +#endif //PINDA_THERMISTOR + +#ifdef AMBIENT_THERMISTOR + SERIAL_PROTOCOLPGM(" A:"); + SERIAL_PROTOCOL_F(current_temperature_ambient,1); +#endif //AMBIENT_THERMISTOR + + +#ifdef SHOW_TEMP_ADC_VALUES + { + float raw = 0.0; +#if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1 + SERIAL_PROTOCOLPGM(" ADC B:"); + SERIAL_PROTOCOL_F(degBed(),1); + SERIAL_PROTOCOLPGM("C->"); + raw = rawBedTemp(); + SERIAL_PROTOCOL_F(raw/OVERSAMPLENR,5); + SERIAL_PROTOCOLPGM(" Rb->"); + SERIAL_PROTOCOL_F(100 * (1 + (PtA * (raw/OVERSAMPLENR)) + (PtB * sq((raw/OVERSAMPLENR)))), 5); + SERIAL_PROTOCOLPGM(" Rxb->"); + SERIAL_PROTOCOL_F(raw, 5); +#endif + for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) { + SERIAL_PROTOCOLPGM(" T"); + SERIAL_PROTOCOL(cur_extruder); + SERIAL_PROTOCOLPGM(":"); + SERIAL_PROTOCOL_F(degHotend(cur_extruder),1); + SERIAL_PROTOCOLPGM("C->"); + raw = rawHotendTemp(cur_extruder); + SERIAL_PROTOCOL_F(raw/OVERSAMPLENR,5); + SERIAL_PROTOCOLPGM(" Rt"); + SERIAL_PROTOCOL(cur_extruder); + SERIAL_PROTOCOLPGM("->"); + SERIAL_PROTOCOL_F(100 * (1 + (PtA * (raw/OVERSAMPLENR)) + (PtB * sq((raw/OVERSAMPLENR)))), 5); + SERIAL_PROTOCOLPGM(" Rx"); + SERIAL_PROTOCOL(cur_extruder); + SERIAL_PROTOCOLPGM("->"); + SERIAL_PROTOCOL_F(raw, 5); + } + } +#endif + SERIAL_PROTOCOLLN(""); + KEEPALIVE_STATE(NOT_BUSY); +} + #ifdef TMC2130 static void gcode_G28(bool home_x_axis, long home_x_value, bool home_y_axis, long home_y_value, bool home_z_axis, long home_z_value, bool calib, bool without_mbl) #else @@ -6280,96 +6388,30 @@ Sigma_Exit: uint8_t extruder; if(setTargetedHotend(105, extruder)){ break; - } - #if defined(TEMP_0_PIN) && TEMP_0_PIN > -1 - SERIAL_PROTOCOLPGM("ok T:"); - SERIAL_PROTOCOL_F(degHotend(extruder),1); - SERIAL_PROTOCOLPGM(" /"); - SERIAL_PROTOCOL_F(degTargetHotend(extruder),1); - #if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1 - SERIAL_PROTOCOLPGM(" B:"); - SERIAL_PROTOCOL_F(degBed(),1); - SERIAL_PROTOCOLPGM(" /"); - SERIAL_PROTOCOL_F(degTargetBed(),1); - #endif //TEMP_BED_PIN - for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) { - SERIAL_PROTOCOLPGM(" T"); - SERIAL_PROTOCOL(cur_extruder); - SERIAL_PROTOCOL(':'); - SERIAL_PROTOCOL_F(degHotend(cur_extruder),1); - SERIAL_PROTOCOLPGM(" /"); - SERIAL_PROTOCOL_F(degTargetHotend(cur_extruder),1); - } - #else - SERIAL_ERROR_START; - SERIAL_ERRORLNRPGM(_i("No thermistors - no temperature"));////MSG_ERR_NO_THERMISTORS - #endif - - SERIAL_PROTOCOLPGM(" @:"); - #ifdef EXTRUDER_WATTS - SERIAL_PROTOCOL((EXTRUDER_WATTS * getHeaterPower(tmp_extruder))/127); - SERIAL_PROTOCOLPGM("W"); - #else - SERIAL_PROTOCOL(getHeaterPower(extruder)); - #endif - - SERIAL_PROTOCOLPGM(" B@:"); - #ifdef BED_WATTS - SERIAL_PROTOCOL((BED_WATTS * getHeaterPower(-1))/127); - SERIAL_PROTOCOLPGM("W"); - #else - SERIAL_PROTOCOL(getHeaterPower(-1)); - #endif - -#ifdef PINDA_THERMISTOR - SERIAL_PROTOCOLPGM(" P:"); - SERIAL_PROTOCOL_F(current_temperature_pinda,1); -#endif //PINDA_THERMISTOR - -#ifdef AMBIENT_THERMISTOR - SERIAL_PROTOCOLPGM(" A:"); - SERIAL_PROTOCOL_F(current_temperature_ambient,1); -#endif //AMBIENT_THERMISTOR - - - #ifdef SHOW_TEMP_ADC_VALUES - {float raw = 0.0; - - #if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1 - SERIAL_PROTOCOLPGM(" ADC B:"); - SERIAL_PROTOCOL_F(degBed(),1); - SERIAL_PROTOCOLPGM("C->"); - raw = rawBedTemp(); - SERIAL_PROTOCOL_F(raw/OVERSAMPLENR,5); - SERIAL_PROTOCOLPGM(" Rb->"); - SERIAL_PROTOCOL_F(100 * (1 + (PtA * (raw/OVERSAMPLENR)) + (PtB * sq((raw/OVERSAMPLENR)))), 5); - SERIAL_PROTOCOLPGM(" Rxb->"); - SERIAL_PROTOCOL_F(raw, 5); - #endif - for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) { - SERIAL_PROTOCOLPGM(" T"); - SERIAL_PROTOCOL(cur_extruder); - SERIAL_PROTOCOLPGM(":"); - SERIAL_PROTOCOL_F(degHotend(cur_extruder),1); - SERIAL_PROTOCOLPGM("C->"); - raw = rawHotendTemp(cur_extruder); - SERIAL_PROTOCOL_F(raw/OVERSAMPLENR,5); - SERIAL_PROTOCOLPGM(" Rt"); - SERIAL_PROTOCOL(cur_extruder); - SERIAL_PROTOCOLPGM("->"); - SERIAL_PROTOCOL_F(100 * (1 + (PtA * (raw/OVERSAMPLENR)) + (PtB * sq((raw/OVERSAMPLENR)))), 5); - SERIAL_PROTOCOLPGM(" Rx"); - SERIAL_PROTOCOL(cur_extruder); - SERIAL_PROTOCOLPGM("->"); - SERIAL_PROTOCOL_F(raw, 5); - }} - #endif - SERIAL_PROTOCOLLN(""); - KEEPALIVE_STATE(NOT_BUSY); + } + + SERIAL_PROTOCOLPGM("ok "); + gcode_M115(extruder); + return; break; } +#ifdef AUTO_REPORT_TEMPERATURES + case 155: + { + if (code_seen('S')) + { + auto_report_temp_period = code_value_uint8(); + if (auto_report_temp_period != 0) + auto_report_temp_timer.start(); + else + auto_report_temp_timer.stop(); + } + } + break; +#endif //AUTO_REPORT_TEMPERATURES + /*! ### M109 - Wait for extruder temperature M109: Set Extruder Temperature and Wait #### Usage From 2c2926882a924d1deabaf046f8a9a82eae9f3594 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Tue, 18 Aug 2020 19:29:18 +0300 Subject: [PATCH 14/73] Don't switch unnecessarily. Also "\n" the ";S" request --- Firmware/Marlin_main.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 49470ae12..70a8f7e57 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3287,25 +3287,23 @@ void gcode_M701() static void gcode_PRUSA_SN() { uint8_t selectedSerialPort_bak = selectedSerialPort; + char SN[20]; selectedSerialPort = 0; - putchar(';'); - putchar('S'); - int numbersRead = 0; + SERIAL_ECHOLNRPGM(PSTR(";S")); + uint8_t numbersRead = 0; ShortTimer timeout; timeout.start(); - while (numbersRead < 19) { - while (MSerial.available() > 0) { - uint8_t serial_char = MSerial.read(); - selectedSerialPort = selectedSerialPort_bak; - putchar(serial_char); + while (numbersRead < (sizeof(SN) - 1)) { + if (MSerial.available() > 0) { + SN[numbersRead] = MSerial.read(); numbersRead++; - selectedSerialPort = 0; } if (timeout.expired(100u)) break; } + SN[numbersRead] = 0; selectedSerialPort = selectedSerialPort_bak; - putchar('\n'); + SERIAL_ECHOLN(SN); } //! Detection of faulty RAMBo 1.1b boards equipped with bigger capacitors //! at the TACH_1 pin, which causes bad detection of print fan speed. From 1659f61dd52ed0be9bc4e825fb10df4414176c2a Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Fri, 21 Aug 2020 10:51:46 +0300 Subject: [PATCH 15/73] Fix fastio extra parenthesis --- Firmware/fastio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/fastio.h b/Firmware/fastio.h index e4f25ed8b..acded8cb6 100644 --- a/Firmware/fastio.h +++ b/Firmware/fastio.h @@ -58,7 +58,7 @@ #define _GET_OUTPUT(IO) ((DIO ## IO ## _DDR & MASK(DIO ## IO ## _PIN)) != 0) /// check if pin is an timer -#define _GET_TIMER(IO) ((DIO ## IO ## _PWM) +#define _GET_TIMER(IO) (DIO ## IO ## _PWM) // why double up on these macros? see http://gcc.gnu.org/onlinedocs/cpp/Stringification.html From 3e7bba54e0c4caffc8d39e47af9f4659d8589aac Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Fri, 28 Aug 2020 17:32:07 +0300 Subject: [PATCH 16/73] SD card released message --- Firmware/cardreader.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Firmware/cardreader.cpp b/Firmware/cardreader.cpp index a49cd6d68..fdef1cd43 100644 --- a/Firmware/cardreader.cpp +++ b/Firmware/cardreader.cpp @@ -243,6 +243,8 @@ void CardReader::release() { sdprinting = false; cardOK = false; + SERIAL_ECHO_START; + SERIAL_ECHOLNRPGM(_n("SD card released"));////MSG_SD_CARD_RELEASED } void CardReader::startFileprint() From 7ac16d5f045aef836a1cf7d36b9f9cfeee45192d Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Mon, 7 Sep 2020 19:42:53 +0300 Subject: [PATCH 17/73] Menu view return patch --- Firmware/menu.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Firmware/menu.cpp b/Firmware/menu.cpp index d31dce7ee..3c4e89260 100755 --- a/Firmware/menu.cpp +++ b/Firmware/menu.cpp @@ -48,6 +48,7 @@ void menu_goto(menu_func_t menu, const uint32_t encoder, const bool feedback, bo { menu_menu = menu; lcd_encoder = encoder; + menu_top = 0; //reset menu view. Needed if menu_back() is called from deep inside a menu, such as Support asm("sei"); if (reset_menu_state) { From 160af0a62482c27d57f152a2e5c8bdcb84214166 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Fri, 11 Sep 2020 16:11:28 +0300 Subject: [PATCH 18/73] Printer capabilities --- Firmware/Configuration_adv.h | 5 +++++ Firmware/Marlin_main.cpp | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/Firmware/Configuration_adv.h b/Firmware/Configuration_adv.h index 7ab7a2ee8..29f7e951e 100644 --- a/Firmware/Configuration_adv.h +++ b/Firmware/Configuration_adv.h @@ -376,6 +376,11 @@ const unsigned int dropsegments=5; //everything with less than this number of st #endif #endif +/** + * Include capabilities in M115 output + */ +// #define EXTENDED_CAPABILITIES_REPORT + //=========================================================================== //============================= Define Defines ============================ //=========================================================================== diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index f1908f213..85d54d3b5 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3404,6 +3404,17 @@ static void gcode_G92() } } +#ifdef EXTENDED_CAPABILITIES_REPORT + +static void cap_line(const char* name, bool ena = false) { + printf_P(PSTR("Cap:%S:%c\n"), name, (char)ena + '0'); +} + +static void extended_capabilities_report() +{ + //@todo +} +#endif //EXTENDED_CAPABILITIES_REPORT #ifdef BACKLASH_X extern uint8_t st_backlash_x; @@ -6803,6 +6814,11 @@ Sigma_Exit: SERIAL_ECHOPGM(" UUID:"); SERIAL_ECHOLNPGM(MACHINE_UUID); } + +#ifdef EXTENDED_CAPABILITIES_REPORT + extended_capabilities_report(); +#endif //EXTENDED_CAPABILITIES_REPORT + break; /*! From eb007c35d27f94eb880653a39ba21930cae497bd Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Fri, 11 Sep 2020 16:12:49 +0300 Subject: [PATCH 19/73] Macros initial --- Firmware/Marlin.h | 7 +------ Firmware/Marlin_main.cpp | 9 +++------ Firmware/backlight.cpp | 6 +++--- Firmware/language.c | 6 +++--- Firmware/language.h | 4 +--- Firmware/macros.h | 18 ++++++++++++++++++ Firmware/tone04.c | 12 +++--------- Firmware/uart2.c | 5 +++-- 8 files changed, 35 insertions(+), 32 deletions(-) create mode 100644 Firmware/macros.h diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index a1736e9c2..6e4b24206 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -4,7 +4,7 @@ #ifndef MARLIN_H #define MARLIN_H -#define FORCE_INLINE __attribute__((always_inline)) inline +#include "macros.h" #include #include @@ -287,11 +287,6 @@ FORCE_INLINE unsigned long millis_nc() { void setPwmFrequency(uint8_t pin, int val); #endif -#ifndef CRITICAL_SECTION_START - #define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli(); - #define CRITICAL_SECTION_END SREG = _sreg; -#endif //CRITICAL_SECTION_START - extern bool fans_check_enabled; extern float homing_feedrate[]; extern uint8_t axis_relative_modes; diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 85d54d3b5..4ea488946 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -47,7 +47,9 @@ #include "Configuration.h" #include "Marlin.h" #include "config.h" - + +#include "macros.h" + #ifdef ENABLE_AUTO_BED_LEVELING #include "vector_3.h" #ifdef AUTO_BED_LEVELING_GRID @@ -139,11 +141,6 @@ #include "cmdqueue.h" #include "io_atmega2560.h" -// Macros for bit masks -#define BIT(b) (1<<(b)) -#define TEST(n,b) (((n)&BIT(b))!=0) -#define SET_BIT(n,b,value) (n) ^= ((-value)^(n)) & (BIT(b)) - //Macro for print fan speed #define FAN_PULSE_WIDTH_LIMIT ((fanSpeed > 100) ? 3 : 4) //time in ms diff --git a/Firmware/backlight.cpp b/Firmware/backlight.cpp index 6500837e5..b59a65ef4 100644 --- a/Firmware/backlight.cpp +++ b/Firmware/backlight.cpp @@ -1,10 +1,10 @@ //backlight.cpp #include "backlight.h" +#include "macros.h" #include #include #include "eeprom.h" -#include "Marlin.h" #include "pins.h" #include "fastio.h" #include "Timer.h" @@ -111,10 +111,10 @@ void backlight_init() #else //LCD_BL_PIN -void force_bl_on(__attribute__((unused)) bool section_start) {} +void force_bl_on(_UNUSED bool section_start) {} void backlight_update() {} void backlight_init() {} void backlight_save() {} -void backlight_wake(__attribute__((unused)) const uint8_t flashNo) {} +void backlight_wake(_UNUSED const uint8_t flashNo) {} #endif //LCD_BL_PIN \ No newline at end of file diff --git a/Firmware/language.c b/Firmware/language.c index e43760967..f7d02b22a 100644 --- a/Firmware/language.c +++ b/Firmware/language.c @@ -17,10 +17,10 @@ uint8_t lang_selected = 0; #if (LANG_MODE == 0) //primary language only -uint8_t lang_select(__attribute__((unused)) uint8_t lang) { return 0; } +uint8_t lang_select(_UNUSED uint8_t lang) { return 0; } uint8_t lang_get_count() { return 1; } -uint16_t lang_get_code(__attribute__((unused)) uint8_t lang) { return LANG_CODE_EN; } -const char* lang_get_name_by_code(__attribute__((unused)) uint16_t code) { return _n("English"); } +uint16_t lang_get_code(_UNUSED uint8_t lang) { return LANG_CODE_EN; } +const char* lang_get_name_by_code(_UNUSED uint16_t code) { return _n("English"); } void lang_reset(void) { } uint8_t lang_is_selected(void) { return 1; } diff --git a/Firmware/language.h b/Firmware/language.h index 1e4137bf3..4f89b9f25 100644 --- a/Firmware/language.h +++ b/Firmware/language.h @@ -5,6 +5,7 @@ #include "config.h" +#include "macros.h" #include #ifdef DEBUG_SEC_LANG #include @@ -22,9 +23,6 @@ #define MSG_FW_VERSION "Firmware" -#define STRINGIFY_(n) #n -#define STRINGIFY(n) STRINGIFY_(n) - #if (LANG_MODE == 0) //primary language only #define PROGMEM_I2 __attribute__((section(".progmem0"))) #define PROGMEM_I1 __attribute__((section(".progmem1"))) diff --git a/Firmware/macros.h b/Firmware/macros.h new file mode 100644 index 000000000..c27dbde77 --- /dev/null +++ b/Firmware/macros.h @@ -0,0 +1,18 @@ +#ifndef MACROS_H +#define MACROS_H + + +#define FORCE_INLINE __attribute__((always_inline)) inline +#define _UNUSED __attribute__((unused)) + +#ifndef CRITICAL_SECTION_START + #define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli(); + #define CRITICAL_SECTION_END SREG = _sreg; +#endif //CRITICAL_SECTION_START + +// Macros to make a string from a macro +#define STRINGIFY_(M) #M +#define STRINGIFY(M) STRINGIFY_(M) + + +#endif //MACROS_H diff --git a/Firmware/tone04.c b/Firmware/tone04.c index 41f904a91..42b19682f 100644 --- a/Firmware/tone04.c +++ b/Firmware/tone04.c @@ -10,14 +10,8 @@ #include #include #include "pins.h" - -#ifndef CRITICAL_SECTION_START - #define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli(); - #define CRITICAL_SECTION_END SREG = _sreg; -#endif //CRITICAL_SECTION_START - - #include "fastio.h" +#include "macros.h" void timer4_init(void) { @@ -79,7 +73,7 @@ ISR(TIMER4_OVF_vect) WRITE(BEEPER, 0); } -void tone4(__attribute__((unused)) uint8_t _pin, uint16_t frequency) +void tone4(_UNUSED uint8_t _pin, uint16_t frequency) { //this ocr and prescalarbits calculation is taken from the Arduino core and simplified for one type of timer only uint8_t prescalarbits = 0b001; @@ -105,7 +99,7 @@ void tone4(__attribute__((unused)) uint8_t _pin, uint16_t frequency) CRITICAL_SECTION_END; } -void noTone4(__attribute__((unused)) uint8_t _pin) +void noTone4(_UNUSED uint8_t _pin) { CRITICAL_SECTION_START; // Revert prescaler to CLK/1024 diff --git a/Firmware/uart2.c b/Firmware/uart2.c index 472389994..9a2a724e1 100644 --- a/Firmware/uart2.c +++ b/Firmware/uart2.c @@ -4,6 +4,7 @@ #include #include #include "rbuf.h" +#include "macros.h" #define UART2_BAUD 115200 #define UART_BAUD_SELECT(baudRate,xtalCpu) (((float)(xtalCpu))/(((float)(baudRate))*8.0)-1.0+0.5) @@ -16,7 +17,7 @@ uint8_t uart2_ibuf[14] = {0, 0}; FILE _uart2io = {0}; -int uart2_putchar(char c, FILE *stream __attribute__((unused))) +int uart2_putchar(char c, _UNUSED FILE *stream) { while (!uart2_txready); UDR2 = c; // transmit byte @@ -25,7 +26,7 @@ int uart2_putchar(char c, FILE *stream __attribute__((unused))) return 0; } -int uart2_getchar(FILE *stream __attribute__((unused))) +int uart2_getchar(_UNUSED FILE *stream) { if (rbuf_empty(uart2_ibuf)) return -1; return rbuf_get(uart2_ibuf); From c3abd4ffe670faaa1d9b44bf4c52bfcd58ba500c Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Fri, 11 Sep 2020 17:43:38 +0300 Subject: [PATCH 20/73] Remove io_atmega2560.h and some more macros --- Firmware/Marlin_main.cpp | 3 +- Firmware/fastio.h | 28 +-- Firmware/fsensor.cpp | 6 +- Firmware/heatbed_pwm.cpp | 1 - Firmware/io_atmega2560.h | 374 -------------------------------------- Firmware/macros.h | 17 ++ Firmware/mmu.cpp | 26 ++- Firmware/pins_Einsy_1_0.h | 2 + Firmware/swi2c.c | 58 +++--- Firmware/timer02.c | 3 - Firmware/ultralcd.cpp | 5 +- Firmware/w25x20cl.c | 8 +- 12 files changed, 79 insertions(+), 452 deletions(-) delete mode 100644 Firmware/io_atmega2560.h diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 4ea488946..7f61c0a8c 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -139,7 +139,6 @@ #include "sound.h" #include "cmdqueue.h" -#include "io_atmega2560.h" //Macro for print fan speed #define FAN_PULSE_WIDTH_LIMIT ((fanSpeed > 100) ? 3 : 4) //time in ms @@ -876,7 +875,7 @@ static void check_if_fw_is_on_right_printer(){ #ifdef PAT9125 //will return 1 only if IR can detect filament in bondtech extruder so this may fail even when we have IR sensor - const uint8_t ir_detected = !(PIN_GET(IR_SENSOR_PIN)); + const uint8_t ir_detected = !READ(IR_SENSOR_PIN); if (ir_detected){ lcd_show_fullscreen_message_and_wait_P(_i("MK3 firmware detected on MK3S printer"));}////c=20 r=3 #endif //PAT9125 diff --git a/Firmware/fastio.h b/Firmware/fastio.h index acded8cb6..19c278d4a 100644 --- a/Firmware/fastio.h +++ b/Firmware/fastio.h @@ -7,15 +7,7 @@ #define _FASTIO_ARDUINO_H #include - -/* - utility functions -*/ - -#ifndef MASK -/// MASKING- returns \f$2^PIN\f$ -#define MASK(PIN) (1 << PIN) -#endif +#include "macros.h" /* magic I/O routines @@ -23,20 +15,20 @@ */ /// Read a pin -#define _READ(IO) ((bool)(DIO ## IO ## _RPORT & MASK(DIO ## IO ## _PIN))) +#define _READ(IO) ((bool)(DIO ## IO ## _RPORT & _BV(DIO ## IO ## _PIN))) /// write to a pin // On some boards pins > 0x100 are used. These are not converted to atomic actions. An critical section is needed. -#define _WRITE_NC(IO, v) do { if (v) {DIO ## IO ## _WPORT |= MASK(DIO ## IO ## _PIN); } else {DIO ## IO ## _WPORT &= ~MASK(DIO ## IO ## _PIN); }; } while (0) +#define _WRITE_NC(IO, v) do { if (v) {DIO ## IO ## _WPORT |= _BV(DIO ## IO ## _PIN); } else {DIO ## IO ## _WPORT &= ~_BV(DIO ## IO ## _PIN); }; } while (0) #define _WRITE_C(IO, v) do { if (v) { \ CRITICAL_SECTION_START; \ - {DIO ## IO ## _WPORT |= MASK(DIO ## IO ## _PIN); }\ + {DIO ## IO ## _WPORT |= _BV(DIO ## IO ## _PIN); }\ CRITICAL_SECTION_END; \ }\ else {\ CRITICAL_SECTION_START; \ - {DIO ## IO ## _WPORT &= ~MASK(DIO ## IO ## _PIN); }\ + {DIO ## IO ## _WPORT &= ~_BV(DIO ## IO ## _PIN); }\ CRITICAL_SECTION_END; \ }\ }\ @@ -45,17 +37,17 @@ #define _WRITE(IO, v) do { if (&(DIO ## IO ## _RPORT) >= (uint8_t *)0x100) {_WRITE_C(IO, v); } else {_WRITE_NC(IO, v); }; } while (0) /// toggle a pin -#define _TOGGLE(IO) do {DIO ## IO ## _RPORT = MASK(DIO ## IO ## _PIN); } while (0) +#define _TOGGLE(IO) do {DIO ## IO ## _RPORT = _BV(DIO ## IO ## _PIN); } while (0) /// set pin as input -#define _SET_INPUT(IO) do {DIO ## IO ## _DDR &= ~MASK(DIO ## IO ## _PIN); } while (0) +#define _SET_INPUT(IO) do {DIO ## IO ## _DDR &= ~_BV(DIO ## IO ## _PIN); } while (0) /// set pin as output -#define _SET_OUTPUT(IO) do {DIO ## IO ## _DDR |= MASK(DIO ## IO ## _PIN); } while (0) +#define _SET_OUTPUT(IO) do {DIO ## IO ## _DDR |= _BV(DIO ## IO ## _PIN); } while (0) /// check if pin is an input -#define _GET_INPUT(IO) ((DIO ## IO ## _DDR & MASK(DIO ## IO ## _PIN)) == 0) +#define _GET_INPUT(IO) ((DIO ## IO ## _DDR & _BV(DIO ## IO ## _PIN)) == 0) /// check if pin is an output -#define _GET_OUTPUT(IO) ((DIO ## IO ## _DDR & MASK(DIO ## IO ## _PIN)) != 0) +#define _GET_OUTPUT(IO) ((DIO ## IO ## _DDR & _BV(DIO ## IO ## _PIN)) != 0) /// check if pin is an timer #define _GET_TIMER(IO) (DIO ## IO ## _PWM) diff --git a/Firmware/fsensor.cpp b/Firmware/fsensor.cpp index 7908c5dbc..c81a5ac6f 100755 --- a/Firmware/fsensor.cpp +++ b/Firmware/fsensor.cpp @@ -6,7 +6,6 @@ #include #include "pat9125.h" #include "stepper.h" -#include "io_atmega2560.h" #include "cmdqueue.h" #include "ultralcd.h" #include "mmu.h" @@ -608,9 +607,8 @@ void fsensor_st_block_chunk(int cnt) if (!fsensor_enabled) return; fsensor_st_cnt += cnt; - // !!! bit toggling (PINxn <- 1) (for PinChangeInterrupt) does not work for some MCU pins - if (PIN_GET(FSENSOR_INT_PIN)) {PIN_VAL(FSENSOR_INT_PIN, LOW);} - else {PIN_VAL(FSENSOR_INT_PIN, HIGH);} + // !!! bit toggling (PINxn <- 1) (for PinChangeInterrupt) does not work for some MCU pins + WRITE(FSENSOR_INT_PIN, !READ(FSENSOR_INT_PIN)); } #endif //PAT9125 diff --git a/Firmware/heatbed_pwm.cpp b/Firmware/heatbed_pwm.cpp index 8121df3ee..b97da52c5 100755 --- a/Firmware/heatbed_pwm.cpp +++ b/Firmware/heatbed_pwm.cpp @@ -1,6 +1,5 @@ #include #include -#include "io_atmega2560.h" // All this is about silencing the heat bed, as it behaves like a loudspeaker. // Basically, we want the PWM heating switched at 30Hz (or so) which is a well ballanced diff --git a/Firmware/io_atmega2560.h b/Firmware/io_atmega2560.h deleted file mode 100644 index e353eb05e..000000000 --- a/Firmware/io_atmega2560.h +++ /dev/null @@ -1,374 +0,0 @@ -//io_atmega2560.h -#ifndef _IO_ATMEGA2560 -#define _IO_ATMEGA2560 - - -#define __PIN_P0 PINE -#define __PIN_P1 PINE -#define __PIN_P2 PINE -#define __PIN_P3 PINE -#define __PIN_P4 PING -#define __PIN_P5 PINE -#define __PIN_P6 PINH -#define __PIN_P7 PINH -#define __PIN_P8 PINH -#define __PIN_P9 PINH -#define __PIN_P10 PINB -#define __PIN_P11 PINB -#define __PIN_P12 PINB -#define __PIN_P13 PINB -#define __PIN_P14 PINJ -#define __PIN_P15 PINJ -#define __PIN_P16 PINH -#define __PIN_P17 PINH -#define __PIN_P18 PIND -#define __PIN_P19 PIND -#define __PIN_P20 PIND -#define __PIN_P21 PIND -#define __PIN_P22 PINA -#define __PIN_P23 PINA -#define __PIN_P24 PINA -#define __PIN_P25 PINA -#define __PIN_P26 PINA -#define __PIN_P27 PINA -#define __PIN_P28 PINA -#define __PIN_P29 PINA -#define __PIN_P30 PINC -#define __PIN_P31 PINC -#define __PIN_P32 PINC -#define __PIN_P33 PINC -#define __PIN_P34 PINC -#define __PIN_P35 PINC -#define __PIN_P36 PINC -#define __PIN_P37 PINC -#define __PIN_P38 PIND -#define __PIN_P39 PING -#define __PIN_P40 PING -#define __PIN_P41 PING -#define __PIN_P42 PINL -#define __PIN_P43 PINL -#define __PIN_P44 PINL -#define __PIN_P45 PINL -#define __PIN_P46 PINL -#define __PIN_P47 PINL -#define __PIN_P48 PINL -#define __PIN_P49 PINL -#define __PIN_P50 PINB -#define __PIN_P51 PINB -#define __PIN_P52 PINB -#define __PIN_P53 PINB -#define __PIN_P54 PINF -#define __PIN_P55 PINF -#define __PIN_P56 PINF -#define __PIN_P57 PINF -#define __PIN_P58 PINF -#define __PIN_P59 PINF -#define __PIN_P60 PINF -#define __PIN_P61 PINF -#define __PIN_P62 PINK -#define __PIN_P63 PINK -#define __PIN_P64 PINK -#define __PIN_P65 PINK -#define __PIN_P66 PINK -#define __PIN_P67 PINK -#define __PIN_P68 PINK -#define __PIN_P69 PINK -#define __PIN_P70 PING -#define __PIN_P71 PING -#define __PIN_P72 PINJ -#define __PIN_P73 PINJ -#define __PIN_P74 PINJ -#define __PIN_P75 PINJ -#define __PIN_P76 PINJ -#define __PIN_P77 PINJ -#define __PIN_P78 PINE -#define __PIN_P79 PINE -#define __PIN_P80 PINE -#define __PIN_P81 PIND -#define __PIN_P82 PIND -#define __PIN_P83 PIND -#define __PIN_P84 PINH -#define __PIN_P85 PINH - -#define __PORT_P0 PORTE -#define __PORT_P1 PORTE -#define __PORT_P2 PORTE -#define __PORT_P3 PORTE -#define __PORT_P4 PORTG -#define __PORT_P5 PORTE -#define __PORT_P6 PORTH -#define __PORT_P7 PORTH -#define __PORT_P8 PORTH -#define __PORT_P9 PORTH -#define __PORT_P10 PORTB -#define __PORT_P11 PORTB -#define __PORT_P12 PORTB -#define __PORT_P13 PORTB -#define __PORT_P14 PORTJ -#define __PORT_P15 PORTJ -#define __PORT_P16 PORTH -#define __PORT_P17 PORTH -#define __PORT_P18 PORTD -#define __PORT_P19 PORTD -#define __PORT_P20 PORTD -#define __PORT_P21 PORTD -#define __PORT_P22 PORTA -#define __PORT_P23 PORTA -#define __PORT_P24 PORTA -#define __PORT_P25 PORTA -#define __PORT_P26 PORTA -#define __PORT_P27 PORTA -#define __PORT_P28 PORTA -#define __PORT_P29 PORTA -#define __PORT_P30 PORTC -#define __PORT_P31 PORTC -#define __PORT_P32 PORTC -#define __PORT_P33 PORTC -#define __PORT_P34 PORTC -#define __PORT_P35 PORTC -#define __PORT_P36 PORTC -#define __PORT_P37 PORTC -#define __PORT_P38 PORTD -#define __PORT_P39 PORTG -#define __PORT_P40 PORTG -#define __PORT_P41 PORTG -#define __PORT_P42 PORTL -#define __PORT_P43 PORTL -#define __PORT_P44 PORTL -#define __PORT_P45 PORTL -#define __PORT_P46 PORTL -#define __PORT_P47 PORTL -#define __PORT_P48 PORTL -#define __PORT_P49 PORTL -#define __PORT_P50 PORTB -#define __PORT_P51 PORTB -#define __PORT_P52 PORTB -#define __PORT_P53 PORTB -#define __PORT_P54 PORTF -#define __PORT_P55 PORTF -#define __PORT_P56 PORTF -#define __PORT_P57 PORTF -#define __PORT_P58 PORTF -#define __PORT_P59 PORTF -#define __PORT_P60 PORTF -#define __PORT_P61 PORTF -#define __PORT_P62 PORTK -#define __PORT_P63 PORTK -#define __PORT_P64 PORTK -#define __PORT_P65 PORTK -#define __PORT_P66 PORTK -#define __PORT_P67 PORTK -#define __PORT_P68 PORTK -#define __PORT_P69 PORTK -#define __PORT_P70 PORTG -#define __PORT_P71 PORTG -#define __PORT_P72 PORTJ -#define __PORT_P73 PORTJ -#define __PORT_P74 PORTJ -#define __PORT_P75 PORTJ -#define __PORT_P76 PORTJ -#define __PORT_P77 PORTJ -#define __PORT_P78 PORTE -#define __PORT_P79 PORTE -#define __PORT_P80 PORTE -#define __PORT_P81 PORTD -#define __PORT_P82 PORTD -#define __PORT_P83 PORTD -#define __PORT_P84 PORTH -#define __PORT_P85 PORTH - -#define __DDR_P0 DDRE -#define __DDR_P1 DDRE -#define __DDR_P2 DDRE -#define __DDR_P3 DDRE -#define __DDR_P4 DDRG -#define __DDR_P5 DDRE -#define __DDR_P6 DDRH -#define __DDR_P7 DDRH -#define __DDR_P8 DDRH -#define __DDR_P9 DDRH -#define __DDR_P10 DDRB -#define __DDR_P11 DDRB -#define __DDR_P12 DDRB -#define __DDR_P13 DDRB -#define __DDR_P14 DDRJ -#define __DDR_P15 DDRJ -#define __DDR_P16 DDRH -#define __DDR_P17 DDRH -#define __DDR_P18 DDRD -#define __DDR_P19 DDRD -#define __DDR_P20 DDRD -#define __DDR_P21 DDRD -#define __DDR_P22 DDRA -#define __DDR_P23 DDRA -#define __DDR_P24 DDRA -#define __DDR_P25 DDRA -#define __DDR_P26 DDRA -#define __DDR_P27 DDRA -#define __DDR_P28 DDRA -#define __DDR_P29 DDRA -#define __DDR_P30 DDRC -#define __DDR_P31 DDRC -#define __DDR_P32 DDRC -#define __DDR_P33 DDRC -#define __DDR_P34 DDRC -#define __DDR_P35 DDRC -#define __DDR_P36 DDRC -#define __DDR_P37 DDRC -#define __DDR_P38 DDRD -#define __DDR_P39 DDRG -#define __DDR_P40 DDRG -#define __DDR_P41 DDRG -#define __DDR_P42 DDRL -#define __DDR_P43 DDRL -#define __DDR_P44 DDRL -#define __DDR_P45 DDRL -#define __DDR_P46 DDRL -#define __DDR_P47 DDRL -#define __DDR_P48 DDRL -#define __DDR_P49 DDRL -#define __DDR_P50 DDRB -#define __DDR_P51 DDRB -#define __DDR_P52 DDRB -#define __DDR_P53 DDRB -#define __DDR_P54 DDRF -#define __DDR_P55 DDRF -#define __DDR_P56 DDRF -#define __DDR_P57 DDRF -#define __DDR_P58 DDRF -#define __DDR_P59 DDRF -#define __DDR_P60 DDRF -#define __DDR_P61 DDRF -#define __DDR_P62 DDRK -#define __DDR_P63 DDRK -#define __DDR_P64 DDRK -#define __DDR_P65 DDRK -#define __DDR_P66 DDRK -#define __DDR_P67 DDRK -#define __DDR_P68 DDRK -#define __DDR_P69 DDRK -#define __DDR_P70 DDRG -#define __DDR_P71 DDRG -#define __DDR_P72 DDRJ -#define __DDR_P73 DDRJ -#define __DDR_P74 DDRJ -#define __DDR_P75 DDRJ -#define __DDR_P76 DDRJ -#define __DDR_P77 DDRJ -#define __DDR_P78 DDRE -#define __DDR_P79 DDRE -#define __DDR_P80 DDRE -#define __DDR_P81 DDRD -#define __DDR_P82 DDRD -#define __DDR_P83 DDRD -#define __DDR_P84 DDRH -#define __DDR_P85 DDRH - -#define __BIT_P0 0 -#define __BIT_P1 1 -#define __BIT_P2 4 -#define __BIT_P3 5 -#define __BIT_P4 5 -#define __BIT_P5 3 -#define __BIT_P6 3 -#define __BIT_P7 4 -#define __BIT_P8 5 -#define __BIT_P9 6 -#define __BIT_P10 4 -#define __BIT_P11 5 -#define __BIT_P12 6 -#define __BIT_P13 7 -#define __BIT_P14 1 -#define __BIT_P15 0 -#define __BIT_P16 0 -#define __BIT_P17 1 -#define __BIT_P18 3 -#define __BIT_P19 2 -#define __BIT_P20 1 -#define __BIT_P21 0 -#define __BIT_P22 0 -#define __BIT_P23 1 -#define __BIT_P24 2 -#define __BIT_P25 3 -#define __BIT_P26 4 -#define __BIT_P27 5 -#define __BIT_P28 6 -#define __BIT_P29 7 -#define __BIT_P30 7 -#define __BIT_P31 6 -#define __BIT_P32 5 -#define __BIT_P33 4 -#define __BIT_P34 3 -#define __BIT_P35 2 -#define __BIT_P36 1 -#define __BIT_P37 0 -#define __BIT_P38 7 -#define __BIT_P39 2 -#define __BIT_P40 1 -#define __BIT_P41 0 -#define __BIT_P42 7 -#define __BIT_P43 6 -#define __BIT_P44 5 -#define __BIT_P45 4 -#define __BIT_P46 3 -#define __BIT_P47 2 -#define __BIT_P48 1 -#define __BIT_P49 0 -#define __BIT_P50 3 -#define __BIT_P51 2 -#define __BIT_P52 1 -#define __BIT_P53 0 -#define __BIT_P54 0 -#define __BIT_P55 1 -#define __BIT_P56 2 -#define __BIT_P57 3 -#define __BIT_P58 4 -#define __BIT_P59 5 -#define __BIT_P60 6 -#define __BIT_P61 7 -#define __BIT_P62 0 -#define __BIT_P63 1 -#define __BIT_P64 2 -#define __BIT_P65 3 -#define __BIT_P66 4 -#define __BIT_P67 5 -#define __BIT_P68 6 -#define __BIT_P69 7 -#define __BIT_P70 4 -#define __BIT_P71 3 -#define __BIT_P72 2 -#define __BIT_P73 3 -#define __BIT_P74 7 -#define __BIT_P75 4 -#define __BIT_P76 5 -#define __BIT_P77 6 -#define __BIT_P78 2 -#define __BIT_P79 6 -#define __BIT_P80 7 -#define __BIT_P81 4 -#define __BIT_P82 5 -#define __BIT_P83 6 -#define __BIT_P84 2 -#define __BIT_P85 7 - -#define __BIT(pin) __BIT_P##pin -#define __MSK(pin) (1 << __BIT(pin)) - -#define __PIN(pin) __PIN_P##pin -#define __PORT(pin) __PORT_P##pin -#define __DDR(pin) __DDR_P##pin - -#define PIN(pin) __PIN(pin) -#define PORT(pin) __PORT(pin) -#define DDR(pin) __DDR(pin) - -#define PIN_INP(pin) DDR(pin) &= ~__MSK(pin) -#define PIN_OUT(pin) DDR(pin) |= __MSK(pin) -#define PIN_CLR(pin) PORT(pin) &= ~__MSK(pin) -#define PIN_SET(pin) PORT(pin) |= __MSK(pin) -#define PIN_VAL(pin, val) if (val) PIN_SET(pin); else PIN_CLR(pin); -#define PIN_GET(pin) (PIN(pin) & __MSK(pin)) -#define PIN_INQ(pin) (PORT(pin) & __MSK(pin)) - - -#endif //_IO_ATMEGA2560 diff --git a/Firmware/macros.h b/Firmware/macros.h index c27dbde77..4d421a273 100644 --- a/Firmware/macros.h +++ b/Firmware/macros.h @@ -1,6 +1,7 @@ #ifndef MACROS_H #define MACROS_H +#include //for cli() and sei() #define FORCE_INLINE __attribute__((always_inline)) inline #define _UNUSED __attribute__((unused)) @@ -14,5 +15,21 @@ #define STRINGIFY_(M) #M #define STRINGIFY(M) STRINGIFY_(M) +// Macros for bit masks +#undef _BV +#define _BV(n) (1<<(n)) +#define TEST(n,b) (!!((n)&_BV(b))) +#define SET_BIT_TO(N,B,TF) do{ if (TF) SBI(N,B); else CBI(N,B); }while(0) + +#ifndef SBI + #define SBI(A,B) (A |= (1 << (B))) +#endif + +#ifndef CBI + #define CBI(A,B) (A &= ~(1 << (B))) +#endif + +#define TBI(N,B) (N ^= _BV(B)) + #endif //MACROS_H diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index c5981894c..ab4af5e29 100755 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -13,8 +13,9 @@ #include "sound.h" #include "printers.h" #include -#include "io_atmega2560.h" #include "AutoDeplete.h" +#include "fastio.h" +#include "pins.h" //-// #include "util.h" @@ -28,9 +29,6 @@ #define MMU_P0_TIMEOUT 3000ul //timeout for P0 command: 3seconds #define MMU_MAX_RESEND_ATTEMPTS 2 -#ifdef MMU_HWRESET -#define MMU_RST_PIN 76 -#endif //MMU_HWRESET namespace { @@ -156,8 +154,8 @@ void mmu_init(void) _delay_ms(10); //wait 10ms for sure mmu_reset(); //reset mmu (HW or SW), do not wait for response mmu_state = S::Init; - PIN_INP(IR_SENSOR_PIN); //input mode - PIN_SET(IR_SENSOR_PIN); //pullup + SET_INPUT(IR_SENSOR_PIN); //input mode + WRITE(IR_SENSOR_PIN, 1); //pullup } //if IR_SENSOR defined, always returns true @@ -170,7 +168,7 @@ bool check_for_ir_sensor() bool detected = false; //if IR_SENSOR_PIN input is low and pat9125sensor is not present we detected idler sensor - if ((PIN_GET(IR_SENSOR_PIN) == 0) + if ((READ(IR_SENSOR_PIN) == 0) #ifdef PAT9125 && fsensor_not_responding #endif //PAT9125 @@ -363,7 +361,7 @@ void mmu_loop(void) case S::GetFinda: //response to command P0 if (mmu_idl_sens) { - if (PIN_GET(IR_SENSOR_PIN) == 0 && mmu_loading_flag) + if (READ(IR_SENSOR_PIN) == 0 && mmu_loading_flag) { #ifdef MMU_DEBUG printf_P(PSTR("MMU <= 'A'\n")); @@ -406,7 +404,7 @@ void mmu_loop(void) case S::WaitCmd: //response to mmu commands if (mmu_idl_sens) { - if (PIN_GET(IR_SENSOR_PIN) == 0 && mmu_loading_flag) + if (READ(IR_SENSOR_PIN) == 0 && mmu_loading_flag) { DEBUG_PRINTF_P(PSTR("MMU <= 'A'\n")); mmu_puts_P(PSTR("A\n")); //send 'abort' request @@ -596,10 +594,10 @@ bool mmu_get_response(uint8_t move) mmu_loading_flag = true; if (can_extrude()) mmu_load_step(); //don't rely on "ok" signal from mmu unit; if filament detected by idler sensor during loading stop loading movements to prevent infinite loading - if (PIN_GET(IR_SENSOR_PIN) == 0) move = MMU_NO_MOVE; + if (READ(IR_SENSOR_PIN) == 0) move = MMU_NO_MOVE; break; case MMU_UNLOAD_MOVE: - if (PIN_GET(IR_SENSOR_PIN) == 0) //filament is still detected by idler sensor, printer helps with unlading + if (READ(IR_SENSOR_PIN) == 0) //filament is still detected by idler sensor, printer helps with unlading { if (can_extrude()) { @@ -617,7 +615,7 @@ bool mmu_get_response(uint8_t move) } break; case MMU_TCODE_MOVE: //first do unload and then continue with infinite loading movements - if (PIN_GET(IR_SENSOR_PIN) == 0) //filament detected by idler sensor, we must unload first + if (READ(IR_SENSOR_PIN) == 0) //filament detected by idler sensor, we must unload first { if (can_extrude()) { @@ -1460,7 +1458,7 @@ static bool can_load() current_position[E_AXIS] -= e_increment; plan_buffer_line_curposXYZE(MMU_LOAD_FEEDRATE); st_synchronize(); - if(0 == PIN_GET(IR_SENSOR_PIN)) + if(0 == READ(IR_SENSOR_PIN)) { ++filament_detected_count; DEBUG_PUTCHAR('O'); @@ -1491,7 +1489,7 @@ static bool load_more() { for (uint8_t i = 0; i < MMU_IDLER_SENSOR_ATTEMPTS_NR; i++) { - if (PIN_GET(IR_SENSOR_PIN) == 0) return true; + if (READ(IR_SENSOR_PIN) == 0) return true; DEBUG_PRINTF_P(PSTR("Additional load attempt nr. %d\n"), i); mmu_command(MmuCmd::C0); manage_response(true, true, MMU_LOAD_MOVE); diff --git a/Firmware/pins_Einsy_1_0.h b/Firmware/pins_Einsy_1_0.h index 14b562337..88713e6ac 100755 --- a/Firmware/pins_Einsy_1_0.h +++ b/Firmware/pins_Einsy_1_0.h @@ -121,6 +121,8 @@ #define IR_SENSOR_PIN 62 //idler sensor @PK0 (digital pin 62/A8) +#define MMU_RST_PIN 76 + // Support for an 8 bit logic analyzer, for example the Saleae. // Channels 0-2 are fast, they could generate 2.667Mhz waveform with a software loop. #define LOGIC_ANALYZER_CH0 X_MIN_PIN // PB6 diff --git a/Firmware/swi2c.c b/Firmware/swi2c.c index 49fbc5efc..02cca2208 100644 --- a/Firmware/swi2c.c +++ b/Firmware/swi2c.c @@ -3,9 +3,10 @@ #include #include #include +#include "stdbool.h" #include "Configuration_prusa.h" #include "pins.h" -#include "io_atmega2560.h" +#include "fastio.h" #define SWI2C_RMSK 0x01 //read mask (bit0 = 1) @@ -21,75 +22,75 @@ void __delay(void) void swi2c_init(void) { - PIN_OUT(SWI2C_SDA); - PIN_OUT(SWI2C_SCL); - PIN_SET(SWI2C_SDA); - PIN_SET(SWI2C_SCL); + WRITE(SWI2C_SDA, 1); + WRITE(SWI2C_SCL, 1); + SET_OUTPUT(SWI2C_SDA); + SET_OUTPUT(SWI2C_SCL); uint8_t i; for (i = 0; i < 100; i++) __delay(); } void swi2c_start(void) { - PIN_CLR(SWI2C_SDA); + WRITE(SWI2C_SDA, 0); __delay(); - PIN_CLR(SWI2C_SCL); + WRITE(SWI2C_SCL, 0); __delay(); } void swi2c_stop(void) { - PIN_SET(SWI2C_SCL); + WRITE(SWI2C_SCL, 1); __delay(); - PIN_SET(SWI2C_SDA); + WRITE(SWI2C_SDA, 1); __delay(); } void swi2c_ack(void) { - PIN_CLR(SWI2C_SDA); + WRITE(SWI2C_SDA, 0); __delay(); - PIN_SET(SWI2C_SCL); + WRITE(SWI2C_SCL, 1); __delay(); - PIN_CLR(SWI2C_SCL); + WRITE(SWI2C_SCL, 0); __delay(); } uint8_t swi2c_wait_ack() { - PIN_INP(SWI2C_SDA); + SET_INPUT(SWI2C_SDA); __delay(); -// PIN_SET(SWI2C_SDA); +// WRITE(SWI2C_SDA, 1); __delay(); - PIN_SET(SWI2C_SCL); + WRITE(SWI2C_SCL, 1); // __delay(); uint8_t ack = 0; uint16_t ackto = SWI2C_TMO; - while (!(ack = (PIN_GET(SWI2C_SDA)?0:1)) && ackto--) __delay(); - PIN_CLR(SWI2C_SCL); + while (!(ack = (!READ(SWI2C_SDA))) && ackto--) __delay(); + WRITE(SWI2C_SCL, 0); __delay(); - PIN_OUT(SWI2C_SDA); + SET_OUTPUT(SWI2C_SDA); __delay(); - PIN_CLR(SWI2C_SDA); + WRITE(SWI2C_SDA, 0); __delay(); return ack; } uint8_t swi2c_read(void) { - PIN_SET(SWI2C_SDA); + WRITE(SWI2C_SDA, 1); __delay(); - PIN_INP(SWI2C_SDA); + SET_INPUT(SWI2C_SDA); uint8_t data = 0; int8_t bit; for (bit = 7; bit >= 0; bit--) { - PIN_SET(SWI2C_SCL); + WRITE(SWI2C_SCL, 1); __delay(); - data |= (PIN_GET(SWI2C_SDA)?1:0) << bit; - PIN_CLR(SWI2C_SCL); + data |= (READ(SWI2C_SDA)) << bit; + WRITE(SWI2C_SCL, 0); __delay(); } - PIN_OUT(SWI2C_SDA); + SET_OUTPUT(SWI2C_SDA); return data; } @@ -97,12 +98,11 @@ void swi2c_write(uint8_t data) { int8_t bit; for (bit = 7; bit >= 0; bit--) { - if (data & (1 << bit)) PIN_SET(SWI2C_SDA); - else PIN_CLR(SWI2C_SDA); + WRITE(SWI2C_SDA, data & _BV(bit)); __delay(); - PIN_SET(SWI2C_SCL); + WRITE(SWI2C_SCL, 1); __delay(); - PIN_CLR(SWI2C_SCL); + WRITE(SWI2C_SCL, 0); __delay(); } } diff --git a/Firmware/timer02.c b/Firmware/timer02.c index 7c6b4ef0f..a866fa259 100644 --- a/Firmware/timer02.c +++ b/Firmware/timer02.c @@ -9,9 +9,6 @@ #include #include -#include "io_atmega2560.h" - -#define BEEPER 84 void timer0_init(void) { diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 6f82db04c..e8031ea56 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -44,7 +44,6 @@ #include "mmu.h" #include "static_assert.h" -#include "io_atmega2560.h" #include "first_lay_cal.h" #include "fsensor.h" @@ -3999,7 +3998,7 @@ static void lcd_show_sensors_state() finda_state = mmu_finda; } if (ir_sensor_detected) { - idler_state = !PIN_GET(IR_SENSOR_PIN); + idler_state = !READ(IR_SENSOR_PIN); } lcd_puts_at_P(0, 0, _i("Sensor state")); lcd_puts_at_P(1, 1, _i("PINDA:")); @@ -8474,7 +8473,7 @@ static bool selftest_irsensor() mmu_load_step(false); while (blocks_queued()) { - if (PIN_GET(IR_SENSOR_PIN) == 0) + if (READ(IR_SENSOR_PIN) == 0) { lcd_selftest_error(TestError::TriggeringFsensor, "", ""); return false; diff --git a/Firmware/w25x20cl.c b/Firmware/w25x20cl.c index 79467cb6d..40d183f13 100644 --- a/Firmware/w25x20cl.c +++ b/Firmware/w25x20cl.c @@ -3,8 +3,8 @@ #include "w25x20cl.h" #include #include -#include "io_atmega2560.h" #include "spi.h" +#include "fastio.h" #define _MFRID 0xEF #define _DEVID 0x11 @@ -31,8 +31,8 @@ #define _CMD_JEDEC_ID 0x9f #define _CMD_RD_UID 0x4b -#define _CS_LOW() PORT(W25X20CL_PIN_CS) &= ~__MSK(W25X20CL_PIN_CS) -#define _CS_HIGH() PORT(W25X20CL_PIN_CS) |= __MSK(W25X20CL_PIN_CS) +#define _CS_LOW() WRITE(W25X20CL_PIN_CS, 0) +#define _CS_HIGH() WRITE(W25X20CL_PIN_CS, 1) //#define _SPI_TX swspi_tx //#define _SPI_RX swspi_rx @@ -45,8 +45,8 @@ int w25x20cl_mfrid_devid(void); int8_t w25x20cl_init(void) { - PIN_OUT(W25X20CL_PIN_CS); _CS_HIGH(); + SET_OUTPUT(W25X20CL_PIN_CS); W25X20CL_SPI_ENTER(); if (!w25x20cl_mfrid_devid()) return 0; return 1; From 44b1b1c2194a7f4cdd335515024812546186b258 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Fri, 11 Sep 2020 18:48:44 +0300 Subject: [PATCH 21/73] More macros --- Firmware/Configuration_adv.h | 2 +- Firmware/macros.h | 55 ++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/Firmware/Configuration_adv.h b/Firmware/Configuration_adv.h index 29f7e951e..b5ea3d229 100644 --- a/Firmware/Configuration_adv.h +++ b/Firmware/Configuration_adv.h @@ -379,7 +379,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st /** * Include capabilities in M115 output */ -// #define EXTENDED_CAPABILITIES_REPORT +#define EXTENDED_CAPABILITIES_REPORT //=========================================================================== //============================= Define Defines ============================ diff --git a/Firmware/macros.h b/Firmware/macros.h index 4d421a273..95a737e1e 100644 --- a/Firmware/macros.h +++ b/Firmware/macros.h @@ -32,4 +32,59 @@ #define TBI(N,B) (N ^= _BV(B)) +// Macros to chain up to 12 conditions +#define _DO_1(W,C,A) (_##W##_1(A)) +#define _DO_2(W,C,A,B) (_##W##_1(A) C _##W##_1(B)) +#define _DO_3(W,C,A,V...) (_##W##_1(A) C _DO_2(W,C,V)) +#define _DO_4(W,C,A,V...) (_##W##_1(A) C _DO_3(W,C,V)) +#define _DO_5(W,C,A,V...) (_##W##_1(A) C _DO_4(W,C,V)) +#define _DO_6(W,C,A,V...) (_##W##_1(A) C _DO_5(W,C,V)) +#define _DO_7(W,C,A,V...) (_##W##_1(A) C _DO_6(W,C,V)) +#define _DO_8(W,C,A,V...) (_##W##_1(A) C _DO_7(W,C,V)) +#define _DO_9(W,C,A,V...) (_##W##_1(A) C _DO_8(W,C,V)) +#define _DO_10(W,C,A,V...) (_##W##_1(A) C _DO_9(W,C,V)) +#define _DO_11(W,C,A,V...) (_##W##_1(A) C _DO_10(W,C,V)) +#define _DO_12(W,C,A,V...) (_##W##_1(A) C _DO_11(W,C,V)) +#define __DO_N(W,C,N,V...) _DO_##N(W,C,V) +#define _DO_N(W,C,N,V...) __DO_N(W,C,N,V) +#define DO(W,C,V...) _DO_N(W,C,NUM_ARGS(V),V) + +// Macros to support option testing +#define _CAT(a,V...) a##V +#define CAT(a,V...) _CAT(a,V) + +#define _ISENA_ ~,1 +#define _ISENA_1 ~,1 +#define _ISENA_0x1 ~,1 +#define _ISENA_true ~,1 +#define _ISENA(V...) IS_PROBE(V) + +#define _ENA_1(O) _ISENA(CAT(_IS,CAT(ENA_, O))) +#define _DIS_1(O) NOT(_ENA_1(O)) +#define ENABLED(V...) DO(ENA,&&,V) +#define DISABLED(V...) DO(DIS,&&,V) + +#define TERN(O,A,B) _TERN(_ENA_1(O),B,A) // OPTION converted to '0' or '1' +#define TERN0(O,A) _TERN(_ENA_1(O),0,A) // OPTION converted to A or '0' +#define TERN1(O,A) _TERN(_ENA_1(O),1,A) // OPTION converted to A or '1' +#define TERN_(O,A) _TERN(_ENA_1(O),,A) // OPTION converted to A or '' +#define _TERN(E,V...) __TERN(_CAT(T_,E),V) // Prepend 'T_' to get 'T_0' or 'T_1' +#define __TERN(T,V...) ___TERN(_CAT(_NO,T),V) // Prepend '_NO' to get '_NOT_0' or '_NOT_1' +#define ___TERN(P,V...) THIRD(P,V) // If first argument has a comma, A. Else B. + + +// Use NUM_ARGS(__VA_ARGS__) to get the number of variadic arguments +#define _NUM_ARGS(_,Z,Y,X,W,V,U,T,S,R,Q,P,O,N,M,L,K,J,I,H,G,F,E,D,C,B,A,OUT,...) OUT +#define NUM_ARGS(V...) _NUM_ARGS(0,V,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0) + +// +// Primitives supporting precompiler REPEAT +// +#define FIRST(a,...) a +#define SECOND(a,b,...) b +#define THIRD(a,b,c,...) c + +#define IS_PROBE(V...) SECOND(V, 0) // Get the second item passed, or 0 +#define NOT(x) IS_PROBE(_CAT(_NOT_, x)) // NOT('0') gets '1'. Anything else gets '0'. + #endif //MACROS_H From c1582599707552bc6d2959354e84096561136411 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Fri, 11 Sep 2020 20:04:06 +0300 Subject: [PATCH 22/73] Remove unused where C++ alternative can be used --- Firmware/backlight.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/backlight.cpp b/Firmware/backlight.cpp index b59a65ef4..04128be8a 100644 --- a/Firmware/backlight.cpp +++ b/Firmware/backlight.cpp @@ -111,10 +111,10 @@ void backlight_init() #else //LCD_BL_PIN -void force_bl_on(_UNUSED bool section_start) {} +void force_bl_on(bool) {} void backlight_update() {} void backlight_init() {} void backlight_save() {} -void backlight_wake(_UNUSED const uint8_t flashNo) {} +void backlight_wake(const uint8_t) {} #endif //LCD_BL_PIN \ No newline at end of file From e2ef5af40e6e7f73ddb750f672282d13d085d416 Mon Sep 17 00:00:00 2001 From: Voinea Dragos Date: Tue, 15 Sep 2020 14:21:09 +0300 Subject: [PATCH 23/73] Add capability line --- Firmware/Marlin_main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index f304c18b3..812cc3839 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3516,6 +3516,7 @@ static void cap_line(const char* name, bool ena = false) { static void extended_capabilities_report() { + cap_line(PSTR("AUTOREPORT_TEMP"), ENABLED(AUTO_REPORT_TEMPERATURES)); //@todo } #endif //EXTENDED_CAPABILITIES_REPORT From c0fced2f3cb7457fae78e1920d2ab373c5f16f4f Mon Sep 17 00:00:00 2001 From: Voinea Dragos Date: Tue, 15 Sep 2020 14:21:21 +0300 Subject: [PATCH 24/73] Fix typo --- Firmware/Marlin_main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 812cc3839..f030f6897 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -403,7 +403,7 @@ static bool setTargetedHotend(int code, uint8_t &extruder); static void print_time_remaining_init(); static void wait_for_heater(long codenum, uint8_t extruder); static void gcode_G28(bool home_x_axis, bool home_y_axis, bool home_z_axis); -static void gcode_M115(uint8_t extruder); +static void gcode_M105(uint8_t extruder); static void temp_compensation_start(); static void temp_compensation_apply(); @@ -1735,7 +1735,7 @@ void host_keepalive() { { if (auto_report_temp_timer.expired(auto_report_temp_period * 1000ul)) { - gcode_M115(active_extruder); + gcode_M105(active_extruder); auto_report_temp_timer.start(); } } @@ -2544,7 +2544,7 @@ void force_high_power_mode(bool start_high_power_section) { } #endif //TMC2130 -void gcode_M115(uint8_t extruder) +void gcode_M105(uint8_t extruder) { #if defined(TEMP_0_PIN) && TEMP_0_PIN > -1 SERIAL_PROTOCOLPGM("T:"); @@ -6399,7 +6399,7 @@ Sigma_Exit: } SERIAL_PROTOCOLPGM("ok "); - gcode_M115(extruder); + gcode_M105(extruder); return; break; From 9fb6efc4355c618b91b2d22ce5c3f9259c26ff75 Mon Sep 17 00:00:00 2001 From: DRracer Date: Tue, 15 Sep 2020 14:56:41 +0200 Subject: [PATCH 25/73] Add newline at the end of file --- Firmware/backlight.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/backlight.cpp b/Firmware/backlight.cpp index 04128be8a..bc63d8e61 100644 --- a/Firmware/backlight.cpp +++ b/Firmware/backlight.cpp @@ -117,4 +117,4 @@ void backlight_init() {} void backlight_save() {} void backlight_wake(const uint8_t) {} -#endif //LCD_BL_PIN \ No newline at end of file +#endif //LCD_BL_PIN From d9fa44c142db83014c6186483b3d76578f1f10b1 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Wed, 23 Sep 2020 09:14:35 +0300 Subject: [PATCH 26/73] Document M155 command --- Firmware/Marlin_main.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index f030f6897..dd6dd78b1 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3613,6 +3613,7 @@ extern uint8_t st_backlash_y; //!@n M129 - EtoP Closed (BariCUDA EtoP = electricity to air pressure transducer by jmil) //!@n M140 - Set bed target temp //!@n M150 - Set BlinkM Color Output R: Red<0-255> U(!): Green<0-255> B: Blue<0-255> over i2c, G for green does not work. +//!@n M155 - Automatically send temperatures //!@n M190 - Sxxx Wait for bed current temp to reach target temp. Waits only when heating //! Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling //!@n M200 D- set filament diameter and set E axis units to cubic millimeters (use S0 to set back to millimeters). @@ -6406,6 +6407,17 @@ Sigma_Exit: } #ifdef AUTO_REPORT_TEMPERATURES + /*! + ### M155 - Automatically send temperatures M155: Automatically send temperatures + #### Usage + + M155 [ S ] + + #### Parameters + + - `S` - Set temperature autoreporting interval in seconds. 0 to disable. Maximum: 255 + + */ case 155: { if (code_seen('S')) From a6a4a0b71d9403fe13b3c50ca1936aa9a255bf8b Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Thu, 1 Oct 2020 16:49:38 +0200 Subject: [PATCH 27/73] Bug fix if using argument EN_ONLY. Thank to @leptun for pointing out. --- PF-build.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/PF-build.sh b/PF-build.sh index f459095c9..adec0e353 100755 --- a/PF-build.sh +++ b/PF-build.sh @@ -56,7 +56,7 @@ # Some may argue that this is only used by a script, BUT as soon someone accidentally or on purpose starts Arduino IDE # it will use the default Arduino IDE folders and so can corrupt the build environment. # -# Version: 1.0.6-Build_18 +# Version: 1.0.6-Build_27 # Change log: # 12 Jan 2019, 3d-gussner, Fixed "compiler.c.elf.flags=-w -Os -Wl,-u,vfprintf -lprintf_flt -lm -Wl,--gc-sections" in 'platform.txt' # 16 Jan 2019, 3d-gussner, Build_2, Added development check to modify 'Configuration.h' to prevent unwanted LCD messages that Firmware is unknown @@ -124,6 +124,8 @@ # After compiling All multilanguage vairants it makes it easier to find missing or unused transltions. # 12 May 2020, DRracer , Cleanup double MK2/s MK25/s `not_tran` and `not_used` files # 13 May 2020, leptun , If cleanup files do not exist don't try to. +# 01 Oct 2020, 3d-gussner, Bug fix if using argument EN_ONLY. Thank to @leptun for pointing out. +# Change Build number to scrpit commits #### Start check if OSTYPE is supported OS_FOUND=$( command -v uname) @@ -473,12 +475,10 @@ if [ -z "$2" ] ; then case $yn in "Multi languages") LANGUAGES="ALL" - sed -i -- "s/^#define LANG_MODE *0/#define LANG_MODE 1/g" $SCRIPT_PATH/Firmware/config.h break ;; "English only") LANGUAGES="EN_ONLY" - sed -i -- "s/^#define LANG_MODE *1/#define LANG_MODE 0/g" $SCRIPT_PATH/Firmware/config.h break ;; *) @@ -622,13 +622,15 @@ do sed -i -- 's/#define FW_REPOSITORY "Unknown"/#define FW_REPOSITORY "Prusa3d"/g' $SCRIPT_PATH/Firmware/Configuration.h #Prepare english only or multilanguage version to be build - if [ $LANGUAGES == "ALL" ]; then + if [ $LANGUAGES == "EN_ONLY" ]; then echo " " - echo "Multi-language firmware will be built" + echo "English only language firmware will be built" + sed -i -- "s/^#define LANG_MODE *1/#define LANG_MODE 0/g" $SCRIPT_PATH/Firmware/config.h echo " " else echo " " - echo "English only language firmware will be built" + echo "Multi-language firmware will be built" + sed -i -- "s/^#define LANG_MODE *0/#define LANG_MODE 1/g" $SCRIPT_PATH/Firmware/config.h echo " " fi From 2dbce5c0cb825ef3f804c382f83aad0eb4785aa1 Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Fri, 2 Oct 2020 18:54:18 +0200 Subject: [PATCH 28/73] Add UNKNOWN as agrument option --- PF-build.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/PF-build.sh b/PF-build.sh index adec0e353..cc3898b75 100755 --- a/PF-build.sh +++ b/PF-build.sh @@ -56,7 +56,7 @@ # Some may argue that this is only used by a script, BUT as soon someone accidentally or on purpose starts Arduino IDE # it will use the default Arduino IDE folders and so can corrupt the build environment. # -# Version: 1.0.6-Build_27 +# Version: 1.0.6-Build_28 # Change log: # 12 Jan 2019, 3d-gussner, Fixed "compiler.c.elf.flags=-w -Os -Wl,-u,vfprintf -lprintf_flt -lm -Wl,--gc-sections" in 'platform.txt' # 16 Jan 2019, 3d-gussner, Build_2, Added development check to modify 'Configuration.h' to prevent unwanted LCD messages that Firmware is unknown @@ -126,6 +126,7 @@ # 13 May 2020, leptun , If cleanup files do not exist don't try to. # 01 Oct 2020, 3d-gussner, Bug fix if using argument EN_ONLY. Thank to @leptun for pointing out. # Change Build number to scrpit commits +# 02 Oct 2020, 3d-gussner, Add UNKNOWN as argument option #### Start check if OSTYPE is supported OS_FOUND=$( command -v uname) @@ -497,11 +498,11 @@ else fi #Check if DEV_STATUS is selected via argument 3 if [ ! -z "$3" ] ; then - if [[ "$3" == "GOLD" || "$3" == "RC" || "$3" == "BETA" || "$3" == "ALPHA" || "$3" == "DEVEL" || "$3" == "DEBUG" ]] ; then + if [[ "$3" == "GOLD" || "$3" == "RC" || "$3" == "BETA" || "$3" == "ALPHA" || "$3" == "DEVEL" || "$3" == "DEBUG" || "$3" == "UNKNOWN" ]] ; then DEV_STATUS_SELECTED=$3 else echo "$(tput setaf 1)Development argument is wrong!$(tput sgr0)" - echo "Only $(tput setaf 2)'GOLD', 'RC', 'BETA', 'ALPHA', 'DEVEL' or 'DEBUG'$(tput sgr0) are allowed as 3rd argument!$(tput sgr0)" + echo "Only $(tput setaf 2)'GOLD', 'RC', 'BETA', 'ALPHA', 'DEVEL', 'DEBUG' or 'UNKOWN' $(tput sgr0) are allowed as 3rd argument!$(tput sgr0)" exit 23 fi fi From ffc7a5344a41774eed52a639de8d3448c89b7f2c Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Fri, 2 Oct 2020 18:56:50 +0200 Subject: [PATCH 29/73] Typo fix --- PF-build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PF-build.sh b/PF-build.sh index cc3898b75..08c3756fd 100755 --- a/PF-build.sh +++ b/PF-build.sh @@ -502,7 +502,7 @@ if [ ! -z "$3" ] ; then DEV_STATUS_SELECTED=$3 else echo "$(tput setaf 1)Development argument is wrong!$(tput sgr0)" - echo "Only $(tput setaf 2)'GOLD', 'RC', 'BETA', 'ALPHA', 'DEVEL', 'DEBUG' or 'UNKOWN' $(tput sgr0) are allowed as 3rd argument!$(tput sgr0)" + echo "Only $(tput setaf 2)'GOLD', 'RC', 'BETA', 'ALPHA', 'DEVEL', 'DEBUG' or 'UNKNOWN' $(tput sgr0) are allowed as 3rd argument!$(tput sgr0)" exit 23 fi fi From 93fd3c95a94ebe2c5c89d5f197cabd213655bedd Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Mon, 5 Oct 2020 13:18:18 +0200 Subject: [PATCH 30/73] Disable pause and warnings using command line with all needed arguments Install needed apps under linux if needed. --- PF-build.sh | 48 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/PF-build.sh b/PF-build.sh index 08c3756fd..2ef702ec0 100755 --- a/PF-build.sh +++ b/PF-build.sh @@ -56,7 +56,7 @@ # Some may argue that this is only used by a script, BUT as soon someone accidentally or on purpose starts Arduino IDE # it will use the default Arduino IDE folders and so can corrupt the build environment. # -# Version: 1.0.6-Build_28 +# Version: 1.0.6-Build_29 # Change log: # 12 Jan 2019, 3d-gussner, Fixed "compiler.c.elf.flags=-w -Os -Wl,-u,vfprintf -lprintf_flt -lm -Wl,--gc-sections" in 'platform.txt' # 16 Jan 2019, 3d-gussner, Build_2, Added development check to modify 'Configuration.h' to prevent unwanted LCD messages that Firmware is unknown @@ -127,6 +127,8 @@ # 01 Oct 2020, 3d-gussner, Bug fix if using argument EN_ONLY. Thank to @leptun for pointing out. # Change Build number to scrpit commits # 02 Oct 2020, 3d-gussner, Add UNKNOWN as argument option +# 05 Oct 2020, 3d-gussner, Disable pause and warnings using command line with all needed arguments +# Install needed apps under linux if needed. #### Start check if OSTYPE is supported OS_FOUND=$( command -v uname) @@ -201,13 +203,14 @@ if ! type zip > /dev/null; then elif [ $TARGET_OS == "linux" ]; then echo "$(tput setaf 1)Missing 'zip' which is important to run this script" echo "install it with the command $(tput setaf 2)'sudo apt-get install zip'$(tput sgr0)" + sudo apt-get update && apt-get install zip exit 3 fi fi # Check python ... needed during language build if ! type python > /dev/null; then if [ $TARGET_OS == "windows" ]; then - echo "$(tput setaf 1)Missing 'python' which is important to run this script" + echo "$(tput setaf 1)Missing 'python3' which is important to run this script" exit 4 elif [ $TARGET_OS == "linux" ]; then echo "$(tput setaf 1)Missing 'python' which is important to run this script" @@ -215,6 +218,7 @@ if ! type python > /dev/null; then echo "install it with the command $(tput setaf 2)'sudo apt-get install python3'." echo "Check which version of Python3 has been installed using 'ls /usr/bin/python3*'" echo "Use 'sudo ln -sf /usr/bin/python3.x /usr/bin/python' (where 'x' is your version number) to make it default.$(tput sgr0)" + sudo apt-get update && apt-get install python3 && ln -sf /usr/bin/python3 /usr/bin/python exit 4 fi fi @@ -507,6 +511,14 @@ if [ ! -z "$3" ] ; then fi fi +# check if script has been started with arguments +if [ "$#" -eq "0" ] ; then + OUTPUT=1 +else + OUTPUT=0 +fi +#echo "Output is:" $OUTPUT + #Set BUILD_ENV_PATH cd ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor || exit 24 BUILD_ENV_PATH="$( pwd -P )" @@ -581,18 +593,24 @@ do echo "" ls -1 $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT.hex | xargs -n1 basename echo "$(tput setaf 6)This hex file to be compiled already exists! To cancel this process press CRTL+C and rename existing hex file.$(tput sgr 0)" - read -t 10 -p "Press Enter to continue..." + if [ $OUTPUT == "1" ] ; then + read -t 10 -p "Press Enter to continue..." + fi elif [[ -f "$SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-EN_ONLY.hex" && "$LANGUAGES" == "EN_ONLY" ]]; then echo "" ls -1 $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-EN_ONLY.hex | xargs -n1 basename echo "$(tput setaf 6)This hex file to be compiled already exists! To cancel this process press CRTL+C and rename existing hex file.$(tput sgr 0)" - read -t 10 -p "Press Enter to continue..." + if [ $OUTPUT == "1" ] ; then + read -t 10 -p "Press Enter to continue..." + fi fi if [[ -f "$SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT.zip" && "$LANGUAGES" == "ALL" ]]; then echo "" ls -1 $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT.zip | xargs -n1 basename echo "$(tput setaf 6)This zip file to be compiled already exists! To cancel this process press CRTL+C and rename existing hex file.$(tput sgr 0)" - read -t 10 -p "Press Enter to continue..." + if [ $OUTPUT == "1" ] ; then + read -t 10 -p "Press Enter to continue..." + fi fi #List some useful data @@ -654,7 +672,9 @@ do echo "Start to build Prusa Firmware ..." echo "Using variant $VARIANT$(tput setaf 3)" - sleep 2 + if [ $OUTPUT == "1" ] ; then + sleep 2 + fi #$BUILD_ENV_PATH/arduino-builder -dump-prefs -debug-level 10 -compile -hardware $ARDUINO/hardware -hardware $ARDUINO/portable/packages -tools $ARDUINO/tools-builder -tools $ARDUINO/hardware/tools/avr -tools $ARDUINO/portable/packages -built-in-libraries $ARDUINO/libraries -libraries $ARDUINO/portable/sketchbook/libraries -fqbn=$BOARD_PACKAGE_NAME:avr:$BOARD -build-path=$BUILD_PATH -warnings=all $SCRIPT_PATH/Firmware/Firmware.ino || exit 14 $BUILD_ENV_PATH/arduino-builder -compile -hardware $ARDUINO/hardware -hardware $ARDUINO/portable/packages -tools $ARDUINO/tools-builder -tools $ARDUINO/hardware/tools/avr -tools $ARDUINO/portable/packages -built-in-libraries $ARDUINO/libraries -libraries $ARDUINO/portable/sketchbook/libraries -fqbn=$BOARD_PACKAGE_NAME:avr:$BOARD -build-path=$BUILD_PATH -warnings=all $SCRIPT_PATH/Firmware/Firmware.ino || exit 14 echo "$(tput sgr 0)" @@ -664,7 +684,9 @@ do echo "Building multi language firmware" $MULTI_LANGUAGE_CHECK echo "$(tput sgr 0)" - sleep 2 + if [ $OUTPUT == "1" ] ; then + sleep 2 + fi cd $SCRIPT_PATH/lang echo "$(tput setaf 3)" ./config.sh || exit 31 @@ -673,7 +695,9 @@ do if [ -f "lang_en.tmp" ]; then echo "" echo "$(tput setaf 6)Previous lang build files already exist these will be cleaned up in 10 seconds.$(tput sgr 0)" - read -t 10 -p "Press Enter to continue..." + if [ $OUTPUT == "1" ] ; then + read -t 10 -p "Press Enter to continue..." + fi echo "$(tput setaf 3)" ./lang-clean.sh echo "$(tput sgr 0)" @@ -681,7 +705,9 @@ do if [ -f "progmem.out" ]; then echo "" echo "$(tput setaf 6)Previous firmware build files already exist these will be cleaned up in 10 seconds.$(tput sgr 0)" - read -t 10 -p "Press Enter to continue..." + if [ $OUTPUT == "1" ] ; then + read -t 10 -p "Press Enter to continue..." + fi echo "$(tput setaf 3)" ./fw-clean.sh echo "$(tput sgr 0)" @@ -749,7 +775,9 @@ do #sed -i -- "s/^#define LANG_MODE * /#define LANG_MODE $MULTI_LANGUAGE_CHECK/g" $SCRIPT_PATH/Firmware/config.h sed -i -- "s/^#define LANG_MODE *1/#define LANG_MODE ${MULTI_LANGUAGE_CHECK}/g" $SCRIPT_PATH/Firmware/config.h sed -i -- "s/^#define LANG_MODE *0/#define LANG_MODE ${MULTI_LANGUAGE_CHECK}/g" $SCRIPT_PATH/Firmware/config.h - sleep 5 + if [ $OUTPUT == "1" ] ; then + sleep 5 + fi done # Switch to hex path and list build files From e3b3e66665913a535ec7841d1378f7e5fe1eee08 Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Mon, 5 Oct 2020 15:25:54 +0200 Subject: [PATCH 31/73] Clean PF-Firmware build when changing git branch --- PF-build.sh | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/PF-build.sh b/PF-build.sh index 2ef702ec0..9bdd377c8 100755 --- a/PF-build.sh +++ b/PF-build.sh @@ -56,7 +56,7 @@ # Some may argue that this is only used by a script, BUT as soon someone accidentally or on purpose starts Arduino IDE # it will use the default Arduino IDE folders and so can corrupt the build environment. # -# Version: 1.0.6-Build_29 +# Version: 1.0.6-Build_30 # Change log: # 12 Jan 2019, 3d-gussner, Fixed "compiler.c.elf.flags=-w -Os -Wl,-u,vfprintf -lprintf_flt -lm -Wl,--gc-sections" in 'platform.txt' # 16 Jan 2019, 3d-gussner, Build_2, Added development check to modify 'Configuration.h' to prevent unwanted LCD messages that Firmware is unknown @@ -129,6 +129,7 @@ # 02 Oct 2020, 3d-gussner, Add UNKNOWN as argument option # 05 Oct 2020, 3d-gussner, Disable pause and warnings using command line with all needed arguments # Install needed apps under linux if needed. +# Clean PF-Firmware build when changing git branch #### Start check if OSTYPE is supported OS_FOUND=$( command -v uname) @@ -519,6 +520,26 @@ else fi #echo "Output is:" $OUTPUT +#Check git branch has changed +if ! type git > /dev/null; then + BRANCH="" + CLEAN_PF_FW_BUILD=0 +else + BRANCH=$(git branch --show-current) + echo "Branch is:" $BRANCH + if [ ! -f "$SCRIPT_PATH/../PF-build.branch" ]; then + echo "$BRANCH" >| $SCRIPT_PATH/../PF-build.branch + echo "created PF-build.branch file" + else + PRE_BRANCH=$(cat "$SCRIPT_PATH/../PF-build.branch") + echo "Previous branch was:" $PRE_BRANCH + if [ ! "$BRANCH" == "$PRE_BRANCH" ] ; then + CLEAN_PF_FW_BUILD=1 + echo "$BRANCH" >| $SCRIPT_PATH/../PF-build.branch + fi + fi +fi + #Set BUILD_ENV_PATH cd ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor || exit 24 BUILD_ENV_PATH="$( pwd -P )" @@ -534,6 +555,14 @@ fi cd Prusa-Firmware-build || exit 26 BUILD_PATH="$( pwd -P )" +#Check git branch has changed +if [ "$CLEAN_PF_FW_BUILD" == "1" ]; then + read -t 10 -p "Branch changed, cleaning Prusa-Firmware-build folder" + rm -r * +else + echo "Nothing to clean up" +fi + for v in ${VARIANTS[*]} do VARIANT=$(basename "$v" ".h") From c8c7563e8a1366330c80c0da5d70dcf87e6959ad Mon Sep 17 00:00:00 2001 From: MartinPoupa <58166333+MartinPoupa@users.noreply.github.com> Date: Wed, 7 Oct 2020 17:44:17 +0200 Subject: [PATCH 32/73] LCD status changed When the lcd status changed it will be printed "LCD status changed" to serial line. --- Firmware/ultralcd.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 936ae873e..a9d3da59f 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -8968,6 +8968,7 @@ void lcd_ignore_click(bool b) } void lcd_finishstatus() { + SERIAL_PROTOCOLLN("LCD status changed"); int len = strlen(lcd_status_message); if (len > 0) { while (len < LCD_WIDTH) { From a84d7ef8d6e7bf37ec6290e92b23cf823bcd1fa8 Mon Sep 17 00:00:00 2001 From: MartinPoupa <58166333+MartinPoupa@users.noreply.github.com> Date: Wed, 7 Oct 2020 18:41:49 +0200 Subject: [PATCH 33/73] corectino of declaration --- Firmware/messages.c | 2 +- Firmware/messages.h | 1 + Firmware/ultralcd.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Firmware/messages.c b/Firmware/messages.c index be613cab1..1c442b479 100644 --- a/Firmware/messages.c +++ b/Firmware/messages.c @@ -176,4 +176,4 @@ const char MSG_FANCHECK_PRINT[] PROGMEM_N1 = "Err: PRINT FAN ERROR"; ////c=20 const char MSG_M112_KILL[] PROGMEM_N1 = "M112 called. Emergency Stop."; ////c=20 const char MSG_ADVANCE_K[] PROGMEM_N1 = "Advance K:"; ////c=13 const char MSG_POWERPANIC_DETECTED[] PROGMEM_N1 = "POWER PANIC DETECTED"; ////c=20 - +const char MSG_LCD_STATUS_CHANGED[] PROGMEM_N1 = "LCD status changed"; diff --git a/Firmware/messages.h b/Firmware/messages.h index 4653c869e..a9a23f0d2 100644 --- a/Firmware/messages.h +++ b/Firmware/messages.h @@ -176,6 +176,7 @@ extern const char MSG_FANCHECK_PRINT[]; extern const char MSG_M112_KILL[]; extern const char MSG_ADVANCE_K[]; extern const char MSG_POWERPANIC_DETECTED[]; +extern const char MSG_LCD_STATUS_CHANGED[]; #if defined(__cplusplus) } diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index a9d3da59f..63fea0e3f 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -8968,7 +8968,7 @@ void lcd_ignore_click(bool b) } void lcd_finishstatus() { - SERIAL_PROTOCOLLN("LCD status changed"); + SERIAL_PROTOCOLLNRPGM(MSG_LCD_STATUS_CHANGED); int len = strlen(lcd_status_message); if (len > 0) { while (len < LCD_WIDTH) { From c05d4c9112c3b4ef8b086ef4fb18fda983a66599 Mon Sep 17 00:00:00 2001 From: DRracer Date: Wed, 21 Oct 2020 17:04:20 +0200 Subject: [PATCH 34/73] Update messages.h cleanup space --- Firmware/messages.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/messages.h b/Firmware/messages.h index a9a23f0d2..cb8010225 100644 --- a/Firmware/messages.h +++ b/Firmware/messages.h @@ -176,7 +176,7 @@ extern const char MSG_FANCHECK_PRINT[]; extern const char MSG_M112_KILL[]; extern const char MSG_ADVANCE_K[]; extern const char MSG_POWERPANIC_DETECTED[]; -extern const char MSG_LCD_STATUS_CHANGED[]; +extern const char MSG_LCD_STATUS_CHANGED[]; #if defined(__cplusplus) } From 5f23474c95309b8a47a0bea92a88dbe3bbf25111 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Wed, 28 Oct 2020 20:49:28 +0100 Subject: [PATCH 35/73] Raise Z while preheating when auto/[un]loading the filament Preheating already raised Z to avoid scorching the PEI sheet, as does filament loading/unloading to allow for excess material to be removed. However, when loading/autoloading/unloading via the LCD with a cold nozzle the preheating menu is performed before the carriage is raised, leaving the carriage close to the sheet while heating the nozzle. Pre-raise the carriage already while waiting, so that the subsequent move is automagically skipped. Set bFilamentWaitingFlag only once to perform both the LCD initialization and raising to the appropriate height. Should fix #2761 --- Firmware/ultralcd.cpp | 61 +++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 63fea0e3f..adb9f2c31 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -2412,7 +2412,7 @@ void mFilamentItem(uint16_t nTemp, uint16_t nTempBed) case FilamentAction::None: case FilamentAction::Preheat: case FilamentAction::Lay1Cal: - + // handled earlier break; } if (bFilamentWaitingFlag) Sound_MakeSound(e_SOUND_TYPE_StandardPrompt); @@ -2420,34 +2420,45 @@ void mFilamentItem(uint16_t nTemp, uint16_t nTempBed) } else { - bFilamentWaitingFlag = true; lcd_set_cursor(0, 0); lcdui_print_temp(LCD_STR_THERMOMETER[0], (int) degHotend(0), (int) degTargetHotend(0)); - lcd_set_cursor(0, 1); - switch (eFilamentAction) + + if (!bFilamentWaitingFlag) { - case FilamentAction::Load: - case FilamentAction::AutoLoad: - case FilamentAction::MmuLoad: - lcd_puts_P(_i("Preheating to load")); ////MSG_ c=20 - break; - case FilamentAction::UnLoad: - case FilamentAction::MmuUnLoad: - lcd_puts_P(_i("Preheating to unload")); ////MSG_ c=20 - break; - case FilamentAction::MmuEject: - lcd_puts_P(_i("Preheating to eject")); ////MSG_ c=20 - break; - case FilamentAction::MmuCut: - lcd_puts_P(_i("Preheating to cut")); ////MSG_ c=20 - break; - case FilamentAction::None: - case FilamentAction::Preheat: - case FilamentAction::Lay1Cal: - break; + // First run after the filament preheat selection: + // setup the fixed LCD parts and raise Z as we wait + bFilamentWaitingFlag = true; + + lcd_set_cursor(0, 1); + switch (eFilamentAction) + { + case FilamentAction::Load: + case FilamentAction::AutoLoad: + case FilamentAction::MmuLoad: + lcd_puts_P(_i("Preheating to load")); ////MSG_ c=20 + raise_z_above(MIN_Z_FOR_LOAD); + break; + case FilamentAction::UnLoad: + case FilamentAction::MmuUnLoad: + lcd_puts_P(_i("Preheating to unload")); ////MSG_ c=20 + raise_z_above(MIN_Z_FOR_UNLOAD); + break; + case FilamentAction::MmuEject: + lcd_puts_P(_i("Preheating to eject")); ////MSG_ c=20 + break; + case FilamentAction::MmuCut: + lcd_puts_P(_i("Preheating to cut")); ////MSG_ c=20 + break; + case FilamentAction::None: + case FilamentAction::Preheat: + case FilamentAction::Lay1Cal: + // handled earlier + break; + } + lcd_set_cursor(0, 3); + lcd_puts_P(_i(">Cancel")); ////MSG_ c=20 r=1 } - lcd_set_cursor(0, 3); - lcd_puts_P(_i(">Cancel")); ////MSG_ c=20 r=1 + if (lcd_clicked()) { bFilamentWaitingFlag = false; From e28159122fcbff5e70d13325304a094d61fb9c2d Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Thu, 29 Oct 2020 15:14:17 +0100 Subject: [PATCH 36/73] Make MIN_Z_FOR_LOAD/UNLOAD the same When unloading + preheat immediately followed by a load, the carriage is raised first up to 20mm, then again to 50mm. With PR #2318 it makes sense to make more space for the extra extrusion anyway, so make them the same. This moves the carriage only once _while_ preheating, which is nice. --- Firmware/Configuration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index a9bf23e99..58e3ee743 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -552,7 +552,7 @@ enum CalibrationStatus // Try to maintain a minimum distance from the bed even when Z is // unknown when doing the following operations #define MIN_Z_FOR_LOAD 50 -#define MIN_Z_FOR_UNLOAD 20 +#define MIN_Z_FOR_UNLOAD 50 #define MIN_Z_FOR_PREHEAT 10 #include "Configuration_adv.h" From a5ba666af0991784a27a7a1863abb1543c6c0ef3 Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Mon, 2 Nov 2020 14:54:16 +0100 Subject: [PATCH 37/73] Changed from arguments to flags/options Check for "gawk" on Linux Add argument to change build number automatically to current commit or define own number Update exit numbers 1-13 for prepare build env 21-29 for prepare compiling 30-36 compiling --- PF-build.sh | 136 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 106 insertions(+), 30 deletions(-) diff --git a/PF-build.sh b/PF-build.sh index 9bdd377c8..7f0fd362e 100755 --- a/PF-build.sh +++ b/PF-build.sh @@ -56,7 +56,7 @@ # Some may argue that this is only used by a script, BUT as soon someone accidentally or on purpose starts Arduino IDE # it will use the default Arduino IDE folders and so can corrupt the build environment. # -# Version: 1.0.6-Build_30 +# Version: 1.0.6-Build_32 # Change log: # 12 Jan 2019, 3d-gussner, Fixed "compiler.c.elf.flags=-w -Os -Wl,-u,vfprintf -lprintf_flt -lm -Wl,--gc-sections" in 'platform.txt' # 16 Jan 2019, 3d-gussner, Build_2, Added development check to modify 'Configuration.h' to prevent unwanted LCD messages that Firmware is unknown @@ -125,11 +125,15 @@ # 12 May 2020, DRracer , Cleanup double MK2/s MK25/s `not_tran` and `not_used` files # 13 May 2020, leptun , If cleanup files do not exist don't try to. # 01 Oct 2020, 3d-gussner, Bug fix if using argument EN_ONLY. Thank to @leptun for pointing out. -# Change Build number to scrpit commits +# Change Build number to scrpit commits 'git rev-list --count HEAD PF-build.sh' # 02 Oct 2020, 3d-gussner, Add UNKNOWN as argument option # 05 Oct 2020, 3d-gussner, Disable pause and warnings using command line with all needed arguments # Install needed apps under linux if needed. # Clean PF-Firmware build when changing git branch +# 02 Nov 2020, 3d-gussner, Check for "gawk" on Linux +# Add argument to change build number automatically to current commit or define own number +# Update exit numbers 1-13 for prepare build env 21-29 for prepare compiling 30-36 compiling + #### Start check if OSTYPE is supported OS_FOUND=$( command -v uname) @@ -224,6 +228,16 @@ if ! type python > /dev/null; then fi fi +# Check gawk ... needed during language build +if ! type gawk > /dev/null; then + if [ $TARGET_OS == "linux" ]; then + echo "$(tput setaf 1)Missing 'gawk' which is important to run this script" + echo "install it with the command $(tput setaf 2)'sudo apt-get install gawk'." + sudo apt-get update && apt-get install gawk + exit 4 + fi +fi + #### End prepare bash / Linux environment @@ -430,8 +444,36 @@ fi #### Start cd $SCRIPT_PATH -# First argument defines which variant of the Prusa Firmware will be compiled -if [ -z "$1" ] ; then +# Check if git is availible +if type git > /dev/null; then + git_availible="1" +fi + +#arguments +#'-v' Variant "All" or variant file name +#'-l' Languages "ALL" for multi language or "EN_ONLY" for english only +#'-d' Devel build "GOLD", "RC", "BETA", "ALPHA", "DEBUG", "DEVEL" and "UNKNOWN" +#'-b' Build/commit number "Auto" needs git or a number +#'-o' Output "1" force or "0" block output and delays +while getopts v:l:d:b:o: flag + do + case "${flag}" in + v) variant_flag=${OPTARG};; + l) language_flag=${OPTARG};; + d) devel_flag=${OPTARG};; + b) build_flag=${OPTARG};; + o) output_flag=${OPTARG};; + esac + done +#echo "variant_flag: $variant_flag"; +#echo "language_flag: $language_flag"; +#echo "devel_flag: $devel_flag"; +#echo "build_flag: $build_flag"; +#echo "output_flag: $output_flag"; + +# +# '-v' argument defines which variant of the Prusa Firmware will be compiled +if [ -z "$variant_flag" ] ; then # Select which variant of the Prusa Firmware will be compiled, like PS3="Select a variant: " while IFS= read -r -d $'\0' f; do @@ -451,7 +493,7 @@ if [ -z "$1" ] ; then ;; "Quit") echo "You chose to stop" - exit + exit 20 ;; *) echo "$(tput setaf 1)This is not a valid variant$(tput sgr0)" @@ -459,21 +501,28 @@ if [ -z "$1" ] ; then esac done else - if [ -f "$SCRIPT_PATH/Firmware/variants/$1" ] ; then - VARIANTS=$1 + if [ -f "$SCRIPT_PATH/Firmware/variants/$variant_flag" ] ; then + VARIANTS=$variant_flag + elif [ "$variant_flag" == "All" ] ; then + while IFS= read -r -d $'\0' f; do + options[i++]="$f" + done < <(find Firmware/variants/ -maxdepth 1 -type f -name "*.h" -print0 ) + VARIANT="All" + VARIANTS=${options[*]} else - echo "$(tput setaf 1)$1 could not be found in Firmware/variants please choose a valid one$(tput setaf 2)" + echo "$(tput setaf 1)Argument $variant_flag could not be found in Firmware/variants please choose a valid one.$(tput sgr0)" + echo "Only $(tput setaf 2)'All'$(tput sgr0) and file names below are allowed as variant '-v' argument.$(tput setaf 2)" ls -1 $SCRIPT_PATH/Firmware/variants/*.h | xargs -n1 basename echo "$(tput sgr0)" exit 21 fi fi -#Second argument defines if it is an english only version. Known values EN_ONLY / ALL +#'-l' argument defines if it is an english only version. Known values EN_ONLY / ALL #Check default language mode MULTI_LANGUAGE_CHECK=$(grep --max-count=1 "^#define LANG_MODE *" $SCRIPT_PATH/Firmware/config.h|sed -e's/ */ /g'|cut -d ' ' -f3) -if [ -z "$2" ] ; then +if [ -z "$language_flag" ] ; then PS3="Select a language: " echo echo "Which lang-build do you want?" @@ -493,27 +542,43 @@ if [ -z "$2" ] ; then esac done else - if [[ "$2" == "ALL" || "$2" == "EN_ONLY" ]] ; then - LANGUAGES=$2 + if [[ "$language_flag" == "ALL" || "$language_flag" == "EN_ONLY" ]] ; then + LANGUAGES=$language_flag else echo "$(tput setaf 1)Language argument is wrong!$(tput sgr0)" - echo "Only $(tput setaf 2)'ALL'$(tput sgr0) or $(tput setaf 2)'EN_ONLY'$(tput sgr0) are allowed as 2nd argument!" + echo "Only $(tput setaf 2)'ALL'$(tput sgr0) or $(tput setaf 2)'EN_ONLY'$(tput sgr0) are allowed as language '-l' argument!" exit 22 fi fi -#Check if DEV_STATUS is selected via argument 3 -if [ ! -z "$3" ] ; then - if [[ "$3" == "GOLD" || "$3" == "RC" || "$3" == "BETA" || "$3" == "ALPHA" || "$3" == "DEVEL" || "$3" == "DEBUG" || "$3" == "UNKNOWN" ]] ; then - DEV_STATUS_SELECTED=$3 +#Check if DEV_STATUS is selected via argument '-d' +if [ ! -z "$devel_flag" ] ; then + if [[ "$devel_flag" == "GOLD" || "$devel_flag" == "RC" || "$devel_flag" == "BETA" || "$devel_flag" == "ALPHA" || "$devel_flag" == "DEVEL" || "$devel_flag" == "DEBUG" || "$devel_flag" == "UNKNOWN" ]] ; then + DEV_STATUS_SELECTED=$devel_flag else echo "$(tput setaf 1)Development argument is wrong!$(tput sgr0)" - echo "Only $(tput setaf 2)'GOLD', 'RC', 'BETA', 'ALPHA', 'DEVEL', 'DEBUG' or 'UNKNOWN' $(tput sgr0) are allowed as 3rd argument!$(tput sgr0)" + echo "Only $(tput setaf 2)'GOLD', 'RC', 'BETA', 'ALPHA', 'DEVEL', 'DEBUG' or 'UNKNOWN' $(tput sgr0) are allowed as devel '-d' argument!$(tput sgr0)" exit 23 fi fi +#Check if Build is selected via argument '-b' +if [ ! -z "$build_flag" ] ; then + if [[ "$build_flag" == "Auto" && "$git_availible" == "1" ]] ; then + echo "Build changed to $build_flag" + BUILD=$(git rev-list --count HEAD) + elif [[ $build_flag =~ ^[0-9]+$ ]] ; then + BUILD=$build_flag + else + echo "$(tput setaf 1)Build number argument is wrong!$(tput sgr0)" + echo "Only $(tput setaf 2)'Auto' (git needed) or numbers $(tput sgr0) are allowed as build '-b' argument!$(tput sgr0)" + exit 24 + + fi + echo "New Build number is: $BUILD" +fi + # check if script has been started with arguments -if [ "$#" -eq "0" ] ; then +if [[ "$#" -eq "0" || "$output_flag" == 1 ]] ; then OUTPUT=1 else OUTPUT=0 @@ -521,12 +586,12 @@ fi #echo "Output is:" $OUTPUT #Check git branch has changed -if ! type git > /dev/null; then +if [ ! -z "git_availible" ]; then BRANCH="" CLEAN_PF_FW_BUILD=0 else BRANCH=$(git branch --show-current) - echo "Branch is:" $BRANCH + echo "Current branch is:" $BRANCH if [ ! -f "$SCRIPT_PATH/../PF-build.branch" ]; then echo "$BRANCH" >| $SCRIPT_PATH/../PF-build.branch echo "created PF-build.branch file" @@ -541,18 +606,18 @@ else fi #Set BUILD_ENV_PATH -cd ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor || exit 24 +cd ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor || exit 25 BUILD_ENV_PATH="$( pwd -P )" cd ../.. #Checkif BUILD_PATH exists and if not creates it if [ ! -d "Prusa-Firmware-build" ]; then - mkdir Prusa-Firmware-build || exit 25 + mkdir Prusa-Firmware-build || exit 26 fi #Set the BUILD_PATH for Arduino IDE -cd Prusa-Firmware-build || exit 26 +cd Prusa-Firmware-build || exit 27 BUILD_PATH="$( pwd -P )" #Check git branch has changed @@ -568,8 +633,15 @@ do VARIANT=$(basename "$v" ".h") # Find firmware version in Configuration.h file and use it to generate the hex filename FW=$(grep --max-count=1 "\bFW_VERSION\b" $SCRIPT_PATH/Firmware/Configuration.h | sed -e's/ */ /g'|cut -d '"' -f2|sed 's/\.//g') - # Find build version in Configuration.h file and use it to generate the hex filename - BUILD=$(grep --max-count=1 "\bFW_COMMIT_NR\b" $SCRIPT_PATH/Firmware/Configuration.h | sed -e's/ */ /g'|cut -d ' ' -f3) + if [ -z "$BUILD" ] ; then + # Find build version in Configuration.h file and use it to generate the hex filename + BUILD=$(grep --max-count=1 "\bFW_COMMIT_NR\b" $SCRIPT_PATH/Firmware/Configuration.h | sed -e's/ */ /g'|cut -d ' ' -f3) + else + # Find and replace build version in Configuration.h file + BUILD_ORG=$(grep --max-count=1 "\bFW_COMMIT_NR\b" $SCRIPT_PATH/Firmware/Configuration.h | sed -e's/ */ /g'|cut -d ' ' -f3) + echo "Original build number: $BUILD_ORG" + sed -i -- "s/^#define FW_COMMIT_NR.*/#define FW_COMMIT_NR $BUILD/g" $SCRIPT_PATH/Firmware/Configuration.h + fi # Check if the motherboard is an EINSY and if so only one hex file will generated MOTHERBOARD=$(grep --max-count=1 "\bMOTHERBOARD\b" $SCRIPT_PATH/Firmware/variants/$VARIANT.h | sed -e's/ */ /g' |cut -d ' ' -f3) # Check development status @@ -613,7 +685,7 @@ do fi #Prepare hex files folders if [ ! -d "$SCRIPT_PATH/../PF-build-hex/FW$FW-Build$BUILD/$MOTHERBOARD" ]; then - mkdir -p $SCRIPT_PATH/../PF-build-hex/FW$FW-Build$BUILD/$MOTHERBOARD || exit 27 + mkdir -p $SCRIPT_PATH/../PF-build-hex/FW$FW-Build$BUILD/$MOTHERBOARD || exit 28 fi OUTPUT_FOLDER="PF-build-hex/FW$FW-Build$BUILD/$MOTHERBOARD" @@ -656,11 +728,11 @@ do #Prepare Firmware to be compiled by copying variant as Configuration_prusa.h if [ ! -f "$SCRIPT_PATH/Firmware/Configuration_prusa.h" ]; then - cp -f $SCRIPT_PATH/Firmware/variants/$VARIANT.h $SCRIPT_PATH/Firmware/Configuration_prusa.h || exit 28 + cp -f $SCRIPT_PATH/Firmware/variants/$VARIANT.h $SCRIPT_PATH/Firmware/Configuration_prusa.h || exit 29 else echo "$(tput setaf 6)Configuration_prusa.h already exist it will be overwritten in 10 seconds by the chosen variant.$(tput sgr 0)" read -t 10 -p "Press Enter to continue..." - cp -f $SCRIPT_PATH/Firmware/variants/$VARIANT.h $SCRIPT_PATH/Firmware/Configuration_prusa.h || exit 28 + cp -f $SCRIPT_PATH/Firmware/variants/$VARIANT.h $SCRIPT_PATH/Firmware/Configuration_prusa.h || exit 29 fi #Prepare Configuration.h to use the correct FW_DEV_VERSION to prevent LCD messages when connecting with OctoPrint @@ -705,7 +777,7 @@ do sleep 2 fi #$BUILD_ENV_PATH/arduino-builder -dump-prefs -debug-level 10 -compile -hardware $ARDUINO/hardware -hardware $ARDUINO/portable/packages -tools $ARDUINO/tools-builder -tools $ARDUINO/hardware/tools/avr -tools $ARDUINO/portable/packages -built-in-libraries $ARDUINO/libraries -libraries $ARDUINO/portable/sketchbook/libraries -fqbn=$BOARD_PACKAGE_NAME:avr:$BOARD -build-path=$BUILD_PATH -warnings=all $SCRIPT_PATH/Firmware/Firmware.ino || exit 14 - $BUILD_ENV_PATH/arduino-builder -compile -hardware $ARDUINO/hardware -hardware $ARDUINO/portable/packages -tools $ARDUINO/tools-builder -tools $ARDUINO/hardware/tools/avr -tools $ARDUINO/portable/packages -built-in-libraries $ARDUINO/libraries -libraries $ARDUINO/portable/sketchbook/libraries -fqbn=$BOARD_PACKAGE_NAME:avr:$BOARD -build-path=$BUILD_PATH -warnings=all $SCRIPT_PATH/Firmware/Firmware.ino || exit 14 + $BUILD_ENV_PATH/arduino-builder -compile -hardware $ARDUINO/hardware -hardware $ARDUINO/portable/packages -tools $ARDUINO/tools-builder -tools $ARDUINO/hardware/tools/avr -tools $ARDUINO/portable/packages -built-in-libraries $ARDUINO/libraries -libraries $ARDUINO/portable/sketchbook/libraries -fqbn=$BOARD_PACKAGE_NAME:avr:$BOARD -build-path=$BUILD_PATH -warnings=all $SCRIPT_PATH/Firmware/Firmware.ino || exit 30 echo "$(tput sgr 0)" if [ $LANGUAGES == "ALL" ]; then @@ -798,8 +870,12 @@ do then rm $SCRIPT_PATH/lang/not_used.txt fi + # Restore files to previous state sed -i -- "s/^#define FW_DEV_VERSION FW_VERSION_$DEV_STATUS/#define FW_DEV_VERSION FW_VERSION_UNKNOWN/g" $SCRIPT_PATH/Firmware/Configuration.h sed -i -- 's/^#define FW_REPOSITORY "Prusa3d"/#define FW_REPOSITORY "Unknown"/g' $SCRIPT_PATH/Firmware/Configuration.h + if [ ! -z "$BUILD_ORG" ] ; then + sed -i -- "s/^#define FW_COMMIT_NR.*/#define FW_COMMIT_NR $BUILD_ORG/g" $SCRIPT_PATH/Firmware/Configuration.h + fi echo $MULTI_LANGUAGE_CHECK #sed -i -- "s/^#define LANG_MODE * /#define LANG_MODE $MULTI_LANGUAGE_CHECK/g" $SCRIPT_PATH/Firmware/config.h sed -i -- "s/^#define LANG_MODE *1/#define LANG_MODE ${MULTI_LANGUAGE_CHECK}/g" $SCRIPT_PATH/Firmware/config.h From 7651fbb0d192dedd9691b8d0dc3388c41af6fbcf Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Mon, 2 Nov 2020 17:11:24 +0100 Subject: [PATCH 38/73] Fix output "Configuration_prusa.h" delay if compiling failed. --- PF-build.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/PF-build.sh b/PF-build.sh index 7f0fd362e..5a174c9ca 100755 --- a/PF-build.sh +++ b/PF-build.sh @@ -731,7 +731,9 @@ do cp -f $SCRIPT_PATH/Firmware/variants/$VARIANT.h $SCRIPT_PATH/Firmware/Configuration_prusa.h || exit 29 else echo "$(tput setaf 6)Configuration_prusa.h already exist it will be overwritten in 10 seconds by the chosen variant.$(tput sgr 0)" - read -t 10 -p "Press Enter to continue..." + if [ $OUTPUT == "1" ] ; then + read -t 10 -p "Press Enter to continue..." + fi cp -f $SCRIPT_PATH/Firmware/variants/$VARIANT.h $SCRIPT_PATH/Firmware/Configuration_prusa.h || exit 29 fi From 26f62f042ee0a0448eba6310547d8f47219e6218 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Sun, 25 Oct 2020 19:32:03 +0200 Subject: [PATCH 39/73] Use the longest filename instead of just using the long filename in M27 --- Firmware/cardreader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/cardreader.cpp b/Firmware/cardreader.cpp index fdef1cd43..0a6fdeea8 100644 --- a/Firmware/cardreader.cpp +++ b/Firmware/cardreader.cpp @@ -498,7 +498,7 @@ void CardReader::getStatus() SERIAL_PROTOCOLLNPGM("Print saved"); } else { - SERIAL_PROTOCOLLN(longFilename); + SERIAL_PROTOCOLLN(LONGEST_FILENAME); SERIAL_PROTOCOLRPGM(_N("SD printing byte "));////MSG_SD_PRINTING_BYTE SERIAL_PROTOCOL(sdpos); SERIAL_PROTOCOL('/'); From e5ebf7c67f057f1ddeba53c759238d2c3b65bdd2 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Sun, 25 Oct 2020 19:32:23 +0200 Subject: [PATCH 40/73] Fix missing keep-alive messages --- Firmware/Marlin_main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index dd6dd78b1..dac3aa6a8 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -2631,7 +2631,6 @@ void gcode_M105(uint8_t extruder) } #endif SERIAL_PROTOCOLLN(""); - KEEPALIVE_STATE(NOT_BUSY); } #ifdef TMC2130 From 0ee8e1f424a2895912e39349ef1a6965a341fb24 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Sun, 25 Oct 2020 19:32:41 +0200 Subject: [PATCH 41/73] Fix missing ok in M601 --- Firmware/Marlin_main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index dac3aa6a8..f1abeb87f 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -7994,6 +7994,7 @@ Sigma_Exit: if (!isPrintPaused) { st_synchronize(); + ClearToSend(); //send OK even before the command finishes executing because we want to make sure it is not skipped because of cmdqueue_pop_front(); cmdqueue_pop_front(); //trick because we want skip this command (M601) after restore lcd_pause_print(); } From 6873a9d28e527dbcf9d26495e18133c2649e8e87 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Sun, 25 Oct 2020 19:33:02 +0200 Subject: [PATCH 42/73] Only send capabilities when M115 is run without arguments --- Firmware/Marlin_main.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index f1abeb87f..fe8bbbade 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -6863,12 +6863,10 @@ Sigma_Exit: SERIAL_ECHOPGM(STRINGIFY(EXTRUDERS)); SERIAL_ECHOPGM(" UUID:"); SERIAL_ECHOLNPGM(MACHINE_UUID); - } - #ifdef EXTENDED_CAPABILITIES_REPORT - extended_capabilities_report(); + extended_capabilities_report(); #endif //EXTENDED_CAPABILITIES_REPORT - + } break; /*! From 5f0e4a1cac9abb3ef35137038afe7945c76f6c8e Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Sun, 25 Oct 2020 19:33:23 +0200 Subject: [PATCH 43/73] Temporary M602 patch. Needs more work --- Firmware/Marlin_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index fe8bbbade..260b9a30b 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -11459,7 +11459,7 @@ void restore_print_from_ram_and_continue(float e_move) //not sd printing nor usb printing } - SERIAL_PROTOCOLLNRPGM(MSG_OK); //dummy response because of octoprint is waiting for this + // SERIAL_PROTOCOLLNRPGM(MSG_OK); //dummy response because of octoprint is waiting for this lcd_setstatuspgm(_T(WELCOME_MSG)); saved_printing_type = PRINTING_TYPE_NONE; saved_printing = false; From ff56ece6f8f5037bf5f00a194911be0fe856bc93 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Sun, 25 Oct 2020 19:48:48 +0200 Subject: [PATCH 44/73] Remove redundant get_command prototype --- Firmware/Marlin.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 6e4b24206..5a38cae52 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -116,7 +116,6 @@ void serial_echopair_P(const char *s_P, unsigned long v); void serialprintPGM(const char *str); bool is_buffer_empty(); -void get_command(); void process_commands(); void ramming(); From fdbbc7d62a0336280d4cf043018ee66ba21e824f Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Sun, 25 Oct 2020 20:12:01 +0200 Subject: [PATCH 45/73] Terminate last line from the SD card even if it doesn't have a \n --- Firmware/cmdqueue.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Firmware/cmdqueue.cpp b/Firmware/cmdqueue.cpp index c86935529..9167aaaa6 100755 --- a/Firmware/cmdqueue.cpp +++ b/Firmware/cmdqueue.cpp @@ -582,8 +582,6 @@ void get_command() ((serial_char == '#' || serial_char == ':') && comment_mode == false) || serial_count >= (MAX_CMD_SIZE - 1) || n==-1) { - if(card.eof()) break; - if(serial_char=='#') stop_buffering=true; @@ -631,6 +629,9 @@ void get_command() comment_mode = false; //for new command serial_count = 0; //clear buffer + + if(card.eof()) break; + // The following line will reserve buffer space if available. if (! cmdqueue_could_enqueue_back(MAX_CMD_SIZE-1, true)) return; From 4abf1f436a43fa4a0ae7b5237acdc251c85d85d5 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Mon, 26 Oct 2020 09:42:26 +0200 Subject: [PATCH 46/73] Gracefully dump the queue + fixes to fancheck --- Firmware/Marlin.h | 11 ----------- Firmware/Marlin_main.cpp | 17 +++++++---------- Firmware/cardreader.cpp | 1 + Firmware/cmdqueue.cpp | 20 +++++++++++++++----- Firmware/cmdqueue.h | 5 +++-- Firmware/first_lay_cal.cpp | 1 + Firmware/menu.cpp | 1 + Firmware/mmu.cpp | 1 + Firmware/temperature.cpp | 2 +- Firmware/ultralcd.cpp | 16 ++++++++++------ 10 files changed, 40 insertions(+), 35 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 5a38cae52..19635c178 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -240,23 +240,12 @@ void Stop(); bool IsStopped(); void finishAndDisableSteppers(); -//put an ASCII command at the end of the current buffer. -void enquecommand(const char *cmd, bool from_progmem = false); - //put an ASCII command at the end of the current buffer, read from flash #define enquecommand_P(cmd) enquecommand(cmd, true) -//put an ASCII command at the begin of the current buffer -void enquecommand_front(const char *cmd, bool from_progmem = false); - //put an ASCII command at the begin of the current buffer, read from flash #define enquecommand_front_P(cmd) enquecommand_front(cmd, true) -void repeatcommand_front(); - -// Remove all lines from the command queue. -void cmdqueue_reset(); - void prepare_arc_move(char isclockwise); void clamp_to_software_endstops(float target[3]); void refresh_cmd_timeout(void); diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 260b9a30b..5376daefe 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -631,7 +631,7 @@ void crashdet_cancel() lcd_print_stop(); }else if(saved_printing_type == PRINTING_TYPE_USB){ SERIAL_ECHOLNRPGM(MSG_OCTOPRINT_CANCEL); //for Octoprint: works the same as clicking "Abort" button in Octoprint GUI - SERIAL_PROTOCOLLNRPGM(MSG_OK); + cmdqueue_reset(); } } @@ -3678,14 +3678,12 @@ There are reasons why some G Codes aren't in numerical order. void process_commands() { #ifdef FANCHECK - if(fan_check_error){ - if(fan_check_error == EFCE_DETECTED){ - fan_check_error = EFCE_REPORTED; - // SERIAL_PROTOCOLLNRPGM(MSG_OCTOPRINT_PAUSED); - lcd_pause_print(); - } // otherwise it has already been reported, so just ignore further processing - return; //ignore usb stream. It is reenabled by selecting resume from the lcd. - } + if(fan_check_error == EFCE_DETECTED){ + fan_check_error = EFCE_REPORTED; + // SERIAL_PROTOCOLLNRPGM(MSG_OCTOPRINT_PAUSED); + lcd_pause_print(); + cmdqueue_serial_disabled = true; + } #endif if (!buflen) return; //empty command @@ -11459,7 +11457,6 @@ void restore_print_from_ram_and_continue(float e_move) //not sd printing nor usb printing } - // SERIAL_PROTOCOLLNRPGM(MSG_OK); //dummy response because of octoprint is waiting for this lcd_setstatuspgm(_T(WELCOME_MSG)); saved_printing_type = PRINTING_TYPE_NONE; saved_printing = false; diff --git a/Firmware/cardreader.cpp b/Firmware/cardreader.cpp index 0a6fdeea8..94077f4cd 100644 --- a/Firmware/cardreader.cpp +++ b/Firmware/cardreader.cpp @@ -1,4 +1,5 @@ #include "Marlin.h" +#include "cmdqueue.h" #include "cardreader.h" #include "ultralcd.h" #include "stepper.h" diff --git a/Firmware/cmdqueue.cpp b/Firmware/cmdqueue.cpp index 9167aaaa6..5c5a71731 100755 --- a/Firmware/cmdqueue.cpp +++ b/Firmware/cmdqueue.cpp @@ -18,6 +18,10 @@ int buflen = 0; // Therefore don't remove the command from the queue in the loop() function. bool cmdbuffer_front_already_processed = false; +// Used for temporarely preventing accidental adding of Serial commands to the queue. +// For now only check_file and the fancheck pause use this. +bool cmdqueue_serial_disabled = false; + int serial_count = 0; //index of character read from serial line boolean comment_mode = false; char *strchr_pointer; // just a pointer to find chars in the command string like X, Y, Z, E, etc @@ -91,14 +95,20 @@ bool cmdqueue_pop_front() void cmdqueue_reset() { - bufindr = 0; - bufindw = 0; - buflen = 0; + while (buflen) + { + uint8_t cmdqueue_current_type = *(cmdbuffer+bufindr); + // printf_P(PSTR("dumping: \"%s\" of type %hu\n"), cmdbuffer+bufindr+CMDHDRSIZE, cmdqueue_current_type); + ClearToSend(); + cmdqueue_pop_front(); + } + bufindr = 0; + bufindw = 0; //commands are removed from command queue after process_command() function is finished //reseting command queue and enqueing new commands during some (usually long running) command processing would cause that new commands are immediately removed from queue (or damaged) //this will ensure that all new commands which are enqueued after cmdqueue reset, will be always executed - cmdbuffer_front_already_processed = true; + cmdbuffer_front_already_processed = true; } // How long a string could be pushed to the front of the command queue? @@ -390,7 +400,7 @@ void get_command() } // start of serial line processing loop - while ((MYSERIAL.available() > 0 && !saved_printing) || (MYSERIAL.available() > 0 && isPrintPaused)) { //is print is saved (crash detection or filament detection), dont process data from serial line + while (((MYSERIAL.available() > 0 && !saved_printing) || (MYSERIAL.available() > 0 && isPrintPaused)) && !cmdqueue_serial_disabled) { //is print is saved (crash detection or filament detection), dont process data from serial line char serial_char = MYSERIAL.read(); /* if (selectedSerialPort == 1) diff --git a/Firmware/cmdqueue.h b/Firmware/cmdqueue.h index 13185f179..017452a2a 100644 --- a/Firmware/cmdqueue.h +++ b/Firmware/cmdqueue.h @@ -35,6 +35,7 @@ extern char cmdbuffer[BUFSIZE * (MAX_CMD_SIZE + 1) + CMDBUFFER_RESERVE_FRONT]; extern size_t bufindr; extern int buflen; extern bool cmdbuffer_front_already_processed; +extern bool cmdqueue_serial_disabled; // Type of a command, which is to be executed right now. #define CMDBUFFER_CURRENT_TYPE (cmdbuffer[bufindr]) @@ -65,8 +66,8 @@ extern void cmdqueue_dump_to_serial_single_line(int nr, const char *p); extern void cmdqueue_dump_to_serial(); #endif /* CMDBUFFER_DEBUG */ extern bool cmd_buffer_empty(); -extern void enquecommand(const char *cmd, bool from_progmem); -extern void enquecommand_front(const char *cmd, bool from_progmem); +extern void enquecommand(const char *cmd, bool from_progmem = false); +extern void enquecommand_front(const char *cmd, bool from_progmem = false); extern void repeatcommand_front(); extern bool is_buffer_empty(); extern void get_command(); diff --git a/Firmware/first_lay_cal.cpp b/Firmware/first_lay_cal.cpp index a6b5f109f..d7ddc5c8d 100644 --- a/Firmware/first_lay_cal.cpp +++ b/Firmware/first_lay_cal.cpp @@ -7,6 +7,7 @@ #include "Configuration_prusa.h" #include "language.h" #include "Marlin.h" +#include "cmdqueue.h" #include "mmu.h" #include diff --git a/Firmware/menu.cpp b/Firmware/menu.cpp index 3c4e89260..9c7704e6f 100755 --- a/Firmware/menu.cpp +++ b/Firmware/menu.cpp @@ -8,6 +8,7 @@ #include "lcd.h" #include "Configuration.h" #include "Marlin.h" +#include "cmdqueue.h" #include "ultralcd.h" #include "language.h" #include "static_assert.h" diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index ab4af5e29..18b5d5e79 100755 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -9,6 +9,7 @@ #include "Configuration_prusa.h" #include "fsensor.h" #include "cardreader.h" +#include "cmdqueue.h" #include "ultralcd.h" #include "sound.h" #include "printers.h" diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index cb4fc8aee..b4977c405 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -30,6 +30,7 @@ #include "Marlin.h" +#include "cmdqueue.h" #include "ultralcd.h" #include "sound.h" #include "temperature.h" @@ -632,7 +633,6 @@ void fanSpeedError(unsigned char _fan) { fanSpeedErrorBeep(PSTR("Print fan speed is lower than expected"), MSG_FANCHECK_PRINT); break; } - // SERIAL_PROTOCOLLNRPGM(MSG_OK); //This ok messes things up with octoprint. } #endif //(defined(TACH_0) && TACH_0 >-1) || (defined(TACH_1) && TACH_1 > -1) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 63fea0e3f..e93047465 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1582,6 +1582,7 @@ void lcd_return_to_status() //! @brief Pause print, disable nozzle heater, move to park position void lcd_pause_print() { + SERIAL_PROTOCOLLNRPGM(MSG_OCTOPRINT_PAUSED); //pause for octoprint stop_and_save_print_to_ram(0.0, -default_retraction); lcd_return_to_status(); isPrintPaused = true; @@ -1589,7 +1590,6 @@ void lcd_pause_print() { lcd_commands_type = LcdCommands::LongPause; } - SERIAL_PROTOCOLLNRPGM(MSG_OCTOPRINT_PAUSED); //pause for octoprint } @@ -6740,6 +6740,7 @@ void lcd_resume_print() lcd_return_to_status(); lcd_reset_alert_level(); //for fan speed error if (fan_error_selftest()) return; //abort if error persists + cmdqueue_serial_disabled = false; lcd_setstatuspgm(_T(MSG_FINISHING_MOVEMENTS)); st_synchronize(); @@ -7352,6 +7353,7 @@ void lcd_print_stop() if (!card.sdprinting) { SERIAL_ECHOLNRPGM(MSG_OCTOPRINT_CANCEL); // for Octoprint } + cmdqueue_serial_disabled = false; //for when canceling a print with a fancheck CRITICAL_SECTION_START; @@ -8780,27 +8782,29 @@ static void lcd_selftest_screen_step(int _row, int _col, int _state, const char /** Menu action functions **/ static bool check_file(const char* filename) { - if (farm_mode) return true; + if (farm_mode) + return true; bool result = false; uint32_t filesize; card.openFile((char*)filename, true); filesize = card.getFileSize(); if (filesize > END_FILE_SECTION) { card.setIndex(filesize - END_FILE_SECTION); - } + cmdqueue_reset(); + cmdqueue_serial_disabled = true; - while (!card.eof() && !result) { + while (!card.eof() && !result) { card.sdprinting = true; get_command(); result = check_commands(); - } + + cmdqueue_serial_disabled = false; card.printingHasFinished(); strncpy_P(lcd_status_message, _T(WELCOME_MSG), LCD_WIDTH); lcd_finishstatus(); return result; - } static void menu_action_sdfile(const char* filename) From 0c305ee5f573c3b925e5089eb0bc8dae60b30143 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Wed, 28 Oct 2020 10:07:46 +0200 Subject: [PATCH 47/73] Fix warning --- Firmware/cmdqueue.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Firmware/cmdqueue.cpp b/Firmware/cmdqueue.cpp index 5c5a71731..afdddfba2 100755 --- a/Firmware/cmdqueue.cpp +++ b/Firmware/cmdqueue.cpp @@ -97,8 +97,7 @@ void cmdqueue_reset() { while (buflen) { - uint8_t cmdqueue_current_type = *(cmdbuffer+bufindr); - // printf_P(PSTR("dumping: \"%s\" of type %hu\n"), cmdbuffer+bufindr+CMDHDRSIZE, cmdqueue_current_type); + // printf_P(PSTR("dumping: \"%s\" of type %hu\n"), cmdbuffer+bufindr+CMDHDRSIZE, CMDBUFFER_CURRENT_TYPE); ClearToSend(); cmdqueue_pop_front(); } From 023ccb0e895c4c936e5e2ceb49fd8a40c34c533b Mon Sep 17 00:00:00 2001 From: Voinea Dragos Date: Mon, 9 Nov 2020 21:39:10 +0200 Subject: [PATCH 48/73] Fix double ok in M603 --- Firmware/Marlin_main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 5376daefe..d47576cd8 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -9205,8 +9205,8 @@ void FlushSerialRequestResend() // Execution of a command from a SD card will not be confirmed. void ClearToSend() { - previous_millis_cmd = _millis(); - if ((CMDBUFFER_CURRENT_TYPE == CMDBUFFER_CURRENT_TYPE_USB) || (CMDBUFFER_CURRENT_TYPE == CMDBUFFER_CURRENT_TYPE_USB_WITH_LINENR)) + previous_millis_cmd = _millis(); + if (buflen && ((CMDBUFFER_CURRENT_TYPE == CMDBUFFER_CURRENT_TYPE_USB) || (CMDBUFFER_CURRENT_TYPE == CMDBUFFER_CURRENT_TYPE_USB_WITH_LINENR))) SERIAL_PROTOCOLLNRPGM(MSG_OK); } From 176e2674b9b3bebdff40f3afc393ee1992801e9c Mon Sep 17 00:00:00 2001 From: Voinea Dragos Date: Mon, 9 Nov 2020 21:39:22 +0200 Subject: [PATCH 49/73] Fix M105 ok hack --- Firmware/Marlin_main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index d47576cd8..c6f9e4b74 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -6399,7 +6399,8 @@ Sigma_Exit: SERIAL_PROTOCOLPGM("ok "); gcode_M105(extruder); - return; + cmdqueue_pop_front(); //prevent an ok after the command since this command uses an ok at the beginning. + break; } From 43ace00a243cc221b8bfcdc4b61c2e5f16a784d4 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Thu, 12 Nov 2020 18:43:48 +0200 Subject: [PATCH 50/73] Fill the progress bar at the end and code optimizations --- Firmware/ultralcd.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 15d0d68c7..0a2236f4a 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -8786,6 +8786,7 @@ static bool check_file(const char* filename) { const uint32_t filesize = card.getFileSize(); uint32_t startPos = 0; const uint16_t bytesToCheck = min(END_FILE_SECTION, filesize); + uint8_t blocksPrinted = 0; if (filesize > END_FILE_SECTION) { startPos = filesize - END_FILE_SECTION; card.setIndex(startPos); @@ -8793,23 +8794,23 @@ static bool check_file(const char* filename) { lcd_clear(); lcd_puts_at_P(0, 1, _i("Checking file"));////c=20 r=1 + lcd_set_cursor(0, 2); printf_P(PSTR("startPos=%lu\n"), startPos); while (!card.eof() && !result) { - lcd_set_cursor(0, 2); - for (int column = 0; column < 20; column++) { - const int8_t percent = ((card.get_sdpos() - startPos) * 100) / bytesToCheck; - if (column < (percent / 5)) - { - lcd_set_cursor(column, 2); - lcd_print('\xFF'); //simple progress bar - } - } + for (; blocksPrinted < (((card.get_sdpos() - startPos) * LCD_WIDTH) / bytesToCheck); blocksPrinted++) + lcd_print('\xFF'); //simple progress bar card.sdprinting = true; get_command(); result = check_commands(); } + + for (; blocksPrinted < LCD_WIDTH; blocksPrinted++) + lcd_print('\xFF'); //simple progress bar + _delay(100); //for the user to see the end of the progress bar. + card.printingHasFinished(); + strncpy_P(lcd_status_message, _T(WELCOME_MSG), LCD_WIDTH); lcd_finishstatus(); return result; From 807eddafb046bf15e68019244cff927980775ab5 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Fri, 13 Nov 2020 12:12:18 +0200 Subject: [PATCH 51/73] Remove debugging code --- Firmware/ultralcd.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 0a2236f4a..0a6e47916 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -8795,7 +8795,6 @@ static bool check_file(const char* filename) { lcd_clear(); lcd_puts_at_P(0, 1, _i("Checking file"));////c=20 r=1 lcd_set_cursor(0, 2); - printf_P(PSTR("startPos=%lu\n"), startPos); while (!card.eof() && !result) { for (; blocksPrinted < (((card.get_sdpos() - startPos) * LCD_WIDTH) / bytesToCheck); blocksPrinted++) lcd_print('\xFF'); //simple progress bar From f96f75bd171cf32afec9e876bc2ff3c2a76db5e7 Mon Sep 17 00:00:00 2001 From: Voinea Dragos Date: Mon, 16 Nov 2020 10:58:26 +0200 Subject: [PATCH 52/73] Fix warning and a bit of indentation Saved 64B of flash and 1B of SRAM --- Firmware/xyzcal.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Firmware/xyzcal.cpp b/Firmware/xyzcal.cpp index 767024dbe..7179996d8 100644 --- a/Firmware/xyzcal.cpp +++ b/Firmware/xyzcal.cpp @@ -495,20 +495,22 @@ int8_t xyzcal_find_point_center2(uint16_t delay_us) xyzcal_lineXYZ_to(_X, _Y, z0 - 400, 500, 1); if (has_temperature_compensation()){ - z0 = _Z - 20; // normal PINDA + z0 = _Z - 20; // normal PINDA return xyzcal_find_point_center2A(x0, y0, z0, delay_us); } else { // try searching harder, each PINDA is different + int8_t rv = 0; for(z0 = _Z - 20; z0 <= _Z + 140; z0 += 20 ){ // alternate PINDA - int8_t rv = xyzcal_find_point_center2A(x0, y0, z0, delay_us); + rv = xyzcal_find_point_center2A(x0, y0, z0, delay_us); printf_P(PSTR(" z0=%d"), z0); if( rv != 0 ){ - printf_P(PSTR("ok\n")); - return rv; + puts_P(PSTR("ok")); + break; } else { - printf_P(PSTR("fail\n")); + puts_P(PSTR("fail")); } } + return rv; } } From 603d704178d6742c175f537fdab242eeeeafedaf Mon Sep 17 00:00:00 2001 From: "D.R.racer" Date: Thu, 7 Jan 2021 12:50:58 +0100 Subject: [PATCH 53/73] Version changed (3.9.3 build 3556) --- Firmware/Configuration.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index fda3bc9e8..315f808a4 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -16,8 +16,8 @@ extern uint16_t nPrinterType; extern PGM_P sPrinterName; // Firmware version -#define FW_VERSION "3.9.3-RC1" -#define FW_COMMIT_NR 3555 +#define FW_VERSION "3.9.3" +#define FW_COMMIT_NR 3556 // FW_VERSION_UNKNOWN means this is an unofficial build. // The firmware should only be checked into github with this symbol. #define FW_DEV_VERSION FW_VERSION_UNKNOWN From f7dbc70b9c5112afd9821b0bddb0d6462596c539 Mon Sep 17 00:00:00 2001 From: Mesa Komarevich Date: Thu, 17 Dec 2020 05:52:14 -0700 Subject: [PATCH 54/73] Added some specific instructions for building firmware with a Debian WSL install. Updated commands to use sudo to avoid permission errors. --- README.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 1562552bc..6cc123987 100644 --- a/README.md +++ b/README.md @@ -111,10 +111,14 @@ _notes: Script and instructions contributed by 3d-gussner. Use at your own risk. - follow the Microsoft guide https://docs.microsoft.com/en-us/windows/wsl/install-win10 You can also use the 'prepare_winbuild.ps1' powershell script with Administrator rights - Tested versions are at this moment - - Ubuntu other may different + - Ubuntu and Debian, other may different - After the installation and reboot please open your Ubuntu bash and do following steps - - run command `apt-get update` - - to install zip run `apt-get install zip` + - run command `sudo apt-get update` + - run command `sudo apt-get upgrade` + - to install zip run `sudo apt-get install zip` + - if using Debian: + - install dos2unix by running `sudo apt-get install dos2unix` + - run `dos2unix PF-build.sh` to convert the windows line endings to unix line endings - add few lines at the top of `~/.bashrc` by running `sudo nano ~/.bashrc` export OS="Linux" @@ -122,10 +126,10 @@ _notes: Script and instructions contributed by 3d-gussner. Use at your own risk. export GPG_TTY=$(tty) use `CRTL-X` to close nano and confirm to write the new entries - - restart Ubuntu bash -Now your Ubuntu subsystem is ready to use the automatic `PF-build.sh` script and compile your firmware correctly + - restart Ubuntu/Debian bash + - Now your Ubuntu/Debian subsystem is ready to use the automatic `PF-build.sh` script and compile your firmware correctly -#### Some Tips for Ubuntu +#### Some Tips for Ubuntu and Debian - Linux is case sensetive so please don't forget to use capital letters where needed, like changing to a directory - To change the path to your Prusa-Firmware location you downloaded and unzipped - Example: You files are under `C:\Users\\Downloads\Prusa-Firmware-MK3` @@ -137,7 +141,7 @@ Now your Ubuntu subsystem is ready to use the automatic `PF-build.sh` script and - If your Windows isn't in English the Paths may look different Example in other languages - English `/mnt/c/Users//Downloads/Prusa-Firmware-MK3` will be on a German Windows`/mnt/c/Anwender//Downloads/Prusa-Firmware-MK3` -#### Compile Prusa-firmware with Ubuntu Linux subsystem installed +#### Compile Prusa-firmware with Ubuntu/Debian Linux subsystem installed - open Ubuntu bash - change to your source code folder (case sensitive) - run `./PF-build.sh` From 2764b9455851e3c6fc83feac2b44c620589536e8 Mon Sep 17 00:00:00 2001 From: Mesa Komarevich Date: Tue, 22 Dec 2020 06:37:23 -0700 Subject: [PATCH 55/73] Updated the dos2unix instructions to no longer be specific to Debian, as unix based distro's being able to handle windows line endings should be considered an exception, and not the rule. Also fixed a few spelling mistakes in the README. --- README.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 6cc123987..108214c0d 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ _Note: Multi language build is not supported._ **c.** Modify compiler flags in `platform.txt` file -* The platform.txt file can be found in Arduino instalation directory, or after Arduino has been updated at: `"C:\Users\(user)\AppData\Local\Arduino15\packages\arduino\hardware\avr\(version)"` If you can locate the file in both places, file from user profile is probably used. +* The platform.txt file can be found in Arduino installation directory, or after Arduino has been updated at: `"C:\Users\(user)\AppData\Local\Arduino15\packages\arduino\hardware\avr\(version)"` If you can locate the file in both places, file from user profile is probably used. * Add `"-Wl,-u,vfprintf -lprintf_flt -lm"` to `"compiler.c.elf.flags="` before existing flag "-Wl,--gc-sections" @@ -116,9 +116,8 @@ _notes: Script and instructions contributed by 3d-gussner. Use at your own risk. - run command `sudo apt-get update` - run command `sudo apt-get upgrade` - to install zip run `sudo apt-get install zip` - - if using Debian: - - install dos2unix by running `sudo apt-get install dos2unix` - - run `dos2unix PF-build.sh` to convert the windows line endings to unix line endings + - to install dos2unix run `sudo apt-get install dos2unix` + - run `dos2unix PF-build.sh` to convert the windows line endings to unix line endings - add few lines at the top of `~/.bashrc` by running `sudo nano ~/.bashrc` export OS="Linux" @@ -130,7 +129,7 @@ _notes: Script and instructions contributed by 3d-gussner. Use at your own risk. - Now your Ubuntu/Debian subsystem is ready to use the automatic `PF-build.sh` script and compile your firmware correctly #### Some Tips for Ubuntu and Debian -- Linux is case sensetive so please don't forget to use capital letters where needed, like changing to a directory +- Linux is case sensitive so please don't forget to use capital letters where needed, like changing to a directory - To change the path to your Prusa-Firmware location you downloaded and unzipped - Example: You files are under `C:\Users\\Downloads\Prusa-Firmware-MK3` - use under Ubuntu the following command `cd /mnt/c/Users//Downloads/Prusa-Firmware-MK3` @@ -210,7 +209,7 @@ or visit https://prusa3d.github.io/Prusa-Firmware-Doc for doxygen generated outp # 5. FAQ Q:I built firmware using Arduino and I see "?" instead of numbers in printer user interface. -A:Step 1.c was ommited or you updated Arduino and now platform.txt located somewhere in your user profile is used. +A:Step 1.c was omitted or you updated Arduino and now platform.txt located somewhere in your user profile is used. Q:I built firmware using Arduino and printer now speaks Klingon (nonsense characters and symbols are displayed @^#$&*°;~ÿ) @@ -222,4 +221,4 @@ A:Our production builds are 99.9% equivalent to https://github.com/prusa3d/Prusa Q:Why are build instructions for Arduino mess. -Y:We are too lazy to ship proper board definition for Arduino. We plan to swich to cmake + ninja to be inherently multiplatform, easily integrate build tools, suport more IDEs, get 10 times shorter build times and be able to update compiler whenewer we want. +Y:We are too lazy to ship proper board definition for Arduino. We plan to switch to cmake + ninja to be inherently multiplatform, easily integrate build tools, suport more IDEs, get 10 times shorter build times and be able to update compiler whenever we want. From 3329d34ce4f0d4a71360fb5ec5df922dd86b8645 Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Mon, 14 Dec 2020 10:37:34 +0100 Subject: [PATCH 56/73] Fix doxygen issue with "^" and "|" only in one line Doxygen 1.8.13 had no issues but newer doxygen version are failing to build tables, if a line only consists of "^" and "|" --- Firmware/eeprom.h | 56 ++--------------------------------------------- 1 file changed, 2 insertions(+), 54 deletions(-) diff --git a/Firmware/eeprom.h b/Firmware/eeprom.h index 5cb7ddb85..9de7d7f5b 100644 --- a/Firmware/eeprom.h +++ b/Firmware/eeprom.h @@ -98,19 +98,9 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP | 0x0FF1h 4081 | uint32 | EEPROM_FILAMENTUSED | ??? | 00 00 00 00h 0 __S/P__| Filament used in meters | ??? | D3 Ax0ff1 C4 | 0x0FEDh 4077 | uint32 | EEPROM_TOTALTIME | ??? | 00 00 00 00h 0 __S/P__| Total print time | ??? | D3 Ax0fed C4 | 0x0FE5h 4069 | float | EEPROM_BED_CALIBRATION_CENTER | ??? | ff ff ff ffh | ??? | ??? | D3 Ax0fe5 C8 -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ | 0x0FDDh 4061 | float | EEPROM_BED_CALIBRATION_VEC_X | ??? | ff ff ff ffh | ??? | ??? | D3 Ax0fdd C8 -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ | 0x0FD5h 4053 | float | EEPROM_BED_CALIBRATION_VEC_Y | ??? | ff ff ff ffh | ??? | ??? | D3 Ax0fd5 C8 -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ | 0x0FC5h 4037 | int16 | EEPROM_BED_CALIBRATION_Z_JITTER | ??? | ff ffh 65535 | ??? | ??? | D3 Ax0fc5 C16 -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ | 0x0FC4h 4036 | bool | EEPROM_FARM_MODE | 00h 0 | ffh 255 __P__ | Prusa farm mode: __off__ | G99 | D3 Ax0fc4 C1 | ^ | ^ | ^ | 01h 1 | ^ | Prusa farm mode: __on__ | G98 | ^ | 0x0FC3h 4035 | free | _EEPROM_FREE_NR1_ | ??? | ffh 255 | _Free EEPROM space_ | _free space_ | D3 Ax0fc3 C1 @@ -129,10 +119,6 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP | ^ | ^ | ^ | 01h 1 | ^ | Toshiba Air: __on__ | ^ | ^ | 0x0FBAh 4026 | uchar | EEPROM_PRINT_FLAG | ??? | ??? | _unsued_ | ??? | D3 Ax0fba C1 | 0x0FB0h 4016 | int16 | EEPROM_PROBE_TEMP_SHIFT | ??? | ??? | ??? | ??? | D3 Ax0fb0 C10 -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ | 0x0FAFh 4015 | bool | EEPROM_TEMP_CAL_ACTIVE | 00h 0 | 00h 0 | PINDA Temp cal.: __inactive__ | LCD menu | D3 Ax0faf C1 | ^ | ^ | ^ | ffh 255 | ^ | PINDA Temp cal.: __active__ | ^ | ^ | 0x0FA7h 4007 | uint32 | EEPROM_BOWDEN_LENGTH | ??? | ff 00 00 00h | Bowden length | ??? | D3 Ax0fae C8 @@ -143,16 +129,8 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP | ^ | ^ | ^ | 01h 1 | ^ | Power Panic flag: __active__ | ^ | ^ | ^ | ^ | ^ | 02h 2 | ^ | Power Panic flag: __???__ | ^ | ^ | 0x0F9Dh 3997 | float | EEPROM_UVLO_CURRENT_POSITION | ??? | ffh 255 | Power Panic position | ??? | D3 Ax0f9d C8 -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ | 0x0F95h 3989 | char | EEPROM_FILENAME | ??? | ffh 255 | Power Panic Filename | ??? | D3 Ax0f95 C8 -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| 0x0F91h 39851 | uint32 | EEPROM_FILE_POSITION | ??? | ff ff ff ffh | Power Panic File Position | ??? | D3 Ax0f91 C4 +| 0x0F91h 3985 | uint32 | EEPROM_FILE_POSITION | ??? | ff ff ff ffh | Power Panic File Position | ??? | D3 Ax0f91 C4 | 0x0F8Dh 3981 | float | EEPROM_UVLO_CURRENT_POSITION_Z | ??? | ff ff ff ffh | Power Panic Z Position | ^ | D3 Ax0f8d C4 | 0x0F8Ch 3980 | ??? | EEPROM_UVLO_UNUSED_001 | ??? | ffh 255 | Power Panic _unused_ | ^ | D3 Ax0f8c C1 | 0x0F8Bh 3979 | uint8 | EEPROM_UVLO_TARGET_BED | ??? | ffh 255 | Power Panic Bed temperature | ^ | D3 Ax0f8b C1 @@ -161,14 +139,6 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP | 0x0F87h 3975 | uint8 | EEPROM_FAN_CHECK_ENABLED | 00h 0 | ??? | Fan Check __disabled__ | LCD menu | D3 Ax0f87 C1 | ^ | ^ | ^ | 01h 1 | ffh 255 | Fan Check __enabled__ | ^ | ^ | 0x0F75h 3957 | uint16 | EEPROM_UVLO_MESH_BED_LEVELING | ??? | ff ffh 65535 | Power Panic Mesh Bed Leveling | ??? | D3 Ax0f75 C18 -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ | 0x0F73h 3955 | uint16 | EEPROM_UVLO_Z_MICROSTEPS | ??? | ff ffh 65535 | Power Panic Z microsteps | ??? | D3 Ax0f73 C2 | 0x0F72h 3954 | uint8 | EEPROM_UVLO_E_ABS | ??? | ffh 255 | Power Panic ??? position | ??? | D3 Ax0f72 C1 | 0x0F6Eh 3950 | foat | EEPROM_UVLO_CURRENT_POSITION_E | ??? | ff ff ff ffh | Power Panic E position | ??? | D3 Ax0f6e C4 @@ -203,7 +173,7 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP | 0x0F01h 3841 | uint16 | EEPROM_FERROR_COUNT_TOT | 0000-fffe | ff ffh __S/P__ | Total filament sensor errors | ??? | D3 Ax0f01 C2 | 0x0EFFh 3839 | uint16 | EEPROM_POWER_COUNT_TOT | 0000-fffe | ff ffh __S/P__ | Total power failures | ??? | D3 Ax0eff C2 | 0x0EFEh 3838 | uint8 | EEPROM_TMC2130_HOME_X_ORIGIN | ??? | ffh 255 | ??? | ??? | D3 Ax0efe C1 -| 0x0EFDh 3837 | uint8 | EEPROM MC2130_HOME_X_BSTEPS | ??? | ffh 255 | ??? | ??? | D3 Ax0efd C1 +| 0x0EFDh 3837 | uint8 | EEPROM MC2130_HOME_X_BSTEPS | ??? | ffh 255 | ??? | ??? | D3 Ax0efd C1 | 0x0EFCh 3836 | uint8 | EEPROM_TMC2130_HOME_X_FSTEPS | ??? | ffh 255 | ??? | ??? | D3 Ax0efc C1 | 0x0EFBh 3835 | uint8 | EEPROM_TMC2130_HOME_Y_ORIGIN | ??? | ffh 255 | ??? | ??? | D3 Ax0efb C1 | 0x0EFAh 3834 | uint8 | EEPROM_TMC2130_HOME_Y_BSTEPS | ??? | ffh 255 | ??? | ??? | D3 Ax0efa C1 @@ -257,28 +227,6 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP | ^ | ^ | ^ | 01h 1 | ^ | MMU2/s cutter: __enabled__ | ^ | ^ | ^ | ^ | ^ | 02h 2 | ^ | MMU2/s cutter: __always__ | ^ | ^ | 0x0DAE 3502 | uint16 | EEPROM_UVLO_MESH_BED_LEVELING_FULL | ??? | ff ffh 65535 | Power panic Mesh bed leveling points | ??? | D3 Ax0dae C288 -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ | 0x0DAD 3501 | uint8 | EEPROM_MBL_TYPE | ??? | ffh 255 | Mesh bed leveling precision _unused atm_ | ??? | D3 Ax0dad C1 | 0x0DAC 3500 | bool | EEPROM_MBL_MAGNET_ELIMINATION | 01h 1 | ffh 255 | Mesh bed leveling does: __ignores__ magnets | LCD menu | D3 Ax0dac C1 | ^ | ^ | ^ | 00h 0 | ^ | Mesh bed leveling does: __NOT ignores__ magnets | ^ | ^ From 584177e8fdb311b5a1b4ece7b51fd03a6a8f72c2 Mon Sep 17 00:00:00 2001 From: espr14 Date: Fri, 18 Dec 2020 20:05:18 +0100 Subject: [PATCH 57/73] Fix E mask --- Firmware/sm4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/sm4.c b/Firmware/sm4.c index 34cf8a3c9..dab47042f 100644 --- a/Firmware/sm4.c +++ b/Firmware/sm4.c @@ -173,7 +173,7 @@ uint16_t sm4_line_xyze_ui(uint16_t dx, uint16_t dy, uint16_t dz, uint16_t de) } if (ce <= de) { - sm |= 4; + sm |= 8; ce += dd; e++; } From 007e59d23c1adaaea42ee2fb6c183c148cbc263b Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Fri, 8 Jan 2021 11:37:47 +0100 Subject: [PATCH 58/73] Comment out 'sudo' auto installation Add '-?' '-h' help output --- PF-build.sh | 51 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/PF-build.sh b/PF-build.sh index 5a174c9ca..afd7fda1f 100755 --- a/PF-build.sh +++ b/PF-build.sh @@ -56,7 +56,7 @@ # Some may argue that this is only used by a script, BUT as soon someone accidentally or on purpose starts Arduino IDE # it will use the default Arduino IDE folders and so can corrupt the build environment. # -# Version: 1.0.6-Build_32 +# Version: 1.0.6-Build_33 # Change log: # 12 Jan 2019, 3d-gussner, Fixed "compiler.c.elf.flags=-w -Os -Wl,-u,vfprintf -lprintf_flt -lm -Wl,--gc-sections" in 'platform.txt' # 16 Jan 2019, 3d-gussner, Build_2, Added development check to modify 'Configuration.h' to prevent unwanted LCD messages that Firmware is unknown @@ -133,6 +133,8 @@ # 02 Nov 2020, 3d-gussner, Check for "gawk" on Linux # Add argument to change build number automatically to current commit or define own number # Update exit numbers 1-13 for prepare build env 21-29 for prepare compiling 30-36 compiling +# 08 Jan 2021, 3d-gussner, Comment out 'sudo' auto installation +# Add '-?' '-h' help option #### Start check if OSTYPE is supported OS_FOUND=$( command -v uname) @@ -208,7 +210,7 @@ if ! type zip > /dev/null; then elif [ $TARGET_OS == "linux" ]; then echo "$(tput setaf 1)Missing 'zip' which is important to run this script" echo "install it with the command $(tput setaf 2)'sudo apt-get install zip'$(tput sgr0)" - sudo apt-get update && apt-get install zip + #sudo apt-get update && apt-get install zip exit 3 fi fi @@ -223,7 +225,7 @@ if ! type python > /dev/null; then echo "install it with the command $(tput setaf 2)'sudo apt-get install python3'." echo "Check which version of Python3 has been installed using 'ls /usr/bin/python3*'" echo "Use 'sudo ln -sf /usr/bin/python3.x /usr/bin/python' (where 'x' is your version number) to make it default.$(tput sgr0)" - sudo apt-get update && apt-get install python3 && ln -sf /usr/bin/python3 /usr/bin/python + #sudo apt-get update && apt-get install python3 && ln -sf /usr/bin/python3 /usr/bin/python exit 4 fi fi @@ -233,7 +235,7 @@ if ! type gawk > /dev/null; then if [ $TARGET_OS == "linux" ]; then echo "$(tput setaf 1)Missing 'gawk' which is important to run this script" echo "install it with the command $(tput setaf 2)'sudo apt-get install gawk'." - sudo apt-get update && apt-get install gawk + #sudo apt-get update && apt-get install gawk exit 4 fi fi @@ -449,13 +451,7 @@ if type git > /dev/null; then git_availible="1" fi -#arguments -#'-v' Variant "All" or variant file name -#'-l' Languages "ALL" for multi language or "EN_ONLY" for english only -#'-d' Devel build "GOLD", "RC", "BETA", "ALPHA", "DEBUG", "DEVEL" and "UNKNOWN" -#'-b' Build/commit number "Auto" needs git or a number -#'-o' Output "1" force or "0" block output and delays -while getopts v:l:d:b:o: flag +while getopts v:l:d:b:o:?h flag do case "${flag}" in v) variant_flag=${OPTARG};; @@ -463,6 +459,8 @@ while getopts v:l:d:b:o: flag d) devel_flag=${OPTARG};; b) build_flag=${OPTARG};; o) output_flag=${OPTARG};; + ?) help_flag=1;; + h) help_flag=1;; esac done #echo "variant_flag: $variant_flag"; @@ -470,6 +468,37 @@ while getopts v:l:d:b:o: flag #echo "devel_flag: $devel_flag"; #echo "build_flag: $build_flag"; #echo "output_flag: $output_flag"; +#echo "help_flag: $help_flag" + +# +# '?' 'h' argument usage and help +if [ "$help_flag" == "1" ] ; then +echo "***************************************" +echo "* PF-build.sh Version: 1.0.6-Build_33 *" +echo "***************************************" +echo "Arguments:" +echo "$(tput setaf 2)-v$(tput sgr0) Variant '$(tput setaf 2)All$(tput sgr0)' or variant file name" +echo "$(tput setaf 2)-l$(tput sgr0) Languages '$(tput setaf 2)ALL$(tput sgr0)' for multi language or '$(tput setaf 2)EN_ONLY$(tput sgr0)' for english only" +echo "$(tput setaf 2)-d$(tput sgr0) Devel build '$(tput setaf 2)GOLD$(tput sgr0)', '$(tput setaf 2)RC$(tput sgr0)', '$(tput setaf 2)BETA$(tput sgr0)', '$(tput setaf 2)ALPHA$(tput sgr0)', '$(tput setaf 2)DEBUG$(tput sgr0)', '$(tput setaf 2)DEVEL$(tput sgr0)' and '$(tput setaf 2)UNKNOWN$(tput sgr0)'" +echo "$(tput setaf 2)-b$(tput sgr0) Build/commit number '$(tput setaf 2)Auto$(tput sgr0)' needs git or a number" +echo "$(tput setaf 2)-o$(tput sgr0) Output '$(tput setaf 2)1$(tput sgr0)' force or '$(tput setaf 2)0$(tput sgr0)' block output and delays" +echo "$(tput setaf 2)-?$(tput sgr0) Help" +echo "$(tput setaf 2)-h$(tput sgr0) Help" +echo +echo "Brief USAGE:" +echo " $(tput setaf 2)./PF-build.sh$(tput sgr0) [-v] [-l] [-d] [-b] [-o]" +echo +echo "Example:" +echo " $(tput setaf 2)./PF-build.sh -v All -l ALL -d GOLD$(tput sgr0)" +echo " Will build all variants as multi language and final GOLD version" +echo +echo " $(tput setaf 2) ./PF-build.sh -v 1_75mm_MK3S-EINSy10a-E3Dv6full.h -b Auto -l ALL -d GOLD -o 1$(tput sgr0)" +echo " Will build MK3S multi language final GOLD firmware " +echo " with current commit count number and output extra information" +echo +exit + +fi # # '-v' argument defines which variant of the Prusa Firmware will be compiled From 67ff9b6b48535e2bb6c4491957f0f9bd497a47e2 Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Fri, 8 Jan 2021 11:01:17 +0100 Subject: [PATCH 59/73] Fix typos --- PF-build.sh | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/PF-build.sh b/PF-build.sh index afd7fda1f..b75395782 100755 --- a/PF-build.sh +++ b/PF-build.sh @@ -15,7 +15,7 @@ # 3. Install zip with 'apt-get install zip' # 4. Install python3 with 'apt-get install python3' # 5. Add command 'ln -sf /usr/bin/python3.5 /usr/bin/python' to link python3 to python. -# Donnot istall 'python' as python 2.x has end of life see https://pythonclock.org/ +# Do not install 'python' as python 2.x has end of life see https://pythonclock.org/ # 6. Add at top of ~/.bashrc following lines by using 'sudo nano ~/.bashrc' # # export OS="Linux" @@ -37,7 +37,7 @@ # 2. Another great tool to compare your custom mod and stock firmware is WinMerge http://winmerge.org/downloads/?lang=en # # Example for MK3: open git bash and change to your Firmware directory -# @ MINGW64 //path +# @ MINGW64 //path # bash build.sh 1_75mm_MK3-EINSy10a-E3Dv6full # # Example for MK25: open git bash and change to your directory @@ -63,8 +63,8 @@ # 17 Jan 2019, 3d-gussner, Build_3, Check for OS Windows or Linux and use the right build environment # 10 Feb 2019, ropaha, Pull Request, Select variant from list while using build.sh # 10 Feb 2019, ropaha, change FW_DEV_VERSION automatically depending on FW_VERSION RC/BETA/ALPHA -# 10 Feb 2019, 3d-gussner, 1st tests with english only -# 10 Feb 2019, ropaha, added compiling of all variants and english only +# 10 Feb 2019, 3d-gussner, 1st tests with English only +# 10 Feb 2019, ropaha, added compiling of all variants and English only # 10 Feb 2019, 3d-gussner, Set OUTPUT_FOLDER for hex files # 11 Feb 2019, 3d-gussner/ropaha, Minor changes and fixes # 11 Feb 2019, 3d-gussner, Ready for RC @@ -80,52 +80,52 @@ # Configuration_prusa.h # language build files # multi language firmware files exist and clean them up -# 15 Feb 2019, 3d-gussner, Fixed selction GOLD/UNKNOWN DEV_STATUS for ALL variants builds, so you have to choose only once +# 15 Feb 2019, 3d-gussner, Fixed selection GOLD/UNKNOWN DEV_STATUS for ALL variants builds, so you have to choose only once # 15 Feb 2019, 3d-gussner, Added some colored output # 15 Feb 2019, 3d-gussner, troubleshooting and minor fixes # 16 Feb 2019, 3d-gussner, Script can be run using arguments # $1 = variant, example "1_75mm_MK3-EINSy10a-E3Dv6full.h" at this moment it is not possible to use ALL -# $2 = multi language OR english only [ALL/EN_ONLY] +# $2 = multi language OR English only [ALL/EN_ONLY] # $3 = development status [GOLD/RC/BETA/ALPHA/DEVEL/DEBUG] # If one argument is wrong a list of valid one will be shown -# 13 Mar 2019, 3d-gussner, MKbel updated the linux build environment to version 1.0.2 with an Fix maximum firmware flash size. +# 13 Mar 2019, 3d-gussner, MKbel updated the Linux build environment to version 1.0.2 with an Fix maximum firmware flash size. # So did I # 11 Jul 2019, deliopoulos,Updated to v1.0.6 as Prusa needs a new board definition for Firmware 3.8.x86_64 -# - Splitted the Download of Windows Arduino IDE 1.8.5 and Prusa specific part +# - Split the Download of Windows Arduino IDE 1.8.5 and Prusa specific part # --> less download volume needed and saves some time # -# 13 Jul 2019, deliopoulos,Splitting of Ardunio IDE and Prusa parts also for Linux64 +# 13 Jul 2019, deliopoulos,Splitting of Arduino IDE and Prusa parts also for Linux64 # 13 Jul 2019, 3d-gussner, Added Linux 32-bit version (untested yet) # MacOS could be added in future if needs # 14 Jul 2019, 3d-gussner, Update preferences and make it really portable -# 15 Jul 2019, 3d-gussner, New PF-build-env gihub branch -# 16 Jul 2019, 3d-gussner, New Arduino_boards github fork +# 15 Jul 2019, 3d-gussner, New PF-build-env GitHub branch +# 16 Jul 2019, 3d-gussner, New Arduino_boards GitHub fork # 17 Jul 2019, 3d-gussner, Final tests under Windows 10 and Linux Subsystem for Windows # 18 Jul 2019, 3d-gussner, Added python check # 18 Jul 2019, deliopoulos, No need more for changing 'platform.txt' file as it comes with the Arduino Boards. # 18 Jul 2019, deliopoulos, Modified 'PF_BUILD_FILE_URL' to use 'BUILD_ENV' variable -# 22 Jul 2019, 3d-gussner, Modiffied checks to check folder and/or installation output exists. +# 22 Jul 2019, 3d-gussner, Modified checks to check folder and/or installation output exists. # 22 Jul 2019, 3d-gussner, Added check if Arduino IDE 1.8.5 boards have been updated # 22 Jul 2019, 3d-gussner, Changed exit numbers 1-13 for prepare build env 21-28 for prepare compiling 31-36 compiling -# 22 Jul 2019, 3d-gussner, Changed BOARD_URL to DRracers respository after he pulled my PR https://github.com/DRracer/Arduino_Boards/pull/1 +# 22 Jul 2019, 3d-gussner, Changed BOARD_URL to DRracers repository after he pulled my PR https://github.com/DRracer/Arduino_Boards/pull/1 # 23 Jul 2019, 3d-gussner, Changed Build-env path to "PF-build-dl" as requested in PR https://github.com/prusa3d/Prusa-Firmware/pull/2028 # Changed Hex-files folder to PF-build-hex as requested in PR # 23 Jul 2019, 3d-gussner, Added Finding OS version routine so supporting new OS should get easier # 26 Jul 2019, 3d-gussner, Change JSON repository to prusa3d after PR https://github.com/prusa3d/Arduino_Boards/pull/1 was merged -# 23 Sep 2019, 3d-gussner, Prepare PF-build.sh for comming Prusa3d/Arduino_Boards version 1.0.2 Pull Request -# 17 Oct 2019, 3d-gussner, Changed folder and check file names to have seperated build enviroments depening on Arduino IDE version and +# 23 Sep 2019, 3d-gussner, Prepare PF-build.sh for coming Prusa3d/Arduino_Boards version 1.0.2 Pull Request +# 17 Oct 2019, 3d-gussner, Changed folder and check file names to have separated build environments depending on Arduino IDE version and # board-versions. # 15 Dec 2019, 3d-gussner, Prepare for switch to Prusa3d/PF-build-env repository -# 15 Dec 2019, 3d-gussner, Fix Audrino user preferences for the chosen board. +# 15 Dec 2019, 3d-gussner, Fix Arduino user preferences for the chosen board. # 17 Dec 2019, 3d-gussner, Fix "timer0_fract = 0" warning by using Arduino_boards v1.0.3 # 28 Apr 2020, 3d-gussner, Added RC3 detection # 03 May 2020, deliopoulos, Accept all RCx as RC versions # 05 May 2020, 3d-gussner, Make a copy of `not_tran.txt`and `not_used.txt` as `not_tran_$VARIANT.txt`and `not_used_$VARIANT.txt` -# After compiling All multilanguage vairants it makes it easier to find missing or unused transltions. +# After compiling All multi-language variants it makes it easier to find missing or unused translations. # 12 May 2020, DRracer , Cleanup double MK2/s MK25/s `not_tran` and `not_used` files # 13 May 2020, leptun , If cleanup files do not exist don't try to. # 01 Oct 2020, 3d-gussner, Bug fix if using argument EN_ONLY. Thank to @leptun for pointing out. -# Change Build number to scrpit commits 'git rev-list --count HEAD PF-build.sh' +# Change Build number to script commits 'git rev-list --count HEAD PF-build.sh' # 02 Oct 2020, 3d-gussner, Add UNKNOWN as argument option # 05 Oct 2020, 3d-gussner, Disable pause and warnings using command line with all needed arguments # Install needed apps under linux if needed. @@ -265,7 +265,7 @@ echo "Script path :" $SCRIPT_PATH echo "OS :" $OS echo "OS type :" $TARGET_OS echo "" -echo "Ardunio IDE :" $ARDUINO_ENV +echo "Arduino IDE :" $ARDUINO_ENV echo "Build env :" $BUILD_ENV echo "Board :" $BOARD echo "Package name:" $BOARD_PACKAGE_NAME @@ -446,9 +446,9 @@ fi #### Start cd $SCRIPT_PATH -# Check if git is availible +# Check if git is available if type git > /dev/null; then - git_availible="1" + git_available="1" fi while getopts v:l:d:b:o:?h flag @@ -478,7 +478,7 @@ echo "* PF-build.sh Version: 1.0.6-Build_33 *" echo "***************************************" echo "Arguments:" echo "$(tput setaf 2)-v$(tput sgr0) Variant '$(tput setaf 2)All$(tput sgr0)' or variant file name" -echo "$(tput setaf 2)-l$(tput sgr0) Languages '$(tput setaf 2)ALL$(tput sgr0)' for multi language or '$(tput setaf 2)EN_ONLY$(tput sgr0)' for english only" +echo "$(tput setaf 2)-l$(tput sgr0) Languages '$(tput setaf 2)ALL$(tput sgr0)' for multi language or '$(tput setaf 2)EN_ONLY$(tput sgr0)' for English only" echo "$(tput setaf 2)-d$(tput sgr0) Devel build '$(tput setaf 2)GOLD$(tput sgr0)', '$(tput setaf 2)RC$(tput sgr0)', '$(tput setaf 2)BETA$(tput sgr0)', '$(tput setaf 2)ALPHA$(tput sgr0)', '$(tput setaf 2)DEBUG$(tput sgr0)', '$(tput setaf 2)DEVEL$(tput sgr0)' and '$(tput setaf 2)UNKNOWN$(tput sgr0)'" echo "$(tput setaf 2)-b$(tput sgr0) Build/commit number '$(tput setaf 2)Auto$(tput sgr0)' needs git or a number" echo "$(tput setaf 2)-o$(tput sgr0) Output '$(tput setaf 2)1$(tput sgr0)' force or '$(tput setaf 2)0$(tput sgr0)' block output and delays" @@ -547,7 +547,7 @@ else fi fi -#'-l' argument defines if it is an english only version. Known values EN_ONLY / ALL +#'-l' argument defines if it is an English only version. Known values EN_ONLY / ALL #Check default language mode MULTI_LANGUAGE_CHECK=$(grep --max-count=1 "^#define LANG_MODE *" $SCRIPT_PATH/Firmware/config.h|sed -e's/ */ /g'|cut -d ' ' -f3) @@ -592,7 +592,7 @@ fi #Check if Build is selected via argument '-b' if [ ! -z "$build_flag" ] ; then - if [[ "$build_flag" == "Auto" && "$git_availible" == "1" ]] ; then + if [[ "$build_flag" == "Auto" && "$git_available" == "1" ]] ; then echo "Build changed to $build_flag" BUILD=$(git rev-list --count HEAD) elif [[ $build_flag =~ ^[0-9]+$ ]] ; then @@ -615,7 +615,7 @@ fi #echo "Output is:" $OUTPUT #Check git branch has changed -if [ ! -z "git_availible" ]; then +if [ ! -z "git_available" ]; then BRANCH="" CLEAN_PF_FW_BUILD=0 else @@ -772,7 +772,7 @@ do # set FW_REPOSITORY sed -i -- 's/#define FW_REPOSITORY "Unknown"/#define FW_REPOSITORY "Prusa3d"/g' $SCRIPT_PATH/Firmware/Configuration.h - #Prepare english only or multilanguage version to be build + #Prepare English only or multi-language version to be build if [ $LANGUAGES == "EN_ONLY" ]; then echo " " echo "English only language firmware will be built" From 2e40a2746098fc7a989444bf37be9572a943b8fd Mon Sep 17 00:00:00 2001 From: espr14 Date: Mon, 11 Jan 2021 15:40:12 +0100 Subject: [PATCH 60/73] Alignment, comments --- Firmware/mesh_bed_calibration.cpp | 190 +++++++++++++++--------------- 1 file changed, 97 insertions(+), 93 deletions(-) diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index 897e3a9e6..8c2a49761 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -2226,104 +2226,104 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level } #endif // SUPPORT_VERBOSITY #ifdef MESH_BED_CALIBRATION_SHOW_LCD - uint8_t next_line; - lcd_display_message_fullscreen_P(_T(MSG_FIND_BED_OFFSET_AND_SKEW_LINE1), next_line); - if (next_line > 3) - next_line = 3; + uint8_t next_line; + lcd_display_message_fullscreen_P(_T(MSG_FIND_BED_OFFSET_AND_SKEW_LINE1), next_line); + if (next_line > 3) + next_line = 3; #endif /* MESH_BED_CALIBRATION_SHOW_LCD */ - // Collect the rear 2x3 points. - current_position[Z_AXIS] = MESH_HOME_Z_SEARCH + FIND_BED_INDUCTION_SENSOR_POINT_Z_STEP * iteration * 0.3; - for (int k = 0; k < 4; ++k) { - // Don't let the manage_inactivity() function remove power from the motors. - refresh_cmd_timeout(); + // Collect the rear 2x3 points. + current_position[Z_AXIS] = MESH_HOME_Z_SEARCH + FIND_BED_INDUCTION_SENSOR_POINT_Z_STEP * iteration * 0.3; + for (int k = 0; k < 4; ++k) { + // Don't let the manage_inactivity() function remove power from the motors. + refresh_cmd_timeout(); #ifdef MESH_BED_CALIBRATION_SHOW_LCD - lcd_set_cursor(0, next_line); - lcd_print(k + 1); - lcd_puts_P(_T(MSG_FIND_BED_OFFSET_AND_SKEW_LINE2)); + lcd_set_cursor(0, next_line); + lcd_print(k + 1); + lcd_puts_P(_T(MSG_FIND_BED_OFFSET_AND_SKEW_LINE2)); - if (iteration > 0) { - lcd_puts_at_P(0, next_line + 1, _i("Iteration "));////MSG_FIND_BED_OFFSET_AND_SKEW_ITERATION c=20 - lcd_print(int(iteration + 1)); - } + if (iteration > 0) { + lcd_puts_at_P(0, next_line + 1, _i("Iteration "));////MSG_FIND_BED_OFFSET_AND_SKEW_ITERATION c=20 + lcd_print(int(iteration + 1)); + } #endif /* MESH_BED_CALIBRATION_SHOW_LCD */ - float *pt = pts + k * 2; - // Go up to z_initial. + float *pt = pts + k * 2; + // Go up to z_initial. - go_to_current(homing_feedrate[Z_AXIS] / 60.f); - #ifdef SUPPORT_VERBOSITY - if (verbosity_level >= 20) { - // Go to Y0, wait, then go to Y-4. - current_position[Y_AXIS] = 0.f; - go_to_current(homing_feedrate[X_AXIS] / 60.f); - SERIAL_ECHOLNPGM("At Y0"); - delay_keep_alive(5000); - current_position[Y_AXIS] = Y_MIN_POS; - go_to_current(homing_feedrate[X_AXIS] / 60.f); - SERIAL_ECHOLNPGM("At Y-4"); - delay_keep_alive(5000); - } - #endif // SUPPORT_VERBOSITY - // Go to the measurement point position. - //if (iteration == 0) { - current_position[X_AXIS] = pgm_read_float(bed_ref_points_4 + k * 2); - current_position[Y_AXIS] = pgm_read_float(bed_ref_points_4 + k * 2 + 1); - /*} - else { - // if first iteration failed, count corrected point coordinates as initial - // Use the corrected coordinate, which is a result of find_bed_offset_and_skew(). - - current_position[X_AXIS] = vec_x[0] * pgm_read_float(bed_ref_points_4 + k * 2) + vec_y[0] * pgm_read_float(bed_ref_points_4 + k * 2 + 1) + cntr[0]; - current_position[Y_AXIS] = vec_x[1] * pgm_read_float(bed_ref_points_4 + k * 2) + vec_y[1] * pgm_read_float(bed_ref_points_4 + k * 2 + 1) + cntr[1]; + go_to_current(homing_feedrate[Z_AXIS] / 60.f); + #ifdef SUPPORT_VERBOSITY + if (verbosity_level >= 20) { + // Go to Y0, wait, then go to Y-4. + current_position[Y_AXIS] = 0.f; + go_to_current(homing_feedrate[X_AXIS] / 60.f); + SERIAL_ECHOLNPGM("At Y0"); + delay_keep_alive(5000); + current_position[Y_AXIS] = Y_MIN_POS; + go_to_current(homing_feedrate[X_AXIS] / 60.f); + SERIAL_ECHOLNPGM("At Y-4"); + delay_keep_alive(5000); + } + #endif // SUPPORT_VERBOSITY + // Go to the measurement point position. + //if (iteration == 0) { + current_position[X_AXIS] = pgm_read_float(bed_ref_points_4 + k * 2); + current_position[Y_AXIS] = pgm_read_float(bed_ref_points_4 + k * 2 + 1); + /*} + else { + // if first iteration failed, count corrected point coordinates as initial + // Use the corrected coordinate, which is a result of find_bed_offset_and_skew(). + + current_position[X_AXIS] = vec_x[0] * pgm_read_float(bed_ref_points_4 + k * 2) + vec_y[0] * pgm_read_float(bed_ref_points_4 + k * 2 + 1) + cntr[0]; + current_position[Y_AXIS] = vec_x[1] * pgm_read_float(bed_ref_points_4 + k * 2) + vec_y[1] * pgm_read_float(bed_ref_points_4 + k * 2 + 1) + cntr[1]; - // The calibration points are very close to the min Y. - if (current_position[Y_AXIS] < Y_MIN_POS_FOR_BED_CALIBRATION) - current_position[Y_AXIS] = Y_MIN_POS_FOR_BED_CALIBRATION; + // The calibration points are very close to the min Y. + if (current_position[Y_AXIS] < Y_MIN_POS_FOR_BED_CALIBRATION) + current_position[Y_AXIS] = Y_MIN_POS_FOR_BED_CALIBRATION; - }*/ - #ifdef SUPPORT_VERBOSITY - if (verbosity_level >= 20) { - SERIAL_ECHOPGM("current_position[X_AXIS]:"); - MYSERIAL.print(current_position[X_AXIS], 5); - SERIAL_ECHOLNPGM(""); - SERIAL_ECHOPGM("current_position[Y_AXIS]:"); - MYSERIAL.print(current_position[Y_AXIS], 5); - SERIAL_ECHOLNPGM(""); - SERIAL_ECHOPGM("current_position[Z_AXIS]:"); - MYSERIAL.print(current_position[Z_AXIS], 5); - SERIAL_ECHOLNPGM(""); - } - #endif // SUPPORT_VERBOSITY + }*/ + #ifdef SUPPORT_VERBOSITY + if (verbosity_level >= 20) { + SERIAL_ECHOPGM("current_position[X_AXIS]:"); + MYSERIAL.print(current_position[X_AXIS], 5); + SERIAL_ECHOLNPGM(""); + SERIAL_ECHOPGM("current_position[Y_AXIS]:"); + MYSERIAL.print(current_position[Y_AXIS], 5); + SERIAL_ECHOLNPGM(""); + SERIAL_ECHOPGM("current_position[Z_AXIS]:"); + MYSERIAL.print(current_position[Z_AXIS], 5); + SERIAL_ECHOLNPGM(""); + } + #endif // SUPPORT_VERBOSITY - go_to_current(homing_feedrate[X_AXIS] / 60.f); - #ifdef SUPPORT_VERBOSITY - if (verbosity_level >= 10) - delay_keep_alive(3000); - #endif // SUPPORT_VERBOSITY - if (!find_bed_induction_sensor_point_xy(verbosity_level)) - return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND; + go_to_current(homing_feedrate[X_AXIS] / 60.f); + #ifdef SUPPORT_VERBOSITY + if (verbosity_level >= 10) + delay_keep_alive(3000); + #endif // SUPPORT_VERBOSITY + if (!find_bed_induction_sensor_point_xy(verbosity_level)) + return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND #ifndef NEW_XYZCAL #ifndef HEATBED_V2 - if (k == 0 || k == 1) { - // Improve the position of the 1st row sensor points by a zig-zag movement. - find_bed_induction_sensor_point_z(); - int8_t i = 4; - for (;;) { - if (improve_bed_induction_sensor_point3(verbosity_level)) - break; - if (--i == 0) - return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND; - // Try to move the Z axis down a bit to increase a chance of the sensor to trigger. - current_position[Z_AXIS] -= 0.025f; - enable_endstops(false); - enable_z_endstop(false); - go_to_current(homing_feedrate[Z_AXIS]); - } - if (i == 0) - // not found - return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND; - } + if (k == 0 || k == 1) { + // Improve the position of the 1st row sensor points by a zig-zag movement. + find_bed_induction_sensor_point_z(); + int8_t i = 4; + for (;;) { + if (improve_bed_induction_sensor_point3(verbosity_level)) + break; + if (--i == 0) + return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND; + // Try to move the Z axis down a bit to increase a chance of the sensor to trigger. + current_position[Z_AXIS] -= 0.025f; + enable_endstops(false); + enable_z_endstop(false); + go_to_current(homing_feedrate[Z_AXIS]); + } + if (i == 0) + // not found + return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND; + } #endif //HEATBED_V2 #endif #ifdef SUPPORT_VERBOSITY @@ -2375,8 +2375,9 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level delay_keep_alive(3000); } #endif // SUPPORT_VERBOSITY - } - delay_keep_alive(0); //manage_heater, reset watchdog, manage inactivity + } + DBG(_n("All 4 calibration points found.\n")); + delay_keep_alive(0); //manage_heater, reset watchdog, manage inactivity #ifdef SUPPORT_VERBOSITY if (verbosity_level >= 20) { @@ -2386,7 +2387,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level // Don't let the manage_inactivity() function remove power from the motors. refresh_cmd_timeout(); // Go to the measurement point. - // Use the coorrected coordinate, which is a result of find_bed_offset_and_skew(). + // Use the corrected coordinate, which is a result of find_bed_offset_and_skew(). current_position[X_AXIS] = pts[mesh_point * 2]; current_position[Y_AXIS] = pts[mesh_point * 2 + 1]; go_to_current(homing_feedrate[X_AXIS] / 60); @@ -2450,7 +2451,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level // Don't let the manage_inactivity() function remove power from the motors. refresh_cmd_timeout(); // Go to the measurement point. - // Use the coorrected coordinate, which is a result of find_bed_offset_and_skew(). + // Use the corrected coordinate, which is a result of find_bed_offset_and_skew(). uint8_t ix = mesh_point % MESH_MEAS_NUM_X_POINTS; // from 0 to MESH_NUM_X_POINTS - 1 uint8_t iy = mesh_point / MESH_MEAS_NUM_X_POINTS; if (iy & 1) ix = (MESH_MEAS_NUM_X_POINTS - 1) - ix; @@ -2462,9 +2463,12 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level } #endif // SUPPORT_VERBOSITY return result; - } - if (result == BED_SKEW_OFFSET_DETECTION_FITTING_FAILED && too_far_mask == 2) return result; //if fitting failed and front center point is out of reach, terminate calibration and inform user - iteration++; + } + if (result == BED_SKEW_OFFSET_DETECTION_FITTING_FAILED && too_far_mask == 2){ + DBG(_n("Calibration failed.\n")); + return result; //if fitting failed and front center point is out of reach, terminate calibration and inform user + } + iteration++; } return result; } From 904a23b69ebc3f6a53cfe8c8569892f9b7b43d00 Mon Sep 17 00:00:00 2001 From: espr14 Date: Mon, 11 Jan 2021 17:02:41 +0100 Subject: [PATCH 61/73] Report calibration results --- Firmware/mesh_bed_calibration.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index 8c2a49761..6ef990b16 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -369,7 +369,9 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS( BedSkewOffsetDetectionResultType result = BED_SKEW_OFFSET_DETECTION_PERFECT; { angleDiff = fabs(a2 - a1); - eeprom_update_float((float*)(EEPROM_XYZ_CAL_SKEW), angleDiff); //storing xyz cal. skew to be able to show in support menu later + DBG(_n("Measured XY skew: %f\n"), a2 - a1); + DBG(_n("Measured Y-bed skew: %f\n"), a2); + eeprom_update_float((float*)(EEPROM_XYZ_CAL_SKEW), angleDiff); //storing xyz cal. skew to be able to show in support menu later if (angleDiff > bed_skew_angle_mild) result = (angleDiff > bed_skew_angle_extreme) ? BED_SKEW_OFFSET_DETECTION_SKEW_EXTREME : @@ -2407,6 +2409,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level delay_keep_alive(0); //manage_heater, reset watchdog, manage inactivity if (result >= 0) { + DBG(_n("Calibration success.\n")); world2machine_update(vec_x, vec_y, cntr); #if 1 // Fearlessly store the calibration values into the eeprom. @@ -2465,7 +2468,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level return result; } if (result == BED_SKEW_OFFSET_DETECTION_FITTING_FAILED && too_far_mask == 2){ - DBG(_n("Calibration failed.\n")); + DBG(_n("Fitting failed => calibration failed.\n")); return result; //if fitting failed and front center point is out of reach, terminate calibration and inform user } iteration++; From 211e5f5f37df763e7bf744012a569c3c4636a61c Mon Sep 17 00:00:00 2001 From: espr14 Date: Mon, 11 Jan 2021 17:31:26 +0100 Subject: [PATCH 62/73] Define DBG output --- Firmware/mesh_bed_calibration.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index 6ef990b16..f19c8c9c4 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -12,6 +12,8 @@ #include "tmc2130.h" #endif //TMC2130 +#define DBG(args...) printf_P(args) + uint8_t world2machine_correction_mode; float world2machine_rotation_and_skew[2][2]; float world2machine_rotation_and_skew_inv[2][2]; From 78f8f1e8f9e2f7abee18a4a7b7d78867880ab1e9 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Mon, 11 Jan 2021 18:31:20 +0100 Subject: [PATCH 63/73] Remove stray serial newlines in fsensor autoload messages --- Firmware/fsensor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/fsensor.cpp b/Firmware/fsensor.cpp index c81a5ac6f..b6ea77883 100755 --- a/Firmware/fsensor.cpp +++ b/Firmware/fsensor.cpp @@ -316,7 +316,7 @@ void fsensor_autoload_check_start(void) printf_P(ERRMSG_PAT9125_NOT_RESP, 3); return; } - puts_P(_N("fsensor_autoload_check_start - autoload ENABLED\n")); + puts_P(_N("fsensor_autoload_check_start - autoload ENABLED")); fsensor_autoload_y = pat9125_y; //save current y value fsensor_autoload_c = 0; //reset number of changes counter fsensor_autoload_sum = 0; @@ -334,7 +334,7 @@ void fsensor_autoload_check_stop(void) 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")); + puts_P(_N("fsensor_autoload_check_stop - autoload DISABLED")); fsensor_autoload_sum = 0; fsensor_watch_autoload = false; fsensor_watch_runout = true; From 09892bec52fd843e2a8bf40f89232fcafe0fbf1d Mon Sep 17 00:00:00 2001 From: espr14 Date: Mon, 11 Jan 2021 18:46:56 +0100 Subject: [PATCH 64/73] Reverse --- Firmware/mesh_bed_calibration.cpp | 181 +++++++++++++++--------------- 1 file changed, 90 insertions(+), 91 deletions(-) diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index f19c8c9c4..dc13eaac4 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -2230,104 +2230,104 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level } #endif // SUPPORT_VERBOSITY #ifdef MESH_BED_CALIBRATION_SHOW_LCD - uint8_t next_line; - lcd_display_message_fullscreen_P(_T(MSG_FIND_BED_OFFSET_AND_SKEW_LINE1), next_line); - if (next_line > 3) - next_line = 3; + uint8_t next_line; + lcd_display_message_fullscreen_P(_T(MSG_FIND_BED_OFFSET_AND_SKEW_LINE1), next_line); + if (next_line > 3) + next_line = 3; #endif /* MESH_BED_CALIBRATION_SHOW_LCD */ - // Collect the rear 2x3 points. - current_position[Z_AXIS] = MESH_HOME_Z_SEARCH + FIND_BED_INDUCTION_SENSOR_POINT_Z_STEP * iteration * 0.3; - for (int k = 0; k < 4; ++k) { - // Don't let the manage_inactivity() function remove power from the motors. - refresh_cmd_timeout(); + // Collect the rear 2x3 points. + current_position[Z_AXIS] = MESH_HOME_Z_SEARCH + FIND_BED_INDUCTION_SENSOR_POINT_Z_STEP * iteration * 0.3; + for (int k = 0; k < 4; ++k) { + // Don't let the manage_inactivity() function remove power from the motors. + refresh_cmd_timeout(); #ifdef MESH_BED_CALIBRATION_SHOW_LCD - lcd_set_cursor(0, next_line); - lcd_print(k + 1); - lcd_puts_P(_T(MSG_FIND_BED_OFFSET_AND_SKEW_LINE2)); + lcd_set_cursor(0, next_line); + lcd_print(k + 1); + lcd_puts_P(_T(MSG_FIND_BED_OFFSET_AND_SKEW_LINE2)); - if (iteration > 0) { - lcd_puts_at_P(0, next_line + 1, _i("Iteration "));////MSG_FIND_BED_OFFSET_AND_SKEW_ITERATION c=20 - lcd_print(int(iteration + 1)); - } + if (iteration > 0) { + lcd_puts_at_P(0, next_line + 1, _i("Iteration "));////MSG_FIND_BED_OFFSET_AND_SKEW_ITERATION c=20 + lcd_print(int(iteration + 1)); + } #endif /* MESH_BED_CALIBRATION_SHOW_LCD */ - float *pt = pts + k * 2; - // Go up to z_initial. + float *pt = pts + k * 2; + // Go up to z_initial. - go_to_current(homing_feedrate[Z_AXIS] / 60.f); - #ifdef SUPPORT_VERBOSITY - if (verbosity_level >= 20) { - // Go to Y0, wait, then go to Y-4. - current_position[Y_AXIS] = 0.f; - go_to_current(homing_feedrate[X_AXIS] / 60.f); - SERIAL_ECHOLNPGM("At Y0"); - delay_keep_alive(5000); - current_position[Y_AXIS] = Y_MIN_POS; - go_to_current(homing_feedrate[X_AXIS] / 60.f); - SERIAL_ECHOLNPGM("At Y-4"); - delay_keep_alive(5000); - } - #endif // SUPPORT_VERBOSITY - // Go to the measurement point position. - //if (iteration == 0) { - current_position[X_AXIS] = pgm_read_float(bed_ref_points_4 + k * 2); - current_position[Y_AXIS] = pgm_read_float(bed_ref_points_4 + k * 2 + 1); - /*} - else { - // if first iteration failed, count corrected point coordinates as initial - // Use the corrected coordinate, which is a result of find_bed_offset_and_skew(). - - current_position[X_AXIS] = vec_x[0] * pgm_read_float(bed_ref_points_4 + k * 2) + vec_y[0] * pgm_read_float(bed_ref_points_4 + k * 2 + 1) + cntr[0]; - current_position[Y_AXIS] = vec_x[1] * pgm_read_float(bed_ref_points_4 + k * 2) + vec_y[1] * pgm_read_float(bed_ref_points_4 + k * 2 + 1) + cntr[1]; + go_to_current(homing_feedrate[Z_AXIS] / 60.f); + #ifdef SUPPORT_VERBOSITY + if (verbosity_level >= 20) { + // Go to Y0, wait, then go to Y-4. + current_position[Y_AXIS] = 0.f; + go_to_current(homing_feedrate[X_AXIS] / 60.f); + SERIAL_ECHOLNPGM("At Y0"); + delay_keep_alive(5000); + current_position[Y_AXIS] = Y_MIN_POS; + go_to_current(homing_feedrate[X_AXIS] / 60.f); + SERIAL_ECHOLNPGM("At Y-4"); + delay_keep_alive(5000); + } + #endif // SUPPORT_VERBOSITY + // Go to the measurement point position. + //if (iteration == 0) { + current_position[X_AXIS] = pgm_read_float(bed_ref_points_4 + k * 2); + current_position[Y_AXIS] = pgm_read_float(bed_ref_points_4 + k * 2 + 1); + /*} + else { + // if first iteration failed, count corrected point coordinates as initial + // Use the corrected coordinate, which is a result of find_bed_offset_and_skew(). + + current_position[X_AXIS] = vec_x[0] * pgm_read_float(bed_ref_points_4 + k * 2) + vec_y[0] * pgm_read_float(bed_ref_points_4 + k * 2 + 1) + cntr[0]; + current_position[Y_AXIS] = vec_x[1] * pgm_read_float(bed_ref_points_4 + k * 2) + vec_y[1] * pgm_read_float(bed_ref_points_4 + k * 2 + 1) + cntr[1]; - // The calibration points are very close to the min Y. - if (current_position[Y_AXIS] < Y_MIN_POS_FOR_BED_CALIBRATION) - current_position[Y_AXIS] = Y_MIN_POS_FOR_BED_CALIBRATION; + // The calibration points are very close to the min Y. + if (current_position[Y_AXIS] < Y_MIN_POS_FOR_BED_CALIBRATION) + current_position[Y_AXIS] = Y_MIN_POS_FOR_BED_CALIBRATION; - }*/ - #ifdef SUPPORT_VERBOSITY - if (verbosity_level >= 20) { - SERIAL_ECHOPGM("current_position[X_AXIS]:"); - MYSERIAL.print(current_position[X_AXIS], 5); - SERIAL_ECHOLNPGM(""); - SERIAL_ECHOPGM("current_position[Y_AXIS]:"); - MYSERIAL.print(current_position[Y_AXIS], 5); - SERIAL_ECHOLNPGM(""); - SERIAL_ECHOPGM("current_position[Z_AXIS]:"); - MYSERIAL.print(current_position[Z_AXIS], 5); - SERIAL_ECHOLNPGM(""); - } - #endif // SUPPORT_VERBOSITY + }*/ + #ifdef SUPPORT_VERBOSITY + if (verbosity_level >= 20) { + SERIAL_ECHOPGM("current_position[X_AXIS]:"); + MYSERIAL.print(current_position[X_AXIS], 5); + SERIAL_ECHOLNPGM(""); + SERIAL_ECHOPGM("current_position[Y_AXIS]:"); + MYSERIAL.print(current_position[Y_AXIS], 5); + SERIAL_ECHOLNPGM(""); + SERIAL_ECHOPGM("current_position[Z_AXIS]:"); + MYSERIAL.print(current_position[Z_AXIS], 5); + SERIAL_ECHOLNPGM(""); + } + #endif // SUPPORT_VERBOSITY - go_to_current(homing_feedrate[X_AXIS] / 60.f); - #ifdef SUPPORT_VERBOSITY - if (verbosity_level >= 10) - delay_keep_alive(3000); - #endif // SUPPORT_VERBOSITY - if (!find_bed_induction_sensor_point_xy(verbosity_level)) - return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND + go_to_current(homing_feedrate[X_AXIS] / 60.f); + #ifdef SUPPORT_VERBOSITY + if (verbosity_level >= 10) + delay_keep_alive(3000); + #endif // SUPPORT_VERBOSITY + if (!find_bed_induction_sensor_point_xy(verbosity_level)) + return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND; #ifndef NEW_XYZCAL #ifndef HEATBED_V2 - if (k == 0 || k == 1) { - // Improve the position of the 1st row sensor points by a zig-zag movement. - find_bed_induction_sensor_point_z(); - int8_t i = 4; - for (;;) { - if (improve_bed_induction_sensor_point3(verbosity_level)) - break; - if (--i == 0) - return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND; - // Try to move the Z axis down a bit to increase a chance of the sensor to trigger. - current_position[Z_AXIS] -= 0.025f; - enable_endstops(false); - enable_z_endstop(false); - go_to_current(homing_feedrate[Z_AXIS]); - } - if (i == 0) - // not found - return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND; - } + if (k == 0 || k == 1) { + // Improve the position of the 1st row sensor points by a zig-zag movement. + find_bed_induction_sensor_point_z(); + int8_t i = 4; + for (;;) { + if (improve_bed_induction_sensor_point3(verbosity_level)) + break; + if (--i == 0) + return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND; + // Try to move the Z axis down a bit to increase a chance of the sensor to trigger. + current_position[Z_AXIS] -= 0.025f; + enable_endstops(false); + enable_z_endstop(false); + go_to_current(homing_feedrate[Z_AXIS]); + } + if (i == 0) + // not found + return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND; + } #endif //HEATBED_V2 #endif #ifdef SUPPORT_VERBOSITY @@ -2379,9 +2379,8 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level delay_keep_alive(3000); } #endif // SUPPORT_VERBOSITY - } - DBG(_n("All 4 calibration points found.\n")); - delay_keep_alive(0); //manage_heater, reset watchdog, manage inactivity + } + delay_keep_alive(0); //manage_heater, reset watchdog, manage inactivity #ifdef SUPPORT_VERBOSITY if (verbosity_level >= 20) { @@ -2391,7 +2390,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level // Don't let the manage_inactivity() function remove power from the motors. refresh_cmd_timeout(); // Go to the measurement point. - // Use the corrected coordinate, which is a result of find_bed_offset_and_skew(). + // Use the coorrected coordinate, which is a result of find_bed_offset_and_skew(). current_position[X_AXIS] = pts[mesh_point * 2]; current_position[Y_AXIS] = pts[mesh_point * 2 + 1]; go_to_current(homing_feedrate[X_AXIS] / 60); @@ -2456,7 +2455,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level // Don't let the manage_inactivity() function remove power from the motors. refresh_cmd_timeout(); // Go to the measurement point. - // Use the corrected coordinate, which is a result of find_bed_offset_and_skew(). + // Use the coorrected coordinate, which is a result of find_bed_offset_and_skew(). uint8_t ix = mesh_point % MESH_MEAS_NUM_X_POINTS; // from 0 to MESH_NUM_X_POINTS - 1 uint8_t iy = mesh_point / MESH_MEAS_NUM_X_POINTS; if (iy & 1) ix = (MESH_MEAS_NUM_X_POINTS - 1) - ix; From b8443b00ad3cee9406532561245d877c65766c6d Mon Sep 17 00:00:00 2001 From: espr14 Date: Mon, 11 Jan 2021 22:18:50 +0100 Subject: [PATCH 65/73] Reverse reverse --- Firmware/mesh_bed_calibration.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index dc13eaac4..594ac4bf6 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -2379,8 +2379,9 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level delay_keep_alive(3000); } #endif // SUPPORT_VERBOSITY - } - delay_keep_alive(0); //manage_heater, reset watchdog, manage inactivity + } + DBG(_n("All 4 calibration points found.\n")); + delay_keep_alive(0); //manage_heater, reset watchdog, manage inactivity #ifdef SUPPORT_VERBOSITY if (verbosity_level >= 20) { @@ -2390,7 +2391,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level // Don't let the manage_inactivity() function remove power from the motors. refresh_cmd_timeout(); // Go to the measurement point. - // Use the coorrected coordinate, which is a result of find_bed_offset_and_skew(). + // Use the corrected coordinate, which is a result of find_bed_offset_and_skew(). current_position[X_AXIS] = pts[mesh_point * 2]; current_position[Y_AXIS] = pts[mesh_point * 2 + 1]; go_to_current(homing_feedrate[X_AXIS] / 60); @@ -2455,7 +2456,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level // Don't let the manage_inactivity() function remove power from the motors. refresh_cmd_timeout(); // Go to the measurement point. - // Use the coorrected coordinate, which is a result of find_bed_offset_and_skew(). + // Use the corrected coordinate, which is a result of find_bed_offset_and_skew(). uint8_t ix = mesh_point % MESH_MEAS_NUM_X_POINTS; // from 0 to MESH_NUM_X_POINTS - 1 uint8_t iy = mesh_point / MESH_MEAS_NUM_X_POINTS; if (iy & 1) ix = (MESH_MEAS_NUM_X_POINTS - 1) - ix; From e6e44fe18861b1cb63bb99e24514538f6474cfb8 Mon Sep 17 00:00:00 2001 From: espr14 Date: Mon, 11 Jan 2021 23:13:08 +0100 Subject: [PATCH 66/73] Convert to degrees --- Firmware/mesh_bed_calibration.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index 594ac4bf6..6dc524226 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -371,9 +371,9 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS( BedSkewOffsetDetectionResultType result = BED_SKEW_OFFSET_DETECTION_PERFECT; { angleDiff = fabs(a2 - a1); - DBG(_n("Measured XY skew: %f\n"), a2 - a1); - DBG(_n("Measured Y-bed skew: %f\n"), a2); - eeprom_update_float((float*)(EEPROM_XYZ_CAL_SKEW), angleDiff); //storing xyz cal. skew to be able to show in support menu later + DBG(_n("Measured XY skew: %f°\n"), degrees(a2 - a1)); + DBG(_n("Measured Y-bed skew: %f°\n"), degrees(a2)); + eeprom_update_float((float *)(EEPROM_XYZ_CAL_SKEW), angleDiff); //storing xyz cal. skew to be able to show in support menu later if (angleDiff > bed_skew_angle_mild) result = (angleDiff > bed_skew_angle_extreme) ? BED_SKEW_OFFSET_DETECTION_SKEW_EXTREME : @@ -1384,7 +1384,7 @@ inline bool find_bed_induction_sensor_point_xy(int verbosity_level) // go_xyz(current_position[X_AXIS], current_position[Y_AXIS], MESH_HOME_Z_SEARCH, homing_feedrate[Z_AXIS]/60); go_xyz(x0, y0, current_position[Z_AXIS], feedrate); - // Continously lower the Z axis. + // Continuously lower the Z axis. endstops_hit_on_purpose(); enable_z_endstop(true); while (current_position[Z_AXIS] > -10.f) { From 333526f65dde201982345aaa063b234bc7f94b00 Mon Sep 17 00:00:00 2001 From: espr14 Date: Mon, 11 Jan 2021 23:14:12 +0100 Subject: [PATCH 67/73] Single skew output --- Firmware/mesh_bed_calibration.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index 6dc524226..4f4261161 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -371,8 +371,8 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS( BedSkewOffsetDetectionResultType result = BED_SKEW_OFFSET_DETECTION_PERFECT; { angleDiff = fabs(a2 - a1); - DBG(_n("Measured XY skew: %f°\n"), degrees(a2 - a1)); - DBG(_n("Measured Y-bed skew: %f°\n"), degrees(a2)); + /// XY skew and Y-bed skew + DBG(_n("Measured skews: %f° %f°\n"), degrees(a2 - a1), degrees(a2)); eeprom_update_float((float *)(EEPROM_XYZ_CAL_SKEW), angleDiff); //storing xyz cal. skew to be able to show in support menu later if (angleDiff > bed_skew_angle_mild) result = (angleDiff > bed_skew_angle_extreme) ? From 180af46fe46947a21526655068948abcffef6636 Mon Sep 17 00:00:00 2001 From: espr14 Date: Tue, 12 Jan 2021 00:27:06 +0100 Subject: [PATCH 68/73] Try double height --- Firmware/mesh_bed_calibration.cpp | 2 +- Firmware/xyzcal.cpp | 79 ++++++++++++++++--------------- 2 files changed, 42 insertions(+), 39 deletions(-) diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index 4f4261161..a0efc3aae 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -372,7 +372,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS( { angleDiff = fabs(a2 - a1); /// XY skew and Y-bed skew - DBG(_n("Measured skews: %f° %f°\n"), degrees(a2 - a1), degrees(a2)); + DBG(_n("Measured skews: %f %f\n"), degrees(a2 - a1), degrees(a2)); eeprom_update_float((float *)(EEPROM_XYZ_CAL_SKEW), angleDiff); //storing xyz cal. skew to be able to show in support menu later if (angleDiff > bed_skew_angle_mild) result = (angleDiff > bed_skew_angle_extreme) ? diff --git a/Firmware/xyzcal.cpp b/Firmware/xyzcal.cpp index c68804890..1370542bc 100644 --- a/Firmware/xyzcal.cpp +++ b/Firmware/xyzcal.cpp @@ -293,7 +293,7 @@ bool xyzcal_spiral2(int16_t cx, int16_t cy, int16_t z0, int16_t dz, int16_t radi dad = dad_max - ((719 - ad) / k); r = (float)(((uint32_t)(719 - ad)) * (-radius)) / 720; } - ar = (ad + rotation)* (float)M_PI / 180; + ar = radians(ad + rotation); int x = (int)(cx + (cos(ar) * r)); int y = (int)(cy + (sin(ar) * r)); int z = (int)(z0 - ((float)((int32_t)dz * ad) / 720)); @@ -831,9 +831,8 @@ float median(float *points, const uint8_t num_points){ void dynamic_circle(uint8_t *matrix_32x32, float &x, float &y, float &r, uint8_t iterations){ /// circle of 10.5 diameter has 33 in circumference, don't go much above const constexpr uint8_t num_points = 33; - float pi_2_div_num_points = 2 * M_PI / num_points; + const float pi_2_div_num_points = 2 * M_PI / num_points; const constexpr uint8_t target_z = 32; ///< target z height of the circle - float angle; float max_change = 0.5f; ///< avoids too fast changes (avoid oscillation) const uint8_t blocks = num_points; float shifts_x[blocks]; @@ -848,7 +847,7 @@ void dynamic_circle(uint8_t *matrix_32x32, float &x, float &y, float &r, uint8_t /// read points on the circle for (uint8_t p = 0; p < num_points; ++p){ - angle = p * pi_2_div_num_points; + const float angle = p * pi_2_div_num_points; const float height = get_value(matrix_32x32, r * cos(angle) + x, r * sin(angle) + y) - target_z; // DBG(_n("%f "), point); @@ -858,7 +857,8 @@ void dynamic_circle(uint8_t *matrix_32x32, float &x, float &y, float &r, uint8_t } // DBG(_n(" points\n")); - const float norm = 1.f / 32.f; + const float reducer = 32.f; ///< reduces speed of convergency to avoid oscillation + const float norm = 1.f / reducer; x += CLAMP(median(shifts_x, blocks) * norm, -max_change, max_change); y += CLAMP(median(shifts_y, blocks) * norm, -max_change, max_change); r += CLAMP(median(shifts_r, blocks) * norm * .5f, -max_change, max_change); @@ -912,49 +912,52 @@ bool xyzcal_scan_and_process(void){ bool ret = false; int16_t x = _X; int16_t y = _Y; - int16_t z = _Z; + const int16_t z = _Z; uint8_t *matrix32 = (uint8_t *)block_buffer; uint16_t *pattern08 = (uint16_t *)(matrix32 + 32 * 32); uint16_t *pattern10 = (uint16_t *)(pattern08 + 12); - xyzcal_scan_pixels_32x32_Zhop(x, y, z - 72, 2400, 200, matrix32); - print_image(matrix32); - for (uint8_t i = 0; i < 12; i++){ pattern08[i] = pgm_read_word((uint16_t*)(xyzcal_point_pattern_08 + i)); pattern10[i] = pgm_read_word((uint16_t*)(xyzcal_point_pattern_10 + i)); } - - /// SEARCH FOR BINARY CIRCLE - uint8_t uc = 0; - uint8_t ur = 0; - - - /// max match = 132, 1/2 good = 66, 2/3 good = 88 - if (find_patterns(matrix32, pattern08, pattern10, uc, ur) >= 88){ - /// find precise circle - /// move to the center of the pattern (+5.5) - float xf = uc + 5.5f; - float yf = ur + 5.5f; - float radius = 5; ///< default radius - const uint8_t iterations = 20; - dynamic_circle(matrix32, xf, yf, radius, iterations); - if (ABS(xf - (uc + 5.5f)) > 3 || ABS(yf - (ur + 5.5f)) > 3 || ABS(radius - 5) > 3){ - DBG(_n(" [%f %f][%f] mm divergence\n"), xf - (uc + 5.5f), yf - (ur + 5.5f), radius - 5); - /// dynamic algorithm diverged, use original position instead - xf = uc + 5.5f; - yf = ur + 5.5f; - } - /// move to the center of area and convert to position - xf = (float)x + (xf - 15.5f) * 64; - yf = (float)y + (yf - 15.5f) * 64; - DBG(_n(" [%f %f] mm pattern center\n"), pos_2_mm(xf), pos_2_mm(yf)); - x = round_to_i16(xf); - y = round_to_i16(yf); - xyzcal_lineXYZ_to(x, y, z, 200, 0); - ret = true; + /// Lower z if pattern not found + for (int8_t lower = 0; lower < 60; lower += 50){ + xyzcal_scan_pixels_32x32_Zhop(x, y, z - lower, 2400, 200, matrix32); + print_image(matrix32); + + /// SEARCH FOR BINARY CIRCLE + uint8_t uc = 0; + uint8_t ur = 0; + + /// max match = 132, 1/2 good = 66, 2/3 good = 88 + if (find_patterns(matrix32, pattern08, pattern10, uc, ur) >= 88){ + /// find precise circle + /// move to the center of the pattern (+5.5) + float xf = uc + 5.5f; + float yf = ur + 5.5f; + float radius = 4.5f; ///< default radius + const uint8_t iterations = 20; + dynamic_circle(matrix32, xf, yf, radius, iterations); + if (ABS(xf - (uc + 5.5f)) > 3 || ABS(yf - (ur + 5.5f)) > 3 || ABS(radius - 5) > 3){ + DBG(_n(" [%f %f][%f] mm divergence\n"), xf - (uc + 5.5f), yf - (ur + 5.5f), radius - 5); + /// dynamic algorithm diverged, use original position instead + xf = uc + 5.5f; + yf = ur + 5.5f; + } + + /// move to the center of area and convert to position + xf = (float)x + (xf - 15.5f) * 64; + yf = (float)y + (yf - 15.5f) * 64; + DBG(_n(" [%f %f] mm pattern center\n"), pos_2_mm(xf), pos_2_mm(yf)); + x = round_to_i16(xf); + y = round_to_i16(yf); + xyzcal_lineXYZ_to(x, y, z, 200, 0); + ret = true; + break; + } } /// wipe buffer From d7507649d8202de6653ca4d376d6f19e309a98b1 Mon Sep 17 00:00:00 2001 From: espr14 Date: Tue, 12 Jan 2021 00:28:46 +0100 Subject: [PATCH 69/73] Remove degree char --- Firmware/mesh_bed_calibration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index 4f4261161..a0efc3aae 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -372,7 +372,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS( { angleDiff = fabs(a2 - a1); /// XY skew and Y-bed skew - DBG(_n("Measured skews: %f° %f°\n"), degrees(a2 - a1), degrees(a2)); + DBG(_n("Measured skews: %f %f\n"), degrees(a2 - a1), degrees(a2)); eeprom_update_float((float *)(EEPROM_XYZ_CAL_SKEW), angleDiff); //storing xyz cal. skew to be able to show in support menu later if (angleDiff > bed_skew_angle_mild) result = (angleDiff > bed_skew_angle_extreme) ? From 546812294ec91d5ad0011c3de7201d6464fa21e0 Mon Sep 17 00:00:00 2001 From: espr14 Date: Tue, 12 Jan 2021 00:34:28 +0100 Subject: [PATCH 70/73] Clean serial output --- Firmware/xyzcal.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/xyzcal.cpp b/Firmware/xyzcal.cpp index 1370542bc..8365fc94b 100644 --- a/Firmware/xyzcal.cpp +++ b/Firmware/xyzcal.cpp @@ -682,7 +682,7 @@ uint8_t xyzcal_find_pattern_12x12_in_32x32(uint8_t* pixels, uint16_t* pattern, u } // DBG(_n("\n")); } - DBG(_n("max_c=%d max_r=%d max_match=%d pixel\n"), max_c, max_r, max_match); + DBG(_n("Pattern center [%f %f], match %f%%\n"), max_c + 5.5f, max_r + 5.5f, max_match / 1.32f); *pc = max_c; *pr = max_r; @@ -839,7 +839,7 @@ void dynamic_circle(uint8_t *matrix_32x32, float &x, float &y, float &r, uint8_t float shifts_y[blocks]; float shifts_r[blocks]; - DBG(_n(" [%f, %f][%f] start circle\n"), x, y, r); + // DBG(_n(" [%f, %f][%f] start circle\n"), x, y, r); for (int8_t i = iterations; i > 0; --i){ From 9dceb488b68bb131e512fe4c7a96c65cc28d4ef2 Mon Sep 17 00:00:00 2001 From: espr14 Date: Tue, 12 Jan 2021 16:04:04 +0100 Subject: [PATCH 71/73] Revert double scanning --- Firmware/xyzcal.cpp | 73 +++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/Firmware/xyzcal.cpp b/Firmware/xyzcal.cpp index 8365fc94b..f6cb1ea10 100644 --- a/Firmware/xyzcal.cpp +++ b/Firmware/xyzcal.cpp @@ -923,40 +923,38 @@ bool xyzcal_scan_and_process(void){ pattern10[i] = pgm_read_word((uint16_t*)(xyzcal_point_pattern_10 + i)); } - /// Lower z if pattern not found - for (int8_t lower = 0; lower < 60; lower += 50){ - xyzcal_scan_pixels_32x32_Zhop(x, y, z - lower, 2400, 200, matrix32); - print_image(matrix32); - - /// SEARCH FOR BINARY CIRCLE - uint8_t uc = 0; - uint8_t ur = 0; - - /// max match = 132, 1/2 good = 66, 2/3 good = 88 - if (find_patterns(matrix32, pattern08, pattern10, uc, ur) >= 88){ - /// find precise circle - /// move to the center of the pattern (+5.5) - float xf = uc + 5.5f; - float yf = ur + 5.5f; - float radius = 4.5f; ///< default radius - const uint8_t iterations = 20; - dynamic_circle(matrix32, xf, yf, radius, iterations); - if (ABS(xf - (uc + 5.5f)) > 3 || ABS(yf - (ur + 5.5f)) > 3 || ABS(radius - 5) > 3){ - DBG(_n(" [%f %f][%f] mm divergence\n"), xf - (uc + 5.5f), yf - (ur + 5.5f), radius - 5); - /// dynamic algorithm diverged, use original position instead - xf = uc + 5.5f; - yf = ur + 5.5f; - } + xyzcal_scan_pixels_32x32_Zhop(x, y, z, 2400, 200, matrix32); + print_image(matrix32); - /// move to the center of area and convert to position - xf = (float)x + (xf - 15.5f) * 64; - yf = (float)y + (yf - 15.5f) * 64; - DBG(_n(" [%f %f] mm pattern center\n"), pos_2_mm(xf), pos_2_mm(yf)); - x = round_to_i16(xf); - y = round_to_i16(yf); - xyzcal_lineXYZ_to(x, y, z, 200, 0); - ret = true; - break; + /// SEARCH FOR BINARY CIRCLE + uint8_t uc = 0; + uint8_t ur = 0; + + /// max match = 132, 1/2 good = 66, 2/3 good = 88 + if (find_patterns(matrix32, pattern08, pattern10, uc, ur) >= 88){ + /// find precise circle + /// move to the center of the pattern (+5.5) + float xf = uc + 5.5f; + float yf = ur + 5.5f; + float radius = 4.5f; ///< default radius + const uint8_t iterations = 20; + dynamic_circle(matrix32, xf, yf, radius, iterations); + if (ABS(xf - (uc + 5.5f)) > 3 || ABS(yf - (ur + 5.5f)) > 3 || ABS(radius - 5) > 3) + { + DBG(_n(" [%f %f][%f] mm divergence\n"), xf - (uc + 5.5f), yf - (ur + 5.5f), radius - 5); + /// dynamic algorithm diverged, use original position instead + xf = uc + 5.5f; + yf = ur + 5.5f; + } + + /// move to the center of area and convert to position + xf = (float)x + (xf - 15.5f) * 64; + yf = (float)y + (yf - 15.5f) * 64; + DBG(_n(" [%f %f] mm pattern center\n"), pos_2_mm(xf), pos_2_mm(yf)); + x = round_to_i16(xf); + y = round_to_i16(yf); + xyzcal_lineXYZ_to(x, y, z, 200, 0); + ret = true; } } @@ -971,9 +969,11 @@ bool xyzcal_find_bed_induction_sensor_point_xy(void){ DBG(_n("xyzcal_find_bed_induction_sensor_point_xy x=%ld y=%ld z=%ld\n"), count_position[X_AXIS], count_position[Y_AXIS], count_position[Z_AXIS]); st_synchronize(); - pos_i16_t x = _X; - pos_i16_t y = _Y; - pos_i16_t z = _Z; + const pos_i16_t x = _X; + const pos_i16_t y = _Y; + const pos_i16_t z = _Z; + ///< magic constant, lowers min_z after searchZ to obtain more dense data in scan + const pos_i16_t lower_z = 72; uint8_t point = xyzcal_xycoords2point(x, y); x = pgm_read_word((uint16_t *)(xyzcal_point_xcoords + point)); @@ -983,6 +983,7 @@ bool xyzcal_find_bed_induction_sensor_point_xy(void){ xyzcal_lineXYZ_to(x, y, z, 200, 0); if (xyzcal_searchZ()){ + xyzcal_lineXYZ_to(_X, _Y, _Z - lower_z, 200, 0); xyzcal_lineXYZ_to(x, y, _Z, 200, 0); ret = xyzcal_scan_and_process(); } From f3faf651c576f8bf7a53f6d7fa5489948d32bd82 Mon Sep 17 00:00:00 2001 From: espr14 Date: Tue, 12 Jan 2021 16:12:34 +0100 Subject: [PATCH 72/73] Move down before scanning --- Firmware/xyzcal.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Firmware/xyzcal.cpp b/Firmware/xyzcal.cpp index f6cb1ea10..98cd04a4d 100644 --- a/Firmware/xyzcal.cpp +++ b/Firmware/xyzcal.cpp @@ -984,7 +984,6 @@ bool xyzcal_find_bed_induction_sensor_point_xy(void){ if (xyzcal_searchZ()){ xyzcal_lineXYZ_to(_X, _Y, _Z - lower_z, 200, 0); - xyzcal_lineXYZ_to(x, y, _Z, 200, 0); ret = xyzcal_scan_and_process(); } xyzcal_meassure_leave(); From 21d6f970ef7e139840dc5535fb09f03c3ff99ed6 Mon Sep 17 00:00:00 2001 From: espr14 Date: Tue, 12 Jan 2021 16:26:46 +0100 Subject: [PATCH 73/73] Fix build --- Firmware/xyzcal.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Firmware/xyzcal.cpp b/Firmware/xyzcal.cpp index 98cd04a4d..47eecb942 100644 --- a/Firmware/xyzcal.cpp +++ b/Firmware/xyzcal.cpp @@ -955,7 +955,6 @@ bool xyzcal_scan_and_process(void){ y = round_to_i16(yf); xyzcal_lineXYZ_to(x, y, z, 200, 0); ret = true; - } } /// wipe buffer @@ -969,8 +968,8 @@ bool xyzcal_find_bed_induction_sensor_point_xy(void){ DBG(_n("xyzcal_find_bed_induction_sensor_point_xy x=%ld y=%ld z=%ld\n"), count_position[X_AXIS], count_position[Y_AXIS], count_position[Z_AXIS]); st_synchronize(); - const pos_i16_t x = _X; - const pos_i16_t y = _Y; + pos_i16_t x = _X; + pos_i16_t y = _Y; const pos_i16_t z = _Z; ///< magic constant, lowers min_z after searchZ to obtain more dense data in scan const pos_i16_t lower_z = 72;