Skip to content

Commit

Permalink
laser feature update part2
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasToka committed Jul 27, 2023
1 parent 94b26fb commit 7e6361a
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 34 deletions.
5 changes: 3 additions & 2 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -1569,8 +1569,9 @@
* The probe replaces the Z-MIN endstop and is used for Z homing.
* (Automatically enables USE_PROBE_FOR_Z_HOMING.)
*/
#define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN

#if DISABLED(ENDER_3S1)
#define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN
#endif
// Force the use of the probe for Z-axis homing
#define USE_PROBE_FOR_Z_HOMING

Expand Down
2 changes: 1 addition & 1 deletion Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -3486,7 +3486,7 @@
#define PLR_ADDR 800
#endif

#define EEPROM_DEMARCATE
//#define EEPROM_DEMARCATE
#if ENABLED(EEPROM_DEMARCATE)
#define DEMARCATE_ADDR 1900
#define DEMARCATE_NUMBER 4
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/STM32/timers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ static constexpr bool verify_no_timer_conflicts() {
// when hovering over it, making it easy to identify the conflicting timers.
static_assert(verify_no_timer_conflicts(), "One or more timer conflict detected. Examine \"timers_in_use\" to help identify conflict.");

#if ALL(E3S1PRO_RTS, HAS_CUTTER)
#if ALL(E3S1PRO_RTS, LASER_FEATURE)

#define LASER_TIMER_NUM 3
#define LASER_TIMER_DEV _TIMER_DEV(LASER_TIMER_NUM)
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/STM32/timers.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const ha
#define HAL_timer_isr_prologue(T) NOOP
#define HAL_timer_isr_epilogue(T) NOOP

#if ALL(E3S1PRO_RTS, HAS_CUTTER)
#if ALL(E3S1PRO_RTS, LASER_FEATURE)
#define LASER_TIMER_FREQUENCY 1000 // PWM freq:1000Hz
#define LASER_TIMER_PWM_MAX 255 // PWM value range: 0~255

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/HAL/STM32F1/timers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ timer_dev* HAL_get_timer_dev(int number) {
}
}

#if ALL(E3S1PRO_RTS, HAS_CUTTER)
#if ALL(E3S1PRO_RTS, LASER_FEATURE)
static unsigned int sw=0, laser_h = 0, laser_l = 0;

void laser_timer_soft_pwm_start(uint8_t pwm)
Expand Down Expand Up @@ -252,6 +252,6 @@ void laser_timer_soft_pwm_init(const uint32_t frequency)
timer_generate_update(LASER_TIMER_DEV);
// timer_resume(LASER_TIMER_DEV);
}
#endif //#if HAS_CUTTER
#endif //#if LASER_FEATURE

#endif // __STM32F1__
2 changes: 1 addition & 1 deletion Marlin/src/HAL/STM32F1/timers.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ void HAL_timer_set_interrupt_priority(uint_fast8_t timer_num, uint_fast8_t prior

#define TIMER_OC_NO_PRELOAD 0 // Need to disable preload also on compare registers.

#if ALL(E3S1PRO_RTS, HAS_CUTTER)
#if ALL(E3S1PRO_RTS, LASER_FEATURE)
#define LASER_TIMER_NUM 3
#define LASER_TIMER_DEV TIMER_DEV(LASER_TIMER_NUM)
#define LASER_TIMER_FREQUENCY 1000 // PWM freq:1000Hz
Expand Down
76 changes: 62 additions & 14 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ void startOrResumeJob() {
card.abortFilePrintNow(TERN_(SD_RESORT, true));

#if ENABLED(E3S1PRO_RTS)
#if HAS_CUTTER
#if ENABLED(LASER_FEATURE)
if(laser_device.is_laser_device())
{
}else
Expand Down Expand Up @@ -422,9 +422,32 @@ void startOrResumeJob() {
}
}

#if ALL(E3S1PRO_RTS, LASER_FEATURE)
inline void abortSDEngraving() {
IF_DISABLED(NO_SD_AUTOSTART, card.autofile_cancel());
card.abortFilePrintNow(TERN_(SD_RESORT, true));

queue.clear();
quickstop_stepper();

print_job_timer.abort();
laser_device.quick_stop();

wait_for_heatup = false;

TERN_(POWER_LOSS_RECOVERY, recovery.purge());

#ifdef EVENT_GCODE_SD_ABORT_LASER
queue.inject(F(EVENT_GCODE_SD_ABORT_LASER));
#endif

TERN_(PASSWORD_AFTER_SD_PRINT_ABORT, password.lock_machine());
}
#endif

#endif // HAS_MEDIA

#if ALL(E3S1PRO_RTS, HAS_CUTTER)
#if ALL(E3S1PRO_RTS, LASER_FEATURE)
void get_sdcard_laser_range();
#endif

Expand Down Expand Up @@ -820,8 +843,16 @@ void idle(const bool no_stepper_sleep/*=false*/) {

// Handle filament runout sensors
#if HAS_FILAMENT_SENSOR
if (TERN1(HAS_PRUSA_MMU2, !mmu2.enabled()))
runout.run();
if (TERN1(HAS_PRUSA_MMU2, !mmu2.enabled())){
#if ALL(E3S1PRO_RTS, LASER_FEATURE)
if(laser_device.is_laser_device())
{
}else
#endif
{
runout.run();
}
}
#endif

// Run HAL idle tasks
Expand All @@ -832,7 +863,14 @@ void idle(const bool no_stepper_sleep/*=false*/) {

// Handle Power-Loss Recovery
#if ENABLED(POWER_LOSS_RECOVERY) && PIN_EXISTS(POWER_LOSS)
#if ALL(E3S1PRO_RTS, LASER_FEATURE)
if(laser_device.is_laser_device())
{
}else
#endif
{
if (IS_SD_PRINTING()) recovery.outage();
}
#endif

// Run StallGuard endstop checks
Expand Down Expand Up @@ -860,7 +898,7 @@ void idle(const bool no_stepper_sleep/*=false*/) {
TERN(DWIN_CREALITY_LCD, dwinUpdate(), ui.update());

#if ENABLED(E3S1PRO_RTS)
#if HAS_CUTTER
#if ENABLED(LASER_FEATURE)
if(laser_device.is_laser_device())
{
TERN(E3S1PRO_RTS, RTSUpdateLaser(),ui.update());
Expand Down Expand Up @@ -1438,8 +1476,9 @@ void setup() {
OUT_WRITE(PHOTOGRAPH_PIN, LOW);
#endif

#if HAS_CUTTER
SETUP_RUN(cutter.init());
#if ENABLED(LASER_FEATURE)
//SETUP_RUN(cutter.init());
SETUP_RUN(laser_device.soft_pwm_init());
#endif

#if ENABLED(COOLANT_MIST)
Expand Down Expand Up @@ -1651,13 +1690,20 @@ void setup() {
BL24CXX::init();
const uint8_t err = BL24CXX::check();
SERIAL_ECHO_TERNARY(err, "BL24CXX Check ", "failed", "succeeded", "!\n");
#if ALL(E3S1PRO_RTS, LASER_FEATURE)
laser_device.get_device_form_eeprom(); // 107011
laser_device.get_z_axis_high_form_eeprom();
#endif
#endif

#if HAS_DWIN_E3V2_BASIC
SETUP_RUN(dwinInitScreen());
#endif

#if ENABLED(E3S1PRO_RTS)
#if ENABLED(LASER_FEATURE)
if(laser_device.is_laser_device()) laser_device.laser_power_open();
#endif
delay(500);
SETUP_RUN(rtscheck.RTS_Init());
#endif
Expand All @@ -1674,12 +1720,6 @@ void setup() {
SETUP_RUN(page_manager.init());
#endif

#if ALL(E3S1PRO_RTS, HAS_CUTTER)
laser_device.get_device_form_eeprom(); // 107011
laser_device.get_z_axis_high_form_eeprom();
if(laser_device.is_laser_device()) laser_device.laser_power_open();
#endif

#if HAS_TFT_LVGL_UI
#if HAS_MEDIA
if (!card.isMounted()) SETUP_RUN(card.mount()); // Mount SD to load graphics and fonts
Expand Down Expand Up @@ -1750,7 +1790,15 @@ void loop() {
idle();

#if HAS_MEDIA
if (card.flag.abort_sd_printing) abortSDPrinting();
#if ALL(E3S1PRO_RTS, LASER_FEATURE)
if(laser_device.is_laser_device())
{
if (card.flag.abort_sd_printing) abortSDEngraving();
}else
#endif
{
if (card.flag.abort_sd_printing) abortSDPrinting();
}
if (marlin_state == MF_SD_COMPLETE) finishSDPrinting();
#endif

Expand Down
10 changes: 5 additions & 5 deletions Marlin/src/feature/powerloss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,11 +626,11 @@ void PrintJobRecovery::resume() {

DEBUG_ECHOLNPGM("zraise: ", info.zraise, " ", info.flag.raised ? "(before)" : "");

//#if ENABLED(GCODE_REPEAT_MARKERS)
// DEBUG_ECHOLNPGM("repeat index: ", info.stored_repeat.index);
// for (uint8_t i = 0; i < info.stored_repeat.index; ++i)
// DEBUG_ECHOLNPGM("..... sdpos: ", info.stored_repeat.marker.sdpos, " count: ", info.stored_repeat.marker.counter);
//#endif
#if ENABLED(GCODE_REPEAT_MARKERS)
DEBUG_ECHOLNPGM("repeat index: ", info.stored_repeat.index);
for (uint8_t i = 0; i < info.stored_repeat.index; ++i)
DEBUG_ECHOLNPGM("..... sdpos: ", info.stored_repeat.marker.sdpos, " count: ", info.stored_repeat.marker.counter);
#endif

#if HAS_HOME_OFFSET
DEBUG_ECHOPGM("home_offset: ");
Expand Down
6 changes: 1 addition & 5 deletions Marlin/src/gcode/gcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -893,11 +893,7 @@ class GcodeSuite {

#if HAS_EXTRUDERS
static void M221();

#if ENABLED(E3S1PRO_RTS)
static void M221_report(const bool forReplay=true);
#endif

static void M221_report(const bool forReplay=true);
#endif

#if ENABLED(DIRECT_PIN_CONTROL)
Expand Down
3 changes: 1 addition & 2 deletions ini/stm32f4.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1008,8 +1008,7 @@ board_build.rename = firmware-{date}-{time}-E3S1Plus-ubl10x10-v004-F4
extends = env:STM32F401RC_creality
build_flags = ${stm32_variant.build_flags} -DMCU_STM32F401RC -DSTM32F4
-DSS_TIMER=4 -DTIMER_SERVO=TIM5
-DENABLE_HWSERIAL3 -DTRANSFER_CLOCK_DIV=8
-DLASER_FEATURE
-DENABLE_HWSERIAL3 -DTRANSFER_CLOCK_DIV=8
-DENDER_MACHINE_OVERRIDE
-DENDER_3S1
-DAUTO_BED_LEVELING_BILINEAR
Expand Down

0 comments on commit 7e6361a

Please sign in to comment.