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.

fwretract.h 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2019 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. #pragma once
  23. /**
  24. * fwretract.h - Define firmware-based retraction interface
  25. */
  26. #include "../inc/MarlinConfigPre.h"
  27. #pragma pack(push, 1) // No padding between fields
  28. typedef struct {
  29. float retract_length, // M207 S - G10 Retract length
  30. retract_feedrate_mm_s, // M207 F - G10 Retract feedrate
  31. retract_zraise, // M207 Z - G10 Retract hop size
  32. retract_recover_extra, // M208 S - G11 Recover length
  33. retract_recover_feedrate_mm_s, // M208 F - G11 Recover feedrate
  34. swap_retract_length, // M207 W - G10 Swap Retract length
  35. swap_retract_recover_extra, // M208 W - G11 Swap Recover length
  36. swap_retract_recover_feedrate_mm_s; // M208 R - G11 Swap Recover feedrate
  37. } fwretract_settings_t;
  38. #pragma pack(pop)
  39. #if ENABLED(FWRETRACT)
  40. class FWRetract {
  41. private:
  42. #if EXTRUDERS > 1
  43. static bool retracted_swap[EXTRUDERS]; // Which extruders are swap-retracted
  44. #endif
  45. public:
  46. static fwretract_settings_t settings;
  47. #if ENABLED(FWRETRACT_AUTORETRACT)
  48. static bool autoretract_enabled; // M209 S - Autoretract switch
  49. #else
  50. static constexpr bool autoretract_enabled = false;
  51. #endif
  52. static bool retracted[EXTRUDERS]; // Which extruders are currently retracted
  53. static float current_retract[EXTRUDERS], // Retract value used by planner
  54. current_hop; // Hop value used by planner
  55. FWRetract() { reset(); }
  56. static void reset();
  57. static void refresh_autoretract() {
  58. LOOP_L_N(i, EXTRUDERS) retracted[i] = false;
  59. }
  60. static void enable_autoretract(const bool enable) {
  61. #if ENABLED(FWRETRACT_AUTORETRACT)
  62. autoretract_enabled = enable;
  63. refresh_autoretract();
  64. #endif
  65. }
  66. static void retract(const bool retracting
  67. #if EXTRUDERS > 1
  68. , bool swapping = false
  69. #endif
  70. );
  71. };
  72. extern FWRetract fwretract;
  73. #endif // FWRETRACT