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.

M500-M504.cpp 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. /**
  27. * M500: Store settings in EEPROM
  28. */
  29. void GcodeSuite::M500() {
  30. (void)settings.save();
  31. }
  32. /**
  33. * M501: Read settings from EEPROM
  34. */
  35. void GcodeSuite::M501() {
  36. (void)settings.load();
  37. }
  38. /**
  39. * M502: Revert to default settings
  40. */
  41. void GcodeSuite::M502() {
  42. (void)settings.reset();
  43. }
  44. #if DISABLED(DISABLE_M503)
  45. /**
  46. * M503: print settings currently in memory
  47. */
  48. void GcodeSuite::M503() {
  49. (void)settings.report(!parser.boolval('S', true));
  50. }
  51. #endif // !DISABLE_M503
  52. #if ENABLED(EEPROM_SETTINGS)
  53. #if ENABLED(MARLIN_DEV_MODE)
  54. #include "../../libs/hex_print.h"
  55. #endif
  56. /**
  57. * M504: Validate EEPROM Contents
  58. */
  59. void GcodeSuite::M504() {
  60. #if ENABLED(MARLIN_DEV_MODE)
  61. const bool dowrite = parser.seenval('W');
  62. if (dowrite || parser.seenval('R')) {
  63. uint8_t val = 0;
  64. int addr = parser.value_ushort();
  65. if (dowrite) {
  66. val = parser.byteval('V');
  67. persistentStore.write_data(addr, &val);
  68. SERIAL_ECHOLNPGM("Wrote address ", addr, " with ", val);
  69. }
  70. else {
  71. if (parser.seenval('T')) {
  72. const int endaddr = parser.value_ushort();
  73. while (addr <= endaddr) {
  74. persistentStore.read_data(addr, &val);
  75. SERIAL_ECHOLNPGM("0x", hex_word(addr), ":", hex_byte(val));
  76. addr++;
  77. safe_delay(10);
  78. }
  79. SERIAL_EOL();
  80. }
  81. else {
  82. persistentStore.read_data(addr, &val);
  83. SERIAL_ECHOLNPGM("Read address ", addr, " and got ", val);
  84. }
  85. }
  86. return;
  87. }
  88. #endif
  89. if (settings.validate())
  90. SERIAL_ECHO_MSG("EEPROM OK");
  91. }
  92. #endif