Spindle/Laser power in planner blocks (#14437)

This commit is contained in:
Scott Lahteine
2019-10-15 16:10:20 -05:00
committed by GitHub
parent 53abfdc2c3
commit b7b303f4bf
9 changed files with 106 additions and 38 deletions

View File

@@ -36,10 +36,10 @@
#define MSG_CUTTER(M) _MSG_CUTTER(M)
#if SPEED_POWER_MAX > 255
#define cutter_power_t uint16_t
typedef uint16_t cutter_power_t;
#define CUTTER_MENU_TYPE uint16_5
#else
#define cutter_power_t uint8_t
typedef uint8_t cutter_power_t;
#define CUTTER_MENU_TYPE uint8
#endif
@@ -51,9 +51,17 @@ public:
static inline bool enabled() { return !!power; }
static inline void set_power(const uint8_t pwr) { power = pwr; update_output(); }
static inline void set_power(const cutter_power_t pwr) { power = pwr; }
static inline void set_enabled(const bool enable) { set_power(enable ? 255 : 0); }
static inline void refresh() { apply_power(power); }
static inline void set_enabled(const bool enable) {
const bool was = enabled();
set_power(enable ? 255 : 0);
if (was != enable) power_delay();
}
static void apply_power(const cutter_power_t inpow);
//static bool active() { return READ(SPINDLE_LASER_ENA_PIN) == SPINDLE_LASER_ACTIVE_HIGH; }
@@ -61,11 +69,15 @@ public:
#if ENABLED(SPINDLE_LASER_PWM)
static void set_ocr(const uint8_t ocr);
static inline void set_ocr_power(const uint8_t pwr) { power = pwr; set_ocr(pwr); }
static inline void set_ocr_power(const cutter_power_t pwr) { power = pwr; set_ocr(pwr); }
#endif
// Wait for spindle to spin up or spin down
static inline void power_delay(const bool on) { safe_delay(on ? SPINDLE_LASER_POWERUP_DELAY : SPINDLE_LASER_POWERDOWN_DELAY); }
static inline void power_delay() {
#if SPINDLE_LASER_POWERUP_DELAY || SPINDLE_LASER_POWERDOWN_DELAY
safe_delay(enabled() ? SPINDLE_LASER_POWERUP_DELAY : SPINDLE_LASER_POWERDOWN_DELAY);
#endif
}
#if ENABLED(SPINDLE_CHANGE_DIR)
static void set_direction(const bool reverse);