My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

configuration_store.cpp 82KB

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