Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Add Laser test fire function" #20452

Merged
merged 8 commits into from
Jan 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -3032,6 +3032,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)
Expand Down
3 changes: 3 additions & 0 deletions Marlin/src/feature/spindle_laser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 23 additions & 1 deletion Marlin/src/feature/spindle_laser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -90,6 +94,10 @@ class SpindleLaser {
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;

Expand Down Expand Up @@ -230,7 +238,21 @@ class SpindleLaser {
}
#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)
/**
Expand Down
5 changes: 5 additions & 0 deletions Marlin/src/feature/spindle_laser_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/lcd/language/language_en.h
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
6 changes: 6 additions & 0 deletions Marlin/src/lcd/menu/menu_spindle_laser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down