Reduce UBL RAM usage by making G26/G29 optional

2.0.x
Bob-the-Kuhn 8 years ago committed by Scott Lahteine
parent e746d68a12
commit f3618c3337

@ -113,6 +113,7 @@
* Y # Y coordinate Specify the starting location of the drawing activity.
*/
extern bool g26_debug_flag;
extern bool ubl_has_control_of_lcd_panel;
extern float feedrate;
//extern bool relative_mode;
@ -171,8 +172,7 @@
int8_t prime_flag = 0;
bool keep_heaters_on = false,
g26_debug_flag = false;
bool keep_heaters_on = false;
/**
* G26: Mesh Validation Pattern generation.

@ -299,11 +299,13 @@
#if ENABLED(AUTO_BED_LEVELING_UBL)
#include "UBL.h"
unified_bed_leveling ubl;
#define UBL_MESH_VALID !( z_values[0][0] == z_values[0][1] && z_values[0][1] == z_values[0][2] \
&& z_values[1][0] == z_values[1][1] && z_values[1][1] == z_values[1][2] \
&& z_values[2][0] == z_values[2][1] && z_values[2][1] == z_values[2][2] \
&& z_values[0][0] == 0 && z_values[1][0] == 0 && z_values[2][0] == 0 \
|| isnan(z_values[0][0]))
#define UBL_MESH_VALID !( ( z_values[0][0] == z_values[0][1] && z_values[0][1] == z_values[0][2] \
&& z_values[1][0] == z_values[1][1] && z_values[1][1] == z_values[1][2] \
&& z_values[2][0] == z_values[2][1] && z_values[2][1] == z_values[2][2] \
&& z_values[0][0] == 0 && z_values[1][0] == 0 && z_values[2][0] == 0 ) \
|| isnan(z_values[0][0]))
extern bool g26_debug_flag;
extern int ubl_eeprom_start;
#endif
bool Running = true;
@ -7213,10 +7215,54 @@ void quickstop_stepper() {
* S[bool] Turns leveling on or off
* Z[height] Sets the Z fade height (0 or none to disable)
* V[bool] Verbose - Print the leveling grid
*
* L[index] Load UBL mesh from index (0 is default)
*/
inline void gcode_M420() {
bool to_enable = false;
#if ENABLED(AUTO_BED_LEVELING_UBL)
// L to load a mesh from the EEPROM
if (code_seen('L')) {
const int8_t storage_slot = code_has_value() ? code_value_int() : ubl.state.eeprom_storage_slot;
const int16_t j = (UBL_LAST_EEPROM_INDEX - ubl.eeprom_start) / sizeof(z_values);
if (storage_slot < 0 || storage_slot >= j || ubl.eeprom_start <= 0) {
SERIAL_PROTOCOLLNPGM("?EEPROM storage not available for use.\n");
return;
}
ubl.load_mesh(Storage_Slot);
ubl.state.eeprom_storage_slot = Storage_Slot;
if (Storage_Slot != ubl.state.eeprom_storage_slot)
ubl.store_state();
ubl.display_map(0); // Right now, we only support one type of map
SERIAL_ECHOLNPAIR("UBL_MESH_VALID = ", UBL_MESH_VALID);
SERIAL_ECHOLNPAIR("eeprom_storage_slot = ", ubl.state.eeprom_storage_slot);
}
#endif // AUTO_BED_LEVELING_UBL
// V to print the matrix or mesh
if (code_seen('V')) {
#if ABL_PLANAR
planner.bed_level_matrix.debug("Bed Level Correction Matrix:");
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
if (bilinear_grid_spacing[X_AXIS]) {
print_bilinear_leveling_grid();
#if ENABLED(ABL_BILINEAR_SUBDIVISION)
bed_level_virt_print();
#endif
}
#elif ENABLED(AUTO_BED_LEVELING_UBL)
ubl.display_map(0); // Currently only supports one map type
SERIAL_ECHOLNPAIR("UBL_MESH_VALID = ", UBL_MESH_VALID);
SERIAL_ECHOLNPAIR("eeprom_storage_slot = ", ubl.state.eeprom_storage_slot);
#elif ENABLED(MESH_BED_LEVELING)
if (mbl.has_mesh()) {
SERIAL_ECHOLNPGM("Mesh Bed Level data:");
mbl_mesh_report();
}
#endif
}
bool to_enable = false;
if (code_seen('S')) {
to_enable = code_value_bool();
set_bed_leveling_enabled(to_enable);
@ -7243,28 +7289,6 @@ void quickstop_stepper() {
SERIAL_ECHO_START;
SERIAL_ECHOLNPAIR("Bed Leveling ", new_status ? MSG_ON : MSG_OFF);
// V to print the matrix or mesh
if (code_seen('V')) {
#if ABL_PLANAR
planner.bed_level_matrix.debug("Bed Level Correction Matrix:");
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
if (bilinear_grid_spacing[X_AXIS]) {
print_bilinear_leveling_grid();
#if ENABLED(ABL_BILINEAR_SUBDIVISION)
bed_level_virt_print();
#endif
}
#elif ENABLED(AUTO_BED_LEVELING_UBL)
ubl.display_map(0); // Right now, we only support one type of map
#elif ENABLED(MESH_BED_LEVELING)
if (mbl.has_mesh()) {
SERIAL_ECHOLNPGM("Mesh Bed Level data:");
mbl_mesh_report();
}
#endif
}
}
#endif
@ -8595,7 +8619,7 @@ void process_next_command() {
gcode_G28();
break;
#if PLANNER_LEVELING
#if PLANNER_LEVELING && !ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(AUTO_BED_LEVELING_UBL) && ENABLED(UBL_MESH_EDIT_ENABLED)
case 29: // G29 Detailed Z probe, probes the bed at 3 or more points,
// or provides access to the UBL System if enabled.
gcode_G29();

@ -81,11 +81,6 @@
#define MESH_X_DIST ((float(UBL_MESH_MAX_X) - float(UBL_MESH_MIN_X)) / (float(UBL_MESH_NUM_X_POINTS) - 1.0))
#define MESH_Y_DIST ((float(UBL_MESH_MAX_Y) - float(UBL_MESH_MIN_Y)) / (float(UBL_MESH_NUM_Y_POINTS) - 1.0))
#if ENABLED(UBL_MESH_EDIT_ENABLED)
extern bool g26_debug_flag;
#else
constexpr bool g26_debug_flag = false;
#endif
extern float last_specified_z;
extern float fade_scaling_factor_for_current_height;
extern float z_values[UBL_MESH_NUM_X_POINTS][UBL_MESH_NUM_Y_POINTS];
@ -339,7 +334,6 @@
}; // class unified_bed_leveling
extern unified_bed_leveling ubl;
extern int ubl_eeprom_start;
#define UBL_LAST_EEPROM_INDEX (E2END - sizeof(unified_bed_leveling::state))

@ -27,6 +27,7 @@
#include "UBL.h"
#include "hex_print_routines.h"
extern int ubl_eeprom_start;
/**
* These support functions allow the use of large bit arrays of flags that take very

@ -22,7 +22,7 @@
#include "MarlinConfig.h"
#if ENABLED(AUTO_BED_LEVELING_UBL)
#if ENABLED(AUTO_BED_LEVELING_UBL) && ENABLED(UBL_MESH_EDIT_ENABLED)
//#include "vector_3.h"
//#include "qr_solve.h"
@ -39,7 +39,10 @@
void lcd_return_to_status();
bool lcd_clicked();
void lcd_implementation_clear();
void lcd_mesh_edit_setup(float initial);
float lcd_mesh_edit();
void lcd_z_offset_edit_setup(float);
float lcd_z_offset_edit();
extern float meshedit_done;
extern long babysteps_done;
extern float code_value_float();
@ -62,6 +65,8 @@
#define SIZE_OF_LITTLE_RAISE 0
#define BIG_RAISE_NOT_NEEDED 0
extern void lcd_quick_feedback();
extern int ubl_eeprom_start;
extern volatile int ubl_encoderDiff; // This is volatile because it is getting changed at interrupt time.
/**
* G29: Unified Bed Leveling by Roxy

@ -31,7 +31,8 @@
extern float destination[XYZE];
extern void set_current_to_destination();
extern float destination[];
bool g26_debug_flag = false;
void debug_current_and_destination(char *title) {
// if the title message starts with a '!' it is so important, we are going to
@ -314,7 +315,7 @@
* because part of the Mesh is undefined and we don't have the
* information we need to complete the height correction.
*/
if (isnan(z0)) z0 = 0.0;
if (isnan(z0)) z0 = 0.0;
const float y = LOGICAL_Y_POSITION(mesh_index_to_y_location[current_yi]);

@ -166,6 +166,7 @@
#if ENABLED(AUTO_BED_LEVELING_UBL)
#include "UBL.h"
int ubl_eeprom_start = -1;
#endif
#if ENABLED(ABL_BILINEAR_SUBDIVISION)

Loading…
Cancel
Save