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

Extend M106/M107 for better laser module support #16082

Merged
merged 33 commits into from
Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b8be593
Added LASER_SYNCHRONOUS_M106_M107 to all configs
DrywFiltiarn Dec 2, 2019
ee87a3d
Add sanity checks for LASER_SYNCHRONOUS_M106_M107
DrywFiltiarn Dec 2, 2019
00cde38
Implement logic for synchronous M106/M107 execute
DrywFiltiarn Dec 2, 2019
8ac0409
Corrected inline documentation
DrywFiltiarn Dec 2, 2019
87c1622
Exclude sync fan blocks in recalculations
DrywFiltiarn Dec 2, 2019
4d0b462
Update config comments, clean whitespace
thinkyhead Dec 3, 2019
f30a0a6
Basic fixes and cleanup
thinkyhead Dec 3, 2019
311b6c2
Basic elements of Tool Types
thinkyhead Dec 3, 2019
137e574
Merge latest upstream
thinkyhead Dec 4, 2019
f5d9768
Fix kickstart_fan method
thinkyhead Dec 4, 2019
a3062d6
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into bf2_fixup_l…
thinkyhead Jun 17, 2020
5534147
Cleanup after merge
thinkyhead Jun 17, 2020
5b47d64
More...
thinkyhead Jun 17, 2020
0e995a0
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into pr/16082
thinkyhead Nov 1, 2020
5fd5ee5
Fix BLOCK_MASK_SYNC
thinkyhead Nov 1, 2020
639e743
Fix a ternary typo
thinkyhead Nov 1, 2020
073cfe5
Drop extra file
thinkyhead Nov 1, 2020
e098037
Apply more HAS_FAN
thinkyhead Nov 1, 2020
a9e8c13
Merge branch 'bugfix-2.0.x' into bugfix-2.0.x
thinkyhead Nov 23, 2020
f9d0cc8
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into bf2_fixup_l…
thinkyhead Jan 7, 2021
bc3fb85
Move WRITE_FAN
thinkyhead Jan 7, 2021
b665b8a
Wrap tool as a class
thinkyhead Jan 8, 2021
d7f96a0
etc
thinkyhead Jan 11, 2021
85b7339
Fix calls, add test
thinkyhead Jan 11, 2021
21730e0
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into pr/16082
thinkyhead Jan 13, 2021
61b13bd
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into pr/16082
thinkyhead Jan 13, 2021
94533dc
Tool fixups
thinkyhead Jan 13, 2021
55fd3a4
No laser/spindle needed
thinkyhead Jan 13, 2021
3a7aae9
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into pr/16082
thinkyhead Mar 24, 2021
bd9a148
cleanup after merge
thinkyhead Mar 24, 2021
ccc537c
move macro
thinkyhead Mar 24, 2021
0814bd4
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into pr/16082
thinkyhead Mar 24, 2021
445109b
clean up after merge
thinkyhead Mar 24, 2021
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
12 changes: 12 additions & 0 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -3217,6 +3217,18 @@
#endif
#endif

/**
* Synchronous Laser Control with M106/M107
*
* Marlin normally applies M106/M107 fan speeds at a time "soon after" processing
* a planner block. This is too inaccurate for a PWM/TTL laser attached to the fan
* header (as with some add-on laser kits). Enable this option to set fan/laser
* speeds with much more exact timing for improved print fidelity.
*
* NOTE: This option sacrifices some cooling fan speed options.
*/
//#define LASER_SYNCHRONOUS_M106_M107

/**
* Coolant Control
*
Expand Down
18 changes: 13 additions & 5 deletions Marlin/src/gcode/temp/M106_M107.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#include "../../module/motion.h"
#include "../../module/temperature.h"

#if ENABLED(LASER_SYNCHRONOUS_M106_M107)
#include "../../module/planner.h"
#endif

#if PREHEAT_COUNT
#include "../../lcd/marlinui.h"
#endif
Expand Down Expand Up @@ -82,6 +86,8 @@ void GcodeSuite::M106() {
// Set speed, with constraint
thermalManager.set_fan_speed(pfan, speed);

TERN_(LASER_SYNCHRONOUS_M106_M107, planner.buffer_sync_block(BLOCK_FLAG_SYNC_FANS));

if (TERN0(DUAL_X_CARRIAGE, idex_is_duplicating())) // pfan == 0 when duplicating
thermalManager.set_fan_speed(1 - pfan, speed);
}
Expand All @@ -92,12 +98,14 @@ void GcodeSuite::M106() {
*/
void GcodeSuite::M107() {
const uint8_t pfan = parser.byteval('P', _ALT_P);
if (pfan < _CNT_P) {
thermalManager.set_fan_speed(pfan, 0);
if (pfan >= _CNT_P) return;

if (TERN0(DUAL_X_CARRIAGE, idex_is_duplicating())) // pfan == 0 when duplicating
thermalManager.set_fan_speed(1 - pfan, 0);
}
thermalManager.set_fan_speed(pfan, 0);

if (TERN0(DUAL_X_CARRIAGE, idex_is_duplicating())) // pfan == 0 when duplicating
thermalManager.set_fan_speed(1 - pfan, 0);

TERN_(LASER_SYNCHRONOUS_M106_M107, planner.buffer_sync_block(BLOCK_FLAG_SYNC_FANS));
}

#endif // HAS_FAN
11 changes: 11 additions & 0 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,17 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#error "To use BED_LIMIT_SWITCHING you must disable PIDTEMPBED."
#endif

/**
* Synchronous M106/M107 checks
*/
#if ENABLED(LASER_SYNCHRONOUS_M106_M107)
#if FAN_KICKSTART_TIME
#error "FAN_KICKSTART_TIME must be 0 with LASER_SYNCHRONOUS_M106_M107 (because the laser will always come on at FULL power)."
#elif FAN_MIN_PWM
#error "FAN_MIN_PWM must be 0 with LASER_SYNCHRONOUS_M106_M107 (otherwise the laser will never turn OFF)."
#endif
#endif

/**
* Chamber Heating Options - PID vs Limit Switching
*/
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ void MarlinUI::draw_status_screen() {
#endif
#endif // HAS_HEATED_BED

#if FAN_COUNT > 0
#if HAS_FAN
uint16_t spd = thermalManager.fan_speed[0];

#if ENABLED(ADAPTIVE_FAN_SLOWING)
Expand All @@ -783,7 +783,7 @@ void MarlinUI::draw_status_screen() {
else
picBits &= ~ICON_FAN;

#endif // FAN_COUNT > 0
#endif // HAS_FAN

//
// Line 9, 10 - icons
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/dwin/e3v2/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2152,7 +2152,7 @@ void HMI_SelectFile() {

card.openAndPrintFile(card.filename);

#if FAN_COUNT > 0
#if HAS_FAN
// All fans on for Ender 3 v2 ?
// The slicer should manage this for us.
//for (uint8_t i = 0; i < FAN_COUNT; i++)
Expand Down
29 changes: 16 additions & 13 deletions Marlin/src/lcd/marlinui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

#include "../inc/MarlinConfig.h"

#include "../MarlinCore.h" // for printingIsPaused

#ifdef LED_BACKLIGHT_TIMEOUT
#include "../feature/leds/leds.h"
#endif
Expand All @@ -39,21 +41,21 @@
MarlinUI ui;

#if HAS_DISPLAY
#include "../module/printcounter.h"
#include "../MarlinCore.h"
#include "../gcode/queue.h"
#include "fontutils.h"
#include "../sd/cardreader.h"
#endif

#if ENABLED(DWIN_CREALITY_LCD)
#include "../module/printcounter.h"
#include "../MarlinCore.h"
#include "dwin/e3v2/dwin.h"
#endif

#if HAS_STATUS_MESSAGE
#define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80U)
#if ENABLED(LCD_PROGRESS_BAR) && !IS_TFTGLCD_PANEL
#define BASIC_PROGRESS_BAR 1
#endif

#if ANY(HAS_DISPLAY, HAS_STATUS_MESSAGE, BASIC_PROGRESS_BAR)
#include "../module/printcounter.h"
#endif

#if LCD_HAS_WAIT_FOR_MOVE
Expand Down Expand Up @@ -535,7 +537,7 @@ bool MarlinUI::get_blink() {
* This is very display-dependent, so the lcd implementation draws this.
*/

#if ENABLED(LCD_PROGRESS_BAR) && !IS_TFTGLCD_PANEL
#if BASIC_PROGRESS_BAR
millis_t MarlinUI::progress_bar_ms; // = 0
#if PROGRESS_MSG_EXPIRE > 0
millis_t MarlinUI::expire_status_ms; // = 0
Expand All @@ -546,7 +548,7 @@ void MarlinUI::status_screen() {

TERN_(HAS_LCD_MENU, ENCODER_RATE_MULTIPLY(false));

#if ENABLED(LCD_PROGRESS_BAR) && !IS_TFTGLCD_PANEL
#if BASIC_PROGRESS_BAR

//
// HD44780 implements the following message blinking and
Expand Down Expand Up @@ -586,7 +588,7 @@ void MarlinUI::status_screen() {

#endif // PROGRESS_MSG_EXPIRE

#endif // LCD_PROGRESS_BAR
#endif // BASIC_PROGRESS_BAR

#if HAS_LCD_MENU
if (use_click()) {
Expand Down Expand Up @@ -1353,6 +1355,7 @@ void MarlinUI::update() {
/**
* Reset the status message
*/

void MarlinUI::reset_status(const bool no_welcome) {
#if SERVICE_INTERVAL_1 > 0
static PGMSTR(service1, "> " SERVICE_NAME_1 "!");
Expand Down Expand Up @@ -1438,17 +1441,17 @@ void MarlinUI::update() {

void MarlinUI::finish_status(const bool persist) {

#if HAS_SPI_LCD
#if HAS_WIRED_LCD

#if !(ENABLED(LCD_PROGRESS_BAR) && (PROGRESS_MSG_EXPIRE) > 0)
#if !(BASIC_PROGRESS_BAR && (PROGRESS_MSG_EXPIRE) > 0)
UNUSED(persist);
#endif

#if ENABLED(LCD_PROGRESS_BAR) || BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT)
const millis_t ms = millis();
#endif

#if ENABLED(LCD_PROGRESS_BAR)
#if BASIC_PROGRESS_BAR
progress_bar_ms = ms;
#if PROGRESS_MSG_EXPIRE > 0
expire_status_ms = persist ? 0 : ms + PROGRESS_MSG_EXPIRE;
Expand All @@ -1462,7 +1465,7 @@ void MarlinUI::update() {
#if ENABLED(STATUS_MESSAGE_SCROLLING)
status_scroll_offset = 0;
#endif
#else // HAS_SPI_LCD
#else // HAS_WIRED_LCD
UNUSED(persist);
#endif

Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/lcd/marlinui.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
#include "../module/motion.h" // for active_extruder
#endif

#define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80U)

#if HAS_WIRED_LCD

enum LCDViewAction : uint8_t {
Expand Down
Loading