My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

configuration_store.cpp 79KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * configuration_store.cpp
  24. *
  25. * Settings and EEPROM storage
  26. *
  27. * IMPORTANT: Whenever there are changes made to the variables stored in EEPROM
  28. * in the functions below, also increment the version number. This makes sure that
  29. * the default values are used whenever there is a change to the data, to prevent
  30. * wrong data being written to the variables.
  31. *
  32. * ALSO: Variables in the Store and Retrieve sections must be in the same order.
  33. * If a feature is disabled, some data must still be written that, when read,
  34. * either sets a Sane Default, or results in No Change to the existing value.
  35. *
  36. */
  37. // Change EEPROM version if the structure changes
  38. #define EEPROM_VERSION "V54"
  39. #define EEPROM_OFFSET 100
  40. // Check the integrity of data offsets.
  41. // Can be disabled for production build.
  42. //#define DEBUG_EEPROM_READWRITE
  43. #include "configuration_store.h"
  44. #if ADD_PORT_ARG
  45. #define PORTARG_SOLO const int8_t port
  46. #define PORTARG_AFTER ,const int8_t port
  47. #define PORTVAR_SOLO port
  48. #else
  49. #define PORTARG_SOLO
  50. #define PORTARG_AFTER
  51. #define PORTVAR_SOLO
  52. #endif
  53. #include "endstops.h"
  54. #include "planner.h"
  55. #include "stepper.h"
  56. #include "temperature.h"
  57. #include "../lcd/ultralcd.h"
  58. #include "../core/language.h"
  59. #include "../libs/vector_3.h"
  60. #include "../gcode/gcode.h"
  61. #include "../Marlin.h"
  62. #if HAS_LEVELING
  63. #include "../feature/bedlevel/bedlevel.h"
  64. #endif
  65. #if HAS_BED_PROBE
  66. #include "../module/probe.h"
  67. #endif
  68. #if HAS_TRINAMIC
  69. #include "stepper_indirection.h"
  70. #include "../feature/tmc_util.h"
  71. #define TMC_GET_PWMTHRS(P,Q) _tmc_thrs(stepper##Q.microsteps(), stepper##Q.TPWMTHRS(), planner.axis_steps_per_mm[P##_AXIS])
  72. #endif
  73. #if ENABLED(FWRETRACT)
  74. #include "../feature/fwretract.h"
  75. #endif
  76. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  77. #include "../feature/pause.h"
  78. #endif
  79. #pragma pack(push, 1) // No padding between variables
  80. typedef struct PID { float Kp, Ki, Kd; } PID;
  81. typedef struct PIDC { float Kp, Ki, Kd, Kc; } PIDC;
  82. /**
  83. * Current EEPROM Layout
  84. *
  85. * Keep this data structure up to date so
  86. * EEPROM size is known at compile time!
  87. */
  88. typedef struct SettingsDataStruct {
  89. char version[4]; // Vnn\0
  90. uint16_t crc; // Data Checksum
  91. //
  92. // DISTINCT_E_FACTORS
  93. //
  94. uint8_t esteppers; // XYZE_N - XYZ
  95. float planner_axis_steps_per_mm[XYZE_N], // M92 XYZE planner.axis_steps_per_mm[XYZE_N]
  96. planner_max_feedrate_mm_s[XYZE_N]; // M203 XYZE planner.max_feedrate_mm_s[XYZE_N]
  97. uint32_t planner_max_acceleration_mm_per_s2[XYZE_N]; // M201 XYZE planner.max_acceleration_mm_per_s2[XYZE_N]
  98. float planner_acceleration, // M204 P planner.acceleration
  99. planner_retract_acceleration, // M204 R planner.retract_acceleration
  100. planner_travel_acceleration, // M204 T planner.travel_acceleration
  101. planner_min_feedrate_mm_s, // M205 S planner.min_feedrate_mm_s
  102. planner_min_travel_feedrate_mm_s; // M205 T planner.min_travel_feedrate_mm_s
  103. uint32_t planner_min_segment_time_us; // M205 B planner.min_segment_time_us
  104. float planner_max_jerk[XYZE]; // M205 XYZE planner.max_jerk[XYZE]
  105. float home_offset[XYZ]; // M206 XYZ
  106. #if HOTENDS > 1
  107. float hotend_offset[XYZ][HOTENDS - 1]; // M218 XYZ
  108. #endif
  109. //
  110. // ENABLE_LEVELING_FADE_HEIGHT
  111. //
  112. float planner_z_fade_height; // M420 Zn planner.z_fade_height
  113. //
  114. // MESH_BED_LEVELING
  115. //
  116. float mbl_z_offset; // mbl.z_offset
  117. uint8_t mesh_num_x, mesh_num_y; // GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y
  118. #if ENABLED(MESH_BED_LEVELING)
  119. float mbl_z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; // mbl.z_values
  120. #else
  121. float mbl_z_values[3][3];
  122. #endif
  123. //
  124. // HAS_BED_PROBE
  125. //
  126. float zprobe_zoffset; // M851 Z
  127. //
  128. // ABL_PLANAR
  129. //
  130. matrix_3x3 planner_bed_level_matrix; // planner.bed_level_matrix
  131. //
  132. // AUTO_BED_LEVELING_BILINEAR
  133. //
  134. uint8_t grid_max_x, grid_max_y; // GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y
  135. int bilinear_grid_spacing[2],
  136. bilinear_start[2]; // G29 L F
  137. #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
  138. float z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; // G29
  139. #else
  140. float z_values[3][3];
  141. #endif
  142. //
  143. // AUTO_BED_LEVELING_UBL
  144. //
  145. bool planner_leveling_active; // M420 S planner.leveling_active
  146. int8_t ubl_storage_slot; // ubl.storage_slot
  147. //
  148. // DELTA / [XYZ]_DUAL_ENDSTOPS
  149. //
  150. #if ENABLED(DELTA)
  151. float delta_height, // M666 H
  152. delta_endstop_adj[ABC], // M666 XYZ
  153. delta_radius, // M665 R
  154. delta_diagonal_rod, // M665 L
  155. delta_segments_per_second, // M665 S
  156. delta_calibration_radius, // M665 B
  157. delta_tower_angle_trim[ABC]; // M665 XYZ
  158. #elif ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || ENABLED(Z_DUAL_ENDSTOPS)
  159. float x_endstop_adj, // M666 X
  160. y_endstop_adj, // M666 Y
  161. z_endstop_adj; // M666 Z
  162. #endif
  163. //
  164. // ULTIPANEL
  165. //
  166. int16_t lcd_preheat_hotend_temp[2], // M145 S0 H
  167. lcd_preheat_bed_temp[2], // M145 S0 B
  168. lcd_preheat_fan_speed[2]; // M145 S0 F
  169. //
  170. // PIDTEMP
  171. //
  172. PIDC hotendPID[MAX_EXTRUDERS]; // M301 En PIDC / M303 En U
  173. int lpq_len; // M301 L
  174. //
  175. // PIDTEMPBED
  176. //
  177. PID bedPID; // M304 PID / M303 E-1 U
  178. //
  179. // HAS_LCD_CONTRAST
  180. //
  181. int16_t lcd_contrast; // M250 C
  182. //
  183. // FWRETRACT
  184. //
  185. bool autoretract_enabled; // M209 S
  186. float retract_length, // M207 S
  187. retract_feedrate_mm_s, // M207 F
  188. retract_zlift, // M207 Z
  189. retract_recover_length, // M208 S
  190. retract_recover_feedrate_mm_s, // M208 F
  191. swap_retract_length, // M207 W
  192. swap_retract_recover_length, // M208 W
  193. swap_retract_recover_feedrate_mm_s; // M208 R
  194. //
  195. // !NO_VOLUMETRIC
  196. //
  197. bool parser_volumetric_enabled; // M200 D parser.volumetric_enabled
  198. float planner_filament_size[MAX_EXTRUDERS]; // M200 T D planner.filament_size[]
  199. //
  200. // HAS_TRINAMIC
  201. //
  202. #define TMC_AXES (MAX_EXTRUDERS + 6)
  203. uint16_t tmc_stepper_current[TMC_AXES]; // M906 X Y Z X2 Y2 Z2 E0 E1 E2 E3 E4
  204. uint32_t tmc_hybrid_threshold[TMC_AXES]; // M913 X Y Z X2 Y2 Z2 E0 E1 E2 E3 E4
  205. int16_t tmc_sgt[XYZ]; // M914 X Y Z
  206. //
  207. // LIN_ADVANCE
  208. //
  209. float planner_extruder_advance_K; // M900 K planner.extruder_advance_K
  210. //
  211. // HAS_MOTOR_CURRENT_PWM
  212. //
  213. uint32_t motor_current_setting[XYZ]; // M907 X Z E
  214. //
  215. // CNC_COORDINATE_SYSTEMS
  216. //
  217. float coordinate_system[MAX_COORDINATE_SYSTEMS][XYZ]; // G54-G59.3
  218. //
  219. // SKEW_CORRECTION
  220. //
  221. float planner_xy_skew_factor, // M852 I planner.xy_skew_factor
  222. planner_xz_skew_factor, // M852 J planner.xz_skew_factor
  223. planner_yz_skew_factor; // M852 K planner.yz_skew_factor
  224. //
  225. // ADVANCED_PAUSE_FEATURE
  226. //
  227. float filament_change_unload_length[MAX_EXTRUDERS], // M603 T U
  228. filament_change_load_length[MAX_EXTRUDERS]; // M603 T L
  229. } SettingsData;
  230. #pragma pack(pop)
  231. MarlinSettings settings;
  232. uint16_t MarlinSettings::datasize() { return sizeof(SettingsData); }
  233. /**
  234. * Post-process after Retrieve or Reset
  235. */
  236. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  237. float new_z_fade_height;
  238. #endif
  239. void MarlinSettings::postprocess() {
  240. const float oldpos[] = { current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] };
  241. // steps per s2 needs to be updated to agree with units per s2
  242. planner.reset_acceleration_rates();
  243. // Make sure delta kinematics are updated before refreshing the
  244. // planner position so the stepper counts will be set correctly.
  245. #if ENABLED(DELTA)
  246. recalc_delta_settings();
  247. #endif
  248. #if ENABLED(PIDTEMP)
  249. thermalManager.updatePID();
  250. #endif
  251. #if DISABLED(NO_VOLUMETRICS)
  252. planner.calculate_volumetric_multipliers();
  253. #else
  254. for (uint8_t i = COUNT(planner.e_factor); i--;)
  255. planner.refresh_e_factor(i);
  256. #endif
  257. #if HAS_HOME_OFFSET || ENABLED(DUAL_X_CARRIAGE)
  258. // Software endstops depend on home_offset
  259. LOOP_XYZ(i) update_software_endstops((AxisEnum)i);
  260. #endif
  261. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  262. set_z_fade_height(new_z_fade_height, false); // false = no report
  263. #endif
  264. #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
  265. refresh_bed_level();
  266. #endif
  267. #if HAS_MOTOR_CURRENT_PWM
  268. stepper.refresh_motor_power();
  269. #endif
  270. #if ENABLED(FWRETRACT)
  271. fwretract.refresh_autoretract();
  272. #endif
  273. // Refresh steps_to_mm with the reciprocal of axis_steps_per_mm
  274. // and init stepper.count[], planner.position[] with current_position
  275. planner.refresh_positioning();
  276. // Various factors can change the current position
  277. if (memcmp(oldpos, current_position, sizeof(oldpos)))
  278. report_current_position();
  279. }
  280. #if ENABLED(EEPROM_SETTINGS)
  281. #include "../HAL/persistent_store_api.h"
  282. #define DUMMY_PID_VALUE 3000.0f
  283. #define EEPROM_START() int eeprom_index = EEPROM_OFFSET; HAL::PersistentStore::access_start()
  284. #define EEPROM_FINISH() HAL::PersistentStore::access_finish()
  285. #define EEPROM_SKIP(VAR) eeprom_index += sizeof(VAR)
  286. #define EEPROM_WRITE(VAR) HAL::PersistentStore::write_data(eeprom_index, (uint8_t*)&VAR, sizeof(VAR), &working_crc)
  287. #define EEPROM_READ(VAR) HAL::PersistentStore::read_data(eeprom_index, (uint8_t*)&VAR, sizeof(VAR), &working_crc, !validating)
  288. #define EEPROM_READ_ALWAYS(VAR) HAL::PersistentStore::read_data(eeprom_index, (uint8_t*)&VAR, sizeof(VAR), &working_crc)
  289. #define EEPROM_ASSERT(TST,ERR) if (!(TST)) do{ SERIAL_ERROR_START_P(port); SERIAL_ERRORLNPGM_P(port, ERR); eeprom_error = true; }while(0)
  290. #if ENABLED(DEBUG_EEPROM_READWRITE)
  291. #define _FIELD_TEST(FIELD) \
  292. EEPROM_ASSERT( \
  293. eeprom_error || eeprom_index == offsetof(SettingsData, FIELD) + EEPROM_OFFSET, \
  294. "Field " STRINGIFY(FIELD) " mismatch." \
  295. )
  296. #else
  297. #define _FIELD_TEST(FIELD) NOOP
  298. #endif
  299. const char version[4] = EEPROM_VERSION;
  300. bool MarlinSettings::eeprom_error, MarlinSettings::validating;
  301. bool MarlinSettings::size_error(const uint16_t size PORTARG_AFTER) {
  302. if (size != datasize()) {
  303. #if ENABLED(EEPROM_CHITCHAT)
  304. SERIAL_ERROR_START_P(port);
  305. SERIAL_ERRORLNPGM_P(port, "EEPROM datasize error.");
  306. #endif
  307. return true;
  308. }
  309. return false;
  310. }
  311. /**
  312. * M500 - Store Configuration
  313. */
  314. bool MarlinSettings::save(PORTARG_SOLO) {
  315. float dummy = 0.0f;
  316. char ver[4] = "ERR";
  317. uint16_t working_crc = 0;
  318. EEPROM_START();
  319. eeprom_error = false;
  320. #if ENABLED(FLASH_EEPROM_EMULATION)
  321. EEPROM_SKIP(ver); // Flash doesn't allow rewriting without erase
  322. #else
  323. EEPROM_WRITE(ver); // invalidate data first
  324. #endif
  325. EEPROM_SKIP(working_crc); // Skip the checksum slot
  326. working_crc = 0; // clear before first "real data"
  327. _FIELD_TEST(esteppers);
  328. const uint8_t esteppers = COUNT(planner.axis_steps_per_mm) - XYZ;
  329. EEPROM_WRITE(esteppers);
  330. EEPROM_WRITE(planner.axis_steps_per_mm);
  331. EEPROM_WRITE(planner.max_feedrate_mm_s);
  332. EEPROM_WRITE(planner.max_acceleration_mm_per_s2);
  333. EEPROM_WRITE(planner.acceleration);
  334. EEPROM_WRITE(planner.retract_acceleration);
  335. EEPROM_WRITE(planner.travel_acceleration);
  336. EEPROM_WRITE(planner.min_feedrate_mm_s);
  337. EEPROM_WRITE(planner.min_travel_feedrate_mm_s);
  338. EEPROM_WRITE(planner.min_segment_time_us);
  339. EEPROM_WRITE(planner.max_jerk);
  340. _FIELD_TEST(home_offset);
  341. #if !HAS_HOME_OFFSET
  342. const float home_offset[XYZ] = { 0 };
  343. #endif
  344. EEPROM_WRITE(home_offset);
  345. #if HOTENDS > 1
  346. // Skip hotend 0 which must be 0
  347. for (uint8_t e = 1; e < HOTENDS; e++)
  348. LOOP_XYZ(i) EEPROM_WRITE(hotend_offset[i][e]);
  349. #endif
  350. //
  351. // Global Leveling
  352. //
  353. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  354. const float zfh = planner.z_fade_height;
  355. #else
  356. const float zfh = 10.0;
  357. #endif
  358. EEPROM_WRITE(zfh);
  359. //
  360. // Mesh Bed Leveling
  361. //
  362. #if ENABLED(MESH_BED_LEVELING)
  363. // Compile time test that sizeof(mbl.z_values) is as expected
  364. static_assert(
  365. sizeof(mbl.z_values) == GRID_MAX_POINTS * sizeof(mbl.z_values[0][0]),
  366. "MBL Z array is the wrong size."
  367. );
  368. const uint8_t mesh_num_x = GRID_MAX_POINTS_X, mesh_num_y = GRID_MAX_POINTS_Y;
  369. EEPROM_WRITE(mbl.z_offset);
  370. EEPROM_WRITE(mesh_num_x);
  371. EEPROM_WRITE(mesh_num_y);
  372. EEPROM_WRITE(mbl.z_values);
  373. #else // For disabled MBL write a default mesh
  374. dummy = 0.0f;
  375. const uint8_t mesh_num_x = 3, mesh_num_y = 3;
  376. EEPROM_WRITE(dummy); // z_offset
  377. EEPROM_WRITE(mesh_num_x);
  378. EEPROM_WRITE(mesh_num_y);
  379. for (uint8_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_WRITE(dummy);
  380. #endif // MESH_BED_LEVELING
  381. _FIELD_TEST(zprobe_zoffset);
  382. #if !HAS_BED_PROBE
  383. const float zprobe_zoffset = 0;
  384. #endif
  385. EEPROM_WRITE(zprobe_zoffset);
  386. //
  387. // Planar Bed Leveling matrix
  388. //
  389. #if ABL_PLANAR
  390. EEPROM_WRITE(planner.bed_level_matrix);
  391. #else
  392. dummy = 0.0;
  393. for (uint8_t q = 9; q--;) EEPROM_WRITE(dummy);
  394. #endif
  395. //
  396. // Bilinear Auto Bed Leveling
  397. //
  398. #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
  399. // Compile time test that sizeof(z_values) is as expected
  400. static_assert(
  401. sizeof(z_values) == GRID_MAX_POINTS * sizeof(z_values[0][0]),
  402. "Bilinear Z array is the wrong size."
  403. );
  404. const uint8_t grid_max_x = GRID_MAX_POINTS_X, grid_max_y = GRID_MAX_POINTS_Y;
  405. EEPROM_WRITE(grid_max_x); // 1 byte
  406. EEPROM_WRITE(grid_max_y); // 1 byte
  407. EEPROM_WRITE(bilinear_grid_spacing); // 2 ints
  408. EEPROM_WRITE(bilinear_start); // 2 ints
  409. EEPROM_WRITE(z_values); // 9-256 floats
  410. #else
  411. // For disabled Bilinear Grid write an empty 3x3 grid
  412. const uint8_t grid_max_x = 3, grid_max_y = 3;
  413. const int bilinear_start[2] = { 0 }, bilinear_grid_spacing[2] = { 0 };
  414. dummy = 0.0f;
  415. EEPROM_WRITE(grid_max_x);
  416. EEPROM_WRITE(grid_max_y);
  417. EEPROM_WRITE(bilinear_grid_spacing);
  418. EEPROM_WRITE(bilinear_start);
  419. for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_WRITE(dummy);
  420. #endif // AUTO_BED_LEVELING_BILINEAR
  421. _FIELD_TEST(planner_leveling_active);
  422. #if ENABLED(AUTO_BED_LEVELING_UBL)
  423. EEPROM_WRITE(planner.leveling_active);
  424. EEPROM_WRITE(ubl.storage_slot);
  425. #else
  426. const bool ubl_active = false;
  427. const int8_t storage_slot = -1;
  428. EEPROM_WRITE(ubl_active);
  429. EEPROM_WRITE(storage_slot);
  430. #endif // AUTO_BED_LEVELING_UBL
  431. // 11 floats for DELTA / [XYZ]_DUAL_ENDSTOPS
  432. #if ENABLED(DELTA)
  433. _FIELD_TEST(delta_height);
  434. EEPROM_WRITE(delta_height); // 1 float
  435. EEPROM_WRITE(delta_endstop_adj); // 3 floats
  436. EEPROM_WRITE(delta_radius); // 1 float
  437. EEPROM_WRITE(delta_diagonal_rod); // 1 float
  438. EEPROM_WRITE(delta_segments_per_second); // 1 float
  439. EEPROM_WRITE(delta_calibration_radius); // 1 float
  440. EEPROM_WRITE(delta_tower_angle_trim); // 3 floats
  441. #elif ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || ENABLED(Z_DUAL_ENDSTOPS)
  442. _FIELD_TEST(x_endstop_adj);
  443. // Write dual endstops in X, Y, Z order. Unused = 0.0
  444. dummy = 0.0f;
  445. #if ENABLED(X_DUAL_ENDSTOPS)
  446. EEPROM_WRITE(endstops.x_endstop_adj); // 1 float
  447. #else
  448. EEPROM_WRITE(dummy);
  449. #endif
  450. #if ENABLED(Y_DUAL_ENDSTOPS)
  451. EEPROM_WRITE(endstops.y_endstop_adj); // 1 float
  452. #else
  453. EEPROM_WRITE(dummy);
  454. #endif
  455. #if ENABLED(Z_DUAL_ENDSTOPS)
  456. EEPROM_WRITE(endstops.z_endstop_adj); // 1 float
  457. #else
  458. EEPROM_WRITE(dummy);
  459. #endif
  460. #endif
  461. _FIELD_TEST(lcd_preheat_hotend_temp);
  462. #if DISABLED(ULTIPANEL)
  463. constexpr int16_t lcd_preheat_hotend_temp[2] = { PREHEAT_1_TEMP_HOTEND, PREHEAT_2_TEMP_HOTEND },
  464. lcd_preheat_bed_temp[2] = { PREHEAT_1_TEMP_BED, PREHEAT_2_TEMP_BED },
  465. lcd_preheat_fan_speed[2] = { PREHEAT_1_FAN_SPEED, PREHEAT_2_FAN_SPEED };
  466. #endif
  467. EEPROM_WRITE(lcd_preheat_hotend_temp);
  468. EEPROM_WRITE(lcd_preheat_bed_temp);
  469. EEPROM_WRITE(lcd_preheat_fan_speed);
  470. for (uint8_t e = 0; e < MAX_EXTRUDERS; e++) {
  471. #if ENABLED(PIDTEMP)
  472. if (e < HOTENDS) {
  473. EEPROM_WRITE(PID_PARAM(Kp, e));
  474. EEPROM_WRITE(PID_PARAM(Ki, e));
  475. EEPROM_WRITE(PID_PARAM(Kd, e));
  476. #if ENABLED(PID_EXTRUSION_SCALING)
  477. EEPROM_WRITE(PID_PARAM(Kc, e));
  478. #else
  479. dummy = 1.0f; // 1.0 = default kc
  480. EEPROM_WRITE(dummy);
  481. #endif
  482. }
  483. else
  484. #endif // !PIDTEMP
  485. {
  486. dummy = DUMMY_PID_VALUE; // When read, will not change the existing value
  487. EEPROM_WRITE(dummy); // Kp
  488. dummy = 0.0f;
  489. for (uint8_t q = 3; q--;) EEPROM_WRITE(dummy); // Ki, Kd, Kc
  490. }
  491. } // Hotends Loop
  492. _FIELD_TEST(lpq_len);
  493. #if DISABLED(PID_EXTRUSION_SCALING)
  494. int lpq_len = 20;
  495. #endif
  496. EEPROM_WRITE(lpq_len);
  497. #if DISABLED(PIDTEMPBED)
  498. dummy = DUMMY_PID_VALUE;
  499. for (uint8_t q = 3; q--;) EEPROM_WRITE(dummy);
  500. #else
  501. EEPROM_WRITE(thermalManager.bedKp);
  502. EEPROM_WRITE(thermalManager.bedKi);
  503. EEPROM_WRITE(thermalManager.bedKd);
  504. #endif
  505. _FIELD_TEST(lcd_contrast);
  506. #if !HAS_LCD_CONTRAST
  507. const int16_t lcd_contrast = 32;
  508. #endif
  509. EEPROM_WRITE(lcd_contrast);
  510. #if DISABLED(FWRETRACT)
  511. const bool autoretract_enabled = false;
  512. const float autoretract_defaults[] = { 3, 45, 0, 0, 0, 13, 0, 8 };
  513. EEPROM_WRITE(autoretract_enabled);
  514. EEPROM_WRITE(autoretract_defaults);
  515. #else
  516. EEPROM_WRITE(fwretract.autoretract_enabled);
  517. EEPROM_WRITE(fwretract.retract_length);
  518. EEPROM_WRITE(fwretract.retract_feedrate_mm_s);
  519. EEPROM_WRITE(fwretract.retract_zlift);
  520. EEPROM_WRITE(fwretract.retract_recover_length);
  521. EEPROM_WRITE(fwretract.retract_recover_feedrate_mm_s);
  522. EEPROM_WRITE(fwretract.swap_retract_length);
  523. EEPROM_WRITE(fwretract.swap_retract_recover_length);
  524. EEPROM_WRITE(fwretract.swap_retract_recover_feedrate_mm_s);
  525. #endif
  526. //
  527. // Volumetric & Filament Size
  528. //
  529. _FIELD_TEST(parser_volumetric_enabled);
  530. #if DISABLED(NO_VOLUMETRICS)
  531. EEPROM_WRITE(parser.volumetric_enabled);
  532. // Save filament sizes
  533. for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
  534. if (q < COUNT(planner.filament_size)) dummy = planner.filament_size[q];
  535. EEPROM_WRITE(dummy);
  536. }
  537. #else
  538. const bool volumetric_enabled = false;
  539. dummy = DEFAULT_NOMINAL_FILAMENT_DIA;
  540. EEPROM_WRITE(volumetric_enabled);
  541. for (uint8_t q = MAX_EXTRUDERS; q--;) EEPROM_WRITE(dummy);
  542. #endif
  543. //
  544. // Save TMC2130 or TMC2208 Configuration, and placeholder values
  545. //
  546. _FIELD_TEST(tmc_stepper_current);
  547. uint16_t tmc_stepper_current[TMC_AXES] = {
  548. #if HAS_TRINAMIC
  549. #if X_IS_TRINAMIC
  550. stepperX.getCurrent(),
  551. #else
  552. 0,
  553. #endif
  554. #if Y_IS_TRINAMIC
  555. stepperY.getCurrent(),
  556. #else
  557. 0,
  558. #endif
  559. #if Z_IS_TRINAMIC
  560. stepperZ.getCurrent(),
  561. #else
  562. 0,
  563. #endif
  564. #if X2_IS_TRINAMIC
  565. stepperX2.getCurrent(),
  566. #else
  567. 0,
  568. #endif
  569. #if Y2_IS_TRINAMIC
  570. stepperY2.getCurrent(),
  571. #else
  572. 0,
  573. #endif
  574. #if Z2_IS_TRINAMIC
  575. stepperZ2.getCurrent(),
  576. #else
  577. 0,
  578. #endif
  579. #if E0_IS_TRINAMIC
  580. stepperE0.getCurrent(),
  581. #else
  582. 0,
  583. #endif
  584. #if E1_IS_TRINAMIC
  585. stepperE1.getCurrent(),
  586. #else
  587. 0,
  588. #endif
  589. #if E2_IS_TRINAMIC
  590. stepperE2.getCurrent(),
  591. #else
  592. 0,
  593. #endif
  594. #if E3_IS_TRINAMIC
  595. stepperE3.getCurrent(),
  596. #else
  597. 0,
  598. #endif
  599. #if E4_IS_TRINAMIC
  600. stepperE4.getCurrent()
  601. #else
  602. 0
  603. #endif
  604. #else
  605. 0
  606. #endif
  607. };
  608. EEPROM_WRITE(tmc_stepper_current);
  609. //
  610. // Save TMC2130 or TMC2208 Hybrid Threshold, and placeholder values
  611. //
  612. _FIELD_TEST(tmc_hybrid_threshold);
  613. uint32_t tmc_hybrid_threshold[TMC_AXES] = {
  614. #if ENABLED(HYBRID_THRESHOLD)
  615. #if X_IS_TRINAMIC
  616. TMC_GET_PWMTHRS(X, X),
  617. #else
  618. X_HYBRID_THRESHOLD,
  619. #endif
  620. #if Y_IS_TRINAMIC
  621. TMC_GET_PWMTHRS(Y, Y),
  622. #else
  623. Y_HYBRID_THRESHOLD,
  624. #endif
  625. #if Z_IS_TRINAMIC
  626. TMC_GET_PWMTHRS(Z, Z),
  627. #else
  628. Z_HYBRID_THRESHOLD,
  629. #endif
  630. #if X2_IS_TRINAMIC
  631. TMC_GET_PWMTHRS(X, X2),
  632. #else
  633. X2_HYBRID_THRESHOLD,
  634. #endif
  635. #if Y2_IS_TRINAMIC
  636. TMC_GET_PWMTHRS(Y, Y2),
  637. #else
  638. Y2_HYBRID_THRESHOLD,
  639. #endif
  640. #if Z2_IS_TRINAMIC
  641. TMC_GET_PWMTHRS(Z, Z2),
  642. #else
  643. Z2_HYBRID_THRESHOLD,
  644. #endif
  645. #if E0_IS_TRINAMIC
  646. TMC_GET_PWMTHRS(E, E0),
  647. #else
  648. E0_HYBRID_THRESHOLD,
  649. #endif
  650. #if E1_IS_TRINAMIC
  651. TMC_GET_PWMTHRS(E, E1),
  652. #else
  653. E1_HYBRID_THRESHOLD,
  654. #endif
  655. #if E2_IS_TRINAMIC
  656. TMC_GET_PWMTHRS(E, E2),
  657. #else
  658. E2_HYBRID_THRESHOLD,
  659. #endif
  660. #if E3_IS_TRINAMIC
  661. TMC_GET_PWMTHRS(E, E3),
  662. #else
  663. E3_HYBRID_THRESHOLD,
  664. #endif
  665. #if E4_IS_TRINAMIC
  666. TMC_GET_PWMTHRS(E, E4)
  667. #else
  668. E4_HYBRID_THRESHOLD
  669. #endif
  670. #else
  671. 100, 100, 3, // X, Y, Z
  672. 100, 100, 3, // X2, Y2, Z2
  673. 30, 30, 30, 30, 30 // E0, E1, E2, E3, E4
  674. #endif
  675. };
  676. EEPROM_WRITE(tmc_hybrid_threshold);
  677. //
  678. // TMC2130 Sensorless homing threshold
  679. //
  680. int16_t tmc_sgt[XYZ] = {
  681. #if ENABLED(SENSORLESS_HOMING)
  682. #if defined(X_HOMING_SENSITIVITY) && (ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS))
  683. stepperX.sgt(),
  684. #else
  685. 0,
  686. #endif
  687. #if defined(Y_HOMING_SENSITIVITY) && (ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS))
  688. stepperY.sgt(),
  689. #else
  690. 0,
  691. #endif
  692. #if defined(Z_HOMING_SENSITIVITY) && (ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS))
  693. stepperZ.sgt()
  694. #else
  695. 0
  696. #endif
  697. #else
  698. 0
  699. #endif
  700. };
  701. EEPROM_WRITE(tmc_sgt);
  702. //
  703. // Linear Advance
  704. //
  705. _FIELD_TEST(planner_extruder_advance_K);
  706. #if ENABLED(LIN_ADVANCE)
  707. EEPROM_WRITE(planner.extruder_advance_K);
  708. #else
  709. dummy = 0.0f;
  710. EEPROM_WRITE(dummy);
  711. #endif
  712. _FIELD_TEST(motor_current_setting);
  713. #if HAS_MOTOR_CURRENT_PWM
  714. for (uint8_t q = XYZ; q--;) EEPROM_WRITE(stepper.motor_current_setting[q]);
  715. #else
  716. const uint32_t dummyui32[XYZ] = { 0 };
  717. EEPROM_WRITE(dummyui32);
  718. #endif
  719. //
  720. // CNC Coordinate Systems
  721. //
  722. _FIELD_TEST(coordinate_system);
  723. #if ENABLED(CNC_COORDINATE_SYSTEMS)
  724. EEPROM_WRITE(gcode.coordinate_system); // 27 floats
  725. #else
  726. dummy = 0.0f;
  727. for (uint8_t q = MAX_COORDINATE_SYSTEMS * XYZ; q--;) EEPROM_WRITE(dummy);
  728. #endif
  729. //
  730. // Skew correction factors
  731. //
  732. _FIELD_TEST(planner_xy_skew_factor);
  733. #if ENABLED(SKEW_CORRECTION)
  734. EEPROM_WRITE(planner.xy_skew_factor);
  735. EEPROM_WRITE(planner.xz_skew_factor);
  736. EEPROM_WRITE(planner.yz_skew_factor);
  737. #else
  738. dummy = 0.0f;
  739. for (uint8_t q = 3; q--;) EEPROM_WRITE(dummy);
  740. #endif
  741. //
  742. // Advanced Pause filament load & unload lengths
  743. //
  744. _FIELD_TEST(filament_change_unload_length);
  745. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  746. for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
  747. if (q < COUNT(filament_change_unload_length)) dummy = filament_change_unload_length[q];
  748. EEPROM_WRITE(dummy);
  749. }
  750. for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
  751. if (q < COUNT(filament_change_load_length)) dummy = filament_change_load_length[q];
  752. EEPROM_WRITE(dummy);
  753. }
  754. #else
  755. dummy = 0.0f;
  756. for (uint8_t q = MAX_EXTRUDERS * 2; q--;) EEPROM_WRITE(dummy);
  757. #endif
  758. //
  759. // Validate CRC and Data Size
  760. //
  761. if (!eeprom_error) {
  762. const uint16_t eeprom_size = eeprom_index - (EEPROM_OFFSET),
  763. final_crc = working_crc;
  764. // Write the EEPROM header
  765. eeprom_index = EEPROM_OFFSET;
  766. EEPROM_WRITE(version);
  767. EEPROM_WRITE(final_crc);
  768. // Report storage size
  769. #if ENABLED(EEPROM_CHITCHAT)
  770. SERIAL_ECHO_START_P(port);
  771. SERIAL_ECHOPAIR_P(port, "Settings Stored (", eeprom_size);
  772. SERIAL_ECHOPAIR_P(port, " bytes; crc ", (uint32_t)final_crc);
  773. SERIAL_ECHOLNPGM_P(port, ")");
  774. #endif
  775. eeprom_error |= size_error(eeprom_size);
  776. }
  777. EEPROM_FINISH();
  778. //
  779. // UBL Mesh
  780. //
  781. #if ENABLED(UBL_SAVE_ACTIVE_ON_M500)
  782. if (ubl.storage_slot >= 0)
  783. store_mesh(ubl.storage_slot);
  784. #endif
  785. return !eeprom_error;
  786. }
  787. /**
  788. * M501 - Retrieve Configuration
  789. */
  790. bool MarlinSettings::_load(PORTARG_SOLO) {
  791. uint16_t working_crc = 0;
  792. EEPROM_START();
  793. char stored_ver[4];
  794. EEPROM_READ_ALWAYS(stored_ver);
  795. uint16_t stored_crc;
  796. EEPROM_READ_ALWAYS(stored_crc);
  797. // Version has to match or defaults are used
  798. if (strncmp(version, stored_ver, 3) != 0) {
  799. if (stored_ver[3] != '\0') {
  800. stored_ver[0] = '?';
  801. stored_ver[1] = '\0';
  802. }
  803. #if ENABLED(EEPROM_CHITCHAT)
  804. SERIAL_ECHO_START_P(port);
  805. SERIAL_ECHOPGM_P(port, "EEPROM version mismatch ");
  806. SERIAL_ECHOPAIR_P(port, "(EEPROM=", stored_ver);
  807. SERIAL_ECHOLNPGM_P(port, " Marlin=" EEPROM_VERSION ")");
  808. #endif
  809. if (!validating) reset();
  810. eeprom_error = true;
  811. }
  812. else {
  813. float dummy = 0;
  814. #if DISABLED(AUTO_BED_LEVELING_UBL) || DISABLED(FWRETRACT) || ENABLED(NO_VOLUMETRICS)
  815. bool dummyb;
  816. #endif
  817. working_crc = 0; // Init to 0. Accumulated by EEPROM_READ
  818. _FIELD_TEST(esteppers);
  819. // Number of esteppers may change
  820. uint8_t esteppers;
  821. EEPROM_READ_ALWAYS(esteppers);
  822. //
  823. // Planner Motion
  824. //
  825. // Get only the number of E stepper parameters previously stored
  826. // Any steppers added later are set to their defaults
  827. const float def1[] = DEFAULT_AXIS_STEPS_PER_UNIT, def2[] = DEFAULT_MAX_FEEDRATE;
  828. const uint32_t def3[] = DEFAULT_MAX_ACCELERATION;
  829. float tmp1[XYZ + esteppers], tmp2[XYZ + esteppers];
  830. uint32_t tmp3[XYZ + esteppers];
  831. EEPROM_READ(tmp1);
  832. EEPROM_READ(tmp2);
  833. EEPROM_READ(tmp3);
  834. if (!validating) LOOP_XYZE_N(i) {
  835. planner.axis_steps_per_mm[i] = i < XYZ + esteppers ? tmp1[i] : def1[i < COUNT(def1) ? i : COUNT(def1) - 1];
  836. planner.max_feedrate_mm_s[i] = i < XYZ + esteppers ? tmp2[i] : def2[i < COUNT(def2) ? i : COUNT(def2) - 1];
  837. planner.max_acceleration_mm_per_s2[i] = i < XYZ + esteppers ? tmp3[i] : def3[i < COUNT(def3) ? i : COUNT(def3) - 1];
  838. }
  839. EEPROM_READ(planner.acceleration);
  840. EEPROM_READ(planner.retract_acceleration);
  841. EEPROM_READ(planner.travel_acceleration);
  842. EEPROM_READ(planner.min_feedrate_mm_s);
  843. EEPROM_READ(planner.min_travel_feedrate_mm_s);
  844. EEPROM_READ(planner.min_segment_time_us);
  845. EEPROM_READ(planner.max_jerk);
  846. //
  847. // Home Offset (M206)
  848. //
  849. _FIELD_TEST(home_offset);
  850. #if !HAS_HOME_OFFSET
  851. float home_offset[XYZ];
  852. #endif
  853. EEPROM_READ(home_offset);
  854. //
  855. // Hotend Offsets, if any
  856. //
  857. #if HOTENDS > 1
  858. // Skip hotend 0 which must be 0
  859. for (uint8_t e = 1; e < HOTENDS; e++)
  860. LOOP_XYZ(i) EEPROM_READ(hotend_offset[i][e]);
  861. #endif
  862. //
  863. // Global Leveling
  864. //
  865. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  866. EEPROM_READ(new_z_fade_height);
  867. #else
  868. EEPROM_READ(dummy);
  869. #endif
  870. //
  871. // Mesh (Manual) Bed Leveling
  872. //
  873. uint8_t mesh_num_x, mesh_num_y;
  874. EEPROM_READ(dummy);
  875. EEPROM_READ_ALWAYS(mesh_num_x);
  876. EEPROM_READ_ALWAYS(mesh_num_y);
  877. #if ENABLED(MESH_BED_LEVELING)
  878. if (!validating) mbl.z_offset = dummy;
  879. if (mesh_num_x == GRID_MAX_POINTS_X && mesh_num_y == GRID_MAX_POINTS_Y) {
  880. // EEPROM data fits the current mesh
  881. EEPROM_READ(mbl.z_values);
  882. }
  883. else {
  884. // EEPROM data is stale
  885. if (!validating) mbl.reset();
  886. for (uint16_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_READ(dummy);
  887. }
  888. #else
  889. // MBL is disabled - skip the stored data
  890. for (uint16_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_READ(dummy);
  891. #endif // MESH_BED_LEVELING
  892. _FIELD_TEST(zprobe_zoffset);
  893. #if !HAS_BED_PROBE
  894. float zprobe_zoffset;
  895. #endif
  896. EEPROM_READ(zprobe_zoffset);
  897. //
  898. // Planar Bed Leveling matrix
  899. //
  900. #if ABL_PLANAR
  901. EEPROM_READ(planner.bed_level_matrix);
  902. #else
  903. for (uint8_t q = 9; q--;) EEPROM_READ(dummy);
  904. #endif
  905. //
  906. // Bilinear Auto Bed Leveling
  907. //
  908. uint8_t grid_max_x, grid_max_y;
  909. EEPROM_READ_ALWAYS(grid_max_x); // 1 byte
  910. EEPROM_READ_ALWAYS(grid_max_y); // 1 byte
  911. #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
  912. if (grid_max_x == GRID_MAX_POINTS_X && grid_max_y == GRID_MAX_POINTS_Y) {
  913. if (!validating) set_bed_leveling_enabled(false);
  914. EEPROM_READ(bilinear_grid_spacing); // 2 ints
  915. EEPROM_READ(bilinear_start); // 2 ints
  916. EEPROM_READ(z_values); // 9 to 256 floats
  917. }
  918. else // EEPROM data is stale
  919. #endif // AUTO_BED_LEVELING_BILINEAR
  920. {
  921. // Skip past disabled (or stale) Bilinear Grid data
  922. int bgs[2], bs[2];
  923. EEPROM_READ(bgs);
  924. EEPROM_READ(bs);
  925. for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_READ(dummy);
  926. }
  927. //
  928. // Unified Bed Leveling active state
  929. //
  930. _FIELD_TEST(planner_leveling_active);
  931. #if ENABLED(AUTO_BED_LEVELING_UBL)
  932. EEPROM_READ(planner.leveling_active);
  933. EEPROM_READ(ubl.storage_slot);
  934. #else
  935. uint8_t dummyui8;
  936. EEPROM_READ(dummyb);
  937. EEPROM_READ(dummyui8);
  938. #endif // AUTO_BED_LEVELING_UBL
  939. //
  940. // DELTA Geometry or Dual Endstops offsets
  941. //
  942. #if ENABLED(DELTA)
  943. _FIELD_TEST(delta_height);
  944. EEPROM_READ(delta_height); // 1 float
  945. EEPROM_READ(delta_endstop_adj); // 3 floats
  946. EEPROM_READ(delta_radius); // 1 float
  947. EEPROM_READ(delta_diagonal_rod); // 1 float
  948. EEPROM_READ(delta_segments_per_second); // 1 float
  949. EEPROM_READ(delta_calibration_radius); // 1 float
  950. EEPROM_READ(delta_tower_angle_trim); // 3 floats
  951. #elif ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || ENABLED(Z_DUAL_ENDSTOPS)
  952. _FIELD_TEST(x_endstop_adj);
  953. #if ENABLED(X_DUAL_ENDSTOPS)
  954. EEPROM_READ(endstops.x_endstop_adj); // 1 float
  955. #else
  956. EEPROM_READ(dummy);
  957. #endif
  958. #if ENABLED(Y_DUAL_ENDSTOPS)
  959. EEPROM_READ(endstops.y_endstop_adj); // 1 float
  960. #else
  961. EEPROM_READ(dummy);
  962. #endif
  963. #if ENABLED(Z_DUAL_ENDSTOPS)
  964. EEPROM_READ(endstops.z_endstop_adj); // 1 float
  965. #else
  966. EEPROM_READ(dummy);
  967. #endif
  968. #endif
  969. //
  970. // LCD Preheat settings
  971. //
  972. _FIELD_TEST(lcd_preheat_hotend_temp);
  973. #if DISABLED(ULTIPANEL)
  974. int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
  975. #endif
  976. EEPROM_READ(lcd_preheat_hotend_temp); // 2 floats
  977. EEPROM_READ(lcd_preheat_bed_temp); // 2 floats
  978. EEPROM_READ(lcd_preheat_fan_speed); // 2 floats
  979. //EEPROM_ASSERT(
  980. // WITHIN(lcd_preheat_fan_speed, 0, 255),
  981. // "lcd_preheat_fan_speed out of range"
  982. //);
  983. //
  984. // Hotend PID
  985. //
  986. #if ENABLED(PIDTEMP)
  987. for (uint8_t e = 0; e < MAX_EXTRUDERS; e++) {
  988. EEPROM_READ(dummy); // Kp
  989. if (e < HOTENDS && dummy != DUMMY_PID_VALUE) {
  990. // do not need to scale PID values as the values in EEPROM are already scaled
  991. if (!validating) PID_PARAM(Kp, e) = dummy;
  992. EEPROM_READ(PID_PARAM(Ki, e));
  993. EEPROM_READ(PID_PARAM(Kd, e));
  994. #if ENABLED(PID_EXTRUSION_SCALING)
  995. EEPROM_READ(PID_PARAM(Kc, e));
  996. #else
  997. EEPROM_READ(dummy);
  998. #endif
  999. }
  1000. else {
  1001. for (uint8_t q=3; q--;) EEPROM_READ(dummy); // Ki, Kd, Kc
  1002. }
  1003. }
  1004. #else // !PIDTEMP
  1005. // 4 x 4 = 16 slots for PID parameters
  1006. for (uint8_t q = MAX_EXTRUDERS * 4; q--;) EEPROM_READ(dummy); // Kp, Ki, Kd, Kc
  1007. #endif // !PIDTEMP
  1008. //
  1009. // PID Extrusion Scaling
  1010. //
  1011. _FIELD_TEST(lpq_len);
  1012. #if DISABLED(PID_EXTRUSION_SCALING)
  1013. int lpq_len;
  1014. #endif
  1015. EEPROM_READ(lpq_len);
  1016. //
  1017. // Heated Bed PID
  1018. //
  1019. #if ENABLED(PIDTEMPBED)
  1020. EEPROM_READ(dummy); // bedKp
  1021. if (dummy != DUMMY_PID_VALUE) {
  1022. if (!validating) thermalManager.bedKp = dummy;
  1023. EEPROM_READ(thermalManager.bedKi);
  1024. EEPROM_READ(thermalManager.bedKd);
  1025. }
  1026. #else
  1027. for (uint8_t q=3; q--;) EEPROM_READ(dummy); // bedKp, bedKi, bedKd
  1028. #endif
  1029. //
  1030. // LCD Contrast
  1031. //
  1032. _FIELD_TEST(lcd_contrast);
  1033. #if !HAS_LCD_CONTRAST
  1034. int16_t lcd_contrast;
  1035. #endif
  1036. EEPROM_READ(lcd_contrast);
  1037. //
  1038. // Firmware Retraction
  1039. //
  1040. #if ENABLED(FWRETRACT)
  1041. EEPROM_READ(fwretract.autoretract_enabled);
  1042. EEPROM_READ(fwretract.retract_length);
  1043. EEPROM_READ(fwretract.retract_feedrate_mm_s);
  1044. EEPROM_READ(fwretract.retract_zlift);
  1045. EEPROM_READ(fwretract.retract_recover_length);
  1046. EEPROM_READ(fwretract.retract_recover_feedrate_mm_s);
  1047. EEPROM_READ(fwretract.swap_retract_length);
  1048. EEPROM_READ(fwretract.swap_retract_recover_length);
  1049. EEPROM_READ(fwretract.swap_retract_recover_feedrate_mm_s);
  1050. #else
  1051. EEPROM_READ(dummyb);
  1052. for (uint8_t q=8; q--;) EEPROM_READ(dummy);
  1053. #endif
  1054. //
  1055. // Volumetric & Filament Size
  1056. //
  1057. _FIELD_TEST(parser_volumetric_enabled);
  1058. #if DISABLED(NO_VOLUMETRICS)
  1059. EEPROM_READ(parser.volumetric_enabled);
  1060. for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
  1061. EEPROM_READ(dummy);
  1062. if (!validating && q < COUNT(planner.filament_size))
  1063. planner.filament_size[q] = dummy;
  1064. }
  1065. #else
  1066. EEPROM_READ(dummyb);
  1067. for (uint8_t q=MAX_EXTRUDERS; q--;) EEPROM_READ(dummy);
  1068. #endif
  1069. if (!validating) reset_stepper_drivers();
  1070. //
  1071. // TMC2130 Stepper Settings
  1072. //
  1073. _FIELD_TEST(tmc_stepper_current);
  1074. #if HAS_TRINAMIC
  1075. #define SET_CURR(Q) stepper##Q.setCurrent(currents[TMC_##Q] ? currents[TMC_##Q] : Q##_CURRENT, R_SENSE, HOLD_MULTIPLIER)
  1076. uint16_t currents[TMC_AXES];
  1077. EEPROM_READ(currents);
  1078. if (!validating) {
  1079. #if X_IS_TRINAMIC
  1080. SET_CURR(X);
  1081. #endif
  1082. #if Y_IS_TRINAMIC
  1083. SET_CURR(Y);
  1084. #endif
  1085. #if Z_IS_TRINAMIC
  1086. SET_CURR(Z);
  1087. #endif
  1088. #if X2_IS_TRINAMIC
  1089. SET_CURR(X2);
  1090. #endif
  1091. #if Y2_IS_TRINAMIC
  1092. SET_CURR(Y2);
  1093. #endif
  1094. #if Z2_IS_TRINAMIC
  1095. SET_CURR(Z2);
  1096. #endif
  1097. #if E0_IS_TRINAMIC
  1098. SET_CURR(E0);
  1099. #endif
  1100. #if E1_IS_TRINAMIC
  1101. SET_CURR(E1);
  1102. #endif
  1103. #if E2_IS_TRINAMIC
  1104. SET_CURR(E2);
  1105. #endif
  1106. #if E3_IS_TRINAMIC
  1107. SET_CURR(E3);
  1108. #endif
  1109. #if E4_IS_TRINAMIC
  1110. SET_CURR(E4);
  1111. #endif
  1112. }
  1113. #else
  1114. uint16_t val;
  1115. for (uint8_t q=TMC_AXES; q--;) EEPROM_READ(val);
  1116. #endif
  1117. #if ENABLED(HYBRID_THRESHOLD)
  1118. #define TMC_SET_PWMTHRS(P,Q) tmc_set_pwmthrs(stepper##Q, TMC_##Q, tmc_hybrid_threshold[TMC_##Q], planner.axis_steps_per_mm[P##_AXIS])
  1119. uint32_t tmc_hybrid_threshold[TMC_AXES];
  1120. EEPROM_READ(tmc_hybrid_threshold);
  1121. if (!validating) {
  1122. #if X_IS_TRINAMIC
  1123. TMC_SET_PWMTHRS(X, X);
  1124. #endif
  1125. #if Y_IS_TRINAMIC
  1126. TMC_SET_PWMTHRS(Y, Y);
  1127. #endif
  1128. #if Z_IS_TRINAMIC
  1129. TMC_SET_PWMTHRS(Z, Z);
  1130. #endif
  1131. #if X2_IS_TRINAMIC
  1132. TMC_SET_PWMTHRS(X, X2);
  1133. #endif
  1134. #if Y2_IS_TRINAMIC
  1135. TMC_SET_PWMTHRS(Y, Y2);
  1136. #endif
  1137. #if Z2_IS_TRINAMIC
  1138. TMC_SET_PWMTHRS(Z, Z2);
  1139. #endif
  1140. #if E0_IS_TRINAMIC
  1141. TMC_SET_PWMTHRS(E, E0);
  1142. #endif
  1143. #if E1_IS_TRINAMIC
  1144. TMC_SET_PWMTHRS(E, E1);
  1145. #endif
  1146. #if E2_IS_TRINAMIC
  1147. TMC_SET_PWMTHRS(E, E2);
  1148. #endif
  1149. #if E3_IS_TRINAMIC
  1150. TMC_SET_PWMTHRS(E, E3);
  1151. #endif
  1152. #if E4_IS_TRINAMIC
  1153. TMC_SET_PWMTHRS(E, E4);
  1154. #endif
  1155. }
  1156. #else
  1157. uint32_t thrs_val;
  1158. for (uint8_t q=TMC_AXES; q--;) EEPROM_READ(thrs_val);
  1159. #endif
  1160. /*
  1161. * TMC2130 Sensorless homing threshold.
  1162. * X and X2 use the same value
  1163. * Y and Y2 use the same value
  1164. * Z and Z2 use the same value
  1165. */
  1166. int16_t tmc_sgt[XYZ];
  1167. EEPROM_READ(tmc_sgt);
  1168. #if ENABLED(SENSORLESS_HOMING)
  1169. if (!validating) {
  1170. #ifdef X_HOMING_SENSITIVITY
  1171. #if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS)
  1172. stepperX.sgt(tmc_sgt[0]);
  1173. #endif
  1174. #if ENABLED(X2_IS_TMC2130)
  1175. stepperX2.sgt(tmc_sgt[0]);
  1176. #endif
  1177. #endif
  1178. #ifdef Y_HOMING_SENSITIVITY
  1179. #if ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS)
  1180. stepperY.sgt(tmc_sgt[1]);
  1181. #endif
  1182. #if ENABLED(Y2_IS_TMC2130)
  1183. stepperY2.sgt(tmc_sgt[1]);
  1184. #endif
  1185. #endif
  1186. #ifdef Z_HOMING_SENSITIVITY
  1187. #if ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS)
  1188. stepperZ.sgt(tmc_sgt[2]);
  1189. #endif
  1190. #if ENABLED(Z2_IS_TMC2130)
  1191. stepperZ2.sgt(tmc_sgt[2]);
  1192. #endif
  1193. #endif
  1194. }
  1195. #endif
  1196. //
  1197. // Linear Advance
  1198. //
  1199. _FIELD_TEST(planner_extruder_advance_K);
  1200. #if ENABLED(LIN_ADVANCE)
  1201. EEPROM_READ(planner.extruder_advance_K);
  1202. #else
  1203. EEPROM_READ(dummy);
  1204. #endif
  1205. //
  1206. // Motor Current PWM
  1207. //
  1208. _FIELD_TEST(motor_current_setting);
  1209. #if HAS_MOTOR_CURRENT_PWM
  1210. for (uint8_t q = XYZ; q--;) EEPROM_READ(stepper.motor_current_setting[q]);
  1211. #else
  1212. uint32_t dummyui32[XYZ];
  1213. EEPROM_READ(dummyui32);
  1214. #endif
  1215. //
  1216. // CNC Coordinate System
  1217. //
  1218. _FIELD_TEST(coordinate_system);
  1219. #if ENABLED(CNC_COORDINATE_SYSTEMS)
  1220. if (!validating) (void)gcode.select_coordinate_system(-1); // Go back to machine space
  1221. EEPROM_READ(gcode.coordinate_system); // 27 floats
  1222. #else
  1223. for (uint8_t q = MAX_COORDINATE_SYSTEMS * XYZ; q--;) EEPROM_READ(dummy);
  1224. #endif
  1225. //
  1226. // Skew correction factors
  1227. //
  1228. _FIELD_TEST(planner_xy_skew_factor);
  1229. #if ENABLED(SKEW_CORRECTION_GCODE)
  1230. EEPROM_READ(planner.xy_skew_factor);
  1231. #if ENABLED(SKEW_CORRECTION_FOR_Z)
  1232. EEPROM_READ(planner.xz_skew_factor);
  1233. EEPROM_READ(planner.yz_skew_factor);
  1234. #else
  1235. EEPROM_READ(dummy);
  1236. EEPROM_READ(dummy);
  1237. #endif
  1238. #else
  1239. for (uint8_t q = 3; q--;) EEPROM_READ(dummy);
  1240. #endif
  1241. //
  1242. // Advanced Pause filament load & unload lengths
  1243. //
  1244. _FIELD_TEST(filament_change_unload_length);
  1245. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  1246. for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
  1247. EEPROM_READ(dummy);
  1248. if (!validating && q < COUNT(filament_change_unload_length)) filament_change_unload_length[q] = dummy;
  1249. }
  1250. for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
  1251. EEPROM_READ(dummy);
  1252. if (!validating && q < COUNT(filament_change_load_length)) filament_change_load_length[q] = dummy;
  1253. }
  1254. #else
  1255. for (uint8_t q = MAX_EXTRUDERS * 2; q--;) EEPROM_READ(dummy);
  1256. #endif
  1257. eeprom_error = size_error(eeprom_index - (EEPROM_OFFSET));
  1258. if (eeprom_error) {
  1259. #if ENABLED(EEPROM_CHITCHAT)
  1260. SERIAL_ECHO_START_P(port);
  1261. SERIAL_ECHOPAIR_P(port, "Index: ", int(eeprom_index - (EEPROM_OFFSET)));
  1262. SERIAL_ECHOLNPAIR_P(port, " Size: ", datasize());
  1263. #endif
  1264. }
  1265. else if (working_crc != stored_crc) {
  1266. eeprom_error = true;
  1267. #if ENABLED(EEPROM_CHITCHAT)
  1268. SERIAL_ERROR_START_P(port);
  1269. SERIAL_ERRORPGM_P(port, "EEPROM CRC mismatch - (stored) ");
  1270. SERIAL_ERROR_P(port, stored_crc);
  1271. SERIAL_ERRORPGM_P(port, " != ");
  1272. SERIAL_ERROR_P(port, working_crc);
  1273. SERIAL_ERRORLNPGM_P(port, " (calculated)!");
  1274. #endif
  1275. }
  1276. else if (!validating) {
  1277. #if ENABLED(EEPROM_CHITCHAT)
  1278. SERIAL_ECHO_START_P(port);
  1279. SERIAL_ECHO_P(port, version);
  1280. SERIAL_ECHOPAIR_P(port, " stored settings retrieved (", eeprom_index - (EEPROM_OFFSET));
  1281. SERIAL_ECHOPAIR_P(port, " bytes; crc ", (uint32_t)working_crc);
  1282. SERIAL_ECHOLNPGM_P(port, ")");
  1283. #endif
  1284. }
  1285. if (!validating) {
  1286. if (eeprom_error) reset(); else postprocess();
  1287. }
  1288. #if ENABLED(AUTO_BED_LEVELING_UBL)
  1289. ubl.report_state();
  1290. if (!validating) {
  1291. if (!ubl.sanity_check()) {
  1292. SERIAL_EOL_P(port);
  1293. #if ENABLED(EEPROM_CHITCHAT)
  1294. ubl.echo_name();
  1295. SERIAL_ECHOLNPGM_P(port, " initialized.\n");
  1296. #endif
  1297. }
  1298. else {
  1299. eeprom_error = true;
  1300. #if ENABLED(EEPROM_CHITCHAT)
  1301. SERIAL_PROTOCOLPGM_P(port, "?Can't enable ");
  1302. ubl.echo_name();
  1303. SERIAL_PROTOCOLLNPGM_P(port, ".");
  1304. #endif
  1305. ubl.reset();
  1306. }
  1307. if (ubl.storage_slot >= 0) {
  1308. load_mesh(ubl.storage_slot);
  1309. #if ENABLED(EEPROM_CHITCHAT)
  1310. SERIAL_ECHOPAIR_P(port, "Mesh ", ubl.storage_slot);
  1311. SERIAL_ECHOLNPGM_P(port, " loaded from storage.");
  1312. #endif
  1313. }
  1314. else {
  1315. ubl.reset();
  1316. #if ENABLED(EEPROM_CHITCHAT)
  1317. SERIAL_ECHOLNPGM_P(port, "UBL System reset()");
  1318. #endif
  1319. }
  1320. }
  1321. #endif
  1322. }
  1323. #if ENABLED(EEPROM_CHITCHAT) && DISABLED(DISABLE_M503)
  1324. if (!validating) report(PORTVAR_SOLO);
  1325. #endif
  1326. EEPROM_FINISH();
  1327. return !eeprom_error;
  1328. }
  1329. bool MarlinSettings::validate(PORTARG_SOLO) {
  1330. validating = true;
  1331. const bool success = _load(PORTVAR_SOLO);
  1332. validating = false;
  1333. return success;
  1334. }
  1335. bool MarlinSettings::load(PORTARG_SOLO) {
  1336. if (validate(PORTVAR_SOLO)) return _load(PORTVAR_SOLO);
  1337. reset();
  1338. return true;
  1339. }
  1340. #if ENABLED(AUTO_BED_LEVELING_UBL)
  1341. #if ENABLED(EEPROM_CHITCHAT)
  1342. void ubl_invalid_slot(const int s) {
  1343. SERIAL_PROTOCOLLNPGM("?Invalid slot.");
  1344. SERIAL_PROTOCOL(s);
  1345. SERIAL_PROTOCOLLNPGM(" mesh slots available.");
  1346. }
  1347. #endif
  1348. int16_t MarlinSettings::meshes_start_index() {
  1349. return (datasize() + EEPROM_OFFSET + 32) & 0xFFF8; // Pad the end of configuration data so it can float up
  1350. // or down a little bit without disrupting the mesh data
  1351. }
  1352. uint16_t MarlinSettings::calc_num_meshes() {
  1353. return (meshes_end - meshes_start_index()) / sizeof(ubl.z_values);
  1354. }
  1355. int MarlinSettings::mesh_slot_offset(const int8_t slot) {
  1356. return meshes_end - (slot + 1) * sizeof(ubl.z_values);
  1357. }
  1358. void MarlinSettings::store_mesh(const int8_t slot) {
  1359. #if ENABLED(AUTO_BED_LEVELING_UBL)
  1360. const int16_t a = calc_num_meshes();
  1361. if (!WITHIN(slot, 0, a - 1)) {
  1362. #if ENABLED(EEPROM_CHITCHAT)
  1363. ubl_invalid_slot(a);
  1364. SERIAL_PROTOCOLPAIR("E2END=", E2END);
  1365. SERIAL_PROTOCOLPAIR(" meshes_end=", meshes_end);
  1366. SERIAL_PROTOCOLLNPAIR(" slot=", slot);
  1367. SERIAL_EOL();
  1368. #endif
  1369. return;
  1370. }
  1371. int pos = mesh_slot_offset(slot);
  1372. uint16_t crc = 0;
  1373. HAL::PersistentStore::access_start();
  1374. const bool status = HAL::PersistentStore::write_data(pos, (uint8_t *)&ubl.z_values, sizeof(ubl.z_values), &crc);
  1375. HAL::PersistentStore::access_finish();
  1376. if (status)
  1377. SERIAL_PROTOCOLPGM("?Unable to save mesh data.\n");
  1378. // Write crc to MAT along with other data, or just tack on to the beginning or end
  1379. #if ENABLED(EEPROM_CHITCHAT)
  1380. if (!status)
  1381. SERIAL_PROTOCOLLNPAIR("Mesh saved in slot ", slot);
  1382. #endif
  1383. #else
  1384. // Other mesh types
  1385. #endif
  1386. }
  1387. void MarlinSettings::load_mesh(const int8_t slot, void * const into/*=NULL*/) {
  1388. #if ENABLED(AUTO_BED_LEVELING_UBL)
  1389. const int16_t a = settings.calc_num_meshes();
  1390. if (!WITHIN(slot, 0, a - 1)) {
  1391. #if ENABLED(EEPROM_CHITCHAT)
  1392. ubl_invalid_slot(a);
  1393. #endif
  1394. return;
  1395. }
  1396. int pos = mesh_slot_offset(slot);
  1397. uint16_t crc = 0;
  1398. uint8_t * const dest = into ? (uint8_t*)into : (uint8_t*)&ubl.z_values;
  1399. HAL::PersistentStore::access_start();
  1400. const uint16_t status = HAL::PersistentStore::read_data(pos, dest, sizeof(ubl.z_values), &crc);
  1401. HAL::PersistentStore::access_finish();
  1402. if (status)
  1403. SERIAL_PROTOCOLPGM("?Unable to load mesh data.\n");
  1404. #if ENABLED(EEPROM_CHITCHAT)
  1405. else
  1406. SERIAL_PROTOCOLLNPAIR("Mesh loaded from slot ", slot);
  1407. #endif
  1408. EEPROM_FINISH();
  1409. #else
  1410. // Other mesh types
  1411. #endif
  1412. }
  1413. //void MarlinSettings::delete_mesh() { return; }
  1414. //void MarlinSettings::defrag_meshes() { return; }
  1415. #endif // AUTO_BED_LEVELING_UBL
  1416. #else // !EEPROM_SETTINGS
  1417. bool MarlinSettings::save(PORTARG_SOLO) {
  1418. #if ENABLED(EEPROM_CHITCHAT)
  1419. SERIAL_ERROR_START_P(port);
  1420. SERIAL_ERRORLNPGM_P(port, "EEPROM disabled");
  1421. #endif
  1422. return false;
  1423. }
  1424. #endif // !EEPROM_SETTINGS
  1425. /**
  1426. * M502 - Reset Configuration
  1427. */
  1428. void MarlinSettings::reset(PORTARG_SOLO) {
  1429. static const float tmp1[] PROGMEM = DEFAULT_AXIS_STEPS_PER_UNIT, tmp2[] PROGMEM = DEFAULT_MAX_FEEDRATE;
  1430. static const uint32_t tmp3[] PROGMEM = DEFAULT_MAX_ACCELERATION;
  1431. LOOP_XYZE_N(i) {
  1432. planner.axis_steps_per_mm[i] = pgm_read_float(&tmp1[i < COUNT(tmp1) ? i : COUNT(tmp1) - 1]);
  1433. planner.max_feedrate_mm_s[i] = pgm_read_float(&tmp2[i < COUNT(tmp2) ? i : COUNT(tmp2) - 1]);
  1434. planner.max_acceleration_mm_per_s2[i] = pgm_read_dword_near(&tmp3[i < COUNT(tmp3) ? i : COUNT(tmp3) - 1]);
  1435. }
  1436. planner.acceleration = DEFAULT_ACCELERATION;
  1437. planner.retract_acceleration = DEFAULT_RETRACT_ACCELERATION;
  1438. planner.travel_acceleration = DEFAULT_TRAVEL_ACCELERATION;
  1439. planner.min_feedrate_mm_s = DEFAULT_MINIMUMFEEDRATE;
  1440. planner.min_travel_feedrate_mm_s = DEFAULT_MINTRAVELFEEDRATE;
  1441. planner.min_segment_time_us = DEFAULT_MINSEGMENTTIME;
  1442. planner.max_jerk[X_AXIS] = DEFAULT_XJERK;
  1443. planner.max_jerk[Y_AXIS] = DEFAULT_YJERK;
  1444. planner.max_jerk[Z_AXIS] = DEFAULT_ZJERK;
  1445. planner.max_jerk[E_AXIS] = DEFAULT_EJERK;
  1446. #if HAS_HOME_OFFSET
  1447. ZERO(home_offset);
  1448. #endif
  1449. #if HOTENDS > 1
  1450. constexpr float tmp4[XYZ][HOTENDS] = {
  1451. HOTEND_OFFSET_X,
  1452. HOTEND_OFFSET_Y
  1453. #ifdef HOTEND_OFFSET_Z
  1454. , HOTEND_OFFSET_Z
  1455. #else
  1456. , { 0 }
  1457. #endif
  1458. };
  1459. static_assert(
  1460. tmp4[X_AXIS][0] == 0 && tmp4[Y_AXIS][0] == 0 && tmp4[Z_AXIS][0] == 0,
  1461. "Offsets for the first hotend must be 0.0."
  1462. );
  1463. LOOP_XYZ(i) HOTEND_LOOP() hotend_offset[i][e] = tmp4[i][e];
  1464. #endif
  1465. //
  1466. // Global Leveling
  1467. //
  1468. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  1469. new_z_fade_height = 0.0;
  1470. #endif
  1471. #if HAS_LEVELING
  1472. reset_bed_level();
  1473. #endif
  1474. #if HAS_BED_PROBE
  1475. zprobe_zoffset = Z_PROBE_OFFSET_FROM_EXTRUDER;
  1476. #endif
  1477. #if ENABLED(DELTA)
  1478. const float adj[ABC] = DELTA_ENDSTOP_ADJ,
  1479. dta[ABC] = DELTA_TOWER_ANGLE_TRIM;
  1480. delta_height = DELTA_HEIGHT;
  1481. COPY(delta_endstop_adj, adj);
  1482. delta_radius = DELTA_RADIUS;
  1483. delta_diagonal_rod = DELTA_DIAGONAL_ROD;
  1484. delta_segments_per_second = DELTA_SEGMENTS_PER_SECOND;
  1485. delta_calibration_radius = DELTA_CALIBRATION_RADIUS;
  1486. COPY(delta_tower_angle_trim, dta);
  1487. #elif ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || ENABLED(Z_DUAL_ENDSTOPS)
  1488. #if ENABLED(X_DUAL_ENDSTOPS)
  1489. endstops.x_endstop_adj = (
  1490. #ifdef X_DUAL_ENDSTOPS_ADJUSTMENT
  1491. X_DUAL_ENDSTOPS_ADJUSTMENT
  1492. #else
  1493. 0
  1494. #endif
  1495. );
  1496. #endif
  1497. #if ENABLED(Y_DUAL_ENDSTOPS)
  1498. endstops.y_endstop_adj = (
  1499. #ifdef Y_DUAL_ENDSTOPS_ADJUSTMENT
  1500. Y_DUAL_ENDSTOPS_ADJUSTMENT
  1501. #else
  1502. 0
  1503. #endif
  1504. );
  1505. #endif
  1506. #if ENABLED(Z_DUAL_ENDSTOPS)
  1507. endstops.z_endstop_adj = (
  1508. #ifdef Z_DUAL_ENDSTOPS_ADJUSTMENT
  1509. Z_DUAL_ENDSTOPS_ADJUSTMENT
  1510. #else
  1511. 0
  1512. #endif
  1513. );
  1514. #endif
  1515. #endif
  1516. #if ENABLED(ULTIPANEL)
  1517. lcd_preheat_hotend_temp[0] = PREHEAT_1_TEMP_HOTEND;
  1518. lcd_preheat_hotend_temp[1] = PREHEAT_2_TEMP_HOTEND;
  1519. lcd_preheat_bed_temp[0] = PREHEAT_1_TEMP_BED;
  1520. lcd_preheat_bed_temp[1] = PREHEAT_2_TEMP_BED;
  1521. lcd_preheat_fan_speed[0] = PREHEAT_1_FAN_SPEED;
  1522. lcd_preheat_fan_speed[1] = PREHEAT_2_FAN_SPEED;
  1523. #endif
  1524. #if ENABLED(PIDTEMP)
  1525. #if ENABLED(PID_PARAMS_PER_HOTEND) && HOTENDS > 1
  1526. HOTEND_LOOP()
  1527. #endif
  1528. {
  1529. PID_PARAM(Kp, e) = DEFAULT_Kp;
  1530. PID_PARAM(Ki, e) = scalePID_i(DEFAULT_Ki);
  1531. PID_PARAM(Kd, e) = scalePID_d(DEFAULT_Kd);
  1532. #if ENABLED(PID_EXTRUSION_SCALING)
  1533. PID_PARAM(Kc, e) = DEFAULT_Kc;
  1534. #endif
  1535. }
  1536. #if ENABLED(PID_EXTRUSION_SCALING)
  1537. lpq_len = 20; // default last-position-queue size
  1538. #endif
  1539. #endif // PIDTEMP
  1540. #if ENABLED(PIDTEMPBED)
  1541. thermalManager.bedKp = DEFAULT_bedKp;
  1542. thermalManager.bedKi = scalePID_i(DEFAULT_bedKi);
  1543. thermalManager.bedKd = scalePID_d(DEFAULT_bedKd);
  1544. #endif
  1545. #if HAS_LCD_CONTRAST
  1546. lcd_contrast = DEFAULT_LCD_CONTRAST;
  1547. #endif
  1548. #if ENABLED(FWRETRACT)
  1549. fwretract.reset();
  1550. #endif
  1551. #if DISABLED(NO_VOLUMETRICS)
  1552. parser.volumetric_enabled =
  1553. #if ENABLED(VOLUMETRIC_DEFAULT_ON)
  1554. true
  1555. #else
  1556. false
  1557. #endif
  1558. ;
  1559. for (uint8_t q = 0; q < COUNT(planner.filament_size); q++)
  1560. planner.filament_size[q] = DEFAULT_NOMINAL_FILAMENT_DIA;
  1561. #endif
  1562. endstops.enable_globally(
  1563. #if ENABLED(ENDSTOPS_ALWAYS_ON_DEFAULT)
  1564. true
  1565. #else
  1566. false
  1567. #endif
  1568. );
  1569. reset_stepper_drivers();
  1570. #if ENABLED(LIN_ADVANCE)
  1571. planner.extruder_advance_K = LIN_ADVANCE_K;
  1572. #endif
  1573. #if HAS_MOTOR_CURRENT_PWM
  1574. uint32_t tmp_motor_current_setting[XYZ] = PWM_MOTOR_CURRENT;
  1575. for (uint8_t q = XYZ; q--;)
  1576. stepper.digipot_current(q, (stepper.motor_current_setting[q] = tmp_motor_current_setting[q]));
  1577. #endif
  1578. #if ENABLED(SKEW_CORRECTION_GCODE)
  1579. planner.xy_skew_factor = XY_SKEW_FACTOR;
  1580. #if ENABLED(SKEW_CORRECTION_FOR_Z)
  1581. planner.xz_skew_factor = XZ_SKEW_FACTOR;
  1582. planner.yz_skew_factor = YZ_SKEW_FACTOR;
  1583. #endif
  1584. #endif
  1585. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  1586. for (uint8_t e = 0; e < E_STEPPERS; e++) {
  1587. filament_change_unload_length[e] = FILAMENT_CHANGE_UNLOAD_LENGTH;
  1588. filament_change_load_length[e] = FILAMENT_CHANGE_LOAD_LENGTH;
  1589. }
  1590. #endif
  1591. postprocess();
  1592. #if ENABLED(EEPROM_CHITCHAT)
  1593. SERIAL_ECHO_START_P(port);
  1594. SERIAL_ECHOLNPGM_P(port, "Hardcoded Default Settings Loaded");
  1595. #endif
  1596. }
  1597. #if DISABLED(DISABLE_M503)
  1598. #define CONFIG_ECHO_START do{ if (!forReplay) SERIAL_ECHO_START_P(port); }while(0)
  1599. #if HAS_TRINAMIC
  1600. void say_M906(PORTARG_SOLO) { SERIAL_ECHOPGM_P(port, " M906 "); }
  1601. #if ENABLED(HYBRID_THRESHOLD)
  1602. void say_M913(PORTARG_SOLO) { SERIAL_ECHOPGM_P(port, " M913 "); }
  1603. #endif
  1604. #if ENABLED(SENSORLESS_HOMING)
  1605. void say_M914(PORTARG_SOLO) { SERIAL_ECHOPGM_P(port, " M914 "); }
  1606. #endif
  1607. #endif
  1608. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  1609. void say_M603(PORTARG_SOLO) { SERIAL_ECHOPGM_P(port, " M603 "); }
  1610. #endif
  1611. /**
  1612. * M503 - Report current settings in RAM
  1613. *
  1614. * Unless specifically disabled, M503 is available even without EEPROM
  1615. */
  1616. void MarlinSettings::report(const bool forReplay
  1617. #if NUM_SERIAL > 1
  1618. , const int8_t port/*=-1*/
  1619. #endif
  1620. ) {
  1621. /**
  1622. * Announce current units, in case inches are being displayed
  1623. */
  1624. CONFIG_ECHO_START;
  1625. #if ENABLED(INCH_MODE_SUPPORT)
  1626. #define LINEAR_UNIT(N) (float(N) / parser.linear_unit_factor)
  1627. #define VOLUMETRIC_UNIT(N) (float(N) / (parser.volumetric_enabled ? parser.volumetric_unit_factor : parser.linear_unit_factor))
  1628. SERIAL_ECHOPGM_P(port, " G2");
  1629. SERIAL_CHAR_P(port, parser.linear_unit_factor == 1.0 ? '1' : '0');
  1630. SERIAL_ECHOPGM_P(port, " ; Units in ");
  1631. serialprintPGM_P(port, parser.linear_unit_factor == 1.0 ? PSTR("mm\n") : PSTR("inches\n"));
  1632. #else
  1633. #define LINEAR_UNIT(N) (N)
  1634. #define VOLUMETRIC_UNIT(N) (N)
  1635. SERIAL_ECHOLNPGM_P(port, " G21 ; Units in mm");
  1636. #endif
  1637. #if ENABLED(ULTIPANEL)
  1638. // Temperature units - for Ultipanel temperature options
  1639. CONFIG_ECHO_START;
  1640. #if ENABLED(TEMPERATURE_UNITS_SUPPORT)
  1641. #define TEMP_UNIT(N) parser.to_temp_units(N)
  1642. SERIAL_ECHOPGM_P(port, " M149 ");
  1643. SERIAL_CHAR_P(port, parser.temp_units_code());
  1644. SERIAL_ECHOPGM_P(port, " ; Units in ");
  1645. serialprintPGM_P(port, parser.temp_units_name());
  1646. #else
  1647. #define TEMP_UNIT(N) (N)
  1648. SERIAL_ECHOLNPGM_P(port, " M149 C ; Units in Celsius");
  1649. #endif
  1650. #endif
  1651. SERIAL_EOL_P(port);
  1652. #if DISABLED(NO_VOLUMETRICS)
  1653. /**
  1654. * Volumetric extrusion M200
  1655. */
  1656. if (!forReplay) {
  1657. CONFIG_ECHO_START;
  1658. SERIAL_ECHOPGM_P(port, "Filament settings:");
  1659. if (parser.volumetric_enabled)
  1660. SERIAL_EOL_P(port);
  1661. else
  1662. SERIAL_ECHOLNPGM_P(port, " Disabled");
  1663. }
  1664. CONFIG_ECHO_START;
  1665. SERIAL_ECHOPAIR_P(port, " M200 D", LINEAR_UNIT(planner.filament_size[0]));
  1666. SERIAL_EOL_P(port);
  1667. #if EXTRUDERS > 1
  1668. CONFIG_ECHO_START;
  1669. SERIAL_ECHOPAIR_P(port, " M200 T1 D", LINEAR_UNIT(planner.filament_size[1]));
  1670. SERIAL_EOL_P(port);
  1671. #if EXTRUDERS > 2
  1672. CONFIG_ECHO_START;
  1673. SERIAL_ECHOPAIR_P(port, " M200 T2 D", LINEAR_UNIT(planner.filament_size[2]));
  1674. SERIAL_EOL_P(port);
  1675. #if EXTRUDERS > 3
  1676. CONFIG_ECHO_START;
  1677. SERIAL_ECHOPAIR_P(port, " M200 T3 D", LINEAR_UNIT(planner.filament_size[3]));
  1678. SERIAL_EOL_P(port);
  1679. #if EXTRUDERS > 4
  1680. CONFIG_ECHO_START;
  1681. SERIAL_ECHOPAIR_P(port, " M200 T4 D", LINEAR_UNIT(planner.filament_size[4]));
  1682. SERIAL_EOL_P(port);
  1683. #endif // EXTRUDERS > 4
  1684. #endif // EXTRUDERS > 3
  1685. #endif // EXTRUDERS > 2
  1686. #endif // EXTRUDERS > 1
  1687. if (!parser.volumetric_enabled) {
  1688. CONFIG_ECHO_START;
  1689. SERIAL_ECHOLNPGM_P(port, " M200 D0");
  1690. }
  1691. #endif // !NO_VOLUMETRICS
  1692. if (!forReplay) {
  1693. CONFIG_ECHO_START;
  1694. SERIAL_ECHOLNPGM_P(port, "Steps per unit:");
  1695. }
  1696. CONFIG_ECHO_START;
  1697. SERIAL_ECHOPAIR_P(port, " M92 X", LINEAR_UNIT(planner.axis_steps_per_mm[X_AXIS]));
  1698. SERIAL_ECHOPAIR_P(port, " Y", LINEAR_UNIT(planner.axis_steps_per_mm[Y_AXIS]));
  1699. SERIAL_ECHOPAIR_P(port, " Z", LINEAR_UNIT(planner.axis_steps_per_mm[Z_AXIS]));
  1700. #if DISABLED(DISTINCT_E_FACTORS)
  1701. SERIAL_ECHOPAIR_P(port, " E", VOLUMETRIC_UNIT(planner.axis_steps_per_mm[E_AXIS]));
  1702. #endif
  1703. SERIAL_EOL_P(port);
  1704. #if ENABLED(DISTINCT_E_FACTORS)
  1705. CONFIG_ECHO_START;
  1706. for (uint8_t i = 0; i < E_STEPPERS; i++) {
  1707. SERIAL_ECHOPAIR_P(port, " M92 T", (int)i);
  1708. SERIAL_ECHOLNPAIR_P(port, " E", VOLUMETRIC_UNIT(planner.axis_steps_per_mm[E_AXIS + i]));
  1709. }
  1710. #endif
  1711. if (!forReplay) {
  1712. CONFIG_ECHO_START;
  1713. SERIAL_ECHOLNPGM_P(port, "Maximum feedrates (units/s):");
  1714. }
  1715. CONFIG_ECHO_START;
  1716. SERIAL_ECHOPAIR_P(port, " M203 X", LINEAR_UNIT(planner.max_feedrate_mm_s[X_AXIS]));
  1717. SERIAL_ECHOPAIR_P(port, " Y", LINEAR_UNIT(planner.max_feedrate_mm_s[Y_AXIS]));
  1718. SERIAL_ECHOPAIR_P(port, " Z", LINEAR_UNIT(planner.max_feedrate_mm_s[Z_AXIS]));
  1719. #if DISABLED(DISTINCT_E_FACTORS)
  1720. SERIAL_ECHOPAIR_P(port, " E", VOLUMETRIC_UNIT(planner.max_feedrate_mm_s[E_AXIS]));
  1721. #endif
  1722. SERIAL_EOL_P(port);
  1723. #if ENABLED(DISTINCT_E_FACTORS)
  1724. CONFIG_ECHO_START;
  1725. for (uint8_t i = 0; i < E_STEPPERS; i++) {
  1726. SERIAL_ECHOPAIR_P(port, " M203 T", (int)i);
  1727. SERIAL_ECHOLNPAIR_P(port, " E", VOLUMETRIC_UNIT(planner.max_feedrate_mm_s[E_AXIS + i]));
  1728. }
  1729. #endif
  1730. if (!forReplay) {
  1731. CONFIG_ECHO_START;
  1732. SERIAL_ECHOLNPGM_P(port, "Maximum Acceleration (units/s2):");
  1733. }
  1734. CONFIG_ECHO_START;
  1735. SERIAL_ECHOPAIR_P(port, " M201 X", LINEAR_UNIT(planner.max_acceleration_mm_per_s2[X_AXIS]));
  1736. SERIAL_ECHOPAIR_P(port, " Y", LINEAR_UNIT(planner.max_acceleration_mm_per_s2[Y_AXIS]));
  1737. SERIAL_ECHOPAIR_P(port, " Z", LINEAR_UNIT(planner.max_acceleration_mm_per_s2[Z_AXIS]));
  1738. #if DISABLED(DISTINCT_E_FACTORS)
  1739. SERIAL_ECHOPAIR_P(port, " E", VOLUMETRIC_UNIT(planner.max_acceleration_mm_per_s2[E_AXIS]));
  1740. #endif
  1741. SERIAL_EOL_P(port);
  1742. #if ENABLED(DISTINCT_E_FACTORS)
  1743. CONFIG_ECHO_START;
  1744. for (uint8_t i = 0; i < E_STEPPERS; i++) {
  1745. SERIAL_ECHOPAIR_P(port, " M201 T", (int)i);
  1746. SERIAL_ECHOLNPAIR_P(port, " E", VOLUMETRIC_UNIT(planner.max_acceleration_mm_per_s2[E_AXIS + i]));
  1747. }
  1748. #endif
  1749. if (!forReplay) {
  1750. CONFIG_ECHO_START;
  1751. SERIAL_ECHOLNPGM_P(port, "Acceleration (units/s2): P<print_accel> R<retract_accel> T<travel_accel>");
  1752. }
  1753. CONFIG_ECHO_START;
  1754. SERIAL_ECHOPAIR_P(port, " M204 P", LINEAR_UNIT(planner.acceleration));
  1755. SERIAL_ECHOPAIR_P(port, " R", LINEAR_UNIT(planner.retract_acceleration));
  1756. SERIAL_ECHOLNPAIR_P(port, " T", LINEAR_UNIT(planner.travel_acceleration));
  1757. if (!forReplay) {
  1758. CONFIG_ECHO_START;
  1759. SERIAL_ECHOLNPGM_P(port, "Advanced: S<min_feedrate> T<min_travel_feedrate> B<min_segment_time_us> X<max_xy_jerk> Z<max_z_jerk> E<max_e_jerk>");
  1760. }
  1761. CONFIG_ECHO_START;
  1762. SERIAL_ECHOPAIR_P(port, " M205 S", LINEAR_UNIT(planner.min_feedrate_mm_s));
  1763. SERIAL_ECHOPAIR_P(port, " T", LINEAR_UNIT(planner.min_travel_feedrate_mm_s));
  1764. SERIAL_ECHOPAIR_P(port, " B", planner.min_segment_time_us);
  1765. SERIAL_ECHOPAIR_P(port, " X", LINEAR_UNIT(planner.max_jerk[X_AXIS]));
  1766. SERIAL_ECHOPAIR_P(port, " Y", LINEAR_UNIT(planner.max_jerk[Y_AXIS]));
  1767. SERIAL_ECHOPAIR_P(port, " Z", LINEAR_UNIT(planner.max_jerk[Z_AXIS]));
  1768. SERIAL_ECHOLNPAIR_P(port, " E", LINEAR_UNIT(planner.max_jerk[E_AXIS]));
  1769. #if HAS_M206_COMMAND
  1770. if (!forReplay) {
  1771. CONFIG_ECHO_START;
  1772. SERIAL_ECHOLNPGM_P(port, "Home offset:");
  1773. }
  1774. CONFIG_ECHO_START;
  1775. SERIAL_ECHOPAIR_P(port, " M206 X", LINEAR_UNIT(home_offset[X_AXIS]));
  1776. SERIAL_ECHOPAIR_P(port, " Y", LINEAR_UNIT(home_offset[Y_AXIS]));
  1777. SERIAL_ECHOLNPAIR_P(port, " Z", LINEAR_UNIT(home_offset[Z_AXIS]));
  1778. #endif
  1779. #if HOTENDS > 1
  1780. if (!forReplay) {
  1781. CONFIG_ECHO_START;
  1782. SERIAL_ECHOLNPGM_P(port, "Hotend offsets:");
  1783. }
  1784. CONFIG_ECHO_START;
  1785. for (uint8_t e = 1; e < HOTENDS; e++) {
  1786. SERIAL_ECHOPAIR_P(port, " M218 T", (int)e);
  1787. SERIAL_ECHOPAIR_P(port, " X", LINEAR_UNIT(hotend_offset[X_AXIS][e]));
  1788. SERIAL_ECHOPAIR_P(port, " Y", LINEAR_UNIT(hotend_offset[Y_AXIS][e]));
  1789. #if ENABLED(DUAL_X_CARRIAGE) || ENABLED(SWITCHING_NOZZLE) ||ENABLED(PARKING_EXTRUDER)
  1790. SERIAL_ECHOPAIR_P(port, " Z", LINEAR_UNIT(hotend_offset[Z_AXIS][e]));
  1791. #endif
  1792. SERIAL_EOL_P(port);
  1793. }
  1794. #endif
  1795. /**
  1796. * Bed Leveling
  1797. */
  1798. #if HAS_LEVELING
  1799. #if ENABLED(MESH_BED_LEVELING)
  1800. if (!forReplay) {
  1801. CONFIG_ECHO_START;
  1802. SERIAL_ECHOLNPGM_P(port, "Mesh Bed Leveling:");
  1803. }
  1804. #elif ENABLED(AUTO_BED_LEVELING_UBL)
  1805. if (!forReplay) {
  1806. CONFIG_ECHO_START;
  1807. ubl.echo_name();
  1808. SERIAL_ECHOLNPGM_P(port, ":");
  1809. }
  1810. #elif HAS_ABL
  1811. if (!forReplay) {
  1812. CONFIG_ECHO_START;
  1813. SERIAL_ECHOLNPGM_P(port, "Auto Bed Leveling:");
  1814. }
  1815. #endif
  1816. CONFIG_ECHO_START;
  1817. SERIAL_ECHOPAIR_P(port, " M420 S", planner.leveling_active ? 1 : 0);
  1818. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  1819. SERIAL_ECHOPAIR_P(port, " Z", LINEAR_UNIT(planner.z_fade_height));
  1820. #endif
  1821. SERIAL_EOL_P(port);
  1822. #if ENABLED(MESH_BED_LEVELING)
  1823. if (leveling_is_valid()) {
  1824. for (uint8_t py = 0; py < GRID_MAX_POINTS_Y; py++) {
  1825. for (uint8_t px = 0; px < GRID_MAX_POINTS_X; px++) {
  1826. CONFIG_ECHO_START;
  1827. SERIAL_ECHOPAIR_P(port, " G29 S3 X", (int)px + 1);
  1828. SERIAL_ECHOPAIR_P(port, " Y", (int)py + 1);
  1829. SERIAL_ECHOPGM_P(port, " Z");
  1830. SERIAL_ECHO_F_P(port, LINEAR_UNIT(mbl.z_values[px][py]), 5);
  1831. SERIAL_EOL_P(port);
  1832. }
  1833. }
  1834. }
  1835. #elif ENABLED(AUTO_BED_LEVELING_UBL)
  1836. if (!forReplay) {
  1837. SERIAL_EOL_P(port);
  1838. ubl.report_state();
  1839. SERIAL_ECHOLNPAIR_P(port, "\nActive Mesh Slot: ", ubl.storage_slot);
  1840. SERIAL_ECHOPAIR_P(port, "EEPROM can hold ", calc_num_meshes());
  1841. SERIAL_ECHOLNPGM_P(port, " meshes.\n");
  1842. }
  1843. ubl.report_current_mesh(PORTVAR_SOLO);
  1844. #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
  1845. if (leveling_is_valid()) {
  1846. for (uint8_t py = 0; py < GRID_MAX_POINTS_Y; py++) {
  1847. for (uint8_t px = 0; px < GRID_MAX_POINTS_X; px++) {
  1848. CONFIG_ECHO_START;
  1849. SERIAL_ECHOPAIR_P(port, " G29 W I", (int)px + 1);
  1850. SERIAL_ECHOPAIR_P(port, " J", (int)py + 1);
  1851. SERIAL_ECHOPGM_P(port, " Z");
  1852. SERIAL_ECHO_F_P(port, LINEAR_UNIT(z_values[px][py]), 5);
  1853. SERIAL_EOL_P(port);
  1854. }
  1855. }
  1856. }
  1857. #endif
  1858. #endif // HAS_LEVELING
  1859. #if ENABLED(DELTA)
  1860. if (!forReplay) {
  1861. CONFIG_ECHO_START;
  1862. SERIAL_ECHOLNPGM_P(port, "Endstop adjustment:");
  1863. }
  1864. CONFIG_ECHO_START;
  1865. SERIAL_ECHOPAIR_P(port, " M666 X", LINEAR_UNIT(delta_endstop_adj[X_AXIS]));
  1866. SERIAL_ECHOPAIR_P(port, " Y", LINEAR_UNIT(delta_endstop_adj[Y_AXIS]));
  1867. SERIAL_ECHOLNPAIR_P(port, " Z", LINEAR_UNIT(delta_endstop_adj[Z_AXIS]));
  1868. if (!forReplay) {
  1869. CONFIG_ECHO_START;
  1870. SERIAL_ECHOLNPGM_P(port, "Delta settings: L<diagonal_rod> R<radius> H<height> S<segments_per_s> B<calibration radius> XYZ<tower angle corrections>");
  1871. }
  1872. CONFIG_ECHO_START;
  1873. SERIAL_ECHOPAIR_P(port, " M665 L", LINEAR_UNIT(delta_diagonal_rod));
  1874. SERIAL_ECHOPAIR_P(port, " R", LINEAR_UNIT(delta_radius));
  1875. SERIAL_ECHOPAIR_P(port, " H", LINEAR_UNIT(delta_height));
  1876. SERIAL_ECHOPAIR_P(port, " S", delta_segments_per_second);
  1877. SERIAL_ECHOPAIR_P(port, " B", LINEAR_UNIT(delta_calibration_radius));
  1878. SERIAL_ECHOPAIR_P(port, " X", LINEAR_UNIT(delta_tower_angle_trim[A_AXIS]));
  1879. SERIAL_ECHOPAIR_P(port, " Y", LINEAR_UNIT(delta_tower_angle_trim[B_AXIS]));
  1880. SERIAL_ECHOPAIR_P(port, " Z", LINEAR_UNIT(delta_tower_angle_trim[C_AXIS]));
  1881. SERIAL_EOL_P(port);
  1882. #elif ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || ENABLED(Z_DUAL_ENDSTOPS)
  1883. if (!forReplay) {
  1884. CONFIG_ECHO_START;
  1885. SERIAL_ECHOLNPGM_P(port, "Endstop adjustment:");
  1886. }
  1887. CONFIG_ECHO_START;
  1888. SERIAL_ECHOPGM_P(port, " M666");
  1889. #if ENABLED(X_DUAL_ENDSTOPS)
  1890. SERIAL_ECHOPAIR_P(port, " X", LINEAR_UNIT(endstops.x_endstop_adj));
  1891. #endif
  1892. #if ENABLED(Y_DUAL_ENDSTOPS)
  1893. SERIAL_ECHOPAIR_P(port, " Y", LINEAR_UNIT(endstops.y_endstop_adj));
  1894. #endif
  1895. #if ENABLED(Z_DUAL_ENDSTOPS)
  1896. SERIAL_ECHOPAIR_P(port, " Z", LINEAR_UNIT(endstops.z_endstop_adj));
  1897. #endif
  1898. SERIAL_EOL_P(port);
  1899. #endif // [XYZ]_DUAL_ENDSTOPS
  1900. #if ENABLED(ULTIPANEL)
  1901. if (!forReplay) {
  1902. CONFIG_ECHO_START;
  1903. SERIAL_ECHOLNPGM_P(port, "Material heatup parameters:");
  1904. }
  1905. for (uint8_t i = 0; i < COUNT(lcd_preheat_hotend_temp); i++) {
  1906. CONFIG_ECHO_START;
  1907. SERIAL_ECHOPAIR_P(port, " M145 S", (int)i);
  1908. SERIAL_ECHOPAIR_P(port, " H", TEMP_UNIT(lcd_preheat_hotend_temp[i]));
  1909. SERIAL_ECHOPAIR_P(port, " B", TEMP_UNIT(lcd_preheat_bed_temp[i]));
  1910. SERIAL_ECHOLNPAIR_P(port, " F", lcd_preheat_fan_speed[i]);
  1911. }
  1912. #endif // ULTIPANEL
  1913. #if HAS_PID_HEATING
  1914. if (!forReplay) {
  1915. CONFIG_ECHO_START;
  1916. SERIAL_ECHOLNPGM_P(port, "PID settings:");
  1917. }
  1918. #if ENABLED(PIDTEMP)
  1919. #if HOTENDS > 1
  1920. if (forReplay) {
  1921. HOTEND_LOOP() {
  1922. CONFIG_ECHO_START;
  1923. SERIAL_ECHOPAIR_P(port, " M301 E", e);
  1924. SERIAL_ECHOPAIR_P(port, " P", PID_PARAM(Kp, e));
  1925. SERIAL_ECHOPAIR_P(port, " I", unscalePID_i(PID_PARAM(Ki, e)));
  1926. SERIAL_ECHOPAIR_P(port, " D", unscalePID_d(PID_PARAM(Kd, e)));
  1927. #if ENABLED(PID_EXTRUSION_SCALING)
  1928. SERIAL_ECHOPAIR_P(port, " C", PID_PARAM(Kc, e));
  1929. if (e == 0) SERIAL_ECHOPAIR_P(port, " L", lpq_len);
  1930. #endif
  1931. SERIAL_EOL_P(port);
  1932. }
  1933. }
  1934. else
  1935. #endif // HOTENDS > 1
  1936. // !forReplay || HOTENDS == 1
  1937. {
  1938. CONFIG_ECHO_START;
  1939. SERIAL_ECHOPAIR_P(port, " M301 P", PID_PARAM(Kp, 0)); // for compatibility with hosts, only echo values for E0
  1940. SERIAL_ECHOPAIR_P(port, " I", unscalePID_i(PID_PARAM(Ki, 0)));
  1941. SERIAL_ECHOPAIR_P(port, " D", unscalePID_d(PID_PARAM(Kd, 0)));
  1942. #if ENABLED(PID_EXTRUSION_SCALING)
  1943. SERIAL_ECHOPAIR_P(port, " C", PID_PARAM(Kc, 0));
  1944. SERIAL_ECHOPAIR_P(port, " L", lpq_len);
  1945. #endif
  1946. SERIAL_EOL_P(port);
  1947. }
  1948. #endif // PIDTEMP
  1949. #if ENABLED(PIDTEMPBED)
  1950. CONFIG_ECHO_START;
  1951. SERIAL_ECHOPAIR_P(port, " M304 P", thermalManager.bedKp);
  1952. SERIAL_ECHOPAIR_P(port, " I", unscalePID_i(thermalManager.bedKi));
  1953. SERIAL_ECHOPAIR_P(port, " D", unscalePID_d(thermalManager.bedKd));
  1954. SERIAL_EOL_P(port);
  1955. #endif
  1956. #endif // PIDTEMP || PIDTEMPBED
  1957. #if HAS_LCD_CONTRAST
  1958. if (!forReplay) {
  1959. CONFIG_ECHO_START;
  1960. SERIAL_ECHOLNPGM_P(port, "LCD Contrast:");
  1961. }
  1962. CONFIG_ECHO_START;
  1963. SERIAL_ECHOLNPAIR_P(port, " M250 C", lcd_contrast);
  1964. #endif
  1965. #if ENABLED(FWRETRACT)
  1966. if (!forReplay) {
  1967. CONFIG_ECHO_START;
  1968. SERIAL_ECHOLNPGM_P(port, "Retract: S<length> F<units/m> Z<lift>");
  1969. }
  1970. CONFIG_ECHO_START;
  1971. SERIAL_ECHOPAIR_P(port, " M207 S", LINEAR_UNIT(fwretract.retract_length));
  1972. SERIAL_ECHOPAIR_P(port, " W", LINEAR_UNIT(fwretract.swap_retract_length));
  1973. SERIAL_ECHOPAIR_P(port, " F", MMS_TO_MMM(LINEAR_UNIT(fwretract.retract_feedrate_mm_s)));
  1974. SERIAL_ECHOLNPAIR_P(port, " Z", LINEAR_UNIT(fwretract.retract_zlift));
  1975. if (!forReplay) {
  1976. CONFIG_ECHO_START;
  1977. SERIAL_ECHOLNPGM_P(port, "Recover: S<length> F<units/m>");
  1978. }
  1979. CONFIG_ECHO_START;
  1980. SERIAL_ECHOPAIR_P(port, " M208 S", LINEAR_UNIT(fwretract.retract_recover_length));
  1981. SERIAL_ECHOPAIR_P(port, " W", LINEAR_UNIT(fwretract.swap_retract_recover_length));
  1982. SERIAL_ECHOLNPAIR_P(port, " F", MMS_TO_MMM(LINEAR_UNIT(fwretract.retract_recover_feedrate_mm_s)));
  1983. if (!forReplay) {
  1984. CONFIG_ECHO_START;
  1985. SERIAL_ECHOLNPGM_P(port, "Auto-Retract: S=0 to disable, 1 to interpret E-only moves as retract/recover");
  1986. }
  1987. CONFIG_ECHO_START;
  1988. SERIAL_ECHOLNPAIR_P(port, " M209 S", fwretract.autoretract_enabled ? 1 : 0);
  1989. #endif // FWRETRACT
  1990. /**
  1991. * Probe Offset
  1992. */
  1993. #if HAS_BED_PROBE
  1994. if (!forReplay) {
  1995. CONFIG_ECHO_START;
  1996. SERIAL_ECHOLNPGM_P(port, "Z-Probe Offset (mm):");
  1997. }
  1998. CONFIG_ECHO_START;
  1999. SERIAL_ECHOLNPAIR_P(port, " M851 Z", LINEAR_UNIT(zprobe_zoffset));
  2000. #endif
  2001. /**
  2002. * Bed Skew Correction
  2003. */
  2004. #if ENABLED(SKEW_CORRECTION_GCODE)
  2005. if (!forReplay) {
  2006. CONFIG_ECHO_START;
  2007. SERIAL_ECHOLNPGM_P(port, "Skew Factor: ");
  2008. }
  2009. CONFIG_ECHO_START;
  2010. #if ENABLED(SKEW_CORRECTION_FOR_Z)
  2011. SERIAL_ECHOPGM_P(port, " M852 I");
  2012. SERIAL_ECHO_F_P(port, LINEAR_UNIT(planner.xy_skew_factor), 6);
  2013. SERIAL_ECHOPGM_P(port, " J");
  2014. SERIAL_ECHO_F_P(port, LINEAR_UNIT(planner.xz_skew_factor), 6);
  2015. SERIAL_ECHOPGM_P(port, " K");
  2016. SERIAL_ECHO_F_P(port, LINEAR_UNIT(planner.yz_skew_factor), 6);
  2017. SERIAL_EOL_P(port);
  2018. #else
  2019. SERIAL_ECHOPGM_P(port, " M852 S");
  2020. SERIAL_ECHO_F_P(port, LINEAR_UNIT(planner.xy_skew_factor), 6);
  2021. SERIAL_EOL_P(port);
  2022. #endif
  2023. #endif
  2024. #if HAS_TRINAMIC
  2025. /**
  2026. * TMC2130 / TMC2208 / TRAMS stepper driver current
  2027. */
  2028. if (!forReplay) {
  2029. CONFIG_ECHO_START;
  2030. SERIAL_ECHOLNPGM_P(port, "Stepper driver current:");
  2031. }
  2032. CONFIG_ECHO_START;
  2033. #if X_IS_TRINAMIC
  2034. say_M906(PORTVAR_SOLO);
  2035. SERIAL_ECHOLNPAIR_P(port, "X", stepperX.getCurrent());
  2036. #endif
  2037. #if X2_IS_TRINAMIC
  2038. say_M906(PORTVAR_SOLO);
  2039. SERIAL_ECHOLNPAIR_P(port, "I1 X", stepperX2.getCurrent());
  2040. #endif
  2041. #if Y_IS_TRINAMIC
  2042. say_M906(PORTVAR_SOLO);
  2043. SERIAL_ECHOLNPAIR_P(port, "Y", stepperY.getCurrent());
  2044. #endif
  2045. #if Y2_IS_TRINAMIC
  2046. say_M906(PORTVAR_SOLO);
  2047. SERIAL_ECHOLNPAIR_P(port, "I1 Y", stepperY2.getCurrent());
  2048. #endif
  2049. #if Z_IS_TRINAMIC
  2050. say_M906(PORTVAR_SOLO);
  2051. SERIAL_ECHOLNPAIR_P(port, "Z", stepperZ.getCurrent());
  2052. #endif
  2053. #if Z2_IS_TRINAMIC
  2054. say_M906(PORTVAR_SOLO);
  2055. SERIAL_ECHOLNPAIR_P(port, "I1 Z", stepperZ2.getCurrent());
  2056. #endif
  2057. #if E0_IS_TRINAMIC
  2058. say_M906(PORTVAR_SOLO);
  2059. SERIAL_ECHOLNPAIR_P(port, "T0 E", stepperE0.getCurrent());
  2060. #endif
  2061. #if E_STEPPERS > 1 && E1_IS_TRINAMIC
  2062. say_M906(PORTVAR_SOLO);
  2063. SERIAL_ECHOLNPAIR_P(port, "T1 E", stepperE1.getCurrent());
  2064. #endif
  2065. #if E_STEPPERS > 2 && E2_IS_TRINAMIC
  2066. say_M906(PORTVAR_SOLO);
  2067. SERIAL_ECHOLNPAIR_P(port, "T2 E", stepperE2.getCurrent());
  2068. #endif
  2069. #if E_STEPPERS > 3 && E3_IS_TRINAMIC
  2070. say_M906(PORTVAR_SOLO);
  2071. SERIAL_ECHOLNPAIR_P(port, "T3 E", stepperE3.getCurrent());
  2072. #endif
  2073. #if E_STEPPERS > 4 && E4_IS_TRINAMIC
  2074. say_M906(PORTVAR_SOLO);
  2075. SERIAL_ECHOLNPAIR_P(port, "T4 E", stepperE4.getCurrent());
  2076. #endif
  2077. SERIAL_EOL_P(port);
  2078. /**
  2079. * TMC2130 / TMC2208 / TRAMS Hybrid Threshold
  2080. */
  2081. #if ENABLED(HYBRID_THRESHOLD)
  2082. if (!forReplay) {
  2083. CONFIG_ECHO_START;
  2084. SERIAL_ECHOLNPGM_P(port, "Hybrid Threshold:");
  2085. }
  2086. CONFIG_ECHO_START;
  2087. #if X_IS_TRINAMIC
  2088. say_M913(PORTVAR_SOLO);
  2089. SERIAL_ECHOLNPAIR_P(port, "X", TMC_GET_PWMTHRS(X, X));
  2090. #endif
  2091. #if X2_IS_TRINAMIC
  2092. say_M913(PORTVAR_SOLO);
  2093. SERIAL_ECHOLNPAIR_P(port, "I1 X", TMC_GET_PWMTHRS(X, X2));
  2094. #endif
  2095. #if Y_IS_TRINAMIC
  2096. say_M913(PORTVAR_SOLO);
  2097. SERIAL_ECHOLNPAIR_P(port, "Y", TMC_GET_PWMTHRS(Y, Y));
  2098. #endif
  2099. #if Y2_IS_TRINAMIC
  2100. say_M913(PORTVAR_SOLO);
  2101. SERIAL_ECHOLNPAIR_P(port, "I1 Y", TMC_GET_PWMTHRS(Y, Y2));
  2102. #endif
  2103. #if Z_IS_TRINAMIC
  2104. say_M913(PORTVAR_SOLO);
  2105. SERIAL_ECHOLNPAIR_P(port, "Z", TMC_GET_PWMTHRS(Z, Z));
  2106. #endif
  2107. #if Z2_IS_TRINAMIC
  2108. say_M913(PORTVAR_SOLO);
  2109. SERIAL_ECHOLNPAIR_P(port, "I1 Z", TMC_GET_PWMTHRS(Z, Z2));
  2110. #endif
  2111. #if E0_IS_TRINAMIC
  2112. say_M913(PORTVAR_SOLO);
  2113. SERIAL_ECHOLNPAIR_P(port, "T0 E", TMC_GET_PWMTHRS(E, E0));
  2114. #endif
  2115. #if E_STEPPERS > 1 && E1_IS_TRINAMIC
  2116. say_M913(PORTVAR_SOLO);
  2117. SERIAL_ECHOLNPAIR_P(port, "T1 E", TMC_GET_PWMTHRS(E, E1));
  2118. #endif
  2119. #if E_STEPPERS > 2 && E2_IS_TRINAMIC
  2120. say_M913(PORTVAR_SOLO);
  2121. SERIAL_ECHOLNPAIR_P(port, "T2 E", TMC_GET_PWMTHRS(E, E2));
  2122. #endif
  2123. #if E_STEPPERS > 3 && E3_IS_TRINAMIC
  2124. say_M913(PORTVAR_SOLO);
  2125. SERIAL_ECHOLNPAIR_P(port, "T3 E", TMC_GET_PWMTHRS(E, E3));
  2126. #endif
  2127. #if E_STEPPERS > 4 && E4_IS_TRINAMIC
  2128. say_M913(PORTVAR_SOLO);
  2129. SERIAL_ECHOLNPAIR_P(port, "T4 E", TMC_GET_PWMTHRS(E, E4));
  2130. #endif
  2131. SERIAL_EOL_P(port);
  2132. #endif // HYBRID_THRESHOLD
  2133. /**
  2134. * TMC2130 Sensorless homing thresholds
  2135. */
  2136. #if ENABLED(SENSORLESS_HOMING)
  2137. if (!forReplay) {
  2138. CONFIG_ECHO_START;
  2139. SERIAL_ECHOLNPGM_P(port, "Sensorless homing threshold:");
  2140. }
  2141. CONFIG_ECHO_START;
  2142. #ifdef X_HOMING_SENSITIVITY
  2143. #if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS)
  2144. say_M914(PORTVAR_SOLO);
  2145. SERIAL_ECHOLNPAIR_P(port, "X", stepperX.sgt());
  2146. #endif
  2147. #if ENABLED(X2_IS_TMC2130)
  2148. say_M914(PORTVAR_SOLO);
  2149. SERIAL_ECHOLNPAIR_P(port, "I1 X", stepperX2.sgt());
  2150. #endif
  2151. #endif
  2152. #ifdef Y_HOMING_SENSITIVITY
  2153. #if ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS)
  2154. say_M914(PORTVAR_SOLO);
  2155. SERIAL_ECHOLNPAIR_P(port, "Y", stepperY.sgt());
  2156. #endif
  2157. #if ENABLED(Y2_IS_TMC2130)
  2158. say_M914(PORTVAR_SOLO);
  2159. SERIAL_ECHOLNPAIR_P(port, "I1 Y", stepperY2.sgt());
  2160. #endif
  2161. #endif
  2162. #ifdef Z_HOMING_SENSITIVITY
  2163. #if ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS)
  2164. say_M914(PORTVAR_SOLO);
  2165. SERIAL_ECHOLNPAIR_P(port, "Z", stepperZ.sgt());
  2166. #endif
  2167. #if ENABLED(Z2_IS_TMC2130)
  2168. say_M914(PORTVAR_SOLO);
  2169. SERIAL_ECHOLNPAIR_P(port, "I1 Z", stepperZ2.sgt());
  2170. #endif
  2171. #endif
  2172. SERIAL_EOL_P(port);
  2173. #endif
  2174. #endif // HAS_TRINAMIC
  2175. /**
  2176. * Linear Advance
  2177. */
  2178. #if ENABLED(LIN_ADVANCE)
  2179. if (!forReplay) {
  2180. CONFIG_ECHO_START;
  2181. SERIAL_ECHOLNPGM_P(port, "Linear Advance:");
  2182. }
  2183. CONFIG_ECHO_START;
  2184. SERIAL_ECHOLNPAIR_P(port, " M900 K", planner.extruder_advance_K);
  2185. #endif
  2186. #if HAS_MOTOR_CURRENT_PWM
  2187. CONFIG_ECHO_START;
  2188. if (!forReplay) {
  2189. SERIAL_ECHOLNPGM_P(port, "Stepper motor currents:");
  2190. CONFIG_ECHO_START;
  2191. }
  2192. SERIAL_ECHOPAIR_P(port, " M907 X", stepper.motor_current_setting[0]);
  2193. SERIAL_ECHOPAIR_P(port, " Z", stepper.motor_current_setting[1]);
  2194. SERIAL_ECHOPAIR_P(port, " E", stepper.motor_current_setting[2]);
  2195. SERIAL_EOL_P(port);
  2196. #endif
  2197. /**
  2198. * Advanced Pause filament load & unload lengths
  2199. */
  2200. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  2201. if (!forReplay) {
  2202. CONFIG_ECHO_START;
  2203. SERIAL_ECHOLNPGM_P(port, "Filament load/unload lengths:");
  2204. }
  2205. CONFIG_ECHO_START;
  2206. #if EXTRUDERS == 1
  2207. say_M603(PORTVAR_SOLO);
  2208. SERIAL_ECHOPAIR_P(port, "L", LINEAR_UNIT(filament_change_load_length[0]));
  2209. SERIAL_ECHOLNPAIR_P(port, " U", LINEAR_UNIT(filament_change_unload_length[0]));
  2210. #else
  2211. say_M603(PORTVAR_SOLO);
  2212. SERIAL_ECHOPAIR_P(port, "T0 L", LINEAR_UNIT(filament_change_load_length[0]));
  2213. SERIAL_ECHOLNPAIR_P(port, " U", LINEAR_UNIT(filament_change_unload_length[0]));
  2214. CONFIG_ECHO_START;
  2215. say_M603(PORTVAR_SOLO);
  2216. SERIAL_ECHOPAIR_P(port, "T1 L", LINEAR_UNIT(filament_change_load_length[1]));
  2217. SERIAL_ECHOLNPAIR_P(port, " U", LINEAR_UNIT(filament_change_unload_length[1]));
  2218. #if EXTRUDERS > 2
  2219. CONFIG_ECHO_START;
  2220. say_M603(PORTVAR_SOLO);
  2221. SERIAL_ECHOPAIR_P(port, "T2 L", LINEAR_UNIT(filament_change_load_length[2]));
  2222. SERIAL_ECHOLNPAIR_P(port, " U", LINEAR_UNIT(filament_change_unload_length[2]));
  2223. #if EXTRUDERS > 3
  2224. CONFIG_ECHO_START;
  2225. say_M603(PORTVAR_SOLO);
  2226. SERIAL_ECHOPAIR_P(port, "T3 L", LINEAR_UNIT(filament_change_load_length[3]));
  2227. SERIAL_ECHOLNPAIR_P(port, " U", LINEAR_UNIT(filament_change_unload_length[3]));
  2228. #if EXTRUDERS > 4
  2229. CONFIG_ECHO_START;
  2230. say_M603(PORTVAR_SOLO);
  2231. SERIAL_ECHOPAIR_P(port, "T4 L", LINEAR_UNIT(filament_change_load_length[4]));
  2232. SERIAL_ECHOLNPAIR_P(port, " U", LINEAR_UNIT(filament_change_unload_length[4]));
  2233. #endif // EXTRUDERS > 4
  2234. #endif // EXTRUDERS > 3
  2235. #endif // EXTRUDERS > 2
  2236. #endif // EXTRUDERS == 1
  2237. #endif // ADVANCED_PAUSE_FEATURE
  2238. }
  2239. #endif // !DISABLE_M503