MKS H43 controller (#20609)
This commit is contained in:
418
Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSScreenHandler.cpp
Normal file
418
Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSScreenHandler.cpp
Normal file
@@ -0,0 +1,418 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../../../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(DGUS_LCD_UI_HYPRECY)
|
||||
|
||||
#include "../DGUSScreenHandler.h"
|
||||
|
||||
#include "../../../../../MarlinCore.h"
|
||||
#include "../../../../../gcode/queue.h"
|
||||
#include "../../../../../libs/duration_t.h"
|
||||
#include "../../../../../module/settings.h"
|
||||
#include "../../../../../module/temperature.h"
|
||||
#include "../../../../../module/motion.h"
|
||||
#include "../../../../../module/planner.h"
|
||||
#include "../../../../../module/printcounter.h"
|
||||
#include "../../../../../sd/cardreader.h"
|
||||
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
#include "../../../../feature/powerloss.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(SDSUPPORT)
|
||||
|
||||
void DGUSScreenHandler::DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr) {
|
||||
uint16_t touched_nr = (int16_t)swap16(*(uint16_t*)val_ptr) + top_file;
|
||||
if (touched_nr > filelist.count()) return;
|
||||
if (!filelist.seek(touched_nr)) return;
|
||||
|
||||
if (filelist.isDir()) {
|
||||
filelist.changeDir(filelist.filename());
|
||||
top_file = 0;
|
||||
ForceCompleteUpdate();
|
||||
return;
|
||||
}
|
||||
|
||||
#if ENABLED(DGUS_PRINT_FILENAME)
|
||||
// Send print filename
|
||||
dgusdisplay.WriteVariable(VP_SD_Print_Filename, filelist.filename(), VP_SD_FileName_LEN, true);
|
||||
#endif
|
||||
|
||||
// Setup Confirmation screen
|
||||
file_to_print = touched_nr;
|
||||
|
||||
HandleUserConfirmationPopUp(VP_SD_FileSelectConfirm, nullptr, PSTR("Print file"), filelist.filename(), PSTR("from SD Card?"), true, true, false, true);
|
||||
}
|
||||
|
||||
void DGUSScreenHandler::DGUSLCD_SD_StartPrint(DGUS_VP_Variable &var, void *val_ptr) {
|
||||
if (!filelist.seek(file_to_print)) return;
|
||||
ExtUI::printFile(filelist.shortFilename());
|
||||
GotoScreen(DGUSLCD_SCREEN_SDPRINTMANIPULATION);
|
||||
}
|
||||
|
||||
void DGUSScreenHandler::DGUSLCD_SD_ResumePauseAbort(DGUS_VP_Variable &var, void *val_ptr) {
|
||||
|
||||
if (!ExtUI::isPrintingFromMedia()) return; // avoid race condition when user stays in this menu and printer finishes.
|
||||
switch (swap16(*(uint16_t*)val_ptr)) {
|
||||
case 0: { // Resume
|
||||
if (ExtUI::isPrintingFromMediaPaused()) {
|
||||
ExtUI::resumePrint();
|
||||
}
|
||||
} break;
|
||||
|
||||
case 1: // Pause
|
||||
|
||||
GotoScreen(MKSLCD_SCREEN_PAUSE);
|
||||
if (!ExtUI::isPrintingFromMediaPaused()) {
|
||||
ExtUI::pausePrint();
|
||||
//ExtUI::mks_pausePrint();
|
||||
}
|
||||
break;
|
||||
case 2: // Abort
|
||||
HandleUserConfirmationPopUp(VP_SD_AbortPrintConfirmed, nullptr, PSTR("Abort printing"), filelist.filename(), PSTR("?"), true, true, false, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void DGUSScreenHandler::DGUSLCD_SD_SendFilename(DGUS_VP_Variable& var) {
|
||||
uint16_t target_line = (var.VP - VP_SD_FileName0) / VP_SD_FileName_LEN;
|
||||
if (target_line > DGUS_SD_FILESPERSCREEN) return;
|
||||
char tmpfilename[VP_SD_FileName_LEN + 1] = "";
|
||||
var.memadr = (void*)tmpfilename;
|
||||
|
||||
if (filelist.seek(top_file + target_line)) {
|
||||
snprintf_P(tmpfilename, VP_SD_FileName_LEN, PSTR("%s%c"), filelist.filename(), filelist.isDir() ? '/' : 0); // snprintf_P(tmpfilename, VP_SD_FileName_LEN, PSTR("%s"), filelist.filename());
|
||||
}
|
||||
DGUSLCD_SendStringToDisplay(var);
|
||||
}
|
||||
|
||||
void DGUSScreenHandler::SDCardInserted() {
|
||||
top_file = 0;
|
||||
filelist.refresh();
|
||||
auto cs = getCurrentScreen();
|
||||
if (cs == DGUSLCD_SCREEN_MAIN || cs == DGUSLCD_SCREEN_STATUS)
|
||||
GotoScreen(DGUSLCD_SCREEN_SDFILELIST);
|
||||
}
|
||||
|
||||
void DGUSScreenHandler::SDCardRemoved() {
|
||||
if (current_screen == DGUSLCD_SCREEN_SDFILELIST
|
||||
|| (current_screen == DGUSLCD_SCREEN_CONFIRM && (ConfirmVP == VP_SD_AbortPrintConfirmed || ConfirmVP == VP_SD_FileSelectConfirm))
|
||||
|| current_screen == DGUSLCD_SCREEN_SDPRINTMANIPULATION
|
||||
) GotoScreen(DGUSLCD_SCREEN_MAIN);
|
||||
}
|
||||
|
||||
#endif // SDSUPPORT
|
||||
|
||||
void DGUSScreenHandler::ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr) {
|
||||
uint8_t *tmp = (uint8_t*)val_ptr;
|
||||
|
||||
// The keycode in target is coded as <from-frame><to-frame>, so 0x0100A means
|
||||
// from screen 1 (main) to 10 (temperature). DGUSLCD_SCREEN_POPUP is special,
|
||||
// meaning "return to previous screen"
|
||||
DGUSLCD_Screens target = (DGUSLCD_Screens)tmp[1];
|
||||
|
||||
DEBUG_ECHOLNPAIR("\n DEBUG target", target);
|
||||
|
||||
if (target == DGUSLCD_SCREEN_POPUP) {
|
||||
// Special handling for popup is to return to previous menu
|
||||
if (current_screen == DGUSLCD_SCREEN_POPUP && confirm_action_cb) confirm_action_cb();
|
||||
PopToOldScreen();
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateNewScreen(target);
|
||||
|
||||
#ifdef DEBUG_DGUSLCD
|
||||
if (!DGUSLCD_FindScreenVPMapList(target)) DEBUG_ECHOLNPAIR("WARNING: No screen Mapping found for ", target);
|
||||
#endif
|
||||
}
|
||||
|
||||
void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
|
||||
DEBUG_ECHOLNPGM("HandleManualMove");
|
||||
|
||||
int16_t movevalue = swap16(*(uint16_t*)val_ptr);
|
||||
#if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
|
||||
if (movevalue) {
|
||||
const uint16_t choice = *(uint16_t*)var.memadr;
|
||||
movevalue = movevalue < 0 ? -choice : choice;
|
||||
}
|
||||
#endif
|
||||
char axiscode;
|
||||
unsigned int speed = 1500; // FIXME: get default feedrate for manual moves, dont hardcode.
|
||||
|
||||
switch (var.VP) {
|
||||
default: return;
|
||||
|
||||
case VP_MOVE_X:
|
||||
axiscode = 'X';
|
||||
if (!ExtUI::canMove(ExtUI::axis_t::X)) goto cannotmove;
|
||||
break;
|
||||
|
||||
case VP_MOVE_Y:
|
||||
axiscode = 'Y';
|
||||
if (!ExtUI::canMove(ExtUI::axis_t::Y)) goto cannotmove;
|
||||
break;
|
||||
|
||||
case VP_MOVE_Z:
|
||||
axiscode = 'Z';
|
||||
speed = 300; // default to 5mm/s
|
||||
if (!ExtUI::canMove(ExtUI::axis_t::Z)) goto cannotmove;
|
||||
break;
|
||||
|
||||
case VP_HOME_ALL: // only used for homing
|
||||
axiscode = '\0';
|
||||
movevalue = 0; // ignore value sent from display, this VP is _ONLY_ for homing.
|
||||
break;
|
||||
}
|
||||
|
||||
if (!movevalue) {
|
||||
// homing
|
||||
DEBUG_ECHOPAIR(" homing ", axiscode);
|
||||
char buf[6] = "G28 X";
|
||||
buf[4] = axiscode;
|
||||
//DEBUG_ECHOPAIR(" ", buf);
|
||||
queue.enqueue_one_now(buf);
|
||||
//DEBUG_ECHOLNPGM(" ✓");
|
||||
ForceCompleteUpdate();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
// movement
|
||||
DEBUG_ECHOPAIR(" move ", axiscode);
|
||||
bool old_relative_mode = relative_mode;
|
||||
if (!relative_mode) {
|
||||
//DEBUG_ECHOPGM(" G91");
|
||||
queue.enqueue_now_P(PSTR("G91"));
|
||||
//DEBUG_ECHOPGM(" ✓ ");
|
||||
}
|
||||
char buf[32]; // G1 X9999.99 F12345
|
||||
unsigned int backup_speed = MMS_TO_MMM(feedrate_mm_s);
|
||||
char sign[] = "\0";
|
||||
int16_t value = movevalue / 100;
|
||||
if (movevalue < 0) { value = -value; sign[0] = '-'; }
|
||||
int16_t fraction = ABS(movevalue) % 100;
|
||||
snprintf_P(buf, 32, PSTR("G0 %c%s%d.%02d F%d"), axiscode, sign, value, fraction, speed);
|
||||
//DEBUG_ECHOPAIR(" ", buf);
|
||||
queue.enqueue_one_now(buf);
|
||||
//DEBUG_ECHOLNPGM(" ✓ ");
|
||||
if (backup_speed != speed) {
|
||||
snprintf_P(buf, 32, PSTR("G0 F%d"), backup_speed);
|
||||
queue.enqueue_one_now(buf);
|
||||
//DEBUG_ECHOPAIR(" ", buf);
|
||||
}
|
||||
// while (!enqueue_and_echo_command(buf)) idle();
|
||||
//DEBUG_ECHOLNPGM(" ✓ ");
|
||||
if (!old_relative_mode) {
|
||||
//DEBUG_ECHOPGM("G90");
|
||||
queue.enqueue_now_P(PSTR("G90"));
|
||||
//DEBUG_ECHOPGM(" ✓ ");
|
||||
}
|
||||
}
|
||||
|
||||
ForceCompleteUpdate();
|
||||
DEBUG_ECHOLNPGM("manmv done.");
|
||||
return;
|
||||
|
||||
cannotmove:
|
||||
DEBUG_ECHOLNPAIR(" cannot move ", axiscode);
|
||||
return;
|
||||
}
|
||||
|
||||
#if HAS_PID_HEATING
|
||||
void DGUSScreenHandler::HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr) {
|
||||
uint16_t rawvalue = swap16(*(uint16_t*)val_ptr);
|
||||
DEBUG_ECHOLNPAIR("V1:", rawvalue);
|
||||
float value = (float)rawvalue / 10;
|
||||
DEBUG_ECHOLNPAIR("V2:", value);
|
||||
float newvalue = 0;
|
||||
|
||||
switch (var.VP) {
|
||||
default: return;
|
||||
#if HOTENDS >= 1
|
||||
case VP_E0_PID_P: newvalue = value; break;
|
||||
case VP_E0_PID_I: newvalue = scalePID_i(value); break;
|
||||
case VP_E0_PID_D: newvalue = scalePID_d(value); break;
|
||||
#endif
|
||||
#if HOTENDS >= 2
|
||||
case VP_E1_PID_P: newvalue = value; break;
|
||||
case VP_E1_PID_I: newvalue = scalePID_i(value); break;
|
||||
case VP_E1_PID_D: newvalue = scalePID_d(value); break;
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
case VP_BED_PID_P: newvalue = value; break;
|
||||
case VP_BED_PID_I: newvalue = scalePID_i(value); break;
|
||||
case VP_BED_PID_D: newvalue = scalePID_d(value); break;
|
||||
#endif
|
||||
}
|
||||
|
||||
DEBUG_ECHOLNPAIR_F("V3:", newvalue);
|
||||
*(float *)var.memadr = newvalue;
|
||||
|
||||
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
|
||||
}
|
||||
#endif // HAS_PID_HEATING
|
||||
|
||||
#if ENABLED(BABYSTEPPING)
|
||||
void DGUSScreenHandler::HandleLiveAdjustZ(DGUS_VP_Variable &var, void *val_ptr) {
|
||||
DEBUG_ECHOLNPGM("HandleLiveAdjustZ");
|
||||
int16_t flag = swap16(*(uint16_t*)val_ptr),
|
||||
steps = flag ? -20 : 20;
|
||||
ExtUI::smartAdjustAxis_steps(steps, ExtUI::axis_t::Z, true);
|
||||
ForceCompleteUpdate();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
|
||||
|
||||
void DGUSScreenHandler::HandleFilamentOption(DGUS_VP_Variable &var, void *val_ptr) {
|
||||
DEBUG_ECHOLNPGM("HandleFilamentOption");
|
||||
|
||||
uint8_t e_temp = 0;
|
||||
filament_data.heated = false;
|
||||
uint16_t preheat_option = swap16(*(uint16_t*)val_ptr);
|
||||
if (preheat_option <= 8) { // Load filament type
|
||||
filament_data.action = 1;
|
||||
}
|
||||
else if (preheat_option >= 10) { // Unload filament type
|
||||
preheat_option -= 10;
|
||||
filament_data.action = 2;
|
||||
filament_data.purge_length = DGUS_FILAMENT_PURGE_LENGTH;
|
||||
}
|
||||
else { // Cancel filament operation
|
||||
filament_data.action = 0;
|
||||
}
|
||||
|
||||
switch (preheat_option) {
|
||||
case 0: // Load PLA
|
||||
#ifdef PREHEAT_1_TEMP_HOTEND
|
||||
e_temp = PREHEAT_1_TEMP_HOTEND;
|
||||
#endif
|
||||
break;
|
||||
case 1: // Load ABS
|
||||
TERN_(PREHEAT_2_TEMP_HOTEND, e_temp = PREHEAT_2_TEMP_HOTEND);
|
||||
break;
|
||||
case 2: // Load PET
|
||||
#ifdef PREHEAT_3_TEMP_HOTEND
|
||||
e_temp = PREHEAT_3_TEMP_HOTEND;
|
||||
#endif
|
||||
break;
|
||||
case 3: // Load FLEX
|
||||
#ifdef PREHEAT_4_TEMP_HOTEND
|
||||
e_temp = PREHEAT_4_TEMP_HOTEND;
|
||||
#endif
|
||||
break;
|
||||
case 9: // Cool down
|
||||
default:
|
||||
e_temp = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (filament_data.action == 0) { // Go back to utility screen
|
||||
#if HOTENDS >= 1
|
||||
thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E0);
|
||||
#endif
|
||||
#if HOTENDS >= 2
|
||||
thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E1);
|
||||
#endif
|
||||
GotoScreen(DGUSLCD_SCREEN_UTILITY);
|
||||
}
|
||||
else { // Go to the preheat screen to show the heating progress
|
||||
switch (var.VP) {
|
||||
default: return;
|
||||
#if HOTENDS >= 1
|
||||
case VP_E0_FILAMENT_LOAD_UNLOAD:
|
||||
filament_data.extruder = ExtUI::extruder_t::E0;
|
||||
thermalManager.setTargetHotend(e_temp, filament_data.extruder);
|
||||
break;
|
||||
#endif
|
||||
#if HOTENDS >= 2
|
||||
case VP_E1_FILAMENT_LOAD_UNLOAD:
|
||||
filament_data.extruder = ExtUI::extruder_t::E1;
|
||||
thermalManager.setTargetHotend(e_temp, filament_data.extruder);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
GotoScreen(DGUSLCD_SCREEN_FILAMENT_HEATING);
|
||||
}
|
||||
}
|
||||
|
||||
void DGUSScreenHandler::HandleFilamentLoadUnload(DGUS_VP_Variable &var) {
|
||||
DEBUG_ECHOLNPGM("HandleFilamentLoadUnload");
|
||||
if (filament_data.action <= 0) return;
|
||||
|
||||
// If we close to the target temperature, we can start load or unload the filament
|
||||
if (thermalManager.hotEnoughToExtrude(filament_data.extruder) && \
|
||||
thermalManager.targetHotEnoughToExtrude(filament_data.extruder)) {
|
||||
float movevalue = DGUS_FILAMENT_LOAD_LENGTH_PER_TIME;
|
||||
|
||||
if (filament_data.action == 1) { // load filament
|
||||
if (!filament_data.heated) {
|
||||
//GotoScreen(DGUSLCD_SCREEN_FILAMENT_LOADING);
|
||||
filament_data.heated = true;
|
||||
}
|
||||
movevalue = ExtUI::getAxisPosition_mm(filament_data.extruder) + movevalue;
|
||||
}
|
||||
else { // unload filament
|
||||
if (!filament_data.heated) {
|
||||
GotoScreen(DGUSLCD_SCREEN_FILAMENT_UNLOADING);
|
||||
filament_data.heated = true;
|
||||
}
|
||||
// Before unloading extrude to prevent jamming
|
||||
if (filament_data.purge_length >= 0) {
|
||||
movevalue = ExtUI::getAxisPosition_mm(filament_data.extruder) + movevalue;
|
||||
filament_data.purge_length -= movevalue;
|
||||
}
|
||||
else {
|
||||
movevalue = ExtUI::getAxisPosition_mm(filament_data.extruder) - movevalue;
|
||||
}
|
||||
}
|
||||
ExtUI::setAxisPosition_mm(movevalue, filament_data.extruder);
|
||||
}
|
||||
}
|
||||
#endif // DGUS_FILAMENT_LOADUNLOAD
|
||||
|
||||
bool DGUSScreenHandler::loop() {
|
||||
dgusdisplay.loop();
|
||||
|
||||
const millis_t ms = millis();
|
||||
static millis_t next_event_ms = 0;
|
||||
|
||||
if (!IsScreenComplete() || ELAPSED(ms, next_event_ms)) {
|
||||
next_event_ms = ms + DGUS_UPDATE_INTERVAL_MS;
|
||||
UpdateScreenVPData();
|
||||
}
|
||||
|
||||
#if ENABLED(SHOW_BOOTSCREEN)
|
||||
static bool booted = false;
|
||||
|
||||
if (!booted && TERN0(POWER_LOSS_RECOVERY, recovery.valid()))
|
||||
booted = true;
|
||||
|
||||
if (!booted && ELAPSED(ms, TERN(USE_MKS_GREEN_UI, 1000, BOOTSCREEN_TIMEOUT)))
|
||||
booted = true;
|
||||
#endif
|
||||
return IsScreenComplete();
|
||||
}
|
||||
|
||||
#endif // DGUS_LCD_UI_HYPRECY
|
||||
240
Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSScreenHandler.h
Normal file
240
Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSScreenHandler.h
Normal file
@@ -0,0 +1,240 @@
|
||||
/**
|
||||
* 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 "../DGUSVPVariable.h"
|
||||
#include "../DGUSDisplayDef.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);
|
||||
#if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
|
||||
// Hook for manual move option
|
||||
static void HandleManualMoveOption(DGUS_VP_Variable &var, void *val_ptr);
|
||||
#endif
|
||||
|
||||
// Hook for manual move.
|
||||
static void HandleManualMove(DGUS_VP_Variable &var, void *val_ptr);
|
||||
// Hook for manual extrude.
|
||||
static void HandleManualExtrude(DGUS_VP_Variable &var, void *val_ptr);
|
||||
// Hook for motor lock and unlook
|
||||
static void HandleMotorLockUnlock(DGUS_VP_Variable &var, void *val_ptr);
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
// Hook for power loss recovery.
|
||||
static void HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr);
|
||||
#endif
|
||||
// Hook for settings
|
||||
static void HandleSettings(DGUS_VP_Variable &var, void *val_ptr);
|
||||
static void HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr);
|
||||
static void HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr);
|
||||
|
||||
#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 HandleProbeOffsetZChanged(DGUS_VP_Variable &var, void *val_ptr);
|
||||
#endif
|
||||
#if ENABLED(BABYSTEPPING)
|
||||
// Hook for live z adjust action
|
||||
static void HandleLiveAdjustZ(DGUS_VP_Variable &var, void *val_ptr);
|
||||
#endif
|
||||
#if HAS_FAN
|
||||
// Hook for fan control
|
||||
static void HandleFanControl(DGUS_VP_Variable &var, void *val_ptr);
|
||||
#endif
|
||||
// Hook for heater control
|
||||
static void HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr);
|
||||
#if ENABLED(DGUS_PREHEAT_UI)
|
||||
// Hook for preheat
|
||||
static void HandlePreheat(DGUS_VP_Variable &var, void *val_ptr);
|
||||
#endif
|
||||
#if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
|
||||
// Hook for filament load and unload filament option
|
||||
static void HandleFilamentOption(DGUS_VP_Variable &var, void *val_ptr);
|
||||
// Hook for filament load and unload
|
||||
static void HandleFilamentLoadUnload(DGUS_VP_Variable &var);
|
||||
#endif
|
||||
|
||||
#if ENABLED(SDSUPPORT)
|
||||
// Callback for VP "Display wants to change screen when there is a SD card"
|
||||
static void ScreenChangeHookIfSD(DGUS_VP_Variable &var, void *val_ptr);
|
||||
// Scroll buttons on the file listing screen.
|
||||
static void DGUSLCD_SD_ScrollFilelist(DGUS_VP_Variable &var, void *val_ptr);
|
||||
// File touched.
|
||||
static void DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr);
|
||||
// start print after confirmation received.
|
||||
static void DGUSLCD_SD_StartPrint(DGUS_VP_Variable &var, void *val_ptr);
|
||||
// User hit the pause, resume or abort button.
|
||||
static void DGUSLCD_SD_ResumePauseAbort(DGUS_VP_Variable &var, void *val_ptr);
|
||||
// User confirmed the abort action
|
||||
static void DGUSLCD_SD_ReallyAbort(DGUS_VP_Variable &var, void *val_ptr);
|
||||
// User hit the tune button
|
||||
static void DGUSLCD_SD_PrintTune(DGUS_VP_Variable &var, void *val_ptr);
|
||||
// Send a single filename to the display.
|
||||
static void DGUSLCD_SD_SendFilename(DGUS_VP_Variable &var);
|
||||
// Marlin informed us that a new SD has been inserted.
|
||||
static void SDCardInserted();
|
||||
// Marlin informed us that the SD Card has been removed().
|
||||
static void SDCardRemoved();
|
||||
// Marlin informed us about a bad SD Card.
|
||||
static void SDCardError();
|
||||
#endif
|
||||
|
||||
// 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 popup=false);
|
||||
|
||||
// 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 ispopup = false);
|
||||
|
||||
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
|
||||
|
||||
// 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 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 inline void SetupConfirmAction( void (*f)()) { confirm_action_cb = f; }
|
||||
|
||||
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").
|
||||
|
||||
#if ENABLED(SDSUPPORT)
|
||||
static int16_t top_file; //< file on top of file chooser
|
||||
static int16_t file_to_print; //< touched file to be confirmed
|
||||
#endif
|
||||
|
||||
static void (*confirm_action_cb)();
|
||||
};
|
||||
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
#define PLR_SCREEN_RECOVER DGUSLCD_SCREEN_SDPRINTMANIPULATION
|
||||
#define PLR_SCREEN_CANCEL DGUSLCD_SCREEN_STATUS
|
||||
#endif
|
||||
Reference in New Issue
Block a user