Fix a bug preventing multiple consecutive raster in one sequence

parent b8cef095
......@@ -4909,8 +4909,11 @@ inline void gcode_G92() {
#if ENABLED(LASER) && ENABLED(LASER_FIRE_SPINDLE)
if(laser.status != LASER_OFF) {
laser.status = LASER_OFF;
laser.mode = CONTINUOUS;
laser.duration = 0;
lcd_update();
prepare_move();
if(laser.diagnostics) ECHO_LM(INFO, "Laser M5 called and laser ON");
}
#endif
}
......@@ -7555,13 +7558,17 @@ inline void gcode_M503() {
#if ENABLED(LASER)
// M649 set laser options
inline void gcode_M649() {
// do this at the start so we can debug if needed!
if (code_seen('D') && IsRunning()) laser.diagnostics = (bool) code_value();
// Wait for the rest
//st_synchronize();
if (code_seen('S') && IsRunning()) {
laser.intensity = (float) code_value();
laser.rasterlaserpower = laser.intensity;
}
if (code_seen('L') && IsRunning()) laser.duration = (unsigned long) labs(code_value());
if (code_seen('P') && IsRunning()) laser.ppm = (float) code_value();
if (code_seen('D') && IsRunning()) laser.diagnostics = (bool) code_value();
if (code_seen('B') && IsRunning()) laser_set_mode((int) code_value());
if (code_seen('R') && IsRunning()) laser.raster_mm_per_pulse = ((float) code_value());
if (code_seen('F')) {
......
......@@ -896,7 +896,7 @@ float junction_deviation = 0.1;
static const float Factor = F_CPU/(LASER_PWM*2*100.0*255.0);
block->laser_raster_intensity_factor = laser.intensity * Factor;
#endif
block->steps_l = labs(block->millimeters*laser.ppm);
block->steps_l = (unsigned long)labs(block->millimeters*laser.ppm);
if (laser.mode == RASTER) {
for (int i = 0; i < LASER_MAX_RASTER_LINE; i++) {
#if (!ENABLED(LASER_PULSE_METHOD))
......
......@@ -104,7 +104,7 @@ typedef struct {
bool laser_status; // LASER_OFF, LASER_ON
float laser_ppm; // pulses per millimeter, for pulsed and raster firing modes
unsigned long laser_duration; // laser firing duration in microseconds, for pulsed and raster firing modes
long steps_l; // step count between firings of the laser, for pulsed firing mode
unsigned long steps_l; // step count between firings of the laser, for pulsed firing mode
float laser_intensity; // Laser firing instensity in clock cycles for the PWM timer
#if ENABLED(LASER_RASTER)
unsigned char laser_raster_data[LASER_MAX_RASTER_LINE];
......@@ -121,6 +121,8 @@ typedef struct {
#define BLOCK_MOD(n) ((n)&(BLOCK_BUFFER_SIZE-1))
#define MAX_EVENTS_COUNT 2147483648 // max for a signed 32 bit number
// Initialize the motion plan subsystem
void plan_init();
......
......@@ -630,9 +630,7 @@ ISR(TIMER1_COMPA_vect) {
// going from darkened paper to burning through paper.
laser_fire(current_block->laser_raster_data[counter_raster]);
#endif
if (laser.diagnostics) {
ECHO_MV("Pixel: ", (float)current_block->laser_raster_data[counter_raster]);
}
if (laser.diagnostics) ECHO_EMV("Pixel: ", (float)current_block->laser_raster_data[counter_raster]);
counter_raster++;
}
#endif // LASER_RASTER
......@@ -640,12 +638,27 @@ ISR(TIMER1_COMPA_vect) {
}
#if !ENABLED(LASER_PULSE_METHOD)
if (current_block->laser_duration != 0 && (laser.last_firing + current_block->laser_duration < micros())) {
if (laser.diagnostics) ECHO_LM(INFO, "Laser firing duration elapsed, in interrupt fast loop");
if (laser.diagnostics) {
ECHO_MV("X: ", counter_X);
ECHO_MV(", Y: ", counter_Y);
ECHO_MV(", L: ", counter_L);
ECHO_MV(", Z: ", counter_L);
ECHO_MV(", E: ", counter_E);
ECHO_MV(", steps done: ",step_events_completed);
ECHO_MV(", event count: ", current_block->step_event_count);
ECHO_EM(", <--------------------");
ECHO_LM(INFO, "Laser firing duration elapsed, in interrupt fast loop ");
}
laser_extinguish();
}
#endif
#endif // LASER
// safe check for erroneous calculated events count
if(current_block->step_event_count >= MAX_EVENTS_COUNT) {
kill_current_block();
break;
}
step_events_completed++;
if (step_events_completed >= current_block->step_event_count) break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment