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.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. #include "../gcode.h"
  23. #include "../../module/configuration_store.h"
  24. #include "../../core/serial.h"
  25. #include "../../inc/MarlinConfig.h"
  26. #if ENABLED(EXTENSIBLE_UI)
  27. #include "../../lcd/extensible_ui/ui_api.h"
  28. #endif
  29. #if NUM_SERIAL > 1
  30. #include "../../gcode/queue.h"
  31. #endif
  32. #if ADD_PORT_ARG
  33. #define CHAT_PORT command_queue_port[cmd_queue_index_r]
  34. #else
  35. #define CHAT_PORT
  36. #endif
  37. /**
  38. * M500: Store settings in EEPROM
  39. */
  40. void GcodeSuite::M500() {
  41. (void)settings.save(CHAT_PORT);
  42. #if ENABLED(EXTENSIBLE_UI)
  43. UI::onStoreSettings();
  44. #endif
  45. }
  46. /**
  47. * M501: Read settings from EEPROM
  48. */
  49. void GcodeSuite::M501() {
  50. (void)settings.load(
  51. #if ENABLED(EEPROM_SETTINGS)
  52. CHAT_PORT
  53. #endif
  54. );
  55. #if ENABLED(EXTENSIBLE_UI)
  56. UI::onLoadSettings();
  57. #endif
  58. }
  59. /**
  60. * M502: Revert to default settings
  61. */
  62. void GcodeSuite::M502() {
  63. (void)settings.reset(CHAT_PORT);
  64. #if ENABLED(EXTENSIBLE_UI)
  65. UI::onFactoryReset();
  66. #endif
  67. }
  68. #if DISABLED(DISABLE_M503)
  69. /**
  70. * M503: print settings currently in memory
  71. */
  72. void GcodeSuite::M503() {
  73. (void)settings.report(
  74. parser.seen('S') && !parser.value_bool()
  75. #if NUM_SERIAL > 1
  76. , command_queue_port[cmd_queue_index_r]
  77. #endif
  78. );
  79. }
  80. #endif // !DISABLE_M503
  81. #if ENABLED(EEPROM_SETTINGS)
  82. /**
  83. * M504: Validate EEPROM Contents
  84. */
  85. void GcodeSuite::M504() {
  86. if (settings.validate(CHAT_PORT)) {
  87. SERIAL_ECHO_START_P(command_queue_port[cmd_queue_index_r]);
  88. SERIAL_ECHOLNPGM_P(command_queue_port[cmd_queue_index_r], "EEPROM OK");
  89. }
  90. }
  91. #endif