Save PROGMEM on serial prefixes (#12033)
With default config and `EEPROM_SETTINGS`, saves over 200 bytes of PROGMEM.
This commit is contained in:
parent
07db08e39d
commit
cb7844c8d4
|
@ -75,13 +75,13 @@ void HAL_adc_init(void) {
|
||||||
#include "../../core/language.h"
|
#include "../../core/language.h"
|
||||||
|
|
||||||
extern void kill(PGM_P);
|
extern void kill(PGM_P);
|
||||||
extern const char errormagic[];
|
|
||||||
|
|
||||||
void HAL_adc_enable_channel(int ch) {
|
void HAL_adc_enable_channel(int ch) {
|
||||||
pin_t pin = analogInputToDigitalPin(ch);
|
pin_t pin = analogInputToDigitalPin(ch);
|
||||||
|
|
||||||
if (pin == -1) {
|
if (pin == -1) {
|
||||||
SERIAL_PRINTF("%sINVALID ANALOG PORT:%d\n", errormagic, ch);
|
serial_error_start();
|
||||||
|
SERIAL_PRINTF("INVALID ANALOG PORT:%d\n", ch);
|
||||||
kill(MSG_KILLED);
|
kill(MSG_KILLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,10 @@ const char echomagic[] PROGMEM = "echo:";
|
||||||
void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, unsigned long v) { serialprintPGM_P(p, s_P); SERIAL_ECHO_P(p, v); }
|
void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, unsigned long v) { serialprintPGM_P(p, s_P); SERIAL_ECHO_P(p, v); }
|
||||||
|
|
||||||
void serial_spaces_P(const int8_t p, uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (count--) SERIAL_CHAR_P(p, ' '); }
|
void serial_spaces_P(const int8_t p, uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (count--) SERIAL_CHAR_P(p, ' '); }
|
||||||
|
|
||||||
|
void serial_echo_start_P(const int8_t p) { serialprintPGM_P(p, echomagic); }
|
||||||
|
void serial_error_start_P(const int8_t p) { serialprintPGM_P(p, errormagic); }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void serialprintPGM(PGM_P str) {
|
void serialprintPGM(PGM_P str) {
|
||||||
|
@ -59,6 +63,9 @@ void serial_echopair_PGM(PGM_P s_P, unsigned long v) { serialprintPGM(s_P); SERI
|
||||||
|
|
||||||
void serial_spaces(uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (count--) SERIAL_CHAR(' '); }
|
void serial_spaces(uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (count--) SERIAL_CHAR(' '); }
|
||||||
|
|
||||||
|
void serial_echo_start() { serialprintPGM(echomagic); }
|
||||||
|
void serial_error_start() { serialprintPGM(errormagic); }
|
||||||
|
|
||||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||||
|
|
||||||
#include "enum.h"
|
#include "enum.h"
|
||||||
|
|
|
@ -44,9 +44,6 @@ enum DebugFlags : unsigned char {
|
||||||
extern uint8_t marlin_debug_flags;
|
extern uint8_t marlin_debug_flags;
|
||||||
#define DEBUGGING(F) (marlin_debug_flags & (DEBUG_## F))
|
#define DEBUGGING(F) (marlin_debug_flags & (DEBUG_## F))
|
||||||
|
|
||||||
extern const char echomagic[] PROGMEM;
|
|
||||||
extern const char errormagic[] PROGMEM;
|
|
||||||
|
|
||||||
#if TX_BUFFER_SIZE < 1
|
#if TX_BUFFER_SIZE < 1
|
||||||
#define SERIAL_FLUSHTX_P(p)
|
#define SERIAL_FLUSHTX_P(p)
|
||||||
#define SERIAL_FLUSHTX()
|
#define SERIAL_FLUSHTX()
|
||||||
|
@ -82,9 +79,9 @@ extern const char errormagic[] PROGMEM;
|
||||||
#define SERIAL_PROTOCOLPGM_P(p,x) (serialprintPGM_P(p,PSTR(x)))
|
#define SERIAL_PROTOCOLPGM_P(p,x) (serialprintPGM_P(p,PSTR(x)))
|
||||||
#define SERIAL_PROTOCOLLNPGM_P(p,x) (serialprintPGM_P(p,PSTR(x "\n")))
|
#define SERIAL_PROTOCOLLNPGM_P(p,x) (serialprintPGM_P(p,PSTR(x "\n")))
|
||||||
#define SERIAL_PROTOCOLPAIR_P(p, pre, value) (serial_echopair_PGM_P(p,PSTR(pre),(value)))
|
#define SERIAL_PROTOCOLPAIR_P(p, pre, value) (serial_echopair_PGM_P(p,PSTR(pre),(value)))
|
||||||
#define SERIAL_PROTOCOLLNPAIR_P(p, pre, value) do { SERIAL_PROTOCOLPAIR_P(p, pre, value); SERIAL_EOL_P(p); } while(0)
|
#define SERIAL_PROTOCOLLNPAIR_P(p, pre, value) do{ SERIAL_PROTOCOLPAIR_P(p, pre, value); SERIAL_EOL_P(p); }while(0)
|
||||||
|
|
||||||
#define SERIAL_ECHO_START_P(p) (serialprintPGM_P(p,echomagic))
|
#define SERIAL_ECHO_START_P(p) serial_echo_start_P(p)
|
||||||
#define SERIAL_ECHO_P(p,x) SERIAL_PROTOCOL_P(p,x)
|
#define SERIAL_ECHO_P(p,x) SERIAL_PROTOCOL_P(p,x)
|
||||||
#define SERIAL_ECHOPGM_P(p,x) SERIAL_PROTOCOLPGM_P(p,x)
|
#define SERIAL_ECHOPGM_P(p,x) SERIAL_PROTOCOLPGM_P(p,x)
|
||||||
#define SERIAL_ECHOLN_P(p,x) SERIAL_PROTOCOLLN_P(p,x)
|
#define SERIAL_ECHOLN_P(p,x) SERIAL_PROTOCOLLN_P(p,x)
|
||||||
|
@ -93,7 +90,7 @@ extern const char errormagic[] PROGMEM;
|
||||||
#define SERIAL_ECHOLNPAIR_P(p,pre, value) SERIAL_PROTOCOLLNPAIR_P(p, pre, value)
|
#define SERIAL_ECHOLNPAIR_P(p,pre, value) SERIAL_PROTOCOLLNPAIR_P(p, pre, value)
|
||||||
#define SERIAL_ECHO_F_P(p,x,y) SERIAL_PROTOCOL_F_P(p,x,y)
|
#define SERIAL_ECHO_F_P(p,x,y) SERIAL_PROTOCOL_F_P(p,x,y)
|
||||||
|
|
||||||
#define SERIAL_ERROR_START_P(p) (serialprintPGM_P(p,errormagic))
|
#define SERIAL_ERROR_START_P(p) serial_error_start_P(p)
|
||||||
#define SERIAL_ERROR_P(p,x) SERIAL_PROTOCOL_P(p,x)
|
#define SERIAL_ERROR_P(p,x) SERIAL_PROTOCOL_P(p,x)
|
||||||
#define SERIAL_ERRORPGM_P(p,x) SERIAL_PROTOCOLPGM_P(p,x)
|
#define SERIAL_ERRORPGM_P(p,x) SERIAL_PROTOCOLPGM_P(p,x)
|
||||||
#define SERIAL_ERRORLN_P(p,x) SERIAL_PROTOCOLLN_P(p,x)
|
#define SERIAL_ERRORLN_P(p,x) SERIAL_PROTOCOLLN_P(p,x)
|
||||||
|
@ -123,7 +120,11 @@ extern const char errormagic[] PROGMEM;
|
||||||
#define SERIAL_PROTOCOL_SP_P(p,C) serial_spaces_P(p,C)
|
#define SERIAL_PROTOCOL_SP_P(p,C) serial_spaces_P(p,C)
|
||||||
|
|
||||||
void serialprintPGM_P(const int8_t p, PGM_P str);
|
void serialprintPGM_P(const int8_t p, PGM_P str);
|
||||||
#else
|
void serial_echo_start_P(const int8_t p);
|
||||||
|
void serial_error_start_P(const int8_t p);
|
||||||
|
|
||||||
|
#else // NUM_SERIAL < 2
|
||||||
|
|
||||||
#define SERIAL_CHAR_P(p,x) SERIAL_CHAR(x)
|
#define SERIAL_CHAR_P(p,x) SERIAL_CHAR(x)
|
||||||
#define SERIAL_PROTOCOL_P(p,x) SERIAL_PROTOCOL(x)
|
#define SERIAL_PROTOCOL_P(p,x) SERIAL_PROTOCOL(x)
|
||||||
#define SERIAL_PROTOCOL_F_P(p,x,y) SERIAL_PROTOCOL_F(x,y)
|
#define SERIAL_PROTOCOL_F_P(p,x,y) SERIAL_PROTOCOL_F(x,y)
|
||||||
|
@ -184,7 +185,8 @@ extern const char errormagic[] PROGMEM;
|
||||||
#define SERIAL_PROTOCOL_SP_P(p,C) SERIAL_PROTOCOL_SP(C)
|
#define SERIAL_PROTOCOL_SP_P(p,C) SERIAL_PROTOCOL_SP(C)
|
||||||
|
|
||||||
#define serialprintPGM_P(p,s) serialprintPGM(s)
|
#define serialprintPGM_P(p,s) serialprintPGM(s)
|
||||||
#endif
|
|
||||||
|
#endif // NUM_SERIAL < 2
|
||||||
|
|
||||||
#define SERIAL_EOL() SERIAL_CHAR('\n')
|
#define SERIAL_EOL() SERIAL_CHAR('\n')
|
||||||
|
|
||||||
|
@ -194,7 +196,7 @@ extern const char errormagic[] PROGMEM;
|
||||||
#define SERIAL_PROTOCOLPAIR(pre, value) (serial_echopair_PGM(PSTR(pre), value))
|
#define SERIAL_PROTOCOLPAIR(pre, value) (serial_echopair_PGM(PSTR(pre), value))
|
||||||
#define SERIAL_PROTOCOLLNPAIR(pre, value) do { SERIAL_PROTOCOLPAIR(pre, value); SERIAL_EOL(); } while(0)
|
#define SERIAL_PROTOCOLLNPAIR(pre, value) do { SERIAL_PROTOCOLPAIR(pre, value); SERIAL_EOL(); } while(0)
|
||||||
|
|
||||||
#define SERIAL_ECHO_START() (serialprintPGM(echomagic))
|
#define SERIAL_ECHO_START() serial_echo_start()
|
||||||
#define SERIAL_ECHO(x) SERIAL_PROTOCOL(x)
|
#define SERIAL_ECHO(x) SERIAL_PROTOCOL(x)
|
||||||
#define SERIAL_ECHOPGM(x) SERIAL_PROTOCOLPGM(x)
|
#define SERIAL_ECHOPGM(x) SERIAL_PROTOCOLPGM(x)
|
||||||
#define SERIAL_ECHOLN(x) SERIAL_PROTOCOLLN(x)
|
#define SERIAL_ECHOLN(x) SERIAL_PROTOCOLLN(x)
|
||||||
|
@ -203,7 +205,7 @@ extern const char errormagic[] PROGMEM;
|
||||||
#define SERIAL_ECHOLNPAIR(pre, value) SERIAL_PROTOCOLLNPAIR(pre, value)
|
#define SERIAL_ECHOLNPAIR(pre, value) SERIAL_PROTOCOLLNPAIR(pre, value)
|
||||||
#define SERIAL_ECHO_F(x,y) SERIAL_PROTOCOL_F(x, y)
|
#define SERIAL_ECHO_F(x,y) SERIAL_PROTOCOL_F(x, y)
|
||||||
|
|
||||||
#define SERIAL_ERROR_START() (serialprintPGM(errormagic))
|
#define SERIAL_ERROR_START() serial_error_start()
|
||||||
#define SERIAL_ERROR(x) SERIAL_PROTOCOL(x)
|
#define SERIAL_ERROR(x) SERIAL_PROTOCOL(x)
|
||||||
#define SERIAL_ERRORPGM(x) SERIAL_PROTOCOLPGM(x)
|
#define SERIAL_ERRORPGM(x) SERIAL_PROTOCOLPGM(x)
|
||||||
#define SERIAL_ERRORLN(x) SERIAL_PROTOCOLLN(x)
|
#define SERIAL_ERRORLN(x) SERIAL_PROTOCOLLN(x)
|
||||||
|
@ -236,6 +238,8 @@ void serial_spaces(uint8_t count);
|
||||||
// Functions for serial printing from PROGMEM. (Saves loads of SRAM.)
|
// Functions for serial printing from PROGMEM. (Saves loads of SRAM.)
|
||||||
//
|
//
|
||||||
void serialprintPGM(PGM_P str);
|
void serialprintPGM(PGM_P str);
|
||||||
|
void serial_echo_start();
|
||||||
|
void serial_error_start();
|
||||||
|
|
||||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||||
void print_xyz(PGM_P prefix, PGM_P suffix, const float x, const float y, const float z);
|
void print_xyz(PGM_P prefix, PGM_P suffix, const float x, const float y, const float z);
|
||||||
|
|
Loading…
Reference in a new issue