Browse Source

Reduce code size with plain inlines

Scott Lahteine 5 years ago
parent
commit
471f403a67

+ 6
- 6
Marlin/src/core/serial.h View File

@@ -108,9 +108,9 @@ extern uint8_t marlin_debug_flags;
108 108
   void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, double v);
109 109
   void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, unsigned int v);
110 110
   void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, unsigned long v);
111
-  FORCE_INLINE void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, uint8_t v) { serial_echopair_PGM_P(p, s_P, (int)v); }
112
-  FORCE_INLINE void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, bool v)    { serial_echopair_PGM_P(p, s_P, (int)v); }
113
-  FORCE_INLINE void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, void *v)   { serial_echopair_PGM_P(p, s_P, (unsigned long)v); }
111
+  inline void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, uint8_t v) { serial_echopair_PGM_P(p, s_P, (int)v); }
112
+  inline void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, bool v)    { serial_echopair_PGM_P(p, s_P, (int)v); }
113
+  inline void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, void *v)   { serial_echopair_PGM_P(p, s_P, (unsigned long)v); }
114 114
 
115 115
   void serial_spaces_P(const int8_t p, uint8_t count);
116 116
   #define SERIAL_ECHO_SP_P(p,C)                     serial_spaces_P(p,C)
@@ -223,9 +223,9 @@ void serial_echopair_PGM(PGM_P s_P, float v);
223 223
 void serial_echopair_PGM(PGM_P s_P, double v);
224 224
 void serial_echopair_PGM(PGM_P s_P, unsigned int v);
225 225
 void serial_echopair_PGM(PGM_P s_P, unsigned long v);
226
-FORCE_INLINE void serial_echopair_PGM(PGM_P s_P, uint8_t v) { serial_echopair_PGM(s_P, (int)v); }
227
-FORCE_INLINE void serial_echopair_PGM(PGM_P s_P, bool v)    { serial_echopair_PGM(s_P, (int)v); }
228
-FORCE_INLINE void serial_echopair_PGM(PGM_P s_P, void *v)   { serial_echopair_PGM(s_P, (unsigned long)v); }
226
+inline void serial_echopair_PGM(PGM_P s_P, uint8_t v) { serial_echopair_PGM(s_P, (int)v); }
227
+inline void serial_echopair_PGM(PGM_P s_P, bool v)    { serial_echopair_PGM(s_P, (int)v); }
228
+inline void serial_echopair_PGM(PGM_P s_P, void *v)   { serial_echopair_PGM(s_P, (unsigned long)v); }
229 229
 
230 230
 void serial_spaces(uint8_t count);
231 231
 #define SERIAL_ECHO_SP(C)                           serial_spaces(C)

+ 2
- 4
Marlin/src/feature/bedlevel/ubl/ubl.h View File

@@ -51,8 +51,6 @@ enum MeshPointType : char { INVALID, REAL, SET_IN_BITMAP };
51 51
 
52 52
 extern uint8_t ubl_cnt;
53 53
 
54
-///////////////////////////////////////////////////////////////////////////////////////////////////////
55
-
56 54
 #if ENABLED(ULTRA_LCD)
57 55
   void lcd_quick_feedback(const bool clear_buttons);
58 56
 #endif
@@ -346,11 +344,11 @@ class unified_bed_leveling {
346 344
       return z0;
347 345
     }
348 346
 
349
-    FORCE_INLINE static float mesh_index_to_xpos(const uint8_t i) {
347
+    static inline float mesh_index_to_xpos(const uint8_t i) {
350 348
       return i < GRID_MAX_POINTS_X ? pgm_read_float(&_mesh_index_to_xpos[i]) : MESH_MIN_X + i * (MESH_X_DIST);
351 349
     }
352 350
 
353
-    FORCE_INLINE static float mesh_index_to_ypos(const uint8_t i) {
351
+    static inline float mesh_index_to_ypos(const uint8_t i) {
354 352
       return i < GRID_MAX_POINTS_Y ? pgm_read_float(&_mesh_index_to_ypos[i]) : MESH_MIN_Y + i * (MESH_Y_DIST);
355 353
     }
356 354
 

+ 13
- 13
Marlin/src/feature/leds/leds.h View File

@@ -146,7 +146,7 @@ public:
146 146
     #endif
147 147
   );
148 148
 
149
-  FORCE_INLINE void set_color(uint8_t r, uint8_t g, uint8_t b
149
+  inline void set_color(uint8_t r, uint8_t g, uint8_t b
150 150
     #if HAS_WHITE_LED
151 151
       , uint8_t w=0
152 152
       #if ENABLED(NEOPIXEL_LED)
@@ -164,23 +164,23 @@ public:
164 164
     );
165 165
   }
166 166
 
167
-  FORCE_INLINE static void set_off()   { set_color(LEDColorOff()); }
168
-  FORCE_INLINE static void set_green() { set_color(LEDColorGreen()); }
169
-  FORCE_INLINE static void set_white() { set_color(LEDColorWhite()); }
167
+  static inline void set_off()   { set_color(LEDColorOff()); }
168
+  static inline void set_green() { set_color(LEDColorGreen()); }
169
+  static inline void set_white() { set_color(LEDColorWhite()); }
170 170
 
171 171
   #if ENABLED(LED_COLOR_PRESETS)
172 172
     static const LEDColor defaultLEDColor;
173
-    FORCE_INLINE static void set_default()  { set_color(defaultLEDColor); }
174
-    FORCE_INLINE static void set_red()      { set_color(LEDColorRed()); }
175
-    FORCE_INLINE static void set_orange()   { set_color(LEDColorOrange()); }
176
-    FORCE_INLINE static void set_yellow()   { set_color(LEDColorYellow()); }
177
-    FORCE_INLINE static void set_blue()     { set_color(LEDColorBlue()); }
178
-    FORCE_INLINE static void set_indigo()   { set_color(LEDColorIndigo()); }
179
-    FORCE_INLINE static void set_violet()   { set_color(LEDColorViolet()); }
173
+    static inline void set_default()  { set_color(defaultLEDColor); }
174
+    static inline void set_red()      { set_color(LEDColorRed()); }
175
+    static inline void set_orange()   { set_color(LEDColorOrange()); }
176
+    static inline void set_yellow()   { set_color(LEDColorYellow()); }
177
+    static inline void set_blue()     { set_color(LEDColorBlue()); }
178
+    static inline void set_indigo()   { set_color(LEDColorIndigo()); }
179
+    static inline void set_violet()   { set_color(LEDColorViolet()); }
180 180
   #endif
181 181
 
182 182
   #if ENABLED(PRINTER_EVENT_LEDS)
183
-    FORCE_INLINE static LEDColor get_color() { return lights_on ? color : LEDColorOff(); }
183
+    static inline LEDColor get_color() { return lights_on ? color : LEDColorOff(); }
184 184
   #endif
185 185
 
186 186
   #if ENABLED(LED_CONTROL_MENU) || ENABLED(PRINTER_EVENT_LEDS)
@@ -189,7 +189,7 @@ public:
189 189
   #endif
190 190
   #if ENABLED(LED_CONTROL_MENU)
191 191
     static void toggle();  // swap "off" with color
192
-    FORCE_INLINE static void update() { set_color(color); }
192
+    static inline void update() { set_color(color); }
193 193
   #endif
194 194
 };
195 195
 

+ 6
- 6
Marlin/src/feature/leds/printer_event_leds.h View File

@@ -38,23 +38,23 @@ private:
38 38
 
39 39
 public:
40 40
   #if HAS_TEMP_HOTEND
41
-    FORCE_INLINE static LEDColor onHotendHeatingStart() { old_intensity = 0; return leds.get_color(); }
41
+    static inline LEDColor onHotendHeatingStart() { old_intensity = 0; return leds.get_color(); }
42 42
     static void onHotendHeating(const float &start, const float &current, const float &target);
43 43
   #endif
44 44
 
45 45
   #if HAS_HEATED_BED
46
-    FORCE_INLINE static LEDColor onBedHeatingStart() { old_intensity = 127; return leds.get_color(); }
46
+    static inline LEDColor onBedHeatingStart() { old_intensity = 127; return leds.get_color(); }
47 47
     static void onBedHeating(const float &start, const float &current, const float &target);
48 48
   #endif
49 49
 
50 50
   #if HAS_TEMP_HOTEND || HAS_HEATED_BED
51
-    FORCE_INLINE static void onHeatingDone() { leds.set_color(LEDColorWhite()); }
52
-    FORCE_INLINE static void onPidTuningDone(LEDColor c) { leds.set_color(c); }
51
+    static inline void onHeatingDone() { leds.set_color(LEDColorWhite()); }
52
+    static inline void onPidTuningDone(LEDColor c) { leds.set_color(c); }
53 53
   #endif
54 54
 
55 55
   #if ENABLED(SDSUPPORT)
56 56
 
57
-    FORCE_INLINE static void onPrintCompleted() {
57
+    static inline void onPrintCompleted() {
58 58
       leds.set_green();
59 59
       #if HAS_LEDS_OFF_FLAG
60 60
         leds_off_after_print = true;
@@ -64,7 +64,7 @@ public:
64 64
       #endif
65 65
     }
66 66
 
67
-    FORCE_INLINE static void onResumeAfterWait() {
67
+    static inline void onResumeAfterWait() {
68 68
       #if HAS_LEDS_OFF_FLAG
69 69
         if (leds_off_after_print) {
70 70
           leds.set_off();

+ 9
- 9
Marlin/src/feature/runout.h View File

@@ -180,9 +180,9 @@ class FilamentSensorTypeSwitch : public FilamentSensorTypeBase {
180 180
     }
181 181
 
182 182
   public:
183
-    FORCE_INLINE static void block_complete(const block_t *b) {}
183
+    static inline void block_complete(const block_t *b) {}
184 184
 
185
-    FORCE_INLINE static void run() {
185
+    static inline void run() {
186 186
       if (!poll_runout_pin(active_extruder))
187 187
         filament_present(active_extruder);
188 188
     }
@@ -220,7 +220,7 @@ class FilamentSensorTypeEncoder : public FilamentSensorTypeBase {
220 220
       motion_detected = 0;
221 221
     }
222 222
 
223
-    FORCE_INLINE static void run() { poll_motion_sensor(); }
223
+    static inline void run() { poll_motion_sensor(); }
224 224
 };
225 225
 
226 226
 /********************************* RESPONSE TYPE *********************************/
@@ -240,7 +240,7 @@ class FilamentSensorTypeEncoder : public FilamentSensorTypeBase {
240 240
     public:
241 241
       static float runout_distance_mm;
242 242
 
243
-      FORCE_INLINE static bool has_runout() {
243
+      static inline bool has_runout() {
244 244
         return get_mm_since_runout(active_extruder) > runout_distance_mm;
245 245
       }
246 246
 
@@ -281,11 +281,11 @@ class FilamentSensorTypeEncoder : public FilamentSensorTypeBase {
281 281
       static constexpr uint8_t FIL_RUNOUT_THRESHOLD = 5;
282 282
       static uint8_t runout_count;
283 283
     public:
284
-      FORCE_INLINE static bool has_runout()                             { return runout_count > FIL_RUNOUT_THRESHOLD; }
285
-      FORCE_INLINE static void block_complete(const block_t *b)         {}
286
-      FORCE_INLINE static void filament_present(const uint8_t extruder) { runout_count = 0; UNUSED(extruder); }
287
-      FORCE_INLINE static void run()                                    { runout_count++; }
288
-      FORCE_INLINE static void reset()                                  { runout_count = 0; }
284
+      static inline bool has_runout()                             { return runout_count > FIL_RUNOUT_THRESHOLD; }
285
+      static inline void block_complete(const block_t *b)         {}
286
+      static inline void filament_present(const uint8_t extruder) { runout_count = 0; UNUSED(extruder); }
287
+      static inline void run()                                    { runout_count++; }
288
+      static inline void reset()                                  { runout_count = 0; }
289 289
   };
290 290
 
291 291
 #endif // !FILAMENT_RUNOUT_DISTANCE_MM

+ 26
- 26
Marlin/src/gcode/parser.h View File

@@ -241,12 +241,12 @@ public:
241 241
   static inline uint32_t value_ulong() { return value_ptr ? strtoul(value_ptr, NULL, 10) : 0UL; }
242 242
 
243 243
   // Code value for use as time
244
-  FORCE_INLINE static millis_t value_millis() { return value_ulong(); }
245
-  FORCE_INLINE static millis_t value_millis_from_seconds() { return (millis_t)(value_float() * 1000); }
244
+  static inline millis_t value_millis() { return value_ulong(); }
245
+  static inline millis_t value_millis_from_seconds() { return (millis_t)(value_float() * 1000); }
246 246
 
247 247
   // Reduce to fewer bits
248
-  FORCE_INLINE static int16_t value_int() { return (int16_t)value_long(); }
249
-  FORCE_INLINE static uint16_t value_ushort() { return (uint16_t)value_long(); }
248
+  static inline int16_t value_int() { return (int16_t)value_long(); }
249
+  static inline uint16_t value_ushort() { return (uint16_t)value_long(); }
250 250
   static inline uint8_t value_byte() { return (uint8_t)constrain(value_long(), 0, 255); }
251 251
 
252 252
   // Bool is true with no value or non-zero
@@ -279,18 +279,18 @@ public:
279 279
       return (axis >= E_AXIS && volumetric_enabled ? volumetric_unit_factor : linear_unit_factor);
280 280
     }
281 281
 
282
-    FORCE_INLINE static float linear_value_to_mm(const float v)                    { return v * linear_unit_factor; }
283
-    FORCE_INLINE static float axis_value_to_mm(const AxisEnum axis, const float v) { return v * axis_unit_factor(axis); }
284
-    FORCE_INLINE static float per_axis_value(const AxisEnum axis, const float v)   { return v / axis_unit_factor(axis); }
282
+    static inline float linear_value_to_mm(const float v)                    { return v * linear_unit_factor; }
283
+    static inline float axis_value_to_mm(const AxisEnum axis, const float v) { return v * axis_unit_factor(axis); }
284
+    static inline float per_axis_value(const AxisEnum axis, const float v)   { return v / axis_unit_factor(axis); }
285 285
 
286 286
   #else
287 287
 
288
-    FORCE_INLINE static float mm_to_linear_unit(const float mm)     { return mm; }
289
-    FORCE_INLINE static float mm_to_volumetric_unit(const float mm) { return mm; }
288
+    static inline float mm_to_linear_unit(const float mm)     { return mm; }
289
+    static inline float mm_to_volumetric_unit(const float mm) { return mm; }
290 290
 
291
-    FORCE_INLINE static float linear_value_to_mm(const float v)                    { return v; }
292
-    FORCE_INLINE static float axis_value_to_mm(const AxisEnum axis, const float v) { UNUSED(axis); return v; }
293
-    FORCE_INLINE static float per_axis_value(const AxisEnum axis, const float v)   { UNUSED(axis); return v; }
291
+    static inline float linear_value_to_mm(const float v)                    { return v; }
292
+    static inline float axis_value_to_mm(const AxisEnum axis, const float v) { UNUSED(axis); return v; }
293
+    static inline float per_axis_value(const AxisEnum axis, const float v)   { UNUSED(axis); return v; }
294 294
 
295 295
   #endif
296 296
 
@@ -307,10 +307,10 @@ public:
307 307
 
308 308
     #if HAS_LCD_MENU && DISABLED(DISABLE_M503)
309 309
 
310
-      FORCE_INLINE static char temp_units_code() {
310
+      static inline char temp_units_code() {
311 311
         return input_temp_units == TEMPUNIT_K ? 'K' : input_temp_units == TEMPUNIT_F ? 'F' : 'C';
312 312
       }
313
-      FORCE_INLINE static PGM_P temp_units_name() {
313
+      static inline PGM_P temp_units_name() {
314 314
         return input_temp_units == TEMPUNIT_K ? PSTR("Kelvin") : input_temp_units == TEMPUNIT_F ? PSTR("Fahrenheit") : PSTR("Celsius");
315 315
       }
316 316
       static inline float to_temp_units(const float &f) {
@@ -355,27 +355,27 @@ public:
355 355
 
356 356
   #else // !TEMPERATURE_UNITS_SUPPORT
357 357
 
358
-    FORCE_INLINE static float value_celsius()      { return value_float(); }
359
-    FORCE_INLINE static float value_celsius_diff() { return value_float(); }
358
+    static inline float value_celsius()      { return value_float(); }
359
+    static inline float value_celsius_diff() { return value_float(); }
360 360
 
361 361
     #define TEMP_UNIT(N) (N)
362 362
 
363 363
   #endif // !TEMPERATURE_UNITS_SUPPORT
364 364
 
365
-  FORCE_INLINE static float value_feedrate() { return value_linear_units(); }
365
+  static inline float value_feedrate() { return value_linear_units(); }
366 366
 
367 367
   void unknown_command_error();
368 368
 
369 369
   // Provide simple value accessors with default option
370
-  FORCE_INLINE static float    floatval(const char c, const float dval=0.0)   { return seenval(c) ? value_float()        : dval; }
371
-  FORCE_INLINE static bool     boolval(const char c, const bool dval=false)   { return seenval(c) ? value_bool()         : (seen(c) ? true : dval); }
372
-  FORCE_INLINE static uint8_t  byteval(const char c, const uint8_t dval=0)    { return seenval(c) ? value_byte()         : dval; }
373
-  FORCE_INLINE static int16_t  intval(const char c, const int16_t dval=0)     { return seenval(c) ? value_int()          : dval; }
374
-  FORCE_INLINE static uint16_t ushortval(const char c, const uint16_t dval=0) { return seenval(c) ? value_ushort()       : dval; }
375
-  FORCE_INLINE static int32_t  longval(const char c, const int32_t dval=0)    { return seenval(c) ? value_long()         : dval; }
376
-  FORCE_INLINE static uint32_t ulongval(const char c, const uint32_t dval=0)  { return seenval(c) ? value_ulong()        : dval; }
377
-  FORCE_INLINE static float    linearval(const char c, const float dval=0)    { return seenval(c) ? value_linear_units() : dval; }
378
-  FORCE_INLINE static float    celsiusval(const char c, const float dval=0)   { return seenval(c) ? value_celsius()      : dval; }
370
+  static inline float    floatval(const char c, const float dval=0.0)   { return seenval(c) ? value_float()        : dval; }
371
+  static inline bool     boolval(const char c, const bool dval=false)   { return seenval(c) ? value_bool()         : (seen(c) ? true : dval); }
372
+  static inline uint8_t  byteval(const char c, const uint8_t dval=0)    { return seenval(c) ? value_byte()         : dval; }
373
+  static inline int16_t  intval(const char c, const int16_t dval=0)     { return seenval(c) ? value_int()          : dval; }
374
+  static inline uint16_t ushortval(const char c, const uint16_t dval=0) { return seenval(c) ? value_ushort()       : dval; }
375
+  static inline int32_t  longval(const char c, const int32_t dval=0)    { return seenval(c) ? value_long()         : dval; }
376
+  static inline uint32_t ulongval(const char c, const uint32_t dval=0)  { return seenval(c) ? value_ulong()        : dval; }
377
+  static inline float    linearval(const char c, const float dval=0)    { return seenval(c) ? value_linear_units() : dval; }
378
+  static inline float    celsiusval(const char c, const float dval=0)   { return seenval(c) ? value_celsius()      : dval; }
379 379
 
380 380
 };
381 381
 

+ 0
- 1
Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp View File

@@ -32,7 +32,6 @@ LCD_CLASS *plcd = &lcd;
32 32
 
33 33
 int lcd_glyph_height(void) { return 1; }
34 34
 
35
-////////////////////////////////////////////////////////////
36 35
 typedef struct _hd44780_charmap_t {
37 36
   wchar_t uchar; // the unicode char
38 37
   uint8_t idx;   // the glyph of the char in the ROM

+ 0
- 3
Marlin/src/lcd/dogm/u8g_fontutf8.cpp View File

@@ -15,7 +15,6 @@
15 15
 #include "../fontutils.h"
16 16
 #include "u8g_fontutf8.h"
17 17
 
18
-////////////////////////////////////////////////////////////
19 18
 typedef void font_t;
20 19
 
21 20
 /**
@@ -31,7 +30,6 @@ typedef void font_t;
31 30
  */
32 31
 typedef int (* fontgroup_cb_draw_t)(void *userdata, const font_t *fnt_current, const char *msg);
33 32
 
34
-////////////////////////////////////////////////////////////
35 33
 /* return v1 - v2 */
36 34
 static int fontinfo_compare(uxg_fontinfo_t * v1, uxg_fontinfo_t * v2) {
37 35
   if (v1->page < v2->page)      return -1;
@@ -115,7 +113,6 @@ static void fontgroup_drawstring(font_group_t *group, const font_t *fnt_default,
115 113
   }
116 114
 }
117 115
 
118
-////////////////////////////////////////////////////////////
119 116
 static bool flag_fontgroup_was_inited = false;
120 117
 static font_group_t g_fontgroup_root = {NULL, 0};
121 118
 

+ 12
- 12
Marlin/src/sd/cardreader.h View File

@@ -114,22 +114,22 @@ public:
114 114
     void removeJobRecoveryFile();
115 115
   #endif
116 116
 
117
-  FORCE_INLINE void pauseSDPrint() { sdprinting = false; }
118
-  FORCE_INLINE bool isFileOpen() { return file.isOpen(); }
119
-  FORCE_INLINE bool eof() { return sdpos >= filesize; }
120
-  FORCE_INLINE int16_t get() { sdpos = file.curPosition(); return (int16_t)file.read(); }
121
-  FORCE_INLINE void setIndex(const uint32_t index) { sdpos = index; file.seekSet(index); }
122
-  FORCE_INLINE uint32_t getIndex() { return sdpos; }
123
-  FORCE_INLINE uint8_t percentDone() { return (isFileOpen() && filesize) ? sdpos / ((filesize + 99) / 100) : 0; }
124
-  FORCE_INLINE char* getWorkDirName() { workDir.getFilename(filename); return filename; }
125
-  FORCE_INLINE int16_t read(void* buf, uint16_t nbyte) { return file.isOpen() ? file.read(buf, nbyte) : -1; }
126
-  FORCE_INLINE int16_t write(void* buf, uint16_t nbyte) { return file.isOpen() ? file.write(buf, nbyte) : -1; }
117
+  inline void pauseSDPrint() { sdprinting = false; }
118
+  inline bool isFileOpen() { return file.isOpen(); }
119
+  inline bool eof() { return sdpos >= filesize; }
120
+  inline int16_t get() { sdpos = file.curPosition(); return (int16_t)file.read(); }
121
+  inline void setIndex(const uint32_t index) { sdpos = index; file.seekSet(index); }
122
+  inline uint32_t getIndex() { return sdpos; }
123
+  inline uint8_t percentDone() { return (isFileOpen() && filesize) ? sdpos / ((filesize + 99) / 100) : 0; }
124
+  inline char* getWorkDirName() { workDir.getFilename(filename); return filename; }
125
+  inline int16_t read(void* buf, uint16_t nbyte) { return file.isOpen() ? file.read(buf, nbyte) : -1; }
126
+  inline int16_t write(void* buf, uint16_t nbyte) { return file.isOpen() ? file.write(buf, nbyte) : -1; }
127 127
 
128 128
   Sd2Card& getSd2Card() { return sd2card; }
129 129
 
130 130
   #if ENABLED(AUTO_REPORT_SD_STATUS)
131 131
     void auto_report_sd_status(void);
132
-    FORCE_INLINE void set_auto_report_interval(uint8_t v
132
+    inline void set_auto_report_interval(uint8_t v
133 133
       #if NUM_SERIAL > 1
134 134
         , int8_t port
135 135
       #endif
@@ -143,7 +143,7 @@ public:
143 143
     }
144 144
   #endif
145 145
 
146
-  FORCE_INLINE char* longest_filename() { return longFilename[0] ? longFilename : filename; }
146
+  inline char* longest_filename() { return longFilename[0] ? longFilename : filename; }
147 147
 
148 148
 public:
149 149
   bool saving, logging, sdprinting, cardOK, filenameIsDir, abort_sd_printing;

Loading…
Cancel
Save