|
@@ -306,9 +306,9 @@ const char menu_20x_space[] PROGMEM = " ";
|
|
|
|
|
|
const char menu_fmt_int3[] PROGMEM = "%c%.15S:%s%3d";
|
|
const char menu_fmt_int3[] PROGMEM = "%c%.15S:%s%3d";
|
|
|
|
|
|
-const char menu_fmt_float31[] PROGMEM = "%-12.12s%+8.1f";
|
|
|
|
|
|
+const char menu_fmt_float31[] PROGMEM = "%-12.12S%+8.1f";
|
|
|
|
|
|
-const char menu_fmt_float13[] PROGMEM = "%c%.12S:%s%+06.3f";
|
|
|
|
|
|
+const char menu_fmt_float13[] PROGMEM = "%-15.15S%+5.3f";
|
|
|
|
|
|
const char menu_fmt_float13off[] PROGMEM = "%c%.12S:%s%";
|
|
const char menu_fmt_float13off[] PROGMEM = "%c%.12S:%s%";
|
|
|
|
|
|
@@ -348,39 +348,36 @@ void menu_draw_P<uint8_t*>(char chr, const char* str, int16_t val)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-//! Draw up to 10 chars of text, ':' and float number in format from +0.0 to +12345.0. The increased range is necessary
|
|
|
|
|
|
+//! @brief Draw up to 10 chars of text and a float number in format from +0.0 to +12345.0. The increased range is necessary
|
|
//! for displaying large values of extruder positions, which caused text overflow in the previous implementation.
|
|
//! for displaying large values of extruder positions, which caused text overflow in the previous implementation.
|
|
|
|
+//!
|
|
//! @param chr first character to print on the line
|
|
//! @param chr first character to print on the line
|
|
-//! @param str string label to print, will be appended with ':' automatically inside the function
|
|
|
|
|
|
+//! @param str string label to print
|
|
//! @param val value to print aligned to the right side of the display
|
|
//! @param val value to print aligned to the right side of the display
|
|
//!
|
|
//!
|
|
//! Implementation comments:
|
|
//! Implementation comments:
|
|
-//! The text needs to be prerendered into the prerendered[] to enable left alignment of text str including the colon behind it.
|
|
|
|
-//! If we didn't want the colon behind it, the whole operation would have been solved with a single vsprintf call,
|
|
|
|
-//! but such line would look different compared to every other similar menu item
|
|
|
|
-//! So it is almost the same amount of code like before, but with added string prerendering
|
|
|
|
-void menu_draw_float31(char chr, const char* str, float val)
|
|
|
|
|
|
+//! The text needs to come with a colon ":", this function does not append it anymore.
|
|
|
|
+//! That resulted in a much shorter implementation (234628B -> 234476B)
|
|
|
|
+//! There are similar functions around which may be shortened in a similar way
|
|
|
|
+void menu_draw_float31(const char* str, float val)
|
|
{
|
|
{
|
|
- uint8_t txtlen = strlen_P(str);
|
|
|
|
- if( txtlen > 10 )txtlen = 10;
|
|
|
|
- char prerendered[21];
|
|
|
|
- strcpy_P(prerendered, menu_20x_space);
|
|
|
|
- prerendered[0] = chr; // start with the initial byte/space for menu navigation
|
|
|
|
- strncpy_P(prerendered+1, str, 10); // render the text and limit it to max 10 characters
|
|
|
|
- prerendered[txtlen+1] = ':'; // put the colon behind it
|
|
|
|
- prerendered[txtlen+2] = 0; // terminate the string to be used inside the printf
|
|
|
|
- lcd_printf_P(menu_fmt_float31, prerendered, val);
|
|
|
|
|
|
+ lcd_printf_P(menu_fmt_float31, str, val);
|
|
}
|
|
}
|
|
|
|
|
|
-//draw up to 12 chars of text, ':' and float number in format +1.234
|
|
|
|
-void menu_draw_float13(char chr, const char* str, float val)
|
|
|
|
|
|
+//! @brief Draw up to 12 chars of text and a float number in format +1.234
|
|
|
|
+//!
|
|
|
|
+//! @param chr first character to print on the line
|
|
|
|
+//! @param str string label to print
|
|
|
|
+//! @param val value to print aligned to the right side of the display
|
|
|
|
+//!
|
|
|
|
+//! Implementation comments:
|
|
|
|
+//! This function uses similar optimization principles as menu_draw_float31
|
|
|
|
+//! (i.e. str must include a ':' at its end)
|
|
|
|
+//! FLASH usage dropped 234476B -> 234392B
|
|
|
|
+//! Moreover, this function gets inlined in the final code, so removing it doesn't really help ;)
|
|
|
|
+void menu_draw_float13(const char* str, float val)
|
|
{
|
|
{
|
|
- int text_len = strlen_P(str);
|
|
|
|
- if (text_len > 12) text_len = 12;
|
|
|
|
- char spaces[21];
|
|
|
|
- strcpy_P(spaces, menu_20x_space);
|
|
|
|
- spaces[12 - text_len] = 0;
|
|
|
|
- lcd_printf_P(menu_fmt_float13, chr, str, spaces, val);
|
|
|
|
|
|
+ lcd_printf_P(menu_fmt_float13, str, val);
|
|
}
|
|
}
|
|
|
|
|
|
template <typename T>
|
|
template <typename T>
|