Reduce code size with plain inlines
This commit is contained in:
parent
30a49f5ee2
commit
471f403a67
@ -108,9 +108,9 @@ extern uint8_t marlin_debug_flags;
|
||||
void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, double v);
|
||||
void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, unsigned int v);
|
||||
void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, unsigned long v);
|
||||
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); }
|
||||
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); }
|
||||
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); }
|
||||
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); }
|
||||
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); }
|
||||
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); }
|
||||
|
||||
void serial_spaces_P(const int8_t p, uint8_t count);
|
||||
#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);
|
||||
void serial_echopair_PGM(PGM_P s_P, double v);
|
||||
void serial_echopair_PGM(PGM_P s_P, unsigned int v);
|
||||
void serial_echopair_PGM(PGM_P s_P, unsigned long v);
|
||||
FORCE_INLINE void serial_echopair_PGM(PGM_P s_P, uint8_t v) { serial_echopair_PGM(s_P, (int)v); }
|
||||
FORCE_INLINE void serial_echopair_PGM(PGM_P s_P, bool v) { serial_echopair_PGM(s_P, (int)v); }
|
||||
FORCE_INLINE void serial_echopair_PGM(PGM_P s_P, void *v) { serial_echopair_PGM(s_P, (unsigned long)v); }
|
||||
inline void serial_echopair_PGM(PGM_P s_P, uint8_t v) { serial_echopair_PGM(s_P, (int)v); }
|
||||
inline void serial_echopair_PGM(PGM_P s_P, bool v) { serial_echopair_PGM(s_P, (int)v); }
|
||||
inline void serial_echopair_PGM(PGM_P s_P, void *v) { serial_echopair_PGM(s_P, (unsigned long)v); }
|
||||
|
||||
void serial_spaces(uint8_t count);
|
||||
#define SERIAL_ECHO_SP(C) serial_spaces(C)
|
||||
|
@ -51,8 +51,6 @@ enum MeshPointType : char { INVALID, REAL, SET_IN_BITMAP };
|
||||
|
||||
extern uint8_t ubl_cnt;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if ENABLED(ULTRA_LCD)
|
||||
void lcd_quick_feedback(const bool clear_buttons);
|
||||
#endif
|
||||
@ -346,11 +344,11 @@ class unified_bed_leveling {
|
||||
return z0;
|
||||
}
|
||||
|
||||
FORCE_INLINE static float mesh_index_to_xpos(const uint8_t i) {
|
||||
static inline float mesh_index_to_xpos(const uint8_t i) {
|
||||
return i < GRID_MAX_POINTS_X ? pgm_read_float(&_mesh_index_to_xpos[i]) : MESH_MIN_X + i * (MESH_X_DIST);
|
||||
}
|
||||
|
||||
FORCE_INLINE static float mesh_index_to_ypos(const uint8_t i) {
|
||||
static inline float mesh_index_to_ypos(const uint8_t i) {
|
||||
return i < GRID_MAX_POINTS_Y ? pgm_read_float(&_mesh_index_to_ypos[i]) : MESH_MIN_Y + i * (MESH_Y_DIST);
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ public:
|
||||
#endif
|
||||
);
|
||||
|
||||
FORCE_INLINE void set_color(uint8_t r, uint8_t g, uint8_t b
|
||||
inline void set_color(uint8_t r, uint8_t g, uint8_t b
|
||||
#if HAS_WHITE_LED
|
||||
, uint8_t w=0
|
||||
#if ENABLED(NEOPIXEL_LED)
|
||||
@ -164,23 +164,23 @@ public:
|
||||
);
|
||||
}
|
||||
|
||||
FORCE_INLINE static void set_off() { set_color(LEDColorOff()); }
|
||||
FORCE_INLINE static void set_green() { set_color(LEDColorGreen()); }
|
||||
FORCE_INLINE static void set_white() { set_color(LEDColorWhite()); }
|
||||
static inline void set_off() { set_color(LEDColorOff()); }
|
||||
static inline void set_green() { set_color(LEDColorGreen()); }
|
||||
static inline void set_white() { set_color(LEDColorWhite()); }
|
||||
|
||||
#if ENABLED(LED_COLOR_PRESETS)
|
||||
static const LEDColor defaultLEDColor;
|
||||
FORCE_INLINE static void set_default() { set_color(defaultLEDColor); }
|
||||
FORCE_INLINE static void set_red() { set_color(LEDColorRed()); }
|
||||
FORCE_INLINE static void set_orange() { set_color(LEDColorOrange()); }
|
||||
FORCE_INLINE static void set_yellow() { set_color(LEDColorYellow()); }
|
||||
FORCE_INLINE static void set_blue() { set_color(LEDColorBlue()); }
|
||||
FORCE_INLINE static void set_indigo() { set_color(LEDColorIndigo()); }
|
||||
FORCE_INLINE static void set_violet() { set_color(LEDColorViolet()); }
|
||||
static inline void set_default() { set_color(defaultLEDColor); }
|
||||
static inline void set_red() { set_color(LEDColorRed()); }
|
||||
static inline void set_orange() { set_color(LEDColorOrange()); }
|
||||
static inline void set_yellow() { set_color(LEDColorYellow()); }
|
||||
static inline void set_blue() { set_color(LEDColorBlue()); }
|
||||
static inline void set_indigo() { set_color(LEDColorIndigo()); }
|
||||
static inline void set_violet() { set_color(LEDColorViolet()); }
|
||||
#endif
|
||||
|
||||
#if ENABLED(PRINTER_EVENT_LEDS)
|
||||
FORCE_INLINE static LEDColor get_color() { return lights_on ? color : LEDColorOff(); }
|
||||
static inline LEDColor get_color() { return lights_on ? color : LEDColorOff(); }
|
||||
#endif
|
||||
|
||||
#if ENABLED(LED_CONTROL_MENU) || ENABLED(PRINTER_EVENT_LEDS)
|
||||
@ -189,7 +189,7 @@ public:
|
||||
#endif
|
||||
#if ENABLED(LED_CONTROL_MENU)
|
||||
static void toggle(); // swap "off" with color
|
||||
FORCE_INLINE static void update() { set_color(color); }
|
||||
static inline void update() { set_color(color); }
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -38,23 +38,23 @@ private:
|
||||
|
||||
public:
|
||||
#if HAS_TEMP_HOTEND
|
||||
FORCE_INLINE static LEDColor onHotendHeatingStart() { old_intensity = 0; return leds.get_color(); }
|
||||
static inline LEDColor onHotendHeatingStart() { old_intensity = 0; return leds.get_color(); }
|
||||
static void onHotendHeating(const float &start, const float ¤t, const float &target);
|
||||
#endif
|
||||
|
||||
#if HAS_HEATED_BED
|
||||
FORCE_INLINE static LEDColor onBedHeatingStart() { old_intensity = 127; return leds.get_color(); }
|
||||
static inline LEDColor onBedHeatingStart() { old_intensity = 127; return leds.get_color(); }
|
||||
static void onBedHeating(const float &start, const float ¤t, const float &target);
|
||||
#endif
|
||||
|
||||
#if HAS_TEMP_HOTEND || HAS_HEATED_BED
|
||||
FORCE_INLINE static void onHeatingDone() { leds.set_color(LEDColorWhite()); }
|
||||
FORCE_INLINE static void onPidTuningDone(LEDColor c) { leds.set_color(c); }
|
||||
static inline void onHeatingDone() { leds.set_color(LEDColorWhite()); }
|
||||
static inline void onPidTuningDone(LEDColor c) { leds.set_color(c); }
|
||||
#endif
|
||||
|
||||
#if ENABLED(SDSUPPORT)
|
||||
|
||||
FORCE_INLINE static void onPrintCompleted() {
|
||||
static inline void onPrintCompleted() {
|
||||
leds.set_green();
|
||||
#if HAS_LEDS_OFF_FLAG
|
||||
leds_off_after_print = true;
|
||||
@ -64,7 +64,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
FORCE_INLINE static void onResumeAfterWait() {
|
||||
static inline void onResumeAfterWait() {
|
||||
#if HAS_LEDS_OFF_FLAG
|
||||
if (leds_off_after_print) {
|
||||
leds.set_off();
|
||||
|
@ -180,9 +180,9 @@ class FilamentSensorTypeSwitch : public FilamentSensorTypeBase {
|
||||
}
|
||||
|
||||
public:
|
||||
FORCE_INLINE static void block_complete(const block_t *b) {}
|
||||
static inline void block_complete(const block_t *b) {}
|
||||
|
||||
FORCE_INLINE static void run() {
|
||||
static inline void run() {
|
||||
if (!poll_runout_pin(active_extruder))
|
||||
filament_present(active_extruder);
|
||||
}
|
||||
@ -220,7 +220,7 @@ class FilamentSensorTypeEncoder : public FilamentSensorTypeBase {
|
||||
motion_detected = 0;
|
||||
}
|
||||
|
||||
FORCE_INLINE static void run() { poll_motion_sensor(); }
|
||||
static inline void run() { poll_motion_sensor(); }
|
||||
};
|
||||
|
||||
/********************************* RESPONSE TYPE *********************************/
|
||||
@ -240,7 +240,7 @@ class FilamentSensorTypeEncoder : public FilamentSensorTypeBase {
|
||||
public:
|
||||
static float runout_distance_mm;
|
||||
|
||||
FORCE_INLINE static bool has_runout() {
|
||||
static inline bool has_runout() {
|
||||
return get_mm_since_runout(active_extruder) > runout_distance_mm;
|
||||
}
|
||||
|
||||
@ -281,11 +281,11 @@ class FilamentSensorTypeEncoder : public FilamentSensorTypeBase {
|
||||
static constexpr uint8_t FIL_RUNOUT_THRESHOLD = 5;
|
||||
static uint8_t runout_count;
|
||||
public:
|
||||
FORCE_INLINE static bool has_runout() { return runout_count > FIL_RUNOUT_THRESHOLD; }
|
||||
FORCE_INLINE static void block_complete(const block_t *b) {}
|
||||
FORCE_INLINE static void filament_present(const uint8_t extruder) { runout_count = 0; UNUSED(extruder); }
|
||||
FORCE_INLINE static void run() { runout_count++; }
|
||||
FORCE_INLINE static void reset() { runout_count = 0; }
|
||||
static inline bool has_runout() { return runout_count > FIL_RUNOUT_THRESHOLD; }
|
||||
static inline void block_complete(const block_t *b) {}
|
||||
static inline void filament_present(const uint8_t extruder) { runout_count = 0; UNUSED(extruder); }
|
||||
static inline void run() { runout_count++; }
|
||||
static inline void reset() { runout_count = 0; }
|
||||
};
|
||||
|
||||
#endif // !FILAMENT_RUNOUT_DISTANCE_MM
|
||||
|
@ -241,12 +241,12 @@ public:
|
||||
static inline uint32_t value_ulong() { return value_ptr ? strtoul(value_ptr, NULL, 10) : 0UL; }
|
||||
|
||||
// Code value for use as time
|
||||
FORCE_INLINE static millis_t value_millis() { return value_ulong(); }
|
||||
FORCE_INLINE static millis_t value_millis_from_seconds() { return (millis_t)(value_float() * 1000); }
|
||||
static inline millis_t value_millis() { return value_ulong(); }
|
||||
static inline millis_t value_millis_from_seconds() { return (millis_t)(value_float() * 1000); }
|
||||
|
||||
// Reduce to fewer bits
|
||||
FORCE_INLINE static int16_t value_int() { return (int16_t)value_long(); }
|
||||
FORCE_INLINE static uint16_t value_ushort() { return (uint16_t)value_long(); }
|
||||
static inline int16_t value_int() { return (int16_t)value_long(); }
|
||||
static inline uint16_t value_ushort() { return (uint16_t)value_long(); }
|
||||
static inline uint8_t value_byte() { return (uint8_t)constrain(value_long(), 0, 255); }
|
||||
|
||||
// Bool is true with no value or non-zero
|
||||
@ -279,18 +279,18 @@ public:
|
||||
return (axis >= E_AXIS && volumetric_enabled ? volumetric_unit_factor : linear_unit_factor);
|
||||
}
|
||||
|
||||
FORCE_INLINE static float linear_value_to_mm(const float v) { return v * linear_unit_factor; }
|
||||
FORCE_INLINE static float axis_value_to_mm(const AxisEnum axis, const float v) { return v * axis_unit_factor(axis); }
|
||||
FORCE_INLINE static float per_axis_value(const AxisEnum axis, const float v) { return v / axis_unit_factor(axis); }
|
||||
static inline float linear_value_to_mm(const float v) { return v * linear_unit_factor; }
|
||||
static inline float axis_value_to_mm(const AxisEnum axis, const float v) { return v * axis_unit_factor(axis); }
|
||||
static inline float per_axis_value(const AxisEnum axis, const float v) { return v / axis_unit_factor(axis); }
|
||||
|
||||
#else
|
||||
|
||||
FORCE_INLINE static float mm_to_linear_unit(const float mm) { return mm; }
|
||||
FORCE_INLINE static float mm_to_volumetric_unit(const float mm) { return mm; }
|
||||
static inline float mm_to_linear_unit(const float mm) { return mm; }
|
||||
static inline float mm_to_volumetric_unit(const float mm) { return mm; }
|
||||
|
||||
FORCE_INLINE static float linear_value_to_mm(const float v) { return v; }
|
||||
FORCE_INLINE static float axis_value_to_mm(const AxisEnum axis, const float v) { UNUSED(axis); return v; }
|
||||
FORCE_INLINE static float per_axis_value(const AxisEnum axis, const float v) { UNUSED(axis); return v; }
|
||||
static inline float linear_value_to_mm(const float v) { return v; }
|
||||
static inline float axis_value_to_mm(const AxisEnum axis, const float v) { UNUSED(axis); return v; }
|
||||
static inline float per_axis_value(const AxisEnum axis, const float v) { UNUSED(axis); return v; }
|
||||
|
||||
#endif
|
||||
|
||||
@ -307,10 +307,10 @@ public:
|
||||
|
||||
#if HAS_LCD_MENU && DISABLED(DISABLE_M503)
|
||||
|
||||
FORCE_INLINE static char temp_units_code() {
|
||||
static inline char temp_units_code() {
|
||||
return input_temp_units == TEMPUNIT_K ? 'K' : input_temp_units == TEMPUNIT_F ? 'F' : 'C';
|
||||
}
|
||||
FORCE_INLINE static PGM_P temp_units_name() {
|
||||
static inline PGM_P temp_units_name() {
|
||||
return input_temp_units == TEMPUNIT_K ? PSTR("Kelvin") : input_temp_units == TEMPUNIT_F ? PSTR("Fahrenheit") : PSTR("Celsius");
|
||||
}
|
||||
static inline float to_temp_units(const float &f) {
|
||||
@ -355,27 +355,27 @@ public:
|
||||
|
||||
#else // !TEMPERATURE_UNITS_SUPPORT
|
||||
|
||||
FORCE_INLINE static float value_celsius() { return value_float(); }
|
||||
FORCE_INLINE static float value_celsius_diff() { return value_float(); }
|
||||
static inline float value_celsius() { return value_float(); }
|
||||
static inline float value_celsius_diff() { return value_float(); }
|
||||
|
||||
#define TEMP_UNIT(N) (N)
|
||||
|
||||
#endif // !TEMPERATURE_UNITS_SUPPORT
|
||||
|
||||
FORCE_INLINE static float value_feedrate() { return value_linear_units(); }
|
||||
static inline float value_feedrate() { return value_linear_units(); }
|
||||
|
||||
void unknown_command_error();
|
||||
|
||||
// Provide simple value accessors with default option
|
||||
FORCE_INLINE static float floatval(const char c, const float dval=0.0) { return seenval(c) ? value_float() : dval; }
|
||||
FORCE_INLINE static bool boolval(const char c, const bool dval=false) { return seenval(c) ? value_bool() : (seen(c) ? true : dval); }
|
||||
FORCE_INLINE static uint8_t byteval(const char c, const uint8_t dval=0) { return seenval(c) ? value_byte() : dval; }
|
||||
FORCE_INLINE static int16_t intval(const char c, const int16_t dval=0) { return seenval(c) ? value_int() : dval; }
|
||||
FORCE_INLINE static uint16_t ushortval(const char c, const uint16_t dval=0) { return seenval(c) ? value_ushort() : dval; }
|
||||
FORCE_INLINE static int32_t longval(const char c, const int32_t dval=0) { return seenval(c) ? value_long() : dval; }
|
||||
FORCE_INLINE static uint32_t ulongval(const char c, const uint32_t dval=0) { return seenval(c) ? value_ulong() : dval; }
|
||||
FORCE_INLINE static float linearval(const char c, const float dval=0) { return seenval(c) ? value_linear_units() : dval; }
|
||||
FORCE_INLINE static float celsiusval(const char c, const float dval=0) { return seenval(c) ? value_celsius() : dval; }
|
||||
static inline float floatval(const char c, const float dval=0.0) { return seenval(c) ? value_float() : dval; }
|
||||
static inline bool boolval(const char c, const bool dval=false) { return seenval(c) ? value_bool() : (seen(c) ? true : dval); }
|
||||
static inline uint8_t byteval(const char c, const uint8_t dval=0) { return seenval(c) ? value_byte() : dval; }
|
||||
static inline int16_t intval(const char c, const int16_t dval=0) { return seenval(c) ? value_int() : dval; }
|
||||
static inline uint16_t ushortval(const char c, const uint16_t dval=0) { return seenval(c) ? value_ushort() : dval; }
|
||||
static inline int32_t longval(const char c, const int32_t dval=0) { return seenval(c) ? value_long() : dval; }
|
||||
static inline uint32_t ulongval(const char c, const uint32_t dval=0) { return seenval(c) ? value_ulong() : dval; }
|
||||
static inline float linearval(const char c, const float dval=0) { return seenval(c) ? value_linear_units() : dval; }
|
||||
static inline float celsiusval(const char c, const float dval=0) { return seenval(c) ? value_celsius() : dval; }
|
||||
|
||||
};
|
||||
|
||||
|
@ -32,7 +32,6 @@ LCD_CLASS *plcd = &lcd;
|
||||
|
||||
int lcd_glyph_height(void) { return 1; }
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
typedef struct _hd44780_charmap_t {
|
||||
wchar_t uchar; // the unicode char
|
||||
uint8_t idx; // the glyph of the char in the ROM
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "../fontutils.h"
|
||||
#include "u8g_fontutf8.h"
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
typedef void font_t;
|
||||
|
||||
/**
|
||||
@ -31,7 +30,6 @@ typedef void font_t;
|
||||
*/
|
||||
typedef int (* fontgroup_cb_draw_t)(void *userdata, const font_t *fnt_current, const char *msg);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/* return v1 - v2 */
|
||||
static int fontinfo_compare(uxg_fontinfo_t * v1, uxg_fontinfo_t * v2) {
|
||||
if (v1->page < v2->page) return -1;
|
||||
@ -115,7 +113,6 @@ static void fontgroup_drawstring(font_group_t *group, const font_t *fnt_default,
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
static bool flag_fontgroup_was_inited = false;
|
||||
static font_group_t g_fontgroup_root = {NULL, 0};
|
||||
|
||||
|
@ -114,22 +114,22 @@ public:
|
||||
void removeJobRecoveryFile();
|
||||
#endif
|
||||
|
||||
FORCE_INLINE void pauseSDPrint() { sdprinting = false; }
|
||||
FORCE_INLINE bool isFileOpen() { return file.isOpen(); }
|
||||
FORCE_INLINE bool eof() { return sdpos >= filesize; }
|
||||
FORCE_INLINE int16_t get() { sdpos = file.curPosition(); return (int16_t)file.read(); }
|
||||
FORCE_INLINE void setIndex(const uint32_t index) { sdpos = index; file.seekSet(index); }
|
||||
FORCE_INLINE uint32_t getIndex() { return sdpos; }
|
||||
FORCE_INLINE uint8_t percentDone() { return (isFileOpen() && filesize) ? sdpos / ((filesize + 99) / 100) : 0; }
|
||||
FORCE_INLINE char* getWorkDirName() { workDir.getFilename(filename); return filename; }
|
||||
FORCE_INLINE int16_t read(void* buf, uint16_t nbyte) { return file.isOpen() ? file.read(buf, nbyte) : -1; }
|
||||
FORCE_INLINE int16_t write(void* buf, uint16_t nbyte) { return file.isOpen() ? file.write(buf, nbyte) : -1; }
|
||||
inline void pauseSDPrint() { sdprinting = false; }
|
||||
inline bool isFileOpen() { return file.isOpen(); }
|
||||
inline bool eof() { return sdpos >= filesize; }
|
||||
inline int16_t get() { sdpos = file.curPosition(); return (int16_t)file.read(); }
|
||||
inline void setIndex(const uint32_t index) { sdpos = index; file.seekSet(index); }
|
||||
inline uint32_t getIndex() { return sdpos; }
|
||||
inline uint8_t percentDone() { return (isFileOpen() && filesize) ? sdpos / ((filesize + 99) / 100) : 0; }
|
||||
inline char* getWorkDirName() { workDir.getFilename(filename); return filename; }
|
||||
inline int16_t read(void* buf, uint16_t nbyte) { return file.isOpen() ? file.read(buf, nbyte) : -1; }
|
||||
inline int16_t write(void* buf, uint16_t nbyte) { return file.isOpen() ? file.write(buf, nbyte) : -1; }
|
||||
|
||||
Sd2Card& getSd2Card() { return sd2card; }
|
||||
|
||||
#if ENABLED(AUTO_REPORT_SD_STATUS)
|
||||
void auto_report_sd_status(void);
|
||||
FORCE_INLINE void set_auto_report_interval(uint8_t v
|
||||
inline void set_auto_report_interval(uint8_t v
|
||||
#if NUM_SERIAL > 1
|
||||
, int8_t port
|
||||
#endif
|
||||
@ -143,7 +143,7 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
FORCE_INLINE char* longest_filename() { return longFilename[0] ? longFilename : filename; }
|
||||
inline char* longest_filename() { return longFilename[0] ? longFilename : filename; }
|
||||
|
||||
public:
|
||||
bool saving, logging, sdprinting, cardOK, filenameIsDir, abort_sd_printing;
|
||||
|
Loading…
Reference in New Issue
Block a user