Skip to content

Commit

Permalink
Misc cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Dec 28, 2020
1 parent e741e87 commit 654e264
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 35 deletions.
10 changes: 5 additions & 5 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -2975,11 +2975,7 @@
#define SPINDLE_LASER_ACTIVE_STATE LOW // Set to "HIGH" if the on/off function is active HIGH
#define SPINDLE_LASER_PWM true // Set to "true" if your controller supports setting the speed/power
#define SPINDLE_LASER_PWM_INVERT false // Set to "true" if the speed/power goes up when you want it to go slower
// Define the minimum and maximum test pulse time values for a laser test fire function
#ifdef LASER_FEATURE
#define LASER_TEST_PULSE_MIN 1 // Used with Laser Control Menu
#define LASER_TEST_PULSE_MAX 999 // Caution Menu display format will show greater than 3 characters
#endif

#define SPINDLE_LASER_FREQUENCY 2500 // (Hz) Spindle/laser frequency (only on supported HALs: AVR and LPC)

//#define SPINDLE_SERVO // A servo converting an angle to spindle power
Expand Down Expand Up @@ -3036,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
6 changes: 3 additions & 3 deletions Marlin/src/feature/spindle_laser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@

SpindleLaser cutter;
uint8_t SpindleLaser::power;
#ifdef LASER_FEATURE
cutter_test_pulse_t SpindleLaser::testPulse; // Test fire Pulse time ms value.
#endif
#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
37 changes: 17 additions & 20 deletions Marlin/src/feature/spindle_laser.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,9 @@ 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); }

#ifdef LASER_FEATURE
static const uint16_t pulse_min() { return (LASER_TEST_PULSE_MIN); }
static const uint16_t pulse_max() { return (LASER_TEST_PULSE_MAX); }
static cutter_test_pulse_t testPulse; // Test fire Pulse ms value.

#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
Expand Down Expand Up @@ -240,22 +238,21 @@ class SpindleLaser {
}
#endif

#ifdef 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
*/
void test_fire_pulse(void) {
enable_forward(); // Turn Laser on (Spindle speak but same funct)
#if USE_BEEPER
buzzer.tone(30, 3000);
#endif
delay(testPulse); // Delay for time set by user in pulse ms menu screen.
disable(); // Turn laser off
}
#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

#endif // HAS_LCD_MENU

#if ENABLED(LASER_POWER_INLINE)
/**
Expand Down
5 changes: 2 additions & 3 deletions Marlin/src/feature/spindle_laser_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,17 @@ typedef IF<(SPEED_POWER_MAX > 255), uint16_t, uint8_t>::type cutter_cpower_t;
#define CUTTER_MENU_POWER_TYPE uint16_5
#define cutter_power2str ui16tostr5rj
#else
typedef uint8_t cutter_power_t;
#if CUTTER_UNIT_IS(PERCENT)
typedef uint8_t cutter_power_t;
#define CUTTER_MENU_POWER_TYPE percent_3
#define cutter_power2str pcttostrpctrj
#else
typedef uint8_t cutter_power_t;
#define CUTTER_MENU_POWER_TYPE uint8
#define cutter_power2str ui8tostr3rj
#endif
#endif

#ifdef LASER_FEATURE
#if ENABLED(LASER_FEATURE)
typedef uint16_t cutter_test_pulse_t;
#define CUTTER_MENU_PULSE_TYPE uint16_3
#endif
Expand Down
7 changes: 3 additions & 4 deletions Marlin/src/lcd/menu/menu_spindle_laser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,10 @@

#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.
if (cutter.testPulse == 0) cutter.testPulse = 50; //Init the testPulse value
EDIT_ITEM_FAST(CUTTER_MENU_PULSE_TYPE, MSG_LASER_PULSE_MS, &cutter.testPulse, cutter.pulse_min(), cutter.pulse_max());
ACTION_ITEM_P(GET_TEXT(MSG_LASER_FIRE_PULSE), [] {cutter.test_fire_pulse(); });
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

0 comments on commit 654e264

Please sign in to comment.