Merge pull request #1066 from mkbel/fix_linearity_correction_2
Fix linearity correction 2
This commit is contained in:
commit
815167c4b6
@ -9,6 +9,7 @@
|
||||
#include "Configuration.h"
|
||||
#include "Marlin.h"
|
||||
#include "ultralcd.h"
|
||||
#include "language.h"
|
||||
|
||||
|
||||
|
||||
@ -92,7 +93,7 @@ void menu_back(void)
|
||||
}
|
||||
}
|
||||
|
||||
void menu_back_no_reset(void)
|
||||
static void menu_back_no_reset(void)
|
||||
{
|
||||
if (menu_depth > 0)
|
||||
{
|
||||
@ -126,7 +127,7 @@ void menu_submenu(menu_func_t submenu)
|
||||
}
|
||||
}
|
||||
|
||||
void menu_submenu_no_reset(menu_func_t submenu)
|
||||
static void menu_submenu_no_reset(menu_func_t submenu)
|
||||
{
|
||||
if (menu_depth <= MENU_DEPTH_MAX)
|
||||
{
|
||||
@ -164,7 +165,7 @@ int menu_draw_item_printf_P(char type_char, const char* format, ...)
|
||||
}
|
||||
*/
|
||||
|
||||
int menu_draw_item_puts_P(char type_char, const char* str)
|
||||
static int menu_draw_item_puts_P(char type_char, const char* str)
|
||||
{
|
||||
lcd_set_cursor(0, menu_row);
|
||||
int cnt = lcd_printf_P(PSTR("%c%-18S%c"), (lcd_encoder == menu_item)?'>':' ', str, type_char);
|
||||
@ -269,8 +270,13 @@ const char menu_fmt_float31[] PROGMEM = "%c%.12S:%s%+06.1f";
|
||||
|
||||
const char menu_fmt_float13[] PROGMEM = "%c%.12S:%s%+06.3f";
|
||||
|
||||
const char menu_fmt_float13off[] PROGMEM = "%c%.12S:%s%";
|
||||
|
||||
void menu_draw_int3(char chr, const char* str, int16_t val)
|
||||
template<typename T>
|
||||
static void menu_draw_P(char chr, const char* str, int16_t val);
|
||||
|
||||
template<>
|
||||
void menu_draw_P<int16_t*>(char chr, const char* str, int16_t val)
|
||||
{
|
||||
int text_len = strlen_P(str);
|
||||
if (text_len > 15) text_len = 15;
|
||||
@ -280,6 +286,27 @@ void menu_draw_int3(char chr, const char* str, int16_t val)
|
||||
lcd_printf_P(menu_fmt_int3, chr, str, spaces, val);
|
||||
}
|
||||
|
||||
template<>
|
||||
void menu_draw_P<uint8_t*>(char chr, const char* str, int16_t val)
|
||||
{
|
||||
menu_data_edit_t* _md = (menu_data_edit_t*)&(menu_data[0]);
|
||||
int text_len = strlen_P(str);
|
||||
if (text_len > 15) text_len = 15;
|
||||
char spaces[21];
|
||||
strcpy_P(spaces, menu_20x_space);
|
||||
spaces[12 - text_len] = 0;
|
||||
float factor = 1.0 + static_cast<float>(val) / 1000.0;
|
||||
if (val <= _md->minEditValue)
|
||||
{
|
||||
lcd_printf_P(menu_fmt_float13off, chr, str, spaces);
|
||||
lcd_puts_P(_i(" [off]"));
|
||||
}
|
||||
else
|
||||
{
|
||||
lcd_printf_P(menu_fmt_float13, chr, str, spaces, factor);
|
||||
}
|
||||
}
|
||||
|
||||
//draw up to 12 chars of text, ':' and float number in format +123.0
|
||||
void menu_draw_float31(char chr, const char* str, float val)
|
||||
{
|
||||
@ -302,7 +329,8 @@ void menu_draw_float13(char chr, const char* str, float val)
|
||||
lcd_printf_P(menu_fmt_float13, chr, str, spaces, val);
|
||||
}
|
||||
|
||||
void _menu_edit_int3(void)
|
||||
template <typename T>
|
||||
static void _menu_edit_P(void)
|
||||
{
|
||||
menu_data_edit_t* _md = (menu_data_edit_t*)&(menu_data[0]);
|
||||
if (lcd_draw_update)
|
||||
@ -310,16 +338,17 @@ void _menu_edit_int3(void)
|
||||
if (lcd_encoder < _md->minEditValue) lcd_encoder = _md->minEditValue;
|
||||
if (lcd_encoder > _md->maxEditValue) lcd_encoder = _md->maxEditValue;
|
||||
lcd_set_cursor(0, 1);
|
||||
menu_draw_int3(' ', _md->editLabel, (int)lcd_encoder);
|
||||
menu_draw_P<T>(' ', _md->editLabel, (int)lcd_encoder);
|
||||
}
|
||||
if (LCD_CLICKED)
|
||||
{
|
||||
*((int*)(_md->editValue)) = (int)lcd_encoder;
|
||||
*((T)(_md->editValue)) = lcd_encoder;
|
||||
menu_back_no_reset();
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t menu_item_edit_int3(const char* str, int16_t* pval, int16_t min_val, int16_t max_val)
|
||||
template <typename T>
|
||||
uint8_t menu_item_edit_P(const char* str, T pval, int16_t min_val, int16_t max_val)
|
||||
{
|
||||
menu_data_edit_t* _md = (menu_data_edit_t*)&(menu_data[0]);
|
||||
if (menu_item == menu_line)
|
||||
@ -327,11 +356,11 @@ uint8_t menu_item_edit_int3(const char* str, int16_t* pval, int16_t min_val, int
|
||||
if (lcd_draw_update)
|
||||
{
|
||||
lcd_set_cursor(0, menu_row);
|
||||
menu_draw_int3((lcd_encoder == menu_item)?'>':' ', str, *pval);
|
||||
menu_draw_P<T>((lcd_encoder == menu_item)?'>':' ', str, *pval);
|
||||
}
|
||||
if (menu_clicked && (lcd_encoder == menu_item))
|
||||
{
|
||||
menu_submenu_no_reset(_menu_edit_int3);
|
||||
menu_submenu_no_reset(_menu_edit_P<T>);
|
||||
_md->editLabel = str;
|
||||
_md->editValue = pval;
|
||||
_md->minEditValue = min_val;
|
||||
@ -344,6 +373,9 @@ uint8_t menu_item_edit_int3(const char* str, int16_t* pval, int16_t min_val, int
|
||||
return 0;
|
||||
}
|
||||
|
||||
template uint8_t menu_item_edit_P<int16_t*>(const char* str, int16_t *pval, int16_t min_val, int16_t max_val);
|
||||
template uint8_t menu_item_edit_P<uint8_t*>(const char* str, uint8_t *pval, int16_t min_val, int16_t max_val);
|
||||
|
||||
#undef _menu_data
|
||||
|
||||
|
||||
|
@ -55,21 +55,16 @@ extern void menu_end(void);
|
||||
|
||||
extern void menu_back(void);
|
||||
|
||||
extern void menu_back_no_reset(void);
|
||||
|
||||
extern void menu_back_if_clicked(void);
|
||||
|
||||
extern void menu_back_if_clicked_fb(void);
|
||||
|
||||
extern void menu_submenu(menu_func_t submenu);
|
||||
|
||||
extern void menu_submenu_no_reset(menu_func_t submenu);
|
||||
|
||||
extern uint8_t menu_item_ret(void);
|
||||
|
||||
//extern int menu_draw_item_printf_P(char type_char, const char* format, ...);
|
||||
|
||||
extern int menu_draw_item_puts_P(char type_char, const char* str);
|
||||
|
||||
//int menu_draw_item_puts_P_int16(char type_char, const char* str, int16_t val, );
|
||||
|
||||
@ -96,17 +91,16 @@ extern const char menu_fmt_int3[];
|
||||
|
||||
extern const char menu_fmt_float31[];
|
||||
|
||||
extern void menu_draw_int3(char chr, const char* str, int16_t val);
|
||||
|
||||
extern void menu_draw_float31(char chr, const char* str, float val);
|
||||
|
||||
extern void menu_draw_float13(char chr, const char* str, float val);
|
||||
|
||||
extern void _menu_edit_int3(void);
|
||||
|
||||
#define MENU_ITEM_EDIT_int3_P(str, pval, minval, maxval) do { if (menu_item_edit_int3(str, pval, minval, maxval)) return; } while (0)
|
||||
#define MENU_ITEM_EDIT_int3_P(str, pval, minval, maxval) do { if (menu_item_edit_P(str, pval, minval, maxval)) return; } while (0)
|
||||
//#define MENU_ITEM_EDIT_int3_P(str, pval, minval, maxval) MENU_ITEM_EDIT(int3, str, pval, minval, maxval)
|
||||
extern uint8_t menu_item_edit_int3(const char* str, int16_t* pval, int16_t min_val, int16_t max_val);
|
||||
template <typename T>
|
||||
extern uint8_t menu_item_edit_P(const char* str, T pval, int16_t min_val, int16_t max_val);
|
||||
|
||||
|
||||
#endif //_MENU_H
|
||||
|
@ -123,7 +123,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 lcd_settings_linearity_correction_menu_save();
|
||||
|
||||
static void prusa_stat_printerstatus(int _status);
|
||||
static void prusa_stat_farm_number();
|
||||
@ -4488,28 +4488,26 @@ void lcd_wizard(int state) {
|
||||
lcd_return_to_status();
|
||||
lcd_update(2);
|
||||
}
|
||||
/*
|
||||
|
||||
void lcd_settings_linearity_correction_menu(void)
|
||||
{
|
||||
MENU_BEGIN();
|
||||
if (menu_item_back_P(_T(MSG_MAIN)))
|
||||
{
|
||||
lcd_settings_menu_back();
|
||||
return;
|
||||
}
|
||||
// MENU_ITEM_BACK_P(_T(MSG_SETTINGS));
|
||||
MENU_ITEM_BACK_P(_T(MSG_SETTINGS));
|
||||
#ifdef TMC2130_LINEARITY_CORRECTION_XYZ
|
||||
//tmc2130_wave_fac[X_AXIS]
|
||||
int corr[4] = {tmc2130_wave_fac[X_AXIS], tmc2130_wave_fac[Y_AXIS], tmc2130_wave_fac[Z_AXIS], tmc2130_wave_fac[E_AXIS]};
|
||||
|
||||
MENU_ITEM_EDIT_int3_P(_i("X-correct"), &corr[X_AXIS], TMC2130_WAVE_FAC1000_MIN-TMC2130_WAVE_FAC1000_STP, TMC2130_WAVE_FAC1000_MAX);////MSG_EXTRUDER_CORRECTION c=9 r=0
|
||||
MENU_ITEM_EDIT_int3_P(_i("Y-correct"), &corr[Y_AXIS], TMC2130_WAVE_FAC1000_MIN-TMC2130_WAVE_FAC1000_STP, TMC2130_WAVE_FAC1000_MAX);////MSG_EXTRUDER_CORRECTION c=9 r=0
|
||||
MENU_ITEM_EDIT_int3_P(_i("Z-correct"), &corr[Z_AXIS], TMC2130_WAVE_FAC1000_MIN-TMC2130_WAVE_FAC1000_STP, TMC2130_WAVE_FAC1000_MAX);////MSG_EXTRUDER_CORRECTION c=9 r=0
|
||||
MENU_ITEM_EDIT_int3_P(_i("X-correct"), &tmc2130_wave_fac[X_AXIS], TMC2130_WAVE_FAC1000_MIN-TMC2130_WAVE_FAC1000_STP, TMC2130_WAVE_FAC1000_MAX);////MSG_EXTRUDER_CORRECTION c=9 r=0
|
||||
MENU_ITEM_EDIT_int3_P(_i("Y-correct"), &tmc2130_wave_fac[Y_AXIS], TMC2130_WAVE_FAC1000_MIN-TMC2130_WAVE_FAC1000_STP, TMC2130_WAVE_FAC1000_MAX);////MSG_EXTRUDER_CORRECTION c=9 r=0
|
||||
MENU_ITEM_EDIT_int3_P(_i("Z-correct"), &tmc2130_wave_fac[Z_AXIS], TMC2130_WAVE_FAC1000_MIN-TMC2130_WAVE_FAC1000_STP, TMC2130_WAVE_FAC1000_MAX);////MSG_EXTRUDER_CORRECTION c=9 r=0
|
||||
#endif //TMC2130_LINEARITY_CORRECTION_XYZ
|
||||
MENU_ITEM_EDIT_int3_P(_i("E-correct"), &corr[E_AXIS], TMC2130_WAVE_FAC1000_MIN-TMC2130_WAVE_FAC1000_STP, TMC2130_WAVE_FAC1000_MAX);////MSG_EXTRUDER_CORRECTION c=9 r=0
|
||||
MENU_ITEM_EDIT_int3_P(_i("E-correct"), &tmc2130_wave_fac[E_AXIS], TMC2130_WAVE_FAC1000_MIN-TMC2130_WAVE_FAC1000_STP, TMC2130_WAVE_FAC1000_MAX);////MSG_EXTRUDER_CORRECTION c=9 r=0
|
||||
MENU_END();
|
||||
if(menu_leaving)
|
||||
{
|
||||
lcd_settings_linearity_correction_menu_save();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
static void lcd_settings_menu()
|
||||
{
|
||||
EEPROM_read(EEPROM_SILENT, (uint8_t*)&SilentModeMenu, sizeof(SilentModeMenu));
|
||||
@ -4580,7 +4578,7 @@ static void lcd_settings_menu()
|
||||
else MENU_ITEM_SUBMENU_P(_T(MSG_CRASHDETECT_NA), lcd_crash_mode_info);
|
||||
}
|
||||
|
||||
// MENU_ITEM_SUBMENU_P(_i("Lin. correction"), lcd_settings_linearity_correction_menu);
|
||||
MENU_ITEM_SUBMENU_P(_i("Lin. correction"), lcd_settings_linearity_correction_menu);
|
||||
#endif //TMC2130
|
||||
|
||||
if (temp_cal_active == false)
|
||||
@ -4665,8 +4663,8 @@ static void lcd_ustep_linearity_menu_save()
|
||||
}
|
||||
#endif //TMC2130
|
||||
|
||||
/*
|
||||
static void lcd_settings_menu_back()
|
||||
|
||||
static void lcd_settings_linearity_correction_menu_save()
|
||||
{
|
||||
#ifdef TMC2130
|
||||
bool changed = false;
|
||||
@ -4681,10 +4679,8 @@ static void lcd_settings_menu_back()
|
||||
lcd_ustep_linearity_menu_save();
|
||||
if (changed) tmc2130_init();
|
||||
#endif //TMC2130
|
||||
menu_menu = lcd_main_menu;
|
||||
// lcd_main_menu();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
static void lcd_calibration_menu()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user