|
@ -37,7 +37,7 @@ cutter_power_t SpindleLaser::menuPower, // Power s |
|
|
SpindleLaser::unitPower; // LCD status power in PWM, PERCENT, or RPM
|
|
|
SpindleLaser::unitPower; // LCD status power in PWM, PERCENT, or RPM
|
|
|
|
|
|
|
|
|
#if ENABLED(MARLIN_DEV_MODE) |
|
|
#if ENABLED(MARLIN_DEV_MODE) |
|
|
cutter_frequency_t SpindleLaser::frequency; // setting PWM frequency; range: 2K - 50K
|
|
|
cutter_frequency_t SpindleLaser::frequency; // PWM frequency setting; range: 2K - 50K
|
|
|
#endif |
|
|
#endif |
|
|
#define SPINDLE_LASER_PWM_OFF ((SPINDLE_LASER_PWM_INVERT) ? 255 : 0) |
|
|
#define SPINDLE_LASER_PWM_OFF ((SPINDLE_LASER_PWM_INVERT) ? 255 : 0) |
|
|
|
|
|
|
|
@ -45,13 +45,13 @@ cutter_power_t SpindleLaser::menuPower, // Power s |
|
|
// Init the cutter to a safe OFF state
|
|
|
// Init the cutter to a safe OFF state
|
|
|
//
|
|
|
//
|
|
|
void SpindleLaser::init() { |
|
|
void SpindleLaser::init() { |
|
|
OUT_WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_HIGH); // Init spindle to off
|
|
|
OUT_WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE); // Init spindle to off
|
|
|
#if ENABLED(SPINDLE_CHANGE_DIR) |
|
|
#if ENABLED(SPINDLE_CHANGE_DIR) |
|
|
OUT_WRITE(SPINDLE_DIR_PIN, SPINDLE_INVERT_DIR ? 255 : 0); // Init rotation to clockwise (M3)
|
|
|
OUT_WRITE(SPINDLE_DIR_PIN, SPINDLE_INVERT_DIR ? 255 : 0); // Init rotation to clockwise (M3)
|
|
|
#endif |
|
|
#endif |
|
|
#if ENABLED(SPINDLE_LASER_PWM) |
|
|
#if ENABLED(SPINDLE_LASER_PWM) |
|
|
SET_PWM(SPINDLE_LASER_PWM_PIN); |
|
|
SET_PWM(SPINDLE_LASER_PWM_PIN); |
|
|
analogWrite(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_PWM_OFF); // set to lowest speed
|
|
|
analogWrite(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_PWM_OFF); // Set to lowest speed
|
|
|
#endif |
|
|
#endif |
|
|
#if ENABLED(HAL_CAN_SET_PWM_FREQ) && defined(SPINDLE_LASER_FREQUENCY) |
|
|
#if ENABLED(HAL_CAN_SET_PWM_FREQ) && defined(SPINDLE_LASER_FREQUENCY) |
|
|
set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_FREQUENCY); |
|
|
set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_FREQUENCY); |
|
@ -64,14 +64,14 @@ void SpindleLaser::init() { |
|
|
* Set the cutter PWM directly to the given ocr value |
|
|
* Set the cutter PWM directly to the given ocr value |
|
|
*/ |
|
|
*/ |
|
|
void SpindleLaser::set_ocr(const uint8_t ocr) { |
|
|
void SpindleLaser::set_ocr(const uint8_t ocr) { |
|
|
WRITE(SPINDLE_LASER_ENA_PIN, SPINDLE_LASER_ACTIVE_HIGH); // turn spindle on
|
|
|
WRITE(SPINDLE_LASER_ENA_PIN, SPINDLE_LASER_ACTIVE_STATE); // Turn spindle on
|
|
|
analogWrite(pin_t(SPINDLE_LASER_PWM_PIN), ocr ^ SPINDLE_LASER_PWM_OFF); |
|
|
analogWrite(pin_t(SPINDLE_LASER_PWM_PIN), ocr ^ SPINDLE_LASER_PWM_OFF); |
|
|
#if NEEDS_HARDWARE_PWM && SPINDLE_LASER_FREQUENCY |
|
|
#if NEEDS_HARDWARE_PWM && SPINDLE_LASER_FREQUENCY |
|
|
set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), ocr ^ SPINDLE_LASER_PWM_OFF); |
|
|
set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), ocr ^ SPINDLE_LASER_PWM_OFF); |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
|
void SpindleLaser::ocr_off() { |
|
|
void SpindleLaser::ocr_off() { |
|
|
WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_HIGH); // Turn spindle off
|
|
|
WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE); // Turn spindle off
|
|
|
analogWrite(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_PWM_OFF); // Only write low byte
|
|
|
analogWrite(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_PWM_OFF); // Only write low byte
|
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
@ -98,7 +98,7 @@ void SpindleLaser::apply_power(const uint8_t opwr) { |
|
|
isReady = false; |
|
|
isReady = false; |
|
|
} |
|
|
} |
|
|
#else |
|
|
#else |
|
|
WRITE(SPINDLE_LASER_ENA_PIN, enabled() == SPINDLE_LASER_ACTIVE_HIGH); |
|
|
WRITE(SPINDLE_LASER_ENA_PIN, enabled() ? SPINDLE_LASER_ACTIVE_STATE : !SPINDLE_LASER_ACTIVE_STATE); |
|
|
isReady = true; |
|
|
isReady = true; |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
|