🎨 Misc. spindle/laser adjustments
This commit is contained in:
parent
c478ed08c8
commit
7b79d53de0
@ -42,7 +42,7 @@
|
|||||||
#elif NUM_SERVOS > 0 && defined(_useTimer3) && (WITHIN(SPINDLE_LASER_PWM_PIN, 2, 3) || SPINDLE_LASER_PWM_PIN == 5)
|
#elif NUM_SERVOS > 0 && defined(_useTimer3) && (WITHIN(SPINDLE_LASER_PWM_PIN, 2, 3) || SPINDLE_LASER_PWM_PIN == 5)
|
||||||
#error "Counter/Timer for SPINDLE_LASER_PWM_PIN is used by the servo system."
|
#error "Counter/Timer for SPINDLE_LASER_PWM_PIN is used by the servo system."
|
||||||
#endif
|
#endif
|
||||||
#elif defined(SPINDLE_LASER_FREQUENCY)
|
#elif SPINDLE_LASER_FREQUENCY
|
||||||
#error "SPINDLE_LASER_FREQUENCY requires SPINDLE_LASER_USE_PWM."
|
#error "SPINDLE_LASER_FREQUENCY requires SPINDLE_LASER_USE_PWM."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -30,12 +30,8 @@ void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255
|
|||||||
LPC176x::pwm_write_ratio(pin, invert ? 1.0f - (float)v / v_size : (float)v / v_size); // map 1-254 onto PWM range
|
LPC176x::pwm_write_ratio(pin, invert ? 1.0f - (float)v / v_size : (float)v / v_size); // map 1-254 onto PWM range
|
||||||
}
|
}
|
||||||
|
|
||||||
#if NEEDS_HARDWARE_PWM // Specific meta-flag for features that mandate PWM
|
|
||||||
|
|
||||||
void set_pwm_frequency(const pin_t pin, const uint16_t f_desired) {
|
void set_pwm_frequency(const pin_t pin, const uint16_t f_desired) {
|
||||||
LPC176x::pwm_set_frequency(pin, f_desired);
|
LPC176x::pwm_set_frequency(pin, f_desired);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // TARGET_LPC1768
|
#endif // TARGET_LPC1768
|
||||||
|
@ -68,7 +68,7 @@ void SpindleLaser::init() {
|
|||||||
SET_PWM(SPINDLE_LASER_PWM_PIN);
|
SET_PWM(SPINDLE_LASER_PWM_PIN);
|
||||||
set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_PWM_OFF); // Set to lowest speed
|
set_pwm_duty(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) && 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);
|
||||||
TERN_(MARLIN_DEV_MODE, frequency = SPINDLE_LASER_FREQUENCY);
|
TERN_(MARLIN_DEV_MODE, frequency = SPINDLE_LASER_FREQUENCY);
|
||||||
#endif
|
#endif
|
||||||
@ -78,9 +78,7 @@ void SpindleLaser::init() {
|
|||||||
#if ENABLED(AIR_ASSIST)
|
#if ENABLED(AIR_ASSIST)
|
||||||
OUT_WRITE(AIR_ASSIST_PIN, !AIR_ASSIST_ACTIVE); // Init Air Assist OFF
|
OUT_WRITE(AIR_ASSIST_PIN, !AIR_ASSIST_ACTIVE); // Init Air Assist OFF
|
||||||
#endif
|
#endif
|
||||||
#if ENABLED(I2C_AMMETER)
|
TERN_(I2C_AMMETER, ammeter.init()); // Init I2C Ammeter
|
||||||
ammeter.init(); // Init I2C Ammeter
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLED(SPINDLE_LASER_USE_PWM)
|
#if ENABLED(SPINDLE_LASER_USE_PWM)
|
||||||
@ -90,7 +88,7 @@ void SpindleLaser::init() {
|
|||||||
* @param ocr Power 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 ENABLED(HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY
|
||||||
set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), TERN(MARLIN_DEV_MODE, frequency, SPINDLE_LASER_FREQUENCY));
|
set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), TERN(MARLIN_DEV_MODE, frequency, SPINDLE_LASER_FREQUENCY));
|
||||||
#endif
|
#endif
|
||||||
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);
|
||||||
|
@ -74,7 +74,7 @@
|
|||||||
ACTION_ITEM(MSG_LASER_FIRE_PULSE, cutter.test_fire_pulse);
|
ACTION_ITEM(MSG_LASER_FIRE_PULSE, cutter.test_fire_pulse);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if BOTH(MARLIN_DEV_MODE, HAL_CAN_SET_PWM_FREQ) && defined(SPINDLE_LASER_FREQUENCY)
|
#if BOTH(MARLIN_DEV_MODE, HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY
|
||||||
EDIT_ITEM_FAST(CUTTER_MENU_FREQUENCY_TYPE, MSG_CUTTER_FREQUENCY, &cutter.frequency, 2000, 80000, cutter.refresh_frequency);
|
EDIT_ITEM_FAST(CUTTER_MENU_FREQUENCY_TYPE, MSG_CUTTER_FREQUENCY, &cutter.frequency, 2000, 80000, cutter.refresh_frequency);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user