Prusa MINI Firmware overview
MarlinSettings Class Reference

#include <configuration_store.h>

Static Public Member Functions

static uint16_t datasize ()
 
static void reset ()
 
static bool save ()
 
static FORCE_INLINE bool init_eeprom ()
 
static FORCE_INLINE bool load ()
 
static FORCE_INLINE void first_load ()
 
static FORCE_INLINE void report (const bool=false)
 

Detailed Description

Marlin 3D Printer Firmware Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]

Based on Sprinter and grbl. Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Member Function Documentation

◆ datasize()

uint16_t MarlinSettings::datasize ( )
static
346 { return sizeof(SettingsData); }

◆ reset()

void MarlinSettings::reset ( )
static

M502 - Reset Configuration

2208  {
2209  LOOP_XYZE_N(i) {
2211  planner.settings.axis_steps_per_mm[i] = pgm_read_float(&_DASU[ALIM(i, _DASU)]);
2213  }
2214 
2221 
2222  #if HAS_CLASSIC_JERK
2223  #ifndef DEFAULT_XJERK
2224  #define DEFAULT_XJERK 0
2225  #endif
2226  #ifndef DEFAULT_YJERK
2227  #define DEFAULT_YJERK 0
2228  #endif
2229  #ifndef DEFAULT_ZJERK
2230  #define DEFAULT_ZJERK 0
2231  #endif
2232  planner.max_jerk.set(DEFAULT_XJERK, DEFAULT_YJERK, DEFAULT_ZJERK);
2233  #if HAS_CLASSIC_E_JERK
2234  planner.max_jerk.e = DEFAULT_EJERK;
2235  #endif
2236  #endif
2237 
2238  #if DISABLED(CLASSIC_JERK)
2239  planner.junction_deviation_mm = float(JUNCTION_DEVIATION_MM);
2240  #endif
2241 
2242  #if HAS_SCARA_OFFSET
2243  scara_home_offset.reset();
2244  #elif HAS_HOME_OFFSET
2245  home_offset.reset();
2246  #endif
2247 
2248  #if HAS_HOTEND_OFFSET
2249  reset_hotend_offsets();
2250  #endif
2251 
2252  //
2253  // Filament Runout Sensor
2254  //
2255 
2256  #if HAS_FILAMENT_SENSOR
2257  runout.enabled = true;
2258  runout.reset();
2259  #ifdef FILAMENT_RUNOUT_DISTANCE_MM
2260  runout.set_runout_distance(FILAMENT_RUNOUT_DISTANCE_MM);
2261  #endif
2262  #endif
2263 
2264  //
2265  // Tool-change Settings
2266  //
2267 
2268  #if EXTRUDERS > 1
2269  #if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
2270  toolchange_settings.swap_length = TOOLCHANGE_FIL_SWAP_LENGTH;
2271  toolchange_settings.extra_prime = TOOLCHANGE_FIL_EXTRA_PRIME;
2272  toolchange_settings.prime_speed = TOOLCHANGE_FIL_SWAP_PRIME_SPEED;
2273  toolchange_settings.retract_speed = TOOLCHANGE_FIL_SWAP_RETRACT_SPEED;
2274  #endif
2275  #if ENABLED(TOOLCHANGE_PARK)
2276  constexpr xyz_pos_t tpxy = TOOLCHANGE_PARK_XY;
2277  toolchange_settings.change_point = tpxy;
2278  #endif
2279  toolchange_settings.z_raise = TOOLCHANGE_ZRAISE;
2280  #endif
2281 
2282  #if ENABLED(BACKLASH_GCODE)
2283  backlash.correction = (BACKLASH_CORRECTION) * 255;
2284  constexpr xyz_float_t tmp = BACKLASH_DISTANCE_MM;
2285  backlash.distance_mm = tmp;
2286  #ifdef BACKLASH_SMOOTHING_MM
2287  backlash.smoothing_mm = BACKLASH_SMOOTHING_MM;
2288  #endif
2289  #endif
2290 
2291  #if ENABLED(EXTENSIBLE_UI)
2293  #endif
2294 
2295  //
2296  // Magnetic Parking Extruder
2297  //
2298 
2299  #if ENABLED(MAGNETIC_PARKING_EXTRUDER)
2300  mpe_settings_init();
2301  #endif
2302 
2303  //
2304  // Global Leveling
2305  //
2306 
2307  #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
2308  new_z_fade_height = 0.0;
2309  #endif
2310 
2311  #if HAS_LEVELING
2312  reset_bed_level();
2313  #endif
2314 
2315  #if HAS_BED_PROBE
2316  #ifndef NOZZLE_TO_PROBE_OFFSET
2317  #define NOZZLE_TO_PROBE_OFFSET { 0, 0, 0 }
2318  #endif
2319  constexpr float dpo[XYZ] = NOZZLE_TO_PROBE_OFFSET;
2320  static_assert(COUNT(dpo) == 3, "NOZZLE_TO_PROBE_OFFSET must contain offsets for X, Y, and Z.");
2321  LOOP_XYZ(a) probe_offset[a] = dpo[a];
2322  #endif
2323 
2324  //
2325  // Servo Angles
2326  //
2327 
2328  #if ENABLED(EDITABLE_SERVO_ANGLES)
2329  COPY(servo_angles, base_servo_angles);
2330  #endif
2331 
2332  //
2333  // BLTOUCH
2334  //
2335  //#if ENABLED(BLTOUCH)
2336  // bltouch.last_written_mode;
2337  //#endif
2338 
2339  //
2340  // Endstop Adjustments
2341  //
2342 
2343  #if ENABLED(DELTA)
2344  const abc_float_t adj = DELTA_ENDSTOP_ADJ, dta = DELTA_TOWER_ANGLE_TRIM;
2345  delta_height = DELTA_HEIGHT;
2346  delta_endstop_adj = adj;
2347  delta_radius = DELTA_RADIUS;
2348  delta_diagonal_rod = DELTA_DIAGONAL_ROD;
2349  delta_segments_per_second = DELTA_SEGMENTS_PER_SECOND;
2350  delta_calibration_radius = DELTA_CALIBRATION_RADIUS;
2351  delta_tower_angle_trim = dta;
2352 
2353  #elif EITHER(X_DUAL_ENDSTOPS, Y_DUAL_ENDSTOPS) || Z_MULTI_ENDSTOPS
2354 
2355  #if ENABLED(X_DUAL_ENDSTOPS)
2356  endstops.x2_endstop_adj = (
2357  #ifdef X_DUAL_ENDSTOPS_ADJUSTMENT
2358  X_DUAL_ENDSTOPS_ADJUSTMENT
2359  #else
2360  0
2361  #endif
2362  );
2363  #endif
2364  #if ENABLED(Y_DUAL_ENDSTOPS)
2365  endstops.y2_endstop_adj = (
2366  #ifdef Y_DUAL_ENDSTOPS_ADJUSTMENT
2367  Y_DUAL_ENDSTOPS_ADJUSTMENT
2368  #else
2369  0
2370  #endif
2371  );
2372  #endif
2373  #if ENABLED(Z_DUAL_ENDSTOPS)
2375  #ifdef Z_DUAL_ENDSTOPS_ADJUSTMENT
2376  Z_DUAL_ENDSTOPS_ADJUSTMENT
2377  #else
2378  0
2379  #endif
2380  );
2381  #elif ENABLED(Z_TRIPLE_ENDSTOPS)
2383  #ifdef Z_TRIPLE_ENDSTOPS_ADJUSTMENT2
2384  Z_TRIPLE_ENDSTOPS_ADJUSTMENT2
2385  #else
2386  0
2387  #endif
2388  );
2389  endstops.z3_endstop_adj = (
2390  #ifdef Z_TRIPLE_ENDSTOPS_ADJUSTMENT3
2391  Z_TRIPLE_ENDSTOPS_ADJUSTMENT3
2392  #else
2393  0
2394  #endif
2395  );
2396  #endif
2397 
2398  #endif
2399 
2400  //
2401  // Preheat parameters
2402  //
2403 
2404  #if HOTENDS && HAS_LCD_MENU
2405  ui.preheat_hotend_temp[0] = PREHEAT_1_TEMP_HOTEND;
2406  ui.preheat_hotend_temp[1] = PREHEAT_2_TEMP_HOTEND;
2407  ui.preheat_bed_temp[0] = PREHEAT_1_TEMP_BED;
2408  ui.preheat_bed_temp[1] = PREHEAT_2_TEMP_BED;
2409  ui.preheat_fan_speed[0] = PREHEAT_1_FAN_SPEED;
2410  ui.preheat_fan_speed[1] = PREHEAT_2_FAN_SPEED;
2411  #endif
2412 
2413  //
2414  // Hotend PID
2415  //
2416 
2417  #if ENABLED(PIDTEMP)
2418  HOTEND_LOOP() {
2419  PID_PARAM(Kp, e) = float(DEFAULT_Kp);
2420  PID_PARAM(Ki, e) = scalePID_i(DEFAULT_Ki);
2421  PID_PARAM(Kd, e) = scalePID_d(DEFAULT_Kd);
2422  #if ENABLED(PID_EXTRUSION_SCALING)
2423  PID_PARAM(Kc, e) = DEFAULT_Kc;
2424  #endif
2425  }
2426  #endif
2427 
2428  //
2429  // PID Extrusion Scaling
2430  //
2431 
2432  #if ENABLED(PID_EXTRUSION_SCALING)
2433  thermalManager.lpq_len = 20; // Default last-position-queue size
2434  #endif
2435 
2436  //
2437  // Heated Bed PID
2438  //
2439 
2440  #if ENABLED(PIDTEMPBED)
2441  thermalManager.temp_bed.pid.Kp = DEFAULT_bedKp;
2442  thermalManager.temp_bed.pid.Ki = scalePID_i(DEFAULT_bedKi);
2443  thermalManager.temp_bed.pid.Kd = scalePID_d(DEFAULT_bedKd);
2444  #endif
2445 
2446  //
2447  // User-Defined Thermistors
2448  //
2449 
2450  #if HAS_USER_THERMISTORS
2451  thermalManager.reset_user_thermistors();
2452  #endif
2453 
2454  //
2455  // LCD Contrast
2456  //
2457 
2458  #if HAS_LCD_CONTRAST
2459  ui.set_contrast(DEFAULT_LCD_CONTRAST);
2460  #endif
2461 
2462  //
2463  // Power-Loss Recovery
2464  //
2465 
2466  #if ENABLED(POWER_LOSS_RECOVERY)
2467  recovery.enable(true);
2468  #endif
2469 
2470  //
2471  // Firmware Retraction
2472  //
2473 
2474  #if ENABLED(FWRETRACT)
2475  fwretract.reset();
2476  #endif
2477 
2478  //
2479  // Volumetric & Filament Size
2480  //
2481 
2482  #if DISABLED(NO_VOLUMETRICS)
2483 
2484  parser.volumetric_enabled =
2485  #if ENABLED(VOLUMETRIC_DEFAULT_ON)
2486  true
2487  #else
2488  false
2489  #endif
2490  ;
2491  for (uint8_t q = 0; q < COUNT(planner.filament_size); q++)
2492  planner.filament_size[q] = DEFAULT_NOMINAL_FILAMENT_DIA;
2493 
2494  #endif
2495 
2497  #if ENABLED(ENDSTOPS_ALWAYS_ON_DEFAULT)
2498  true
2499  #else
2500  false
2501  #endif
2502  );
2503 
2505 
2506  //
2507  // Linear Advance
2508  //
2509 
2510  #if ENABLED(LIN_ADVANCE)
2511  LOOP_L_N(i, EXTRUDERS) {
2512  planner.extruder_advance_K[i] = LIN_ADVANCE_K;
2513  #if ENABLED(EXTRA_LIN_ADVANCE_K)
2514  saved_extruder_advance_K[i] = LIN_ADVANCE_K;
2515  #endif
2516  }
2517  #endif
2518 
2519  //
2520  // Motor Current PWM
2521  //
2522 
2523  #if HAS_MOTOR_CURRENT_PWM
2524  constexpr uint32_t tmp_motor_current_setting[3] = PWM_MOTOR_CURRENT;
2525  for (uint8_t q = 3; q--;)
2526  stepper.digipot_current(q, (stepper.motor_current_setting[q] = tmp_motor_current_setting[q]));
2527  #endif
2528 
2529  //
2530  // CNC Coordinate System
2531  //
2532 
2533  #if ENABLED(CNC_COORDINATE_SYSTEMS)
2534  (void)gcode.select_coordinate_system(-1); // Go back to machine space
2535  #endif
2536 
2537  //
2538  // Skew Correction
2539  //
2540 
2541  #if ENABLED(SKEW_CORRECTION_GCODE)
2542  planner.skew_factor.xy = XY_SKEW_FACTOR;
2543  #if ENABLED(SKEW_CORRECTION_FOR_Z)
2544  planner.skew_factor.xz = XZ_SKEW_FACTOR;
2545  planner.skew_factor.yz = YZ_SKEW_FACTOR;
2546  #endif
2547  #endif
2548 
2549  //
2550  // Advanced Pause filament load & unload lengths
2551  //
2552 
2553  #if ENABLED(ADVANCED_PAUSE_FEATURE)
2554  for (uint8_t e = 0; e < EXTRUDERS; e++) {
2555  fc_settings[e].unload_length = FILAMENT_CHANGE_UNLOAD_LENGTH;
2556  fc_settings[e].load_length = FILAMENT_CHANGE_FAST_LOAD_LENGTH;
2557  }
2558  #endif
2559 
2560  postprocess();
2561 
2562  DEBUG_ECHO_START();
2563  DEBUG_ECHOLNPGM("Hardcoded Default Settings Loaded");
2564 
2565  #if ENABLED(EXTENSIBLE_UI)
2567  #endif
2568 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ save()

bool MarlinSettings::save ( )
static
2198  {
2199  DEBUG_ERROR_MSG("EEPROM disabled");
2200  return false;
2201  }
Here is the caller graph for this function:

◆ init_eeprom()

static FORCE_INLINE bool MarlinSettings::init_eeprom ( )
static
37  {
38  reset();
39  #if ENABLED(EEPROM_SETTINGS)
40  const bool success = save();
41  #if ENABLED(EEPROM_CHITCHAT)
42  if (success) report();
43  #endif
44  return success;
45  #else
46  return true;
47  #endif
48  }
Here is the call graph for this function:

◆ load()

static FORCE_INLINE bool MarlinSettings::load ( )
static
79 { reset(); report(); return true; }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ first_load()

static FORCE_INLINE void MarlinSettings::first_load ( )
static
81 { (void)load(); }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ report()

static FORCE_INLINE void MarlinSettings::report ( const bool  = false)
static
88 {}
Here is the caller graph for this function:
reset_bed_level
void reset_bed_level()
delta_segments_per_second
float delta_segments_per_second
DEFAULT_EJERK
#define DEFAULT_EJERK
Definition: Configuration_A3ides_2209_MINI.h:733
SettingsData
struct SettingsDataStruct SettingsData
backlash
Backlash backlash
planner_settings_t::min_feedrate_mm_s
feedRate_t min_feedrate_mm_s
Definition: planner.h:186
planner_settings_t::max_feedrate_mm_s
feedRate_t max_feedrate_mm_s[XYZE_N]
Definition: planner.h:182
probe_offset
constexpr xyz_pos_t probe_offset
Definition: probe.h:58
PREHEAT_1_TEMP_BED
#define PREHEAT_1_TEMP_BED
Definition: Configuration_A3ides_2209_MINI.h:1379
g29_auto.gcode
list gcode
Definition: g29_auto.py:44
Backlash::correction
static constexpr uint8_t correction
Definition: backlash.h:41
DEBUG_ECHOLNPGM
#define DEBUG_ECHOLNPGM(...)
Definition: debug_out.h:79
DEFAULT_TRAVEL_ACCELERATION
#define DEFAULT_TRAVEL_ACCELERATION
Definition: Configuration_A3ides_2209_MINI.h:709
stepper
Stepper stepper
Definition: stepper.cpp:82
planner_settings_t::retract_acceleration
float retract_acceleration
Definition: planner.h:183
i
uint8_t i
Definition: screen_test_graph.c:72
LOOP_XYZE_N
#define LOOP_XYZE_N(VAR)
Definition: types.h:62
PREHEAT_2_TEMP_HOTEND
#define PREHEAT_2_TEMP_HOTEND
Definition: Configuration_A3ides_2209_MINI.h:1383
recovery
PrintJobRecovery recovery
DEBUG_ECHO_START
#define DEBUG_ECHO_START()
Definition: debug_out.h:72
delta_height
float delta_height
feedRate_t
float feedRate_t
Definition: types.h:80
skew_factor_t::yz
const float yz
Definition: planner.h:206
scalePID_d
#define scalePID_d(d)
Definition: temperature.h:151
delta_endstop_adj
abc_float_t delta_endstop_adj
MarlinSettings::save
static bool save()
Definition: configuration_store.cpp:2198
MarlinSettings::reset
static void reset()
Definition: configuration_store.cpp:2208
XYZ
#define XYZ
Definition: macros.h:27
Backlash::distance_mm
static const xyz_float_t distance_mm
Definition: backlash.h:42
delta_diagonal_rod
float delta_diagonal_rod
DEBUG_ERROR_MSG
#define DEBUG_ERROR_MSG(...)
Definition: debug_out.h:85
DEFAULT_MINTRAVELFEEDRATE
#define DEFAULT_MINTRAVELFEEDRATE
Definition: Configuration_A3ides_2209_MINI_adv.h:515
Stepper::digipot_current
static void digipot_current(const uint8_t driver, const int16_t current)
Definition: stepper.cpp:2495
COPY
Definition: inflate.h:36
MarlinSettings::report
static FORCE_INLINE void report(const bool=false)
Definition: configuration_store.h:88
COUNT
#define COUNT(a)
Definition: macros.h:200
PREHEAT_2_FAN_SPEED
#define PREHEAT_2_FAN_SPEED
Definition: Configuration_A3ides_2209_MINI.h:1385
LOOP_L_N
#define LOOP_L_N(VAR, N)
Definition: types.h:58
LOOP_XYZ
#define LOOP_XYZ(VAR)
Definition: types.h:60
planner_settings_t::travel_acceleration
float travel_acceleration
Definition: planner.h:183
planner_settings_t::axis_steps_per_mm
float axis_steps_per_mm[XYZE_N]
Definition: planner.h:181
void
void
Definition: png.h:1083
DEFAULT_MINIMUMFEEDRATE
#define DEFAULT_MINIMUMFEEDRATE
Definition: Configuration_A3ides_2209_MINI_adv.h:514
runout
FilamentMonitor runout
TFilamentMonitor::reset
static void reset()
Definition: runout.h:76
ALIM
#define ALIM(I, ARR)
Definition: configuration_store.cpp:125
planner_settings_t::acceleration
float acceleration
Definition: planner.h:183
PREHEAT_1_FAN_SPEED
#define PREHEAT_1_FAN_SPEED
Definition: Configuration_A3ides_2209_MINI.h:1380
planner_settings_t::max_acceleration_mm_per_s2
uint32_t max_acceleration_mm_per_s2[XYZE_N]
Definition: planner.h:179
pgm_read_float
#define pgm_read_float(addr)
Definition: pgmspace.h:109
reset_stepper_drivers
void reset_stepper_drivers()
Definition: indirection.cpp:41
DEFAULT_ACCELERATION
#define DEFAULT_ACCELERATION
Definition: Configuration_A3ides_2209_MINI.h:707
ExtUI::onFactoryReset
void onFactoryReset()
Definition: marlin_server.cpp:922
createSpeedLookupTable.a
list a
Definition: createSpeedLookupTable.py:29
HOTEND_LOOP
#define HOTEND_LOOP()
Definition: Conditionals_LCD.h:436
scalePID_i
#define scalePID_i(i)
Definition: temperature.h:149
DEFAULT_MINSEGMENTTIME
#define DEFAULT_MINSEGMENTTIME
Definition: Configuration_A3ides_2209_MINI_adv.h:532
Endstops::z2_endstop_adj
static float z2_endstop_adj
Definition: endstops.h:51
uint8_t
const uint8_t[]
Definition: 404_html.c:3
PREHEAT_2_TEMP_BED
#define PREHEAT_2_TEMP_BED
Definition: Configuration_A3ides_2209_MINI.h:1384
skew_factor_t::xz
const float xz
Definition: planner.h:206
delta_tower_angle_trim
abc_float_t delta_tower_angle_trim
ui
MarlinUI ui
DEFAULT_NOMINAL_FILAMENT_DIA
#define DEFAULT_NOMINAL_FILAMENT_DIA
Definition: Configuration_A3ides_2209_MINI.h:151
NOZZLE_TO_PROBE_OFFSET
#define NOZZLE_TO_PROBE_OFFSET
Definition: Configuration_A3ides_2209_MINI.h:858
EXTRUDERS
#define EXTRUDERS
Definition: Configuration_A3ides_2209_MINI.h:148
pgm_read_dword
#define pgm_read_dword(addr)
Definition: pgmspace.h:105
Endstops::enable_globally
static void enable_globally(const bool onoff=true)
Definition: endstops.cpp:285
skew_factor_t::xy
const float xy
Definition: planner.h:205
delta_radius
float delta_radius
FilamentMonitorBase::enabled
static bool enabled
Definition: runout.h:53
MarlinSettings::load
static FORCE_INLINE bool load()
Definition: configuration_store.h:79
XYZval< float >
PID_PARAM
#define PID_PARAM(F, H)
Definition: temperature.h:87
delta_calibration_radius
float delta_calibration_radius
Planner::settings
static planner_settings_t settings
Definition: planner.h:251
planner_settings_t::min_travel_feedrate_mm_s
feedRate_t min_travel_feedrate_mm_s
Definition: planner.h:186
thermalManager
Temperature thermalManager
Definition: temperature.cpp:89
endstops
Endstops endstops
Definition: endstops.cpp:51
DEFAULT_RETRACT_ACCELERATION
#define DEFAULT_RETRACT_ACCELERATION
Definition: Configuration_A3ides_2209_MINI.h:708
planner_settings_t::min_segment_time_us
uint32_t min_segment_time_us
Definition: planner.h:179
ENABLED
#define ENABLED(V...)
Definition: macros.h:177
PREHEAT_1_TEMP_HOTEND
#define PREHEAT_1_TEMP_HOTEND
Definition: Configuration_A3ides_2209_MINI.h:1378
planner
Planner planner
Definition: planner.cpp:111
createSpeedLookupTable.parser
parser
Definition: createSpeedLookupTable.py:14
PrintJobRecovery::enable
static void enable(const bool onoff)
Planner::skew_factor
static skew_factor_t skew_factor
Definition: planner.h:299