Fix EEPROM servo angles init, section grouping

This commit is contained in:
Scott Lahteine 2018-11-04 16:14:54 -06:00
parent 9c0e05552e
commit c04cf127f7

View File

@ -432,6 +432,10 @@ void MarlinSettings::postprocess() {
const uint8_t esteppers = COUNT(planner.settings.axis_steps_per_mm) - XYZ;
EEPROM_WRITE(esteppers);
//
// Planner Motion
//
{
EEPROM_WRITE(planner.settings);
#if HAS_CLASSIC_JERK
@ -451,7 +455,12 @@ void MarlinSettings::postprocess() {
dummy = 0.02f;
EEPROM_WRITE(dummy);
#endif
}
//
// Home Offset
//
{
_FIELD_TEST(home_offset);
#if HAS_SCARA_OFFSET
@ -468,11 +477,12 @@ void MarlinSettings::postprocess() {
for (uint8_t e = 1; e < HOTENDS; e++)
LOOP_XYZ(i) EEPROM_WRITE(hotend_offset[i][e]);
#endif
}
//
// Global Leveling
//
{
const float zfh = (
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
planner.z_fade_height
@ -481,11 +491,12 @@ void MarlinSettings::postprocess() {
#endif
);
EEPROM_WRITE(zfh);
}
//
// Mesh Bed Leveling
//
{
#if ENABLED(MESH_BED_LEVELING)
// Compile time test that sizeof(mbl.z_values) is as expected
static_assert(
@ -504,30 +515,37 @@ void MarlinSettings::postprocess() {
EEPROM_WRITE(mesh_num_x);
EEPROM_WRITE(mesh_num_y);
for (uint8_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_WRITE(dummy);
#endif // MESH_BED_LEVELING
#endif
}
//
// Probe Z Offset
//
{
_FIELD_TEST(zprobe_zoffset);
#if !HAS_BED_PROBE
const float zprobe_zoffset = 0;
#endif
EEPROM_WRITE(zprobe_zoffset);
}
//
// Planar Bed Leveling matrix
//
{
#if ABL_PLANAR
EEPROM_WRITE(planner.bed_level_matrix);
#else
dummy = 0;
for (uint8_t q = 9; q--;) EEPROM_WRITE(dummy);
#endif
}
//
// Bilinear Auto Bed Leveling
//
{
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
// Compile time test that sizeof(z_values) is as expected
static_assert(
@ -550,8 +568,13 @@ void MarlinSettings::postprocess() {
EEPROM_WRITE(bilinear_grid_spacing);
EEPROM_WRITE(bilinear_start);
for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_WRITE(dummy);
#endif // AUTO_BED_LEVELING_BILINEAR
#endif
}
//
// Unified Bed Leveling
//
{
_FIELD_TEST(planner_leveling_active);
#if ENABLED(AUTO_BED_LEVELING_UBL)
@ -563,28 +586,49 @@ void MarlinSettings::postprocess() {
EEPROM_WRITE(ubl_active);
EEPROM_WRITE(storage_slot);
#endif // AUTO_BED_LEVELING_UBL
}
//
// Servo Angles
//
{
#if !(HAS_SERVOS && ENABLED(EDITABLE_SERVO_ANGLES))
uint16_t servo_angles[NUM_SERVOS][2] = { { 0, 0 } };
#if !HAS_SERVOS || DISABLED(EDITABLE_SERVO_ANGLES)
#if ENABLED(SWITCHING_EXTRUDER)
constexpr uint16_t sesa[][2] = SWITCHING_EXTRUDER_SERVO_ANGLES;
#endif
constexpr uint16_t servo_angles[NUM_SERVOS][2] = {
#if ENABLED(SWITCHING_EXTRUDER)
[SWITCHING_EXTRUDER_SERVO_NR] = { sesa[0][0], sesa[0][1] }
servo_angles[SWITCHING_EXTRUDER_SERVO_NR][0] = sesa[0][0];
servo_angles[SWITCHING_EXTRUDER_SERVO_NR][1] = sesa[0][1];
#if EXTRUDERS > 3
, [SWITCHING_EXTRUDER_E23_SERVO_NR] = { sesa[1][0], sesa[1][1] }
servo_angles[SWITCHING_EXTRUDER_E23_SERVO_NR][0] = sesa[1][0];
servo_angles[SWITCHING_EXTRUDER_E23_SERVO_NR][1] = sesa[1][1];
#endif
#elif ENABLED(SWITCHING_NOZZLE)
[SWITCHING_NOZZLE_SERVO_NR] = SWITCHING_NOZZLE_SERVO_ANGLES
constexpr uint16_t snsa[] = SWITCHING_NOZZLE_SERVO_ANGLES;
servo_angles[SWITCHING_NOZZLE_SERVO_NR][0] = snsa[0];
servo_angles[SWITCHING_NOZZLE_SERVO_NR][1] = snsa[1];
#elif defined(Z_SERVO_ANGLES) && defined(Z_PROBE_SERVO_NR)
[Z_PROBE_SERVO_NR] = Z_SERVO_ANGLES
#endif
};
constexpr uint16_t zsa[] = Z_SERVO_ANGLES;
servo_angles[Z_PROBE_SERVO_NR][0] = zsa[0];
servo_angles[Z_PROBE_SERVO_NR][1] = zsa[1];
#endif
#endif // !HAS_SERVOS || !EDITABLE_SERVO_ANGLES
EEPROM_WRITE(servo_angles);
}
// 11 floats for DELTA / [XYZ]_DUAL_ENDSTOPS
//
// DELTA Geometry or Dual Endstops offsets
//
{
#if ENABLED(DELTA)
_FIELD_TEST(delta_height);
@ -628,7 +672,12 @@ void MarlinSettings::postprocess() {
#endif
#endif
}
//
// LCD Preheat settings
//
{
_FIELD_TEST(lcd_preheat_hotend_temp);
#if DISABLED(ULTIPANEL)
@ -640,6 +689,7 @@ void MarlinSettings::postprocess() {
EEPROM_WRITE(lcd_preheat_hotend_temp);
EEPROM_WRITE(lcd_preheat_bed_temp);
EEPROM_WRITE(lcd_preheat_fan_speed);
}
//
// PIDTEMP
@ -678,13 +728,14 @@ void MarlinSettings::postprocess() {
//
// LCD Contrast
//
{
_FIELD_TEST(lcd_contrast);
#if !HAS_LCD_CONTRAST
const int16_t lcd_contrast = 32;
#endif
EEPROM_WRITE(lcd_contrast);
}
//
// Firmware Retraction
@ -1199,7 +1250,7 @@ void MarlinSettings::postprocess() {
// SERVO_ANGLES
//
{
#if !HAS_SERVOS || DISABLED(EDITABLE_SERVO_ANGLES)
#if !(HAS_SERVOS && ENABLED(EDITABLE_SERVO_ANGLES))
uint16_t servo_angles[NUM_SERVOS][2];
#endif
EEPROM_READ(servo_angles);
@ -1894,26 +1945,26 @@ void MarlinSettings::reset(PORTARG_SOLO) {
#else
#define REQ_ANGLES 2
#endif
constexpr uint16_t extruder_angles[] = SWITCHING_EXTRUDER_SERVO_ANGLES;
static_assert(COUNT(extruder_angles) == REQ_ANGLES, "SWITCHING_EXTRUDER_SERVO_ANGLES needs " STRINGIFY(REQ_ANGLES) " angles.");
servo_angles[SWITCHING_EXTRUDER_SERVO_NR][0] = extruder_angles[0];
servo_angles[SWITCHING_EXTRUDER_SERVO_NR][1] = extruder_angles[1];
constexpr uint16_t sesa[] = SWITCHING_EXTRUDER_SERVO_ANGLES;
static_assert(COUNT(sesa) == REQ_ANGLES, "SWITCHING_EXTRUDER_SERVO_ANGLES needs " STRINGIFY(REQ_ANGLES) " angles.");
servo_angles[SWITCHING_EXTRUDER_SERVO_NR][0] = sesa[0];
servo_angles[SWITCHING_EXTRUDER_SERVO_NR][1] = sesa[1];
#if EXTRUDERS > 3
servo_angles[SWITCHING_EXTRUDER_E23_SERVO_NR][0] = extruder_angles[2];
servo_angles[SWITCHING_EXTRUDER_E23_SERVO_NR][1] = extruder_angles[3];
servo_angles[SWITCHING_EXTRUDER_E23_SERVO_NR][0] = sesa[2];
servo_angles[SWITCHING_EXTRUDER_E23_SERVO_NR][1] = sesa[3];
#endif
#elif ENABLED(SWITCHING_NOZZLE)
constexpr uint16_t nozzle_angles[2] = SWITCHING_NOZZLE_SERVO_ANGLES;
servo_angles[SWITCHING_NOZZLE_SERVO_NR][0] = nozzle_angles[0];
servo_angles[SWITCHING_NOZZLE_SERVO_NR][1] = nozzle_angles[1];
constexpr uint16_t snsa[2] = SWITCHING_NOZZLE_SERVO_ANGLES;
servo_angles[SWITCHING_NOZZLE_SERVO_NR][0] = snsa[0];
servo_angles[SWITCHING_NOZZLE_SERVO_NR][1] = snsa[1];
#elif defined(Z_SERVO_ANGLES) && defined(Z_PROBE_SERVO_NR)
constexpr uint16_t z_probe_angles[2] = Z_SERVO_ANGLES;
servo_angles[Z_PROBE_SERVO_NR][0] = z_probe_angles[0];
servo_angles[Z_PROBE_SERVO_NR][1] = z_probe_angles[1];
constexpr uint16_t zsa[2] = Z_SERVO_ANGLES;
servo_angles[Z_PROBE_SERVO_NR][0] = zsa[0];
servo_angles[Z_PROBE_SERVO_NR][1] = zsa[1];
#endif