From 623c0765ea16aff6bbaa9f9468654ebf38cf7c9c Mon Sep 17 00:00:00 2001 From: Lino77 Date: Sun, 30 Jun 2019 14:06:36 +0200 Subject: [PATCH 1/6] Update fsensor.cpp M600 Z_MAX_POS --- Firmware/fsensor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/fsensor.cpp b/Firmware/fsensor.cpp index 840c5260..20078912 100755 --- a/Firmware/fsensor.cpp +++ b/Firmware/fsensor.cpp @@ -543,7 +543,7 @@ void fsensor_enque_M600(){ // 8bit arithmetics in fsensor_clamp_z is 10B shorter than 16bit (not talking about float ;) ) // The compile-time static_assert here ensures, that the computation gets enough bits in case of Z-range too high, // i.e. makes the user change the data type, which also results in larger code - static_assert(Z_MAX_POS < (255 - FILAMENTCHANGE_ZADD), "Z-range too high, change fsensor_clamp_z to "); + static_assert(Z_MAX_POS < (Z_MAX_POS + 45 - FILAMENTCHANGE_ZADD), "Z-range too high, change fsensor_clamp_z to "); sprintf_P(buf, gcodeMove, fsensor_clamp_z(current_position[Z_AXIS]) ); enquecommand_front(buf, false); } From 1c2153bd4f00679cce4fa283792ce5e7511d3fd3 Mon Sep 17 00:00:00 2001 From: Lino77 Date: Sun, 30 Jun 2019 14:08:35 +0200 Subject: [PATCH 2/6] Update Marlin_main.cpp M600 Z_MAX_POS --- 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 c29eb477..8a32fd6b 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3001,7 +3001,7 @@ template static T gcode_M600_filament_change_z_shift() { #ifdef FILAMENTCHANGE_ZADD - static_assert(Z_MAX_POS < (255 - FILAMENTCHANGE_ZADD), "Z-range too high, change the T type from uint8_t to uint16_t"); + static_assert(Z_MAX_POS < (Z_MAX_POS + 45 - FILAMENTCHANGE_ZADD), "Z-range too high, change the T type from uint8_t to uint16_t"); // avoid floating point arithmetics when not necessary - results in shorter code T ztmp = T( current_position[Z_AXIS] ); T z_shift = 0; From 15ae9ecce207f777e1f787c39c685e31f13941b9 Mon Sep 17 00:00:00 2001 From: Lino77 Date: Sun, 30 Jun 2019 14:14:48 +0200 Subject: [PATCH 3/6] Update sm4.c Make the simple 4 axis stepper control respect the axis inversion settings in Configuration_prusa.h THX metacollin --- Firmware/sm4.c | 47 +++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/Firmware/sm4.c b/Firmware/sm4.c index 34cf8a3c..f97bfc59 100644 --- a/Firmware/sm4.c +++ b/Firmware/sm4.c @@ -36,6 +36,13 @@ //#define E0_STEP_PIN 34 //PC3 (+) +#define XDIR INVERT_X_DIR:!INVERT_X_DIR +#define YDIR INVERT_Y_DIR:!INVERT_Y_DIR +#define ZDIR INVERT_Z_DIR:!INVERT_Z_DIR +#define EDIR INVERT_E0_DIR:!INVERT_E0_DIR + +uint8_t dir_mask = 0x0F^(INVERT_X_DIR | (INVERT_Y_DIR << 1) | (INVERT_Z_DIR << 2) | (INVERT_E0_DIR << 3)); + sm4_stop_cb_t sm4_stop_cb = 0; sm4_update_pos_cb_t sm4_update_pos_cb = 0; @@ -50,15 +57,15 @@ uint8_t sm4_get_dir(uint8_t axis) switch (axis) { #if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3)) - case 0: return (PORTL & 2)?0:1; - case 1: return (PORTL & 1)?0:1; - case 2: return (PORTL & 4)?0:1; - case 3: return (PORTL & 64)?1:0; + case 0: return (PORTL & 2)?XDIR; + case 1: return (PORTL & 1)?YDIR; + case 2: return (PORTL & 4)?ZDIR; + case 3: return (PORTL & 64)?EDIR; #elif ((MOTHERBOARD == BOARD_EINSY_1_0a)) - case 0: return (PORTL & 1)?1:0; - case 1: return (PORTL & 2)?0:1; - case 2: return (PORTL & 4)?1:0; - case 3: return (PORTL & 64)?0:1; + case 0: return (PORTL & 1)?XDIR; + case 1: return (PORTL & 2)?YDIR; + case 2: return (PORTL & 4)?ZDIR; + case 3: return (PORTL & 64)?EDIR; #endif } return 0; @@ -69,15 +76,15 @@ void sm4_set_dir(uint8_t axis, uint8_t dir) switch (axis) { #if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3)) - case 0: if (!dir) PORTL |= 2; else PORTL &= ~2; break; - case 1: if (!dir) PORTL |= 1; else PORTL &= ~1; break; - case 2: if (!dir) PORTL |= 4; else PORTL &= ~4; break; - case 3: if (dir) PORTL |= 64; else PORTL &= ~64; break; + case 0: if (dir == INVERT_X_DIR) PORTL |= 2; else PORTL &= ~2; break; + case 1: if (dir == INVERT_Y_DIR) PORTL |= 1; else PORTL &= ~1; break; + case 2: if (dir == INVERT_Z_DIR) PORTL |= 4; else PORTL &= ~4; break; + case 3: if (dir == INVERT_E0_DIR) PORTL |= 64; else PORTL &= ~64; break; #elif ((MOTHERBOARD == BOARD_EINSY_1_0a)) - case 0: if (dir) PORTL |= 1; else PORTL &= ~1; break; - case 1: if (!dir) PORTL |= 2; else PORTL &= ~2; break; - case 2: if (dir) PORTL |= 4; else PORTL &= ~4; break; - case 3: if (!dir) PORTL |= 64; else PORTL &= ~64; break; + case 0: if (dir == INVERT_X_DIR) PORTL |= 1; else PORTL &= ~1; break; + case 1: if (dir == INVERT_Y_DIR) PORTL |= 2; else PORTL &= ~2; break; + case 2: if (dir == INVERT_Z_DIR) PORTL |= 4; else PORTL &= ~4; break; + case 3: if (dir == INVERT_E0_DIR) PORTL |= 64; else PORTL &= ~64; break; #endif } asm("nop"); @@ -93,13 +100,13 @@ uint8_t sm4_get_dir_bits(void) if (portL & 1) dir_bits |= 2; if (portL & 4) dir_bits |= 4; if (portL & 64) dir_bits |= 8; - dir_bits ^= 0x07; //invert XYZ, do not invert E + dir_bits ^= dir_mask; #elif ((MOTHERBOARD == BOARD_EINSY_1_0a)) if (portL & 1) dir_bits |= 1; if (portL & 2) dir_bits |= 2; if (portL & 4) dir_bits |= 4; if (portL & 64) dir_bits |= 8; - dir_bits ^= 0x0a; //invert YE, do not invert XZ + dir_bits ^= dir_mask; #endif return dir_bits; } @@ -110,13 +117,13 @@ void sm4_set_dir_bits(uint8_t dir_bits) portL &= 0xb8; //set direction bits to zero //TODO -optimize in asm #if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3)) - dir_bits ^= 0x07; //invert XYZ, do not invert E + dir_bits ^= dir_mask; if (dir_bits & 1) portL |= 2; //set X direction bit if (dir_bits & 2) portL |= 1; //set Y direction bit if (dir_bits & 4) portL |= 4; //set Z direction bit if (dir_bits & 8) portL |= 64; //set E direction bit #elif ((MOTHERBOARD == BOARD_EINSY_1_0a)) - dir_bits ^= 0x0a; //invert YE, do not invert XZ + dir_bits ^= dir_mask; if (dir_bits & 1) portL |= 1; //set X direction bit if (dir_bits & 2) portL |= 2; //set Y direction bit if (dir_bits & 4) portL |= 4; //set Z direction bit From f868569071f6ed4157bcd42c730f108cd57b1e0e Mon Sep 17 00:00:00 2001 From: Lino77 Date: Sun, 30 Jun 2019 16:01:17 +0200 Subject: [PATCH 4/6] Update ultralcd.cpp All LCD Menu --- Firmware/ultralcd.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index d4f934f0..e5547e28 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -116,6 +116,7 @@ static void lcd_status_screen(); static void lcd_language_menu(); static void lcd_main_menu(); static void lcd_tune_menu(); +static void lcd_led_menu(); //static void lcd_move_menu(); static void lcd_settings_menu(); static void lcd_calibration_menu(); @@ -2230,6 +2231,21 @@ static void lcd_preheat_menu() MENU_END(); } +static void lcd_led_menu() +{ + MENU_BEGIN(); + + MENU_ITEM_BACK_P(_T(MSG_MAIN));{ + + MENU_ITEM_GCODE_P(_i("Light off"), PSTR("M42 P5 S0"));////MSG_LED_OFF + MENU_ITEM_GCODE_P(_i("Light 25%"), PSTR("M42 P5 S64"));////MSG_LED_25 + MENU_ITEM_GCODE_P(_i("Light 50%"), PSTR("M42 P5 S127"));////MSG_LED_50 + MENU_ITEM_GCODE_P(_i("Light 75%"), PSTR("M42 P5 S190"));////MSG_LED_75 + MENU_ITEM_GCODE_P(_i("Light 100%"), PSTR("M42 P5 S255"));////MSG_LED_100 + } + MENU_END(); +} + static void lcd_support_menu() { typedef struct @@ -6384,6 +6400,7 @@ static void lcd_test_menu() void lcd_resume_print() { lcd_return_to_status(); + lcd_reset_alert_level(); lcd_setstatuspgm(_T(MSG_RESUMING_PRINT)); lcd_reset_alert_level(); //for fan speed error restore_print_from_ram_and_continue(0.0); @@ -6468,6 +6485,7 @@ static void lcd_main_menu() MENU_ITEM_SUBMENU_P(_T(MSG_BABYSTEP_Z), lcd_babystep_z);//8 } + MENU_ITEM_SUBMENU_P(_i("Light"), lcd_led_menu);////MSG_LED if ( moves_planned() || IS_SD_PRINTING || is_usb_printing || (lcd_commands_type == LCD_COMMAND_V2_CAL)) { @@ -6489,7 +6507,14 @@ static void lcd_main_menu() } else { - MENU_ITEM_SUBMENU_P(_i("Resume print"), lcd_resume_print);////MSG_RESUME_PRINT + #ifdef FANCHECK + checkFanSpeed(); //Check manually to get most recent fan speed status + if(fan_check_error == EFCE_OK) + MENU_ITEM_SUBMENU_P(_i("Resume print"), lcd_resume_print);////MSG_RESUME_PRINT + #else + MENU_ITEM_SUBMENU_P(_i("Resume print"), lcd_resume_print);////MSG_RESUME_PRINT + #endif + } MENU_ITEM_SUBMENU_P(_T(MSG_STOP_PRINT), lcd_sdcard_stop); } From b0d702b90d40a541db28b5bb81e169395bb5136f Mon Sep 17 00:00:00 2001 From: Lino77 Date: Sun, 30 Jun 2019 16:01:17 +0200 Subject: [PATCH 5/6] Revert "Update ultralcd.cpp" This reverts commit f868569071f6ed4157bcd42c730f108cd57b1e0e. --- Firmware/ultralcd.cpp | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index e5547e28..d4f934f0 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -116,7 +116,6 @@ static void lcd_status_screen(); static void lcd_language_menu(); static void lcd_main_menu(); static void lcd_tune_menu(); -static void lcd_led_menu(); //static void lcd_move_menu(); static void lcd_settings_menu(); static void lcd_calibration_menu(); @@ -2231,21 +2230,6 @@ static void lcd_preheat_menu() MENU_END(); } -static void lcd_led_menu() -{ - MENU_BEGIN(); - - MENU_ITEM_BACK_P(_T(MSG_MAIN));{ - - MENU_ITEM_GCODE_P(_i("Light off"), PSTR("M42 P5 S0"));////MSG_LED_OFF - MENU_ITEM_GCODE_P(_i("Light 25%"), PSTR("M42 P5 S64"));////MSG_LED_25 - MENU_ITEM_GCODE_P(_i("Light 50%"), PSTR("M42 P5 S127"));////MSG_LED_50 - MENU_ITEM_GCODE_P(_i("Light 75%"), PSTR("M42 P5 S190"));////MSG_LED_75 - MENU_ITEM_GCODE_P(_i("Light 100%"), PSTR("M42 P5 S255"));////MSG_LED_100 - } - MENU_END(); -} - static void lcd_support_menu() { typedef struct @@ -6400,7 +6384,6 @@ static void lcd_test_menu() void lcd_resume_print() { lcd_return_to_status(); - lcd_reset_alert_level(); lcd_setstatuspgm(_T(MSG_RESUMING_PRINT)); lcd_reset_alert_level(); //for fan speed error restore_print_from_ram_and_continue(0.0); @@ -6485,7 +6468,6 @@ static void lcd_main_menu() MENU_ITEM_SUBMENU_P(_T(MSG_BABYSTEP_Z), lcd_babystep_z);//8 } - MENU_ITEM_SUBMENU_P(_i("Light"), lcd_led_menu);////MSG_LED if ( moves_planned() || IS_SD_PRINTING || is_usb_printing || (lcd_commands_type == LCD_COMMAND_V2_CAL)) { @@ -6507,14 +6489,7 @@ static void lcd_main_menu() } else { - #ifdef FANCHECK - checkFanSpeed(); //Check manually to get most recent fan speed status - if(fan_check_error == EFCE_OK) - MENU_ITEM_SUBMENU_P(_i("Resume print"), lcd_resume_print);////MSG_RESUME_PRINT - #else - MENU_ITEM_SUBMENU_P(_i("Resume print"), lcd_resume_print);////MSG_RESUME_PRINT - #endif - + MENU_ITEM_SUBMENU_P(_i("Resume print"), lcd_resume_print);////MSG_RESUME_PRINT } MENU_ITEM_SUBMENU_P(_T(MSG_STOP_PRINT), lcd_sdcard_stop); } From 472da9c6cc71f5a997308395ce80c579a04494a1 Mon Sep 17 00:00:00 2001 From: Lino77 Date: Sun, 30 Jun 2019 14:14:48 +0200 Subject: [PATCH 6/6] Revert "Update sm4.c" This reverts commit 15ae9ecce207f777e1f787c39c685e31f13941b9. --- Firmware/sm4.c | 47 ++++++++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/Firmware/sm4.c b/Firmware/sm4.c index f97bfc59..34cf8a3c 100644 --- a/Firmware/sm4.c +++ b/Firmware/sm4.c @@ -36,13 +36,6 @@ //#define E0_STEP_PIN 34 //PC3 (+) -#define XDIR INVERT_X_DIR:!INVERT_X_DIR -#define YDIR INVERT_Y_DIR:!INVERT_Y_DIR -#define ZDIR INVERT_Z_DIR:!INVERT_Z_DIR -#define EDIR INVERT_E0_DIR:!INVERT_E0_DIR - -uint8_t dir_mask = 0x0F^(INVERT_X_DIR | (INVERT_Y_DIR << 1) | (INVERT_Z_DIR << 2) | (INVERT_E0_DIR << 3)); - sm4_stop_cb_t sm4_stop_cb = 0; sm4_update_pos_cb_t sm4_update_pos_cb = 0; @@ -57,15 +50,15 @@ uint8_t sm4_get_dir(uint8_t axis) switch (axis) { #if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3)) - case 0: return (PORTL & 2)?XDIR; - case 1: return (PORTL & 1)?YDIR; - case 2: return (PORTL & 4)?ZDIR; - case 3: return (PORTL & 64)?EDIR; + case 0: return (PORTL & 2)?0:1; + case 1: return (PORTL & 1)?0:1; + case 2: return (PORTL & 4)?0:1; + case 3: return (PORTL & 64)?1:0; #elif ((MOTHERBOARD == BOARD_EINSY_1_0a)) - case 0: return (PORTL & 1)?XDIR; - case 1: return (PORTL & 2)?YDIR; - case 2: return (PORTL & 4)?ZDIR; - case 3: return (PORTL & 64)?EDIR; + case 0: return (PORTL & 1)?1:0; + case 1: return (PORTL & 2)?0:1; + case 2: return (PORTL & 4)?1:0; + case 3: return (PORTL & 64)?0:1; #endif } return 0; @@ -76,15 +69,15 @@ void sm4_set_dir(uint8_t axis, uint8_t dir) switch (axis) { #if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3)) - case 0: if (dir == INVERT_X_DIR) PORTL |= 2; else PORTL &= ~2; break; - case 1: if (dir == INVERT_Y_DIR) PORTL |= 1; else PORTL &= ~1; break; - case 2: if (dir == INVERT_Z_DIR) PORTL |= 4; else PORTL &= ~4; break; - case 3: if (dir == INVERT_E0_DIR) PORTL |= 64; else PORTL &= ~64; break; + case 0: if (!dir) PORTL |= 2; else PORTL &= ~2; break; + case 1: if (!dir) PORTL |= 1; else PORTL &= ~1; break; + case 2: if (!dir) PORTL |= 4; else PORTL &= ~4; break; + case 3: if (dir) PORTL |= 64; else PORTL &= ~64; break; #elif ((MOTHERBOARD == BOARD_EINSY_1_0a)) - case 0: if (dir == INVERT_X_DIR) PORTL |= 1; else PORTL &= ~1; break; - case 1: if (dir == INVERT_Y_DIR) PORTL |= 2; else PORTL &= ~2; break; - case 2: if (dir == INVERT_Z_DIR) PORTL |= 4; else PORTL &= ~4; break; - case 3: if (dir == INVERT_E0_DIR) PORTL |= 64; else PORTL &= ~64; break; + case 0: if (dir) PORTL |= 1; else PORTL &= ~1; break; + case 1: if (!dir) PORTL |= 2; else PORTL &= ~2; break; + case 2: if (dir) PORTL |= 4; else PORTL &= ~4; break; + case 3: if (!dir) PORTL |= 64; else PORTL &= ~64; break; #endif } asm("nop"); @@ -100,13 +93,13 @@ uint8_t sm4_get_dir_bits(void) if (portL & 1) dir_bits |= 2; if (portL & 4) dir_bits |= 4; if (portL & 64) dir_bits |= 8; - dir_bits ^= dir_mask; + dir_bits ^= 0x07; //invert XYZ, do not invert E #elif ((MOTHERBOARD == BOARD_EINSY_1_0a)) if (portL & 1) dir_bits |= 1; if (portL & 2) dir_bits |= 2; if (portL & 4) dir_bits |= 4; if (portL & 64) dir_bits |= 8; - dir_bits ^= dir_mask; + dir_bits ^= 0x0a; //invert YE, do not invert XZ #endif return dir_bits; } @@ -117,13 +110,13 @@ void sm4_set_dir_bits(uint8_t dir_bits) portL &= 0xb8; //set direction bits to zero //TODO -optimize in asm #if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3)) - dir_bits ^= dir_mask; + dir_bits ^= 0x07; //invert XYZ, do not invert E if (dir_bits & 1) portL |= 2; //set X direction bit if (dir_bits & 2) portL |= 1; //set Y direction bit if (dir_bits & 4) portL |= 4; //set Z direction bit if (dir_bits & 8) portL |= 64; //set E direction bit #elif ((MOTHERBOARD == BOARD_EINSY_1_0a)) - dir_bits ^= dir_mask; + dir_bits ^= 0x0a; //invert YE, do not invert XZ if (dir_bits & 1) portL |= 1; //set X direction bit if (dir_bits & 2) portL |= 2; //set Y direction bit if (dir_bits & 4) portL |= 4; //set Z direction bit