Skip to content

Commit 4342798

Browse files
thinkyheadSebazzz
andcommitted
Creality CR-6 SE code, examples
Co-Authored-By: Sebastiaan Dammann <sebastiaandammann@outlook.com>
1 parent 6071a08 commit 4342798

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+3796
-27
lines changed

Marlin/Configuration.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2170,6 +2170,11 @@
21702170
//#define DGUS_LCD_UI_FYSETC
21712171
//#define DGUS_LCD_UI_HIPRECY
21722172

2173+
//
2174+
// CR-6 OEM touch screen. A DWIN display with touch.
2175+
//
2176+
//#define DGUS_LCD_UI_CREALITY_TOUCH
2177+
21732178
//
21742179
// Touch-screen LCD for Malyan M200/M300 printers
21752180
//

Marlin/src/HAL/STM32F1/HAL.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@
109109
#else
110110
#error "LCD_SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration."
111111
#endif
112+
#if HAS_DGUS_LCD
113+
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
114+
#endif
112115
#endif
113116

114117
// Set interrupt grouping for this MCU

Marlin/src/HAL/STM32F1/watchdog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* 625 reload value (counts down to 0)
3333
* use 1250 for 8 seconds
3434
*/
35-
#define STM32F1_WD_RELOAD 625
35+
#define STM32F1_WD_RELOAD 625 // Note CR-6 requires 1250 but the watchdog is disabled anyway?
3636

3737
// Arduino STM32F1 core now has watchdog support
3838

Marlin/src/MarlinCore.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include "core/utility.h"
4646
#include "module/motion.h"
4747
#include "module/planner.h"
48+
#include "module/probe.h"
4849
#include "module/endstops.h"
4950
#include "module/temperature.h"
5051
#include "module/settings.h"
@@ -60,6 +61,7 @@
6061
#include "sd/cardreader.h"
6162

6263
#include "lcd/marlinui.h"
64+
6365
#if HAS_TOUCH_XPT2046
6466
#include "lcd/touch/touch_buttons.h"
6567
#endif
@@ -77,6 +79,10 @@
7779
#include "lcd/dwin/e3v2/rotary_encoder.h"
7880
#endif
7981

82+
#if ENABLED(EXTENSIBLE_UI)
83+
#include "lcd/extui/ui_api.h"
84+
#endif
85+
8086
#if HAS_ETHERNET
8187
#include "feature/ethernet.h"
8288
#endif
@@ -356,6 +362,8 @@ void enable_all_steppers() {
356362
ENABLE_AXIS_Y();
357363
ENABLE_AXIS_Z();
358364
enable_e_steppers();
365+
366+
TERN_(EXTENSIBLE_UI, ExtUI::onSteppersEnabled());
359367
}
360368

361369
void disable_e_steppers() {
@@ -375,6 +383,8 @@ void disable_all_steppers() {
375383
DISABLE_AXIS_Y();
376384
DISABLE_AXIS_Z();
377385
disable_e_steppers();
386+
387+
TERN_(EXTENSIBLE_UI, ExtUI::onSteppersDisabled());
378388
}
379389

380390
#if ENABLED(G29_RETRY_AND_RECOVER)
@@ -751,6 +761,16 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
751761
// Handle UI input / draw events
752762
TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update());
753763

764+
#if PIN_EXISTS(OPTO_SWITCH)
765+
static bool optoSwitch;
766+
const bool opto = READ(OPTO_SWITCH_PIN);
767+
if (optoSwitch != opto) {
768+
optoSwitch = opto;
769+
//SERIAL_ECHOLNPAIR("Opto switch says: ", opto);
770+
}
771+
if (is_homing_z) endstops.enable_z_probe(!opto);
772+
#endif
773+
754774
// Run i2c Position Encoders
755775
#if ENABLED(I2C_POSITION_ENCODERS)
756776
static millis_t i2cpem_next_update_ms;
@@ -1090,6 +1110,16 @@ void setup() {
10901110
SETUP_RUN(ui.reset_status()); // Load welcome message early. (Retained if no errors exist.)
10911111
#endif
10921112

1113+
#if PIN_EXISTS(COM)
1114+
SETUP_LOG("Init COM_PIN");
1115+
OUT_WRITE(COM_PIN, HIGH);
1116+
#endif
1117+
1118+
#if PIN_EXISTS(OPTO_SWITCH)
1119+
SETUP_LOG("Init OPTO_SWITCH_PIN");
1120+
SET_INPUT(OPTO_SWITCH_PIN);
1121+
#endif
1122+
10931123
#if BOTH(SDSUPPORT, SDCARD_EEPROM_EMULATION)
10941124
SETUP_RUN(card.mount()); // Mount media with settings before first_load
10951125
#endif

Marlin/src/core/boards.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@
326326
#define BOARD_TRIGORILLA_PRO 4037 // Trigorilla Pro (STM32F103ZET6)
327327
#define BOARD_FLY_MINI 4038 // FLY MINI (STM32F103RCT6)
328328
#define BOARD_FLSUN_HISPEED 4039 // FLSUN HiSpeedV1 (STM32F103VET6)
329+
#define BOARD_CREALITY_V452 4040 // Creality v4.5.2 (STM32F103RE)
329330

330331
//
331332
// ARM Cortex-M4F

Marlin/src/gcode/bedlevel/abl/G29.cpp

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
#include "../../../module/temperature.h"
4242
#endif
4343

44+
#if ENABLED(AUTOLEVEL_NEEDS_PREHEATING)
45+
#include "../../../module/temperature.h"
46+
#endif
47+
4448
#if HAS_DISPLAY
4549
#include "../../../lcd/marlinui.h"
4650
#endif
@@ -177,6 +181,21 @@ G29_TYPE GcodeSuite::G29() {
177181
if (DISABLED(PROBE_MANUALLY) && seenQ) G29_RETURN(false);
178182
#endif
179183

184+
TERN_(EXTENSIBLE_UI, ExtUI::onMeshLevelingStart());
185+
186+
#if ENABLED(AUTOLEVEL_NEEDS_PREHEATING)
187+
{
188+
uint16_t hotendTemperature = AUTOLEVEL_PREHEAT_NOZZLE_TEMP,
189+
bedTemperature = AUTOLEVEL_PREHEAT_BED_TEMP;
190+
SERIAL_ECHOLNPAIR("Preheating hot-end to ", hotendTemperature);
191+
SERIAL_ECHOLNPAIR("Preheating bed to ", bedTemperature);
192+
thermalManager.setTargetHotend(hotendTemperature, 0);
193+
thermalManager.setTargetBed(bedTemperature);
194+
thermalManager.wait_for_hotend(0);
195+
thermalManager.wait_for_bed_heating();
196+
}
197+
#endif
198+
180199
const bool seenA = TERN0(PROBE_MANUALLY, parser.seen('A')),
181200
no_action = seenA || seenQ,
182201
faux = ENABLED(DEBUG_LEVELING_FEATURE) && DISABLED(PROBE_MANUALLY) ? parser.boolval('C') : no_action;
@@ -392,6 +411,10 @@ G29_TYPE GcodeSuite::G29() {
392411

393412
planner.synchronize();
394413

414+
#if ENABLED(FIX_MOUNTED_PROBE)
415+
do_blocking_move_to_z(_MAX(Z_CLEARANCE_BETWEEN_PROBES, Z_CLEARANCE_DEPLOY_PROBE));
416+
#endif
417+
395418
if (!faux) remember_feedrate_scaling_off();
396419

397420
// Disable auto bed leveling during G29.
@@ -588,8 +611,7 @@ G29_TYPE GcodeSuite::G29() {
588611
measured_z = 0;
589612

590613
#if ABL_GRID
591-
592-
bool zig = PR_OUTER_END & 1; // Always end at RIGHT and BACK_PROBE_BED_POSITION
614+
bool zig = PR_OUTER_END & 1; // Always end at RIGHT and BACK_PROBE_BED_POSITION
593615

594616
measured_z = 0;
595617

@@ -656,8 +678,11 @@ G29_TYPE GcodeSuite::G29() {
656678

657679
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
658680

659-
z_values[meshCount.x][meshCount.y] = measured_z + zoffset;
660-
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(meshCount, z_values[meshCount.x][meshCount.y]));
681+
#if ENABLED(EXTENSIBLE_UI)
682+
const float z = z_values[meshCount.x][meshCount.y] = measured_z + zoffset;
683+
ExtUI::onMeshUpdate(meshCount, z);
684+
ExtUI::onMeshCallback(meshCount, z);
685+
#endif
661686

662687
#endif
663688

Marlin/src/gcode/calibrate/G28.cpp

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
#include "../../lcd/dwin/e3v2/dwin.h"
5151
#endif
5252

53+
#if ENABLED(EXTENSIBLE_UI)
54+
#include "../../lcd/extui/ui_api.h"
55+
#endif
56+
5357
#if HAS_L64XX // set L6470 absolute position registers to counts
5458
#include "../../libs/L64XX/L64XX_Marlin.h"
5559
#endif
@@ -61,6 +65,8 @@
6165
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
6266
#include "../../core/debug_out.h"
6367

68+
bool is_homing, is_homing_z; // = false
69+
6470
#if ENABLED(QUICK_HOME)
6571

6672
static void quick_home_xy() {
@@ -209,6 +215,10 @@ void GcodeSuite::G28() {
209215

210216
TERN_(DWIN_CREALITY_LCD, HMI_flag.home_flag = true);
211217

218+
TERN_(EXTENSIBLE_UI, ExtUI::onHomingStart());
219+
220+
is_homing = true;
221+
212222
#if ENABLED(DUAL_X_CARRIAGE)
213223
bool IDEX_saved_duplication_state = extruder_duplication_enabled;
214224
DualXMode IDEX_saved_mode = dual_x_carriage_mode;
@@ -324,11 +334,13 @@ void GcodeSuite::G28() {
324334
? 0
325335
: (parser.seenval('R') ? parser.value_linear_units() : Z_HOMING_HEIGHT);
326336

327-
if (z_homing_height && (doX || doY || (ENABLED(Z_SAFE_HOMING) && doZ))) {
328-
// Raise Z before homing any other axes and z is not already high enough (never lower z)
329-
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Raise Z (before homing) by ", z_homing_height);
330-
do_z_clearance(z_homing_height, true, DISABLED(UNKNOWN_Z_NO_RAISE));
331-
}
337+
if (z_homing_height && (doX || doY || (ENABLED(Z_SAFE_HOMING) && doZ))) {
338+
// Raise Z before homing any other axes and z is not already high enough (never lower z)
339+
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Raise Z (before homing) by ", z_homing_height);
340+
do_z_clearance(z_homing_height, true, DISABLED(UNKNOWN_Z_NO_RAISE));
341+
}
342+
343+
is_homing = false;
332344

333345
#if ENABLED(QUICK_HOME)
334346

@@ -463,6 +475,12 @@ void GcodeSuite::G28() {
463475

464476
TERN_(DWIN_CREALITY_LCD, DWIN_CompletedHoming());
465477

478+
TERN_(FIX_MOUNTED_PROBE, endstops.enable_z_probe(false));
479+
480+
TERN_(EXTENSIBLE_UI, ExtUI::onHomingComplete());
481+
482+
is_homing_z = false;
483+
466484
report_current_position();
467485

468486
if (ENABLED(NANODLP_Z_SYNC) && (doZ || ENABLED(NANODLP_ALL_AXIS)))

Marlin/src/gcode/gcode.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ GcodeSuite gcode;
6161
#include "../feature/password/password.h"
6262
#endif
6363

64+
#if ENABLED(FIX_MOUNTED_PROBE)
65+
#include "../feature/bedlevel/bedlevel.h"
66+
#endif
67+
6468
#include "../MarlinCore.h" // for idle()
6569

6670
// Inactivity shutdown
@@ -307,7 +311,11 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
307311
case 27: G27(); break; // G27: Nozzle Park
308312
#endif
309313

310-
case 28: G28(); break; // G28: Home one or more axes
314+
case 28:
315+
G28(); // G28: Home one or more axes
316+
TERN_(FIX_MOUNTED_PROBE, set_bed_leveling_enabled(true));
317+
break;
318+
311319

312320
#if HAS_LEVELING
313321
case 29: // G29: Bed leveling calibration

Marlin/src/gcode/gcode.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@
298298
#include "../inc/MarlinConfig.h"
299299
#include "parser.h"
300300

301+
extern bool is_homing, is_homing_z;
302+
301303
#if ENABLED(I2C_POSITION_ENCODERS)
302304
#include "../feature/encoder_i2c.h"
303305
#endif

Marlin/src/gcode/geometry/M206_M428.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
#include "../../libs/buzzer.h"
3131
#include "../../MarlinCore.h"
3232

33+
#if ENABLED(EXTENSIBLE_UI)
34+
#include "../../lcd/extui/ui_api.h"
35+
#endif
36+
3337
extern const char SP_Y_STR[], SP_Z_STR[];
3438

3539
void m206_report() {

0 commit comments

Comments
 (0)