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

M500-M504.cpp 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 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 <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "../gcode.h"
  23. #include "../../module/settings.h"
  24. #include "../../core/serial.h"
  25. #include "../../inc/MarlinConfig.h"
  26. #if ENABLED(CONFIGURATION_EMBEDDING)
  27. #include "../../sd/SdBaseFile.h"
  28. #include "../../mczip.h"
  29. #endif
  30. /**
  31. * M500: Store settings in EEPROM
  32. */
  33. void GcodeSuite::M500() {
  34. (void)settings.save();
  35. }
  36. /**
  37. * M501: Read settings from EEPROM
  38. */
  39. void GcodeSuite::M501() {
  40. (void)settings.load();
  41. }
  42. /**
  43. * M502: Revert to default settings
  44. */
  45. void GcodeSuite::M502() {
  46. (void)settings.reset();
  47. }
  48. #if DISABLED(DISABLE_M503)
  49. /**
  50. * M503: print settings currently in memory
  51. *
  52. * S<bool> : Include / exclude header comments in the output. (Default: S1)
  53. *
  54. * With CONFIGURATION_EMBEDDING:
  55. * C<flag> : Save the full Marlin configuration to SD Card as "mc.zip"
  56. */
  57. void GcodeSuite::M503() {
  58. (void)settings.report(!parser.boolval('S', true));
  59. #if ENABLED(CONFIGURATION_EMBEDDING)
  60. if (parser.seen_test('C')) {
  61. SdBaseFile file;
  62. const uint16_t size = sizeof(mc_zip);
  63. // Need to create the config size on the SD card
  64. if (file.open("mc.zip", O_WRITE|O_CREAT) && file.write(pgm_read_ptr(mc_zip), size) != -1 && file.close())
  65. SERIAL_ECHO_MSG("Configuration saved as 'mc.zip'");
  66. }
  67. #endif
  68. }
  69. #endif // !DISABLE_M503
  70. #if ENABLED(EEPROM_SETTINGS)
  71. #if ENABLED(MARLIN_DEV_MODE)
  72. #include "../../libs/hex_print.h"
  73. #endif
  74. /**
  75. * M504: Validate EEPROM Contents
  76. */
  77. void GcodeSuite::M504() {
  78. #if ENABLED(MARLIN_DEV_MODE)
  79. const bool dowrite = parser.seenval('W');
  80. if (dowrite || parser.seenval('R')) {
  81. uint8_t val = 0;
  82. int addr = parser.value_ushort();
  83. if (dowrite) {
  84. val = parser.byteval('V');
  85. persistentStore.write_data(addr, &val);
  86. SERIAL_ECHOLNPGM("Wrote address ", addr, " with ", val);
  87. }
  88. else {
  89. if (parser.seenval('T')) {
  90. const int endaddr = parser.value_ushort();
  91. while (addr <= endaddr) {
  92. persistentStore.read_data(addr, &val);
  93. SERIAL_ECHOLNPGM("0x", hex_word(addr), ":", hex_byte(val));
  94. addr++;
  95. safe_delay(10);
  96. }
  97. SERIAL_EOL();
  98. }
  99. else {
  100. persistentStore.read_data(addr, &val);
  101. SERIAL_ECHOLNPGM("Read address ", addr, " and got ", val);
  102. }
  103. }
  104. return;
  105. }
  106. #endif
  107. if (settings.validate())
  108. SERIAL_ECHO_MSG("EEPROM OK");
  109. }
  110. #endif