ubl_state no longer needed

master
Scott Lahteine 7 years ago
parent ece14af556
commit b8ddae61e2

@ -9335,7 +9335,7 @@ void quickstop_stepper() {
if (parser.seen('L')) { if (parser.seen('L')) {
#if ENABLED(EEPROM_SETTINGS) #if ENABLED(EEPROM_SETTINGS)
const int8_t storage_slot = parser.has_value() ? parser.value_int() : ubl.state.storage_slot; const int8_t storage_slot = parser.has_value() ? parser.value_int() : ubl.storage_slot;
const int16_t a = settings.calc_num_meshes(); const int16_t a = settings.calc_num_meshes();
if (!a) { if (!a) {
@ -9350,7 +9350,7 @@ void quickstop_stepper() {
} }
settings.load_mesh(storage_slot); settings.load_mesh(storage_slot);
ubl.state.storage_slot = storage_slot; ubl.storage_slot = storage_slot;
#else #else
@ -9364,7 +9364,7 @@ void quickstop_stepper() {
if (parser.seen('L') || parser.seen('V')) { if (parser.seen('L') || parser.seen('V')) {
ubl.display_map(0); // Currently only supports one map type ubl.display_map(0); // Currently only supports one map type
SERIAL_ECHOLNPAIR("UBL_MESH_VALID = ", UBL_MESH_VALID); SERIAL_ECHOLNPAIR("UBL_MESH_VALID = ", UBL_MESH_VALID);
SERIAL_ECHOLNPAIR("ubl.state.storage_slot = ", ubl.state.storage_slot); SERIAL_ECHOLNPAIR("ubl.storage_slot = ", ubl.storage_slot);
} }
#endif // AUTO_BED_LEVELING_UBL #endif // AUTO_BED_LEVELING_UBL

@ -89,7 +89,7 @@
* *
* AUTO_BED_LEVELING_UBL: 6 bytes * AUTO_BED_LEVELING_UBL: 6 bytes
* 324 G29 A planner.leveling_active (bool) * 324 G29 A planner.leveling_active (bool)
* 325 G29 S ubl.state.storage_slot (int8_t) * 325 G29 S ubl.storage_slot (int8_t)
* *
* DELTA: 48 bytes * DELTA: 48 bytes
* 348 M666 XYZ endstop_adj (float x3) * 348 M666 XYZ endstop_adj (float x3)
@ -440,7 +440,7 @@ void MarlinSettings::postprocess() {
#if ENABLED(AUTO_BED_LEVELING_UBL) #if ENABLED(AUTO_BED_LEVELING_UBL)
EEPROM_WRITE(planner.leveling_active); EEPROM_WRITE(planner.leveling_active);
EEPROM_WRITE(ubl.state.storage_slot); EEPROM_WRITE(ubl.storage_slot);
#else #else
const bool ubl_active = false; const bool ubl_active = false;
const int8_t storage_slot = -1; const int8_t storage_slot = -1;
@ -665,8 +665,8 @@ void MarlinSettings::postprocess() {
} }
#if ENABLED(UBL_SAVE_ACTIVE_ON_M500) #if ENABLED(UBL_SAVE_ACTIVE_ON_M500)
if (ubl.state.storage_slot >= 0) if (ubl.storage_slot >= 0)
store_mesh(ubl.state.storage_slot); store_mesh(ubl.storage_slot);
#endif #endif
return !eeprom_error; return !eeprom_error;
@ -829,7 +829,7 @@ void MarlinSettings::postprocess() {
#if ENABLED(AUTO_BED_LEVELING_UBL) #if ENABLED(AUTO_BED_LEVELING_UBL)
EEPROM_READ(planner.leveling_active); EEPROM_READ(planner.leveling_active);
EEPROM_READ(ubl.state.storage_slot); EEPROM_READ(ubl.storage_slot);
#else #else
uint8_t dummyui8; uint8_t dummyui8;
EEPROM_READ(dummyb); EEPROM_READ(dummyb);
@ -1046,10 +1046,10 @@ void MarlinSettings::postprocess() {
ubl.reset(); ubl.reset();
} }
if (ubl.state.storage_slot >= 0) { if (ubl.storage_slot >= 0) {
load_mesh(ubl.state.storage_slot); load_mesh(ubl.storage_slot);
#if ENABLED(EEPROM_CHITCHAT) #if ENABLED(EEPROM_CHITCHAT)
SERIAL_ECHOPAIR("Mesh ", ubl.state.storage_slot); SERIAL_ECHOPAIR("Mesh ", ubl.storage_slot);
SERIAL_ECHOLNPGM(" loaded from storage."); SERIAL_ECHOLNPGM(" loaded from storage.");
#endif #endif
} }
@ -1624,7 +1624,7 @@ void MarlinSettings::reset() {
if (!forReplay) { if (!forReplay) {
SERIAL_EOL(); SERIAL_EOL();
ubl.report_state(); ubl.report_state();
SERIAL_ECHOLNPAIR("\nActive Mesh Slot: ", ubl.state.storage_slot); SERIAL_ECHOLNPAIR("\nActive Mesh Slot: ", ubl.storage_slot);
SERIAL_ECHOPAIR("EEPROM can hold ", calc_num_meshes()); SERIAL_ECHOPAIR("EEPROM can hold ", calc_num_meshes());
SERIAL_ECHOLNPGM(" meshes.\n"); SERIAL_ECHOLNPGM(" meshes.\n");
} }

@ -61,7 +61,7 @@
safe_delay(10); safe_delay(10);
} }
ubl_state unified_bed_leveling::state; int8_t unified_bed_leveling::storage_slot;
float unified_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; float unified_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
@ -82,7 +82,7 @@
void unified_bed_leveling::reset() { void unified_bed_leveling::reset() {
set_bed_leveling_enabled(false); set_bed_leveling_enabled(false);
state.storage_slot = -1; storage_slot = -1;
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
planner.set_z_fade_height(10.0); planner.set_z_fade_height(10.0);
#endif #endif

@ -76,11 +76,6 @@
#define MESH_X_DIST (float(UBL_MESH_MAX_X - (UBL_MESH_MIN_X)) / float(GRID_MAX_POINTS_X - 1)) #define MESH_X_DIST (float(UBL_MESH_MAX_X - (UBL_MESH_MIN_X)) / float(GRID_MAX_POINTS_X - 1))
#define MESH_Y_DIST (float(UBL_MESH_MAX_Y - (UBL_MESH_MIN_Y)) / float(GRID_MAX_POINTS_Y - 1)) #define MESH_Y_DIST (float(UBL_MESH_MAX_Y - (UBL_MESH_MIN_Y)) / float(GRID_MAX_POINTS_Y - 1))
typedef struct {
bool active = false;
int8_t storage_slot = -1;
} ubl_state;
class unified_bed_leveling { class unified_bed_leveling {
private: private:
@ -165,7 +160,7 @@
static void G26(); static void G26();
#endif #endif
static ubl_state state; static int8_t storage_slot;
static float z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; static float z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];

@ -423,8 +423,8 @@
#endif // HAS_BED_PROBE #endif // HAS_BED_PROBE
if (parser.seen('P')) { if (parser.seen('P')) {
if (WITHIN(g29_phase_value, 0, 1) && state.storage_slot == -1) { if (WITHIN(g29_phase_value, 0, 1) && storage_slot == -1) {
state.storage_slot = 0; storage_slot = 0;
SERIAL_PROTOCOLLNPGM("Default storage slot 0 selected."); SERIAL_PROTOCOLLNPGM("Default storage slot 0 selected.");
} }
@ -603,7 +603,7 @@
// //
if (parser.seen('L')) { // Load Current Mesh Data if (parser.seen('L')) { // Load Current Mesh Data
g29_storage_slot = parser.has_value() ? parser.value_int() : state.storage_slot; g29_storage_slot = parser.has_value() ? parser.value_int() : storage_slot;
int16_t a = settings.calc_num_meshes(); int16_t a = settings.calc_num_meshes();
@ -619,7 +619,7 @@
} }
settings.load_mesh(g29_storage_slot); settings.load_mesh(g29_storage_slot);
state.storage_slot = g29_storage_slot; storage_slot = g29_storage_slot;
SERIAL_PROTOCOLLNPGM("Done."); SERIAL_PROTOCOLLNPGM("Done.");
} }
@ -629,7 +629,7 @@
// //
if (parser.seen('S')) { // Store (or Save) Current Mesh Data if (parser.seen('S')) { // Store (or Save) Current Mesh Data
g29_storage_slot = parser.has_value() ? parser.value_int() : state.storage_slot; g29_storage_slot = parser.has_value() ? parser.value_int() : storage_slot;
if (g29_storage_slot == -1) { // Special case, we are going to 'Export' the mesh to the if (g29_storage_slot == -1) { // Special case, we are going to 'Export' the mesh to the
SERIAL_ECHOLNPGM("G29 I 999"); // host in a form it can be reconstructed on a different machine SERIAL_ECHOLNPGM("G29 I 999"); // host in a form it can be reconstructed on a different machine
@ -661,7 +661,7 @@
} }
settings.store_mesh(g29_storage_slot); settings.store_mesh(g29_storage_slot);
state.storage_slot = g29_storage_slot; storage_slot = g29_storage_slot;
SERIAL_PROTOCOLLNPGM("Done."); SERIAL_PROTOCOLLNPGM("Done.");
} }
@ -1190,10 +1190,10 @@
void unified_bed_leveling::g29_what_command() { void unified_bed_leveling::g29_what_command() {
report_state(); report_state();
if (state.storage_slot == -1) if (storage_slot == -1)
SERIAL_PROTOCOLPGM("No Mesh Loaded."); SERIAL_PROTOCOLPGM("No Mesh Loaded.");
else { else {
SERIAL_PROTOCOLPAIR("Mesh ", state.storage_slot); SERIAL_PROTOCOLPAIR("Mesh ", storage_slot);
SERIAL_PROTOCOLPGM(" Loaded."); SERIAL_PROTOCOLPGM(" Loaded.");
} }
SERIAL_EOL(); SERIAL_EOL();

Loading…
Cancel
Save