My Marlin configs for Fabrikator Mini and CTC i3 Pro B
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

menu_spindle_laser.cpp 3.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. //
  23. // Spindle / Laser Menu
  24. //
  25. #include "../../inc/MarlinConfig.h"
  26. #if HAS_MARLINUI_MENU && HAS_CUTTER
  27. #include "menu_item.h"
  28. #include "../../feature/spindle_laser.h"
  29. void menu_spindle_laser() {
  30. bool is_enabled = cutter.enabled();
  31. #if ENABLED(SPINDLE_CHANGE_DIR)
  32. bool is_rev = cutter.is_reverse();
  33. #endif
  34. START_MENU();
  35. BACK_ITEM(MSG_MAIN);
  36. #if ENABLED(SPINDLE_LASER_USE_PWM)
  37. // Change the cutter's "current power" value without turning the cutter on or off
  38. // Power is displayed and set in units and range according to CUTTER_POWER_UNIT
  39. EDIT_ITEM_FAST(CUTTER_MENU_POWER_TYPE, MSG_CUTTER(POWER), &cutter.menuPower,
  40. cutter.mpower_min(), cutter.mpower_max(), cutter.update_from_mpower);
  41. #endif
  42. editable.state = is_enabled;
  43. EDIT_ITEM(bool, MSG_CUTTER(TOGGLE), &is_enabled, []{
  44. #if ENABLED(SPINDLE_FEATURE)
  45. if (editable.state) cutter.disable(); else cutter.enable_same_dir();
  46. #else
  47. cutter.laser_menu_toggle(!editable.state);
  48. #endif
  49. });
  50. #if ENABLED(AIR_EVACUATION)
  51. bool evac_state = cutter.air_evac_state();
  52. EDIT_ITEM(bool, MSG_CUTTER(EVAC_TOGGLE), &evac_state, cutter.air_evac_toggle);
  53. #endif
  54. #if ENABLED(AIR_ASSIST)
  55. bool air_assist_state = cutter.air_assist_state();
  56. EDIT_ITEM(bool, MSG_CUTTER(ASSIST_TOGGLE), &air_assist_state, cutter.air_assist_toggle);
  57. #endif
  58. #if ENABLED(SPINDLE_CHANGE_DIR)
  59. if (!is_enabled) {
  60. editable.state = is_rev;
  61. ACTION_ITEM_F(is_rev ? GET_TEXT_F(MSG_CUTTER(REVERSE)) : GET_TEXT_F(MSG_CUTTER(FORWARD)), []{ cutter.set_reverse(!editable.state); });
  62. }
  63. #endif
  64. #if ENABLED(LASER_FEATURE)
  65. // Setup and fire a test pulse using the current PWM power level for for a duration of test_pulse_min to test_pulse_max ms.
  66. EDIT_ITEM_FAST(CUTTER_MENU_PULSE_TYPE, MSG_LASER_PULSE_MS, &cutter.testPulse, LASER_TEST_PULSE_MIN, LASER_TEST_PULSE_MAX);
  67. ACTION_ITEM(MSG_LASER_FIRE_PULSE, cutter.test_fire_pulse);
  68. #if ENABLED(HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY
  69. EDIT_ITEM_FAST(CUTTER_MENU_FREQUENCY_TYPE, MSG_CUTTER_FREQUENCY, &cutter.frequency, 2000, 80000, cutter.refresh_frequency);
  70. #endif
  71. #endif
  72. END_MENU();
  73. }
  74. #endif // HAS_MARLINUI_MENU && HAS_CUTTER