Skip to content

Commit

Permalink
Creality CR-6 SE code, examples
Browse files Browse the repository at this point in the history
Co-Authored-By: Sebastiaan Dammann <[email protected]>
  • Loading branch information
thinkyhead and Sebazzz committed Oct 31, 2020
1 parent 6071a08 commit 4342798
Show file tree
Hide file tree
Showing 47 changed files with 3,796 additions and 27 deletions.
5 changes: 5 additions & 0 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -2170,6 +2170,11 @@
//#define DGUS_LCD_UI_FYSETC
//#define DGUS_LCD_UI_HIPRECY

//
// CR-6 OEM touch screen. A DWIN display with touch.
//
//#define DGUS_LCD_UI_CREALITY_TOUCH

//
// Touch-screen LCD for Malyan M200/M300 printers
//
Expand Down
3 changes: 3 additions & 0 deletions Marlin/src/HAL/STM32F1/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@
#else
#error "LCD_SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration."
#endif
#if HAS_DGUS_LCD
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
#endif
#endif

// Set interrupt grouping for this MCU
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/STM32F1/watchdog.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* 625 reload value (counts down to 0)
* use 1250 for 8 seconds
*/
#define STM32F1_WD_RELOAD 625
#define STM32F1_WD_RELOAD 625 // Note CR-6 requires 1250 but the watchdog is disabled anyway?

// Arduino STM32F1 core now has watchdog support

Expand Down
30 changes: 30 additions & 0 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "core/utility.h"
#include "module/motion.h"
#include "module/planner.h"
#include "module/probe.h"
#include "module/endstops.h"
#include "module/temperature.h"
#include "module/settings.h"
Expand All @@ -60,6 +61,7 @@
#include "sd/cardreader.h"

#include "lcd/marlinui.h"

#if HAS_TOUCH_XPT2046
#include "lcd/touch/touch_buttons.h"
#endif
Expand All @@ -77,6 +79,10 @@
#include "lcd/dwin/e3v2/rotary_encoder.h"
#endif

#if ENABLED(EXTENSIBLE_UI)
#include "lcd/extui/ui_api.h"
#endif

#if HAS_ETHERNET
#include "feature/ethernet.h"
#endif
Expand Down Expand Up @@ -356,6 +362,8 @@ void enable_all_steppers() {
ENABLE_AXIS_Y();
ENABLE_AXIS_Z();
enable_e_steppers();

TERN_(EXTENSIBLE_UI, ExtUI::onSteppersEnabled());
}

void disable_e_steppers() {
Expand All @@ -375,6 +383,8 @@ void disable_all_steppers() {
DISABLE_AXIS_Y();
DISABLE_AXIS_Z();
disable_e_steppers();

TERN_(EXTENSIBLE_UI, ExtUI::onSteppersDisabled());
}

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

#if PIN_EXISTS(OPTO_SWITCH)
static bool optoSwitch;
const bool opto = READ(OPTO_SWITCH_PIN);
if (optoSwitch != opto) {
optoSwitch = opto;
//SERIAL_ECHOLNPAIR("Opto switch says: ", opto);
}
if (is_homing_z) endstops.enable_z_probe(!opto);
#endif

// Run i2c Position Encoders
#if ENABLED(I2C_POSITION_ENCODERS)
static millis_t i2cpem_next_update_ms;
Expand Down Expand Up @@ -1090,6 +1110,16 @@ void setup() {
SETUP_RUN(ui.reset_status()); // Load welcome message early. (Retained if no errors exist.)
#endif

#if PIN_EXISTS(COM)
SETUP_LOG("Init COM_PIN");
OUT_WRITE(COM_PIN, HIGH);
#endif

#if PIN_EXISTS(OPTO_SWITCH)
SETUP_LOG("Init OPTO_SWITCH_PIN");
SET_INPUT(OPTO_SWITCH_PIN);
#endif

#if BOTH(SDSUPPORT, SDCARD_EEPROM_EMULATION)
SETUP_RUN(card.mount()); // Mount media with settings before first_load
#endif
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/core/boards.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@
#define BOARD_TRIGORILLA_PRO 4037 // Trigorilla Pro (STM32F103ZET6)
#define BOARD_FLY_MINI 4038 // FLY MINI (STM32F103RCT6)
#define BOARD_FLSUN_HISPEED 4039 // FLSUN HiSpeedV1 (STM32F103VET6)
#define BOARD_CREALITY_V452 4040 // Creality v4.5.2 (STM32F103RE)

//
// ARM Cortex-M4F
Expand Down
33 changes: 29 additions & 4 deletions Marlin/src/gcode/bedlevel/abl/G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
#include "../../../module/temperature.h"
#endif

#if ENABLED(AUTOLEVEL_NEEDS_PREHEATING)
#include "../../../module/temperature.h"
#endif

#if HAS_DISPLAY
#include "../../../lcd/marlinui.h"
#endif
Expand Down Expand Up @@ -177,6 +181,21 @@ G29_TYPE GcodeSuite::G29() {
if (DISABLED(PROBE_MANUALLY) && seenQ) G29_RETURN(false);
#endif

TERN_(EXTENSIBLE_UI, ExtUI::onMeshLevelingStart());

#if ENABLED(AUTOLEVEL_NEEDS_PREHEATING)
{
uint16_t hotendTemperature = AUTOLEVEL_PREHEAT_NOZZLE_TEMP,
bedTemperature = AUTOLEVEL_PREHEAT_BED_TEMP;
SERIAL_ECHOLNPAIR("Preheating hot-end to ", hotendTemperature);
SERIAL_ECHOLNPAIR("Preheating bed to ", bedTemperature);
thermalManager.setTargetHotend(hotendTemperature, 0);
thermalManager.setTargetBed(bedTemperature);
thermalManager.wait_for_hotend(0);
thermalManager.wait_for_bed_heating();
}
#endif

const bool seenA = TERN0(PROBE_MANUALLY, parser.seen('A')),
no_action = seenA || seenQ,
faux = ENABLED(DEBUG_LEVELING_FEATURE) && DISABLED(PROBE_MANUALLY) ? parser.boolval('C') : no_action;
Expand Down Expand Up @@ -392,6 +411,10 @@ G29_TYPE GcodeSuite::G29() {

planner.synchronize();

#if ENABLED(FIX_MOUNTED_PROBE)
do_blocking_move_to_z(_MAX(Z_CLEARANCE_BETWEEN_PROBES, Z_CLEARANCE_DEPLOY_PROBE));
#endif

if (!faux) remember_feedrate_scaling_off();

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

#if ABL_GRID

bool zig = PR_OUTER_END & 1; // Always end at RIGHT and BACK_PROBE_BED_POSITION
bool zig = PR_OUTER_END & 1; // Always end at RIGHT and BACK_PROBE_BED_POSITION

measured_z = 0;

Expand Down Expand Up @@ -656,8 +678,11 @@ G29_TYPE GcodeSuite::G29() {

#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)

z_values[meshCount.x][meshCount.y] = measured_z + zoffset;
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(meshCount, z_values[meshCount.x][meshCount.y]));
#if ENABLED(EXTENSIBLE_UI)
const float z = z_values[meshCount.x][meshCount.y] = measured_z + zoffset;
ExtUI::onMeshUpdate(meshCount, z);
ExtUI::onMeshCallback(meshCount, z);
#endif

#endif

Expand Down
28 changes: 23 additions & 5 deletions Marlin/src/gcode/calibrate/G28.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
#include "../../lcd/dwin/e3v2/dwin.h"
#endif

#if ENABLED(EXTENSIBLE_UI)
#include "../../lcd/extui/ui_api.h"
#endif

#if HAS_L64XX // set L6470 absolute position registers to counts
#include "../../libs/L64XX/L64XX_Marlin.h"
#endif
Expand All @@ -61,6 +65,8 @@
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../../core/debug_out.h"

bool is_homing, is_homing_z; // = false

#if ENABLED(QUICK_HOME)

static void quick_home_xy() {
Expand Down Expand Up @@ -209,6 +215,10 @@ void GcodeSuite::G28() {

TERN_(DWIN_CREALITY_LCD, HMI_flag.home_flag = true);

TERN_(EXTENSIBLE_UI, ExtUI::onHomingStart());

is_homing = true;

#if ENABLED(DUAL_X_CARRIAGE)
bool IDEX_saved_duplication_state = extruder_duplication_enabled;
DualXMode IDEX_saved_mode = dual_x_carriage_mode;
Expand Down Expand Up @@ -324,11 +334,13 @@ void GcodeSuite::G28() {
? 0
: (parser.seenval('R') ? parser.value_linear_units() : Z_HOMING_HEIGHT);

if (z_homing_height && (doX || doY || (ENABLED(Z_SAFE_HOMING) && doZ))) {
// Raise Z before homing any other axes and z is not already high enough (never lower z)
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Raise Z (before homing) by ", z_homing_height);
do_z_clearance(z_homing_height, true, DISABLED(UNKNOWN_Z_NO_RAISE));
}
if (z_homing_height && (doX || doY || (ENABLED(Z_SAFE_HOMING) && doZ))) {
// Raise Z before homing any other axes and z is not already high enough (never lower z)
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Raise Z (before homing) by ", z_homing_height);
do_z_clearance(z_homing_height, true, DISABLED(UNKNOWN_Z_NO_RAISE));
}

is_homing = false;

#if ENABLED(QUICK_HOME)

Expand Down Expand Up @@ -463,6 +475,12 @@ void GcodeSuite::G28() {

TERN_(DWIN_CREALITY_LCD, DWIN_CompletedHoming());

TERN_(FIX_MOUNTED_PROBE, endstops.enable_z_probe(false));

TERN_(EXTENSIBLE_UI, ExtUI::onHomingComplete());

is_homing_z = false;

report_current_position();

if (ENABLED(NANODLP_Z_SYNC) && (doZ || ENABLED(NANODLP_ALL_AXIS)))
Expand Down
10 changes: 9 additions & 1 deletion Marlin/src/gcode/gcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ GcodeSuite gcode;
#include "../feature/password/password.h"
#endif

#if ENABLED(FIX_MOUNTED_PROBE)
#include "../feature/bedlevel/bedlevel.h"
#endif

#include "../MarlinCore.h" // for idle()

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

case 28: G28(); break; // G28: Home one or more axes
case 28:
G28(); // G28: Home one or more axes
TERN_(FIX_MOUNTED_PROBE, set_bed_leveling_enabled(true));
break;


#if HAS_LEVELING
case 29: // G29: Bed leveling calibration
Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/gcode/gcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@
#include "../inc/MarlinConfig.h"
#include "parser.h"

extern bool is_homing, is_homing_z;

#if ENABLED(I2C_POSITION_ENCODERS)
#include "../feature/encoder_i2c.h"
#endif
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/gcode/geometry/M206_M428.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
#include "../../libs/buzzer.h"
#include "../../MarlinCore.h"

#if ENABLED(EXTENSIBLE_UI)
#include "../../lcd/extui/ui_api.h"
#endif

extern const char SP_Y_STR[], SP_Z_STR[];

void m206_report() {
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/gcode/lcd/M300.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
#include "../../lcd/marlinui.h" // i2c-based BUZZ
#include "../../libs/buzzer.h" // Buzzer, if possible

#if ENABLED(EXTENSIBLE_UI)
#include "../../lcd/extui/ui_api.h"
#endif

/**
* M300: Play beep sound S<frequency Hz> P<duration ms>
*/
Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/gcode/sd/M1001.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ void GcodeSuite::M1001() {
queue.inject_P(PSTR(SD_FINISHED_RELEASECOMMAND));
#endif

TERN_(EXTENSIBLE_UI, ExtUI::onPrintFinished());

// Re-select the last printed file in the UI
TERN_(SD_REPRINT_LAST_SELECTED_FILE, ui.reselect_last_file());
}
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@
#endif

// Aliases for LCD features
#if ANY(DGUS_LCD_UI_ORIGIN, DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY)
#if ANY(DGUS_LCD_UI_ORIGIN, DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY, DGUS_LCD_UI_CREALITY_TOUCH)
#define HAS_DGUS_LCD 1
#endif

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -2205,7 +2205,7 @@
#define HAS_TEMPERATURE 1
#endif

#if HAS_TEMPERATURE && EITHER(HAS_LCD_MENU, DWIN_CREALITY_LCD)
#if HAS_TEMPERATURE && ANY(HAS_LCD_MENU, DWIN_CREALITY_LCD, DGUS_LCD_UI_CREALITY_TOUCH)
#ifdef PREHEAT_5_LABEL
#define PREHEAT_COUNT 5
#elif defined(PREHEAT_4_LABEL)
Expand Down Expand Up @@ -2615,7 +2615,7 @@
#endif

// Number of VFAT entries used. Each entry has 13 UTF-16 characters
#if EITHER(SCROLL_LONG_FILENAMES, DWIN_CREALITY_LCD)
#if ANY(SCROLL_LONG_FILENAMES, DWIN_CREALITY_LCD, DWIN_CREALITY_TOUCHLCD)
#define MAX_VFAT_ENTRIES (5)
#else
#define MAX_VFAT_ENTRIES (2)
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -2248,6 +2248,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
+ ENABLED(MKS_LCD12864) \
+ ENABLED(OLED_PANEL_TINYBOY2) \
+ ENABLED(OVERLORD_OLED) \
+ ENABLED(DGUS_LCD_UI_CREALITY_TOUCH) \
+ ENABLED(PANEL_ONE) \
+ ENABLED(RA_CONTROL_PANEL) \
+ ENABLED(RADDS_DISPLAY) \
Expand Down
7 changes: 7 additions & 0 deletions Marlin/src/lcd/extui/anycubic_chiron_lcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ namespace ExtUI {
void onUserConfirmRequired(const char * const msg) { Chiron.ConfirmationRequest(msg); }
void onStatusChanged(const char * const msg) { Chiron.StatusChange(msg); }

void onHomingStart() {}
void onHomingComplete() {}
void onPrintFinished() {}

void onFactoryReset() {}

void onStoreSettings(char *buff) {
Expand Down Expand Up @@ -116,6 +120,9 @@ namespace ExtUI {
// Called for temperature PID tuning result
}
#endif

void onSteppersDisabled() {}
void onSteppersEnabled() {}
}

#endif // ANYCUBIC_LCD_CHIRON
8 changes: 8 additions & 0 deletions Marlin/src/lcd/extui/anycubic_i3mega_lcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ namespace ExtUI {
void onFilamentRunout(const extruder_t extruder) { AnycubicTFT.OnFilamentRunout(); }
void onUserConfirmRequired(const char * const msg) { AnycubicTFT.OnUserConfirmRequired(msg); }
void onStatusChanged(const char * const msg) {}

void onHomingStart() {}
void onHomingComplete() {}
void onPrintFinished() {}

void onFactoryReset() {}

void onStoreSettings(char *buff) {
Expand Down Expand Up @@ -99,6 +104,9 @@ namespace ExtUI {
// Called for temperature PID tuning result
}
#endif

void onSteppersDisabled() {}
void onSteppersEnabled() {}
}

#endif // ANYCUBIC_LCD_I3MEGA
Loading

0 comments on commit 4342798

Please sign in to comment.