Browse Source

Pretty up EEPROM port args

pull/1/head
Scott Lahteine 7 years ago
parent
commit
4aebe3d82e
  1. 87
      Marlin/src/module/configuration_store.cpp
  2. 47
      Marlin/src/module/configuration_store.h

87
Marlin/src/module/configuration_store.cpp

@ -45,6 +45,17 @@
//#define DEBUG_EEPROM_READWRITE //#define DEBUG_EEPROM_READWRITE
#include "configuration_store.h" #include "configuration_store.h"
#if ADD_PORT_ARG
#define PORTARG_SOLO const int8_t port
#define PORTARG_AFTER ,const int8_t port
#define PORTVAR_SOLO port
#else
#define PORTARG_SOLO
#define PORTARG_AFTER
#define PORTVAR_SOLO
#endif
#include "endstops.h" #include "endstops.h"
#include "planner.h" #include "planner.h"
#include "stepper.h" #include "stepper.h"
@ -345,11 +356,7 @@ void MarlinSettings::postprocess() {
bool MarlinSettings::eeprom_error, MarlinSettings::validating; bool MarlinSettings::eeprom_error, MarlinSettings::validating;
bool MarlinSettings::size_error(const uint16_t size bool MarlinSettings::size_error(const uint16_t size PORTARG_AFTER) {
#if ADD_PORT_ARG
, const int8_t port/*=-1*/
#endif
) {
if (size != datasize()) { if (size != datasize()) {
#if ENABLED(EEPROM_CHITCHAT) #if ENABLED(EEPROM_CHITCHAT)
SERIAL_ERROR_START_P(port); SERIAL_ERROR_START_P(port);
@ -363,11 +370,7 @@ void MarlinSettings::postprocess() {
/** /**
* M500 - Store Configuration * M500 - Store Configuration
*/ */
bool MarlinSettings::save( bool MarlinSettings::save(PORTARG_SOLO) {
#if ADD_PORT_ARG
const int8_t port/*=-1*/
#endif
) {
float dummy = 0.0f; float dummy = 0.0f;
char ver[4] = "ERR"; char ver[4] = "ERR";
@ -853,11 +856,7 @@ void MarlinSettings::postprocess() {
/** /**
* M501 - Retrieve Configuration * M501 - Retrieve Configuration
*/ */
bool MarlinSettings::_load( bool MarlinSettings::_load(PORTARG_SOLO) {
#if ADD_PORT_ARG
const int8_t port/*=-1*/
#endif
) {
uint16_t working_crc = 0; uint16_t working_crc = 0;
EEPROM_START(); EEPROM_START();
@ -1431,46 +1430,22 @@ void MarlinSettings::postprocess() {
} }
#if ENABLED(EEPROM_CHITCHAT) && DISABLED(DISABLE_M503) #if ENABLED(EEPROM_CHITCHAT) && DISABLED(DISABLE_M503)
if (!validating) report( if (!validating) report(PORTVAR_SOLO);
#if ADD_PORT_ARG
port
#endif
);
#endif #endif
EEPROM_FINISH(); EEPROM_FINISH();
return !eeprom_error; return !eeprom_error;
} }
bool MarlinSettings::validate( bool MarlinSettings::validate(PORTARG_SOLO) {
#if ADD_PORT_ARG
const int8_t port/*=-1*/
#endif
) {
validating = true; validating = true;
const bool success = _load( const bool success = _load(PORTVAR_SOLO);
#if ADD_PORT_ARG
port
#endif
);
validating = false; validating = false;
return success; return success;
} }
bool MarlinSettings::load( bool MarlinSettings::load(PORTARG_SOLO) {
#if ADD_PORT_ARG if (validate(PORTVAR_SOLO)) return _load(PORTVAR_SOLO);
const int8_t port/*=-1*/
#endif
) {
if (validate(
#if ADD_PORT_ARG
port
#endif
)) return _load(
#if ADD_PORT_ARG
port
#endif
);
reset(); reset();
return true; return true;
} }
@ -1581,11 +1556,7 @@ void MarlinSettings::postprocess() {
#else // !EEPROM_SETTINGS #else // !EEPROM_SETTINGS
bool MarlinSettings::save( bool MarlinSettings::save(PORTARG_SOLO) {
#if ADD_PORT_ARG
const int8_t port/*=-1*/
#endif
) {
#if ENABLED(EEPROM_CHITCHAT) #if ENABLED(EEPROM_CHITCHAT)
SERIAL_ERROR_START_P(port); SERIAL_ERROR_START_P(port);
SERIAL_ERRORLNPGM_P(port, "EEPROM disabled"); SERIAL_ERRORLNPGM_P(port, "EEPROM disabled");
@ -1598,11 +1569,7 @@ void MarlinSettings::postprocess() {
/** /**
* M502 - Reset Configuration * M502 - Reset Configuration
*/ */
void MarlinSettings::reset( void MarlinSettings::reset(PORTARG_SOLO) {
#if ADD_PORT_ARG
const int8_t port/*=-1*/
#endif
) {
static const float tmp1[] PROGMEM = DEFAULT_AXIS_STEPS_PER_UNIT, tmp2[] PROGMEM = DEFAULT_MAX_FEEDRATE; static const float tmp1[] PROGMEM = DEFAULT_AXIS_STEPS_PER_UNIT, tmp2[] PROGMEM = DEFAULT_MAX_FEEDRATE;
static const uint32_t tmp3[] PROGMEM = DEFAULT_MAX_ACCELERATION; static const uint32_t tmp3[] PROGMEM = DEFAULT_MAX_ACCELERATION;
LOOP_XYZE_N(i) { LOOP_XYZE_N(i) {
@ -1860,11 +1827,7 @@ void MarlinSettings::reset(
#if DISABLED(DISABLE_M503) #if DISABLED(DISABLE_M503)
#if ADD_PORT_ARG #define CONFIG_ECHO_START do{ if (!forReplay) SERIAL_ECHO_START_P(PORTVAR_SOLO); }while(0)
#define CONFIG_ECHO_START do{ if (!forReplay) SERIAL_ECHO_START_P(port); }while(0)
#else
#define CONFIG_ECHO_START do{ if (!forReplay) SERIAL_ECHO_START(); }while(0)
#endif
/** /**
* M503 - Report current settings in RAM * M503 - Report current settings in RAM
@ -2129,11 +2092,7 @@ void MarlinSettings::reset(
SERIAL_ECHOLNPGM_P(port, " meshes.\n"); SERIAL_ECHOLNPGM_P(port, " meshes.\n");
} }
ubl.report_current_mesh( ubl.report_current_mesh(PORTVAR_SOLO);
#if ADD_PORT_ARG
port
#endif
);
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR) #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)

47
Marlin/src/module/configuration_store.h

@ -27,22 +27,22 @@
#define ADD_PORT_ARG ENABLED(EEPROM_CHITCHAT) && NUM_SERIAL > 1 #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 { class MarlinSettings {
public: public:
MarlinSettings() { } MarlinSettings() { }
static uint16_t datasize(); static uint16_t datasize();
static void reset( static void reset(PORTINIT_SOLO);
#if ADD_PORT_ARG static bool save(PORTINIT_SOLO); // Return 'true' if data was saved
const int8_t port=-1
#endif
);
static bool save(
#if ADD_PORT_ARG
const int8_t port=-1
#endif
); // Return 'true' if data was saved
FORCE_INLINE static bool init_eeprom() { FORCE_INLINE static bool init_eeprom() {
bool success = true; bool success = true;
@ -57,16 +57,8 @@ class MarlinSettings {
} }
#if ENABLED(EEPROM_SETTINGS) #if ENABLED(EEPROM_SETTINGS)
static bool load( static bool load(PORTINIT_SOLO); // Return 'true' if data was loaded ok
#if ADD_PORT_ARG static bool validate(PORTINIT_SOLO); // Return 'true' if EEPROM data is ok
const int8_t port=-1
#endif
); // Return 'true' if data was loaded ok
static bool validate(
#if ADD_PORT_ARG
const int8_t port=-1
#endif
); // Return 'true' if EEPROM data is ok
#if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system #if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system
// That can store is enabled // That can store is enabled
@ -110,19 +102,14 @@ class MarlinSettings {
#endif #endif
static bool _load( static bool _load(PORTINIT_SOLO);
#if ADD_PORT_ARG static bool size_error(const uint16_t size PORTINIT_AFTER);
const int8_t port=-1
#endif
);
static bool size_error(const uint16_t size
#if ADD_PORT_ARG
, const int8_t port=-1
#endif
);
#endif #endif
}; };
extern MarlinSettings settings; extern MarlinSettings settings;
#undef PORTINIT_SOLO
#undef PORTINIT_AFTER
#endif // CONFIGURATION_STORE_H #endif // CONFIGURATION_STORE_H

Loading…
Cancel
Save