From 39f703310b8da3b95ad08c3eecd642d76e88fd78 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 5 May 2020 17:55:35 -0500 Subject: [PATCH] Move S_FMT to HAL, apply to mixer --- Marlin/src/HAL/AVR/HAL.h | 6 ++---- Marlin/src/HAL/HAL.h | 5 +++++ Marlin/src/core/macros.h | 7 ------- Marlin/src/lcd/dogm/status_screen_DOGM.cpp | 8 ++++---- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/Marlin/src/HAL/AVR/HAL.h b/Marlin/src/HAL/AVR/HAL.h index f715295d0a..f319868e36 100644 --- a/Marlin/src/HAL/AVR/HAL.h +++ b/Marlin/src/HAL/AVR/HAL.h @@ -50,7 +50,8 @@ // Defines // ------------------------ -//#define analogInputToDigitalPin(IO) IO +// AVR PROGMEM extension for sprintf_P +#define S_FMT "%S" #ifndef CRITICAL_SECTION_START #define CRITICAL_SECTION_START() unsigned char _sreg = SREG; cli() @@ -60,9 +61,6 @@ #define ENABLE_ISRS() sei() #define DISABLE_ISRS() cli() -// On AVR this is in math.h? -//#define square(x) ((x)*(x)) - // ------------------------ // Types // ------------------------ diff --git a/Marlin/src/HAL/HAL.h b/Marlin/src/HAL/HAL.h index 614c6cbaf9..b38f9567bd 100644 --- a/Marlin/src/HAL/HAL.h +++ b/Marlin/src/HAL/HAL.h @@ -31,6 +31,11 @@ #define I2C_ADDRESS(A) (A) #endif +// Needed for AVR sprintf_P PROGMEM extension +#ifndef S_FMT + #define S_FMT "%s" +#endif + inline void watchdog_refresh() { TERN_(USE_WATCHDOG, HAL_watchdog_refresh()); } diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index 88a807c570..edab6ae5bc 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -76,13 +76,6 @@ // Nanoseconds per cycle #define NANOSECONDS_PER_CYCLE (1000000000.0 / F_CPU) -// Macros to make sprintf_P read from PROGMEM (AVR extension) -#ifdef __AVR__ - #define S_FMT "%S" -#else - #define S_FMT "%s" -#endif - // Macros to make a string from a macro #define STRINGIFY_(M) #M #define STRINGIFY(M) STRINGIFY_(M) diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index 5fea16bf97..8c67ff10ab 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -695,19 +695,19 @@ void MarlinUI::draw_status_screen() { // Two-component mix / gradient instead of XY char mixer_messages[12]; - const char *mix_label; + PGM_P mix_label; #if ENABLED(GRADIENT_MIX) if (mixer.gradient.enabled) { mixer.update_mix_from_gradient(); - mix_label = "Gr"; + mix_label = PSTR("Gr"); } else #endif { mixer.update_mix_from_vtool(); - mix_label = "Mx"; + mix_label = PSTR("Mx"); } - sprintf_P(mixer_messages, PSTR("%s %d;%d%% "), mix_label, int(mixer.mix[0]), int(mixer.mix[1])); + 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); #else