Simplify serial port redirect (#13234)

This commit is contained in:
Scott Lahteine
2019-02-23 22:53:01 -06:00
committed by GitHub
parent 88cc1d1a31
commit e15354e387
22 changed files with 575 additions and 876 deletions

File diff suppressed because it is too large Load Diff

View File

@ -27,24 +27,14 @@
#include "../HAL/shared/persistent_store_api.h"
#endif
#define ADD_PORT_ARG ENABLED(EEPROM_CHITCHAT) && NUM_SERIAL > 1
#if ADD_PORT_ARG
#define PORTINIT_SOLO const int8_t port=-1
#define PORTINIT_AFTER ,const int8_t port=-1
#else
#define PORTINIT_SOLO
#define PORTINIT_AFTER
#endif
class MarlinSettings {
public:
MarlinSettings() { }
static uint16_t datasize();
static void reset(PORTINIT_SOLO);
static bool save(PORTINIT_SOLO); // Return 'true' if data was saved
static void reset();
static bool save(); // Return 'true' if data was saved
FORCE_INLINE static bool init_eeprom() {
reset();
@ -65,8 +55,8 @@ class MarlinSettings {
#endif
#if ENABLED(EEPROM_SETTINGS)
static bool load(PORTINIT_SOLO); // Return 'true' if data was loaded ok
static bool validate(PORTINIT_SOLO); // Return 'true' if EEPROM data is ok
static bool load(); // Return 'true' if data was loaded ok
static bool validate(); // Return 'true' if EEPROM data is ok
#if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system
// That can store is enabled
@ -86,11 +76,7 @@ class MarlinSettings {
#endif
#if DISABLED(DISABLE_M503)
static void report(const bool forReplay=false
#if NUM_SERIAL > 1
, const int8_t port=-1
#endif
);
static void report(const bool forReplay=false);
#else
FORCE_INLINE
static void report(const bool forReplay=false) { UNUSED(forReplay); }
@ -109,12 +95,9 @@ class MarlinSettings {
// live at the very end of the eeprom
#endif
static bool _load(PORTINIT_SOLO);
static bool size_error(const uint16_t size PORTINIT_AFTER);
static bool _load();
static bool size_error(const uint16_t size);
#endif
};
extern MarlinSettings settings;
#undef PORTINIT_SOLO
#undef PORTINIT_AFTER

View File

@ -2500,17 +2500,14 @@ void Temperature::isr() {
#if ENABLED(SHOW_TEMP_ADC_VALUES)
, const float r
#endif
#if NUM_SERIAL > 1
, const int8_t port=-1
#endif
, const int8_t e=-3
) {
#if !(HAS_HEATED_BED && HAS_TEMP_HOTEND && HAS_TEMP_CHAMBER) && HOTENDS <= 1
UNUSED(e);
#endif
SERIAL_CHAR_P(port, ' ');
SERIAL_CHAR_P(port,
SERIAL_CHAR(' ');
SERIAL_CHAR(
#if HAS_TEMP_CHAMBER && HAS_HEATED_BED && HAS_TEMP_HOTEND
e == -2 ? 'C' : e == -1 ? 'B' : 'T'
#elif HAS_HEATED_BED && HAS_TEMP_HOTEND
@ -2522,23 +2519,19 @@ void Temperature::isr() {
#endif
);
#if HOTENDS > 1
if (e >= 0) SERIAL_CHAR_P(port, '0' + e);
if (e >= 0) SERIAL_CHAR('0' + e);
#endif
SERIAL_CHAR_P(port, ':');
SERIAL_ECHO_P(port, c);
SERIAL_ECHOPAIR_P(port, " /" , t);
SERIAL_CHAR(':');
SERIAL_ECHO(c);
SERIAL_ECHOPAIR(" /" , t);
#if ENABLED(SHOW_TEMP_ADC_VALUES)
SERIAL_ECHOPAIR_P(port, " (", r / OVERSAMPLENR);
SERIAL_CHAR_P(port, ')');
SERIAL_ECHOPAIR(" (", r / OVERSAMPLENR);
SERIAL_CHAR(')');
#endif
delay(2);
}
void Temperature::print_heater_states(const uint8_t target_extruder
#if NUM_SERIAL > 1
, const int8_t port
#endif
) {
void Temperature::print_heater_states(const uint8_t target_extruder) {
#if HAS_TEMP_HOTEND
print_heater_state(degHotend(target_extruder), degTargetHotend(target_extruder)
#if ENABLED(SHOW_TEMP_ADC_VALUES)
@ -2579,17 +2572,17 @@ void Temperature::isr() {
, e
);
#endif
SERIAL_ECHOPGM_P(port, " @:");
SERIAL_ECHO_P(port, getHeaterPower(target_extruder));
SERIAL_ECHOPGM(" @:");
SERIAL_ECHO(getHeaterPower(target_extruder));
#if HAS_HEATED_BED
SERIAL_ECHOPGM_P(port, " B@:");
SERIAL_ECHO_P(port, getHeaterPower(-1));
SERIAL_ECHOPGM(" B@:");
SERIAL_ECHO(getHeaterPower(-1));
#endif
#if HOTENDS > 1
HOTEND_LOOP() {
SERIAL_ECHOPAIR_P(port, " @", e);
SERIAL_CHAR_P(port, ':');
SERIAL_ECHO_P(port, getHeaterPower(e));
SERIAL_ECHOPAIR(" @", e);
SERIAL_CHAR(':');
SERIAL_ECHO(getHeaterPower(e));
}
#endif
}

View File

@ -672,11 +672,7 @@ class Temperature {
#endif // HEATER_IDLE_HANDLER
#if HAS_TEMP_SENSOR
static void print_heater_states(const uint8_t target_extruder
#if NUM_SERIAL > 1
, const int8_t port = -1
#endif
);
static void print_heater_states(const uint8_t target_extruder);
#if ENABLED(AUTO_REPORT_TEMPERATURES)
static uint8_t auto_report_temp_interval;
static millis_t next_temp_report_ms;