Skip to content

Commit

Permalink
Creality CR-6 SE pins, controller, probe, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Nov 6, 2020
1 parent 90abea2 commit b4814c0
Show file tree
Hide file tree
Showing 35 changed files with 3,728 additions and 24 deletions.
26 changes: 24 additions & 2 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,12 @@
*/
//#define FIX_MOUNTED_PROBE

/**
* Use the nozzle as the probe, with the hotend
* assembly attached to a sensitive strain gauge.
*/
//#define STRAIN_GAUGE_PROBE

/**
* Use the nozzle as the probe, as with a conductive
* nozzle system or a piezo-electric smart effector.
Expand Down Expand Up @@ -1251,10 +1257,21 @@
//#define MESH_BED_LEVELING

/**
* Normally G28 leaves leveling disabled on completion. Enable
* this option to have G28 restore the prior leveling state.
* Normally G28 leaves leveling disabled on completion. Enable one of
* these options to restore the prior leveling state or to always enable
* leveling immediately after G28.
*/
//#define RESTORE_LEVELING_AFTER_G28
//#define ENABLE_LEVELING_AFTER_G28

/**
* Auto-leveling needs preheating
*/
//#define PREHEAT_BEFORE_LEVELING
#if ENABLED(PREHEAT_BEFORE_LEVELING)
#define LEVELING_NOZZLE_TEMP 120
#define LEVELING_BED_TEMP 50
#endif

/**
* Enable detailed logging of G28, G29, M48, etc.
Expand Down Expand Up @@ -2178,6 +2195,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
23 changes: 23 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 Down Expand Up @@ -759,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 ENABLED(STRAIN_GAUGE_PROBE) && PIN_EXISTS(OPTO_SWITCH)
static bool optoSwitch;
const bool opto = READ(OPTO_SWITCH_PIN);
if (optoSwitch != opto) {
optoSwitch = opto;
//DEBUG_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 @@ -1098,6 +1110,17 @@ void setup() {
SETUP_RUN(ui.reset_status()); // Load welcome message early. (Retained if no errors exist.)
#endif

#if ENABLED(STRAIN_GAUGE_PROBE)
#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
#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
20 changes: 20 additions & 0 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(PREHEAT_BEFORE_LEVELING)
#include "../../../module/temperature.h"
#endif

#if HAS_DISPLAY
#include "../../../lcd/marlinui.h"
#endif
Expand Down Expand Up @@ -179,6 +183,18 @@ G29_TYPE GcodeSuite::G29() {

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

#if ENABLED(PREHEAT_BEFORE_LEVELING)
{
constexpr uint16_t hotendPreheat = LEVELING_NOZZLE_TEMP, bedPreheat = LEVELING_BED_TEMP;
if (DEBUGGING(LEVELING))
DEBUG_ECHOLNPAIR("Preheating hotend (", hotendPreheat, ") and bed (", bedPreheat, ")");
thermalManager.setTargetHotend(hotendPreheat, 0);
thermalManager.setTargetBed(bedPreheat);
if (hotendPreheat) thermalManager.wait_for_hotend(0);
if (bedPreheat) 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 @@ -394,6 +410,10 @@ G29_TYPE GcodeSuite::G29() {

planner.synchronize();

#if ENABLED(STRAIN_GAUGE_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
35 changes: 23 additions & 12 deletions Marlin/src/gcode/calibrate/G28.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../../core/debug_out.h"

#if ENABLED(STRAIN_GAUGE_PROBE)
bool is_homing, is_homing_z; // = false
#endif

#if ENABLED(QUICK_HOME)

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

TERN_(LASER_MOVE_G28_OFF, cutter.set_inline_enabled(false)); // turn off laser

TERN_(DWIN_CREALITY_LCD, HMI_flag.home_flag = true);

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

#if ENABLED(DUAL_X_CARRIAGE)
bool IDEX_saved_duplication_state = extruder_duplication_enabled;
DualXMode IDEX_saved_mode = dual_x_carriage_mode;
Expand All @@ -236,20 +236,25 @@ void GcodeSuite::G28() {
return;
}

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

TERN_(STRAIN_GAUGE_PROBE, is_homing = true);

planner.synchronize(); // Wait for planner moves to finish!

SET_SOFT_ENDSTOP_LOOSE(false); // Reset a leftover 'loose' motion state

// Disable the leveling matrix before homing
#if HAS_LEVELING

// Cancel the active G29 session
TERN_(PROBE_MANUALLY, g29_in_progress = false);

TERN_(RESTORE_LEVELING_AFTER_G28, const bool leveling_was_active = planner.leveling_active);
TERN_(PROBE_MANUALLY, g29_in_progress = false); // Cancel the active G29 session
const bool leveling_restore_state = ENABLED(ENABLE_LEVELING_AFTER_G28) || TERN0(RESTORE_LEVELING_AFTER_G28, planner.leveling_active);
set_bed_leveling_enabled(false);
#else
constexpr bool leveling_restore_state = false;
#endif

// Reset to the XY plane
TERN_(CNC_WORKSPACE_PLANES, workspace_plane = PLANE_XY);

// Count this command as movement / activity
Expand Down Expand Up @@ -336,6 +341,8 @@ void GcodeSuite::G28() {
do_z_clearance(z_homing_height, true, DISABLED(UNKNOWN_Z_NO_RAISE));
}

TERN_(STRAIN_GAUGE_PROBE, is_homing = false);

#if ENABLED(QUICK_HOME)

if (doX && doY) quick_home_xy();
Expand Down Expand Up @@ -430,6 +437,11 @@ void GcodeSuite::G28() {

#endif // DUAL_X_CARRIAGE

#if ENABLED(STRAIN_GAUGE_PROBE)
endstops.enable_z_probe(false);
is_homing_z = false;
#endif

endstops.not_homing();

// Clear endstop state for polled stallGuard endstops
Expand All @@ -440,8 +452,6 @@ void GcodeSuite::G28() {
do_blocking_move_to_z(delta_clip_start_height);
#endif

TERN_(RESTORE_LEVELING_AFTER_G28, set_bed_leveling_enabled(leveling_was_active));

restore_feedrate_and_scaling();

// Restore the active tool after homing
Expand All @@ -465,10 +475,11 @@ void GcodeSuite::G28() {
#endif
#endif

TERN_(HAS_LEVELING, set_bed_leveling_enabled(leveling_restore_state));

ui.refresh();

TERN_(DWIN_CREALITY_LCD, DWIN_CompletedHoming());

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

report_current_position();
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
7 changes: 6 additions & 1 deletion Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -1388,7 +1388,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#error "AUTO_BED_LEVELING_UBL requires EEPROM_SETTINGS. Please update your configuration."
#elif !WITHIN(GRID_MAX_POINTS_X, 3, 15) || !WITHIN(GRID_MAX_POINTS_Y, 3, 15)
#error "GRID_MAX_POINTS_[XY] must be a whole number between 3 and 15."
#elif !defined(RESTORE_LEVELING_AFTER_G28)
#elif !defined(RESTORE_LEVELING_AFTER_G28) && !defined(ENABLE_LEVELING_AFTER_G28)
#error "AUTO_BED_LEVELING_UBL used to enable RESTORE_LEVELING_AFTER_G28. To keep this behavior enable RESTORE_LEVELING_AFTER_G28. Otherwise define it as 'false'."
#endif

Expand Down Expand Up @@ -1416,6 +1416,10 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS

#endif

#if ALL(HAS_LEVELING, RESTORE_LEVELING_AFTER_G28, ENABLE_LEVELING_AFTER_G28)
#error "Only enable RESTORE_LEVELING_AFTER_G28 or ENABLE_LEVELING_AFTER_G28, but not both."
#endif

#if HAS_MESH && HAS_CLASSIC_JERK
static_assert(DEFAULT_ZJERK > 0.1, "Low DEFAULT_ZJERK values are incompatible with mesh-based leveling.");
#endif
Expand Down Expand Up @@ -2239,6 +2243,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
2 changes: 2 additions & 0 deletions Marlin/src/lcd/dwin/e3v2/dwin.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,5 +369,7 @@ void DWIN_Update();
void EachMomentUpdate();
void DWIN_HandleScreen();

inline void DWIN_StartHoming() { HMI_flag.home_flag = true; }

void DWIN_CompletedHoming();
void DWIN_CompletedLeveling();
Loading

0 comments on commit b4814c0

Please sign in to comment.