🔧 Add DGUS_LCD_UI RELOADED conditions

This commit is contained in:
Scott Lahteine 2023-03-06 22:55:55 -06:00
parent cc31537ae3
commit 4b9bb85b12
8 changed files with 56 additions and 99 deletions

View file

@ -4409,6 +4409,8 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive.");
#error "DGUS_LCD_UI RELOADED requires BABYSTEP_ALWAYS_AVAILABLE."
#elif DISABLED(BABYSTEP_ZPROBE_OFFSET)
#error "DGUS_LCD_UI RELOADED requires BABYSTEP_ZPROBE_OFFSET."
#elif ENABLED(HOME_AFTER_DEACTIVATE)
#error "DGUS_LCD_UI RELOADED requires HOME_AFTER_DEACTIVATE to be disabled."
#elif ENABLED(AUTO_BED_LEVELING_UBL) && DISABLED(UBL_SAVE_ACTIVE_ON_M500)
#warning "Without UBL_SAVE_ACTIVE_ON_M500, your mesh will not be saved when using the touchscreen."
#endif

View file

@ -125,8 +125,7 @@ void DGUSDisplay::WriteStringPGM(uint16_t addr, const void* data_ptr, uint8_t si
const char* data = static_cast<const char*>(data_ptr);
size_t len = strlen_P(data);
uint8_t left_spaces = 0;
uint8_t right_spaces = 0;
uint8_t left_spaces = 0, right_spaces = 0;
if (len < size) {
if (!len) {
@ -147,15 +146,9 @@ void DGUSDisplay::WriteStringPGM(uint16_t addr, const void* data_ptr, uint8_t si
len = size;
}
while (left_spaces--) {
LCD_SERIAL.write(' ');
}
while (len--) {
LCD_SERIAL.write(pgm_read_byte(data++));
}
while (right_spaces--) {
LCD_SERIAL.write(use_space ? ' ' : '\0');
}
while (left_spaces--) LCD_SERIAL.write(' ');
while (len--) LCD_SERIAL.write(pgm_read_byte(data++));
while (right_spaces--) LCD_SERIAL.write(use_space ? ' ' : '\0');
}
void DGUSDisplay::ReadVersions() {
@ -340,11 +333,13 @@ void DGUSDisplay::ProcessRx() {
}
size_t DGUSDisplay::GetFreeTxBuffer() {
return (
#ifdef LCD_SERIAL_GET_TX_BUFFER_FREE
return LCD_SERIAL_GET_TX_BUFFER_FREE();
LCD_SERIAL_GET_TX_BUFFER_FREE()
#else
return SIZE_MAX;
SIZE_MAX
#endif
);
}
void DGUSDisplay::FlushTx() {

View file

@ -63,8 +63,11 @@ public:
static void Read(uint16_t addr, uint8_t size);
static void Write(uint16_t addr, const void* data_ptr, uint8_t size);
static void WriteString(uint16_t addr, const void* data_ptr, uint8_t size, bool left = true, bool right = false, bool use_space = true);
static void WriteStringPGM(uint16_t addr, const void* data_ptr, uint8_t size, bool left = true, bool right = false, bool use_space = true);
static void WriteString(uint16_t addr, const void* data_ptr, uint8_t size, bool left=true, bool right=false, bool use_space=true);
static void WriteStringPGM(uint16_t addr, const void* data_ptr, uint8_t size, bool left=true, bool right=false, bool use_space=true);
static void WriteString(uint16_t addr, FSTR_P const fstr, uint8_t size, bool left=true, bool right=false, bool use_space=true) {
WriteStringPGM(addr, FTOP(fstr), size, left, right, use_space);
}
template<typename T>
static void Write(uint16_t addr, T data) {
@ -83,7 +86,7 @@ public:
// start: position at which the sound was stored on the display.
// len: how many sounds to play. Sounds will play consecutively from start to start+len-1.
// volume: playback volume. 0 keeps the current volume.
static void PlaySound(uint8_t start, uint8_t len = 1, uint8_t volume = 0);
static void PlaySound(uint8_t start, uint8_t len=1, uint8_t volume=0);
// Enable/disable a specific touch control.
// type: control type.
// control: index of the control on the page (set during screen development).
@ -154,7 +157,7 @@ private:
};
enum dgus_system_addr : uint16_t {
DGUS_VERSION = 0x000f // OS/GUI version
DGUS_VERSION = 0x000F // OS/GUI version
};
static void WriteHeader(uint16_t addr, uint8_t command, uint8_t len);

View file

@ -387,7 +387,7 @@ void DGUSRxHandler::Steppers(DGUS_VP &vp, void *data_ptr) {
void DGUSRxHandler::ZOffset(DGUS_VP &vp, void *data_ptr) {
UNUSED(vp);
if (!ExtUI::isAxisPositionKnown(ExtUI::Z)) {
if (TERN0(NO_MOTION_BEFORE_HOMING, !ExtUI::isAxisPositionKnown(ExtUI::Z))) {
dgus_screen_handler.SetStatusMessage(GET_TEXT_F(DGUS_MSG_HOMING_REQUIRED));
return;
}
@ -411,7 +411,7 @@ void DGUSRxHandler::ZOffset(DGUS_VP &vp, void *data_ptr) {
void DGUSRxHandler::ZOffsetStep(DGUS_VP &vp, void *data_ptr) {
UNUSED(vp);
if (!ExtUI::isAxisPositionKnown(ExtUI::Z)) {
if (TERN0(NO_MOTION_BEFORE_HOMING, !ExtUI::isAxisPositionKnown(ExtUI::Z))) {
dgus_screen_handler.SetStatusMessage(GET_TEXT_F(DGUS_MSG_HOMING_REQUIRED));
return;
}
@ -525,7 +525,7 @@ void DGUSRxHandler::Probe(DGUS_VP &vp, void *data_ptr) {
#else
queue.enqueue_now(F("G29"));
#endif
queue.enqueue_now_P(DGUS_CMD_EEPROM_SAVE);
queue.enqueue_now(F("M500"));
}
void DGUSRxHandler::DisableABL(DGUS_VP &vp, void *data_ptr) {
@ -646,18 +646,12 @@ void DGUSRxHandler::Move(DGUS_VP &vp, void *data_ptr) {
switch (vp.addr) {
default: return;
case DGUS_Addr::MOVE_SetX:
axis = ExtUI::X;
break;
case DGUS_Addr::MOVE_SetY:
axis = ExtUI::Y;
break;
case DGUS_Addr::MOVE_SetZ:
axis = ExtUI::Z;
break;
case DGUS_Addr::MOVE_SetX: axis = ExtUI::X; break;
case DGUS_Addr::MOVE_SetY: axis = ExtUI::Y; break;
case DGUS_Addr::MOVE_SetZ: axis = ExtUI::Z; break;
}
if (!ExtUI::isAxisPositionKnown(axis)) {
if (TERN0(NO_MOTION_BEFORE_HOMING, !ExtUI::isAxisPositionKnown(axis))) {
dgus_screen_handler.SetStatusMessage(GET_TEXT_F(DGUS_MSG_HOMING_REQUIRED));
return;
}
@ -671,18 +665,11 @@ void DGUSRxHandler::MoveStep(DGUS_VP &vp, void *data_ptr) {
UNUSED(vp);
float offset;
switch (dgus_screen_handler.move_steps) {
default: return;
case DGUS_Data::StepSize::MM10:
offset = 10.0f;
break;
case DGUS_Data::StepSize::MM1:
offset = 1.0f;
break;
case DGUS_Data::StepSize::MMP1:
offset = 0.1f;
break;
case DGUS_Data::StepSize::MM10: offset = 10.0f; break;
case DGUS_Data::StepSize::MM1: offset = 1.0f; break;
case DGUS_Data::StepSize::MMP1: offset = 0.1f; break;
}
const DGUS_Data::MoveDirection direction = (DGUS_Data::MoveDirection)((uint8_t*)data_ptr)[1];
@ -690,30 +677,15 @@ void DGUSRxHandler::MoveStep(DGUS_VP &vp, void *data_ptr) {
switch (direction) {
default: return;
case DGUS_Data::MoveDirection::XP:
axis = ExtUI::X;
break;
case DGUS_Data::MoveDirection::XM:
axis = ExtUI::X;
offset = -offset;
break;
case DGUS_Data::MoveDirection::YP:
axis = ExtUI::Y;
break;
case DGUS_Data::MoveDirection::YM:
axis = ExtUI::Y;
offset = -offset;
break;
case DGUS_Data::MoveDirection::ZP:
axis = ExtUI::Z;
break;
case DGUS_Data::MoveDirection::ZM:
axis = ExtUI::Z;
offset = -offset;
break;
case DGUS_Data::MoveDirection::XM: offset = -offset;
case DGUS_Data::MoveDirection::XP: axis = ExtUI::X; break;
case DGUS_Data::MoveDirection::YM: offset = -offset;
case DGUS_Data::MoveDirection::YP: axis = ExtUI::Y; break;
case DGUS_Data::MoveDirection::ZM: offset = -offset;
case DGUS_Data::MoveDirection::ZP: axis = ExtUI::Z; break;
}
if (!ExtUI::isAxisPositionKnown(axis)) {
if (TERN0(NO_MOTION_BEFORE_HOMING, !ExtUI::isAxisPositionKnown(axis))) {
dgus_screen_handler.SetStatusMessage(GET_TEXT_F(DGUS_MSG_HOMING_REQUIRED));
return;
}
@ -727,7 +699,6 @@ void DGUSRxHandler::MoveSetStep(DGUS_VP &vp, void *data_ptr) {
UNUSED(vp);
const DGUS_Data::StepSize size = (DGUS_Data::StepSize)((uint8_t*)data_ptr)[1];
dgus_screen_handler.move_steps = size;
dgus_screen_handler.TriggerFullUpdate();
@ -746,9 +717,7 @@ void DGUSRxHandler::GcodeExecute(DGUS_VP &vp, void *data_ptr) {
UNUSED(vp);
UNUSED(data_ptr);
if (!strlen(dgus_screen_handler.gcode)) {
return;
}
if (!strlen(dgus_screen_handler.gcode)) return;
if (!dgus_screen_handler.IsPrinterIdle()) {
dgus_screen_handler.SetStatusMessage(GET_TEXT_F(DGUS_MSG_BUSY));
@ -765,9 +734,7 @@ void DGUSRxHandler::ResetEEPROM(DGUS_VP &vp, void *data_ptr) {
const DGUS_Data::Popup result = (DGUS_Data::Popup)((uint8_t*)data_ptr)[1];
if (result != DGUS_Data::Popup::CONFIRMED) {
return;
}
if (result != DGUS_Data::Popup::CONFIRMED) return;
if (!dgus_screen_handler.IsPrinterIdle()) {
dgus_screen_handler.SetStatusMessage(GET_TEXT_F(DGUS_MSG_BUSY));
@ -775,7 +742,7 @@ void DGUSRxHandler::ResetEEPROM(DGUS_VP &vp, void *data_ptr) {
}
queue.enqueue_now(F("M502"));
queue.enqueue_now_P(DGUS_CMD_EEPROM_SAVE);
queue.enqueue_now(F("M500"));
}
void DGUSRxHandler::SettingsExtra(DGUS_VP &vp, void *data_ptr) {
@ -908,7 +875,7 @@ void DGUSRxHandler::PIDRun(DGUS_VP &vp, void *data_ptr) {
dgus_screen_handler.ShowWaitScreen(GET_TEXT_F(DGUS_MSG_PID_AUTOTUNING), DGUS_Screen::PID);
queue.enqueue_one_now(buffer);
queue.enqueue_now_P(DGUS_CMD_EEPROM_SAVE);
queue.enqueue_now(F("M500"));
}
#if ENABLED(POWER_LOSS_RECOVERY)

View file

@ -69,11 +69,6 @@ bool DGUSScreenHandler::leveling_active = false;
millis_t DGUSScreenHandler::status_expire = 0;
millis_t DGUSScreenHandler::eeprom_save = 0;
const char DGUS_MSG_UNDEF[] PROGMEM = "-";
const char DGUS_CMD_HOME[] PROGMEM = "G28",
DGUS_CMD_EEPROM_SAVE[] PROGMEM = "M500";
void DGUSScreenHandler::Init() {
dgus_display.Init();
@ -146,7 +141,7 @@ void DGUSScreenHandler::Loop() {
if (eeprom_save > 0 && ELAPSED(ms, eeprom_save) && IsPrinterIdle()) {
eeprom_save = 0;
queue.enqueue_now_P(DGUS_CMD_EEPROM_SAVE);
queue.enqueue_now(F("M500"));
return;
}
@ -385,7 +380,7 @@ void DGUSScreenHandler::SetStatusMessage(const char* msg, const millis_t duratio
}
void DGUSScreenHandler::SetStatusMessage(FSTR_P const fmsg, const millis_t duration) {
dgus_display.WriteStringPGM((uint16_t)DGUS_Addr::MESSAGE_Status, FTOP(fmsg), DGUS_STATUS_LEN, false, true);
dgus_display.WriteString((uint16_t)DGUS_Addr::MESSAGE_Status, fmsg, DGUS_STATUS_LEN, false, true);
status_expire = (duration > 0 ? ExtUI::safe_millis() + duration : 0);
}

View file

@ -141,8 +141,3 @@ private:
};
extern DGUSScreenHandler dgus_screen_handler;
extern const char DGUS_MSG_UNDEF[];
extern const char DGUS_CMD_HOME[],
DGUS_CMD_EEPROM_SAVE[];

View file

@ -82,7 +82,7 @@ bool DGUSSetupHandler::LevelingMenu() {
dgus_screen_handler.ShowWaitScreen(GET_TEXT_F(DGUS_MSG_HOMING), DGUS_Screen::LEVELING_MENU);
queue.enqueue_now_P(DGUS_CMD_HOME);
queue.enqueue_now(F("G28"));
return false;
}
@ -101,7 +101,7 @@ bool DGUSSetupHandler::LevelingManual() {
dgus_screen_handler.ShowWaitScreen(GET_TEXT_F(DGUS_MSG_HOMING), DGUS_Screen::LEVELING_MANUAL);
queue.enqueue_now_P(DGUS_CMD_HOME);
queue.enqueue_now(F("G28"));
return false;
}
@ -130,7 +130,7 @@ bool DGUSSetupHandler::LevelingOffset() {
dgus_screen_handler.ShowWaitScreen(GET_TEXT_F(DGUS_MSG_HOMING), DGUS_Screen::LEVELING_OFFSET);
queue.enqueue_now_P(DGUS_CMD_HOME);
queue.enqueue_now(F("G28"));
return false;
}

View file

@ -522,7 +522,7 @@ void DGUSTxHandler::PrintTime(DGUS_VP &vp) {
dgus_display.WriteString((uint16_t)vp.addr, buffer, vp.size);
#else
dgus_display.WriteStringPGM((uint16_t)vp.addr, DGUS_MSG_UNDEF, vp.size);
dgus_display.WriteString((uint16_t)vp.addr, F("-"), vp.size);
#endif
}
@ -533,7 +533,7 @@ void DGUSTxHandler::LongestPrint(DGUS_VP &vp) {
dgus_display.WriteString((uint16_t)vp.addr, buffer, vp.size);
#else
dgus_display.WriteStringPGM((uint16_t)vp.addr, DGUS_MSG_UNDEF, vp.size);
dgus_display.WriteString((uint16_t)vp.addr, F("-"), vp.size);
#endif
}
@ -544,7 +544,7 @@ void DGUSTxHandler::FilamentUsed(DGUS_VP &vp) {
dgus_display.WriteString((uint16_t)vp.addr, buffer, vp.size);
#else
dgus_display.WriteStringPGM((uint16_t)vp.addr, DGUS_MSG_UNDEF, vp.size);
dgus_display.WriteString((uint16_t)vp.addr, F("-"), vp.size);
#endif
}