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.

settings.h 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. #pragma once
  23. //
  24. // settings.cpp - Settings and EEPROM storage
  25. //
  26. #include "../inc/MarlinConfig.h"
  27. #if ENABLED(EEPROM_SETTINGS)
  28. #include "../HAL/shared/eeprom_api.h"
  29. #endif
  30. class MarlinSettings {
  31. public:
  32. static uint16_t datasize();
  33. static void reset();
  34. static bool save(); // Return 'true' if data was saved
  35. FORCE_INLINE static bool init_eeprom() {
  36. reset();
  37. #if ENABLED(EEPROM_SETTINGS)
  38. const bool success = save();
  39. if (TERN0(EEPROM_CHITCHAT, success)) report();
  40. return success;
  41. #else
  42. return true;
  43. #endif
  44. }
  45. #if ENABLED(SD_FIRMWARE_UPDATE)
  46. static bool sd_update_status(); // True if the SD-Firmware-Update EEPROM flag is set
  47. static bool set_sd_update_status(const bool enable); // Return 'true' after EEPROM is set (-> always true)
  48. #endif
  49. #if ENABLED(EEPROM_SETTINGS)
  50. static bool load(); // Return 'true' if data was loaded ok
  51. static bool validate(); // Return 'true' if EEPROM data is ok
  52. static inline void first_load() {
  53. static bool loaded = false;
  54. if (!loaded && load()) loaded = true;
  55. }
  56. #if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system
  57. // That can store is enabled
  58. static uint16_t meshes_start_index();
  59. FORCE_INLINE static uint16_t meshes_end_index() { return meshes_end; }
  60. static uint16_t calc_num_meshes();
  61. static int mesh_slot_offset(const int8_t slot);
  62. static void store_mesh(const int8_t slot);
  63. static void load_mesh(const int8_t slot, void * const into=nullptr);
  64. //static void delete_mesh(); // necessary if we have a MAT
  65. //static void defrag_meshes(); // "
  66. #endif
  67. #else
  68. FORCE_INLINE
  69. static bool load() { reset(); report(); return true; }
  70. FORCE_INLINE
  71. static void first_load() { (void)load(); }
  72. #endif
  73. #if DISABLED(DISABLE_M503)
  74. static void report(const bool forReplay=false);
  75. #else
  76. FORCE_INLINE
  77. static void report(const bool=false) {}
  78. #endif
  79. private:
  80. static void postprocess();
  81. #if ENABLED(EEPROM_SETTINGS)
  82. static bool eeprom_error, validating;
  83. #if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system
  84. // That can store is enabled
  85. static const uint16_t meshes_end; // 128 is a placeholder for the size of the MAT; the MAT will always
  86. // live at the very end of the eeprom
  87. #endif
  88. static bool _load();
  89. static bool size_error(const uint16_t size);
  90. #endif
  91. };
  92. extern MarlinSettings settings;