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.

spindle_laser.h 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. * feature/spindle_laser.h
  25. * Support for Laser Power or Spindle Power & Direction
  26. */
  27. #include "../inc/MarlinConfig.h"
  28. #if ENABLED(SPINDLE_FEATURE)
  29. #define _MSG_CUTTER(M) MSG_SPINDLE_##M
  30. #else
  31. #define _MSG_CUTTER(M) MSG_LASER_##M
  32. #endif
  33. #define MSG_CUTTER(M) _MSG_CUTTER(M)
  34. #if SPEED_POWER_MAX > 255
  35. #define cutter_power_t uint16_t
  36. #define CUTTER_MENU_TYPE uint16_5
  37. #else
  38. #define cutter_power_t uint8_t
  39. #define CUTTER_MENU_TYPE uint8
  40. #endif
  41. class SpindleLaser {
  42. public:
  43. static cutter_power_t power;
  44. static void init();
  45. static inline bool enabled() { return !!power; }
  46. static inline void set_power(const uint8_t pwr) { power = pwr; update_output(); }
  47. static inline void set_enabled(const bool enable) { set_power(enable ? 255 : 0); }
  48. //static bool active() { return READ(SPINDLE_LASER_ENA_PIN) == SPINDLE_LASER_ACTIVE_HIGH; }
  49. #if ENABLED(SPINDLE_LASER_PWM)
  50. static void update_output();
  51. static void set_ocr(const uint8_t ocr);
  52. static inline void set_ocr_power(const uint8_t pwr) { power = pwr; set_ocr(pwr); }
  53. #else
  54. static inline void update_output() { }
  55. #endif
  56. // Wait for spindle to spin up or spin down
  57. static inline void power_delay(const bool on) { safe_delay(on ? SPINDLE_LASER_POWERUP_DELAY : SPINDLE_LASER_POWERDOWN_DELAY); }
  58. #if ENABLED(SPINDLE_CHANGE_DIR)
  59. static void set_direction(const bool reverse);
  60. #else
  61. static inline void set_direction(const bool reverse) { UNUSED(reverse); }
  62. #endif
  63. static inline void disable() { set_enabled(false); }
  64. static inline void enable_forward() { set_direction(false); set_enabled(true); }
  65. static inline void enable_reverse() { set_direction(true); set_enabled(true); }
  66. };
  67. extern SpindleLaser cutter;