Improve editing, fix some small value editing

This commit is contained in:
Scott Lahteine 2019-05-25 15:24:26 -05:00
parent 612eaa87bd
commit 44caf70917
4 changed files with 18 additions and 3 deletions

View File

@ -161,6 +161,18 @@ void safe_delay(millis_t ms) {
return &conv[3];
}
// Convert signed float to fixed-length string with 12.34 / -2.34 format or 123.45 / -23.45 format
char* ftostr42_52(const float &f) {
if (f <= -10 || f >= 100) return ftostr52(f); // need more digits
long i = (f * 1000 + (f < 0 ? -5: 5)) / 10;
conv[2] = (f >= 0 && f < 10) ? ' ' : MINUSOR(i, DIGIMOD(i, 1000));
conv[3] = DIGIMOD(i, 100);
conv[4] = '.';
conv[5] = DIGIMOD(i, 10);
conv[6] = DIGIMOD(i, 1);
return &conv[2];
}
// Convert signed float to fixed-length string with 023.45 / -23.45 format
char* ftostr52(const float &f) {
long i = (f * 1000 + (f < 0 ? -5: 5)) / 10;

View File

@ -82,6 +82,9 @@ inline void serial_delay(const millis_t ms) {
// Convert unsigned float to string with 1.23 format
char* ftostr12ns(const float &x);
// Convert signed float to fixed-length string with 12.34 / -2.34 or 023.45 / -23.45 format
char* ftostr42_52(const float &x);
// Convert signed float to fixed-length string with 023.45 / -23.45 format
char* ftostr52(const float &x);

View File

@ -418,7 +418,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
onpage = PAGE_CONTAINS(baseline - (EDIT_FONT_ASCENT - 1), baseline);
}
if (onpage) {
lcd_moveto(((lcd_chr_fit - 1) - (vallen + 1)) * one_chr_width, baseline); // Right-justified, leaving padded by spaces
lcd_moveto((lcd_chr_fit - (vallen + 1)) * one_chr_width, baseline); // Right-justified, leaving padded by spaces
lcd_put_wchar(' '); // overwrite char if value gets shorter
lcd_put_u8str(value);
}

View File

@ -53,7 +53,7 @@ DECLARE_MENU_EDIT_TYPE(uint8_t, uint8, ui8tostr3, 1 ); // 123
DECLARE_MENU_EDIT_TYPE(uint16_t, uint16_3, ui16tostr3, 1 ); // 123, -12 right-justified
DECLARE_MENU_EDIT_TYPE(uint16_t, uint16_4, ui16tostr4, 0.1 ); // 1234, -123 right-justified
DECLARE_MENU_EDIT_TYPE(float, float3, ftostr3, 1 ); // 123 right-justified
DECLARE_MENU_EDIT_TYPE(float, float52, ftostr52, 100 ); // 123.45, -23.45
DECLARE_MENU_EDIT_TYPE(float, float52, ftostr42_52, 100 ); // _2.34, 12.34, -2.34 or 123.45, -23.45
DECLARE_MENU_EDIT_TYPE(float, float43, ftostr43sign, 1000 ); // 1.234
DECLARE_MENU_EDIT_TYPE(float, float5, ftostr5rj, 0.01f ); // 12345 right-justified
DECLARE_MENU_EDIT_TYPE(float, float5_25, ftostr5rj, 0.04f ); // 12345 right-justified (25 increment)
@ -123,7 +123,7 @@ DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(uint8); // 123 right-justif
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(uint16_3); // 123, -12 right-justified
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(uint16_4); // 1234, -123 right-justified
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float3); // 123 right-justified
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float52); // 123.45, -23.45
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float52); // _2.34, 12.34, -2.34 or 123.45, -23.45
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float43); // 1.234
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float5); // 12345 right-justified
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float5_25); // 12345 right-justified (25 increment)