From 5cac3c9254fcd2e172ba2af19a791438bb2a8dc0 Mon Sep 17 00:00:00 2001 From: metacollin Date: Wed, 17 Oct 2018 06:00:23 -0600 Subject: [PATCH 01/12] Make NEW_XYZCAL respect INVERT_*_DIR #defines. --- Firmware/sm4.c | 47 +++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/Firmware/sm4.c b/Firmware/sm4.c index 509ac23f..319fd5e8 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 47b8462c38253b1bd31813ec890ca3224f1dabfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Thu, 24 Jun 2021 19:04:14 +0000 Subject: [PATCH 02/12] Remove two functions EEPROM_read() and EEPROM_save() --- Firmware/ultralcd.cpp | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 81fef967..d87f2b12 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -4242,37 +4242,16 @@ static void lcd_move_menu_1mm() lcd_move_menu_axis(); } - -void EEPROM_save(int pos, uint8_t* value, uint8_t size) -{ - do - { - eeprom_write_byte((unsigned char*)pos, *value); - pos++; - value++; - } while (--size); -} - -void EEPROM_read(int pos, uint8_t* value, uint8_t size) -{ - do - { - *value = eeprom_read_byte((unsigned char*)pos); - pos++; - value++; - } while (--size); -} - #ifdef SDCARD_SORT_ALPHA static void lcd_sort_type_set() { uint8_t sdSort; - EEPROM_read(EEPROM_SD_SORT, (uint8_t*)&sdSort, sizeof(sdSort)); + sdSort = eeprom_read_byte((uint8_t*) EEPROM_SD_SORT); switch (sdSort) { case SD_SORT_TIME: sdSort = SD_SORT_ALPHA; break; case SD_SORT_ALPHA: sdSort = SD_SORT_NONE; break; default: sdSort = SD_SORT_TIME; } - eeprom_update_byte((unsigned char *)EEPROM_SD_SORT, sdSort); + eeprom_update_byte((uint8_t*)EEPROM_SD_SORT, sdSort); card.presort_flag = true; } #endif //SDCARD_SORT_ALPHA @@ -5272,7 +5251,7 @@ do\ MENU_ITEM_TOGGLE_P(_T(MSG_SD_CARD), _T(MSG_NORMAL), lcd_toshiba_flash_air_compatibility_toggle);\ \ uint8_t sdSort;\ - EEPROM_read(EEPROM_SD_SORT, (uint8_t*)&sdSort, sizeof(sdSort));\ + sdSort = eeprom_read_byte((uint8_t*) EEPROM_SD_SORT);\ switch (sdSort)\ {\ case SD_SORT_TIME: MENU_ITEM_TOGGLE_P(_T(MSG_SORT), _T(MSG_SORT_TIME), lcd_sort_type_set); break;\ @@ -5665,7 +5644,7 @@ void lcd_hw_setup_menu(void) // can not be "static" static void lcd_settings_menu() { - EEPROM_read(EEPROM_SILENT, (uint8_t*)&SilentModeMenu, sizeof(SilentModeMenu)); + SilentModeMenu = eeprom_read_byte((uint8_t*) EEPROM_SILENT); MENU_BEGIN(); MENU_ITEM_BACK_P(_T(MSG_MAIN)); @@ -6872,9 +6851,7 @@ static void lcd_tune_menu() calculate_extruder_multipliers(); } - EEPROM_read(EEPROM_SILENT, (uint8_t*)&SilentModeMenu, sizeof(SilentModeMenu)); - - + SilentModeMenu = eeprom_read_byte((uint8_t*) EEPROM_SILENT); MENU_BEGIN(); MENU_ITEM_BACK_P(_T(MSG_MAIN)); //1 From 13477c65c6678fddd18a4f1977a22153812d9487 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Fri, 2 Jul 2021 20:02:13 +0000 Subject: [PATCH 03/12] Remove two functions EEPROM_read_B() and EEPROM_save_B() This resolves #3218 --- Firmware/Marlin_main.cpp | 55 ++++++++++++++++++++++++++-------------- Firmware/ultralcd.cpp | 32 +++++++---------------- Firmware/ultralcd.h | 2 -- 3 files changed, 45 insertions(+), 44 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index d1bc83a1..a7365025 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1502,7 +1502,9 @@ void setup() #ifdef SNMM if (eeprom_read_dword((uint32_t*)EEPROM_BOWDEN_LENGTH) == 0x0ffffffff) { //bowden length used for SNMM int _z = BOWDEN_LENGTH; - for(int i = 0; i<4; i++) EEPROM_save_B(EEPROM_BOWDEN_LENGTH + i * 2, &_z); + for(uint8_t i = 0; i < 4; i++) { + eeprom_update_word((uint16_t*)EEPROM_BOWDEN_LENGTH + i, _z); + } } #endif @@ -1547,7 +1549,9 @@ void setup() //eeprom_write_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 0); eeprom_write_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 1); int16_t z_shift = 0; - for (uint8_t i = 0; i < 5; i++) EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + i * 2, &z_shift); + for (uint8_t i = 0; i < 5; i++) { + eeprom_update_word((uint16_t*)EEPROM_PROBE_TEMP_SHIFT + i, z_shift); + } eeprom_write_byte((uint8_t*)EEPROM_TEMP_CAL_ACTIVE, 0); } if (eeprom_read_byte((uint8_t*)EEPROM_UVLO) == 255) { @@ -1571,8 +1575,10 @@ void setup() #ifdef PAT9125 fsensor_setup_interrupt(); #endif //PAT9125 - for (int i = 0; i<4; i++) EEPROM_read_B(EEPROM_BOWDEN_LENGTH + i * 2, &bowden_length[i]); - + for (uint8_t i = 0; i < 4; i++) { + bowden_length[i] = eeprom_read_word((uint16_t*) EEPROM_BOWDEN_LENGTH + i); + } + #ifndef DEBUG_DISABLE_STARTMSGS KEEPALIVE_STATE(PAUSED_FOR_USER); @@ -5434,7 +5440,9 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) { float temp = (40 + i * 5); printf_P(_N("\nStep: %d/6 (skipped)\nPINDA temperature: %d Z shift (mm):0\n"), i + 2, (40 + i*5)); - if (i >= 0) EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + i * 2, &z_shift); + if (i >= 0) { + eeprom_update_word((uint16_t*)EEPROM_PROBE_TEMP_SHIFT + i, z_shift); + } if (start_temp <= temp) break; } @@ -5473,7 +5481,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) printf_P(_N("\nPINDA temperature: %.1f Z shift (mm): %.3f"), current_temperature_pinda, current_position[Z_AXIS] - zero_z); - EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + i * 2, &z_shift); + eeprom_update_word((uint16_t*)EEPROM_PROBE_TEMP_SHIFT + i, z_shift); } lcd_temp_cal_show_result(true); homing_flag = false; @@ -5558,7 +5566,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) printf_P(_N("\nTemperature: %d Z shift (mm): %.3f\n"), t_c, current_position[Z_AXIS] - zero_z); - EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + i*2, &z_shift); + eeprom_update_word((uint16_t*)EEPROM_PROBE_TEMP_SHIFT + i, z_shift); } @@ -5680,7 +5688,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) }else{ // Save it to the eeprom babystepLoadZ = babystepz; - EEPROM_save_B(EEPROM_BABYSTEP_Z0+(BabyPosition*2),&babystepLoadZ); + eeprom_update_word((uint16_t*)EEPROM_BABYSTEP_Z0 + BabyPosition, babystepLoadZ); // adjust the Z babystepsTodoZadd(babystepLoadZ); } @@ -8363,7 +8371,9 @@ Sigma_Exit: SERIAL_PROTOCOLLN("index, temp, ustep, um"); for (uint8_t i = 0; i < 6; i++) { - if(i>0) EEPROM_read_B(EEPROM_PROBE_TEMP_SHIFT + (i-1) * 2, &usteps); + if(i > 0) { + usteps = eeprom_read_word((uint16_t*) EEPROM_PROBE_TEMP_SHIFT + (i - 1)); + } float mm = ((float)usteps) / cs.axis_steps_per_unit[Z_AXIS]; i == 0 ? SERIAL_PROTOCOLPGM("n/a") : SERIAL_PROTOCOL(i - 1); SERIAL_PROTOCOLPGM(", "); @@ -8378,21 +8388,23 @@ Sigma_Exit: else if (code_seen('!')) { // ! - Set factory default values eeprom_write_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 1); int16_t z_shift = 8; //40C - 20um - 8usteps - EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT, &z_shift); + eeprom_update_word((uint16_t*)EEPROM_PROBE_TEMP_SHIFT, z_shift); z_shift = 24; //45C - 60um - 24usteps - EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + 2, &z_shift); + eeprom_update_word((uint16_t*)EEPROM_PROBE_TEMP_SHIFT + 1, z_shift); z_shift = 48; //50C - 120um - 48usteps - EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + 4, &z_shift); + eeprom_update_word((uint16_t*)EEPROM_PROBE_TEMP_SHIFT + 2, z_shift); z_shift = 80; //55C - 200um - 80usteps - EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + 6, &z_shift); + eeprom_update_word((uint16_t*)EEPROM_PROBE_TEMP_SHIFT + 3, z_shift); z_shift = 120; //60C - 300um - 120usteps - EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + 8, &z_shift); + eeprom_update_word((uint16_t*)EEPROM_PROBE_TEMP_SHIFT + 4, z_shift); SERIAL_PROTOCOLLN("factory restored"); } else if (code_seen('Z')) { // Z - Set all values to 0 (effectively disabling PINDA temperature compensation) eeprom_write_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 1); int16_t z_shift = 0; - for (uint8_t i = 0; i < 5; i++) EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + i * 2, &z_shift); + for (uint8_t i = 0; i < 5; i++) { + eeprom_update_word((uint16_t*)EEPROM_PROBE_TEMP_SHIFT + i, z_shift); + } SERIAL_PROTOCOLLN("zerorized"); } else if (code_seen('S')) { // Sxxx Iyyy - Set compensation ustep value S for compensation table index I @@ -8400,13 +8412,15 @@ Sigma_Exit: if (code_seen('I')) { uint8_t index = code_value(); if (index < 5) { - EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + index * 2, &usteps); + eeprom_update_word((uint16_t*)EEPROM_PROBE_TEMP_SHIFT + index, usteps); SERIAL_PROTOCOLLN("OK"); SERIAL_PROTOCOLLN("index, temp, ustep, um"); for (uint8_t i = 0; i < 6; i++) { usteps = 0; - if (i>0) EEPROM_read_B(EEPROM_PROBE_TEMP_SHIFT + (i - 1) * 2, &usteps); + if (i > 0) { + usteps = eeprom_read_word((uint16_t*)EEPROM_PROBE_TEMP_SHIFT + (i - 1)); + } float mm = ((float)usteps) / cs.axis_steps_per_unit[Z_AXIS]; i == 0 ? SERIAL_PROTOCOLPGM("n/a") : SERIAL_PROTOCOL(i - 1); SERIAL_PROTOCOLPGM(", "); @@ -10898,7 +10912,7 @@ static void temp_compensation_apply() { if (calibration_status() == CALIBRATION_STATUS_CALIBRATED) { if (target_temperature_bed % 10 == 0 && target_temperature_bed >= 60 && target_temperature_bed <= 100) { i_add = (target_temperature_bed - 60) / 10; - EEPROM_read_B(EEPROM_PROBE_TEMP_SHIFT + i_add * 2, &z_shift); + z_shift = eeprom_read_word((uint16_t*)EEPROM_PROBE_TEMP_SHIFT + i_add); z_shift_mm = z_shift / cs.axis_steps_per_unit[Z_AXIS]; }else { //interpolation @@ -10928,7 +10942,10 @@ float temp_comp_interpolation(float inp_temperature) { shift[0] = 0; for (i = 0; i < n; i++) { - if (i>0) EEPROM_read_B(EEPROM_PROBE_TEMP_SHIFT + (i-1) * 2, &shift[i]); //read shift in steps from EEPROM + if (i > 0) { + //read shift in steps from EEPROM + shift[i] = eeprom_read_word((uint16_t*)EEPROM_PROBE_TEMP_SHIFT + (i - 1)); + } temp_C[i] = 50 + i * 10; //temperature in C #ifdef PINDA_THERMISTOR constexpr int start_compensating_temp = 35; diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index d87f2b12..e01e17df 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -2928,20 +2928,6 @@ static void lcd_menu_xyz_offset() menu_back_if_clicked(); } -// Save a single axis babystep value. -void EEPROM_save_B(int pos, int* value) -{ - eeprom_update_byte((unsigned char*)pos, (unsigned char)((*value) & 0xff)); - eeprom_update_byte((unsigned char*)pos + 1, (unsigned char)((*value) >> 8)); -} - -// Read a single axis babystep value. -void EEPROM_read_B(int pos, int* value) -{ - *value = (int)eeprom_read_byte((unsigned char*)pos) | (int)(eeprom_read_byte((unsigned char*)pos + 1) << 8); -} - - // Note: the colon behind the text (X, Y, Z) is necessary to greatly shorten // the implementation of menu_draw_float31 static void lcd_move_x() { @@ -3211,15 +3197,15 @@ void lcd_adjust_z() { fsm = cursor_pos; if (fsm == 1) { int babystepLoadZ = 0; - EEPROM_read_B(EEPROM_BABYSTEP_Z, &babystepLoadZ); + babystepLoadZ = eeprom_read_word((uint16_t*)EEPROM_BABYSTEP_Z); CRITICAL_SECTION_START babystepsTodo[Z_AXIS] = babystepLoadZ; CRITICAL_SECTION_END } else { int zero = 0; - EEPROM_save_B(EEPROM_BABYSTEP_X, &zero); - EEPROM_save_B(EEPROM_BABYSTEP_Y, &zero); - EEPROM_save_B(EEPROM_BABYSTEP_Z, &zero); + eeprom_update_word((uint16_t*)EEPROM_BABYSTEP_X, zero); + eeprom_update_word((uint16_t*)EEPROM_BABYSTEP_Y, zero); + eeprom_update_word((uint16_t*)EEPROM_BABYSTEP_Z, zero); } _delay(500); } @@ -4213,8 +4199,8 @@ void lcd_pick_babystep(){ if (lcd_clicked()) { fsm = cursor_pos; int babyStepZ; - EEPROM_read_B(EEPROM_BABYSTEP_Z0+((fsm-1)*2),&babyStepZ); - EEPROM_save_B(EEPROM_BABYSTEP_Z,&babyStepZ); + babyStepZ = eeprom_read_word((uint16_t*)EEPROM_BABYSTEP_Z0+(fsm-1)); + eeprom_update_word((uint16_t*)EEPROM_BABYSTEP_Z, babyStepZ); calibration_status_store(CALIBRATION_STATUS_CALIBRATED); _delay(500); @@ -5804,7 +5790,7 @@ void bowden_menu() { lcd_puts_at_P(1, i, PSTR("Extruder ")); lcd_print(i); lcd_print(": "); - EEPROM_read_B(EEPROM_BOWDEN_LENGTH + i * 2, &bowden_length[i]); + bowden_length[i] = eeprom_read_word((uint16_t*)EEPROM_BOWDEN_LENGTH + i); lcd_print(bowden_length[i] - 48); } @@ -5874,7 +5860,7 @@ void bowden_menu() { _delay(100); if (lcd_clicked()) { Sound_MakeSound(e_SOUND_TYPE_ButtonEcho); - EEPROM_save_B(EEPROM_BOWDEN_LENGTH + cursor_pos * 2, &bowden_length[cursor_pos]); + eeprom_update_word((uint16_t*)EEPROM_BOWDEN_LENGTH + cursor_pos, bowden_length[cursor_pos]); if (lcd_show_fullscreen_message_yes_no_and_wait_P(PSTR("Continue with another bowden?"))) { lcd_update_enable(true); lcd_clear(); @@ -5884,7 +5870,7 @@ void bowden_menu() { lcd_puts_at_P(1, i, PSTR("Extruder ")); lcd_print(i); lcd_print(": "); - EEPROM_read_B(EEPROM_BOWDEN_LENGTH + i * 2, &bowden_length[i]); + bowden_length[i] = eeprom_read_word((uint16_t*)EEPROM_BOWDEN_LENGTH + i); lcd_print(bowden_length[i] - 48); } diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index 68b933d0..0b1f0fc6 100755 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -30,8 +30,6 @@ void lcd_adjust_z(); void lcd_pick_babystep(); void lcd_alright(); void show_preheat_nozzle_warning(); -void EEPROM_save_B(int pos, int* value); -void EEPROM_read_B(int pos, int* value); void lcd_wait_interact(); void lcd_loading_filament(); void lcd_change_success(); From 25408d14da2b0b061ee15b1c1e6e008fdc93ad50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Wed, 21 Jul 2021 06:27:44 +0000 Subject: [PATCH 04/12] Remove unused #ifdef MK1BP MK1BP is never defined anywhere --- Firmware/Marlin_main.cpp | 7 ++----- Firmware/ultralcd.cpp | 14 -------------- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 023b646f..450ddea6 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -2901,7 +2901,7 @@ static void gcode_G28(bool home_x_axis, long home_x_value, bool home_y_axis, lon raise_z_above(Z_RAISE_BEFORE_HOMING); st_synchronize(); #endif // defined (Z_RAISE_BEFORE_HOMING) && (Z_RAISE_BEFORE_HOMING > 0) - #if (defined(MESH_BED_LEVELING) && !defined(MK1BP)) // If Mesh bed leveling, move X&Y to safe position for home + #ifdef MESH_BED_LEVELING // If Mesh bed leveling, move X&Y to safe position for home raise_z_above(MESH_HOME_Z_SEARCH); st_synchronize(); if (!axis_known_position[X_AXIS]) homeaxis(X_AXIS); @@ -3015,7 +3015,7 @@ static void gcode_G28(bool home_x_axis, long home_x_value, bool home_y_axis, lon // and correct the current_position XY axes to match the transformed coordinate system. world2machine_update_current(); -#if (defined(MESH_BED_LEVELING) && !defined(MK1BP)) +#ifdef MESH_BED_LEVELING if (home_x_axis || home_y_axis || without_mbl || home_z_axis) { if (! home_z && mbl_was_active) { @@ -5614,9 +5614,6 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) */ case 80: { -#ifdef MK1BP - break; -#endif //MK1BP gcode_G80(); } break; diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 658e6b01..fd8c7b45 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -2035,7 +2035,6 @@ static void lcd_support_menu() } } - #ifndef MK1BP MENU_ITEM_BACK_P(STR_SEPARATOR); MENU_ITEM_SUBMENU_P(_i("XYZ cal. details"), lcd_menu_xyz_y_min);////MSG_XYZ_DETAILS c=18 MENU_ITEM_SUBMENU_P(_i("Extruder info"), lcd_menu_extruder_info);////MSG_INFO_EXTRUDER c=18 @@ -2068,8 +2067,6 @@ static void lcd_support_menu() MENU_ITEM_SUBMENU_P(PSTR("Debug"), lcd_menu_debug);////MSG_DEBUG c=18 #endif /* DEBUG_BUILD */ - #endif //MK1BP - MENU_END(); } @@ -5777,11 +5774,6 @@ static void lcd_calibration_menu() MENU_ITEM_FUNCTION_P(_i("Belt test"), lcd_belttest_v);////MSG_BELTTEST c=18 #endif //TMC2130 MENU_ITEM_FUNCTION_P(_i("Selftest"), lcd_selftest_v);////MSG_SELFTEST c=18 -#ifdef MK1BP - // MK1 - // "Calibrate Z" - MENU_ITEM_GCODE_P(_T(MSG_HOMEYZ), PSTR("G28 Z")); -#else //MK1BP // MK2 MENU_ITEM_FUNCTION_P(_i("Calibrate XYZ"), lcd_mesh_calibration);////MSG_CALIBRATE_BED c=18 // "Calibrate Z" with storing the reference values to EEPROM. @@ -5791,26 +5783,20 @@ static void lcd_calibration_menu() #endif // "Mesh Bed Leveling" MENU_ITEM_SUBMENU_P(_T(MSG_MESH_BED_LEVELING), lcd_mesh_bedleveling); - -#endif //MK1BP MENU_ITEM_SUBMENU_P(_i("Bed level correct"), lcd_adjust_bed);////MSG_BED_CORRECTION_MENU c=18 MENU_ITEM_SUBMENU_P(_i("PID calibration"), pid_extruder);////MSG_PID_EXTRUDER c=17 #ifndef TMC2130 MENU_ITEM_SUBMENU_P(_i("Show end stops"), menu_show_end_stops);////MSG_SHOW_END_STOPS c=18 #endif -#ifndef MK1BP MENU_ITEM_GCODE_P(_i("Reset XYZ calibr."), PSTR("M44"));////MSG_CALIBRATE_BED_RESET c=18 -#endif //MK1BP #ifndef SNMM //MENU_ITEM_FUNCTION_P(MSG_RESET_CALIBRATE_E, lcd_extr_cal_reset); #endif -#ifndef MK1BP if(has_temperature_compensation()) { MENU_ITEM_SUBMENU_P(_i("Temp. calibration"), lcd_pinda_calibration_menu);////MSG_CALIBRATION_PINDA_MENU c=17 } -#endif //MK1BP } MENU_END(); From 21226214a7aa61c58b56ce69429648007486a2ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Wed, 21 Jul 2021 14:06:23 +0000 Subject: [PATCH 05/12] Remove MAX_SILENT_FEEDRATE It was last used on MK2 in 3rd July 2017. I suspect this code was simply forgotten. --- Firmware/Marlin_main.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 450ddea6..d3d87631 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -9628,10 +9628,6 @@ void get_coordinates() } if(code_seen('F')) { next_feedrate = code_value(); -#ifdef MAX_SILENT_FEEDRATE - if (tmc2130_mode == TMC2130_MODE_SILENT) - if (next_feedrate > MAX_SILENT_FEEDRATE) next_feedrate = MAX_SILENT_FEEDRATE; -#endif //MAX_SILENT_FEEDRATE if(next_feedrate > 0.0) feedrate = next_feedrate; if (!seen[0] && !seen[1] && !seen[2] && seen[3]) { From 7e90047bba7554737b5cc11eeb76ac64731b022f Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Sat, 12 Feb 2022 09:41:07 +0100 Subject: [PATCH 06/12] Use eeprom_update_block instead of a for loop Saves 32B --- Firmware/Marlin_main.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 56ec480f..a4f2302b 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1572,9 +1572,7 @@ void setup() #ifdef PAT9125 fsensor_setup_interrupt(); #endif //PAT9125 - for (uint8_t i = 0; i < 4; i++) { - bowden_length[i] = eeprom_read_word((uint16_t*) EEPROM_BOWDEN_LENGTH + i); - } + eeprom_update_block(bowden_length, (uint16_t*)EEPROM_BOWDEN_LENGTH, sizeof(bowden_length)); #ifndef DEBUG_DISABLE_STARTMSGS KEEPALIVE_STATE(PAUSED_FOR_USER); From 70ee06144ebcdd903b74dc3a0f4d1cc194e3bcc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sat, 12 Feb 2022 12:48:39 +0000 Subject: [PATCH 07/12] Add menu back arrow to the Perheat menu All other menus have this arrow on the back button. --- Firmware/ultralcd.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index e90eaa8a..0a5d5196 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -2384,7 +2384,6 @@ static void mFilamentItem_PVB() void mFilamentBack() { - menu_back(); if (eFilamentAction == FilamentAction::AutoLoad || eFilamentAction == FilamentAction::Preheat || eFilamentAction == FilamentAction::Lay1Cal) @@ -2398,13 +2397,16 @@ void lcd_generic_preheat_menu() MENU_BEGIN(); if (!eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE)) { + ON_MENU_LEAVE( + mFilamentBack(); + ); if (eFilamentAction == FilamentAction::Lay1Cal) { - MENU_ITEM_FUNCTION_P(_T(MSG_BACK), mFilamentBack); + MENU_ITEM_BACK_P(_T(MSG_BACK)); } else { - MENU_ITEM_FUNCTION_P(_T(MSG_MAIN), mFilamentBack); + MENU_ITEM_BACK_P(_T(MSG_MAIN)); } } if (farm_mode) From bd3a8355163e58ceb30041885d651489c73ceacd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sat, 12 Feb 2022 14:17:11 +0000 Subject: [PATCH 08/12] Optimise preheat menu's MENU_ITEM_BACK_P Saves 10 bytes of flash memory --- Firmware/ultralcd.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 0a5d5196..6d733bff 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -2400,14 +2400,7 @@ void lcd_generic_preheat_menu() ON_MENU_LEAVE( mFilamentBack(); ); - if (eFilamentAction == FilamentAction::Lay1Cal) - { - MENU_ITEM_BACK_P(_T(MSG_BACK)); - } - else - { - MENU_ITEM_BACK_P(_T(MSG_MAIN)); - } + MENU_ITEM_BACK_P(_T(eFilamentAction == FilamentAction::Lay1Cal ? MSG_BACK : MSG_MAIN)); } if (farm_mode) { From 5ae45d583fd76e9496ef76e4107c0fc0f4a24e62 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Sun, 13 Feb 2022 08:52:27 +0100 Subject: [PATCH 09/12] Fix time remaining not reset on stop print --- Firmware/Marlin_main.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 3663cbe1..b1d4ed75 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -6911,8 +6911,6 @@ Sigma_Exit: #endif } } - //in the end of print set estimated time to end of print and extruders used during print to default values for next print - print_time_remaining_init(); snmm_filaments_used = 0; break; @@ -10188,6 +10186,9 @@ void finishAndDisableSteppers() // state for the next print. la10c_reset(); #endif + + //in the end of print set estimated time to end of print and extruders used during print to default values for next print + print_time_remaining_init(); } #ifdef FAST_PWM_FAN From d89f4e99529bd6718b69a2e9dcc9774647057b52 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Mon, 14 Feb 2022 17:47:47 +0100 Subject: [PATCH 10/12] Fix indentation in the MK3 sensor information screen --- Firmware/ultralcd.cpp | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index e90eaa8a..b934af6b 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -3843,26 +3843,18 @@ static void lcd_show_sensors_state() // Shutter register is an index of LASER shutter time. It is automatically controlled by the chip's internal // auto-exposure algorithm. When the chip is tracking on a good reflection surface, the Shutter is small. // When the chip is tracking on a poor reflection surface, the Shutter is large. Value ranges from 0 to 46. - if (mmu_enabled == false) - { - //if (!fsensor_enabled) - // lcd_puts_P(_N("Filament sensor\n" "is disabled.")); - //else - //{ - if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LcdCommands::Layer1Cal)) - pat9125_update(); - lcd_set_cursor(0, 2); - lcd_printf_P(_N( - "Xd: %3d " - "Yd: %3d\n" ////c=4 - "Int: %3d " ////c=4 - "Shut: %3d" ////c=4 - ), - pat9125_x, pat9125_y, - pat9125_b, pat9125_s - ); - //} - } + if (mmu_enabled == false) + { + // pat9125_update is already called while printing: only update manually when idling + if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LcdCommands::Layer1Cal)) + pat9125_update(); + + lcd_set_cursor(0, 2); + lcd_printf_P(_N("Xd: %3d Yd: %3d\n" + "Int: %3d Shut: %3d"), + pat9125_x, pat9125_y, + pat9125_b, pat9125_s); + } #endif //PAT9125 } From 0c63e0e8dfb6191dad916fde120f0cc486232c6f Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Mon, 14 Feb 2022 17:57:10 +0100 Subject: [PATCH 11/12] Prettify MK3 sensor-info screen --- Firmware/ultralcd.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index b934af6b..5cf00655 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -3797,9 +3797,9 @@ static void lcd_print_state(uint8_t state) //! @code{.unparsed} //! |01234567890123456789| //! |PINDA N/A FINDA N/A| MSG_PINDA c=5 MSG_FINDA c=5 -//! |Fil. sensor N/A| MSG_FSENSOR -//! |Xd 000 Yd 000| MSG_XD -//! |Int 000 Shut 000| +//! |Fil. sensor N/A| MSG_FSENSOR +//! | Xd 000 Yd 000| +//! |Int 000 Shut 000| //! ---------------------- //! @endcode static void lcd_show_sensors_state() @@ -3850,8 +3850,8 @@ static void lcd_show_sensors_state() pat9125_update(); lcd_set_cursor(0, 2); - lcd_printf_P(_N("Xd: %3d Yd: %3d\n" - "Int: %3d Shut: %3d"), + lcd_printf_P(_N(" Xd: %4d Yd: %3d\n" + "Int: %4d Shut: %3d"), pat9125_x, pat9125_y, pat9125_b, pat9125_s); } From 40881f52adfc096e24a419f123d2f44ead470e7b Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Mon, 14 Feb 2022 23:30:08 +0100 Subject: [PATCH 12/12] Prettify lcd_show_sensors_state() v2 Allow to show the full precision of Xd/Yd by rearranging the layout --- Firmware/ultralcd.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 5cf00655..b815ce60 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -3798,8 +3798,8 @@ static void lcd_print_state(uint8_t state) //! |01234567890123456789| //! |PINDA N/A FINDA N/A| MSG_PINDA c=5 MSG_FINDA c=5 //! |Fil. sensor N/A| MSG_FSENSOR -//! | Xd 000 Yd 000| -//! |Int 000 Shut 000| +//! | Int: 000 Xd:+00000| +//! |Shut: 000 Yd:+00000| //! ---------------------- //! @endcode static void lcd_show_sensors_state() @@ -3850,10 +3850,10 @@ static void lcd_show_sensors_state() pat9125_update(); lcd_set_cursor(0, 2); - lcd_printf_P(_N(" Xd: %4d Yd: %3d\n" - "Int: %4d Shut: %3d"), - pat9125_x, pat9125_y, - pat9125_b, pat9125_s); + lcd_printf_P(_N(" Int: %3d Xd:%6d\n" + "Shut: %3d Yd:%6d"), + pat9125_b, pat9125_x, + pat9125_s, pat9125_y); } #endif //PAT9125 }