From 06da2bb91595b4aee6574c9f23b1ba2645230eee Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Thu, 22 Feb 2018 20:50:34 +0100 Subject: [PATCH] Accurate homing, fix - enabled after selftest. Experimantal menu - conditional translation. --- Firmware/Configuration_prusa.h | 1 + Firmware/tmc2130.cpp | 9 +++++---- Firmware/tmc2130.h | 2 +- Firmware/ultralcd.cpp | 12 ++++++++++-- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Firmware/Configuration_prusa.h b/Firmware/Configuration_prusa.h index e13b8753..42f63c96 100644 --- a/Firmware/Configuration_prusa.h +++ b/Firmware/Configuration_prusa.h @@ -135,6 +135,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o #define PLANNER_DIAGNOSTICS // Show the planner queue status on printer display. #endif /* DEBUG_BUILD */ +//#define EXPERIMENTAL_FEATURES /*------------------------------------ TMC2130 default settings diff --git a/Firmware/tmc2130.cpp b/Firmware/tmc2130.cpp index 98ae11e1..cb6c5252 100644 --- a/Firmware/tmc2130.cpp +++ b/Firmware/tmc2130.cpp @@ -672,10 +672,10 @@ uint16_t tmc2130_get_res(uint8_t axis) void tmc2130_set_res(uint8_t axis, uint16_t res) { tmc2130_mres[axis] = tmc2130_usteps2mres(res); - uint32_t u = micros(); +// uint32_t u = micros(); tmc2130_setup_chopper(axis, tmc2130_mres[axis], tmc2130_current_h[axis], tmc2130_current_r[axis]); - u = micros() - u; - printf_P(PSTR("tmc2130_setup_chopper %c %lu us"), "XYZE"[axis], u); +// u = micros() - u; +// printf_P(PSTR("tmc2130_setup_chopper %c %lu us"), "XYZE"[axis], u); } uint8_t tmc2130_get_pwr(uint8_t axis) @@ -948,7 +948,7 @@ uint8_t clusterize_uint8(uint8_t* data, uint8_t size, uint8_t* ccnt, uint8_t* cv return ++cl; } -void tmc2130_home_calibrate(uint8_t axis) +bool tmc2130_home_calibrate(uint8_t axis) { uint8_t step[16]; uint8_t cnt[16]; @@ -967,6 +967,7 @@ void tmc2130_home_calibrate(uint8_t axis) printf_P(PSTR("result value: %d\n"), tmc2130_home_origin[axis]); if (axis == X_AXIS) eeprom_update_byte((uint8_t*)EEPROM_TMC2130_HOME_X_ORIGIN, tmc2130_home_origin[X_AXIS]); else if (axis == Y_AXIS) eeprom_update_byte((uint8_t*)EEPROM_TMC2130_HOME_Y_ORIGIN, tmc2130_home_origin[Y_AXIS]); + return true; } #endif //TMC2130 diff --git a/Firmware/tmc2130.h b/Firmware/tmc2130.h index ee0ce1ba..6dd9f59d 100644 --- a/Firmware/tmc2130.h +++ b/Firmware/tmc2130.h @@ -119,6 +119,6 @@ extern void tmc2130_goto_step(uint8_t axis, uint8_t step, uint8_t dir, uint16_t extern void tmc2130_get_wave(uint8_t axis, uint8_t* data, FILE* stream); extern void tmc2130_set_wave(uint8_t axis, uint8_t amp, uint8_t fac200); -extern void tmc2130_home_calibrate(uint8_t axis); +extern bool tmc2130_home_calibrate(uint8_t axis); #endif //TMC2130_H \ No newline at end of file diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index aec66143..86af480b 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -3953,6 +3953,7 @@ static void lcd_selftest_() lcd_selftest(); } +#ifdef EXPERIMENTAL_FEATURES static void lcd_experimantal_menu(); static void lcd_homing_accuracy_menu(); @@ -4164,6 +4165,7 @@ static void lcd_experimantal_menu() MENU_ITEM(submenu, PSTR("uStep linearity"), lcd_ustep_linearity_menu); END_MENU(); } +#endif //EXPERIMENTAL_FEATURES static void lcd_calibration_menu() @@ -5375,7 +5377,10 @@ static void lcd_main_menu() #endif MENU_ITEM(submenu, MSG_SETTINGS, lcd_settings_menu); if(!isPrintPaused) MENU_ITEM(submenu, MSG_MENU_CALIBRATION, lcd_calibration_menu); + +#ifdef EXPERIMENTAL_FEATURES MENU_ITEM(submenu, PSTR("Experimantal"), lcd_experimantal_menu); +#endif //EXPERIMENTAL_FEATURES } if (!is_usb_printing && (lcd_commands_type != LCD_COMMAND_V2_CAL)) @@ -5940,10 +5945,13 @@ static bool lcd_selftest() if (_result) { _progress = lcd_selftest_screen(13, 0, 2, true, 0); - tmc2130_home_calibrate(X_AXIS); + bool bres = tmc2130_home_calibrate(X_AXIS); _progress = lcd_selftest_screen(13, 1, 2, true, 0); - tmc2130_home_calibrate(Y_AXIS); + bres &= tmc2130_home_calibrate(Y_AXIS); _progress = lcd_selftest_screen(13, 2, 2, true, 0); + if (bres) + eeprom_update_byte((uint8_t*)EEPROM_TMC2130_HOME_ENABLED, 1); + _result = bres; } if (_result)