Convert config code to a static class

This commit is contained in:
Scott Lahteine
2017-04-09 21:47:49 -05:00
parent 5b9476fe78
commit 786af73e24
4 changed files with 75 additions and 46 deletions

View File

@ -25,19 +25,38 @@
#include "MarlinConfig.h"
void Config_ResetDefault();
bool Config_StoreSettings();
class MarlinSettings {
public:
MarlinSettings() { }
#if DISABLED(DISABLE_M503)
void Config_PrintSettings(bool forReplay=false);
#else
FORCE_INLINE void Config_PrintSettings(bool forReplay=false) {}
#endif
static void reset();
static bool save();
#if ENABLED(EEPROM_SETTINGS)
bool Config_RetrieveSettings();
#else
FORCE_INLINE bool Config_RetrieveSettings() { Config_ResetDefault(); Config_PrintSettings(); return true; }
#endif
#if ENABLED(EEPROM_SETTINGS)
static bool load();
#else
FORCE_INLINE
static bool load() { reset(); report(); return true; }
#endif
#endif //CONFIGURATION_STORE_H
#if DISABLED(DISABLE_M503)
static void report(bool forReplay=false);
#else
FORCE_INLINE
static void report(bool forReplay=false) { }
#endif
private:
static void postprocess();
#if ENABLED(EEPROM_SETTINGS)
static uint16_t eeprom_checksum;
static bool eeprom_read_error, eeprom_write_error;
static void write_data(int &pos, const uint8_t* value, uint16_t size);
static void read_data(int &pos, uint8_t* value, uint16_t size);
#endif
};
extern MarlinSettings settings;
#endif // CONFIGURATION_STORE_H