|
@ -52,9 +52,9 @@ cutter_power_t SpindleLaser::menuPower, // Power s |
|
|
#endif |
|
|
#endif |
|
|
#define SPINDLE_LASER_PWM_OFF TERN(SPINDLE_LASER_PWM_INVERT, 255, 0) |
|
|
#define SPINDLE_LASER_PWM_OFF TERN(SPINDLE_LASER_PWM_INVERT, 255, 0) |
|
|
|
|
|
|
|
|
//
|
|
|
/**
|
|
|
// Init the cutter to a safe OFF state
|
|
|
* Init the cutter to a safe OFF state |
|
|
//
|
|
|
*/ |
|
|
void SpindleLaser::init() { |
|
|
void SpindleLaser::init() { |
|
|
#if ENABLED(SPINDLE_SERVO) |
|
|
#if ENABLED(SPINDLE_SERVO) |
|
|
MOVE_SERVO(SPINDLE_SERVO_NR, SPINDLE_SERVO_MIN); |
|
|
MOVE_SERVO(SPINDLE_SERVO_NR, SPINDLE_SERVO_MIN); |
|
@ -86,6 +86,8 @@ void SpindleLaser::init() { |
|
|
#if ENABLED(SPINDLE_LASER_PWM) |
|
|
#if ENABLED(SPINDLE_LASER_PWM) |
|
|
/**
|
|
|
/**
|
|
|
* Set the cutter PWM directly to the given ocr value |
|
|
* Set the cutter PWM directly to the given ocr value |
|
|
|
|
|
* |
|
|
|
|
|
* @param ocr Power value |
|
|
*/ |
|
|
*/ |
|
|
void SpindleLaser::_set_ocr(const uint8_t ocr) { |
|
|
void SpindleLaser::_set_ocr(const uint8_t ocr) { |
|
|
#if NEEDS_HARDWARE_PWM && SPINDLE_LASER_FREQUENCY |
|
|
#if NEEDS_HARDWARE_PWM && SPINDLE_LASER_FREQUENCY |
|
@ -105,11 +107,15 @@ void SpindleLaser::init() { |
|
|
WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE); // Cutter OFF
|
|
|
WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE); // Cutter OFF
|
|
|
_set_ocr(0); |
|
|
_set_ocr(0); |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif // SPINDLE_LASER_PWM
|
|
|
|
|
|
|
|
|
//
|
|
|
/**
|
|
|
// Set cutter ON/OFF state (and PWM) to the given cutter power value
|
|
|
* Apply power for laser/spindle |
|
|
//
|
|
|
* |
|
|
|
|
|
* Apply cutter power value for PWM, Servo, and on/off pin. |
|
|
|
|
|
* |
|
|
|
|
|
* @param opwr Power value. Range 0 to MAX. When 0 disable spindle/laser. |
|
|
|
|
|
*/ |
|
|
void SpindleLaser::apply_power(const uint8_t opwr) { |
|
|
void SpindleLaser::apply_power(const uint8_t opwr) { |
|
|
static uint8_t last_power_applied = 0; |
|
|
static uint8_t last_power_applied = 0; |
|
|
if (opwr == last_power_applied) return; |
|
|
if (opwr == last_power_applied) return; |
|
@ -137,10 +143,10 @@ void SpindleLaser::apply_power(const uint8_t opwr) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#if ENABLED(SPINDLE_CHANGE_DIR) |
|
|
#if ENABLED(SPINDLE_CHANGE_DIR) |
|
|
//
|
|
|
/**
|
|
|
// Set the spindle direction and apply immediately
|
|
|
* Set the spindle direction and apply immediately |
|
|
// Stop on direction change if SPINDLE_STOP_ON_DIR_CHANGE is enabled
|
|
|
* Stop on direction change if SPINDLE_STOP_ON_DIR_CHANGE is enabled |
|
|
//
|
|
|
*/ |
|
|
void SpindleLaser::set_reverse(const bool reverse) { |
|
|
void SpindleLaser::set_reverse(const bool reverse) { |
|
|
const bool dir_state = (reverse == SPINDLE_INVERT_DIR); // Forward (M3) HIGH when not inverted
|
|
|
const bool dir_state = (reverse == SPINDLE_INVERT_DIR); // Forward (M3) HIGH when not inverted
|
|
|
if (TERN0(SPINDLE_STOP_ON_DIR_CHANGE, enabled()) && READ(SPINDLE_DIR_PIN) != dir_state) disable(); |
|
|
if (TERN0(SPINDLE_STOP_ON_DIR_CHANGE, enabled()) && READ(SPINDLE_DIR_PIN) != dir_state) disable(); |
|
@ -149,25 +155,17 @@ void SpindleLaser::apply_power(const uint8_t opwr) { |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#if ENABLED(AIR_EVACUATION) |
|
|
#if ENABLED(AIR_EVACUATION) |
|
|
|
|
|
|
|
|
// Enable / disable Cutter Vacuum or Laser Blower motor
|
|
|
// Enable / disable Cutter Vacuum or Laser Blower motor
|
|
|
void SpindleLaser::air_evac_enable() { WRITE(AIR_EVACUATION_PIN, AIR_EVACUATION_ACTIVE); } // Turn ON
|
|
|
void SpindleLaser::air_evac_enable() { WRITE(AIR_EVACUATION_PIN, AIR_EVACUATION_ACTIVE); } // Turn ON
|
|
|
|
|
|
|
|
|
void SpindleLaser::air_evac_disable() { WRITE(AIR_EVACUATION_PIN, !AIR_EVACUATION_ACTIVE); } // Turn OFF
|
|
|
void SpindleLaser::air_evac_disable() { WRITE(AIR_EVACUATION_PIN, !AIR_EVACUATION_ACTIVE); } // Turn OFF
|
|
|
|
|
|
|
|
|
void SpindleLaser::air_evac_toggle() { TOGGLE(AIR_EVACUATION_PIN); } // Toggle state
|
|
|
void SpindleLaser::air_evac_toggle() { TOGGLE(AIR_EVACUATION_PIN); } // Toggle state
|
|
|
|
|
|
#endif |
|
|
#endif // AIR_EVACUATION
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(AIR_ASSIST) |
|
|
#if ENABLED(AIR_ASSIST) |
|
|
|
|
|
|
|
|
// Enable / disable air assist
|
|
|
// Enable / disable air assist
|
|
|
void SpindleLaser::air_assist_enable() { WRITE(AIR_ASSIST_PIN, AIR_ASSIST_PIN); } // Turn ON
|
|
|
void SpindleLaser::air_assist_enable() { WRITE(AIR_ASSIST_PIN, AIR_ASSIST_PIN); } // Turn ON
|
|
|
|
|
|
|
|
|
void SpindleLaser::air_assist_disable() { WRITE(AIR_ASSIST_PIN, !AIR_ASSIST_PIN); } // Turn OFF
|
|
|
void SpindleLaser::air_assist_disable() { WRITE(AIR_ASSIST_PIN, !AIR_ASSIST_PIN); } // Turn OFF
|
|
|
|
|
|
|
|
|
void SpindleLaser::air_assist_toggle() { TOGGLE(AIR_ASSIST_PIN); } // Toggle state
|
|
|
void SpindleLaser::air_assist_toggle() { TOGGLE(AIR_ASSIST_PIN); } // Toggle state
|
|
|
|
|
|
#endif |
|
|
#endif // AIR_ASSIST
|
|
|
|
|
|
|
|
|
|
|
|
#endif // HAS_CUTTER
|
|
|
#endif // HAS_CUTTER
|
|
|