Initial Touchscreen Support
This commit is contained in:
@@ -102,7 +102,7 @@ typedef int8_t pin_t;
|
||||
#error "LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
||||
#endif
|
||||
#define LCD_SERIAL lcdSerial
|
||||
#if HAS_DGUS_LCD
|
||||
#if HAS_DGUS_LCD || ENABLED(DGUS_LCD_UI_CREALITY_TOUCH)
|
||||
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.get_tx_buffer_free()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -779,7 +779,7 @@ MarlinSerial<MarlinSerialCfg<SERIAL_PORT>> customizedSerial1;
|
||||
// Instantiate
|
||||
MarlinSerial<LCDSerialCfg<LCD_SERIAL_PORT>> lcdSerial;
|
||||
|
||||
#if HAS_DGUS_LCD
|
||||
#if HAS_DGUS_LCD || ENABLED(DGUS_LCD_UI_CREALITY_TOUCH)
|
||||
template<typename Cfg>
|
||||
typename MarlinSerial<Cfg>::ring_buffer_pos_t MarlinSerial<Cfg>::get_tx_buffer_free() {
|
||||
const ring_buffer_pos_t t = tx_buffer.tail, // next byte to send.
|
||||
|
||||
@@ -217,7 +217,7 @@
|
||||
static ring_buffer_pos_t available();
|
||||
static void write(const uint8_t c);
|
||||
static void flushTX();
|
||||
#if HAS_DGUS_LCD
|
||||
#if HAS_DGUS_LCD || ENABLED(DGUS_LCD_UI_CREALITY_TOUCH)
|
||||
static ring_buffer_pos_t get_tx_buffer_free();
|
||||
#endif
|
||||
|
||||
@@ -307,7 +307,7 @@
|
||||
static constexpr bool DROPPED_RX = false;
|
||||
static constexpr bool RX_FRAMING_ERRORS = false;
|
||||
static constexpr bool MAX_RX_QUEUED = false;
|
||||
#if HAS_DGUS_LCD
|
||||
#if HAS_DGUS_LCD || ENABLED(DGUS_LCD_UI_CREALITY_TOUCH)
|
||||
static constexpr unsigned int RX_SIZE = DGUS_RX_BUFFER_SIZE;
|
||||
static constexpr unsigned int TX_SIZE = DGUS_TX_BUFFER_SIZE;
|
||||
static constexpr bool RX_OVERRUNS = ENABLED(SERIAL_STATS_RX_BUFFER_OVERRUNS);
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
#else
|
||||
#error "LCD_SERIAL_PORT must be -1 or from 1 to 6. Please update your configuration."
|
||||
#endif
|
||||
#if HAS_DGUS_LCD
|
||||
#if HAS_DGUS_LCD || ENABLED(DGUS_LCD_UI_CREALITY_TOUCH)
|
||||
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -451,7 +451,7 @@
|
||||
#endif
|
||||
|
||||
// Extensible UI serial touch screens. (See src/lcd/extui)
|
||||
#if ANY(HAS_DGUS_LCD, MALYAN_LCD, TOUCH_UI_FTDI_EVE, ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON)
|
||||
#if ANY(HAS_DGUS_LCD, MALYAN_LCD, TOUCH_UI_FTDI_EVE, ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, DGUS_LCD_UI_CREALITY_TOUCH)
|
||||
#define IS_EXTUI 1
|
||||
#define EXTENSIBLE_UI
|
||||
#endif
|
||||
|
||||
@@ -2206,7 +2206,7 @@
|
||||
#define HAS_TEMPERATURE 1
|
||||
#endif
|
||||
|
||||
#if HAS_TEMPERATURE && EITHER(HAS_LCD_MENU, DWIN_CREALITY_LCD)
|
||||
#if HAS_TEMPERATURE && ANY(HAS_LCD_MENU, DWIN_CREALITY_LCD, DGUS_LCD_UI_CREALITY_TOUCH)
|
||||
#ifdef PREHEAT_5_LABEL
|
||||
#define PREHEAT_COUNT 5
|
||||
#elif defined(PREHEAT_4_LABEL)
|
||||
|
||||
@@ -2278,7 +2278,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
|
||||
+ (DISABLED(IS_LEGACY_TFT) && ENABLED(TFT_GENERIC)) \
|
||||
+ (ENABLED(IS_LEGACY_TFT) && COUNT_ENABLED(TFT_320x240, TFT_320x240_SPI, TFT_480x320, TFT_480x320_SPI)) \
|
||||
+ COUNT_ENABLED(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, ANYCUBIC_TFT35) \
|
||||
+ COUNT_ENABLED(DGUS_LCD_UI_ORIGIN, DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY) \
|
||||
+ COUNT_ENABLED(DGUS_LCD_UI_ORIGIN, DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY, DGUS_LCD_UI_CREALITY_TOUCH) \
|
||||
+ COUNT_ENABLED(ENDER2_STOCKDISPLAY, CR10_STOCKDISPLAY, DWIN_CREALITY_LCD) \
|
||||
+ COUNT_ENABLED(FYSETC_MINI_12864_X_X, FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1, FYSETC_GENERIC_12864_1_1) \
|
||||
+ COUNT_ENABLED(LCD_SAINSMART_I2C_1602, LCD_SAINSMART_I2C_2004) \
|
||||
@@ -2657,7 +2657,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
|
||||
#elif ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
|
||||
#error "SENSORLESS_PROBING cannot be used with Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN."
|
||||
#elif ENABLED(USE_PROBE_FOR_Z_HOMING)
|
||||
#error "SENSORLESS_PROBING cannot be used with USE_PROBE_FOR_Z_HOMING."
|
||||
#error "SENSORLESS_PROBING cannot be used with USE_PROBE_FOR_Z_HOMING."
|
||||
#elif !Z_SENSORLESS
|
||||
#error "SENSORLESS_PROBING requires a TMC stepper driver with StallGuard on Z."
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,242 @@
|
||||
/**
|
||||
* 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_creality/DGUSDisplay.h"
|
||||
#include "lib/dgus_creality/DGUSDisplayDef.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);
|
||||
}
|
||||
|
||||
bool hasPrintTimer = false;
|
||||
|
||||
void onPrintTimerStarted() {
|
||||
hasPrintTimer = true;
|
||||
|
||||
if (!ExtUI::isPrintingFromMedia()) {
|
||||
ScreenHandler.SetPrintingFromHost();
|
||||
}
|
||||
|
||||
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_PRINT_RUNNING);
|
||||
}
|
||||
|
||||
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() {
|
||||
hasPrintTimer = false;
|
||||
|
||||
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_PRINT_FINISH);
|
||||
}
|
||||
|
||||
void onFilamentRunout(const extruder_t extruder) {
|
||||
ScreenHandler.FilamentRunout();
|
||||
}
|
||||
|
||||
void onUserConfirmed() {
|
||||
DEBUG_ECHOLN("User confirmation invoked");
|
||||
|
||||
ExtUI::setUserConfirmed();
|
||||
}
|
||||
|
||||
void onUserConfirmRequired(const char * const msg) {
|
||||
if (msg) {
|
||||
DEBUG_ECHOLNPAIR("User confirmation requested: ", msg);
|
||||
|
||||
ScreenHandler.setstatusmessagePGM(msg);
|
||||
ScreenHandler.sendinfoscreen(PSTR("Confirmation required"), msg, NUL_STR, NUL_STR, true, true, false, true);
|
||||
|
||||
if (hasPrintTimer) {
|
||||
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_PRINT_PAUSED);
|
||||
} else {
|
||||
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_POPUP);
|
||||
}
|
||||
}
|
||||
else if (ScreenHandler.getCurrentScreen() == DGUSLCD_SCREEN_POPUP) {
|
||||
DEBUG_ECHOLNPAIR("User confirmation canceled");
|
||||
|
||||
ScreenHandler.setstatusmessagePGM(nullptr);
|
||||
ScreenHandler.PopToOldScreen();
|
||||
}
|
||||
|
||||
while (!ScreenHandler.loop()); // Wait while anything is left to be sent
|
||||
}
|
||||
|
||||
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) {
|
||||
}
|
||||
|
||||
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const ExtUI::probe_state_t state) {
|
||||
}
|
||||
|
||||
void onMeshCallback(const int8_t xpos, const int8_t ypos, const float zval) {
|
||||
ScreenHandler.OnMeshLevelingUpdate(xpos, ypos);
|
||||
}
|
||||
|
||||
void onMeshCallback(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
|
||||
@@ -0,0 +1,331 @@
|
||||
/**
|
||||
* 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 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 "DGUSDisplayDef.h"
|
||||
|
||||
// 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
|
||||
|
||||
#define dgusserial LCD_SERIAL
|
||||
|
||||
void DGUSDisplay::InitDisplay() {
|
||||
dgusserial.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 (true
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
&& !recovery.valid()
|
||||
#endif
|
||||
)
|
||||
RequestScreen(
|
||||
#if ENABLED(SHOW_BOOTSCREEN)
|
||||
DGUSLCD_SCREEN_BOOT
|
||||
#else
|
||||
DGUSLCD_SCREEN_MAIN
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
void DGUSDisplay::ResetDisplay() {
|
||||
SERIAL_ECHOLN("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
|
||||
dgusserial.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 = ' ';
|
||||
}
|
||||
dgusserial.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 = ' ';
|
||||
}
|
||||
dgusserial.write(x);
|
||||
}
|
||||
}
|
||||
|
||||
void DGUSDisplay::ProcessRx() {
|
||||
|
||||
#if ENABLED(DGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS)
|
||||
if (!dgusserial.available() && dgusserial.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;
|
||||
//dgusserial.reset_rx_overun();
|
||||
dgusserial.flush();
|
||||
}
|
||||
#endif
|
||||
|
||||
uint8_t receivedbyte;
|
||||
while (dgusserial.available()) {
|
||||
switch (rx_datagram_state) {
|
||||
|
||||
case DGUS_IDLE: // Waiting for the first header byte
|
||||
receivedbyte = dgusserial.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 = dgusserial.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 = dgusserial.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 (dgusserial.available() < rx_datagram_len) return;
|
||||
|
||||
Initialized = true; // We've talked to it, so we defined it as initialized.
|
||||
uint8_t command = dgusserial.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 = dgusserial.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) {
|
||||
dgusserial.write(DGUS_HEADER1);
|
||||
dgusserial.write(DGUS_HEADER2);
|
||||
dgusserial.write(payloadlen + 3);
|
||||
dgusserial.write(cmd);
|
||||
dgusserial.write(adr >> 8);
|
||||
dgusserial.write(adr & 0xFF);
|
||||
}
|
||||
|
||||
void DGUSDisplay::WritePGM(const char str[], uint8_t len) {
|
||||
while (len--) dgusserial.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
|
||||
@@ -0,0 +1,134 @@
|
||||
/**
|
||||
* 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_DGUSLCD
|
||||
//#define DEBUG_DGUSLCD_OUTGOING_COMM
|
||||
|
||||
|
||||
/* Creality DGUS implementation written by Sebastiaan Dammann in 2020 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;
|
||||
|
||||
#define DEBUG_OUT ENABLED(DEBUG_DGUSLCD)
|
||||
#include "../../../../core/debug_out.h"
|
||||
|
||||
|
||||
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 (*UPDATE_CURRENT_SCREEN_CALLBACK)(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 UPDATE_CURRENT_SCREEN_CALLBACK 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);
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* 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 Sebastiaan Dammann in 2020 for Marlin */
|
||||
|
||||
#include "../dgus/DGUSVPVariable.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// This file defines the interaction between Marlin and the display firmware.
|
||||
|
||||
// information on which screen which VP is displayed
|
||||
// As this is a sparse table, two arrays are needed:
|
||||
// one to list the VPs of one screen and one to map screens to the lists.
|
||||
// (Strictly this would not be necessary, but allows to only send data the display needs and reducing load on Marlin)
|
||||
struct VPMapping {
|
||||
const uint8_t screen;
|
||||
const uint16_t *VPList; // The list is null-terminated.
|
||||
};
|
||||
|
||||
extern const struct VPMapping VPMap[];
|
||||
|
||||
// List of VPs handled by Marlin / The Display.
|
||||
extern const struct DGUS_VP_Variable ListOfVP[];
|
||||
|
||||
#include "../../../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(DGUS_LCD_UI_CREALITY_TOUCH)
|
||||
#include "creality_touch/DGUSDisplayDef.h"
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,270 @@
|
||||
/**
|
||||
* 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 "DGUSDisplay.h"
|
||||
#include "../dgus/DGUSVPVariable.h"
|
||||
|
||||
#include "../../../../inc/MarlinConfig.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);
|
||||
// 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);
|
||||
|
||||
// Hook for move to position
|
||||
static void HandlePositionChange(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 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
|
||||
// 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();
|
||||
|
||||
static void SetPrintingFromHost();
|
||||
#endif
|
||||
|
||||
static void HandleLEDToggle();
|
||||
|
||||
static void HandleFanToggle();
|
||||
|
||||
static void HandleStepperState(bool is_enabled);
|
||||
|
||||
static void FilamentRunout();
|
||||
|
||||
static void OnFactoryReset();
|
||||
|
||||
#if HAS_BUZZER || ENABLED(SPEAKER)
|
||||
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 bool HandlePendingUserConfirmation();
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
extern DGUSScreenHandler ScreenHandler;
|
||||
@@ -0,0 +1,492 @@
|
||||
/**
|
||||
* 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 = {
|
||||
#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_Z_OFFSET,
|
||||
//VP_Fan0_Percentage,
|
||||
VP_Feedrate_Percentage,
|
||||
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
|
||||
VP_PrintProgress_Percentage,
|
||||
#endif
|
||||
0x0000
|
||||
};
|
||||
|
||||
const uint16_t VPList_SDFileList[] 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_Z_OFFSET,
|
||||
//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 = {
|
||||
#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_Z_OFFSET,
|
||||
//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 = {
|
||||
#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_Z_OFFSET,
|
||||
//VP_Fan0_Percentage,
|
||||
VP_Feedrate_Percentage,
|
||||
|
||||
|
||||
0x0000
|
||||
};
|
||||
|
||||
const uint16_t VPList_Temp[] 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_Z_OFFSET,
|
||||
//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 = {
|
||||
#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_Z_OFFSET,
|
||||
//VP_Fan0_Percentage,
|
||||
VP_Feedrate_Percentage,
|
||||
|
||||
VP_PREHEAT_PLA_HOTEND_TEMP,
|
||||
VP_PREHEAT_PLA_BED_TEMP,
|
||||
|
||||
0x0000
|
||||
};
|
||||
|
||||
const uint16_t VPList_PreheatABSSettings[] 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_Z_OFFSET,
|
||||
//VP_Fan0_Percentage,
|
||||
VP_Feedrate_Percentage,
|
||||
|
||||
VP_PREHEAT_ABS_HOTEND_TEMP,
|
||||
VP_PREHEAT_ABS_BED_TEMP,
|
||||
|
||||
0x0000
|
||||
};
|
||||
|
||||
|
||||
const uint16_t VPList_PrintPausingError[] 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_Z_OFFSET,
|
||||
//VP_Fan0_Percentage,
|
||||
VP_Feedrate_Percentage,
|
||||
|
||||
VP_PrintProgress_Percentage,
|
||||
VP_PrintTimeProgressBar,
|
||||
VP_PrintTime,
|
||||
|
||||
0x0000
|
||||
};
|
||||
|
||||
const uint16_t VPList_PrintScreen[] PROGMEM = {
|
||||
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_X_POSITION, VP_Y_POSITION, VP_Z_POSITION,
|
||||
VP_Z_OFFSET,
|
||||
//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_Z_OFFSET,
|
||||
//VP_Fan0_Percentage,
|
||||
VP_Feedrate_Percentage,
|
||||
|
||||
VP_MESH_LEVEL_TEMP,
|
||||
|
||||
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_Z_OFFSET,
|
||||
//VP_Fan0_Percentage,
|
||||
VP_Feedrate_Percentage,
|
||||
|
||||
0x0000
|
||||
};
|
||||
|
||||
const uint16_t VPList_TuneScreen[] PROGMEM = {
|
||||
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_Z_OFFSET,
|
||||
//VP_Fan0_Percentage,
|
||||
VP_Feedrate_Percentage,
|
||||
|
||||
VP_LED_TOGGLE,
|
||||
VP_FAN_TOGGLE,
|
||||
|
||||
|
||||
0x0000
|
||||
};
|
||||
|
||||
const uint16_t VPList_Prepare[] PROGMEM = {
|
||||
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_Z_OFFSET,
|
||||
//VP_Fan0_Percentage,
|
||||
VP_Feedrate_Percentage,
|
||||
|
||||
VP_STEPPERS,
|
||||
|
||||
0x0000
|
||||
};
|
||||
|
||||
const uint16_t VPList_Info[] PROGMEM = {
|
||||
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_Z_OFFSET,
|
||||
//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_X_POSITION, ¤t_position.x, ScreenHandler.HandlePositionChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
|
||||
VPHELPER(VP_Y_POSITION, ¤t_position.y, ScreenHandler.HandlePositionChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
|
||||
VPHELPER(VP_Z_POSITION, ¤t_position.z, ScreenHandler.HandlePositionChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
|
||||
|
||||
VPHELPER(VP_Z_OFFSET, &probe.offset.z, ScreenHandler.HandleZoffsetChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<2>),
|
||||
|
||||
VPHELPER(VP_FAN_TOGGLE, &thermalManager.fan_speed[0], nullptr, 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),
|
||||
VPHELPER(VP_BUTTON_MOVEKEY, 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
|
||||
@@ -0,0 +1,352 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
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_MOVE10MM = 43, // DWINTouchPage::MOVE_1MM
|
||||
DGUSLCD_SCREEN_MOVE1MM = 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 = 60;
|
||||
|
||||
// // 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;
|
||||
|
||||
constexpr uint16_t VP_Z_OFFSET = 0x1026;
|
||||
|
||||
// // 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;
|
||||
|
||||
// Movement screen
|
||||
constexpr uint16_t VP_X_POSITION = 0x1048;
|
||||
constexpr uint16_t VP_Y_POSITION = 0x104A;
|
||||
constexpr uint16_t VP_Z_POSITION = 0x104C;
|
||||
constexpr uint16_t VP_BUTTON_MOVEKEY = 0x1046;
|
||||
|
||||
// Icons
|
||||
constexpr uint16_t ICON_TOGGLE_ON = 1;
|
||||
constexpr uint16_t ICON_TOGGLE_OFF = 2;
|
||||
@@ -0,0 +1,361 @@
|
||||
#include "../../../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#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"
|
||||
|
||||
#if ENABLED(FILAMENT_RUNOUT_SENSOR)
|
||||
#include "../../../../../feature/runout.h"
|
||||
#endif
|
||||
|
||||
#include "../../../../../module/settings.h"
|
||||
|
||||
#include "../../../../marlinui.h"
|
||||
#include "../../../ui_api.h"
|
||||
|
||||
#include "PageHandlers.h"
|
||||
|
||||
#if ENABLED(DGUS_LCD_UI_CREALITY_TOUCH)
|
||||
|
||||
// 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:
|
||||
ExtUI::injectCommands_P("G28\nG0 Z0");
|
||||
break;
|
||||
|
||||
case 2:
|
||||
// Increase Z-offset
|
||||
ExtUI::smartAdjustAxis_steps(ExtUI::mmToWholeSteps(0.01, ExtUI::axis_t::Z), ExtUI::axis_t::Z, true);;
|
||||
ScreenHandler.ForceCompleteUpdate();
|
||||
settings.save();
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// Decrease Z-offset
|
||||
ExtUI::smartAdjustAxis_steps(ExtUI::mmToWholeSteps(-0.01, ExtUI::axis_t::Z), ExtUI::axis_t::Z, true);;
|
||||
ScreenHandler.ForceCompleteUpdate();
|
||||
settings.save();
|
||||
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:
|
||||
ScreenHandler.HandleFanToggle();
|
||||
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:
|
||||
ScreenHandler.HandleFanToggle();
|
||||
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:
|
||||
#if ENABLED(FILAMENT_RUNOUT_SENSOR)
|
||||
runout.reset();
|
||||
#endif
|
||||
|
||||
if (!ScreenHandler.HandlePendingUserConfirmation()) {
|
||||
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 change_filament_with_temp(PGM_P command, const uint16_t celsius) {
|
||||
thermalManager.setTargetHotend(celsius, ExtUI::H0);
|
||||
|
||||
char cmd[32];
|
||||
sprintf_P(cmd, command, ScreenHandler.feed_amount);
|
||||
|
||||
SERIAL_ECHOPAIR("Injecting command: ", cmd);
|
||||
ExtUI::injectCommands(cmd);
|
||||
|
||||
SERIAL_ECHOPGM_P("- waiting for queue");
|
||||
queue.advance();
|
||||
|
||||
SERIAL_ECHOPGM_P("- done");
|
||||
}
|
||||
|
||||
void FeedHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
|
||||
if (var.VP != VP_BUTTON_HEATLOADSTARTKEY) return;
|
||||
|
||||
// Common for load/unload -> determine minimum temperature
|
||||
uint16_t celsius = ExtUI::getActualTemp_celsius(ExtUI::H0);
|
||||
if (celsius < PREHEAT_1_TEMP_HOTEND) {
|
||||
celsius = PREHEAT_1_TEMP_HOTEND;
|
||||
}
|
||||
|
||||
switch (buttonValue) {
|
||||
case 1:
|
||||
dgusdisplay.WriteVariable(VP_FEED_PROGRESS, static_cast<int16_t>(10));
|
||||
|
||||
change_filament_with_temp(PSTR("M701 L%f"), celsius);
|
||||
|
||||
dgusdisplay.WriteVariable(VP_FEED_PROGRESS, static_cast<int16_t>(0));
|
||||
break;
|
||||
|
||||
case 2:
|
||||
dgusdisplay.WriteVariable(VP_FEED_PROGRESS, static_cast<int16_t>(10));
|
||||
|
||||
change_filament_with_temp(PSTR("M702 U%f"), celsius);
|
||||
|
||||
dgusdisplay.WriteVariable(VP_FEED_PROGRESS, static_cast<int16_t>(0));
|
||||
break;
|
||||
}
|
||||
|
||||
ScreenHandler.ForceCompleteUpdate();
|
||||
}
|
||||
|
||||
void MoveHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
|
||||
if (var.VP != VP_BUTTON_MOVEKEY) return;
|
||||
|
||||
switch (buttonValue) {
|
||||
case 1:
|
||||
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_MOVE10MM);
|
||||
break;
|
||||
case 2:
|
||||
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_MOVE1MM);
|
||||
break;
|
||||
case 3:
|
||||
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_MOVE01MM);
|
||||
break;
|
||||
case 4:
|
||||
ExtUI::injectCommands_P("G28");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 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_MOVE01MM, MoveHandler)
|
||||
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_MOVE1MM, MoveHandler)
|
||||
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_MOVE10MM, MoveHandler)
|
||||
|
||||
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
|
||||
@@ -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);
|
||||
@@ -951,6 +951,10 @@ namespace ExtUI {
|
||||
TERN_(HAS_RESUME_CONTINUE, wait_for_user = false);
|
||||
}
|
||||
|
||||
bool isWaitingOnUser() {
|
||||
return TERN(HAS_RESUME_CONTINUE, wait_for_user, false);
|
||||
}
|
||||
|
||||
void printFile(const char *filename) {
|
||||
UNUSED(filename);
|
||||
IFSD(card.openAndPrintFile(filename), NOOP);
|
||||
|
||||
@@ -187,6 +187,7 @@ namespace ExtUI {
|
||||
void setFeedrate_percent(const float);
|
||||
void setFlow_percent(const int16_t, const extruder_t);
|
||||
void setUserConfirmed();
|
||||
bool isWaitingOnUser();
|
||||
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
float getLinearAdvance_mm_mm_s(const extruder_t);
|
||||
|
||||
@@ -52,6 +52,7 @@ default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared>
|
||||
-<src/lcd/menu/menu_ubl.cpp>
|
||||
-<src/lcd/extui/lib/mks_ui>
|
||||
-<src/lcd/extui/lib/dgus> -<src/lcd/extui/dgus_lcd.cpp>
|
||||
-<src/lcd/extui/lib/dgus_creality> -<src/lcd/extui/dgus_creality_lcd.cpp>
|
||||
-<src/lcd/extui/example.cpp>
|
||||
-<src/lcd/extui/malyan_lcd.cpp>
|
||||
-<src/lcd/extui/lib/ftdi_eve_touch_ui>
|
||||
@@ -269,6 +270,7 @@ HAS_MENU_UBL = src_filter=+<src/lcd/menu/menu_ubl.cpp>
|
||||
ANYCUBIC_LCD_CHIRON = src_filter=+<src/lcd/extui/anycubic_chiron_lcd.cpp> +<src/lcd/extui/lib/anycubic_chiron>
|
||||
ANYCUBIC_LCD_I3MEGA = src_filter=+<src/lcd/extui/anycubic_i3mega_lcd.cpp> +<src/lcd/extui/lib/anycubic_i3mega>
|
||||
HAS_DGUS_LCD = src_filter=+<src/lcd/extui/lib/dgus> +<src/lcd/extui/dgus_lcd.cpp>
|
||||
DGUS_LCD_UI_CREALITY_TOUCH = src_filter=+<src/lcd/extui/lib/dgus_creality> +<src/lcd/extui/dgus_creality_lcd.cpp>
|
||||
TOUCH_UI_FTDI_EVE = src_filter=+<src/lcd/extui/lib/ftdi_eve_touch_ui>
|
||||
EXTUI_EXAMPLE = src_filter=+<src/lcd/extui/example.cpp>
|
||||
MALYAN_LCD = src_filter=+<src/lcd/extui/malyan_lcd.cpp>
|
||||
|
||||
Reference in New Issue
Block a user