Explorar o código

Merge pull request #586 from mkbel/ustep_linearity_2

Ustep linearity
XPila %!s(int64=6) %!d(string=hai) anos
pai
achega
06d5ec5659

+ 5 - 5
Firmware/Configuration.h

@@ -158,11 +158,11 @@
 ////////////////////////////////////////
 // TMC2130 uStep linearity correction
 
-// Linearity correction factor (XYZE) encoded as uint8 (0=>1, 1=>1.001, 254=>1.254, 255=>clear eeprom/disabled)
-#define EEPROM_TMC2130_WAVE_X_FAC              (EEPROM_TMC2130_HOME_ENABLED - 1)               // uint8
-#define EEPROM_TMC2130_WAVE_Y_FAC              (EEPROM_TMC2130_WAVE_X_FAC - 1)                 // uint8
-#define EEPROM_TMC2130_WAVE_Z_FAC              (EEPROM_TMC2130_WAVE_Y_FAC - 1)                 // uint8
-#define EEPROM_TMC2130_WAVE_E_FAC              (EEPROM_TMC2130_WAVE_Z_FAC - 1)                 // uint8
+// Linearity correction factor (XYZE)
+#define EEPROM_TMC2130_WAVE_X_FAC              (EEPROM_TMC2130_HOME_ENABLED - 2)               // uint16
+#define EEPROM_TMC2130_WAVE_Y_FAC              (EEPROM_TMC2130_WAVE_X_FAC - 2)                 // uint16
+#define EEPROM_TMC2130_WAVE_Z_FAC              (EEPROM_TMC2130_WAVE_Y_FAC - 2)                 // uint16
+#define EEPROM_TMC2130_WAVE_E_FAC              (EEPROM_TMC2130_WAVE_Z_FAC - 2)                 // uint16
 
 
 ////////////////////////////////////////

+ 1 - 1
Firmware/Configuration_prusa.h

@@ -167,7 +167,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
 #endif /* DEBUG_BUILD */
 
 //#define EXPERIMENTAL_FEATURES
-//#define TMC2130_LINEARITY_CORRECTION
+#define TMC2130_LINEARITY_CORRECTION
 //#define TMC2130_VARIABLE_RESOLUTION
 
 

+ 38 - 6
Firmware/Dcodes.cpp

@@ -470,8 +470,40 @@ void dcode_12()
 
 #ifdef TMC2130
 #include "planner.h"
-extern void st_synchronize();
 #include "tmc2130.h"
+extern void st_synchronize();
+/**
+ * @brief D2130 Trinamic stepper controller
+ * D2130<axis><command>[subcommand][value]
+ *  * Axis
+ *  * * 'X'
+ *  * * 'Y'
+ *  * * 'Z'
+ *  * * 'E'
+ *  * command
+ *  * * '0' current off
+ *  * * '1' current on
+ *  * * '+' single step
+ *  * * * value sereval steps
+ *  * * '-' dtto oposite direction
+ *  * * '?' read register
+ *  * * * "mres"
+ *  * * * "step"
+ *  * * * "mscnt"
+ *  * * * "mscuract"
+ *  * * * "wave"
+ *  * * '!' set register
+ *  * * * "mres"
+ *  * * * "step"
+ *  * * * "wave"
+ *  * * * *0, 180..250 meaning: off, 0.9..1.25, recommended value is 1.1
+ *  * * '@' home calibrate axis
+ *
+ *  Example:
+ *  D2130E?wave //print extruder microstep linearity compensation curve
+ *  D2130E!wave0 //disable extruder linearity compensation curve, (sine curve is used)
+ *  D2130E!wave220 // (sin(x))^1.1 extruder microstep compensation curve used
+ */
 void dcode_2130()
 {
 	printf_P(PSTR("D2130 - TMC2130\n"));
@@ -558,11 +590,11 @@ void dcode_2130()
 			}
 			else if (strncmp(strchr_pointer + 7, "wave", 4) == 0)
 			{
-				uint8_t fac200 = atoi(strchr_pointer + 11) & 0xff;
-				if (fac200 < TMC2130_WAVE_FAC200_MIN) fac200 = 0;
-				if (fac200 > TMC2130_WAVE_FAC200_MAX) fac200 = TMC2130_WAVE_FAC200_MAX;
-				tmc2130_set_wave(axis, 247, fac200);
-				tmc2130_wave_fac[axis] = fac200;
+				uint16_t fac1000 = atoi(strchr_pointer + 11) & 0xffff;
+				if (fac1000 < TMC2130_WAVE_FAC1000_MIN) fac1000 = 0;
+				if (fac1000 > TMC2130_WAVE_FAC1000_MAX) fac1000 = TMC2130_WAVE_FAC1000_MAX;
+				tmc2130_set_wave(axis, 247, fac1000);
+				tmc2130_wave_fac[axis] = fac1000;
 			}
 		}
 		else if (strchr_pointer[1+5] == '@')

+ 10 - 8
Firmware/Marlin_main.cpp

@@ -1072,14 +1072,16 @@ void setup()
 	}
 
 #ifdef TMC2130_LINEARITY_CORRECTION
-	tmc2130_wave_fac[X_AXIS] = eeprom_read_byte((uint8_t*)EEPROM_TMC2130_WAVE_X_FAC);
-	tmc2130_wave_fac[Y_AXIS] = eeprom_read_byte((uint8_t*)EEPROM_TMC2130_WAVE_Y_FAC);
-	tmc2130_wave_fac[Z_AXIS] = eeprom_read_byte((uint8_t*)EEPROM_TMC2130_WAVE_Z_FAC);
-	tmc2130_wave_fac[E_AXIS] = eeprom_read_byte((uint8_t*)EEPROM_TMC2130_WAVE_E_FAC);
-	if (tmc2130_wave_fac[X_AXIS] == 0xff) tmc2130_wave_fac[X_AXIS] = 0;
-	if (tmc2130_wave_fac[Y_AXIS] == 0xff) tmc2130_wave_fac[Y_AXIS] = 0;
-	if (tmc2130_wave_fac[Z_AXIS] == 0xff) tmc2130_wave_fac[Z_AXIS] = 0;
-	if (tmc2130_wave_fac[E_AXIS] == 0xff) tmc2130_wave_fac[E_AXIS] = 0;
+#ifdef EXPERIMENTAL_FEATURES
+	tmc2130_wave_fac[X_AXIS] = eeprom_read_word((uint16_t*)EEPROM_TMC2130_WAVE_X_FAC);
+	tmc2130_wave_fac[Y_AXIS] = eeprom_read_word((uint16_t*)EEPROM_TMC2130_WAVE_Y_FAC);
+	tmc2130_wave_fac[Z_AXIS] = eeprom_read_word((uint16_t*)EEPROM_TMC2130_WAVE_Z_FAC);
+#endif //EXPERIMENTAL_FEATURES
+	tmc2130_wave_fac[E_AXIS] = eeprom_read_word((uint16_t*)EEPROM_TMC2130_WAVE_E_FAC);
+	if (tmc2130_wave_fac[X_AXIS] == 0xffff) tmc2130_wave_fac[X_AXIS] = 0;
+	if (tmc2130_wave_fac[Y_AXIS] == 0xffff) tmc2130_wave_fac[Y_AXIS] = 0;
+	if (tmc2130_wave_fac[Z_AXIS] == 0xffff) tmc2130_wave_fac[Z_AXIS] = 0;
+	if (tmc2130_wave_fac[E_AXIS] == 0xffff) tmc2130_wave_fac[E_AXIS] = 0;
 #endif //TMC2130_LINEARITY_CORRECTION
 
 #ifdef TMC2130_VARIABLE_RESOLUTION

+ 0 - 0
Firmware/langtool.pl


+ 10 - 0
Firmware/language_all.cpp

@@ -627,6 +627,16 @@ const char * const MSG_EXTRUDER_4_LANG_TABLE[1] PROGMEM = {
 	MSG_EXTRUDER_4_EN
 };
 
+const char MSG_EXTRUDER_CORRECTION_EN[] PROGMEM = "E-correct";
+const char * const MSG_EXTRUDER_CORRECTION_LANG_TABLE[1] PROGMEM = {
+	MSG_EXTRUDER_CORRECTION_EN
+};
+
+const char MSG_EXTRUDER_CORRECTION_OFF_EN[] PROGMEM = "  [off";
+const char * const MSG_EXTRUDER_CORRECTION_OFF_LANG_TABLE[1] PROGMEM = {
+	MSG_EXTRUDER_CORRECTION_OFF_EN
+};
+
 const char MSG_E_CAL_KNOB_EN[] PROGMEM = "Rotate knob until mark reaches extruder body. Click when done.";
 const char MSG_E_CAL_KNOB_CZ[] PROGMEM = "Otacejte tlacitkem dokud znacka nedosahne tela extruderu. Potvrdte tlacitkem.";
 const char * const MSG_E_CAL_KNOB_LANG_TABLE[LANG_NUM] PROGMEM = {

+ 4 - 0
Firmware/language_all.h

@@ -222,6 +222,10 @@ extern const char* const MSG_EXTRUDER_3_LANG_TABLE[1];
 #define MSG_EXTRUDER_3 LANG_TABLE_SELECT_EXPLICIT(MSG_EXTRUDER_3_LANG_TABLE, 0)
 extern const char* const MSG_EXTRUDER_4_LANG_TABLE[1];
 #define MSG_EXTRUDER_4 LANG_TABLE_SELECT_EXPLICIT(MSG_EXTRUDER_4_LANG_TABLE, 0)
+extern const char* const MSG_EXTRUDER_CORRECTION_LANG_TABLE[1];
+#define MSG_EXTRUDER_CORRECTION LANG_TABLE_SELECT_EXPLICIT(MSG_EXTRUDER_CORRECTION_LANG_TABLE, 0)
+extern const char* const MSG_EXTRUDER_CORRECTION_OFF_LANG_TABLE[1];
+#define MSG_EXTRUDER_CORRECTION_OFF LANG_TABLE_SELECT_EXPLICIT(MSG_EXTRUDER_CORRECTION_OFF_LANG_TABLE, 0)
 extern const char* const MSG_E_CAL_KNOB_LANG_TABLE[LANG_NUM];
 #define MSG_E_CAL_KNOB LANG_TABLE_SELECT(MSG_E_CAL_KNOB_LANG_TABLE)
 extern const char* const MSG_Enqueing_LANG_TABLE[1];

+ 2 - 0
Firmware/language_en.h

@@ -360,6 +360,8 @@
 #define MSG_FSENSOR_OFF											"Fil. sensor [off]"
 #define MSG_FSENSOR_NA											"Fil. sensor [N/A]"
 #define MSG_FSENSOR_ON											"Fil. sensor  [on]"
+#define(length=9)MSG_EXTRUDER_CORRECTION                        "E-correct"
+#define(length=6)MSG_EXTRUDER_CORRECTION_OFF                    "  [off"
 
 #define(length=20, lines=4) MSG_PLACE_STEEL_SHEET				"Please place steel sheet on heatbed."
 #define(length=20, lines=4) MSG_REMOVE_STEEL_SHEET				"Please remove steel sheet from heatbed."

+ 6 - 6
Firmware/tmc2130.cpp

@@ -58,7 +58,7 @@ uint8_t tmc2130_home_origin[2] = {0, 0};
 uint8_t tmc2130_home_bsteps[2] = {48, 48};
 uint8_t tmc2130_home_fsteps[2] = {48, 48};
 
-uint8_t tmc2130_wave_fac[4] = {0, 0, 0, 0};
+uint16_t tmc2130_wave_fac[4] = {0, 0, 0, 0};
 
 bool tmc2130_sg_stop_on_crash = true;
 uint8_t tmc2130_sg_diag_mask = 0x00;
@@ -825,14 +825,14 @@ void tmc2130_get_wave(uint8_t axis, uint8_t* data, FILE* stream)
 	tmc2130_setup_chopper(axis, tmc2130_mres[axis], tmc2130_current_h[axis], tmc2130_current_r[axis]);
 }
 
-void tmc2130_set_wave(uint8_t axis, uint8_t amp, uint8_t fac200)
+void tmc2130_set_wave(uint8_t axis, uint8_t amp, uint16_t fac1000)
 {
 // TMC2130 wave compression algorithm
 // optimized for minimal memory requirements
-	printf_P(PSTR("tmc2130_set_wave %d %d\n"), axis, fac200);
-	if (fac200 < TMC2130_WAVE_FAC200_MIN) fac200 = 0;
-	if (fac200 > TMC2130_WAVE_FAC200_MAX) fac200 = TMC2130_WAVE_FAC200_MAX;
-	float fac = (float)fac200/200; //correction factor
+	printf_P(PSTR("tmc2130_set_wave %d %d\n"), axis, fac1000);
+	if (fac1000 < TMC2130_WAVE_FAC1000_MIN) fac1000 = 0;
+	if (fac1000 > TMC2130_WAVE_FAC1000_MAX) fac1000 = TMC2130_WAVE_FAC1000_MAX;
+	float fac = (float)fac1000/1000; //correction factor
 	uint8_t vA = 0;                //value of currentA
 	uint8_t va = 0;                //previous vA
 	uint8_t d0 = 0;                //delta0

+ 6 - 6
Firmware/tmc2130.h

@@ -23,16 +23,16 @@ extern uint32_t tmc2130_sg_meassure_val;
 #define TMC2130_MODE_NORMAL 0
 #define TMC2130_MODE_SILENT 1
 
-#define TMC2130_WAVE_FAC200_MIN 180
-#define TMC2130_WAVE_FAC200_MAX 250
-#define TMC2130_WAVE_FAC200_STP   1
+#define TMC2130_WAVE_FAC1000_MIN 900
+#define TMC2130_WAVE_FAC1000_MAX 1250
+#define TMC2130_WAVE_FAC1000_STP   1
 
 extern uint8_t tmc2130_home_enabled;
 extern uint8_t tmc2130_home_origin[2];
 extern uint8_t tmc2130_home_bsteps[2];
 extern uint8_t tmc2130_home_fsteps[2];
 
-extern uint8_t tmc2130_wave_fac[4];
+extern uint16_t tmc2130_wave_fac[4];
 
 
 //initialize tmc2130
@@ -117,8 +117,8 @@ extern void tmc2130_do_step(uint8_t axis);
 extern void tmc2130_do_steps(uint8_t axis, uint16_t steps, uint8_t dir, uint16_t delay_us);
 extern void tmc2130_goto_step(uint8_t axis, uint8_t step, uint8_t dir, uint16_t delay_us, uint16_t microstep_resolution);
 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_set_wave(uint8_t axis, uint8_t amp, uint16_t fac1000);
 
 extern bool tmc2130_home_calibrate(uint8_t axis);
 
-#endif //TMC2130_H
+#endif //TMC2130_H

+ 56 - 41
Firmware/ultralcd.cpp

@@ -210,6 +210,7 @@ static void lcd_control_temperature_preheat_pla_settings_menu();
 static void lcd_control_temperature_preheat_abs_settings_menu();
 static void lcd_control_motion_menu();
 static void lcd_control_volumetric_menu();
+static void lcd_settings_menu_back();
 
 static void prusa_stat_printerstatus(int _status);
 static void prusa_stat_farm_number();
@@ -245,7 +246,7 @@ static void menu_action_setlang(unsigned char lang);
 static void menu_action_sdfile(const char* filename, char* longFilename);
 static void menu_action_sddirectory(const char* filename, char* longFilename);
 static void menu_action_setting_edit_bool(const char* pstr, bool* ptr);
-static void menu_action_setting_edit_wfac(const char* pstr, uint8_t* ptr, uint8_t minValue, uint8_t maxValue);
+static void menu_action_setting_edit_wfac(const char* pstr, uint16_t* ptr, uint16_t minValue, uint16_t maxValue);
 static void menu_action_setting_edit_mres(const char* pstr, uint8_t* ptr, uint8_t minValue, uint8_t maxValue);
 static void menu_action_setting_edit_byte3(const char* pstr, uint8_t* ptr, uint8_t minValue, uint8_t maxValue);
 static void menu_action_setting_edit_int3(const char* pstr, int* ptr, int minValue, int maxValue);
@@ -3968,7 +3969,7 @@ static void lcd_settings_menu()
   EEPROM_read(EEPROM_SILENT, (uint8_t*)&SilentModeMenu, sizeof(SilentModeMenu));
   START_MENU();
 
-  MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
+  MENU_ITEM(back, MSG_MAIN, lcd_settings_menu_back);
 
   MENU_ITEM(submenu, MSG_TEMPERATURE, lcd_control_temperature_menu);
   if (!homing_flag)
@@ -4034,6 +4035,7 @@ static void lcd_settings_menu()
     else MENU_ITEM(function, MSG_CRASHDETECT_ON, lcd_crash_mode_set);
   }
   else MENU_ITEM(submenu, MSG_CRASHDETECT_NA, lcd_crash_mode_info);
+  MENU_ITEM_EDIT(wfac, MSG_EXTRUDER_CORRECTION,  &tmc2130_wave_fac[E_AXIS],  TMC2130_WAVE_FAC1000_MIN-TMC2130_WAVE_FAC1000_STP, TMC2130_WAVE_FAC1000_MAX);
 #endif //TMC2130
 
   if (temp_cal_active == false) {
@@ -4089,6 +4091,23 @@ static void lcd_selftest_()
 	lcd_selftest();
 }
 
+static void lcd_ustep_linearity_menu_save()
+{
+    eeprom_update_word((uint16_t*)EEPROM_TMC2130_WAVE_X_FAC, tmc2130_wave_fac[X_AXIS]);
+    eeprom_update_word((uint16_t*)EEPROM_TMC2130_WAVE_Y_FAC, tmc2130_wave_fac[Y_AXIS]);
+    eeprom_update_word((uint16_t*)EEPROM_TMC2130_WAVE_Z_FAC, tmc2130_wave_fac[Z_AXIS]);
+    eeprom_update_word((uint16_t*)EEPROM_TMC2130_WAVE_E_FAC, tmc2130_wave_fac[E_AXIS]);
+}
+static void lcd_settings_menu_back()
+{
+    bool changed = false;
+    if (tmc2130_wave_fac[E_AXIS] < TMC2130_WAVE_FAC1000_MIN) tmc2130_wave_fac[E_AXIS] = 0;
+    changed |= (eeprom_read_word((uint16_t*)EEPROM_TMC2130_WAVE_E_FAC) != tmc2130_wave_fac[E_AXIS]);
+    lcd_ustep_linearity_menu_save();
+    if (changed) tmc2130_init();
+    currentMenu = lcd_main_menu;
+    lcd_main_menu();
+}
 #ifdef EXPERIMENTAL_FEATURES
 
 static void lcd_experimantal_menu();
@@ -4219,25 +4238,19 @@ static void lcd_ustep_resolution_menu()
 	END_MENU();
 }
 
-static void lcd_ustep_linearity_menu_save()
-{
-	eeprom_update_byte((uint8_t*)EEPROM_TMC2130_WAVE_X_FAC, tmc2130_wave_fac[X_AXIS]);
-	eeprom_update_byte((uint8_t*)EEPROM_TMC2130_WAVE_Y_FAC, tmc2130_wave_fac[Y_AXIS]);
-	eeprom_update_byte((uint8_t*)EEPROM_TMC2130_WAVE_Z_FAC, tmc2130_wave_fac[Z_AXIS]);
-	eeprom_update_byte((uint8_t*)EEPROM_TMC2130_WAVE_E_FAC, tmc2130_wave_fac[E_AXIS]);
-}
+
 
 static void lcd_ustep_linearity_menu_back()
 {
 	bool changed = false;
-	if (tmc2130_wave_fac[X_AXIS] < TMC2130_WAVE_FAC200_MIN) tmc2130_wave_fac[X_AXIS] = 0;
-	if (tmc2130_wave_fac[Y_AXIS] < TMC2130_WAVE_FAC200_MIN) tmc2130_wave_fac[Y_AXIS] = 0;
-	if (tmc2130_wave_fac[Z_AXIS] < TMC2130_WAVE_FAC200_MIN) tmc2130_wave_fac[Z_AXIS] = 0;
-	if (tmc2130_wave_fac[E_AXIS] < TMC2130_WAVE_FAC200_MIN) tmc2130_wave_fac[E_AXIS] = 0;
-	changed |= (eeprom_read_byte((uint8_t*)EEPROM_TMC2130_WAVE_X_FAC) != tmc2130_wave_fac[X_AXIS]);
-	changed |= (eeprom_read_byte((uint8_t*)EEPROM_TMC2130_WAVE_Y_FAC) != tmc2130_wave_fac[Y_AXIS]);
-	changed |= (eeprom_read_byte((uint8_t*)EEPROM_TMC2130_WAVE_Z_FAC) != tmc2130_wave_fac[Z_AXIS]);
-	changed |= (eeprom_read_byte((uint8_t*)EEPROM_TMC2130_WAVE_E_FAC) != tmc2130_wave_fac[E_AXIS]);
+	if (tmc2130_wave_fac[X_AXIS] < TMC2130_WAVE_FAC1000_MIN) tmc2130_wave_fac[X_AXIS] = 0;
+	if (tmc2130_wave_fac[Y_AXIS] < TMC2130_WAVE_FAC1000_MIN) tmc2130_wave_fac[Y_AXIS] = 0;
+	if (tmc2130_wave_fac[Z_AXIS] < TMC2130_WAVE_FAC1000_MIN) tmc2130_wave_fac[Z_AXIS] = 0;
+	if (tmc2130_wave_fac[E_AXIS] < TMC2130_WAVE_FAC1000_MIN) tmc2130_wave_fac[E_AXIS] = 0;
+	changed |= (eeprom_read_word((uint16_t*)EEPROM_TMC2130_WAVE_X_FAC) != tmc2130_wave_fac[X_AXIS]);
+	changed |= (eeprom_read_word((uint16_t*)EEPROM_TMC2130_WAVE_Y_FAC) != tmc2130_wave_fac[Y_AXIS]);
+	changed |= (eeprom_read_word((uint16_t*)EEPROM_TMC2130_WAVE_Z_FAC) != tmc2130_wave_fac[Z_AXIS]);
+	changed |= (eeprom_read_word((uint16_t*)EEPROM_TMC2130_WAVE_E_FAC) != tmc2130_wave_fac[E_AXIS]);
 	lcd_ustep_linearity_menu_save();
 	if (changed) tmc2130_init();
 	currentMenu = lcd_experimantal_menu;
@@ -4267,10 +4280,10 @@ static void lcd_ustep_linearity_menu()
 	MENU_ITEM(back, PSTR("Experimental"), lcd_ustep_linearity_menu_back);
 	MENU_ITEM(function, PSTR("Reset correction"), lcd_ustep_linearity_menu_reset);
 	MENU_ITEM(function, PSTR("Recomended config"), lcd_ustep_linearity_menu_recomended);
-	MENU_ITEM_EDIT(wfac, PSTR("X-correction"),  &tmc2130_wave_fac[X_AXIS],  TMC2130_WAVE_FAC200_MIN-TMC2130_WAVE_FAC200_STP, TMC2130_WAVE_FAC200_MAX);
-	MENU_ITEM_EDIT(wfac, PSTR("Y-correction"),  &tmc2130_wave_fac[Y_AXIS],  TMC2130_WAVE_FAC200_MIN-TMC2130_WAVE_FAC200_STP, TMC2130_WAVE_FAC200_MAX);
-	MENU_ITEM_EDIT(wfac, PSTR("Z-correction"),  &tmc2130_wave_fac[Z_AXIS],  TMC2130_WAVE_FAC200_MIN-TMC2130_WAVE_FAC200_STP, TMC2130_WAVE_FAC200_MAX);
-	MENU_ITEM_EDIT(wfac, PSTR("E-correction"),  &tmc2130_wave_fac[E_AXIS],  TMC2130_WAVE_FAC200_MIN-TMC2130_WAVE_FAC200_STP, TMC2130_WAVE_FAC200_MAX);
+	MENU_ITEM_EDIT(wfac, PSTR("X-correction"),  &tmc2130_wave_fac[X_AXIS],  TMC2130_WAVE_FAC1000_MIN-TMC2130_WAVE_FAC1000_STP, TMC2130_WAVE_FAC1000_MAX);
+	MENU_ITEM_EDIT(wfac, PSTR("Y-correction"),  &tmc2130_wave_fac[Y_AXIS],  TMC2130_WAVE_FAC1000_MIN-TMC2130_WAVE_FAC1000_STP, TMC2130_WAVE_FAC1000_MAX);
+	MENU_ITEM_EDIT(wfac, PSTR("Z-correction"),  &tmc2130_wave_fac[Z_AXIS],  TMC2130_WAVE_FAC1000_MIN-TMC2130_WAVE_FAC1000_STP, TMC2130_WAVE_FAC1000_MAX);
+	MENU_ITEM_EDIT(wfac, PSTR("E-correction"),  &tmc2130_wave_fac[E_AXIS],  TMC2130_WAVE_FAC1000_MIN-TMC2130_WAVE_FAC1000_STP, TMC2130_WAVE_FAC1000_MAX);
 	END_MENU();
 }
 
@@ -6086,21 +6099,21 @@ char *mres_to_str3(const uint8_t &x)
 extern char conv[8];
 
 // Convert tmc2130 wfac to string 
-char *wfac_to_str5(const uint8_t &x)
-{
-#ifdef TMC2130
-	if (x>=TMC2130_WAVE_FAC200_MIN) return ftostr43(((float)(x & 0xff))/200);
-	conv[0] = ' ';
-	conv[1] = ' ';
-	conv[2] = 'O';
-	conv[3] = 'f';
-	conv[4] = 'f';
-	conv[5] = 0;
-#endif //TMC2130
+char *wfac_to_str5(const uint16_t &x)
+{
+	if (x>=TMC2130_WAVE_FAC1000_MIN)
+	    {
+	    conv[0] = '[';
+	    ftostr43(((float)(x & 0xffff)/1000),1);
+	    }
+	else strcpy_P(conv,MSG_EXTRUDER_CORRECTION_OFF);
+	conv[6] = ']';
+	conv[7] = ' ';
+	conv[8] = 0;
 	return conv;
 }
 
-menu_edit_type(uint8_t, wfac, wfac_to_str5, 1)
+menu_edit_type(uint16_t, wfac, wfac_to_str5, 1)
 menu_edit_type(uint8_t, mres, mres_to_str3, 1)
 menu_edit_type(uint8_t, byte3, itostr3, 1)
 menu_edit_type(int, int3, itostr3, 1)
@@ -7769,19 +7782,21 @@ char *ftostr32ns(const float &x) {
 
 
 // Convert float to string with 1.234 format
-char *ftostr43(const float &x)
+char *ftostr43(const float &x, uint8_t offset)
 {
+  const size_t maxOffset = sizeof(conv)/sizeof(conv[0]) - 6;
+  if (offset>maxOffset) offset = maxOffset;
   long xx = x * 1000;
   if (xx >= 0)
-    conv[0] = (xx / 1000) % 10 + '0';
+    conv[offset] = (xx / 1000) % 10 + '0';
   else
-    conv[0] = '-';
+    conv[offset] = '-';
   xx = abs(xx);
-  conv[1] = '.';
-  conv[2] = (xx / 100) % 10 + '0';
-  conv[3] = (xx / 10) % 10 + '0';
-  conv[4] = (xx) % 10 + '0';
-  conv[5] = 0;
+  conv[offset + 1] = '.';
+  conv[offset + 2] = (xx / 100) % 10 + '0';
+  conv[offset + 3] = (xx / 10) % 10 + '0';
+  conv[offset + 4] = (xx) % 10 + '0';
+  conv[offset + 5] = 0;
   return conv;
 }
 

+ 2 - 2
Firmware/ultralcd.h

@@ -204,7 +204,7 @@ char *ftostr31ns(const float &x); // float to string without sign character
 char *ftostr31(const float &x);
 char *ftostr32(const float &x);
 char *ftostr32ns(const float &x);
-char *ftostr43(const float &x);
+char *ftostr43(const float &x, uint8_t offset = 0);
 char *ftostr12ns(const float &x);
 char *ftostr13ns(const float &x);
 char *ftostr32sp(const float &x); // remove zero-padding from ftostr32
@@ -295,4 +295,4 @@ void lcd_wizard(int state);
 static void lcd_send_status();
 static void lcd_connect_printer();
 
-#endif //ULTRALCD_H
+#endif //ULTRALCD_H

+ 1 - 1
Firmware/ultralcd_implementation_hitachi_HD44780.h

@@ -1145,7 +1145,7 @@ static void lcd_implementation_drawmenu_setting_edit_generic_P(uint8_t row, cons
 }
 
 
-extern char *wfac_to_str5(const uint8_t &x);
+extern char *wfac_to_str5(const uint16_t &x);
 extern char *mres_to_str3(const uint8_t &x);
 
 #define lcd_implementation_drawmenu_setting_edit_wfac_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', wfac_to_str5(*(data)))