sync LASER patch with latest changes and last fixes

parent 3ad54bd4
......@@ -113,6 +113,16 @@
//#define PS_DEFAULT_OFF
/*************************************************************************************/
/***********************************************************************
******************************* Cooler ********************************
***********************************************************************
* *
* Uncomment the following line to enable COOLER support *
* *
***********************************************************************/
#define COOLER
/***********************************************************************
************************** Extruders number ***************************
......
......@@ -113,6 +113,16 @@
//#define PS_DEFAULT_OFF
/*************************************************************************************/
/***********************************************************************
******************************* Cooler ********************************
***********************************************************************
* *
* Uncomment the following line to enable COOLER support *
* *
***********************************************************************/
//#define COOLER
/***********************************************************************
************************** Extruders number ***************************
......
......@@ -116,7 +116,7 @@ inline void refresh_cmd_timeout() { previous_cmd_ms = millis(); }
extern void delay_ms(millis_t ms);
#if ENABLED(FAST_PWM_FAN) || ENABLED(COOLER_PWM)
#if ENABLED(FAST_PWM_FAN) || ENABLED(FAST_COOLER_PWM)
void setPwmFrequency(uint8_t pin, int val);
#endif
......
......@@ -805,7 +805,7 @@
#define WRITE_HEATER_BED(v) WRITE(HEATER_BED_PIN,v)
#endif
#endif
#if HAS(HEATER_COOLER)
#if HAS(COOLER_DEV)
#if ENABLED(INVERTED_COOLER_PINS)
#define WRITE_COOLER(v) WRITE(COOLER_PIN,!v)
#else
......
......@@ -94,7 +94,6 @@
#define SERIAL_INVALID_HOTEND "Invalid hotend"
#define SERIAL_INVALID_SOLENOID "Invalid solenoid"
#define SERIAL_ERR_NO_THERMISTORS "No thermistors - no temperature"
#define SERIAL_COUNT_X " Count X: "
#define SERIAL_ERR_KILLED "Printer halted. kill() called!"
#define SERIAL_ERR_STOPPED "Printer stopped due to errors. Fix the error and use M999 to restart. (Temperature is reset. Set it after restarting)"
#define SERIAL_BUSY_PROCESSING "processing"
......
......@@ -757,7 +757,7 @@ MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_multiplier, 10, 999);
// Laser:
//
#if ENABLED(LASER)
MENU_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15);
MENU_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature_cooler, 0, COOLER_MAXTEMP - 15);
#endif
//
......@@ -1774,7 +1774,7 @@ static void lcd_control_volumetric_menu() {
static void lcd_laser_menu()
{
START_MENU();
MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
MENU_ITEM(back, MSG_MAIN);
MENU_ITEM(submenu, "Set Focus", lcd_laser_focus_menu);
MENU_ITEM(submenu, "Test Fire", lcd_laser_test_fire_menu);
#ifdef LASER_PERIPHERALS
......@@ -1789,7 +1789,7 @@ static void lcd_laser_menu()
static void lcd_laser_test_fire_menu() {
START_MENU();
MENU_ITEM(back, "Laser Functions", lcd_laser_menu);
MENU_ITEM(back, "Laser Functions");
MENU_ITEM(function, " 20% 50ms", action_laser_test_20_50ms);
MENU_ITEM(function, " 20% 100ms", action_laser_test_20_100ms);
MENU_ITEM(function, "100% 50ms", action_laser_test_100_50ms);
......@@ -1835,7 +1835,7 @@ static void laser_test_fire(uint8_t power, int dwell) {
float focalLength = 0;
static void lcd_laser_focus_menu() {
START_MENU();
MENU_ITEM(back, "Laser Functions", lcd_laser_menu);
MENU_ITEM(back, "Laser Functions");
MENU_ITEM(function, "1mm", action_laser_focus_1mm);
MENU_ITEM(function, "2mm", action_laser_focus_2mm);
MENU_ITEM(function, "3mm - 1/8in", action_laser_focus_3mm);
......@@ -1878,7 +1878,7 @@ static void action_laser_focus_7mm() {
laser_set_focus(7);
}
static void laser_set_focus(float f_length) {
if (!TEST(axis_was_homed, Z_AXIS)) {
if (!axis_homed[Z_AXIS]) {
enqueue_and_echo_commands_P(PSTR("G28 Z F150"));
}
focalLength = f_length;
......
......@@ -69,7 +69,7 @@ static unsigned char last_direction_bits = 0; // The next stepping-bits to be o
static unsigned int cleaning_buffer_counter = 0;
#ifdef LASER
static long counter_l;
static long counter_L;
#endif // LASER
#ifdef LASER_RASTER
......@@ -447,7 +447,7 @@ ISR(TIMER1_COMPA_vect) {
// Initialize Bresenham counters to 1/2 the ceiling
counter_X = counter_Y = counter_Z = counter_E = -(current_block->step_event_count >> 1);
#if ENABLED(LASER)
counter_l = counter_x;
counter_L = counter_X;
laser.dur = current_block->laser_duration;
#endif
......@@ -597,14 +597,14 @@ ISR(TIMER1_COMPA_vect) {
#endif
#if ENABLED(LASER)
counter_l += current_block->steps_l;
if (counter_l > 0) {
counter_L += current_block->steps_l;
if (counter_L > 0) {
if (current_block->laser_mode == PULSED && current_block->laser_status == LASER_ON) { // Pulsed Firing Mode
laser_fire(current_block->laser_intensity);
if (laser.diagnostics) {
ECHO_MV("X: ", counter_x);
ECHO_MV("Y: ", counter_y);
ECHO_MV("L: ", counter_l);
ECHO_MV("X: ", counter_X);
ECHO_MV("Y: ", counter_Y);
ECHO_MV("L: ", counter_L);
}
}
#if ENABLED(LASER_RASTER)
......@@ -618,7 +618,7 @@ ISR(TIMER1_COMPA_vect) {
counter_raster++;
}
#endif // LASER_RASTER
counter_l -= current_block->step_event_count;
counter_L -= current_block->step_event_count;
}
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");
......
......@@ -155,6 +155,9 @@
#if DISABLED(COOLER_MINTEMP)
#error DEPENDENCY ERROR: Missing setting COOLER_MINTEMP
#endif
#if DISABLED(COOLER)
#error DEPENDENCY ERROR: Cannot enable TEMP_SENSOR_COOLER and not COOLER
#endif
#endif
#if DISABLED(PLA_PREHEAT_HOTEND_TEMP)
#error DEPENDENCY ERROR: Missing setting PLA_PREHEAT_HOTEND_TEMP
......
......@@ -987,7 +987,7 @@ void manage_temp_controller() {
}
else { // NEXTIME XXX here we have to manage hw pwm?
soft_pwm_cooler = 0;
WRITE_HEATER_COOLER(LOW);
WRITE_COOLER(LOW);
}
#else // COOLER_LIMIT_SWITCHING
// Check if temperature is within the correct range
......@@ -996,7 +996,7 @@ void manage_temp_controller() {
}
else {
soft_pwm_cooler = 0;
WRITE_HEATER_COOLER(LOW);
WRITE_COOLER(LOW);
}
#endif
#endif // TEMP_SENSOR_COOLER != 0
......@@ -1276,11 +1276,9 @@ void tp_init() {
SET_OUTPUT(HEATER_BED_PIN);
#endif
#if HAS(COOLER_DEV)
SET_OUTPUT(COOLER_PIN)
#if ENABLED(COOLER_PWM)
SET_OUTPUT(COOLER_PIN);
#if ENABLED(FAST_COOLER_PWM)
setPwmFrequency(COOLER_PIN, 2); // No prescaling. Pwm frequency = F_CPU/256/64
#else
soft_pwm_cooler = coolerSpeedSoftPwm / 2;
#endif
#endif
#if HAS(FAN)
......@@ -1793,7 +1791,7 @@ ISR(TIMER0_COMPB_vect) {
ISR_STATICS(BED);
#endif
#if HAS(COOLER_DEV)
ISR_STATICS(COOLER_DEVICE);
ISR_STATICS(COOLER_DEV);
#endif
#if HAS(FILAMENT_SENSOR)
......@@ -1829,8 +1827,8 @@ ISR(TIMER0_COMPB_vect) {
WRITE_HEATER_BED(soft_pwm_BED > 0 ? 1 : 0);
#endif
#if HAS(COOLER_DEV)
soft_pwm_COOLER_DEVICE = soft_pwm_cooler;
WRITE_COOLER(soft_pwm_COOLER_DEVICE > 0 ? 1 : 0);
soft_pwm_cooler = soft_pwm_cooler;
WRITE_COOLER(soft_pwm_cooler > 0 ? 1 : 0);
#endif
#if ENABLED(FAN_SOFT_PWM)
soft_pwm_fan = fanSpeedSoftPwm / 2;
......@@ -1872,7 +1870,7 @@ ISR(TIMER0_COMPB_vect) {
if (soft_pwm_BED < pwm_count) WRITE_HEATER_BED(0);
#endif
#if HAS(COOLER_DEV)
if (soft_pwm_COOLER_DEVICE < pwm_count ) WRITE_COOLER(0);
if (soft_pwm_cooler < pwm_count ) WRITE_COOLER(0);
#endif
#if ENABLED(FAN_SOFT_PWM)
......@@ -1956,7 +1954,7 @@ ISR(TIMER0_COMPB_vect) {
_SLOW_PWM_ROUTINE(BED, soft_pwm_bed); // BED
#endif
#if HAS(COOLER_DEV)
_SLOW_PWM_SOURINT(COOLER_DEVICE, soft_pwm_cooler); // COOLER
_SLOW_PWM_SOURINT(COOLER_DEV, soft_pwm_cooler); // COOLER
#endif
} // slow_pwm_count == 0
......@@ -1975,7 +1973,7 @@ ISR(TIMER0_COMPB_vect) {
PWM_OFF_ROUTINE(BED); // BED
#endif
#if HAS(COOLER_DEV)
PWM_OFF_ROUTINE(COOLER_DEVICE); // COOLER
PWM_OFF_ROUTINE(COOLER_DEV); // COOLER
#endif
#if ENABLED(FAN_SOFT_PWM)
......@@ -2047,7 +2045,7 @@ ISR(TIMER0_COMPB_vect) {
if (state_timer_heater_BED > 0) state_timer_heater_BED--;
#endif
#if HAS(COOLER_DEV)
if(state_timer_heater_COOLER_DEVICE > 0) state_timer_heater_COOLER_DEVICE--;
if(state_timer_heater_COOLER_DEV > 0) state_timer_heater_COOLER_DEV--;
#endif
} // (pwm_count % 64) == 0
......
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