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.

marlin-6x12-2.bdf 476KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. #include "../../inc/MarlinConfig.h"
  24. #if HAS_FILAMENT_SENSOR
  25. #include "../runout.h"
  26. #endif
  27. #if SERIAL_USB
  28. #define MMU_RX_SIZE 256
  29. #define MMU_TX_SIZE 256
  30. #else
  31. #define MMU_RX_SIZE 16
  32. #define MMU_TX_SIZE 16
  33. #endif
  34. struct E_Step;
  35. class MMU2 {
  36. public:
  37. MMU2();
  38. static void init();
  39. static void reset();
  40. static void mmu_loop();
  41. static void tool_change(const uint8_t index);
  42. static void tool_change(const char* special);
  43. static uint8_t get_current_tool();
  44. static void set_filament_type(const uint8_t index, const uint8_t type);
  45. #if BOTH(HAS_LCD_MENU, MMU2_MENUS)
  46. static bool unload();
  47. static void load_filament(uint8_t);
  48. static void load_all();
  49. static bool load_filament_to_nozzle(const uint8_t index);
  50. static bool eject_filament(const uint8_t index, const bool recover);
  51. #endif
  52. private:
  53. static bool rx_str_P(const char* str);
  54. static void tx_str_P(const char* str);
  55. static void tx_printf_P(const char* format, const int argument);
  56. static void tx_printf_P(const char* format, const int argument1, const int argument2);
  57. static void clear_rx_buffer();
  58. static bool rx_ok();
  59. static bool rx_start();
  60. static void check_version();
  61. static void command(const uint8_t cmd);
  62. static bool get_response();
  63. static void manage_response(const bool move_axes, const bool turn_off_nozzle);
  64. #if BOTH(HAS_LCD_MENU, MMU2_MENUS)
  65. static void load_to_nozzle();
  66. static void filament_ramming();
  67. static void execute_extruder_sequence(const E_Step * sequence, int steps);
  68. #endif
  69. static void filament_runout();
  70. #if ENABLED(PRUSA_MMU2_S_MODE)
  71. static bool mmu2s_triggered;
  72. static void check_filament();
  73. static bool can_load();
  74. static bool load_to_gears();
  75. #else
  76. FORCE_INLINE static bool load_to_gears() { return true; }
  77. #endif
  78. #if ENABLED(MMU_EXTRUDER_SENSOR)
  79. static void mmu_continue_loading();
  80. #endif
  81. static bool enabled, ready, mmu_print_saved;
  82. static uint8_t cmd, cmd_arg, last_cmd, extruder;
  83. static int8_t state;
  84. static volatile int8_t finda;
  85. static volatile bool finda_runout_valid;
  86. static int16_t version, buildnr;
  87. static millis_t prev_request, prev_P0_request;
  88. static char rx_buffer[MMU_RX_SIZE], tx_buffer[MMU_TX_SIZE];
  89. static inline void set_runout_valid(const bool valid) {
  90. finda_runout_valid = valid;
  91. #if HAS_FILAMENT_SENSOR
  92. if (valid) runout.reset();
  93. #endif
  94. }
  95. };
  96. extern MMU2 mmu2;