Add menu_item_edit_P<uint8_t*> specialization to be used for linearity correction. Works well, but costs about 600..700B of FLASH, needs to be optimized.
This commit is contained in:
parent
5a7c9e3ffd
commit
46a3baac57
@ -9,6 +9,7 @@
|
||||
#include "Configuration.h"
|
||||
#include "Marlin.h"
|
||||
#include "ultralcd.h"
|
||||
#include "language.h"
|
||||
|
||||
|
||||
|
||||
@ -269,6 +270,8 @@ 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%";
|
||||
|
||||
template<typename T>
|
||||
static void menu_draw_P(char chr, const char* str, int16_t val);
|
||||
|
||||
@ -305,6 +308,27 @@ void menu_draw_float13(char chr, const char* str, float val)
|
||||
lcd_printf_P(menu_fmt_float13, 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);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static void _menu_edit_P(void)
|
||||
{
|
||||
@ -350,6 +374,7 @@ uint8_t menu_item_edit_P(const char* str, T pval, int16_t min_val, int16_t max_v
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
|
@ -97,7 +97,7 @@ extern void menu_draw_float31(char chr, const char* str, float val);
|
||||
extern void menu_draw_float13(char chr, const char* str, float val);
|
||||
|
||||
|
||||
#define MENU_ITEM_EDIT_int3_P(str, pval, minval, maxval) do { if (menu_item_edit_P<int16_t*>(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)
|
||||
template <typename T>
|
||||
extern uint8_t menu_item_edit_P(const char* str, T pval, int16_t min_val, int16_t max_val);
|
||||
|
@ -4496,13 +4496,12 @@ void lcd_settings_linearity_correction_menu(void)
|
||||
// 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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user