Reduce math library code size by 3.4KB (#21575)

This commit is contained in:
Scott Lahteine
2021-04-12 16:49:53 -05:00
committed by GitHub
parent 1742fb8655
commit 24a095c5c1
35 changed files with 141 additions and 145 deletions

View File

@ -1457,7 +1457,7 @@ void MarlinUI::draw_status_screen() {
* Print Z values
*/
_ZLABEL(_LCD_W_POS, 1);
if (!isnan(ubl.z_values[x_plot][y_plot]))
if (!ISNAN(ubl.z_values[x_plot][y_plot]))
lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
else
lcd_put_u8str_P(PSTR(" -----"));
@ -1476,7 +1476,7 @@ void MarlinUI::draw_status_screen() {
* Show the location value
*/
_ZLABEL(_LCD_W_POS, 3);
if (!isnan(ubl.z_values[x_plot][y_plot]))
if (!ISNAN(ubl.z_values[x_plot][y_plot]))
lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
else
lcd_put_u8str_P(PSTR(" -----"));

View File

@ -941,7 +941,7 @@ void MarlinUI::draw_status_screen() {
// Show the location value
lcd.setCursor(_LCD_W_POS, 3); lcd_put_u8str_P(PSTR("Z:"));
if (!isnan(ubl.z_values[x_plot][y_plot]))
if (!ISNAN(ubl.z_values[x_plot][y_plot]))
lcd.print(ftostr43sign(ubl.z_values[x_plot][y_plot]));
else
lcd_put_u8str_P(PSTR(" -----"));

View File

@ -569,7 +569,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
// Show the location value
lcd_put_u8str_P(74, LCD_PIXEL_HEIGHT, Z_LBL);
if (!isnan(ubl.z_values[x_plot][y_plot]))
if (!ISNAN(ubl.z_values[x_plot][y_plot]))
lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
else
lcd_put_u8str_P(PSTR(" -----"));

View File

@ -835,13 +835,17 @@ void MarlinUI::draw_status_screen() {
mix_label = PSTR("Mx");
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-overflow"
#if GCC_VERSION <= 50000
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-overflow"
#endif
sprintf_P(mixer_messages, PSTR(S_FMT " %d;%d%% "), mix_label, int(mixer.mix[0]), int(mixer.mix[1]));
lcd_put_u8str(X_LABEL_POS, XYZ_BASELINE, mixer_messages);
#pragma GCC diagnostic pop
#if GCC_VERSION <= 50000
#pragma GCC diagnostic pop
#endif
#else

View File

@ -32,7 +32,7 @@
namespace FTDI {
void draw_adjuster_value(CommandProcessor& cmd, int16_t x, int16_t y, int16_t w, int16_t h, float value, progmem_str units, int8_t width, uint8_t precision) {
char str[width + precision + 10 + (units ? strlen_P((const char*) units) : 0)];
if (isnan(value))
if (ISNAN(value))
strcpy_P(str, PSTR("-"));
else
dtostrf(value, width, precision, str);

View File

@ -31,7 +31,7 @@ void BedMeshBase::_drawMesh(CommandProcessor &cmd, int16_t x, int16_t y, int16_t
constexpr uint8_t cols = GRID_MAX_POINTS_X;
#define VALUE(X,Y) (func ? func(X,Y,data) : 0)
#define ISVAL(X,Y) (func ? !isnan(VALUE(X,Y)) : true)
#define ISVAL(X,Y) (func ? !ISNAN(VALUE(X,Y)) : true)
#define HEIGHT(X,Y) (ISVAL(X,Y) ? (VALUE(X,Y) - val_min) * scale_z : 0)
// Compute the mean, min and max for the points

View File

@ -70,7 +70,7 @@ void BedMeshEditScreen::onEntry() {
float BedMeshEditScreen::getHighlightedValue() {
const float val = ExtUI::getMeshPoint(mydata.highlight);
return (isnan(val) ? 0 : val) + mydata.zAdjustment;
return (ISNAN(val) ? 0 : val) + mydata.zAdjustment;
}
void BedMeshEditScreen::setHighlightedValue(float value) {

View File

@ -421,7 +421,7 @@ namespace ExtUI {
#if AXIS_IS_TMC(Z2)
case Z2: return stepperZ2.getMilliamps();
#endif
default: return NAN;
default: return MFNAN;
};
}
@ -451,7 +451,7 @@ namespace ExtUI {
#if AXIS_IS_TMC(E7)
case E7: return stepperE7.getMilliamps();
#endif
default: return NAN;
default: return MFNAN;
};
}

View File

@ -54,7 +54,7 @@ static bool probe_single_point() {
z_measured[tram_index] = z_probed_height;
move_to_tramming_wait_pos();
return !isnan(z_probed_height);
return !ISNAN(z_probed_height);
}
static void _menu_single_probe(const uint8_t point) {

View File

@ -505,7 +505,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
tft.set_background(COLOR_BACKGROUND);
tft_string.set(Z_LBL);
tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
tft_string.set(isnan(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot]));
tft_string.set(ISNAN(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot]));
tft_string.trim();
tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);

View File

@ -492,7 +492,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
tft.set_background(COLOR_BACKGROUND);
tft_string.set(Z_LBL);
tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
tft_string.set(isnan(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot]));
tft_string.set(ISNAN(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot]));
tft_string.trim();
tft.add_text(96 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);

View File

@ -492,7 +492,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
tft.set_background(COLOR_BACKGROUND);
tft_string.set(Z_LBL);
tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
tft_string.set(isnan(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot]));
tft_string.set(ISNAN(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot]));
tft_string.trim();
tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);