This commit is contained in:
Scott Lahteine 2020-11-12 01:38:19 +01:00 committed by GitHub
commit 1b736c7e29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 3811 additions and 33 deletions

View file

@ -891,6 +891,12 @@
*/ */
//#define FIX_MOUNTED_PROBE //#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 * Use the nozzle as the probe, as with a conductive
* nozzle system or a piezo-electric smart effector. * nozzle system or a piezo-electric smart effector.
@ -1270,10 +1276,21 @@
//#define MESH_BED_LEVELING //#define MESH_BED_LEVELING
/** /**
* Normally G28 leaves leveling disabled on completion. Enable * Normally G28 leaves leveling disabled on completion. Enable one of
* this option to have G28 restore the prior leveling state. * these options to restore the prior leveling state or to always enable
* leveling immediately after G28.
*/ */
//#define RESTORE_LEVELING_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. * Enable detailed logging of G28, G29, M48, etc.
@ -2198,6 +2215,11 @@
//#define DGUS_LCD_UI_FYSETC //#define DGUS_LCD_UI_FYSETC
//#define DGUS_LCD_UI_HIPRECY //#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 // Touch-screen LCD for Malyan M200/M300 printers
// //

View file

@ -109,6 +109,9 @@
#else #else
#error "LCD_SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration." #error "LCD_SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration."
#endif #endif
#if HAS_DGUS_LCD
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
#endif
#endif #endif
// Set interrupt grouping for this MCU // Set interrupt grouping for this MCU

View file

@ -45,6 +45,7 @@
#include "core/utility.h" #include "core/utility.h"
#include "module/motion.h" #include "module/motion.h"
#include "module/planner.h" #include "module/planner.h"
#include "module/probe.h"
#include "module/endstops.h" #include "module/endstops.h"
#include "module/temperature.h" #include "module/temperature.h"
#include "module/settings.h" #include "module/settings.h"
@ -60,6 +61,7 @@
#include "sd/cardreader.h" #include "sd/cardreader.h"
#include "lcd/marlinui.h" #include "lcd/marlinui.h"
#if HAS_TOUCH_XPT2046 #if HAS_TOUCH_XPT2046
#include "lcd/touch/touch_buttons.h" #include "lcd/touch/touch_buttons.h"
#endif #endif
@ -77,6 +79,10 @@
#include "lcd/dwin/e3v2/rotary_encoder.h" #include "lcd/dwin/e3v2/rotary_encoder.h"
#endif #endif
#if ENABLED(EXTENSIBLE_UI)
#include "lcd/extui/ui_api.h"
#endif
#if HAS_ETHERNET #if HAS_ETHERNET
#include "feature/ethernet.h" #include "feature/ethernet.h"
#endif #endif
@ -356,6 +362,8 @@ void enable_all_steppers() {
ENABLE_AXIS_Y(); ENABLE_AXIS_Y();
ENABLE_AXIS_Z(); ENABLE_AXIS_Z();
enable_e_steppers(); enable_e_steppers();
TERN_(EXTENSIBLE_UI, ExtUI::onSteppersEnabled());
} }
void disable_e_steppers() { void disable_e_steppers() {
@ -375,6 +383,8 @@ void disable_all_steppers() {
DISABLE_AXIS_Y(); DISABLE_AXIS_Y();
DISABLE_AXIS_Z(); DISABLE_AXIS_Z();
disable_e_steppers(); disable_e_steppers();
TERN_(EXTENSIBLE_UI, ExtUI::onSteppersDisabled());
} }
#if ENABLED(G29_RETRY_AND_RECOVER) #if ENABLED(G29_RETRY_AND_RECOVER)
@ -751,6 +761,16 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
// Handle UI input / draw events // Handle UI input / draw events
TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update()); 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 // Run i2c Position Encoders
#if ENABLED(I2C_POSITION_ENCODERS) #if ENABLED(I2C_POSITION_ENCODERS)
static millis_t i2cpem_next_update_ms; static millis_t i2cpem_next_update_ms;
@ -1098,6 +1118,17 @@ void setup() {
SETUP_RUN(ui.reset_status()); // Load welcome message early. (Retained if no errors exist.) SETUP_RUN(ui.reset_status()); // Load welcome message early. (Retained if no errors exist.)
#endif #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) #if BOTH(SDSUPPORT, SDCARD_EEPROM_EMULATION)
SETUP_RUN(card.mount()); // Mount media with settings before first_load SETUP_RUN(card.mount()); // Mount media with settings before first_load
#endif #endif

View file

@ -327,6 +327,7 @@
#define BOARD_TRIGORILLA_PRO 4037 // Trigorilla Pro (STM32F103ZET6) #define BOARD_TRIGORILLA_PRO 4037 // Trigorilla Pro (STM32F103ZET6)
#define BOARD_FLY_MINI 4038 // FLY MINI (STM32F103RCT6) #define BOARD_FLY_MINI 4038 // FLY MINI (STM32F103RCT6)
#define BOARD_FLSUN_HISPEED 4039 // FLSUN HiSpeedV1 (STM32F103VET6) #define BOARD_FLSUN_HISPEED 4039 // FLSUN HiSpeedV1 (STM32F103VET6)
#define BOARD_CREALITY_V452 4040 // Creality v4.5.2 (STM32F103RE)
// //
// ARM Cortex-M4F // ARM Cortex-M4F

View file

@ -36,9 +36,12 @@
#include "../../../module/probe.h" #include "../../../module/probe.h"
#include "../../queue.h" #include "../../queue.h"
#if EITHER(PROBE_TEMP_COMPENSATION, PREHEAT_BEFORE_LEVELING)
#include "../../../module/temperature.h"
#endif
#if ENABLED(PROBE_TEMP_COMPENSATION) #if ENABLED(PROBE_TEMP_COMPENSATION)
#include "../../../feature/probe_temp_comp.h" #include "../../../feature/probe_temp_comp.h"
#include "../../../module/temperature.h"
#endif #endif
#if HAS_DISPLAY #if HAS_DISPLAY
@ -177,6 +180,20 @@ G29_TYPE GcodeSuite::G29() {
if (DISABLED(PROBE_MANUALLY) && seenQ) G29_RETURN(false); if (DISABLED(PROBE_MANUALLY) && seenQ) G29_RETURN(false);
#endif #endif
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')), const bool seenA = TERN0(PROBE_MANUALLY, parser.seen('A')),
no_action = seenA || seenQ, no_action = seenA || seenQ,
faux = ENABLED(DEBUG_LEVELING_FEATURE) && DISABLED(PROBE_MANUALLY) ? parser.boolval('C') : no_action; faux = ENABLED(DEBUG_LEVELING_FEATURE) && DISABLED(PROBE_MANUALLY) ? parser.boolval('C') : no_action;
@ -392,6 +409,10 @@ G29_TYPE GcodeSuite::G29() {
planner.synchronize(); 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(); if (!faux) remember_feedrate_scaling_off();
// Disable auto bed leveling during G29. // Disable auto bed leveling during G29.
@ -656,8 +677,10 @@ G29_TYPE GcodeSuite::G29() {
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR) #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
z_values[meshCount.x][meshCount.y] = measured_z + zoffset; #if ENABLED(EXTENSIBLE_UI)
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(meshCount, z_values[meshCount.x][meshCount.y])); const float z = z_values[meshCount.x][meshCount.y] = measured_z + zoffset;
ExtUI::onMeshUpdate(meshCount, z);
#endif
#endif #endif

View file

@ -50,6 +50,10 @@
#include "../../lcd/dwin/e3v2/dwin.h" #include "../../lcd/dwin/e3v2/dwin.h"
#endif #endif
#if ENABLED(EXTENSIBLE_UI)
#include "../../lcd/extui/ui_api.h"
#endif
#if HAS_L64XX // set L6470 absolute position registers to counts #if HAS_L64XX // set L6470 absolute position registers to counts
#include "../../libs/L64XX/L64XX_Marlin.h" #include "../../libs/L64XX/L64XX_Marlin.h"
#endif #endif
@ -61,6 +65,10 @@
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../../core/debug_out.h" #include "../../core/debug_out.h"
#if ENABLED(STRAIN_GAUGE_PROBE)
bool is_homing, is_homing_z; // = false
#endif
#if ENABLED(QUICK_HOME) #if ENABLED(QUICK_HOME)
static void quick_home_xy() { static void quick_home_xy() {
@ -207,8 +215,6 @@ void GcodeSuite::G28() {
TERN_(LASER_MOVE_G28_OFF, cutter.set_inline_enabled(false)); // turn off laser TERN_(LASER_MOVE_G28_OFF, cutter.set_inline_enabled(false)); // turn off laser
TERN_(DWIN_CREALITY_LCD, HMI_flag.home_flag = true);
#if ENABLED(DUAL_X_CARRIAGE) #if ENABLED(DUAL_X_CARRIAGE)
bool IDEX_saved_duplication_state = extruder_duplication_enabled; bool IDEX_saved_duplication_state = extruder_duplication_enabled;
DualXMode IDEX_saved_mode = dual_x_carriage_mode; DualXMode IDEX_saved_mode = dual_x_carriage_mode;
@ -230,20 +236,25 @@ void GcodeSuite::G28() {
return; return;
} }
TERN_(DWIN_CREALITY_LCD, DWIN_StartHoming());
TERN_(EXTENSIBLE_UI, ExtUI::onHomingStart());
TERN_(STRAIN_GAUGE_PROBE, is_homing = true);
planner.synchronize(); // Wait for planner moves to finish! planner.synchronize(); // Wait for planner moves to finish!
SET_SOFT_ENDSTOP_LOOSE(false); // Reset a leftover 'loose' motion state SET_SOFT_ENDSTOP_LOOSE(false); // Reset a leftover 'loose' motion state
// Disable the leveling matrix before homing // Disable the leveling matrix before homing
#if HAS_LEVELING #if HAS_LEVELING
TERN_(PROBE_MANUALLY, g29_in_progress = false); // Cancel the active G29 session
// Cancel the active G29 session const bool leveling_restore_state = ENABLED(ENABLE_LEVELING_AFTER_G28) || TERN0(RESTORE_LEVELING_AFTER_G28, planner.leveling_active);
TERN_(PROBE_MANUALLY, g29_in_progress = false);
TERN_(RESTORE_LEVELING_AFTER_G28, const bool leveling_was_active = planner.leveling_active);
set_bed_leveling_enabled(false); set_bed_leveling_enabled(false);
#else
constexpr bool leveling_restore_state = false;
#endif #endif
// Reset to the XY plane
TERN_(CNC_WORKSPACE_PLANES, workspace_plane = PLANE_XY); TERN_(CNC_WORKSPACE_PLANES, workspace_plane = PLANE_XY);
// Count this command as movement / activity // Count this command as movement / activity
@ -330,6 +341,8 @@ void GcodeSuite::G28() {
do_z_clearance(z_homing_height, true, DISABLED(UNKNOWN_Z_NO_RAISE)); do_z_clearance(z_homing_height, true, DISABLED(UNKNOWN_Z_NO_RAISE));
} }
TERN_(STRAIN_GAUGE_PROBE, is_homing = false);
#if ENABLED(QUICK_HOME) #if ENABLED(QUICK_HOME)
if (doX && doY) quick_home_xy(); if (doX && doY) quick_home_xy();
@ -419,6 +432,11 @@ void GcodeSuite::G28() {
#endif // DUAL_X_CARRIAGE #endif // DUAL_X_CARRIAGE
#if ENABLED(STRAIN_GAUGE_PROBE)
endstops.enable_z_probe(false);
is_homing_z = false;
#endif
endstops.not_homing(); endstops.not_homing();
// Clear endstop state for polled stallGuard endstops // Clear endstop state for polled stallGuard endstops
@ -429,8 +447,6 @@ void GcodeSuite::G28() {
do_blocking_move_to_z(delta_clip_start_height); do_blocking_move_to_z(delta_clip_start_height);
#endif #endif
TERN_(RESTORE_LEVELING_AFTER_G28, set_bed_leveling_enabled(leveling_was_active));
restore_feedrate_and_scaling(); restore_feedrate_and_scaling();
// Restore the active tool after homing // Restore the active tool after homing
@ -454,9 +470,12 @@ void GcodeSuite::G28() {
#endif #endif
#endif #endif
TERN_(HAS_LEVELING, set_bed_leveling_enabled(leveling_restore_state));
ui.refresh(); ui.refresh();
TERN_(DWIN_CREALITY_LCD, DWIN_CompletedHoming()); TERN_(DWIN_CREALITY_LCD, DWIN_CompletedHoming());
TERN_(EXTENSIBLE_UI, ExtUI::onHomingComplete());
report_current_position(); report_current_position();

View file

@ -96,6 +96,8 @@ void GcodeSuite::M1001() {
queue.inject_P(PSTR(SD_FINISHED_RELEASECOMMAND)); queue.inject_P(PSTR(SD_FINISHED_RELEASECOMMAND));
#endif #endif
TERN_(EXTENSIBLE_UI, ExtUI::onPrintFinished());
// Re-select the last printed file in the UI // Re-select the last printed file in the UI
TERN_(SD_REPRINT_LAST_SELECTED_FILE, ui.reselect_last_file()); TERN_(SD_REPRINT_LAST_SELECTED_FILE, ui.reselect_last_file());
} }

View file

@ -456,7 +456,7 @@
#endif #endif
// Aliases for LCD features // 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 #define HAS_DGUS_LCD 1
#endif #endif

View file

@ -2211,7 +2211,7 @@
#define HAS_TEMPERATURE 1 #define HAS_TEMPERATURE 1
#endif #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 #ifdef PREHEAT_5_LABEL
#define PREHEAT_COUNT 5 #define PREHEAT_COUNT 5
#elif defined(PREHEAT_4_LABEL) #elif defined(PREHEAT_4_LABEL)
@ -2621,7 +2621,7 @@
#endif #endif
// Number of VFAT entries used. Each entry has 13 UTF-16 characters // 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) #define MAX_VFAT_ENTRIES (5)
#else #else
#define MAX_VFAT_ENTRIES (2) #define MAX_VFAT_ENTRIES (2)

View file

@ -1381,7 +1381,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." #error "AUTO_BED_LEVELING_UBL requires EEPROM_SETTINGS."
#elif !WITHIN(GRID_MAX_POINTS_X, 3, 15) || !WITHIN(GRID_MAX_POINTS_Y, 3, 15) #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." #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'." #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 #endif
@ -1409,6 +1409,10 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#endif #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 #if HAS_MESH && HAS_CLASSIC_JERK
static_assert(DEFAULT_ZJERK > 0.1, "Low DEFAULT_ZJERK values are incompatible with mesh-based leveling."); static_assert(DEFAULT_ZJERK > 0.1, "Low DEFAULT_ZJERK values are incompatible with mesh-based leveling.");
#endif #endif
@ -2244,6 +2248,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
+ ENABLED(MKS_LCD12864) \ + ENABLED(MKS_LCD12864) \
+ ENABLED(OLED_PANEL_TINYBOY2) \ + ENABLED(OLED_PANEL_TINYBOY2) \
+ ENABLED(OVERLORD_OLED) \ + ENABLED(OVERLORD_OLED) \
+ ENABLED(DGUS_LCD_UI_CREALITY_TOUCH) \
+ ENABLED(PANEL_ONE) \ + ENABLED(PANEL_ONE) \
+ ENABLED(RA_CONTROL_PANEL) \ + ENABLED(RA_CONTROL_PANEL) \
+ ENABLED(RADDS_DISPLAY) \ + ENABLED(RADDS_DISPLAY) \

View file

@ -369,5 +369,7 @@ void DWIN_Update();
void EachMomentUpdate(); void EachMomentUpdate();
void DWIN_HandleScreen(); void DWIN_HandleScreen();
inline void DWIN_StartHoming() { HMI_flag.home_flag = true; }
void DWIN_CompletedHoming(); void DWIN_CompletedHoming();
void DWIN_CompletedLeveling(); void DWIN_CompletedLeveling();

View file

@ -62,6 +62,10 @@ namespace ExtUI {
void onUserConfirmRequired(const char * const msg) { Chiron.ConfirmationRequest(msg); } void onUserConfirmRequired(const char * const msg) { Chiron.ConfirmationRequest(msg); }
void onStatusChanged(const char * const msg) { Chiron.StatusChange(msg); } void onStatusChanged(const char * const msg) { Chiron.StatusChange(msg); }
void onHomingStart() {}
void onHomingComplete() {}
void onPrintFinished() {}
void onFactoryReset() {} void onFactoryReset() {}
void onStoreSettings(char *buff) { void onStoreSettings(char *buff) {
@ -95,6 +99,8 @@ namespace ExtUI {
} }
#if HAS_MESH #if HAS_MESH
void onMeshLevelingStart() {}
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) { void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) {
// Called when any mesh points are updated // Called when any mesh points are updated
//SERIAL_ECHOLNPAIR("onMeshUpdate() x:", xpos, " y:", ypos, " z:", zval); //SERIAL_ECHOLNPAIR("onMeshUpdate() x:", xpos, " y:", ypos, " z:", zval);
@ -116,6 +122,9 @@ namespace ExtUI {
// Called for temperature PID tuning result // Called for temperature PID tuning result
} }
#endif #endif
void onSteppersDisabled() {}
void onSteppersEnabled() {}
} }
#endif // ANYCUBIC_LCD_CHIRON #endif // ANYCUBIC_LCD_CHIRON

View file

@ -52,6 +52,11 @@ namespace ExtUI {
void onFilamentRunout(const extruder_t extruder) { AnycubicTFT.OnFilamentRunout(); } void onFilamentRunout(const extruder_t extruder) { AnycubicTFT.OnFilamentRunout(); }
void onUserConfirmRequired(const char * const msg) { AnycubicTFT.OnUserConfirmRequired(msg); } void onUserConfirmRequired(const char * const msg) { AnycubicTFT.OnUserConfirmRequired(msg); }
void onStatusChanged(const char * const msg) {} void onStatusChanged(const char * const msg) {}
void onHomingStart() {}
void onHomingComplete() {}
void onPrintFinished() {}
void onFactoryReset() {} void onFactoryReset() {}
void onStoreSettings(char *buff) { void onStoreSettings(char *buff) {
@ -84,9 +89,14 @@ namespace ExtUI {
// whether successful or not. // whether successful or not.
} }
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) { #if HAS_MESH
// Called when any mesh points are updated
} void onMeshLevelingStart() {}
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) {
// Called when any mesh points are updated
}
#endif
#if ENABLED(POWER_LOSS_RECOVERY) #if ENABLED(POWER_LOSS_RECOVERY)
void onPowerLossResume() { void onPowerLossResume() {
@ -99,6 +109,9 @@ namespace ExtUI {
// Called for temperature PID tuning result // Called for temperature PID tuning result
} }
#endif #endif
void onSteppersDisabled() {}
void onSteppersEnabled() {}
} }
#endif // ANYCUBIC_LCD_I3MEGA #endif // ANYCUBIC_LCD_I3MEGA

View file

@ -0,0 +1,197 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/**
* dgus_creality_lcd.cpp
*
* DGUS implementation written by coldtobi in 2019 for Marlin
*/
#include "../../inc/MarlinConfigPre.h"
#if ENABLED(DGUS_LCD_UI_CREALITY_TOUCH)
#include "ui_api.h"
#include "lib/dgus/DGUSDisplayDef.h"
#include "lib/dgus_creality/DGUSDisplay.h"
#include "lib/dgus_creality/DGUSScreenHandler.h"
extern const char NUL_STR[];
namespace ExtUI {
void onStartup() {
dgusdisplay.InitDisplay();
ScreenHandler.UpdateScreenVPData();
}
void onIdle() { ScreenHandler.loop(); }
void onPrinterKilled(PGM_P const error, PGM_P const component) {
ScreenHandler.sendinfoscreen(GET_TEXT(MSG_HALTED), error, GET_TEXT(MSG_PLEASE_RESET), NUL_STR, true, true, true, true);
if (strcmp_P(error, GET_TEXT(MSG_ERR_MAXTEMP)) == 0 || strcmp_P(error, GET_TEXT(MSG_THERMAL_RUNAWAY)) == 0) {
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_THERMAL_RUNAWAY);
} else if (strcmp_P(error, GET_TEXT(MSG_HEATING_FAILED_LCD)) == 0) {
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_HEATING_FAILED);
}else if (strcmp_P(error, GET_TEXT(MSG_ERR_MINTEMP)) == 0) {
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_THERMISTOR_ERROR);
} else {
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_KILL);
}
while (!ScreenHandler.loop()); // Wait while anything is left to be sent
}
void onMediaInserted() { TERN_(SDSUPPORT, ScreenHandler.SDCardInserted()); }
void onMediaError() { TERN_(SDSUPPORT, ScreenHandler.SDCardError()); }
void onMediaRemoved() { TERN_(SDSUPPORT, ScreenHandler.SDCardRemoved()); }
void onPlayTone(const uint16_t frequency, const uint16_t duration) {
ScreenHandler.Buzzer(frequency, duration);
}
void onPrintTimerStarted() {}
void onPrintTimerPaused() {
// Handle M28 Pause SD print - But only if we're not waiting on a user
if (ExtUI::isPrintingFromMediaPaused() && ScreenHandler.getCurrentScreen() == DGUSLCD_SCREEN_PRINT_RUNNING) {
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_PRINT_PAUSED);
}
}
void onPrintTimerStopped() {}
void onFilamentRunout(const extruder_t extruder) { ScreenHandler.FilamentRunout(); }
void onUserConfirmed() {
SERIAL_ECHOLNPGM("User confirmation invoked");
ScreenHandler.SetupConfirmAction(nullptr);
ExtUI::setUserConfirmed();
}
void onUserConfirmRequired(const char * const msg) {
if (msg) {
SERIAL_ECHOLNPAIR("User confirmation requested: ", msg);
ScreenHandler.setstatusmessagePGM(msg);
ScreenHandler.SetupConfirmAction(onUserConfirmed);
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_POPUP);
ScreenHandler.sendinfoscreen(PSTR("Confirmation required"), msg, NUL_STR, NUL_STR, true, true, false, true);
}
else if (ScreenHandler.getCurrentScreen() == DGUSLCD_SCREEN_POPUP) {
SERIAL_ECHOLNPGM("User confirmation canceled");
//ScreenHandler.SetupConfirmAction(nullptr);
ScreenHandler.setstatusmessagePGM(nullptr);
ScreenHandler.PopToOldScreen();
}
}
void onStatusChanged(const char * const msg) { ScreenHandler.setstatusmessage(msg); }
void onFactoryReset() { ScreenHandler.OnFactoryReset(); }
void onHomingStart() { ScreenHandler.OnHomingStart(); }
void onHomingComplete() { ScreenHandler.OnHomingComplete(); }
void onPrintFinished() { ScreenHandler.OnPrintFinished(); }
void onStoreSettings(char *buff) {
// Called when saving to EEPROM (i.e. M500). If the ExtUI needs
// permanent data to be stored, it can write up to eeprom_data_size bytes
// into buff.
// Example:
// static_assert(sizeof(myDataStruct) <= ExtUI::eeprom_data_size);
// memcpy(buff, &myDataStruct, sizeof(myDataStruct));
}
void onLoadSettings(const char *buff) {
// Called while loading settings from EEPROM. If the ExtUI
// needs to retrieve data, it should copy up to eeprom_data_size bytes
// from buff
// Example:
// static_assert(sizeof(myDataStruct) <= ExtUI::eeprom_data_size);
// memcpy(&myDataStruct, buff, sizeof(myDataStruct));
}
void onConfigurationStoreWritten(bool success) {
// Called after the entire EEPROM has been written,
// whether successful or not.
}
void onConfigurationStoreRead(bool success) {
// Called after the entire EEPROM has been read,
// whether successful or not.
}
#if HAS_MESH
void onMeshLevelingStart() { ScreenHandler.OnMeshLevelingStart(); }
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) {
ScreenHandler.OnMeshLevelingUpdate(xpos, ypos);
}
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const ExtUI::probe_state_t state) {
// Only called for UBL
if (state == MESH_START) ScreenHandler.OnMeshLevelingStart();
ScreenHandler.OnMeshLevelingUpdate(xpos, ypos);
}
#endif
#if ENABLED(POWER_LOSS_RECOVERY)
void onPowerLossResume() {
// Called on resume from power-loss
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_POWER_LOSS);
}
#endif
#if HAS_PID_HEATING
void onPidTuning(const result_t rst) {
// Called for temperature PID tuning result
// switch (rst) {
// case PID_BAD_EXTRUDER_NUM:
// ScreenHandler.setstatusmessagePGM(GET_TEXT(MSG_PID_BAD_EXTRUDER_NUM));
// break;
// case PID_TEMP_TOO_HIGH:
// ScreenHandler.setstatusmessagePGM(GET_TEXT(MSG_PID_TEMP_TOO_HIGH));
// break;
// case PID_TUNING_TIMEOUT:
// ScreenHandler.setstatusmessagePGM(GET_TEXT(MSG_PID_TIMEOUT));
// break;
// case PID_DONE:
// ScreenHandler.setstatusmessagePGM(GET_TEXT(MSG_PID_AUTOTUNE_DONE));
// break;
// }
// ScreenHandler.GotoScreen(DGUSLCD_SCREEN_MAIN);
}
#endif
void onSteppersDisabled() { ScreenHandler.HandleStepperState(false); }
void onSteppersEnabled() { ScreenHandler.HandleStepperState(true); }
}
#endif // HAS_DGUS_LCD

View file

@ -28,7 +28,7 @@
#include "../../inc/MarlinConfigPre.h" #include "../../inc/MarlinConfigPre.h"
#if HAS_DGUS_LCD #if HAS_DGUS_LCD && DISABLED(DGUS_LCD_UI_CREALITY_TOUCH)
#include "ui_api.h" #include "ui_api.h"
#include "lib/dgus/DGUSDisplay.h" #include "lib/dgus/DGUSDisplay.h"
@ -76,7 +76,12 @@ namespace ExtUI {
void onStatusChanged(const char * const msg) { ScreenHandler.setstatusmessage(msg); } void onStatusChanged(const char * const msg) { ScreenHandler.setstatusmessage(msg); }
void onHomingStart() {}
void onHomingComplete() {}
void onPrintFinished() {}
void onFactoryReset() {} void onFactoryReset() {}
void onStoreSettings(char *buff) { void onStoreSettings(char *buff) {
// Called when saving to EEPROM (i.e. M500). If the ExtUI needs // Called when saving to EEPROM (i.e. M500). If the ExtUI needs
// permanent data to be stored, it can write up to eeprom_data_size bytes // permanent data to be stored, it can write up to eeprom_data_size bytes
@ -108,6 +113,8 @@ namespace ExtUI {
} }
#if HAS_MESH #if HAS_MESH
void onMeshLevelingStart() {}
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) { void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) {
// Called when any mesh points are updated // Called when any mesh points are updated
} }
@ -146,5 +153,8 @@ namespace ExtUI {
} }
#endif #endif
void onSteppersDisabled() {}
void onSteppersEnabled() {}
} }
#endif // HAS_DGUS_LCD #endif // HAS_DGUS_LCD

View file

@ -47,9 +47,9 @@ namespace ExtUI {
} }
void onIdle() {} void onIdle() {}
void onPrinterKilled(PGM_P const error, PGM_P const component) {} void onPrinterKilled(PGM_P const error, PGM_P const component) {}
void onMediaInserted() {}; void onMediaInserted() {}
void onMediaError() {}; void onMediaError() {}
void onMediaRemoved() {}; void onMediaRemoved() {}
void onPlayTone(const uint16_t frequency, const uint16_t duration) {} void onPlayTone(const uint16_t frequency, const uint16_t duration) {}
void onPrintTimerStarted() {} void onPrintTimerStarted() {}
void onPrintTimerPaused() {} void onPrintTimerPaused() {}
@ -57,6 +57,11 @@ namespace ExtUI {
void onFilamentRunout(const extruder_t extruder) {} void onFilamentRunout(const extruder_t extruder) {}
void onUserConfirmRequired(const char * const msg) {} void onUserConfirmRequired(const char * const msg) {}
void onStatusChanged(const char * const msg) {} void onStatusChanged(const char * const msg) {}
void onHomingStart() {}
void onHomingComplete() {}
void onPrintFinished() {}
void onFactoryReset() {} void onFactoryReset() {}
void onStoreSettings(char *buff) { void onStoreSettings(char *buff) {
@ -90,6 +95,8 @@ namespace ExtUI {
} }
#if HAS_MESH #if HAS_MESH
void onMeshLevelingStart() {}
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) { void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) {
// Called when any mesh points are updated // Called when any mesh points are updated
} }
@ -110,6 +117,9 @@ namespace ExtUI {
// Called for temperature PID tuning result // Called for temperature PID tuning result
} }
#endif #endif
void onSteppersDisabled() {}
void onSteppersEnabled() {}
} }
#endif // EXTUI_EXAMPLE && EXTENSIBLE_UI #endif // EXTUI_EXAMPLE && EXTENSIBLE_UI

View file

@ -24,7 +24,7 @@
#include "../../../../inc/MarlinConfigPre.h" #include "../../../../inc/MarlinConfigPre.h"
#if HAS_DGUS_LCD #if HAS_DGUS_LCD && DISABLED(DGUS_LCD_UI_CREALITY_TOUCH)
#if HOTENDS > 2 #if HOTENDS > 2
#error "More than 2 hotends not implemented on the Display UI design." #error "More than 2 hotends not implemented on the Display UI design."

View file

@ -21,7 +21,7 @@
*/ */
#pragma once #pragma once
/* DGUS implementation written by coldtobi in 2019 for Marlin */ /* DGUS implementation written by Sebastiaan Dammann in 2020 for Marlin */
#include "DGUSVPVariable.h" #include "DGUSVPVariable.h"
@ -51,4 +51,6 @@ extern const struct DGUS_VP_Variable ListOfVP[];
#include "fysetc/DGUSDisplayDef.h" #include "fysetc/DGUSDisplayDef.h"
#elif ENABLED(DGUS_LCD_UI_HIPRECY) #elif ENABLED(DGUS_LCD_UI_HIPRECY)
#include "hiprecy/DGUSDisplayDef.h" #include "hiprecy/DGUSDisplayDef.h"
#elif ENABLED(DGUS_LCD_UI_CREALITY_TOUCH)
#include "creality/DGUSDisplayDef.h"
#endif #endif

View file

@ -22,7 +22,7 @@
#include "../../../../inc/MarlinConfigPre.h" #include "../../../../inc/MarlinConfigPre.h"
#if HAS_DGUS_LCD #if HAS_DGUS_LCD && DISABLED(DGUS_LCD_UI_CREALITY_TOUCH)
#include "DGUSScreenHandler.h" #include "DGUSScreenHandler.h"
#include "DGUSDisplay.h" #include "DGUSDisplay.h"

View file

@ -0,0 +1,509 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/* DGUS implementation written by Sebastiaan Dammann in 2020 for Marlin */
#include "../../../../../inc/MarlinConfigPre.h"
#if ENABLED(DGUS_LCD_UI_CREALITY_TOUCH)
#include "DGUSDisplayDef.h"
#include "../DGUSDisplay.h"
#include "../DGUSScreenHandler.h"
#include "../../../../../module/temperature.h"
#include "../../../../../module/motion.h"
#include "../../../../../module/planner.h"
#include "../../../../../feature/caselight.h"
#include "../../../../marlinui.h"
#include "../../../ui_api.h"
#include "PageHandlers.h"
#if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
uint16_t distanceToMove = 10;
#endif
using namespace ExtUI;
const char MarlinVersion[] PROGMEM = SHORT_BUILD_VERSION;
// ----- Which variables to auto-update on which screens
const uint16_t VPList_None[] PROGMEM = {
0x0000
};
const uint16_t VPList_DialogStop[] PROGMEM = {
0x0000
};
const uint16_t VPList_Main[] PROGMEM = {
/* VP_M117, for completeness, but it cannot be auto-uploaded. */
#if HOTENDS >= 1
VP_T_E0_Is, VP_T_E0_Set,// VP_E0_STATUS,
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set,// VP_BED_STATUS,
#endif
/*VP_XPos, VP_YPos,*/ VP_ZPos,
//VP_Fan0_Percentage,
VP_Feedrate_Percentage,
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
VP_PrintProgress_Percentage,
#endif
0x0000
};
const uint16_t VPList_SDFileList[] PROGMEM = {
/* VP_M117, for completeness, but it cannot be auto-uploaded. */
#if HOTENDS >= 1
VP_T_E0_Is, VP_T_E0_Set,// VP_E0_STATUS,
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set,// VP_BED_STATUS,
#endif
/*VP_XPos, VP_YPos,*/ VP_ZPos,
//VP_Fan0_Percentage,
VP_Feedrate_Percentage,
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
VP_PrintProgress_Percentage,
#endif
VP_SD_FileName0,
VP_SD_FileName1,
VP_SD_FileName2,
VP_SD_FileName3,
VP_SD_FileName4,
VP_SD_FileName5,
0x0000
};
const uint16_t VPList_Control[] PROGMEM = {
/* VP_M117, for completeness, but it cannot be auto-uploaded. */
#if HOTENDS >= 1
VP_T_E0_Is, VP_T_E0_Set,// VP_E0_STATUS,
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set,// VP_BED_STATUS,
#endif
/*VP_XPos, VP_YPos,*/ VP_ZPos,
//VP_Fan0_Percentage,
VP_Feedrate_Percentage,
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
VP_PrintProgress_Percentage,
#endif
VP_LED_TOGGLE,
0x0000
};
const uint16_t VPList_Feed[] PROGMEM = {
/* VP_M117, for completeness, but it cannot be auto-uploaded. */
#if HOTENDS >= 1
VP_T_E0_Is, VP_T_E0_Set,// VP_E0_STATUS,
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set,// VP_BED_STATUS,
#endif
/*VP_XPos, VP_YPos,*/ VP_ZPos,
//VP_Fan0_Percentage,
VP_Feedrate_Percentage,
0x0000
};
const uint16_t VPList_Temp[] PROGMEM = {
/* VP_M117, for completeness, but it cannot be auto-uploaded. */
#if HOTENDS >= 1
VP_T_E0_Is, VP_T_E0_Set,// VP_E0_STATUS,
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set,// VP_BED_STATUS,
#endif
/*VP_XPos, VP_YPos,*/ VP_ZPos,
//VP_Fan0_Percentage,
VP_Feedrate_Percentage,
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
VP_PrintProgress_Percentage,
#endif
VP_FAN_TOGGLE,
0x0000
};
const uint16_t VPList_PreheatPLASettings[] PROGMEM = {
/* VP_M117, for completeness, but it cannot be auto-uploaded. */
#if HOTENDS >= 1
VP_T_E0_Is, VP_T_E0_Set,// VP_E0_STATUS,
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set,// VP_BED_STATUS,
#endif
/*VP_XPos, VP_YPos,*/ VP_ZPos,
//VP_Fan0_Percentage,
VP_Feedrate_Percentage,
VP_PREHEAT_PLA_HOTEND_TEMP,
VP_PREHEAT_PLA_BED_TEMP,
0x0000
};
const uint16_t VPList_PreheatABSSettings[] PROGMEM = {
/* VP_M117, for completeness, but it cannot be auto-uploaded. */
#if HOTENDS >= 1
VP_T_E0_Is, VP_T_E0_Set,// VP_E0_STATUS,
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set,// VP_BED_STATUS,
#endif
/*VP_XPos, VP_YPos,*/ VP_ZPos,
//VP_Fan0_Percentage,
VP_Feedrate_Percentage,
VP_PREHEAT_ABS_HOTEND_TEMP,
VP_PREHEAT_ABS_BED_TEMP,
0x0000
};
const uint16_t VPList_PrintPausingError[] PROGMEM = {
/* VP_M117, for completeness, but it cannot be auto-uploaded. */
#if HOTENDS >= 1
VP_T_E0_Is, VP_T_E0_Set,// VP_E0_STATUS,
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set,// VP_BED_STATUS,
#endif
/*VP_XPos, VP_YPos,*/ VP_ZPos,
//VP_Fan0_Percentage,
VP_Feedrate_Percentage,
VP_PrintProgress_Percentage,
VP_PrintTimeProgressBar,
VP_PrintTime,
0x0000
};
const uint16_t VPList_PrintScreen[] PROGMEM = {
/* VP_M117, for completeness, but it cannot be auto-uploaded. */
VP_M117,
VP_PrintTime,
#if HOTENDS >= 1
VP_T_E0_Is, VP_T_E0_Set,// VP_E0_STATUS,
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set,// VP_BED_STATUS,
#endif
/*VP_XPos, VP_YPos,*/ VP_ZPos,
//VP_Fan0_Percentage,
VP_Feedrate_Percentage,
VP_PrintProgress_Percentage,
VP_PrintTimeProgressBar,
VP_PrintTime,
0x0000
};
const uint16_t VPList_Leveling[] PROGMEM = {
#if HOTENDS >= 1
VP_T_E0_Is, VP_T_E0_Set,// VP_E0_STATUS,
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set,// VP_BED_STATUS,
#endif
/*VP_XPos, VP_YPos,*/ VP_ZPos,
//VP_Fan0_Percentage,
VP_Feedrate_Percentage,
VP_MESH_LEVEL_TEMP,
VP_MESH_LEVEL_STATUS,
0x0000
};
const uint16_t VPList_ZOffsetLevel[] PROGMEM = {
#if HOTENDS >= 1
VP_T_E0_Is, VP_T_E0_Set,// VP_E0_STATUS,
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set,// VP_BED_STATUS,
#endif
/*VP_XPos, VP_YPos,*/ VP_ZPos,
//VP_Fan0_Percentage,
VP_Feedrate_Percentage,
0x0000
};
const uint16_t VPList_TuneScreen[] PROGMEM = {
/* VP_M117, for completeness, but it cannot be auto-uploaded. */
VP_M117,
VP_PrintTime,
#if HOTENDS >= 1
VP_T_E0_Is, VP_T_E0_Set,// VP_E0_STATUS,
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set,// VP_BED_STATUS,
#endif
/*VP_XPos, VP_YPos,*/ VP_ZPos,
//VP_Fan0_Percentage,
VP_Feedrate_Percentage,
VP_LED_TOGGLE,
VP_FAN_TOGGLE,
0x0000
};
const uint16_t VPList_Prepare[] PROGMEM = {
/* VP_M117, for completeness, but it cannot be auto-uploaded. */
VP_M117,
VP_PrintTime,
#if HOTENDS >= 1
VP_T_E0_Is, VP_T_E0_Set,// VP_E0_STATUS,
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set,// VP_BED_STATUS,
#endif
/*VP_XPos, VP_YPos,*/ VP_ZPos,
//VP_Fan0_Percentage,
VP_Feedrate_Percentage,
VP_STEPPERS,
0x0000
};
const uint16_t VPList_Info[] PROGMEM = {
/* VP_M117, for completeness, but it cannot be auto-uploaded. */
VP_M117,
VP_PrintTime,
#if HOTENDS >= 1
VP_T_E0_Is, VP_T_E0_Set,// VP_E0_STATUS,
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set,// VP_BED_STATUS,
#endif
/*VP_XPos, VP_YPos,*/ VP_ZPos,
//VP_Fan0_Percentage,
VP_Feedrate_Percentage,
VP_PRINTER_BEDSIZE,
VP_MARLIN_VERSION,
0x0000
};
// Toggle button handler
void DGUSCrealityDisplay_HandleToggleButton(DGUS_VP_Variable &var, void *val_ptr) {
switch (*(uint16_t*)var.memadr) {
case ICON_TOGGLE_ON:
*((bool*)var.memadr) = true;
break;
case ICON_TOGGLE_OFF:
*((bool*)var.memadr) = true;
break;
}
}
void DGUSCrealityDisplay_SendToggleButton(DGUS_VP_Variable &var) {
dgusdisplay.WriteVariable(var.VP, *(bool*)var.memadr ? ICON_TOGGLE_ON : ICON_TOGGLE_OFF);
}
// -- Mapping from screen to variable list
const struct VPMapping VPMap[] PROGMEM = {
{ DGUSLCD_SCREEN_BOOT, VPList_None },
{ DGUSLCD_SCREEN_MAIN, VPList_Main },
{ DGUSLCD_SCREEN_SDFILELIST, VPList_SDFileList },
{ DGUSLCD_SCREEN_FILAMENTRUNOUT1, VPList_PrintPausingError },
{ DGUSLCD_SCREEN_FILAMENTRUNOUT2, VPList_PrintPausingError },
{ DGUSLCD_SCREEN_PRINT_FINISH, VPList_PrintScreen },
{ DGUSLCD_SCREEN_PRINT_RUNNING, VPList_PrintScreen },
{ DGUSLCD_SCREEN_PRINT_PAUSED, VPList_PrintScreen },
{ DGUSLCD_SCREEN_TUNING, VPList_TuneScreen },
{ DGUSLCD_SCREEN_PREPARE, VPList_Prepare },
{ DGUSLCD_SCREEN_INFO, VPList_Info },
{ DGUSLCD_SCREEN_MOVE1MM, VPList_PrintScreen },
{ DGUSLCD_SCREEN_MOVE10MM, VPList_PrintScreen },
{ DGUSLCD_SCREEN_MOVE01MM, VPList_PrintScreen },
{ DGUSLCD_SCREEN_FEED, VPList_Feed },
{ DGUSLCD_SCREEN_CONTROL, VPList_Control },
{ DGUSLCD_SCREEN_TEMP, VPList_Temp },
{ DGUSLCD_SCREEN_TEMP_PLA, VPList_PreheatPLASettings },
{ DGUSLCD_SCREEN_TEMP_ABS, VPList_PreheatABSSettings },
{ DGUSLCD_SCREEN_INFO, VPList_PrintScreen },
{ DGUSLCD_SCREEN_ZOFFSET_LEVEL, VPList_ZOffsetLevel },
{ DGUSLCD_SCREEN_LEVELING, VPList_Leveling },
{ DGUSLCD_SCREEN_POWER_LOSS, VPList_None },
{ DGUSLCD_SCREEN_THERMAL_RUNAWAY, VPList_None },
{ DGUSLCD_SCREEN_HEATING_FAILED, VPList_None },
{ DGUSLCD_SCREEN_THERMISTOR_ERROR, VPList_None },
{ DGUSLCD_SCREEN_AUTOHOME, VPList_None },
{ DGUSLCD_SCREEN_DIALOG_PAUSE, VPList_None },
{ DGUSLCD_SCREEN_DIALOG_STOP, VPList_DialogStop },
{ DGUSLCD_SCREEN_CONFIRM, VPList_None },
{ DGUSLCD_SCREEN_POPUP, VPList_None },
{ 0 , nullptr } // List is terminated with an nullptr as table entry.
};
// Helper to define a DGUS_VP_Variable for common use cases.
#define VPHELPER(VPADR, VPADRVAR, RXFPTR, TXFPTR ) { .VP=VPADR, .memadr=VPADRVAR, .size=sizeof(VPADRVAR), \
.set_by_display_handler = RXFPTR, .send_to_display_handler = TXFPTR }
// Helper to define a DGUS_VP_Variable when the sizeo of the var cannot be determined automaticalyl (eg. a string)
#define VPHELPER_STR(VPADR, VPADRVAR, STRLEN, RXFPTR, TXFPTR ) { .VP=VPADR, .memadr=VPADRVAR, .size=STRLEN, \
.set_by_display_handler = RXFPTR, .send_to_display_handler = TXFPTR }
const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
// TODO:
#if HOTENDS >= 1
VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#endif
#if HAS_HEATED_BED
VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#endif
VPHELPER(VP_MESH_LEVEL_TEMP, &thermalManager.temp_hotend[0].target, nullptr, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_MESH_LEVEL_STATUS, nullptr, nullptr, nullptr),
// Feedrate
VPHELPER(VP_Feedrate_Percentage, &feedrate_percentage, ScreenHandler.DGUSLCD_SetValueDirectly<int16_t>, &ScreenHandler.DGUSLCD_SendWordValueToDisplay ),
VPHELPER(VP_PrintProgress_Percentage, nullptr, nullptr, ScreenHandler.DGUSLCD_SendPrintProgressToDisplay),
VPHELPER(VP_PrintTimeProgressBar, nullptr, nullptr, ScreenHandler.DGUSLCD_SendPrintProgressToDisplay),
// Preheat settings
#ifdef PREHEAT_1_LABEL
VPHELPER(VP_PREHEAT_PLA_HOTEND_TEMP, &ui.material_preset[0].hotend_temp, ScreenHandler.DGUSLCD_SetValueDirectly<int16_t>, &ScreenHandler.DGUSLCD_SendWordValueToDisplay ),
VPHELPER(VP_PREHEAT_PLA_BED_TEMP, &ui.material_preset[0].bed_temp, ScreenHandler.DGUSLCD_SetValueDirectly<int16_t>, &ScreenHandler.DGUSLCD_SendWordValueToDisplay ),
#endif
#ifdef PREHEAT_2_LABEL
VPHELPER(VP_PREHEAT_ABS_HOTEND_TEMP, &ui.material_preset[1].hotend_temp, ScreenHandler.DGUSLCD_SetValueDirectly<int16_t>, &ScreenHandler.DGUSLCD_SendWordValueToDisplay ),
VPHELPER(VP_PREHEAT_ABS_BED_TEMP, &ui.material_preset[1].bed_temp, ScreenHandler.DGUSLCD_SetValueDirectly<int16_t>, &ScreenHandler.DGUSLCD_SendWordValueToDisplay ),
#endif
// About info
VPHELPER(VP_MARLIN_VERSION, nullptr, nullptr, ScreenHandler.DGUSLCD_SendAboutFirmwareVersion),
VPHELPER(VP_PRINTER_BEDSIZE, nullptr, nullptr, ScreenHandler.DGUSLCD_SendAboutPrintSize),
// Position Data
//VPHELPER(VP_XPos, &current_position.x, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
//VPHELPER(VP_YPos, &current_position.y, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
//VPHELPER(VP_YPos, &current_position.y, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
VPHELPER(VP_ZPos, &probe.offset.z, ScreenHandler.HandleZoffsetChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<2>),
VPHELPER(VP_FAN_TOGGLE, &thermalManager.fan_speed[0], ScreenHandler.HandleFanControl, ScreenHandler.DGUSLCD_SendFanStatusToDisplay),
#if ENABLED(POWER_LOSS_RECOVERY)
VPHELPER(VP_POWER_LOSS_RECOVERY, nullptr, &ScreenHandler.HandlePowerLossRecovery, nullptr),
#endif
VPHELPER_STR(VP_PrintTime, nullptr, VP_PrintTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintTimeToDisplay ),
VPHELPER(VP_SCREENCHANGE, nullptr, ScreenHandler.ScreenChangeHook, nullptr),
VPHELPER(VP_CONFIRMED, nullptr, ScreenHandler.ScreenConfirmedOK, nullptr),
// Feed
VPHELPER(VP_FEED_AMOUNT, &ScreenHandler.feed_amount, ScreenHandler.HandleFeedAmountChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<2>),
// Creality has the same button ID mapped all over the place, so let the generic handler figure it out
VPHELPER(VP_BUTTON_MAINENTERKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
VPHELPER(VP_BUTTON_ADJUSTENTERKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
VPHELPER(VP_BUTTON_PREPAREENTERKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
VPHELPER(VP_BUTTON_RESUMEPRINTKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
VPHELPER(VP_BUTTON_SELECTFILEKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
VPHELPER(VP_BUTTON_STARTPRINTKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
VPHELPER(VP_BUTTON_STOPPRINTKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
VPHELPER(VP_BUTTON_PAUSEPRINTKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
VPHELPER(VP_BUTTON_COOLDOWN, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
VPHELPER(VP_BUTTON_TEMPCONTROL, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
VPHELPER(VP_BUTTON_BEDLEVELKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
VPHELPER(VP_BUTTON_HEATLOADSTARTKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
// File listing
VPHELPER(VP_SD_ScrollEvent, nullptr, ScreenHandler.DGUSLCD_SD_ScrollFilelist, nullptr),
VPHELPER(VP_SD_FileSelected, nullptr, ScreenHandler.DGUSLCD_SD_FileSelected, nullptr),
VPHELPER(VP_SD_FileSelectConfirm, nullptr, ScreenHandler.DGUSLCD_SD_StartPrint, nullptr),
VPHELPER_STR(VP_SD_FileName0, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ),
VPHELPER_STR(VP_SD_FileName1, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ),
VPHELPER_STR(VP_SD_FileName2, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ),
VPHELPER_STR(VP_SD_FileName3, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ),
VPHELPER_STR(VP_SD_FileName4, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ),
VPHELPER_STR(VP_SD_FileName5, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ),
// Icons
VPHELPER(VP_STEPPERS, &ScreenHandler.are_steppers_enabled, nullptr, (ScreenHandler.DGUSLCD_SendIconValue<ICON_TOGGLE_OFF, ICON_TOGGLE_ON>)),
VPHELPER(VP_LED_TOGGLE, &caselight.on, nullptr, (ScreenHandler.DGUSLCD_SendIconValue<ICON_TOGGLE_ON,ICON_TOGGLE_OFF>)),
// M117 LCD String (We don't need the string in memory but "just" push it to the display on demand, hence the nullptr
{ .VP = VP_M117, .memadr = nullptr, .size = VP_M117_LEN, .set_by_display_handler = nullptr, .send_to_display_handler =&ScreenHandler.DGUSLCD_SendStringToDisplay },
// Messages for the User, shared by the popup and the kill screen. They cant be autouploaded as we do not buffer content.
{ .VP = VP_MSGSTR1, .memadr = nullptr, .size = VP_MSGSTR1_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM },
{ .VP = VP_MSGSTR2, .memadr = nullptr, .size = VP_MSGSTR2_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM },
{ .VP = VP_MSGSTR3, .memadr = nullptr, .size = VP_MSGSTR3_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM },
//{ .VP = VP_MSGSTR4, .memadr = nullptr, .size = VP_MSGSTR4_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM },
VPHELPER(0, 0, 0, 0) // must be last entry.
};
#endif // DGUS_LCD_UI_ORIGIN

View file

@ -0,0 +1,357 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "../DGUSDisplayDef.h"
enum DGUSLCD_Screens : uint8_t {
DGUSLCD_SCREEN_BOOT = 0,
DGUSLCD_SCREEN_MAIN = 28,
DGUSLCD_SCREEN_CONFIRM = 66,
DGUSLCD_SCREEN_SDPRINTMANIPULATION = 37 ,
DGUSLCD_SCREEN_SDPRINTTUNE = 41,
DGUSLCD_SCREEN_SDFILELIST = 67,
DGUSLCD_SCREEN_FILAMENTRUNOUT1 = 34, // DWINTouchPage::ERR_FILAMENTRUNOUT_HOTEND_COLD
DGUSLCD_SCREEN_FILAMENTRUNOUT2 = 35, // DWINTouchPage::ERR_FILAMENTRUNOUT_FILAMENT_LOADED
DGUSLCD_SCREEN_PRINT_FINISH = 36, // DWINTouchPage::PRINT_FINISHED
DGUSLCD_SCREEN_PRINT_RUNNING = 37, // DWINTouchPage::PRINT_PROGRESS_RUNNING
DGUSLCD_SCREEN_PRINT_PAUSED = 39, // DWINTouchPage::PRINT_PROGRESS_PAUSED
DGUSLCD_SCREEN_DIALOG_PAUSE = 38, // DWINTouchPage::DIALOG_PAUSE_PRINTING
DGUSLCD_SCREEN_DIALOG_STOP = 40, // DWINTouchPage::DIALOG_STOP_PRINTING
DGUSLCD_SCREEN_TUNING = 41, // DWINTouchPage::MENU_TUNING
DGUSLCD_SCREEN_PREPARE = 42, // DWINTouchPage::MENU_PREPARE
DGUSLCD_SCREEN_MOVE1MM = 43, // DWINTouchPage::MOVE_1MM
DGUSLCD_SCREEN_MOVE10MM = 44, // DWINTouchPage::MOVE_10MM
DGUSLCD_SCREEN_MOVE01MM = 45, // DWINTouchPage::MOVE_01MM
DGUSLCD_SCREEN_FEED = 46, // DWINTouchPage::FEED
DGUSLCD_SCREEN_CONTROL = 47, // DWINTouchPage::MENU_CONTROL
DGUSLCD_SCREEN_TEMP = 48, // DWINTouchPage::MENU_TEMP
DGUSLCD_SCREEN_TEMP_PLA = 49, // DWINTouchPage::MENU_PLA_TEMP
DGUSLCD_SCREEN_TEMP_ABS = 50, // DWINTouchPage::MENU_ABS_TEMP
DGUSLCD_SCREEN_INFO = 51, // DWINTouchPage::MENU_ABOUT
DGUSLCD_SCREEN_ZOFFSET_LEVEL = 52, // DWINTouchPage::MENU_ZOFFSET_LEVELING
DGUSLCD_SCREEN_LEVELING = 53, // DWINTouchPage::LEVELING
DGUSLCD_SCREEN_POWER_LOSS = 54, // DWINTouchPage::DIALOG_POWER_FAILURE
DGUSLCD_SCREEN_THERMAL_RUNAWAY = 57, // DWINTouchPage::ERR_THERMAL_RUNAWAY
DGUSLCD_SCREEN_HEATING_FAILED = 58, // DWINTouchPage::ERR_HEATING_FAILED
DGUSLCD_SCREEN_THERMISTOR_ERROR = 59, // DWINTouchPage::ERR_THERMISTOR
DGUSLCD_SCREEN_AUTOHOME = 61, // DWINTouchPage::AUTOHOME_IN_PROGRESS
DGUSLCD_SCREEN_POPUP = 63, // NEW - does not exist in original display
DGUSLCD_SCREEN_KILL = 64, // NEW - does not exist in original display
};
// Display Memory layout used (T5UID)
// Except system variables this is arbitrary, just to organize stuff....
// 0x0000 .. 0x0FFF -- System variables and reserved by the display
// 0x1000 .. 0x1FFF -- Variables to never change location, regardless of UI Version
// 0x2000 .. 0x2FFF -- Controls (VPs that will trigger some action)
// 0x3000 .. 0x4FFF -- Marlin Data to be displayed
// 0x5000 .. -- SPs (if we want to modify display elements, e.g change color or like) -- currently unused
// As there is plenty of space (at least most displays have >8k RAM), we do not pack them too tight,
// so that we can keep variables nicely together in the address space.
// UI Version always on 0x1000...0x1002 so that the firmware can check this and bail out.
// constexpr uint16_t VP_UI_VERSION_MAJOR = 0x1000; // Major -- incremented when incompatible
// constexpr uint16_t VP_UI_VERSION_MINOR = 0x1001; // Minor -- incremented on new features, but compatible
// constexpr uint16_t VP_UI_VERSION_PATCH = 0x1002; // Patch -- fixed which do not change functionality.
// constexpr uint16_t VP_UI_FLAVOUR = 0x1010; // lets reserve 16 bytes here to determine if UI is suitable for this Marlin. tbd.
#define VP_STARTPROGRESSBAR 0x1000
// // Storage space for the Killscreen messages. Reused for the popup.
constexpr uint16_t VP_MSGSTR1 = 0x2010;
constexpr uint8_t VP_MSGSTR1_LEN = 0x20; // might be more place for it...
constexpr uint16_t VP_MSGSTR2 = 0x2030;
constexpr uint8_t VP_MSGSTR2_LEN = 0x40;
constexpr uint16_t VP_MSGSTR3 = 0x2070;
constexpr uint8_t VP_MSGSTR3_LEN = 0x40;
//constexpr uint16_t VP_MSGSTR4 = 0x11C0;
// constexpr uint8_t VP_MSGSTR4_LEN = 0x20;
// // Screenchange request for screens that only make sense when printer is idle.
// // e.g movement is only allowed if printer is not printing.
// // Marlin must confirm by setting the screen manually.
// constexpr uint16_t VP_SCREENCHANGE_ASK = 0x2000;
constexpr uint16_t VP_SCREENCHANGE = 0x219f; // Key-Return button to new menu pressed. Data contains target screen in low byte and info in high byte.
// constexpr uint16_t VP_TEMP_ALL_OFF = 0x2002; // Turn all heaters off. Value arbitrary ;)=
// constexpr uint16_t VP_SCREENCHANGE_WHENSD = 0x2003; // "Print" Button touched -- go only there if there is an SD Card.
constexpr uint16_t VP_CONFIRMED = 0x219E; // OK on confirm screen.
// // Buttons on the SD-Card File listing.
// constexpr uint16_t VP_SD_ScrollEvent = 0x2020; // Data: 0 for "up a directory", numbers are the amount to scroll, e.g -1 one up, 1 one down
// constexpr uint16_t VP_SD_FileSelected = 0x2022; // Number of file field selected.
constexpr uint16_t VP_SD_FileSelectConfirm = 0x2024; // (This is a virtual VP and emulated by the Confirm Screen when a file has been confirmed)
// constexpr uint16_t VP_SD_ResumePauseAbort = 0x2026; // Resume(Data=0), Pause(Data=1), Abort(Data=2) SD Card prints
constexpr uint16_t VP_SD_AbortPrintConfirmed = 0x2028; // Abort print confirmation (virtual, will be injected by the confirm dialog)
// constexpr uint16_t VP_SD_Print_Setting = 0x2040;
// constexpr uint16_t VP_SD_Print_LiveAdjustZ = 0x2050; // Data: 0 down, 1 up
// // Controls for movement (we can't use the incremental / decremental feature of the display at this feature works only with 16 bit values
// // (which would limit us to 655.35mm, which is likely not a problem for common setups, but i don't want to rule out hangprinters support)
// // A word about the coding: The VP will be per axis and the return code will be an signed 16 bit value in 0.01 mm resolution, telling us
// // the relative travel amount t he user wants to do. So eg. if the display sends us VP=2100 with value 100, the user wants us to move X by +1 mm.
constexpr uint16_t VP_MOVE_X = 0x2100;
constexpr uint16_t VP_MOVE_Y = 0x2102;
constexpr uint16_t VP_MOVE_Z = 0x2104;
constexpr uint16_t VP_MOVE_E0 = 0x2110;
// constexpr uint16_t VP_MOVE_E1 = 0x2112;
// //constexpr uint16_t VP_MOVE_E2 = 0x2114;
// //constexpr uint16_t VP_MOVE_E3 = 0x2116;
// //constexpr uint16_t VP_MOVE_E4 = 0x2118;
// //constexpr uint16_t VP_MOVE_E5 = 0x211A;
constexpr uint16_t VP_HOME_ALL = 0x2120;
// constexpr uint16_t VP_MOTOR_LOCK_UNLOK = 0x2130;
// // Power loss recovery
// constexpr uint16_t VP_POWER_LOSS_RECOVERY = 0x2180;
// // Fan Control Buttons , switch between "off" and "on"
// constexpr uint16_t VP_FAN0_CONTROL = 0x2200;
// constexpr uint16_t VP_FAN1_CONTROL = 0x2202;
// //constexpr uint16_t VP_FAN2_CONTROL = 0x2204;
// //constexpr uint16_t VP_FAN3_CONTROL = 0x2206;
// // Heater Control Buttons , triged between "cool down" and "heat PLA" state
constexpr uint16_t VP_E0_CONTROL = 0x2210;
// constexpr uint16_t VP_E1_CONTROL = 0x2212;
// //constexpr uint16_t VP_E2_CONTROL = 0x2214;
// //constexpr uint16_t VP_E3_CONTROL = 0x2216;
// //constexpr uint16_t VP_E4_CONTROL = 0x2218;
// //constexpr uint16_t VP_E5_CONTROL = 0x221A;
constexpr uint16_t VP_BED_CONTROL = 0x221C;
// // Preheat
// constexpr uint16_t VP_E0_BED_PREHEAT = 0x2220;
// constexpr uint16_t VP_E1_BED_CONTROL = 0x2222;
// //constexpr uint16_t VP_E2_BED_CONTROL = 0x2224;
// //constexpr uint16_t VP_E3_BED_CONTROL = 0x2226;
// //constexpr uint16_t VP_E4_BED_CONTROL = 0x2228;
// //constexpr uint16_t VP_E5_BED_CONTROL = 0x222A;
// // Filament load and unload
// constexpr uint16_t VP_E0_FILAMENT_LOAD_UNLOAD = 0x2300;
// constexpr uint16_t VP_E1_FILAMENT_LOAD_UNLOAD = 0x2302;
// // Settings store , reset
// constexpr uint16_t VP_SETTINGS = 0x2400;
// // PID autotune
constexpr uint16_t VP_PID_AUTOTUNE_E0 = 0x2410;
// //constexpr uint16_t VP_PID_AUTOTUNE_E1 = 0x2412;
// //constexpr uint16_t VP_PID_AUTOTUNE_E2 = 0x2414;
// //constexpr uint16_t VP_PID_AUTOTUNE_E3 = 0x2416;
// //constexpr uint16_t VP_PID_AUTOTUNE_E4 = 0x2418;
// //constexpr uint16_t VP_PID_AUTOTUNE_E5 = 0x241A;
constexpr uint16_t VP_PID_AUTOTUNE_BED = 0x2420;
// // Firmware version on the boot screen.
constexpr uint16_t VP_PRINTER_BEDSIZE = 0x1074;
constexpr uint16_t VP_PRINTER_BEDSIZE_LEN = 12;
constexpr uint16_t VP_MARLIN_VERSION = 0x2222;
constexpr uint8_t VP_MARLIN_VERSION_LEN = 20; // there is more space on the display, if needed.
// Material preheat settings
constexpr uint16_t VP_PREHEAT_PLA_HOTEND_TEMP = 0x1102;
constexpr uint16_t VP_PREHEAT_PLA_BED_TEMP = 0x1104;
constexpr uint16_t VP_PREHEAT_ABS_HOTEND_TEMP = 0x1108;
constexpr uint16_t VP_PREHEAT_ABS_BED_TEMP = 0x110a;
// // Place for status messages.
constexpr uint16_t VP_M117 = 0x21B3;
constexpr uint8_t VP_M117_LEN = 0x20;
// // Temperatures.
constexpr uint16_t VP_T_E0_Is = 0x1036; // 4 Byte Integer - HEAD_CURRENT_TEMP_VP
constexpr uint16_t VP_T_E0_Set = 0x1034; // 2 Byte Integer - HEAD_SET_TEMP_VP
// constexpr uint16_t VP_T_E1_Is = 0x3064; // 4 Byte Integer
// // reserved to support up to 6 Extruders:
// //constexpr uint16_t VP_T_E1_Set = 0x3066; // 2 Byte Integer
// //constexpr uint16_t VP_T_E2_Is = 0x3068; // 4 Byte Integer
// //constexpr uint16_t VP_T_E2_Set = 0x306A; // 2 Byte Integer
// //constexpr uint16_t VP_T_E3_Is = 0x306C; // 4 Byte Integer
// //constexpr uint16_t VP_T_E3_Set = 0x306E; // 2 Byte Integer
// //constexpr uint16_t VP_T_E4_Is = 0x3070; // 4 Byte Integer
// //constexpr uint16_t VP_T_E4_Set = 0x3072; // 2 Byte Integer
// //constexpr uint16_t VP_T_E4_Is = 0x3074; // 4 Byte Integer
// //constexpr uint16_t VP_T_E4_Set = 0x3076; // 2 Byte Integer
// //constexpr uint16_t VP_T_E5_Is = 0x3078; // 4 Byte Integer
// //constexpr uint16_t VP_T_E5_Set = 0x307A; // 2 Byte Integer
constexpr uint16_t VP_T_Bed_Is = 0x103c; // 4 Byte Integer - BED_SET_TEMP_VP
constexpr uint16_t VP_T_Bed_Set = 0x103A; // 2 Byte Integer - BED_CURRENT_TEMP_VP
constexpr uint16_t VP_Flowrate_E0 = 0x3090; // 2 Byte Integer
// constexpr uint16_t VP_Flowrate_E1 = 0x3092; // 2 Byte Integer
// constexpr uint16_t VP_Fan0_Percentage = 0x3100; // 2 Byte Integer (0..100)
// constexpr uint16_t VP_Fan1_Percentage = 0x33A2; // 2 Byte Integer (0..100)
// //constexpr uint16_t VP_Fan2_Percentage = 0x33A4; // 2 Byte Integer (0..100)
// //constexpr uint16_t VP_Fan3_Percentage = 0x33A6; // 2 Byte Integer (0..100)
constexpr uint16_t VP_Feedrate_Percentage = 0x1006; // 2 Byte Integer (0..100) - PRINT_SPEED_RATE_VP
constexpr uint16_t VP_PrintProgress_Percentage = 0x1016; // 2 Byte Integer (0..100)
constexpr uint16_t VP_PrintTimeProgressBar = 0x100E;
constexpr uint16_t VP_PrintTime = 0x21a0;
constexpr uint16_t VP_PrintTime_LEN = 6;
// constexpr uint16_t VP_PrintAccTime = 0x3160;
// constexpr uint16_t VP_PrintAccTime_LEN = 32;
// constexpr uint16_t VP_PrintsTotal = 0x3180;
// constexpr uint16_t VP_PrintsTotal_LEN = 16;
// // Actual Position
// constexpr uint16_t VP_XPos = 0x3110; // 4 Byte Fixed point number; format xxx.yy
// constexpr uint16_t VP_YPos = 0x3112; // 4 Byte Fixed point number; format xxx.yy
constexpr uint16_t VP_ZPos = 0x1026; // 4 Byte Fixed point number; format xxx.yy - AUTO_BED_LEVEL_ZOFFSET_VP [SD: this is actually Z-offset?]
// constexpr uint16_t VP_EPos = 0x3120; // 4 Byte Fixed point number; format xxx.yy
// // SDCard File Listing
constexpr uint16_t VP_SD_ScrollEvent = 0x20D4; // Data: 0 for "up a directory", numbers are the amount to scroll, e.g -1 one up, 1 one down
constexpr uint16_t VP_SD_FileSelected = 0x2200; // Number of file field selected.
constexpr uint16_t VP_SD_FileName_LEN = 21; // LEN is shared for all entries.
constexpr uint16_t VP_SD_FileName_CNT = 6; // LEN is shared for all entries.
constexpr uint16_t DGUS_SD_FILESPERSCREEN = VP_SD_FileName_CNT; // FIXME move that info to the display and read it from there.
constexpr uint16_t VP_SD_FileName0 = 0x20D5;
constexpr uint16_t VP_SD_FileName1 = VP_SD_FileName0 + VP_SD_FileName_LEN;
constexpr uint16_t VP_SD_FileName2 = VP_SD_FileName1 + VP_SD_FileName_LEN;
constexpr uint16_t VP_SD_FileName3 = VP_SD_FileName2 + VP_SD_FileName_LEN;
constexpr uint16_t VP_SD_FileName4 = VP_SD_FileName3 + VP_SD_FileName_LEN;
constexpr uint16_t VP_SD_FileName5 = VP_SD_FileName4 + VP_SD_FileName_LEN;
constexpr uint16_t VP_SD_Print_ProbeOffsetZ = 0x32A0; //
constexpr uint16_t VP_SD_Print_Filename = 0x2000; //
constexpr uint16_t VP_ICON_OVERLAY_CLEAR = 10;
constexpr uint16_t VP_ICON_OVERLAY_SELECTED = 6;
// // Fan status
// constexpr uint16_t VP_FAN0_STATUS = 0x3300;
// constexpr uint16_t VP_FAN1_STATUS = 0x3302;
// //constexpr uint16_t VP_FAN2_STATUS = 0x3304;
// //constexpr uint16_t VP_FAN3_STATUS = 0x3306;
// // Heater status
// constexpr uint16_t VP_E0_STATUS = 0x3310;
// //constexpr uint16_t VP_E1_STATUS = 0x3312;
// //constexpr uint16_t VP_E2_STATUS = 0x3314;
// //constexpr uint16_t VP_E3_STATUS = 0x3316;
// //constexpr uint16_t VP_E4_STATUS = 0x3318;
// //constexpr uint16_t VP_E5_STATUS = 0x331A;
// constexpr uint16_t VP_BED_STATUS = 0x331C;
// constexpr uint16_t VP_MOVE_OPTION = 0x3400;
// // Step per mm
constexpr uint16_t VP_X_STEP_PER_MM = 0x3600; // at the moment , 2 byte unsigned int , 0~1638.4
// //constexpr uint16_t VP_X2_STEP_PER_MM = 0x3602;
constexpr uint16_t VP_Y_STEP_PER_MM = 0x3604;
// //constexpr uint16_t VP_Y2_STEP_PER_MM = 0x3606;
constexpr uint16_t VP_Z_STEP_PER_MM = 0x3608;
// //constexpr uint16_t VP_Z2_STEP_PER_MM = 0x360A;
constexpr uint16_t VP_E0_STEP_PER_MM = 0x3610;
// //constexpr uint16_t VP_E1_STEP_PER_MM = 0x3612;
// //constexpr uint16_t VP_E2_STEP_PER_MM = 0x3614;
// //constexpr uint16_t VP_E3_STEP_PER_MM = 0x3616;
// //constexpr uint16_t VP_E4_STEP_PER_MM = 0x3618;
// //constexpr uint16_t VP_E5_STEP_PER_MM = 0x361A;
// // PIDs
constexpr uint16_t VP_E0_PID_P = 0x3700; // at the moment , 2 byte unsigned int , 0~1638.4
constexpr uint16_t VP_E0_PID_I = 0x3702;
constexpr uint16_t VP_E0_PID_D = 0x3704;
constexpr uint16_t VP_BED_PID_P = 0x3710;
constexpr uint16_t VP_BED_PID_I = 0x3712;
constexpr uint16_t VP_BED_PID_D = 0x3714;
// // Wating screen status
// constexpr uint16_t VP_WAITING_STATUS = 0x3800;
// // SPs for certain variables...
// // located at 0x5000 and up
// // Not used yet!
// // This can be used e.g to make controls / data display invisible
// constexpr uint16_t SP_T_E0_Is = 0x5000;
// constexpr uint16_t SP_T_E0_Set = 0x5010;
// constexpr uint16_t SP_T_E1_Is = 0x5020;
// constexpr uint16_t SP_T_Bed_Is = 0x5030;
// constexpr uint16_t SP_T_Bed_Set = 0x5040;
// Power loss recovery
constexpr uint16_t VP_POWER_LOSS_RECOVERY = 0x105F;
// Buttons defined by Creality - Don't worry if you're confused by the naming, so am I
constexpr uint16_t VP_BUTTON_MAINENTERKEY = 0x1002;
constexpr uint16_t VP_BUTTON_ADJUSTENTERKEY = 0x1004;
constexpr uint16_t VP_BUTTON_PAUSEPRINTKEY = 0x100A;
constexpr uint16_t VP_BUTTON_TEMPCONTROL = 0x1030;
constexpr uint16_t VP_BUTTON_COOLDOWN = 0x1032;
constexpr uint16_t VP_BUTTON_PREPAREENTERKEY = 0x103E;
constexpr uint16_t VP_BUTTON_SELECTFILEKEY = 0x20D3;
constexpr uint16_t VP_BUTTON_STARTPRINTKEY = 0x20D2;
constexpr uint16_t VP_BUTTON_STOPPRINTKEY = 0x1008;
constexpr uint16_t VP_BUTTON_RESUMEPRINTKEY = 0x100C;
constexpr uint16_t VP_BUTTON_BEDLEVELKEY = 0x1044;
constexpr uint16_t VP_BUTTON_HEATLOADSTARTKEY = 0x1056;
// Additional stuff defined by Creality
constexpr uint16_t VP_FAN_TOGGLE = 0x101E;
constexpr uint16_t VP_LED_TOGGLE = 0x101F;
constexpr uint16_t VP_STEPPERS = 0x1200;
constexpr uint16_t VP_MESH_LEVEL_TEMP = 0x108A;
constexpr uint16_t VP_MESH_LEVEL_STATUS = 0x108D;
constexpr uint16_t VP_FEED_AMOUNT = 0x1054;
constexpr uint16_t VP_FEED_PROGRESS = 0x108e;
// Icons
constexpr uint16_t ICON_TOGGLE_ON = 1;
constexpr uint16_t ICON_TOGGLE_OFF = 2;
// Additional variables to migrate later
extern bool LEDStatus;

View file

@ -26,7 +26,7 @@
#if ENABLED(DGUS_LCD_UI_HIPRECY) #if ENABLED(DGUS_LCD_UI_HIPRECY)
#include "../DGUSDisplayDef.h" #include "DGUSDisplayDef.h"
#include "../DGUSDisplay.h" #include "../DGUSDisplay.h"
#include "../DGUSScreenHandler.h" #include "../DGUSScreenHandler.h"

View file

@ -21,6 +21,8 @@
*/ */
#pragma once #pragma once
#include "../DGUSDisplayDef.h"
enum DGUSLCD_Screens : uint8_t { enum DGUSLCD_Screens : uint8_t {
DGUSLCD_SCREEN_BOOT = 160, DGUSLCD_SCREEN_BOOT = 160,
DGUSLCD_SCREEN_MAIN = 1, DGUSLCD_SCREEN_MAIN = 1,

View file

@ -26,7 +26,7 @@
#if ENABLED(DGUS_LCD_UI_ORIGIN) #if ENABLED(DGUS_LCD_UI_ORIGIN)
#include "../DGUSDisplayDef.h" #include "DGUSDisplayDef.h"
#include "../DGUSDisplay.h" #include "../DGUSDisplay.h"
#include "../DGUSScreenHandler.h" #include "../DGUSScreenHandler.h"

View file

@ -21,6 +21,8 @@
*/ */
#pragma once #pragma once
#include "../DGUSDisplayDef.h"
enum DGUSLCD_Screens : uint8_t { enum DGUSLCD_Screens : uint8_t {
DGUSLCD_SCREEN_BOOT = 0, DGUSLCD_SCREEN_BOOT = 0,
DGUSLCD_SCREEN_MAIN = 10, DGUSLCD_SCREEN_MAIN = 10,

View file

@ -0,0 +1,332 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
//#define DEBUG_DGUSLCD
//#define DEBUG_DGUSLCD_COMM
/* DGUS implementation written by coldtobi in 2019 for Marlin */
#include "../../../../inc/MarlinConfigPre.h"
#if ENABLED(DGUS_LCD_UI_CREALITY_TOUCH)
#if HOTENDS > 2
#error "More than 2 hotends not implemented on the Display UI design."
#endif
#include "../../ui_api.h"
#include "../../../../MarlinCore.h"
#include "../../../../module/temperature.h"
#include "../../../../module/motion.h"
#include "../../../../gcode/queue.h"
#include "../../../../module/planner.h"
#include "../../../../sd/cardreader.h"
#include "../../../../libs/duration_t.h"
#include "../../../../module/printcounter.h"
#if ENABLED(POWER_LOSS_RECOVERY)
#include "../../../../feature/powerloss.h"
#endif
#include "DGUSDisplay.h"
#include "../dgus/DGUSVPVariable.h"
#include "../dgus/DGUSDisplayDef.h"
#define DEBUG_OUT ENABLED(DEBUG_DGUSLCD)
#include "../../../../core/debug_out.h"
#if DEBUG_DGUSLCD_COMM
#define DEBUGLCDCOMM_ECHOPAIR DEBUG_ECHOPAIR
#define DEBUGLCDCOMM_ECHOPGM DEBUG_ECHOPGM
#else
#define DEBUGLCDCOMM_ECHOPAIR(...) NOOP
#define DEBUGLCDCOMM_ECHOPGM(...) NOOP
#endif
// Preamble... 2 Bytes, usually 0x5A 0xA5, but configurable
constexpr uint8_t DGUS_HEADER1 = 0x5A;
constexpr uint8_t DGUS_HEADER2 = 0xA5;
constexpr uint8_t DGUS_CMD_WRITEVAR = 0x82;
constexpr uint8_t DGUS_CMD_READVAR = 0x83;
#if ENABLED(DEBUG_DGUSLCD)
bool dguslcd_local_debug; // = false;
#endif
void DGUSDisplay::InitDisplay() {
LCD_SERIAL.begin(LCD_BAUDRATE);
/*
delay(500); // Attempt to fix possible handshake error
ResetDisplay(); // Reset for firmware update
delay(500); // Attempt to fix possible handshake error
*/
if (TERN1(POWER_LOSS_RECOVERY, !recovery.valid())
RequestScreen(TERN_(SHOW_BOOTSCREEN, DGUSLCD_SCREEN_BOOT, DGUSLCD_SCREEN_MAIN));
}
void DGUSDisplay::ResetDisplay() {
DEBUG_ECHOLNPGM("ResetDisplay");
const unsigned char resetCommand[] = { 0x55, 0xAA, 0x5A, 0xA5 };
WriteVariable(0x04, resetCommand, sizeof(resetCommand));
}
void DGUSDisplay::ReadVariable(uint16_t adr) {
WriteHeader(adr, DGUS_CMD_READVAR, sizeof(uint8_t));
// Specify to read one byte
LCD_SERIAL.write(static_cast<uint8_t>(1));
}
void DGUSDisplay::WriteVariable(uint16_t adr, const void* values, uint8_t valueslen, bool isstr) {
const char* myvalues = static_cast<const char*>(values);
bool strend = !myvalues;
WriteHeader(adr, DGUS_CMD_WRITEVAR, valueslen);
while (valueslen--) {
char x;
if (!strend) x = *myvalues++;
if ((isstr && !x) || strend) {
strend = true;
x = ' ';
}
LCD_SERIAL.write(x);
}
}
void DGUSDisplay::WriteVariable(uint16_t adr, uint16_t value) {
value = (value & 0xffU) << 8U | (value >> 8U);
WriteVariable(adr, static_cast<const void*>(&value), sizeof(uint16_t));
}
void DGUSDisplay::WriteVariable(uint16_t adr, int16_t value) {
value = (value & 0xffU) << 8U | (value >> 8U);
WriteVariable(adr, static_cast<const void*>(&value), sizeof(uint16_t));
}
void DGUSDisplay::WriteVariable(uint16_t adr, uint8_t value) {
WriteVariable(adr, static_cast<const void*>(&value), sizeof(uint8_t));
}
void DGUSDisplay::WriteVariable(uint16_t adr, int8_t value) {
WriteVariable(adr, static_cast<const void*>(&value), sizeof(int8_t));
}
void DGUSDisplay::WriteVariable(uint16_t adr, long value) {
union { long l; char lb[4]; } endian;
char tmp[4];
endian.l = value;
tmp[0] = endian.lb[3];
tmp[1] = endian.lb[2];
tmp[2] = endian.lb[1];
tmp[3] = endian.lb[0];
WriteVariable(adr, static_cast<const void*>(&tmp), sizeof(long));
}
void DGUSDisplay::WriteVariablePGM(uint16_t adr, const void* values, uint8_t valueslen, bool isstr) {
const char* myvalues = static_cast<const char*>(values);
bool strend = !myvalues;
WriteHeader(adr, DGUS_CMD_WRITEVAR, valueslen);
while (valueslen--) {
char x;
if (!strend) x = pgm_read_byte(myvalues++);
if ((isstr && !x) || strend) {
strend = true;
x = ' ';
}
LCD_SERIAL.write(x);
}
}
void DGUSDisplay::ProcessRx() {
#if ENABLED(DGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS)
if (!LCD_SERIAL.available() && LCD_SERIAL.buffer_overruns()) {
// Overrun, but reset the flag only when the buffer is empty
// We want to extract as many as valid datagrams possible...
DEBUG_ECHOPGM("OVFL");
rx_datagram_state = DGUS_IDLE;
//LCD_SERIAL.reset_rx_overun();
LCD_SERIAL.flush();
}
#endif
uint8_t receivedbyte;
while (LCD_SERIAL.available()) {
switch (rx_datagram_state) {
case DGUS_IDLE: // Waiting for the first header byte
receivedbyte = LCD_SERIAL.read();
//DEBUGLCDCOMM_ECHOPAIR("< ",receivedbyte);
if (DGUS_HEADER1 == receivedbyte) rx_datagram_state = DGUS_HEADER1_SEEN;
break;
case DGUS_HEADER1_SEEN: // Waiting for the second header byte
receivedbyte = LCD_SERIAL.read();
//DEBUGLCDCOMM_ECHOPAIR(" ", receivedbyte);
rx_datagram_state = (DGUS_HEADER2 == receivedbyte) ? DGUS_HEADER2_SEEN : DGUS_IDLE;
break;
case DGUS_HEADER2_SEEN: // Waiting for the length byte
rx_datagram_len = LCD_SERIAL.read();
//DEBUGLCDCOMM_ECHOPAIR(" (", rx_datagram_len, ") ");
// Telegram min len is 3 (command and one word of payload)
rx_datagram_state = WITHIN(rx_datagram_len, 3, DGUS_RX_BUFFER_SIZE) ? DGUS_WAIT_TELEGRAM : DGUS_IDLE;
break;
case DGUS_WAIT_TELEGRAM: // wait for complete datagram to arrive.
if (LCD_SERIAL.available() < rx_datagram_len) return;
Initialized = true; // We've talked to it, so we defined it as initialized.
uint8_t command = LCD_SERIAL.read();
// DEBUGLCDCOMM_ECHOPAIR("# ", command);
uint8_t readlen = rx_datagram_len - 1; // command is part of len.
unsigned char tmp[rx_datagram_len - 1];
unsigned char *ptmp = tmp;
while (readlen--) {
receivedbyte = LCD_SERIAL.read();
//DEBUGLCDCOMM_ECHOPAIR(" ", receivedbyte);
*ptmp++ = receivedbyte;
}
//DEBUGLCDCOMM_ECHOPGM(" # ");
// mostly we'll get this: 5A A5 03 82 4F 4B -- ACK on 0x82, so discard it.
if (command == DGUS_CMD_WRITEVAR && 'O' == tmp[0] && 'K' == tmp[1]) {
//DEBUG_ECHOLNPGM(">");
rx_datagram_state = DGUS_IDLE;
break;
}
/* AutoUpload, (and answer to) Command 0x83 :
| tmp[0 1 2 3 4 ... ]
| Example 5A A5 06 83 20 01 01 78 01
| / / | | \ / | \ \
| Header | | | | \_____\_ DATA (Words!)
| DatagramLen / VPAdr |
| Command DataLen (in Words) */
if (command == DGUS_CMD_READVAR) {
const uint16_t vp = tmp[0] << 8 | tmp[1];
if (vp == 0x14 /*PIC_Now*/) {
const uint16_t screen_id = tmp[3] << 8 | tmp[4];
// In the code below DGUSLCD_SCREEN_BOOT acts as a sentinel
if (screen_id == 255) {
// DGUS OS sometimes randomly sends 255 back as an answer. Possible buffer overrun?
ReadCurrentScreen(); // Request again
} else if (displayRequest != DGUSLCD_SCREEN_BOOT && screen_id != displayRequest) {
// A display was requested. If the screen didn't yet switch to that display, we won't give that value back, otherwise the code gets confused.
// The DWIN display mostly honours the PIC_SET requests from the firmware, so after a while we may want to nudge it to the correct screen
DEBUG_ECHOPAIR(" Got a response on the current screen: ", screen_id);
DEBUG_ECHOLNPAIR(" - however, we've requested screen ", displayRequest);
} else {
displayRequest = DGUSLCD_SCREEN_BOOT;
if (current_screen_update_callback != nullptr) {
current_screen_update_callback(static_cast<DGUSLCD_Screens>(screen_id));
}
}
} else {
//const uint8_t dlen = tmp[2] << 1; // Convert to Bytes. (Display works with words)
//DEBUG_ECHOPAIR(" vp=", vp, " dlen=", dlen);
DGUS_VP_Variable ramcopy;
DEBUG_ECHOLNPAIR("VP received: ", vp , " - val ", tmp[3]);
if (populate_VPVar(vp, &ramcopy)) {
if (ramcopy.set_by_display_handler)
ramcopy.set_by_display_handler(ramcopy, &tmp[3]);
else
DEBUG_ECHOLNPGM(" VPVar found, no handler.");
}
else
DEBUG_ECHOLNPAIR(" VPVar not found:", vp);
// Always ask for a screen update so we can send a screen update earlier, this prevents a flash of unstyled screen
ReadCurrentScreen();
}
rx_datagram_state = DGUS_IDLE;
break;
}
// discard anything else
rx_datagram_state = DGUS_IDLE;
}
}
}
size_t DGUSDisplay::GetFreeTxBuffer() { return SERIAL_GET_TX_BUFFER_FREE(); }
void DGUSDisplay::WriteHeader(uint16_t adr, uint8_t cmd, uint8_t payloadlen) {
LCD_SERIAL.write(DGUS_HEADER1);
LCD_SERIAL.write(DGUS_HEADER2);
LCD_SERIAL.write(payloadlen + 3);
LCD_SERIAL.write(cmd);
LCD_SERIAL.write(adr >> 8);
LCD_SERIAL.write(adr & 0xFF);
}
void DGUSDisplay::WritePGM(const char str[], uint8_t len) {
while (len--) LCD_SERIAL.write(pgm_read_byte(str++));
}
void DGUSDisplay::loop() {
// protect against recursion… ProcessRx() may indirectly call idle() when injecting gcode commands.
if (!no_reentrance) {
no_reentrance = true;
ProcessRx();
no_reentrance = false;
}
}
void DGUSDisplay::RequestScreen(DGUSLCD_Screens screen) {
displayRequest = screen;
DEBUG_ECHOLNPAIR("GotoScreen ", screen);
const unsigned char gotoscreen[] = { 0x5A, 0x01, (unsigned char) (screen >> 8U), (unsigned char) (screen & 0xFFU) };
WriteVariable(0x84, gotoscreen, sizeof(gotoscreen));
}
void DGUSDisplay::ReadCurrentScreen() {
ReadVariable(0x14 /*PIC_NOW*/);
}
rx_datagram_state_t DGUSDisplay::rx_datagram_state = DGUS_IDLE;
uint8_t DGUSDisplay::rx_datagram_len = 0;
bool DGUSDisplay::Initialized = false;
bool DGUSDisplay::no_reentrance = false;
DGUSLCD_Screens DGUSDisplay::displayRequest = DGUSLCD_SCREEN_BOOT;
// A SW memory barrier, to ensure GCC does not overoptimize loops
#define sw_barrier() asm volatile("": : :"memory");
bool populate_VPVar(const uint16_t VP, DGUS_VP_Variable * const ramcopy) {
//DEBUG_ECHOLNPAIR("populate_VPVar ", VP);
const DGUS_VP_Variable *pvp = DGUSLCD_FindVPVar(VP);
// DEBUG_ECHOLNPAIR(" pvp ", (uint16_t )pvp);
if (!pvp) return false;
memcpy_P(ramcopy, pvp, sizeof(DGUS_VP_Variable));
return true;
}
#endif // HAS_DGUS_LCD

View file

@ -0,0 +1,126 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
/* DGUS implementation written by coldtobi in 2019 for Marlin */
#include "../../../../inc/MarlinConfigPre.h"
#include "../../../../MarlinCore.h"
#if HAS_BED_PROBE
#include "../../../../module/probe.h"
#endif
#include "../dgus/DGUSVPVariable.h"
enum DGUSLCD_Screens : uint8_t;
typedef enum : uint8_t {
DGUS_IDLE, //< waiting for DGUS_HEADER1.
DGUS_HEADER1_SEEN, //< DGUS_HEADER1 received
DGUS_HEADER2_SEEN, //< DGUS_HEADER2 received
DGUS_WAIT_TELEGRAM, //< LEN received, Waiting for to receive all bytes.
} rx_datagram_state_t;
typedef void (*screenUpdateCallback_t)(DGUSLCD_Screens screen);
// Low-Level access to the display.
class DGUSDisplay {
public:
DGUSDisplay() = default;
static void InitDisplay();
static void ResetDisplay();
// Variable access.
static void WriteVariable(uint16_t adr, const void* values, uint8_t valueslen, bool isstr=false);
static void WriteVariablePGM(uint16_t adr, const void* values, uint8_t valueslen, bool isstr=false);
static void WriteVariable(uint16_t adr, int16_t value);
static void WriteVariable(uint16_t adr, uint16_t value);
static void WriteVariable(uint16_t adr, uint8_t value);
static void WriteVariable(uint16_t adr, int8_t value);
static void WriteVariable(uint16_t adr, long value);
static void ReadVariable(uint16_t adr);
// Utility functions for bridging ui_api and dgus
template<typename T, float(*Getter)(const T), T selector, typename WireType=uint16_t>
static void SetVariable(DGUS_VP_Variable &var) {
WriteVariable(var.VP, (WireType)Getter(selector));
}
template<typename T, void(*Setter)(const float V, const T), T selector>
static void GetVariable(DGUS_VP_Variable &var, void *val_ptr) {
uint16_t newvalue = swap16(*(uint16_t*)val_ptr);
Setter(newvalue, selector);
}
// Until now I did not need to actively read from the display. That's why there is no ReadVariable
// (I extensively use the auto upload of the display)
// Force display into another screen.
// (And trigger update of containing VPs)
// (to implement a pop up message, which may not be nested)
static void RequestScreen(DGUSLCD_Screens screen);
// Request the current displayed screen - will be passed to current_screen_update_callback
static void ReadCurrentScreen();
// Periodic tasks, eg. Rx-Queue handling.
static void loop();
public:
// Helper for users of this class to estimate if an interaction would be blocking.
static size_t GetFreeTxBuffer();
// Checks two things: Can we confirm the presence of the display and has we initiliazed it.
// (both boils down that the display answered to our chatting)
static inline bool isInitialized() { return Initialized; }
static screenUpdateCallback_t current_screen_update_callback;
private:
static void WriteHeader(uint16_t adr, uint8_t cmd, uint8_t payloadlen);
static void WritePGM(const char str[], uint8_t len);
static void ProcessRx();
static inline uint16_t swap16(const uint16_t value) { return (value & 0xffU) << 8U | (value >> 8U); }
static rx_datagram_state_t rx_datagram_state;
static uint8_t rx_datagram_len;
static bool Initialized, no_reentrance;
static DGUSLCD_Screens displayRequest;
};
#define GET_VARIABLE(f, t, V...) (&DGUSDisplay::GetVariable<decltype(t), f, t, ##V>)
#define SET_VARIABLE(f, t, V...) (&DGUSDisplay::SetVariable<decltype(t), f, t, ##V>)
extern DGUSDisplay dgusdisplay;
// compile-time x^y
constexpr float cpow(const float x, const int y) { return y == 0 ? 1.0 : x * cpow(x, y - 1); }
/// Find the flash address of a DGUS_VP_Variable for the VP.
extern const DGUS_VP_Variable* DGUSLCD_FindVPVar(const uint16_t vp);
/// Helper to populate a DGUS_VP_Variable for a given VP. Return false if not found.
extern bool populate_VPVar(const uint16_t VP, DGUS_VP_Variable * const ramcopy);

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,282 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
//#define DEBUG_DGUS_SCREEN_HANDLER
#include "DGUSDisplay.h"
#include "../dgus/DGUSVPVariable.h"
#include "../../../../inc/MarlinConfig.h"
#define DEBUG_OUT ENABLED(DEBUG_DGUS_SCREEN_HANDLER)
#include "../../../../core/debug_out.h"
enum DGUSLCD_Screens : uint8_t;
class DGUSScreenHandler {
public:
DGUSScreenHandler() = default;
static bool loop();
/// Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen
/// The bools specifing whether the strings are in RAM or FLASH.
static void sendinfoscreen(const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
/// "M117" Message -- msg is a RAM ptr.
static void setstatusmessage(const char* msg);
/// The same for messages from Flash
static void setstatusmessagePGM(PGM_P const msg);
// Callback for VP "Display wants to change screen on idle printer"
static void ScreenChangeHookIfIdle(DGUS_VP_Variable &var, void *val_ptr);
// Callback for VP "Screen has been changed"
static void ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr);
// Callback for VP "All Heaters Off"
static void HandleAllHeatersOff(DGUS_VP_Variable &var, void *val_ptr);
// Hook for "Change this temperature"
static void HandleTemperatureChanged(DGUS_VP_Variable &var, void *val_ptr);
// Hook for "Change Flowrate"
static void HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_ptr);
#if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
// Hook for manual move option
static void HandleManualMoveOption(DGUS_VP_Variable &var, void *val_ptr);
#endif
// Hook for manual move.
static void HandleManualMove(DGUS_VP_Variable &var, void *val_ptr);
// Hook for manual extrude.
static void HandleManualExtrude(DGUS_VP_Variable &var, void *val_ptr);
// Hook for motor lock and unlook
static void HandleMotorLockUnlock(DGUS_VP_Variable &var, void *val_ptr);
#if ENABLED(POWER_LOSS_RECOVERY)
// Hook for power loss recovery.
static void HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr);
#endif
// Hook for settings
static void HandleSettings(DGUS_VP_Variable &var, void *val_ptr);
static void HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr);
static void HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr);
static void HandleFeedAmountChanged(DGUS_VP_Variable &var, void *val_ptr);
#if HAS_PID_HEATING
// Hook for "Change this temperature PID para"
static void HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr);
// Hook for PID autotune
static void HandlePIDAutotune(DGUS_VP_Variable &var, void *val_ptr);
#endif
#if HAS_BED_PROBE
// Hook for "Change probe offset z"
static void HandleZoffsetChange(DGUS_VP_Variable &var, void *val_ptr);
static void HandleProbeOffsetZChanged(DGUS_VP_Variable &var, void *val_ptr);
static void OnMeshLevelingStart();
static void OnMeshLevelingUpdate(const int8_t xpos, const int8_t ypos);
#endif
#if ENABLED(BABYSTEPPING)
// Hook for live z adjust action
static void HandleLiveAdjustZ(DGUS_VP_Variable &var, void *val_ptr);
#endif
#if HAS_FAN
// Hook for fan control
static void HandleFanControl(DGUS_VP_Variable &var, void *val_ptr);
#endif
// Hook for heater control
static void HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr);
#if ENABLED(DGUS_PREHEAT_UI)
// Hook for preheat
static void HandlePreheat(DGUS_VP_Variable &var, void *val_ptr);
#endif
#if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
// Hook for filament load and unload filament option
static void HandleFilamentOption(DGUS_VP_Variable &var, void *val_ptr);
// Hook for filament load and unload
static void HandleFilamentLoadUnload(DGUS_VP_Variable &var);
#endif
#if ENABLED(SDSUPPORT)
// Callback for VP "Display wants to change screen when there is a SD card"
static void ScreenChangeHookIfSD(DGUS_VP_Variable &var, void *val_ptr);
/// Scroll buttons on the file listing screen.
static void DGUSLCD_SD_ScrollFilelist(DGUS_VP_Variable &var, void *val_ptr);
/// File touched.
static void DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr);
/// start print after confirmation received.
static void DGUSLCD_SD_StartPrint(DGUS_VP_Variable &var, void *val_ptr);
/// User hit the pause, resume or abort button.
static void DGUSLCD_SD_ResumePauseAbort(DGUS_VP_Variable &var, void *val_ptr);
/// User confirmed the abort action
static void DGUSLCD_SD_ReallyAbort(DGUS_VP_Variable &var, void *val_ptr);
/// User hit the tune button
static void DGUSLCD_SD_PrintTune(DGUS_VP_Variable &var, void *val_ptr);
/// Send a single filename to the display.
static void DGUSLCD_SD_SendFilename(DGUS_VP_Variable &var);
/// Marlin informed us that a new SD has been inserted.
static void SDCardInserted();
/// Marlin informed us that the SD Card has been removed().
static void SDCardRemoved();
/// Marlin informed us about a bad SD Card.
static void SDCardError();
#endif
static void HandleLEDToggle();
static void HandleStepperState(bool is_enabled);
static void FilamentRunout();
static void OnFactoryReset();
#if HAS_BUZZER
static void Buzzer(const uint16_t frequency, const uint16_t duration);
#endif
static void OnHomingStart();
static void OnHomingComplete();
static void OnPrintFinished();
// OK Button the Confirm screen.
static void ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr);
// Update data after went to new screen (by display or by GotoScreen)
// remember: store the last-displayed screen, so it can get returned to.
// (e.g for pop up messages)
static void UpdateNewScreen(DGUSLCD_Screens newscreen, bool save_current_screen=true);
// Recall the remembered screen.
static void PopToOldScreen();
// Make the display show the screen and update all VPs in it.
static void GotoScreen(DGUSLCD_Screens screen, bool save_current_screen = true);
static void UpdateScreenVPData();
// Helpers to convert and transfer data to the display.
static void DGUSLCD_SendWordValueToDisplay(DGUS_VP_Variable &var);
static void DGUSLCD_SendStringToDisplay(DGUS_VP_Variable &var);
static void DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable &var);
static void DGUSLCD_SendTemperaturePID(DGUS_VP_Variable &var);
static void DGUSLCD_SendPercentageToDisplay(DGUS_VP_Variable &var);
static void DGUSLCD_SendPrintProgressToDisplay(DGUS_VP_Variable &var);
static void DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var);
#if ENABLED(PRINTCOUNTER)
static void DGUSLCD_SendPrintAccTimeToDisplay(DGUS_VP_Variable &var);
static void DGUSLCD_SendPrintsTotalToDisplay(DGUS_VP_Variable &var);
#endif
#if HAS_FAN
static void DGUSLCD_SendFanStatusToDisplay(DGUS_VP_Variable &var);
#endif
static void DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var);
#if ENABLED(DGUS_UI_WAITING)
static void DGUSLCD_SendWaitingStatusToDisplay(DGUS_VP_Variable &var);
#endif
static void DGUSLCD_SendAboutFirmwareVersion(DGUS_VP_Variable &var);
static void DGUSLCD_SendAboutPrintSize(DGUS_VP_Variable &var);
/// Send a value from 0..100 to a variable with a range from 0..255
static void DGUSLCD_PercentageToUint8(DGUS_VP_Variable &var, void *val_ptr);
template<typename T>
static void DGUSLCD_SetValueDirectly(DGUS_VP_Variable &var, void *val_ptr) {
if (!var.memadr) return;
union { unsigned char tmp[sizeof(T)]; T t; } x;
unsigned char *ptr = (unsigned char*)val_ptr;
LOOP_L_N(i, sizeof(T)) x.tmp[i] = ptr[sizeof(T) - i - 1];
*(T*)var.memadr = x.t;
}
/// Send a float value to the display.
/// Display will get a 4-byte integer scaled to the number of digits:
/// Tell the display the number of digits and it cheats by displaying a dot between...
template<unsigned int decimals>
static void DGUSLCD_SendFloatAsLongValueToDisplay(DGUS_VP_Variable &var) {
if (var.memadr) {
float f = *(float *)var.memadr;
f *= cpow(10, decimals);
dgusdisplay.WriteVariable(var.VP, (long)f);
}
}
// Send an icon to the display, depending on whether it is true or false
template<unsigned int value_if_true, unsigned int value_if_false>
static void DGUSLCD_SendIconValue(DGUS_VP_Variable &var) {
if (var.memadr) {
bool value = *(bool *)var.memadr;
uint16_t valueToSend = value ? value_if_true : value_if_false;
dgusdisplay.WriteVariable(var.VP, valueToSend);
}
}
/// Send a float value to the display.
/// Display will get a 2-byte integer scaled to the number of digits:
/// Tell the display the number of digits and it cheats by displaying a dot between...
template<unsigned int decimals>
static void DGUSLCD_SendFloatAsIntValueToDisplay(DGUS_VP_Variable &var) {
if (var.memadr) {
float f = *(float *)var.memadr;
DEBUG_ECHOLNPAIR_F(" >> ", f, 6);
f *= cpow(10, decimals);
dgusdisplay.WriteVariable(var.VP, (int16_t)f);
}
}
/// Force an update of all VP on the current screen.
static inline void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; }
/// Has all VPs sent to the screen
static inline bool IsScreenComplete() { return ScreenComplete; }
static inline DGUSLCD_Screens getCurrentScreen() { return current_screen; }
static void updateCurrentScreen(DGUSLCD_Screens current);
static inline void SetupConfirmAction( void (*f)()) { confirm_action_cb = f; }
static float feed_amount;
static bool are_steppers_enabled;
private:
static DGUSLCD_Screens current_screen; ///< currently on screen
static constexpr uint8_t NUM_PAST_SCREENS = 4;
static DGUSLCD_Screens past_screens[NUM_PAST_SCREENS]; ///< LIFO with past screens for the "back" button.
static uint8_t update_ptr; ///< Last sent entry in the VPList for the actual screen.
static uint16_t skipVP; ///< When updating the screen data, skip this one, because the user is interacting with it.
static bool ScreenComplete; ///< All VPs sent to screen?
static uint16_t ConfirmVP; ///< context for confirm screen (VP that will be emulated-sent on "OK").
static uint8_t MeshLevelIndex;
#if ENABLED(SDSUPPORT)
static int16_t top_file; ///< file on top of file chooser
static int16_t file_to_print; ///< touched file to be confirmed
#endif
static void (*confirm_action_cb)();
};
extern DGUSScreenHandler ScreenHandler;

View file

@ -0,0 +1,350 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "../../../../../inc/MarlinConfigPre.h"
#if ENABLED(DGUS_LCD_UI_CREALITY_TOUCH)
#include "../DGUSDisplayDef.h"
#include "../DGUSDisplay.h"
#include "../DGUSScreenHandler.h"
#include "../../../../../module/temperature.h"
#include "../../../../../module/motion.h"
#include "../../../../../module/planner.h"
#include "../../../../../feature/pause.h"
#include "../../../../../feature/runout.h"
#include "../../../../../module/settings.h"
#include "../../../../marlinui.h"
#include "../../../ui_api.h"
#include "PageHandlers.h"
// Definitions of page handlers
void MainMenuHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
// Nothing
}
void ControlMenuHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
switch (var.VP) {
case VP_BUTTON_PREPAREENTERKEY:
switch (buttonValue) {
case 5: // About
// Automatically handled
break;
case 7: // Reset to factory settings
settings.reset();
settings.save();
break;
case 9: // Back button
// TODO: should navigate automatically
break;
}
break;
case VP_BUTTON_ADJUSTENTERKEY:
ScreenHandler.HandleLEDToggle();
break;
}
}
void LevelingModeHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
switch (var.VP) {
case VP_BUTTON_BEDLEVELKEY:
switch (buttonValue) {
case 1:
if (ExtUI::isAxisPositionKnown(ExtUI::axis_t::X) && ExtUI::isAxisPositionKnown(ExtUI::axis_t::Y))
ExtUI::injectCommands_P("G28 Z");
else
ExtUI::injectCommands_P("G28");
break;
case 2:
// Increase Z-offset
ExtUI::smartAdjustAxis_steps(5, ExtUI::axis_t::Z, true);
ScreenHandler.ForceCompleteUpdate();
break;
case 3:
// Decrease Z-offset
ExtUI::smartAdjustAxis_steps(-5, ExtUI::axis_t::Z, true);
ScreenHandler.ForceCompleteUpdate();
break;
}
break;
case VP_BUTTON_MAINENTERKEY:
// Go to leveling screen
ExtUI::injectCommands_P("G28\nG29");
break;
}
}
void LevelingHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
switch (var.VP) {
case VP_BUTTON_BEDLEVELKEY:
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_ZOFFSET_LEVEL);
break;
}
}
void TempMenuHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
switch (var.VP) {
case VP_BUTTON_ADJUSTENTERKEY:
switch (buttonValue) {
case 3:
DGUSScreenHandler::HandleFanControl(var, &buttonValue);
break;
}
break;
}
}
void PrepareMenuHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
switch (var.VP) {
case VP_BUTTON_PREPAREENTERKEY:
// Disable steppers
ScreenHandler.HandleMotorLockUnlock(var, &buttonValue);
break;
case VP_BUTTON_COOLDOWN:
ScreenHandler.HandleAllHeatersOff(var, &buttonValue);
break;
case VP_BUTTON_TEMPCONTROL:
switch (buttonValue) {
case 5:
thermalManager.setTargetHotend(ui.material_preset[0].hotend_temp, 0);
thermalManager.setTargetBed(ui.material_preset[0].bed_temp);
break;
case 6:
thermalManager.setTargetHotend(ui.material_preset[1].hotend_temp, 0);
thermalManager.setTargetBed(ui.material_preset[1].bed_temp);
break;
}
break;
}
ScreenHandler.ForceCompleteUpdate();
}
void TuneMenuHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
switch (var.VP) {
case VP_BUTTON_ADJUSTENTERKEY:
switch (buttonValue) {
case 2:
ScreenHandler.GotoScreen(ExtUI::isPrintingFromMediaPaused() ? DGUSLCD_SCREEN_PRINT_PAUSED : DGUSLCD_SCREEN_PRINT_RUNNING);
break;
case 3:
DGUSScreenHandler::HandleFanControl(var, &buttonValue);
break;
case 4:
ScreenHandler.HandleLEDToggle();
break;
}
}
}
void PrintRunningMenuHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
// There are actually no buttons to handle here: all buttons navigate to other screens (like confirmation screens)
}
void PrintPausedMenuHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
switch (var.VP) {
case VP_BUTTON_RESUMEPRINTKEY:
runout.reset();
ExtUI::resumePrint();
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_PRINT_RUNNING);
break;
}
}
void PrintPauseDialogHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
switch (var.VP) {
case VP_BUTTON_PAUSEPRINTKEY:
switch (buttonValue) {
case 2:
ExtUI::pausePrint();
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_PRINT_PAUSED);
break;
case 3:
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_PRINT_RUNNING);
break;
}
break;
}
}
void FilamentRunoutHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
switch (var.VP) {
case VP_BUTTON_RESUMEPRINTKEY:
ExtUI::resumePrint();
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_PRINT_RUNNING);
break;
case VP_BUTTON_STOPPRINTKEY:
ExtUI::stopPrint();
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_MAIN);
break;
}
}
void StopConfirmScreenHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
switch (var.VP) {
case VP_BUTTON_STOPPRINTKEY:
switch (buttonValue) {
case 2:
ExtUI::stopPrint();
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_MAIN);
break;
case 3:
ScreenHandler.GotoScreen(ExtUI::isPrintingFromMediaPaused() ? DGUSLCD_SCREEN_PRINT_PAUSED : DGUSLCD_SCREEN_PRINT_RUNNING);
break;
}
break;
}
}
void PreheatSettingsScreenHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
switch (var.VP) {
case VP_BUTTON_PREPAREENTERKEY:
// Save button, save settings and go back
settings.save();
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_TEMP);
break;
case VP_BUTTON_COOLDOWN:
// Back button, discard settings
settings.load();
break;
}
}
void FeedHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
if (var.VP != VP_BUTTON_HEATLOADSTARTKEY) return;
switch (buttonValue) {
case 1:
if (ExtUI::getActualTemp_celsius(ExtUI::H0) < PREHEAT_1_TEMP_HOTEND) {
ExtUI::setTargetTemp_celsius(PREHEAT_1_TEMP_HOTEND, ExtUI::H0);
thermalManager.wait_for_hotend(0);
}
dgusdisplay.WriteVariable(VP_FEED_PROGRESS, static_cast<int16_t>(10));
load_filament(
FILAMENT_CHANGE_SLOW_LOAD_LENGTH,
FILAMENT_CHANGE_FAST_LOAD_LENGTH,
ScreenHandler.feed_amount,
FILAMENT_CHANGE_ALERT_BEEPS,
false,
thermalManager.still_heating(0),
PAUSE_MODE_LOAD_FILAMENT
);
dgusdisplay.WriteVariable(VP_FEED_PROGRESS, static_cast<int16_t>(0));
break;
case 2:
if (ExtUI::getActualTemp_celsius(ExtUI::H0) < PREHEAT_1_TEMP_HOTEND) {
ExtUI::setTargetTemp_celsius(PREHEAT_1_TEMP_HOTEND, ExtUI::H0);
thermalManager.wait_for_hotend(0);
}
dgusdisplay.WriteVariable(VP_FEED_PROGRESS, static_cast<int16_t>(10));
unload_filament(ScreenHandler.feed_amount, false, PAUSE_MODE_UNLOAD_FILAMENT);
dgusdisplay.WriteVariable(VP_FEED_PROGRESS, static_cast<int16_t>(0));
break;
}
ScreenHandler.ForceCompleteUpdate();
}
// Register the page handlers
#define PAGE_HANDLER(SCRID, HDLRPTR) { .ScreenID = SCRID, .Handler = HDLRPTR },
const struct PageHandler PageHandlers[] PROGMEM = {
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_MAIN, MainMenuHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_CONTROL, ControlMenuHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_ZOFFSET_LEVEL, LevelingModeHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_LEVELING, LevelingHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_TEMP, TempMenuHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_TEMP_PLA, PreheatSettingsScreenHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_TEMP_ABS, PreheatSettingsScreenHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_TUNING, TuneMenuHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_FEED, FeedHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_FILAMENTRUNOUT1, FilamentRunoutHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_DIALOG_STOP, StopConfirmScreenHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_PRINT_RUNNING, PrintRunningMenuHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_PRINT_PAUSED, PrintPausedMenuHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_DIALOG_PAUSE, PrintPauseDialogHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_PREPARE, PrepareMenuHandler)
// Terminating
PAGE_HANDLER(static_cast<DGUSLCD_Screens>(0), 0)
};
void DGUSCrealityDisplay_HandleReturnKeyEvent(DGUS_VP_Variable &var, void *val_ptr) {
const struct PageHandler *map = PageHandlers;
const uint16_t *ret;
const DGUSLCD_Screens current_screen = DGUSScreenHandler::getCurrentScreen();
while ((ret = (uint16_t*) pgm_read_ptr(&(map->Handler)))) {
if (map->ScreenID == current_screen) {
unsigned short button_value = *static_cast<unsigned short*>(val_ptr);
button_value = (button_value & 0xffU) << 8U | (button_value >> 8U);
SERIAL_ECHOPAIR("Invoking handler for screen ", current_screen);
SERIAL_ECHOLNPAIR("with VP=", var.VP, " value=", button_value);
map->Handler(var, button_value);
return;
}
map++;
}
}
#endif // DGUS_LCD_UI_CREALITY_TOUCH

View file

@ -0,0 +1,11 @@
#pragma once
// Mapping of handlers per page. This construction is necessary because the CR-6 touch screen re-uses the same button IDs all over the place.
typedef void (*DGUS_CREALITY_SCREEN_BUTTON_HANDLER)(DGUS_VP_Variable &var, unsigned short buttonValue);
struct PageHandler {
DGUSLCD_Screens ScreenID;
DGUS_CREALITY_SCREEN_BUTTON_HANDLER Handler;
};
void DGUSCrealityDisplay_HandleReturnKeyEvent(DGUS_VP_Variable &var, void *val_ptr);

View file

@ -134,6 +134,8 @@ namespace ExtUI {
} }
#if HAS_LEVELING && HAS_MESH #if HAS_LEVELING && HAS_MESH
void onMeshLevelingStart() {}
void onMeshUpdate(const int8_t x, const int8_t y, const float val) { void onMeshUpdate(const int8_t x, const int8_t y, const float val) {
BedMeshScreen::onMeshUpdate(x, y, val); BedMeshScreen::onMeshUpdate(x, y, val);
} }

View file

@ -511,12 +511,15 @@ namespace ExtUI {
// Not needed for Malyan LCD // Not needed for Malyan LCD
void onStatusChanged(const char * const) {} void onStatusChanged(const char * const) {}
void onMediaInserted() {}; void onMediaInserted() {}
void onMediaError() {}; void onMediaError() {}
void onMediaRemoved() {}; void onMediaRemoved() {}
void onPlayTone(const uint16_t, const uint16_t) {} void onPlayTone(const uint16_t, const uint16_t) {}
void onFilamentRunout(const extruder_t extruder) {} void onFilamentRunout(const extruder_t extruder) {}
void onUserConfirmRequired(const char * const) {} void onUserConfirmRequired(const char * const) {}
void onHomingStart() {}
void onHomingComplete() {}
void onPrintFinished() {}
void onFactoryReset() {} void onFactoryReset() {}
void onStoreSettings(char*) {} void onStoreSettings(char*) {}
void onLoadSettings(const char*) {} void onLoadSettings(const char*) {}
@ -524,6 +527,7 @@ namespace ExtUI {
void onConfigurationStoreRead(bool) {} void onConfigurationStoreRead(bool) {}
#if HAS_MESH #if HAS_MESH
void onMeshLevelingStart() {}
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) {} void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) {}
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const ExtUI::probe_state_t state) {} void onMeshUpdate(const int8_t xpos, const int8_t ypos, const ExtUI::probe_state_t state) {}
#endif #endif
@ -531,6 +535,9 @@ namespace ExtUI {
#if ENABLED(POWER_LOSS_RECOVERY) #if ENABLED(POWER_LOSS_RECOVERY)
void onPowerLossResume() {} void onPowerLossResume() {}
#endif #endif
void onSteppersDisabled() {}
void onSteppersEnabled() {}
} }
#endif // MALYAN_LCD #endif // MALYAN_LCD

View file

@ -140,6 +140,7 @@ namespace ExtUI {
bed_mesh_t& getMeshArray(); bed_mesh_t& getMeshArray();
float getMeshPoint(const xy_uint8_t &pos); float getMeshPoint(const xy_uint8_t &pos);
void setMeshPoint(const xy_uint8_t &pos, const float zval); void setMeshPoint(const xy_uint8_t &pos, const float zval);
void onMeshLevelingStart();
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval); void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval);
inline void onMeshUpdate(const xy_int8_t &pos, const float zval) { onMeshUpdate(pos.x, pos.y, zval); } inline void onMeshUpdate(const xy_int8_t &pos, const float zval) { onMeshUpdate(pos.x, pos.y, zval); }
@ -344,11 +345,16 @@ namespace ExtUI {
void onPrintTimerStarted(); void onPrintTimerStarted();
void onPrintTimerPaused(); void onPrintTimerPaused();
void onPrintTimerStopped(); void onPrintTimerStopped();
void onPrintFinished();
void onFilamentRunout(const extruder_t extruder); void onFilamentRunout(const extruder_t extruder);
void onUserConfirmRequired(const char * const msg); void onUserConfirmRequired(const char * const msg);
void onUserConfirmRequired_P(PGM_P const pstr); void onUserConfirmRequired_P(PGM_P const pstr);
void onStatusChanged(const char * const msg); void onStatusChanged(const char * const msg);
void onStatusChanged_P(PGM_P const pstr); void onStatusChanged_P(PGM_P const pstr);
void onHomingStart();
void onHomingComplete();
void onSteppersDisabled();
void onSteppersEnabled();
void onFactoryReset(); void onFactoryReset();
void onStoreSettings(char *); void onStoreSettings(char *);
void onLoadSettings(const char *); void onLoadSettings(const char *);

View file

@ -115,9 +115,16 @@
// Buzz directly via the BEEPER pin tone queue // Buzz directly via the BEEPER pin tone queue
#define BUZZ(d,f) buzzer.tone(d, f) #define BUZZ(d,f) buzzer.tone(d, f)
#elif ENABLED(DGUS_LCD_UI_CREALITY_TOUCH)
// Let extensible UI handle it
#include "../lcd/extui/ui_api.h"
#define BUZZ(d,f) ExtUI::onPlayTone(f, d)
#elif HAS_BUZZER #elif HAS_BUZZER
// Buzz indirectly via the MarlinUI instance // Buzz indirectly via the MarlinUI instance
#include "../lcd/marlinui.h"
#define BUZZ(d,f) ui.buzz(d,f) #define BUZZ(d,f) ui.buzz(d,f)
#else #else

View file

@ -1313,6 +1313,15 @@ void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t
DEBUG_ECHOLNPGM(")"); DEBUG_ECHOLNPGM(")");
} }
#if ENABLED(STRAIN_GAUGE_PROBE) && PIN_EXISTS(OPTO_SWITCH)
if (axis == Z_AXIS) {
const bool in_probing_zone = READ(OPTO_SWITCH_PIN) == LOW;
probe.set_deployed(in_probing_zone);
endstops.enable_z_probe(in_probing_zone);
DEBUG_ECHOLNPAIR("Is in probing zone: ", int(in_probing_zone));
}
#endif
#if ALL(HOMING_Z_WITH_PROBE, HAS_HEATED_BED, WAIT_FOR_BED_HEATER) #if ALL(HOMING_Z_WITH_PROBE, HAS_HEATED_BED, WAIT_FOR_BED_HEATER)
// Wait for bed to heat back up between probing points // Wait for bed to heat back up between probing points
if (axis == Z_AXIS && distance < 0) if (axis == Z_AXIS && distance < 0)
@ -1593,6 +1602,13 @@ void homeaxis(const AxisEnum axis) {
} }
#endif #endif
#if ENABLED(STRAIN_GAUGE_PROBE) && PIN_EXISTS(OPTO_SWITCH)
if (axis == Z_AXIS) {
DEBUG_ECHOLNPAIR(">>> is_homing_z (", int(READ(OPTO_SWITCH_PIN)), ")");
is_homing_z = true;
}
#endif
// Fast move towards endstop until triggered // Fast move towards endstop until triggered
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Home 1 Fast:"); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Home 1 Fast:");

View file

@ -47,6 +47,10 @@ FORCE_INLINE bool homing_needed() {
return !TERN(HOME_AFTER_DEACTIVATE, all_axes_known, all_axes_homed)(); return !TERN(HOME_AFTER_DEACTIVATE, all_axes_known, all_axes_homed)();
} }
#if ENABLED(STRAIN_GAUGE_PROBE)
extern bool is_homing_z;
#endif
// Error margin to work around float imprecision // Error margin to work around float imprecision
constexpr float fslop = 0.0001; constexpr float fslop = 0.0001;

View file

@ -556,6 +556,17 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
float probes[TOTAL_PROBING]; float probes[TOTAL_PROBING];
#endif #endif
#if ENABLED(STRAIN_GAUGE_PROBE) && PINS_EXIST(OPTO_SWITCH, COM)
if (READ(OPTO_SWITCH_PIN) == LOW && is_homing_z) {
DEBUG_ECHOLNPGM("STRAIN_GAUGE_PROBE: Considering homing complete");
WRITE(COM_PIN, HIGH);
delay(200);
WRITE(COM_PIN, LOW);
delay(200);
is_homing_z = false;
}
#endif
#if TOTAL_PROBING > 2 #if TOTAL_PROBING > 2
float probes_z_sum = 0; float probes_z_sum = 0;
for ( for (
@ -684,6 +695,15 @@ float Probe::probe_at_point(const float &rx, const float &ry, const ProbePtRaise
// Move the probe to the starting XYZ // Move the probe to the starting XYZ
do_blocking_move_to(npos); do_blocking_move_to(npos);
#if ENABLED(STRAIN_GAUGE_PROBE) && PINS_EXIST(OPTO_SWITCH, COM)
if (READ(OPTO_SWITCH_PIN) == LOW) {
DEBUG_ECHOLNPGM("FIX_MOUNTED_PROBE: Setting COM_PIN low");
safe_delay(100);
WRITE(COM_PIN, LOW);
safe_delay(200);
}
#endif
float measured_z = NAN; float measured_z = NAN;
if (!deploy()) measured_z = run_z_probe(sanity_check) + offset.z; if (!deploy()) measured_z = run_z_probe(sanity_check) + offset.z;
if (!isnan(measured_z)) { if (!isnan(measured_z)) {
@ -697,6 +717,11 @@ float Probe::probe_at_point(const float &rx, const float &ry, const ProbePtRaise
SERIAL_ECHOLNPAIR("Bed X: ", LOGICAL_X_POSITION(rx), " Y: ", LOGICAL_Y_POSITION(ry), " Z: ", measured_z); SERIAL_ECHOLNPAIR("Bed X: ", LOGICAL_X_POSITION(rx), " Y: ", LOGICAL_Y_POSITION(ry), " Z: ", measured_z);
} }
#if ENABLED(STRAIN_GAUGE_PROBE) && PIN_EXISTS(COM)
DEBUG_ECHOLNPGM("STRAIN_GAUGE_PROBE: Setting COM_PIN high");
WRITE(COM_PIN, HIGH);
#endif
feedrate_mm_s = old_feedrate_mm_s; feedrate_mm_s = old_feedrate_mm_s;
if (isnan(measured_z)) { if (isnan(measured_z)) {

View file

@ -579,6 +579,8 @@
#include "stm32f1/pins_CREALITY_V4.h" // STM32F1 env:STM32F103RET6_creality #include "stm32f1/pins_CREALITY_V4.h" // STM32F1 env:STM32F103RET6_creality
#elif MB(CREALITY_V427) #elif MB(CREALITY_V427)
#include "stm32f1/pins_CREALITY_V427.h" // STM32F1 env:STM32F103RET6_creality #include "stm32f1/pins_CREALITY_V427.h" // STM32F1 env:STM32F103RET6_creality
#elif MB(CREALITY_V452)
#include "stm32f1/pins_CREALITY_V452.h" // STM32F1 env:STM32F103RET6_creality
#elif MB(TRIGORILLA_PRO) #elif MB(TRIGORILLA_PRO)
#include "stm32f1/pins_TRIGORILLA_PRO.h" // STM32F1 env:trigorilla_pro #include "stm32f1/pins_TRIGORILLA_PRO.h" // STM32F1 env:trigorilla_pro
#elif MB(FLY_MINI) #elif MB(FLY_MINI)

View file

@ -0,0 +1,150 @@
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Creality v4.5.2 (STM32F103) board pin assignments
*/
#if NOT_TARGET(__STM32F1__)
#error "Oops! Select an STM32F1 board in 'Tools > Board.'"
#endif
#if HOTENDS > 1 || E_STEPPERS > 1
#error "CREALITY supports up to 1 hotends / E-steppers. Comment out this line to continue."
#endif
#define BOARD_NAME "Creality v4.5.2"
#define DEFAULT_MACHINE_NAME "Creality3D"
//
// EEPROM
//
#if NO_EEPROM_SELECTED
#define IIC_BL24CXX_EEPROM // EEPROM on I2C-0 used only for display settings
#if ENABLED(IIC_BL24CXX_EEPROM)
#define IIC_EEPROM_SDA PA11
#define IIC_EEPROM_SCL PA12
#define MARLIN_EEPROM_SIZE 0x800 // 2Kb (24C16)
#else
#define SDCARD_EEPROM_EMULATION // SD EEPROM until all EEPROM is BL24CXX
#define MARLIN_EEPROM_SIZE 0x800 // 2Kb
#endif
#endif
/* SPI */
//#define SPI_EEPROM // EEPROM on SPI-0
//#define SPI_CHAN_EEPROM1 ?
//#define SPI_EEPROM1_CS ?
// 2K EEPROM
//#define SPI_EEPROM2_CS ?
// 32Mb FLASH
//#define SPI_FLASH_CS ?
//
// Limit Switches
//
#define X_MIN_PIN PC4
//#define X_MAX_PIN PA7
#define Y_MIN_PIN PC5
#define Z_MIN_PIN PA4
#define COM_PIN PA5
//
// Steppers
//
#define X_ENABLE_PIN PC3
#define X_STEP_PIN PB8
#define X_DIR_PIN PB7
#define Y_ENABLE_PIN PC3
#define Y_STEP_PIN PB6
#define Y_DIR_PIN PB5
#define Z_ENABLE_PIN PC3
#define Z_STEP_PIN PB4
#define Z_DIR_PIN PB3
#define E0_ENABLE_PIN PC3
#define E0_STEP_PIN PC2
#define E0_DIR_PIN PB9
#if HAS_TMC220x
//
// TMC2208 mode
//
//#define TMC2208_STANDALONE
#define X_HARDWARE_SERIAL MSerial2
#define Y_HARDWARE_SERIAL MSerial2
#define Z_HARDWARE_SERIAL MSerial2
#define E0_HARDWARE_SERIAL MSerial2
//
// TMC2208 Software serial
//
//#define HAVE_SW_SERIAL
// Reduce baud rate to improve software serial reliability
//#define TMC_BAUD_RATE 19200
#endif
//
// Release PB4 (Z_STEP_PIN) from JTAG NRST role
//
#define DISABLE_DEBUG
//
// Temperature Sensors
//
#define TEMP_0_PIN PB1 // TH1
#define TEMP_BED_PIN PB0 // TB1
//
// Heaters / Fans
//
//#define HEATER_0_PIN PB14 // HEATER1
//#define HEATER_BED_PIN PB13 // HOT BED
//#define FAN_PIN PB15 // FAN
//#define FAN_SOFT_PWM
#define HEATER_0_PIN PA1 // HEATER1
#define HEATER_BED_PIN PA2 // HOT BED
#define FAN_PIN PA0 // FAN
#define FAN_SOFT_PWM
#define SD_DETECT_PIN PC7
#define NO_SD_HOST_DRIVE // This board's SD is only seen by the printer
#define SDIO_SUPPORT // Extra added by Creality
#define SDIO_CLOCK 6000000 // In original source code overridden by Creality in sdio.h
#define CASE_LIGHT_PIN PA6
#define FIL_RUNOUT_PIN PA7
//#define OPTO_SWITCH_PIN PB2 // certification
#define OPTO_SWITCH_PIN PC6
#define TEMP_TIMER_CHAN 4 // Channel of the timer to use for compare and interrupts

View file

@ -13,4 +13,7 @@ use_example_configs "Creality/Ender-3 V2"
opt_enable MARLIN_DEV_MODE opt_enable MARLIN_DEV_MODE
exec_test $1 $2 "Ender 3 v2" exec_test $1 $2 "Ender 3 v2"
use_example_configs "Creality/CR-6 SE"
exec_test $1 $2 "Creality CR-6 SE"
restore_configs restore_configs

View file

@ -237,6 +237,7 @@ HAS_GRAPHICAL_TFT = src_filter=+<src/lcd/tft>
DWIN_CREALITY_LCD = src_filter=+<src/lcd/dwin> DWIN_CREALITY_LCD = src_filter=+<src/lcd/dwin>
IS_TFTGLCD_PANEL = src_filter=+<src/lcd/TFTGLCD> IS_TFTGLCD_PANEL = src_filter=+<src/lcd/TFTGLCD>
HAS_TOUCH_XPT2046 = src_filter=+<src/lcd/touch/touch_buttons.cpp> HAS_TOUCH_XPT2046 = src_filter=+<src/lcd/touch/touch_buttons.cpp>
DWIN_CREALITY_TOUCHLCD = src_filter=+<src/lcd/dwin>
HAS_LCD_MENU = src_filter=+<src/lcd/menu> HAS_LCD_MENU = src_filter=+<src/lcd/menu>
HAS_GAMES = src_filter=+<src/lcd/menu/game/game.cpp> HAS_GAMES = src_filter=+<src/lcd/menu/game/game.cpp>
MARLIN_BRICKOUT = src_filter=+<src/lcd/menu/game/brickout.cpp> MARLIN_BRICKOUT = src_filter=+<src/lcd/menu/game/brickout.cpp>