2020-07-19 21:35:15 +00:00
|
|
|
/**
|
|
|
|
* 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
|
2020-07-23 03:20:14 +00:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2020-07-19 21:35:15 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "../../../../inc/MarlinConfigPre.h"
|
|
|
|
|
|
|
|
#if HAS_DGUS_LCD
|
|
|
|
|
|
|
|
#include "DGUSScreenHandler.h"
|
|
|
|
|
|
|
|
#include "../../../../MarlinCore.h"
|
2021-02-27 23:35:32 +00:00
|
|
|
#include "../../../../gcode/queue.h"
|
|
|
|
#include "../../../../libs/duration_t.h"
|
|
|
|
#include "../../../../module/settings.h"
|
2020-07-19 21:35:15 +00:00
|
|
|
#include "../../../../module/temperature.h"
|
|
|
|
#include "../../../../module/motion.h"
|
|
|
|
#include "../../../../module/planner.h"
|
|
|
|
#include "../../../../module/printcounter.h"
|
2021-02-27 23:35:32 +00:00
|
|
|
#include "../../../../sd/cardreader.h"
|
2020-07-19 21:35:15 +00:00
|
|
|
|
|
|
|
#if ENABLED(POWER_LOSS_RECOVERY)
|
|
|
|
#include "../../../../feature/powerloss.h"
|
|
|
|
#endif
|
|
|
|
|
2021-02-27 23:35:32 +00:00
|
|
|
DGUSScreenHandler ScreenHandler;
|
2020-07-19 21:35:15 +00:00
|
|
|
|
2021-02-27 23:35:32 +00:00
|
|
|
uint16_t DGUSScreenHandler::ConfirmVP;
|
2020-07-19 21:35:15 +00:00
|
|
|
|
|
|
|
DGUSLCD_Screens DGUSScreenHandler::current_screen;
|
|
|
|
DGUSLCD_Screens DGUSScreenHandler::past_screens[NUM_PAST_SCREENS];
|
|
|
|
uint8_t DGUSScreenHandler::update_ptr;
|
|
|
|
uint16_t DGUSScreenHandler::skipVP;
|
|
|
|
bool DGUSScreenHandler::ScreenComplete;
|
|
|
|
|
2021-02-27 23:35:32 +00:00
|
|
|
void (*DGUSScreenHandler::confirm_action_cb)() = nullptr;
|
2020-07-19 21:35:15 +00:00
|
|
|
|
2021-02-27 23:35:32 +00:00
|
|
|
#if ENABLED(SDSUPPORT)
|
|
|
|
int16_t DGUSScreenHandler::top_file = 0,
|
|
|
|
DGUSScreenHandler::file_to_print = 0;
|
|
|
|
static ExtUI::FileList filelist;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
|
|
|
|
filament_data_t filament_data;
|
|
|
|
#endif
|
2020-07-19 21:35:15 +00:00
|
|
|
|
|
|
|
void DGUSScreenHandler::sendinfoscreen(const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool l4inflash) {
|
|
|
|
DGUS_VP_Variable ramcopy;
|
|
|
|
if (populate_VPVar(VP_MSGSTR1, &ramcopy)) {
|
|
|
|
ramcopy.memadr = (void*) line1;
|
|
|
|
l1inflash ? DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenHandler::DGUSLCD_SendStringToDisplay(ramcopy);
|
|
|
|
}
|
|
|
|
if (populate_VPVar(VP_MSGSTR2, &ramcopy)) {
|
|
|
|
ramcopy.memadr = (void*) line2;
|
|
|
|
l2inflash ? DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenHandler::DGUSLCD_SendStringToDisplay(ramcopy);
|
|
|
|
}
|
|
|
|
if (populate_VPVar(VP_MSGSTR3, &ramcopy)) {
|
|
|
|
ramcopy.memadr = (void*) line3;
|
|
|
|
l3inflash ? DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenHandler::DGUSLCD_SendStringToDisplay(ramcopy);
|
|
|
|
}
|
|
|
|
if (populate_VPVar(VP_MSGSTR4, &ramcopy)) {
|
|
|
|
ramcopy.memadr = (void*) line4;
|
|
|
|
l4inflash ? DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenHandler::DGUSLCD_SendStringToDisplay(ramcopy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DGUSScreenHandler::HandleUserConfirmationPopUp(uint16_t VP, const char* line1, const char* line2, const char* line3, const char* line4, bool l1, bool l2, bool l3, bool l4) {
|
2021-02-27 23:35:32 +00:00
|
|
|
if (current_screen == DGUSLCD_SCREEN_CONFIRM) // Already showing a pop up, so we need to cancel that first.
|
2020-07-19 21:35:15 +00:00
|
|
|
PopToOldScreen();
|
|
|
|
|
|
|
|
ConfirmVP = VP;
|
|
|
|
sendinfoscreen(line1, line2, line3, line4, l1, l2, l3, l4);
|
2021-02-27 23:35:32 +00:00
|
|
|
GotoScreen(DGUSLCD_SCREEN_CONFIRM);
|
2020-07-19 21:35:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DGUSScreenHandler::setstatusmessage(const char *msg) {
|
|
|
|
DGUS_VP_Variable ramcopy;
|
|
|
|
if (populate_VPVar(VP_M117, &ramcopy)) {
|
|
|
|
ramcopy.memadr = (void*) msg;
|
|
|
|
DGUSLCD_SendStringToDisplay(ramcopy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DGUSScreenHandler::setstatusmessagePGM(PGM_P const msg) {
|
|
|
|
DGUS_VP_Variable ramcopy;
|
|
|
|
if (populate_VPVar(VP_M117, &ramcopy)) {
|
|
|
|
ramcopy.memadr = (void*) msg;
|
|
|
|
DGUSLCD_SendStringToDisplayPGM(ramcopy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Send an 8 bit or 16 bit value to the display.
|
|
|
|
void DGUSScreenHandler::DGUSLCD_SendWordValueToDisplay(DGUS_VP_Variable &var) {
|
|
|
|
if (var.memadr) {
|
|
|
|
//DEBUG_ECHOPAIR(" DGUS_LCD_SendWordValueToDisplay ", var.VP);
|
|
|
|
//DEBUG_ECHOLNPAIR(" data ", *(uint16_t *)var.memadr);
|
2020-07-19 22:34:36 +00:00
|
|
|
if (var.size > 1)
|
|
|
|
dgusdisplay.WriteVariable(var.VP, *(int16_t*)var.memadr);
|
|
|
|
else
|
|
|
|
dgusdisplay.WriteVariable(var.VP, *(int8_t*)var.memadr);
|
2020-07-19 21:35:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Send an uint8_t between 0 and 255 to the display, but scale to a percentage (0..100)
|
|
|
|
void DGUSScreenHandler::DGUSLCD_SendPercentageToDisplay(DGUS_VP_Variable &var) {
|
|
|
|
if (var.memadr) {
|
|
|
|
//DEBUG_ECHOPAIR(" DGUS_LCD_SendWordValueToDisplay ", var.VP);
|
|
|
|
//DEBUG_ECHOLNPAIR(" data ", *(uint16_t *)var.memadr);
|
2021-02-27 23:35:32 +00:00
|
|
|
uint16_t tmp = *(uint8_t *) var.memadr + 1; // +1 -> avoid rounding issues for the display.
|
2020-07-19 21:35:15 +00:00
|
|
|
tmp = map(tmp, 0, 255, 0, 100);
|
2020-07-19 22:34:36 +00:00
|
|
|
dgusdisplay.WriteVariable(var.VP, tmp);
|
2020-07-19 21:35:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Send the current print progress to the display.
|
|
|
|
void DGUSScreenHandler::DGUSLCD_SendPrintProgressToDisplay(DGUS_VP_Variable &var) {
|
|
|
|
//DEBUG_ECHOPAIR(" DGUSLCD_SendPrintProgressToDisplay ", var.VP);
|
|
|
|
uint16_t tmp = ExtUI::getProgress_percent();
|
|
|
|
//DEBUG_ECHOLNPAIR(" data ", tmp);
|
2020-07-19 22:34:36 +00:00
|
|
|
dgusdisplay.WriteVariable(var.VP, tmp);
|
2020-07-19 21:35:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Send the current print time to the display.
|
|
|
|
// It is using a hex display for that: It expects BSD coded data in the format xxyyzz
|
|
|
|
void DGUSScreenHandler::DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var) {
|
|
|
|
duration_t elapsed = print_job_timer.duration();
|
|
|
|
char buf[32];
|
|
|
|
elapsed.toString(buf);
|
|
|
|
dgusdisplay.WriteVariable(VP_PrintTime, buf, var.size, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Send an uint8_t between 0 and 100 to a variable scale to 0..255
|
|
|
|
void DGUSScreenHandler::DGUSLCD_PercentageToUint8(DGUS_VP_Variable &var, void *val_ptr) {
|
|
|
|
if (var.memadr) {
|
|
|
|
uint16_t value = swap16(*(uint16_t*)val_ptr);
|
2021-02-27 23:35:32 +00:00
|
|
|
DEBUG_ECHOLNPAIR("FAN value get:", value);
|
2020-07-19 21:35:15 +00:00
|
|
|
*(uint8_t*)var.memadr = map(constrain(value, 0, 100), 0, 100, 0, 255);
|
2021-02-27 23:35:32 +00:00
|
|
|
DEBUG_ECHOLNPAIR("FAN value change:", *(uint8_t*)var.memadr);
|
2020-07-19 21:35:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sends a (RAM located) string to the DGUS Display
|
|
|
|
// (Note: The DGUS Display does not clear after the \0, you have to
|
|
|
|
// overwrite the remainings with spaces.// var.size has the display buffer size!
|
|
|
|
void DGUSScreenHandler::DGUSLCD_SendStringToDisplay(DGUS_VP_Variable &var) {
|
|
|
|
char *tmp = (char*) var.memadr;
|
|
|
|
dgusdisplay.WriteVariable(var.VP, tmp, var.size, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sends a (flash located) string to the DGUS Display
|
|
|
|
// (Note: The DGUS Display does not clear after the \0, you have to
|
|
|
|
// overwrite the remainings with spaces.// var.size has the display buffer size!
|
|
|
|
void DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable &var) {
|
|
|
|
char *tmp = (char*) var.memadr;
|
|
|
|
dgusdisplay.WriteVariablePGM(var.VP, tmp, var.size, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if HAS_PID_HEATING
|
|
|
|
void DGUSScreenHandler::DGUSLCD_SendTemperaturePID(DGUS_VP_Variable &var) {
|
|
|
|
float value = *(float *)var.memadr;
|
|
|
|
float valuesend = 0;
|
|
|
|
switch (var.VP) {
|
|
|
|
default: return;
|
|
|
|
#if HOTENDS >= 1
|
|
|
|
case VP_E0_PID_P: valuesend = value; break;
|
|
|
|
case VP_E0_PID_I: valuesend = unscalePID_i(value); break;
|
|
|
|
case VP_E0_PID_D: valuesend = unscalePID_d(value); break;
|
|
|
|
#endif
|
|
|
|
#if HOTENDS >= 2
|
|
|
|
case VP_E1_PID_P: valuesend = value; break;
|
|
|
|
case VP_E1_PID_I: valuesend = unscalePID_i(value); break;
|
|
|
|
case VP_E1_PID_D: valuesend = unscalePID_d(value); break;
|
|
|
|
#endif
|
|
|
|
#if HAS_HEATED_BED
|
|
|
|
case VP_BED_PID_P: valuesend = value; break;
|
|
|
|
case VP_BED_PID_I: valuesend = unscalePID_i(value); break;
|
|
|
|
case VP_BED_PID_D: valuesend = unscalePID_d(value); break;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
valuesend *= cpow(10, 1);
|
|
|
|
union { int16_t i; char lb[2]; } endian;
|
|
|
|
|
|
|
|
char tmp[2];
|
|
|
|
endian.i = valuesend;
|
|
|
|
tmp[0] = endian.lb[1];
|
|
|
|
tmp[1] = endian.lb[0];
|
|
|
|
dgusdisplay.WriteVariable(var.VP, tmp, 2);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(PRINTCOUNTER)
|
|
|
|
|
|
|
|
// Send the accumulate print time to the display.
|
|
|
|
// It is using a hex display for that: It expects BSD coded data in the format xxyyzz
|
|
|
|
void DGUSScreenHandler::DGUSLCD_SendPrintAccTimeToDisplay(DGUS_VP_Variable &var) {
|
|
|
|
printStatistics state = print_job_timer.getStats();
|
2020-11-14 00:27:31 +00:00
|
|
|
char buf[22];
|
2020-07-19 21:35:15 +00:00
|
|
|
duration_t elapsed = state.printTime;
|
|
|
|
elapsed.toString(buf);
|
|
|
|
dgusdisplay.WriteVariable(VP_PrintAccTime, buf, var.size, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DGUSScreenHandler::DGUSLCD_SendPrintsTotalToDisplay(DGUS_VP_Variable &var) {
|
|
|
|
printStatistics state = print_job_timer.getStats();
|
2020-11-14 00:27:31 +00:00
|
|
|
char buf[10];
|
2020-07-19 21:35:15 +00:00
|
|
|
sprintf_P(buf, PSTR("%u"), state.totalPrints);
|
|
|
|
dgusdisplay.WriteVariable(VP_PrintsTotal, buf, var.size, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Send fan status value to the display.
|
|
|
|
#if HAS_FAN
|
2021-02-27 23:35:32 +00:00
|
|
|
|
2020-07-19 21:35:15 +00:00
|
|
|
void DGUSScreenHandler::DGUSLCD_SendFanStatusToDisplay(DGUS_VP_Variable &var) {
|
|
|
|
if (var.memadr) {
|
|
|
|
DEBUG_ECHOPAIR(" DGUSLCD_SendFanStatusToDisplay ", var.VP);
|
|
|
|
DEBUG_ECHOLNPAIR(" data ", *(uint8_t *)var.memadr);
|
|
|
|
uint16_t data_to_send = 0;
|
|
|
|
if (*(uint8_t *) var.memadr) data_to_send = 1;
|
|
|
|
dgusdisplay.WriteVariable(var.VP, data_to_send);
|
|
|
|
}
|
|
|
|
}
|
2021-02-27 23:35:32 +00:00
|
|
|
|
2020-07-19 21:35:15 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// Send heater status value to the display.
|
|
|
|
void DGUSScreenHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var) {
|
|
|
|
if (var.memadr) {
|
|
|
|
DEBUG_ECHOPAIR(" DGUSLCD_SendHeaterStatusToDisplay ", var.VP);
|
|
|
|
DEBUG_ECHOLNPAIR(" data ", *(int16_t *)var.memadr);
|
|
|
|
uint16_t data_to_send = 0;
|
|
|
|
if (*(int16_t *) var.memadr) data_to_send = 1;
|
|
|
|
dgusdisplay.WriteVariable(var.VP, data_to_send);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if ENABLED(DGUS_UI_WAITING)
|
2021-02-27 23:35:32 +00:00
|
|
|
|
2020-07-19 21:35:15 +00:00
|
|
|
void DGUSScreenHandler::DGUSLCD_SendWaitingStatusToDisplay(DGUS_VP_Variable &var) {
|
|
|
|
// In FYSETC UI design there are 10 statuses to loop
|
|
|
|
static uint16_t period = 0;
|
|
|
|
static uint16_t index = 0;
|
|
|
|
//DEBUG_ECHOPAIR(" DGUSLCD_SendWaitingStatusToDisplay ", var.VP);
|
|
|
|
//DEBUG_ECHOLNPAIR(" data ", swap16(index));
|
|
|
|
if (period++ > DGUS_UI_WAITING_STATUS_PERIOD) {
|
2020-07-19 22:34:36 +00:00
|
|
|
dgusdisplay.WriteVariable(var.VP, index);
|
2020-07-19 21:35:15 +00:00
|
|
|
//DEBUG_ECHOLNPAIR(" data ", swap16(index));
|
|
|
|
if (++index >= DGUS_UI_WAITING_STATUS) index = 0;
|
|
|
|
period = 0;
|
|
|
|
}
|
|
|
|
}
|
2021-02-27 23:35:32 +00:00
|
|
|
|
2020-07-19 21:35:15 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(SDSUPPORT)
|
|
|
|
|
|
|
|
void DGUSScreenHandler::ScreenChangeHookIfSD(DGUS_VP_Variable &var, void *val_ptr) {
|
|
|
|
// default action executed when there is a SD card, but not printing
|
|
|
|
if (ExtUI::isMediaInserted() && !ExtUI::isPrintingFromMedia()) {
|
|
|
|
ScreenChangeHook(var, val_ptr);
|
|
|
|
dgusdisplay.RequestScreen(current_screen);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if we are printing, we jump to two screens after the requested one.
|
|
|
|
// This should host e.g a print pause / print abort / print resume dialog.
|
|
|
|
// This concept allows to recycle this hook for other file
|
|
|
|
if (ExtUI::isPrintingFromMedia() && !card.flag.abort_sd_printing) {
|
|
|
|
GotoScreen(DGUSLCD_SCREEN_SDPRINTMANIPULATION);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Don't let the user in the dark why there is no reaction.
|
|
|
|
if (!ExtUI::isMediaInserted()) {
|
|
|
|
setstatusmessagePGM(GET_TEXT(MSG_NO_MEDIA));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (card.flag.abort_sd_printing) {
|
|
|
|
setstatusmessagePGM(GET_TEXT(MSG_MEDIA_ABORTING));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DGUSScreenHandler::DGUSLCD_SD_ScrollFilelist(DGUS_VP_Variable& var, void *val_ptr) {
|
|
|
|
auto old_top = top_file;
|
|
|
|
const int16_t scroll = (int16_t)swap16(*(uint16_t*)val_ptr);
|
|
|
|
if (scroll) {
|
|
|
|
top_file += scroll;
|
|
|
|
DEBUG_ECHOPAIR("new topfile calculated:", top_file);
|
|
|
|
if (top_file < 0) {
|
|
|
|
top_file = 0;
|
|
|
|
DEBUG_ECHOLNPGM("Top of filelist reached");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
int16_t max_top = filelist.count() - DGUS_SD_FILESPERSCREEN;
|
|
|
|
NOLESS(max_top, 0);
|
|
|
|
NOMORE(top_file, max_top);
|
|
|
|
}
|
|
|
|
DEBUG_ECHOPAIR("new topfile adjusted:", top_file);
|
|
|
|
}
|
|
|
|
else if (!filelist.isAtRootDir()) {
|
2021-02-27 23:35:32 +00:00
|
|
|
IF_DISABLED(DGUS_LCD_UI_MKS, filelist.upDir());
|
2020-07-19 21:35:15 +00:00
|
|
|
top_file = 0;
|
|
|
|
ForceCompleteUpdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (old_top != top_file) ForceCompleteUpdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DGUSScreenHandler::DGUSLCD_SD_ReallyAbort(DGUS_VP_Variable &var, void *val_ptr) {
|
|
|
|
ExtUI::stopPrint();
|
|
|
|
GotoScreen(DGUSLCD_SCREEN_MAIN);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DGUSScreenHandler::DGUSLCD_SD_PrintTune(DGUS_VP_Variable &var, void *val_ptr) {
|
|
|
|
if (!ExtUI::isPrintingFromMedia()) return; // avoid race condition when user stays in this menu and printer finishes.
|
|
|
|
GotoScreen(DGUSLCD_SCREEN_SDPRINTTUNE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DGUSScreenHandler::SDCardError() {
|
|
|
|
DGUSScreenHandler::SDCardRemoved();
|
2021-02-27 23:35:32 +00:00
|
|
|
sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("SD card error"), nullptr, true, true, true, true);
|
|
|
|
SetupConfirmAction(nullptr);
|
|
|
|
GotoScreen(DGUSLCD_SCREEN_POPUP);
|
2020-07-19 21:35:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // SDSUPPORT
|
|
|
|
|
|
|
|
void DGUSScreenHandler::ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr) {
|
|
|
|
DGUS_VP_Variable ramcopy;
|
|
|
|
if (!populate_VPVar(ConfirmVP, &ramcopy)) return;
|
|
|
|
if (ramcopy.set_by_display_handler) ramcopy.set_by_display_handler(ramcopy, val_ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
const uint16_t* DGUSLCD_FindScreenVPMapList(uint8_t screen) {
|
|
|
|
const uint16_t *ret;
|
|
|
|
const struct VPMapping *map = VPMap;
|
2021-02-27 23:35:32 +00:00
|
|
|
while ((ret = (uint16_t*) pgm_read_ptr(&(map->VPList)))) {
|
2020-07-19 21:35:15 +00:00
|
|
|
if (pgm_read_byte(&(map->screen)) == screen) return ret;
|
|
|
|
map++;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
const DGUS_VP_Variable* DGUSLCD_FindVPVar(const uint16_t vp) {
|
|
|
|
const DGUS_VP_Variable *ret = ListOfVP;
|
|
|
|
do {
|
|
|
|
const uint16_t vpcheck = pgm_read_word(&(ret->VP));
|
|
|
|
if (vpcheck == 0) break;
|
|
|
|
if (vpcheck == vp) return ret;
|
|
|
|
++ret;
|
|
|
|
} while (1);
|
|
|
|
|
|
|
|
DEBUG_ECHOLNPAIR("FindVPVar NOT FOUND ", vp);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DGUSScreenHandler::ScreenChangeHookIfIdle(DGUS_VP_Variable &var, void *val_ptr) {
|
|
|
|
if (!ExtUI::isPrinting()) {
|
|
|
|
ScreenChangeHook(var, val_ptr);
|
|
|
|
dgusdisplay.RequestScreen(current_screen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DGUSScreenHandler::HandleAllHeatersOff(DGUS_VP_Variable &var, void *val_ptr) {
|
|
|
|
thermalManager.disable_all_heaters();
|
2021-02-27 23:35:32 +00:00
|
|
|
ForceCompleteUpdate(); // hint to send all data.
|
2020-07-19 21:35:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DGUSScreenHandler::HandleTemperatureChanged(DGUS_VP_Variable &var, void *val_ptr) {
|
2021-03-24 09:11:43 +00:00
|
|
|
celsius_t newvalue = swap16(*(uint16_t*)val_ptr);
|
|
|
|
celsius_t acceptedvalue;
|
2020-07-19 21:35:15 +00:00
|
|
|
|
|
|
|
switch (var.VP) {
|
|
|
|
default: return;
|
|
|
|
#if HOTENDS >= 1
|
|
|
|
case VP_T_E0_Set:
|
2021-03-24 09:11:43 +00:00
|
|
|
NOMORE(newvalue, HEATER_0_MAXTEMP);
|
2020-07-19 21:35:15 +00:00
|
|
|
thermalManager.setTargetHotend(newvalue, 0);
|
2021-03-06 15:04:05 +00:00
|
|
|
acceptedvalue = thermalManager.degTargetHotend(0);
|
2020-07-19 21:35:15 +00:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#if HOTENDS >= 2
|
|
|
|
case VP_T_E1_Set:
|
2021-03-24 09:11:43 +00:00
|
|
|
NOMORE(newvalue, HEATER_1_MAXTEMP);
|
2020-07-19 21:35:15 +00:00
|
|
|
thermalManager.setTargetHotend(newvalue, 1);
|
2021-03-06 15:04:05 +00:00
|
|
|
acceptedvalue = thermalManager.degTargetHotend(1);
|
2021-02-27 23:35:32 +00:00
|
|
|
break;
|
2020-07-19 21:35:15 +00:00
|
|
|
#endif
|
|
|
|
#if HAS_HEATED_BED
|
|
|
|
case VP_T_Bed_Set:
|
2021-03-24 09:11:43 +00:00
|
|
|
NOMORE(newvalue, BED_MAXTEMP);
|
2020-07-19 21:35:15 +00:00
|
|
|
thermalManager.setTargetBed(newvalue);
|
2021-03-06 15:04:05 +00:00
|
|
|
acceptedvalue = thermalManager.degTargetBed();
|
2020-07-19 21:35:15 +00:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// reply to display the new value to update the view if the new value was rejected by the Thermal Manager.
|
|
|
|
if (newvalue != acceptedvalue && var.send_to_display_handler) var.send_to_display_handler(var);
|
2021-02-27 23:35:32 +00:00
|
|
|
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
|
2020-07-19 21:35:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DGUSScreenHandler::HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_ptr) {
|
|
|
|
#if EXTRUDERS
|
|
|
|
uint16_t newvalue = swap16(*(uint16_t*)val_ptr);
|
|
|
|
uint8_t target_extruder;
|
|
|
|
switch (var.VP) {
|
|
|
|
default: return;
|
|
|
|
#if HOTENDS >= 1
|
|
|
|
case VP_Flowrate_E0: target_extruder = 0; break;
|
|
|
|
#endif
|
|
|
|
#if HOTENDS >= 2
|
|
|
|
case VP_Flowrate_E1: target_extruder = 1; break;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
planner.set_flow(target_extruder, newvalue);
|
2021-02-27 23:35:32 +00:00
|
|
|
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
|
2020-07-19 21:35:15 +00:00
|
|
|
#else
|
|
|
|
UNUSED(var); UNUSED(val_ptr);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void DGUSScreenHandler::HandleManualExtrude(DGUS_VP_Variable &var, void *val_ptr) {
|
|
|
|
DEBUG_ECHOLNPGM("HandleManualExtrude");
|
|
|
|
|
|
|
|
int16_t movevalue = swap16(*(uint16_t*)val_ptr);
|
|
|
|
float target = movevalue * 0.01f;
|
|
|
|
ExtUI::extruder_t target_extruder;
|
|
|
|
|
|
|
|
switch (var.VP) {
|
|
|
|
#if HOTENDS >= 1
|
|
|
|
case VP_MOVE_E0: target_extruder = ExtUI::extruder_t::E0; break;
|
|
|
|
#endif
|
|
|
|
#if HOTENDS >= 2
|
|
|
|
case VP_MOVE_E1: target_extruder = ExtUI::extruder_t::E1; break;
|
|
|
|
#endif
|
|
|
|
default: return;
|
|
|
|
}
|
|
|
|
|
|
|
|
target += ExtUI::getAxisPosition_mm(target_extruder);
|
|
|
|
ExtUI::setAxisPosition_mm(target, target_extruder);
|
|
|
|
skipVP = var.VP;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
|
|
|
|
void DGUSScreenHandler::HandleManualMoveOption(DGUS_VP_Variable &var, void *val_ptr) {
|
|
|
|
DEBUG_ECHOLNPGM("HandleManualMoveOption");
|
|
|
|
*(uint16_t*)var.memadr = swap16(*(uint16_t*)val_ptr);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void DGUSScreenHandler::HandleMotorLockUnlock(DGUS_VP_Variable &var, void *val_ptr) {
|
|
|
|
DEBUG_ECHOLNPGM("HandleMotorLockUnlock");
|
|
|
|
|
|
|
|
char buf[4];
|
|
|
|
const int16_t lock = swap16(*(uint16_t*)val_ptr);
|
|
|
|
strcpy_P(buf, lock ? PSTR("M18") : PSTR("M17"));
|
|
|
|
|
|
|
|
//DEBUG_ECHOPAIR(" ", buf);
|
|
|
|
queue.enqueue_one_now(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DGUSScreenHandler::HandleSettings(DGUS_VP_Variable &var, void *val_ptr) {
|
|
|
|
DEBUG_ECHOLNPGM("HandleSettings");
|
|
|
|
uint16_t value = swap16(*(uint16_t*)val_ptr);
|
|
|
|
switch (value) {
|
|
|
|
default: break;
|
|
|
|
case 1:
|
|
|
|
TERN_(PRINTCOUNTER, print_job_timer.initStats());
|
2021-02-27 23:35:32 +00:00
|
|
|
settings.reset();
|
|
|
|
settings.save();
|
2020-07-19 21:35:15 +00:00
|
|
|
break;
|
2021-02-27 23:35:32 +00:00
|
|
|
case 2: settings.load(); break;
|
|
|
|
case 3: settings.save(); break;
|
2020-07-19 21:35:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DGUSScreenHandler::HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr) {
|
|
|
|
DEBUG_ECHOLNPGM("HandleStepPerMMChanged");
|
|
|
|
|
|
|
|
uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
|
|
|
|
DEBUG_ECHOLNPAIR("value_raw:", value_raw);
|
2021-02-27 23:35:32 +00:00
|
|
|
float value = (float)value_raw / 10;
|
2020-07-19 21:35:15 +00:00
|
|
|
ExtUI::axis_t axis;
|
|
|
|
switch (var.VP) {
|
|
|
|
case VP_X_STEP_PER_MM: axis = ExtUI::axis_t::X; break;
|
|
|
|
case VP_Y_STEP_PER_MM: axis = ExtUI::axis_t::Y; break;
|
|
|
|
case VP_Z_STEP_PER_MM: axis = ExtUI::axis_t::Z; break;
|
|
|
|
default: return;
|
|
|
|
}
|
|
|
|
DEBUG_ECHOLNPAIR_F("value:", value);
|
|
|
|
ExtUI::setAxisSteps_per_mm(value, axis);
|
|
|
|
DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisSteps_per_mm(axis));
|
2021-02-27 23:35:32 +00:00
|
|
|
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
|
2020-07-19 21:35:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DGUSScreenHandler::HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr) {
|
|
|
|
DEBUG_ECHOLNPGM("HandleStepPerMMExtruderChanged");
|
|
|
|
|
|
|
|
uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
|
|
|
|
DEBUG_ECHOLNPAIR("value_raw:", value_raw);
|
2021-02-27 23:35:32 +00:00
|
|
|
float value = (float)value_raw / 10;
|
2020-07-19 21:35:15 +00:00
|
|
|
ExtUI::extruder_t extruder;
|
|
|
|
switch (var.VP) {
|
|
|
|
default: return;
|
|
|
|
#if HOTENDS >= 1
|
2021-02-27 23:35:32 +00:00
|
|
|
case VP_E0_STEP_PER_MM: extruder = ExtUI::extruder_t::E0; break;
|
2020-07-19 21:35:15 +00:00
|
|
|
#endif
|
|
|
|
#if HOTENDS >= 2
|
2021-02-27 23:35:32 +00:00
|
|
|
case VP_E1_STEP_PER_MM: extruder = ExtUI::extruder_t::E1; break;
|
2020-07-19 21:35:15 +00:00
|
|
|
#endif
|
|
|
|
}
|
2021-02-27 23:35:32 +00:00
|
|
|
DEBUG_ECHOLNPAIR_F("value:", value);
|
|
|
|
ExtUI::setAxisSteps_per_mm(value, extruder);
|
|
|
|
DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisSteps_per_mm(extruder));
|
|
|
|
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
|
|
|
|
}
|
2020-07-19 21:35:15 +00:00
|
|
|
|
2021-02-27 23:35:32 +00:00
|
|
|
#if HAS_PID_HEATING
|
2020-07-19 21:35:15 +00:00
|
|
|
void DGUSScreenHandler::HandlePIDAutotune(DGUS_VP_Variable &var, void *val_ptr) {
|
|
|
|
DEBUG_ECHOLNPGM("HandlePIDAutotune");
|
|
|
|
|
|
|
|
char buf[32] = {0};
|
|
|
|
|
|
|
|
switch (var.VP) {
|
|
|
|
default: break;
|
2021-02-27 23:35:32 +00:00
|
|
|
#if ENABLED(PIDTEMP)
|
|
|
|
#if HOTENDS >= 1
|
|
|
|
case VP_PID_AUTOTUNE_E0: // Autotune Extruder 0
|
|
|
|
sprintf_P(buf, PSTR("M303 E%d C5 S210 U1"), ExtUI::extruder_t::E0);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#if HOTENDS >= 2
|
|
|
|
case VP_PID_AUTOTUNE_E1:
|
|
|
|
sprintf_P(buf, PSTR("M303 E%d C5 S210 U1"), ExtUI::extruder_t::E1);
|
|
|
|
break;
|
|
|
|
#endif
|
2020-07-19 21:35:15 +00:00
|
|
|
#endif
|
2021-02-27 23:35:32 +00:00
|
|
|
#if ENABLED(PIDTEMPBED)
|
|
|
|
case VP_PID_AUTOTUNE_BED:
|
|
|
|
sprintf_P(buf, PSTR("M303 E-1 C5 S70 U1"));
|
2020-07-19 21:35:15 +00:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
if (buf[0]) queue.enqueue_one_now(buf);
|
|
|
|
|
|
|
|
#if ENABLED(DGUS_UI_WAITING)
|
|
|
|
sendinfoscreen(PSTR("PID is autotuning"), PSTR("please wait"), NUL_STR, NUL_STR, true, true, true, true);
|
|
|
|
GotoScreen(DGUSLCD_SCREEN_WAITING);
|
|
|
|
#endif
|
|
|
|
}
|
2021-02-27 23:35:32 +00:00
|
|
|
#endif // HAS_PID_HEATING
|
2020-07-19 21:35:15 +00:00
|
|
|
|
|
|
|
#if HAS_BED_PROBE
|
|
|
|
void DGUSScreenHandler::HandleProbeOffsetZChanged(DGUS_VP_Variable &var, void *val_ptr) {
|
|
|
|
DEBUG_ECHOLNPGM("HandleProbeOffsetZChanged");
|
|
|
|
|
|
|
|
const float offset = float(int16_t(swap16(*(uint16_t*)val_ptr))) / 100.0f;
|
|
|
|
ExtUI::setZOffset_mm(offset);
|
2021-02-27 23:35:32 +00:00
|
|
|
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
|
2020-07-19 21:35:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAS_FAN
|
|
|
|
void DGUSScreenHandler::HandleFanControl(DGUS_VP_Variable &var, void *val_ptr) {
|
|
|
|
DEBUG_ECHOLNPGM("HandleFanControl");
|
|
|
|
*(uint8_t*)var.memadr = *(uint8_t*)var.memadr > 0 ? 0 : 255;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void DGUSScreenHandler::HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr) {
|
|
|
|
DEBUG_ECHOLNPGM("HandleHeaterControl");
|
|
|
|
|
|
|
|
uint8_t preheat_temp = 0;
|
|
|
|
switch (var.VP) {
|
|
|
|
#if HOTENDS >= 1
|
|
|
|
case VP_E0_CONTROL:
|
|
|
|
#endif
|
|
|
|
#if HOTENDS >= 2
|
|
|
|
case VP_E1_CONTROL:
|
|
|
|
#endif
|
|
|
|
#if HOTENDS >= 3
|
|
|
|
case VP_E2_CONTROL:
|
|
|
|
#endif
|
2021-02-27 23:35:32 +00:00
|
|
|
preheat_temp = PREHEAT_1_TEMP_HOTEND;
|
|
|
|
break;
|
2020-07-19 21:35:15 +00:00
|
|
|
|
|
|
|
case VP_BED_CONTROL:
|
|
|
|
preheat_temp = PREHEAT_1_TEMP_BED;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
*(int16_t*)var.memadr = *(int16_t*)var.memadr > 0 ? 0 : preheat_temp;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if ENABLED(DGUS_PREHEAT_UI)
|
|
|
|
|
|
|
|
void DGUSScreenHandler::HandlePreheat(DGUS_VP_Variable &var, void *val_ptr) {
|
|
|
|
DEBUG_ECHOLNPGM("HandlePreheat");
|
|
|
|
|
|
|
|
uint8_t e_temp = 0;
|
2021-03-24 10:40:28 +00:00
|
|
|
#if ENABLED(HAS_HEATED_BED)
|
|
|
|
uint8_t bed_temp = 0;
|
|
|
|
#endif
|
2020-07-19 21:35:15 +00:00
|
|
|
const uint16_t preheat_option = swap16(*(uint16_t*)val_ptr);
|
|
|
|
switch (preheat_option) {
|
|
|
|
default:
|
|
|
|
case 0: // Preheat PLA
|
|
|
|
#if defined(PREHEAT_1_TEMP_HOTEND) && defined(PREHEAT_1_TEMP_BED)
|
|
|
|
e_temp = PREHEAT_1_TEMP_HOTEND;
|
|
|
|
TERN_(HAS_HEATED_BED, bed_temp = PREHEAT_1_TEMP_BED);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case 1: // Preheat ABS
|
|
|
|
#if defined(PREHEAT_2_TEMP_HOTEND) && defined(PREHEAT_2_TEMP_BED)
|
|
|
|
e_temp = PREHEAT_2_TEMP_HOTEND;
|
|
|
|
TERN_(HAS_HEATED_BED, bed_temp = PREHEAT_2_TEMP_BED);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case 2: // Preheat PET
|
|
|
|
#if defined(PREHEAT_3_TEMP_HOTEND) && defined(PREHEAT_3_TEMP_BED)
|
|
|
|
e_temp = PREHEAT_3_TEMP_HOTEND;
|
|
|
|
TERN_(HAS_HEATED_BED, bed_temp = PREHEAT_3_TEMP_BED);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case 3: // Preheat FLEX
|
|
|
|
#if defined(PREHEAT_4_TEMP_HOTEND) && defined(PREHEAT_4_TEMP_BED)
|
|
|
|
e_temp = PREHEAT_4_TEMP_HOTEND;
|
|
|
|
TERN_(HAS_HEATED_BED, bed_temp = PREHEAT_4_TEMP_BED);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case 7: break; // Custom preheat
|
|
|
|
case 9: break; // Cool down
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (var.VP) {
|
|
|
|
default: return;
|
2021-02-27 23:35:32 +00:00
|
|
|
#if HOTENDS >= 1
|
|
|
|
case VP_E0_BED_PREHEAT:
|
|
|
|
thermalManager.setTargetHotend(e_temp, 0);
|
|
|
|
TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(bed_temp));
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#if HOTENDS >= 2
|
|
|
|
case VP_E1_BED_PREHEAT:
|
|
|
|
thermalManager.setTargetHotend(e_temp, 1);
|
|
|
|
TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(bed_temp));
|
|
|
|
break;
|
|
|
|
#endif
|
2020-07-19 21:35:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Go to the preheat screen to show the heating progress
|
|
|
|
GotoScreen(DGUSLCD_SCREEN_PREHEAT);
|
|
|
|
}
|
|
|
|
|
2021-02-27 23:35:32 +00:00
|
|
|
#endif // DGUS_PREHEAT_UI
|
2020-07-19 21:35:15 +00:00
|
|
|
|
2021-02-27 23:35:32 +00:00
|
|
|
#if ENABLED(POWER_LOSS_RECOVERY)
|
2020-07-19 21:35:15 +00:00
|
|
|
|
2021-02-27 23:35:32 +00:00
|
|
|
void DGUSScreenHandler::HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr) {
|
|
|
|
uint16_t value = swap16(*(uint16_t*)val_ptr);
|
|
|
|
if (value) {
|
|
|
|
queue.inject_P(PSTR("M1000"));
|
|
|
|
dgusdisplay.WriteVariable(VP_SD_Print_Filename, filelist.filename(), 32, true);
|
|
|
|
GotoScreen(PLR_SCREEN_RECOVER);
|
2020-07-19 21:35:15 +00:00
|
|
|
}
|
2021-02-27 23:35:32 +00:00
|
|
|
else {
|
|
|
|
recovery.cancel();
|
|
|
|
GotoScreen(PLR_SCREEN_CANCEL);
|
2020-07-19 21:35:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void DGUSScreenHandler::UpdateNewScreen(DGUSLCD_Screens newscreen, bool popup) {
|
|
|
|
DEBUG_ECHOLNPAIR("SetNewScreen: ", newscreen);
|
|
|
|
if (!popup) {
|
|
|
|
memmove(&past_screens[1], &past_screens[0], sizeof(past_screens) - 1);
|
|
|
|
past_screens[0] = current_screen;
|
|
|
|
}
|
|
|
|
current_screen = newscreen;
|
|
|
|
skipVP = 0;
|
|
|
|
ForceCompleteUpdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DGUSScreenHandler::PopToOldScreen() {
|
|
|
|
DEBUG_ECHOLNPAIR("PopToOldScreen s=", past_screens[0]);
|
|
|
|
GotoScreen(past_screens[0], true);
|
|
|
|
memmove(&past_screens[0], &past_screens[1], sizeof(past_screens) - 1);
|
|
|
|
past_screens[sizeof(past_screens) - 1] = DGUSLCD_SCREEN_MAIN;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DGUSScreenHandler::UpdateScreenVPData() {
|
|
|
|
DEBUG_ECHOPAIR(" UpdateScreenVPData Screen: ", current_screen);
|
|
|
|
|
|
|
|
const uint16_t *VPList = DGUSLCD_FindScreenVPMapList(current_screen);
|
|
|
|
if (!VPList) {
|
|
|
|
DEBUG_ECHOLNPAIR(" NO SCREEN FOR: ", current_screen);
|
|
|
|
ScreenComplete = true;
|
2021-02-27 23:35:32 +00:00
|
|
|
return; // nothing to do, likely a bug or boring screen.
|
2020-07-19 21:35:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Round-robin updating of all VPs.
|
|
|
|
VPList += update_ptr;
|
|
|
|
|
|
|
|
bool sent_one = false;
|
|
|
|
do {
|
|
|
|
uint16_t VP = pgm_read_word(VPList);
|
|
|
|
DEBUG_ECHOPAIR(" VP: ", VP);
|
|
|
|
if (!VP) {
|
|
|
|
update_ptr = 0;
|
|
|
|
DEBUG_ECHOLNPGM(" UpdateScreenVPData done");
|
|
|
|
ScreenComplete = true;
|
2021-02-27 23:35:32 +00:00
|
|
|
return; // Screen completed.
|
2020-07-19 21:35:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (VP == skipVP) { skipVP = 0; continue; }
|
|
|
|
|
|
|
|
DGUS_VP_Variable rcpy;
|
|
|
|
if (populate_VPVar(VP, &rcpy)) {
|
2021-02-27 23:35:32 +00:00
|
|
|
uint8_t expected_tx = 6 + rcpy.size; // expected overhead is 6 bytes + payload.
|
2020-07-19 21:35:15 +00:00
|
|
|
// Send the VP to the display, but try to avoid overrunning the Tx Buffer.
|
|
|
|
// But send at least one VP, to avoid getting stalled.
|
|
|
|
if (rcpy.send_to_display_handler && (!sent_one || expected_tx <= dgusdisplay.GetFreeTxBuffer())) {
|
|
|
|
//DEBUG_ECHOPAIR(" calling handler for ", rcpy.VP);
|
|
|
|
sent_one = true;
|
|
|
|
rcpy.send_to_display_handler(rcpy);
|
|
|
|
}
|
|
|
|
else {
|
2021-02-27 23:35:32 +00:00
|
|
|
// auto x=dgusdisplay.GetFreeTxBuffer();
|
2020-07-19 21:35:15 +00:00
|
|
|
//DEBUG_ECHOLNPAIR(" tx almost full: ", x);
|
|
|
|
//DEBUG_ECHOPAIR(" update_ptr ", update_ptr);
|
|
|
|
ScreenComplete = false;
|
2021-02-27 23:35:32 +00:00
|
|
|
return; // please call again!
|
2020-07-19 21:35:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} while (++update_ptr, ++VPList, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DGUSScreenHandler::GotoScreen(DGUSLCD_Screens screen, bool ispopup) {
|
|
|
|
dgusdisplay.RequestScreen(screen);
|
|
|
|
UpdateNewScreen(screen, ispopup);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DGUSDisplay::RequestScreen(DGUSLCD_Screens screen) {
|
|
|
|
DEBUG_ECHOLNPAIR("GotoScreen ", screen);
|
|
|
|
const unsigned char gotoscreen[] = { 0x5A, 0x01, (unsigned char) (screen >> 8U), (unsigned char) (screen & 0xFFU) };
|
|
|
|
WriteVariable(0x84, gotoscreen, sizeof(gotoscreen));
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // HAS_DGUS_LCD
|