Laser Test Fire (#20452)

This commit is contained in:
Mike La Spina 2021-01-10 06:01:25 -06:00 committed by Scott Lahteine
parent 4e46de66d3
commit 9901b4e9f1
6 changed files with 43 additions and 1 deletions

View File

@ -3055,6 +3055,10 @@
#define SPEED_POWER_MAX 100 // (%) 0-100
#define SPEED_POWER_STARTUP 80 // (%) M3/M4 speed/power default (with no arguments)
// Define the minimum and maximum test pulse time values for a laser test fire function
#define LASER_TEST_PULSE_MIN 1 // Used with Laser Control Menu
#define LASER_TEST_PULSE_MAX 999 // Caution: Menu may not show more than 3 characters
/**
* Enable inline laser power to be handled in the planner / stepper routines.
* Inline power is specified by the I (inline) flag in an M3 command (e.g., M3 S20 I)

View File

@ -36,6 +36,9 @@
SpindleLaser cutter;
uint8_t SpindleLaser::power;
#if ENABLED(LASER_FEATURE)
cutter_test_pulse_t SpindleLaser::testPulse = 50; // Test fire Pulse time ms value.
#endif
bool SpindleLaser::isReady; // Ready to apply power setting from the UI to OCR
cutter_power_t SpindleLaser::menuPower, // Power set via LCD menu in PWM, PERCENT, or RPM
SpindleLaser::unitPower; // LCD status power in PWM, PERCENT, or RPM

View File

@ -30,6 +30,10 @@
#include "spindle_laser_types.h"
#if USE_BEEPER
#include "../libs/buzzer.h"
#endif
#if ENABLED(LASER_POWER_INLINE)
#include "../module/planner.h"
#endif
@ -90,6 +94,10 @@ public:
static const cutter_power_t mpower_min() { return cpwr_to_upwr(SPEED_POWER_MIN); }
static const cutter_power_t mpower_max() { return cpwr_to_upwr(SPEED_POWER_MAX); }
#if ENABLED(LASER_FEATURE)
static cutter_test_pulse_t testPulse; // Test fire Pulse ms value
#endif
static bool isReady; // Ready to apply power setting from the UI to OCR
static uint8_t power;
@ -230,7 +238,21 @@ public:
}
#endif
#endif
#if ENABLED(LASER_FEATURE)
/**
* Test fire the laser using the testPulse ms duration
* Also fires with any PWM power that was previous set
* If not set defaults to 80% power
*/
static inline void test_fire_pulse() {
enable_forward(); // Turn Laser on (Spindle speak but same funct)
TERN_(USE_BEEPER, buzzer.tone(30, 3000));
delay(testPulse); // Delay for time set by user in pulse ms menu screen.
disable(); // Turn laser off
}
#endif
#endif // HAS_LCD_MENU
#if ENABLED(LASER_POWER_INLINE)
/**

View File

@ -52,6 +52,11 @@ typedef IF<(SPEED_POWER_MAX > 255), uint16_t, uint8_t>::type cutter_cpower_t;
#endif
#endif
#if ENABLED(LASER_FEATURE)
typedef uint16_t cutter_test_pulse_t;
#define CUTTER_MENU_PULSE_TYPE uint16_3
#endif
#if ENABLED(MARLIN_DEV_MODE)
typedef uint16_t cutter_frequency_t;
#define CUTTER_MENU_FREQUENCY_TYPE uint16_5

View File

@ -114,6 +114,8 @@ namespace Language_en {
PROGMEM Language_Str MSG_LASER_POWER = _UxGT("Laser Power");
PROGMEM Language_Str MSG_SPINDLE_POWER = _UxGT("Spindle Pwr");
PROGMEM Language_Str MSG_LASER_TOGGLE = _UxGT("Toggle Laser");
PROGMEM Language_Str MSG_LASER_PULSE_MS = _UxGT("Test Pulse ms");
PROGMEM Language_Str MSG_LASER_FIRE_PULSE = _UxGT("Fire Pulse");
PROGMEM Language_Str MSG_SPINDLE_TOGGLE = _UxGT("Toggle Spindle");
PROGMEM Language_Str MSG_SPINDLE_FORWARD = _UxGT("Spindle Forward");
PROGMEM Language_Str MSG_SPINDLE_REVERSE = _UxGT("Spindle Reverse");

View File

@ -58,6 +58,12 @@
}
#endif
#if ENABLED(LASER_FEATURE)
// Setup and fire a test pulse using the current PWM power level for for a duration of test_pulse_min to test_pulse_max ms.
EDIT_ITEM_FAST(CUTTER_MENU_PULSE_TYPE, MSG_LASER_PULSE_MS, &cutter.testPulse, LASER_TEST_PULSE_MIN, LASER_TEST_PULSE_MAX);
ACTION_ITEM(MSG_LASER_FIRE_PULSE, cutter.test_fire_pulse);
#endif
#if BOTH(MARLIN_DEV_MODE, HAL_CAN_SET_PWM_FREQ) && defined(SPINDLE_LASER_FREQUENCY)
EDIT_ITEM_FAST(CUTTER_MENU_FREQUENCY_TYPE, MSG_CUTTER_FREQUENCY, &cutter.frequency, 2000, 80000, cutter.refresh_frequency);
#endif