Browse Source

Move S_FMT to HAL, apply to mixer

Scott Lahteine 4 years ago
parent
commit
39f703310b

+ 2
- 4
Marlin/src/HAL/AVR/HAL.h View File

@@ -50,7 +50,8 @@
50 50
 // Defines
51 51
 // ------------------------
52 52
 
53
-//#define analogInputToDigitalPin(IO) IO
53
+// AVR PROGMEM extension for sprintf_P
54
+#define S_FMT "%S"
54 55
 
55 56
 #ifndef CRITICAL_SECTION_START
56 57
   #define CRITICAL_SECTION_START()  unsigned char _sreg = SREG; cli()
@@ -60,9 +61,6 @@
60 61
 #define ENABLE_ISRS()  sei()
61 62
 #define DISABLE_ISRS() cli()
62 63
 
63
-// On AVR this is in math.h?
64
-//#define square(x) ((x)*(x))
65
-
66 64
 // ------------------------
67 65
 // Types
68 66
 // ------------------------

+ 5
- 0
Marlin/src/HAL/HAL.h View File

@@ -31,6 +31,11 @@
31 31
   #define I2C_ADDRESS(A) (A)
32 32
 #endif
33 33
 
34
+// Needed for AVR sprintf_P PROGMEM extension
35
+#ifndef S_FMT
36
+  #define S_FMT "%s"
37
+#endif
38
+
34 39
 inline void watchdog_refresh() {
35 40
   TERN_(USE_WATCHDOG, HAL_watchdog_refresh());
36 41
 }

+ 0
- 7
Marlin/src/core/macros.h View File

@@ -76,13 +76,6 @@
76 76
 // Nanoseconds per cycle
77 77
 #define NANOSECONDS_PER_CYCLE (1000000000.0 / F_CPU)
78 78
 
79
-// Macros to make sprintf_P read from PROGMEM (AVR extension)
80
-#ifdef __AVR__
81
-  #define S_FMT "%S"
82
-#else
83
-  #define S_FMT "%s"
84
-#endif
85
-
86 79
 // Macros to make a string from a macro
87 80
 #define STRINGIFY_(M) #M
88 81
 #define STRINGIFY(M) STRINGIFY_(M)

+ 4
- 4
Marlin/src/lcd/dogm/status_screen_DOGM.cpp View File

@@ -695,19 +695,19 @@ void MarlinUI::draw_status_screen() {
695 695
         // Two-component mix / gradient instead of XY
696 696
 
697 697
         char mixer_messages[12];
698
-        const char *mix_label;
698
+        PGM_P mix_label;
699 699
         #if ENABLED(GRADIENT_MIX)
700 700
           if (mixer.gradient.enabled) {
701 701
             mixer.update_mix_from_gradient();
702
-            mix_label = "Gr";
702
+            mix_label = PSTR("Gr");
703 703
           }
704 704
           else
705 705
         #endif
706 706
           {
707 707
             mixer.update_mix_from_vtool();
708
-            mix_label = "Mx";
708
+            mix_label = PSTR("Mx");
709 709
           }
710
-        sprintf_P(mixer_messages, PSTR("%s %d;%d%% "), mix_label, int(mixer.mix[0]), int(mixer.mix[1]));
710
+        sprintf_P(mixer_messages, PSTR(S_FMT " %d;%d%% "), mix_label, int(mixer.mix[0]), int(mixer.mix[1]));
711 711
         lcd_put_u8str(X_LABEL_POS, XYZ_BASELINE, mixer_messages);
712 712
 
713 713
       #else

Loading…
Cancel
Save