lcd folder

This commit is contained in:
Malte Reents 2024-05-19 11:46:28 +02:00
parent bb939520ee
commit 402d623376
457 changed files with 78994 additions and 0 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,107 @@
/**
* 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
/**
* Hitachi HD44780 display defines and headers
*/
#include "../../inc/MarlinConfig.h"
#if ENABLED(LCD_I2C_TYPE_PCF8575)
// NOTE: These are register-mapped pins on the PCF8575 controller, not Arduino pins.
#define LCD_I2C_PIN_BL 3
#define LCD_I2C_PIN_EN 2
#define LCD_I2C_PIN_RW 1
#define LCD_I2C_PIN_RS 0
#define LCD_I2C_PIN_D4 4
#define LCD_I2C_PIN_D5 5
#define LCD_I2C_PIN_D6 6
#define LCD_I2C_PIN_D7 7
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#define LCD_CLASS LiquidCrystal_I2C
#elif ENABLED(LCD_I2C_TYPE_MCP23017)
// For the LED indicators (which may be mapped to different events in update_indicators())
#define LCD_HAS_STATUS_INDICATORS
#define LED_A 0x04 //100
#define LED_B 0x02 //010
#define LED_C 0x01 //001
#include <Wire.h>
#include <LiquidTWI2.h>
#define LCD_CLASS LiquidTWI2
#elif ENABLED(LCD_I2C_TYPE_MCP23008)
#include <Wire.h>
#include <LiquidTWI2.h>
#define LCD_CLASS LiquidTWI2
#elif ENABLED(LCD_I2C_TYPE_PCA8574)
#include <LiquidCrystal_I2C.h>
#define LCD_CLASS LiquidCrystal_I2C
#elif ENABLED(SR_LCD_2W_NL)
// 2 wire Non-latching LCD SR from:
// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection
#include <LCD.h>
#include <LiquidCrystal_SR.h>
#define LCD_CLASS LiquidCrystal_SR
#elif ENABLED(SR_LCD_3W_NL)
// NewLiquidCrystal didn't work, so this uses
// https://github.com/mikeshub/SailfishLCD
#include <SailfishLCD.h>
#define LCD_CLASS LiquidCrystalSerial
#elif ENABLED(LCM1602)
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#define LCD_CLASS LiquidCrystal_I2C
#elif ENABLED(YHCB2004)
#include <LiquidCrystal_AIP31068_SPI.h>
#define LCD_CLASS LiquidCrystal_AIP31068_SPI
#else
// Standard directly connected LCD implementations
#include <LiquidCrystal.h>
#define LCD_CLASS LiquidCrystal
#endif
#include "../fontutils.h"
#include "../lcdprint.h"

View File

@ -0,0 +1,258 @@
/**
* 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/>.
*
*/
/**
* lcd/extui/anycubic_chiron/FileNavigator.cpp
*
* Extensible_UI implementation for Anycubic Chiron
* Written By Nick Wells, 2020 [https://github.com/SwiftNick]
* (not affiliated with Anycubic, Ltd.)
*
* The AC panel wants files in block of 4 and can only display a flat list
* This library allows full folder traversal or flat file display and supports both standerd and new style panels.
*
* ## Old Style TFT panel
* Supported chars {}[]-+=_"$%^&*()~<>|
* Max display length 22 chars
* Max path len 29 chars
* (DOS 8.3 filepath max 29chars)
* (long filepath Max 22)
*
* ## New TFT Panel Format file display format
* Supported chars {}[]-+=_!"$%^&*()~<>\|
* Max display length 26 chars
* Max path len 29 chars
* (DOS 8.3 filepath must end '.GCO')
* (long filepath must end '.gcode')
*
*/
#include "../../../inc/MarlinConfigPre.h"
#if ENABLED(ANYCUBIC_LCD_CHIRON)
#include "FileNavigator.h"
#include "chiron_tft.h"
using namespace ExtUI;
#define DEBUG_OUT ACDEBUG(AC_FILE)
#include "../../../core/debug_out.h"
namespace Anycubic {
FileNavigator filenavigator;
FileList FileNavigator::filelist; // Instance of the Marlin file API
uint16_t FileNavigator::lastpanelindex;
uint16_t FileNavigator::currentindex; // override the panel request
uint8_t FileNavigator::currentfolderdepth;
uint16_t FileNavigator::currentfolderindex[MAX_FOLDER_DEPTH]; // track folder pos for iteration
char FileNavigator::currentfoldername[MAX_PATH_LEN + 1]; // Current folder path
FileNavigator::FileNavigator() { reset(); }
void FileNavigator::reset() {
DEBUG_ECHOLNPGM("reset()");
currentfoldername[0] = '\0';
currentfolderdepth = 0;
currentindex = 0;
lastpanelindex = 0;
ZERO(currentfolderindex);
// Start at root folder
while (!filelist.isAtRootDir()) filelist.upDir();
refresh();
}
void FileNavigator::refresh() { filelist.refresh(); }
void FileNavigator::changeDIR(const char *folder) {
if (currentfolderdepth >= MAX_FOLDER_DEPTH) return; // limit the folder depth
DEBUG_ECHOLNPGM("FD:" , folderdepth, " FP:",currentindex, " currentfolder:", currentfoldername, " enter:", folder);
currentfolderindex[currentfolderdepth] = currentindex;
strcat(currentfoldername, folder);
strcat(currentfoldername, "/");
filelist.changeDir(folder);
currentfolderdepth++;
currentindex = 0;
}
void FileNavigator::upDIR() {
DEBUG_ECHOLNPGM("upDIR() from D:", currentfolderdepth, " N:", currentfoldername);
if (!filelist.isAtRootDir()) {
filelist.upDir();
currentfolderdepth--;
currentindex = currentfolderindex[currentfolderdepth]; // restore last position in the folder
filelist.seek(currentindex); // restore file information
}
// Remove the child folder from the stored path
if (currentfolderdepth == 0)
currentfoldername[0] = '\0';
else {
char * const pos = strchr(currentfoldername, '/');
*(pos + 1) = '\0';
}
}
void FileNavigator::skiptofileindex(uint16_t skip) {
if (skip == 0) return;
while (skip > 0) {
if (filelist.seek(currentindex)) {
DEBUG_ECHOLNPGM("CI:", currentindex, " FD:", currentfolderdepth, " N:", skip, " ", filelist.longFilename());
if (!filelist.isDir()) {
skip--;
currentindex++;
}
else
changeDIR(filelist.shortFilename());
} // valid file
if (currentindex == filelist.count()) {
if (currentfolderdepth > 0) {
upDIR();
currentindex++;
}
else break; // end of root folder
} // end of folder
} // files needed
// No more files available.
}
#if ENABLED(AC_SD_FOLDER_VIEW) // SD Folder navigation
void FileNavigator::getFiles(uint16_t index, panel_type_t paneltype, uint8_t filesneeded) {
if (index == 0) currentindex = 0;
// Each time we change folder we reset the file index to 0 and keep track
// of the current position, since the TFT panel isn't aware of folder trees.
if (index > 0) {
--currentindex; // go back a file to take account of the .. we added to the root.
if (index > lastpanelindex)
currentindex += filesneeded;
else
currentindex = currentindex < 4 ? 0 : currentindex - filesneeded;
}
lastpanelindex = index;
DEBUG_ECHOLNPGM("index=", index, " currentindex=", currentindex);
if (currentindex == 0 && currentfolderdepth > 0) { // Add a link to go up a folder
// The new panel ignores entries that don't end in .GCO or .gcode so add and pad them.
if (paneltype <= AC_panel_new) {
TFTSer.println("<<.GCO");
Chiron.SendtoTFTLN(F(".. .gcode"));
}
else {
TFTSer.println("<<");
TFTSer.println("..");
}
filesneeded--;
}
for (uint16_t seek = currentindex; seek < currentindex + filesneeded; seek++) {
if (filelist.seek(seek)) {
sendFile(paneltype);
DEBUG_ECHOLNPGM("-", seek, " '", filelist.longFilename(), "' '", currentfoldername, "", filelist.shortFilename(), "'");
}
}
}
void FileNavigator::sendFile(panel_type_t paneltype) {
if (filelist.isDir()) {
// Add mandatory tags for new panel otherwise lines are ignored.
if (paneltype <= AC_panel_new) {
TFTSer.print(filelist.shortFilename());
TFTSer.println(".GCO");
TFTSer.print(filelist.shortFilename());
TFTSer.write('/');
// Make sure we fill all 29 chars of the display line to clear the text buffer otherwise the last line is still visible
for (int8_t i = strlen(filelist.shortFilename()); i < 19; i++)
TFTSer.write(' ');
TFTSer.println(".gcode");
}
else {
TFTSer.println(filelist.shortFilename());
TFTSer.print(filelist.shortFilename());
TFTSer.write('/');
TFTSer.println();
}
}
else { // Not DIR
TFTSer.write('/');
if (currentfolderdepth > 0) TFTSer.print(currentfoldername);
TFTSer.println(filelist.shortFilename());
TFTSer.print(filelist.longFilename());
// Make sure we fill all 29 chars of the display line to clear the text buffer otherwise the last line is still visible
if (paneltype == AC_panel_new)
for (int8_t i = strlen(filelist.longFilename()); i < 26; i++)
TFTSer.write(' ');
TFTSer.println();
}
} // AC_SD_FOLDER_VIEW
#else // Flat file list
void FileNavigator::getFiles(uint16_t index, panel_type_t paneltype, uint8_t filesneeded) {
DEBUG_ECHOLNPGM("getFiles() I:", index," L:", lastpanelindex);
// if we're searching backwards, jump back to start and search forward
if (index < lastpanelindex) {
reset();
skiptofileindex(index);
}
lastpanelindex = index;
while (filesneeded > 0) {
if (filelist.seek(currentindex)) {
if (!filelist.isDir()) {
sendFile(paneltype);
filesneeded--;
currentindex++;
}
else
changeDIR(filelist.shortFilename());
} // valid file
if (currentindex == filelist.count()) {
if (currentfolderdepth > 0) {
upDIR();
currentindex++;
}
else break; // end of root folder
} // end of folder
} // files needed
// No more files available.
}
void FileNavigator::sendFile(panel_type_t paneltype) {
TFTSer.write('/');
if (currentfolderdepth > 0) TFTSer.print(currentfoldername);
TFTSer.println(filelist.shortFilename());
if (currentfolderdepth > 0) TFTSer.print(currentfoldername);
TFTSer.println(filelist.longFilename());
DEBUG_ECHOLNPGM("/", currentfoldername, "", filelist.shortFilename(), " ", filelist.longFilename());
}
#endif // Flat file list
} // Anycubic namespace
#endif // ANYCUBIC_LCD_CHIRON

View File

@ -0,0 +1,61 @@
/**
* 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
/**
* lcd/extui/anycubic_chiron/FileNavigator.h
*
* Extensible_UI implementation for Anycubic Chiron
* Written By Nick Wells, 2020 [https://github.com/SwiftNick]
* (not affiliated with Anycubic, Ltd.)
*/
#include "chiron_tft_defs.h"
#include "../ui_api.h"
using namespace ExtUI;
namespace Anycubic {
class FileNavigator {
public:
FileNavigator();
static void reset();
static void getFiles(uint16_t, panel_type_t, uint8_t filesneeded=4);
static void upDIR();
static void changeDIR(const char *);
static void sendFile(panel_type_t);
static void refresh();
static void skiptofileindex(uint16_t);
static FileList filelist;
private:
static uint16_t lastpanelindex;
static uint16_t currentindex;
static uint8_t currentfolderdepth;
static uint16_t currentfolderindex[MAX_FOLDER_DEPTH];
static char currentfoldername[MAX_PATH_LEN + 1];
};
extern FileNavigator filenavigator;
}

View File

@ -0,0 +1,61 @@
/**
* 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/>.
*
*/
/**
* lcd/extui/anycubic_chiron/Tunes.cpp
*
* Extensible_UI implementation for Anycubic Chiron
* Written By Nick Wells, 2020 [https://github.com/SwiftNick]
* (not affiliated with Anycubic, Ltd.)
*/
/***********************************************************************
* A Utility to play tunes using the buzzer in the printer controller. *
* See Tunes.h for note and tune definitions. *
***********************************************************************/
#include "../../../inc/MarlinConfigPre.h"
// TODO: Use Marlin's built-in tone player instead.
#if ENABLED(ANYCUBIC_LCD_CHIRON)
#include "Tunes.h"
#include "../ui_api.h"
namespace Anycubic {
void PlayTune(uint8_t beeperPin, const uint16_t *tune, uint8_t speed=1) {
uint8_t pos = 1;
const uint16_t wholenotelen = tune[0] / speed;
do {
const uint16_t freq = tune[pos], notelen = wholenotelen / tune[pos + 1];
::tone(beeperPin, freq, notelen);
ExtUI::delay_ms(notelen);
pos += 2;
if (pos >= MAX_TUNE_LENGTH) break;
} while (tune[pos] != n_END);
}
}
#endif // ANYCUBIC_LCD_CHIRON

View File

@ -0,0 +1,224 @@
/**
* 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
/**
* lcd/extui/anycubic_chiron/Tunes.h
*
* Extensible_UI implementation for Anycubic Chiron
* Written By Nick Wells, 2020 [https://github.com/SwiftNick]
* (not affiliated with Anycubic, Ltd.)
*/
/**************************************************************************
* Notes definition from https://pages.mtu.edu/~suits/NoteFreqCalcs.html *
* *
* The format of a tune is: *
* {<whole note time>,<note1>,<length1>, <note2>,<length2>, ... <END>} *
* *
* 1) The first value is the length of a whole note in milliseconds *
* 2) Then a sequence of pitch and duration pairs *
* 3) Finally the END marker so your tunes can be any length up to *
* MAX_TUNE_LEN *
*************************************************************************/
#include <stdint.h>
#define MAX_TUNE_LENGTH 128
// Special notes!
#define n_P 0 // silence or pause
#define n_END 10000 // end of tune marker
// Note duration divisors
#define l_T1 1
#define l_T2 2
#define l_T3 3
#define l_T4 4
#define l_T8 8
#define l_T16 16
// Note Frequency
#define n_C0 16
#define n_CS0 17
#define n_D0 18
#define n_DS0 19
#define n_E0 21
#define n_F0 22
#define n_FS0 23
#define n_G0 25
#define n_GS0 26
#define n_A0 28
#define n_AS0 29
#define n_B0 31
#define n_C1 33
#define n_CS1 35
#define n_D1 37
#define n_DS1 39
#define n_E1 41
#define n_F1 44
#define n_FS1 46
#define n_G1 49
#define n_GS1 52
#define n_A1 55
#define n_AS1 58
#define n_B1 62
#define n_C2 65
#define n_CS2 69
#define n_D2 73
#define n_DS2 78
#define n_E2 82
#define n_F2 87
#define n_FS2 93
#define n_G2 98
#define n_GS2 104
#define n_A2 110
#define n_AS2 117
#define n_B2 123
#define n_C3 131
#define n_CS3 139
#define n_D3 147
#define n_DS3 156
#define n_E3 165
#define n_F3 175
#define n_FS3 185
#define n_G3 196
#define n_GS3 208
#define n_A3 220
#define n_AS3 233
#define n_B3 247
#define n_C4 262
#define n_CS4 277
#define n_D4 294
#define n_DS4 311
#define n_E4 330
#define n_F4 349
#define n_FS4 370
#define n_G4 392
#define n_GS4 415
#define n_A4 440
#define n_AS4 466
#define n_B4 494
#define n_C5 523
#define n_CS5 554
#define n_D5 587
#define n_DS5 622
#define n_E5 659
#define n_F5 698
#define n_FS5 740
#define n_G5 784
#define n_GS5 831
#define n_A5 880
#define n_AS5 932
#define n_B5 988
#define n_C6 1047
#define n_CS6 1109
#define n_D6 1175
#define n_DS6 1245
#define n_E6 1319
#define n_F6 1397
#define n_FS6 1480
#define n_G6 1568
#define n_GS6 1661
#define n_A6 1760
#define n_AS6 1865
#define n_B6 1976
#define n_C7 2093
#define n_CS7 2217
#define n_D7 2349
#define n_DS7 2489
#define n_E7 2637
#define n_F7 2794
#define n_FS7 2960
#define n_G7 3136
#define n_GS7 3322
#define n_A7 3520
#define n_AS7 3729
#define n_B7 3951
#define n_C8 4186
#define n_CS8 4435
#define n_D8 4699
#define n_DS8 4978
#define n_E8 5274
#define n_F8 5587
#define n_FS8 5920
#define n_G8 6272
#define n_GS8 6645
#define n_A8 7040
#define n_AS8 7459
#define n_B8 7902
namespace Anycubic {
void PlayTune(uint8_t beeperPin, const uint16_t *tune, uint8_t speed);
// Only uncomment the tunes you are using to save memory
// This will help you write tunes!
// https://www.apronus.com/music/flashpiano.htm
const uint16_t SOS[] = {
250,
n_G6,l_T3, n_P,l_T3, n_G6,l_T3, n_P,l_T3, n_G6,l_T3, n_P,l_T1,
n_G6,l_T1, n_P,l_T3, n_G6,l_T1, n_P,l_T3, n_G6,l_T1, n_P,l_T1,
n_G6,l_T3, n_P,l_T3, n_G6,l_T3, n_P,l_T3, n_G6,l_T3, n_P,l_T1,
n_END
};
const uint16_t BeepBeep[] = {
500,
n_C7,l_T8, n_P,l_T16, n_C7,l_T8, n_P,l_T8,
n_END
};
const uint16_t BeepBeepBeeep[] = {
1000,
n_G7,l_T4, n_P,l_T16, n_G7,l_T4, n_P,l_T8, n_G7,l_T2,
n_END
};
const uint16_t Anycubic_PowerOn[] = {
1000,
n_F7,l_T8, n_P,l_T8, n_C7,l_T8, n_P,l_T8, n_D7,l_T8, n_P,l_T8,
n_E7,l_T8, n_P,l_T8, n_D7,l_T4, n_P,l_T4, n_G7,l_T4, n_P,l_T4,
n_A7,l_T2, n_P,l_T1,
n_END
};
const uint16_t GB_PowerOn[] = {
500,
n_C6,l_T4, n_P,l_T16, n_C7,l_T2, n_P,l_T8,
n_END
};
const uint16_t Heater_Timedout[] = {
1000,
n_C6,l_T1,
n_END
};
const uint16_t FilamentOut[] = {
1000,
n_AS7,l_T4, n_P,l_T16, n_FS7,l_T2,
n_END
};
}

View File

@ -0,0 +1,137 @@
/**
* 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/>.
*
*/
/**
* lcd/extui/anycubic_chiron/chiron_extui.cpp
*
* Anycubic Chiron TFT support for Marlin
*/
#include "../../../inc/MarlinConfigPre.h"
#if ENABLED(ANYCUBIC_LCD_CHIRON)
#include "../ui_api.h"
#include "chiron_tft.h"
using namespace Anycubic;
namespace ExtUI {
void onStartup() { Chiron.Startup(); }
void onIdle() { Chiron.IdleLoop(); }
void onPrinterKilled(FSTR_P const error, FSTR_P const component) {
Chiron.PrinterKilled(error, component);
}
void onMediaInserted() { Chiron.MediaEvent(AC_media_inserted); }
void onMediaError() { Chiron.MediaEvent(AC_media_error); }
void onMediaRemoved() { Chiron.MediaEvent(AC_media_removed); }
void onPlayTone(const uint16_t frequency, const uint16_t duration) {
#if ENABLED(SPEAKER)
::tone(BEEPER_PIN, frequency, duration);
#endif
}
void onPrintTimerStarted() { Chiron.TimerEvent(AC_timer_started); }
void onPrintTimerPaused() { Chiron.TimerEvent(AC_timer_paused); }
void onPrintTimerStopped() { Chiron.TimerEvent(AC_timer_stopped); }
void onPrintDone() {}
void onFilamentRunout(const extruder_t) { Chiron.FilamentRunout(); }
void onUserConfirmRequired(const char * const msg) { Chiron.ConfirmationRequest(msg); }
void onStatusChanged(const char * const msg) { Chiron.StatusChange(msg); }
void onHomingStart() {}
void onHomingDone() {}
void onFactoryReset() {}
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) <= 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) <= eeprom_data_size);
// memcpy(&myDataStruct, buff, sizeof(myDataStruct));
}
void onPostprocessSettings() {
// Called after loading or resetting stored settings
}
void onSettingsStored(bool success) {
// Called after the entire EEPROM has been written,
// whether successful or not.
}
void onSettingsLoaded(bool success) {
// Called after the entire EEPROM has been read,
// whether successful or not.
}
#if HAS_MESH
void onLevelingStart() {}
void onLevelingDone() {}
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) {
// Called when any mesh points are updated
//SERIAL_ECHOLNPGM("onMeshUpdate() x:", xpos, " y:", ypos, " z:", zval);
}
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const probe_state_t state) {
// Called to indicate a special condition
//SERIAL_ECHOLNPGM("onMeshUpdate() x:", xpos, " y:", ypos, " state:", state);
}
#endif
#if ENABLED(POWER_LOSS_RECOVERY)
// Called on resume from power-loss
void onPowerLossResume() { Chiron.PowerLossRecovery(); }
#endif
#if HAS_PID_HEATING
void onPidTuning(const result_t rst) {
// Called for temperature PID tuning result
}
#endif
void onSteppersDisabled() {}
void onSteppersEnabled() {}
}
#endif // ANYCUBIC_LCD_CHIRON

View File

@ -0,0 +1,985 @@
/**
* 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/>.
*
*/
/**
* lcd/extui/anycubic_chiron/chiron_tft.cpp
*
* Extensible_UI implementation for Anycubic Chiron
* Written By Nick Wells, 2020 [https://github.com/SwiftNick]
* (not affiliated with Anycubic, Ltd.)
*/
#include "../../../inc/MarlinConfigPre.h"
#if ENABLED(ANYCUBIC_LCD_CHIRON)
#include "chiron_tft.h"
#include "Tunes.h"
#include "FileNavigator.h"
#include "../../../gcode/queue.h"
#include "../../../module/stepper.h"
#include "../../../sd/cardreader.h"
#include "../../../libs/numtostr.h"
#include "../../../MarlinCore.h"
namespace Anycubic {
ChironTFT Chiron;
#if AUTO_DETECT_CHIRON_TFT
panel_type_t ChironTFT::panel_type = AC_panel_unknown;
#endif
last_error_t ChironTFT::last_error;
printer_state_t ChironTFT::printer_state;
paused_state_t ChironTFT::pause_state;
heater_state_t ChironTFT::hotend_state;
heater_state_t ChironTFT::hotbed_state;
xy_uint8_t ChironTFT::selectedmeshpoint;
char ChironTFT::selectedfile[MAX_PATH_LEN + 1];
char ChironTFT::panel_command[MAX_CMND_LEN + 1];
uint8_t ChironTFT::command_len;
float ChironTFT::live_Zoffset;
file_menu_t ChironTFT::file_menu;
void ChironTFT::Startup() {
selectedfile[0] = '\0';
panel_command[0] = '\0';
command_len = 0;
last_error = AC_error_none;
printer_state = AC_printer_idle;
pause_state = AC_paused_idle;
hotend_state = AC_heater_off;
hotbed_state = AC_heater_off;
live_Zoffset = 0.0;
file_menu = AC_menu_file;
// Setup pins for powerloss detection
// Two IO pins are connected on the Trigorilla Board
// On a power interruption the OUTAGECON_PIN goes low.
#if ENABLED(POWER_LOSS_RECOVERY)
OUT_WRITE(OUTAGECON_PIN, HIGH);
#endif
// Filament runout is handled by Marlin settings in Configuration.h
// opt_set FIL_RUNOUT_STATE HIGH // Pin state indicating that filament is NOT present.
// opt_enable FIL_RUNOUT_PULLUP
TFTSer.begin(115200);
// Wait for the TFT panel to initialize and finish the animation
safe_delay(1000);
// There are different panels for the Chiron with slightly different commands
// So we need to know what we are working with.
// Panel type can be defined otherwise detect it automatically
switch (panel_type) {
case AC_panel_new:
SERIAL_ECHOLNF(AC_msg_new_panel_set);
break;
case AC_panel_standard:
SERIAL_ECHOLNF(AC_msg_old_panel_set);
break;
default:
SERIAL_ECHOLNF(AC_msg_auto_panel_detection);
DetectPanelType();
break;
}
// Signal Board has reset
SendtoTFTLN(AC_msg_main_board_has_reset);
// Enable leveling and Disable end stops during print
// as Z home places nozzle above the bed so we need to allow it past the end stops
injectCommands(AC_cmnd_enable_leveling);
// Startup tunes are defined in Tunes.h
PlayTune(BEEPER_PIN, TERN(AC_DEFAULT_STARTUP_TUNE, Anycubic_PowerOn, GB_PowerOn), 1);
#if ACDEBUGLEVEL
SERIAL_ECHOLNPGM("AC Debug Level ", ACDEBUGLEVEL);
#endif
SendtoTFTLN(AC_msg_ready);
}
void ChironTFT::DetectPanelType() {
#if AUTO_DETECT_CHIRON_TFT
// Send a query to the TFT
SendtoTFTLN(AC_Test_for_OldPanel); // The panel will respond with 'SXY 480 320'
SendtoTFTLN(AC_Test_for_NewPanel); // the panel will respond with '[0]=0 ' to '[19]=0 '
#endif
}
void ChironTFT::IdleLoop() {
if (ReadTFTCommand()) {
ProcessPanelRequest();
command_len = 0;
}
CheckHeaters();
}
void ChironTFT::PrinterKilled(FSTR_P const error, FSTR_P const component) {
SendtoTFTLN(AC_msg_kill_lcd);
#if ACDEBUG(AC_MARLIN)
SERIAL_ECHOLNPGM("PrinterKilled()\nerror: ", error , "\ncomponent: ", component);
#endif
}
void ChironTFT::MediaEvent(media_event_t event) {
#if ACDEBUG(AC_MARLIN)
SERIAL_ECHOLNPGM("ProcessMediaStatus() ", event);
#endif
switch (event) {
case AC_media_inserted:
SendtoTFTLN(AC_msg_sd_card_inserted);
break;
case AC_media_removed:
SendtoTFTLN(AC_msg_sd_card_removed);
break;
case AC_media_error:
last_error = AC_error_noSD;
SendtoTFTLN(AC_msg_no_sd_card);
break;
}
}
void ChironTFT::TimerEvent(timer_event_t event) {
#if ACDEBUG(AC_MARLIN)
SERIAL_ECHOLNPGM("TimerEvent() ", event);
SERIAL_ECHOLNPGM("Printer State: ", printer_state);
#endif
switch (event) {
case AC_timer_started: {
live_Zoffset = 0.0; // reset print offset
setSoftEndstopState(false); // disable endstops to print
printer_state = AC_printer_printing;
SendtoTFTLN(AC_msg_print_from_sd_card);
} break;
case AC_timer_paused: {
printer_state = AC_printer_paused;
pause_state = AC_paused_idle;
SendtoTFTLN(AC_msg_paused);
} break;
case AC_timer_stopped: {
if (printer_state != AC_printer_idle) {
printer_state = AC_printer_stopping;
SendtoTFTLN(AC_msg_print_complete);
}
setSoftEndstopState(true); // enable endstops
} break;
}
}
void ChironTFT::FilamentRunout() {
#if ACDEBUG(AC_MARLIN)
SERIAL_ECHOLNPGM("FilamentRunout() printer_state ", printer_state);
#endif
// 1 Signal filament out
last_error = AC_error_filament_runout;
SendtoTFTLN(isPrintingFromMedia() ? AC_msg_filament_out_alert : AC_msg_filament_out_block);
PlayTune(BEEPER_PIN, FilamentOut, 1);
}
void ChironTFT::ConfirmationRequest(const char * const msg) {
// M108 continue
#if ACDEBUG(AC_MARLIN)
SERIAL_ECHOLNPGM("ConfirmationRequest() ", msg, " printer_state:", printer_state);
#endif
switch (printer_state) {
case AC_printer_pausing: {
if (strcmp_P(msg, MARLIN_msg_print_paused) == 0 || strcmp_P(msg, MARLIN_msg_nozzle_parked) == 0) {
SendtoTFTLN(AC_msg_paused); // enable continue button
printer_state = AC_printer_paused;
}
} break;
case AC_printer_resuming_from_power_outage:
case AC_printer_printing:
case AC_printer_paused: {
// Heater timeout, send acknowledgement
if (strcmp_P(msg, MARLIN_msg_heater_timeout) == 0) {
pause_state = AC_paused_heater_timed_out;
SendtoTFTLN(AC_msg_paused); // enable continue button
PlayTune(BEEPER_PIN,Heater_Timedout,1);
}
// Reheat finished, send acknowledgement
else if (strcmp_P(msg, MARLIN_msg_reheat_done) == 0) {
pause_state = AC_paused_idle;
SendtoTFTLN(AC_msg_paused); // enable continue button
}
// Filament Purging, send acknowledgement enter run mode
else if (strcmp_P(msg, MARLIN_msg_filament_purging) == 0) {
pause_state = AC_paused_purging_filament;
SendtoTFTLN(AC_msg_paused); // enable continue button
}
} break;
default:
break;
}
}
void ChironTFT::StatusChange(const char * const msg) {
#if ACDEBUG(AC_MARLIN)
SERIAL_ECHOLNPGM("StatusChange() ", msg);
SERIAL_ECHOLNPGM("printer_state:", printer_state);
#endif
bool msg_matched = false;
// The only way to get printer status is to parse messages
// Use the state to minimise the work we do here.
switch (printer_state) {
case AC_printer_probing: {
// If probing completes ok save the mesh and park
// Ignore the custom machine name
if (strcmp_P(msg + strlen(MACHINE_NAME), MARLIN_msg_ready) == 0) {
injectCommands(F("M500\nG27"));
SendtoTFTLN(AC_msg_probing_complete);
printer_state = AC_printer_idle;
msg_matched = true;
}
// If probing fails don't save the mesh raise the probe above the bad point
if (strcmp_P(msg, MARLIN_msg_probing_failed) == 0) {
PlayTune(BEEPER_PIN, BeepBeepBeeep, 1);
injectCommands(F("G1 Z50 F500"));
SendtoTFTLN(AC_msg_probing_complete);
printer_state = AC_printer_idle;
msg_matched = true;
}
} break;
case AC_printer_printing: {
if (strcmp_P(msg, MARLIN_msg_reheating) == 0) {
SendtoTFTLN(AC_msg_paused); // enable continue button
msg_matched = true;
}
} break;
case AC_printer_pausing: {
if (strcmp_P(msg, MARLIN_msg_print_paused) == 0) {
SendtoTFTLN(AC_msg_paused);
printer_state = AC_printer_paused;
pause_state = AC_paused_idle;
msg_matched = true;
}
} break;
case AC_printer_stopping: {
if (strcmp_P(msg, MARLIN_msg_print_aborted) == 0) {
SendtoTFTLN(AC_msg_stop);
printer_state = AC_printer_idle;
msg_matched = true;
}
} break;
default:
break;
}
// If not matched earlier see if this was a heater message
if (!msg_matched) {
if (strcmp_P(msg, MARLIN_msg_extruder_heating) == 0) {
SendtoTFTLN(AC_msg_nozzle_heating);
hotend_state = AC_heater_temp_set;
}
else if (strcmp_P(msg, MARLIN_msg_bed_heating) == 0) {
SendtoTFTLN(AC_msg_bed_heating);
hotbed_state = AC_heater_temp_set;
}
else if (strcmp_P(msg, MARLIN_msg_EEPROM_version) == 0) {
last_error = AC_error_EEPROM;
}
}
}
void ChironTFT::PowerLossRecovery() {
printer_state = AC_printer_resuming_from_power_outage; // Play tune to notify user we can recover.
last_error = AC_error_powerloss;
PlayTune(BEEPER_PIN, SOS, 1);
SERIAL_ECHOLNF(AC_msg_powerloss_recovery);
}
void ChironTFT::PrintComplete() {
SendtoTFT(AC_msg_print_complete);
printer_state = AC_printer_idle;
setSoftEndstopState(true); // enable endstops
}
void ChironTFT::SendtoTFT(FSTR_P const fstr/*=nullptr*/) { // A helper to print PROGMEM string to the panel
#if ACDEBUG(AC_SOME)
SERIAL_ECHOF(fstr);
#endif
PGM_P str = FTOP(fstr);
while (const char c = pgm_read_byte(str++)) TFTSer.write(c);
}
void ChironTFT::SendtoTFTLN(FSTR_P const fstr/*=nullptr*/) {
if (fstr) {
#if ACDEBUG(AC_SOME)
SERIAL_ECHOPGM("> ");
#endif
SendtoTFT(fstr);
#if ACDEBUG(AC_SOME)
SERIAL_EOL();
#endif
}
TFTSer.println();
}
bool ChironTFT::ReadTFTCommand() {
bool command_ready = false;
while (TFTSer.available() > 0 && command_len < MAX_CMND_LEN) {
panel_command[command_len] = TFTSer.read();
if (panel_command[command_len] == '\n') {
command_ready = true;
break;
}
command_len++;
}
if (command_ready || command_len == MAX_CMND_LEN) {
panel_command[command_len] = '\0';
#if ACDEBUG(AC_ALL)
SERIAL_ECHOLNPGM("len(",command_len,") < ", panel_command);
#endif
command_ready = true;
}
return command_ready;
}
int8_t ChironTFT::FindToken(char c) {
for (int8_t pos = 0; pos < command_len; pos++) {
if (panel_command[pos] == c) {
#if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPGM("Tpos:", pos, " ", c);
#endif
return pos;
}
}
#if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPGM("Not found: ", c);
#endif
return -1;
}
void ChironTFT::CheckHeaters() {
uint8_t faultDuration = 0;
// if the hotend temp is abnormal, confirm state before signalling panel
celsius_float_t temp = getActualTemp_celsius(E0);
while (!WITHIN(temp, HEATER_0_MINTEMP, HEATER_0_MAXTEMP)) {
faultDuration++;
if (faultDuration >= AC_HEATER_FAULT_VALIDATION_TIME) {
SendtoTFTLN(AC_msg_nozzle_temp_abnormal);
last_error = AC_error_abnormal_temp_t0;
SERIAL_ECHOLNPGM("Extruder temp abnormal! : ", temp);
break;
}
delay_ms(500);
temp = getActualTemp_celsius(E0);
}
// If the hotbed temp is abnormal, confirm state before signaling panel
faultDuration = 0;
temp = getActualTemp_celsius(BED);
while (!WITHIN(temp, BED_MINTEMP, BED_MAXTEMP)) {
faultDuration++;
if (faultDuration >= AC_HEATER_FAULT_VALIDATION_TIME) {
SendtoTFTLN(AC_msg_nozzle_temp_abnormal);
last_error = AC_error_abnormal_temp_bed;
SERIAL_ECHOLNPGM("Bed temp abnormal! : ", temp);
break;
}
delay_ms(500);
temp = getActualTemp_celsius(E0);
}
// Update panel with hotend heater status
if (hotend_state != AC_heater_temp_reached) {
if (WITHIN(getActualTemp_celsius(E0) - getTargetTemp_celsius(E0), -(TEMP_WINDOW), TEMP_WINDOW)) {
SendtoTFTLN(AC_msg_nozzle_heating_done);
hotend_state = AC_heater_temp_reached;
}
}
// Update panel with bed heater status
if (hotbed_state != AC_heater_temp_reached) {
if (WITHIN(getActualTemp_celsius(BED) - getTargetTemp_celsius(BED), -(TEMP_BED_WINDOW), TEMP_BED_WINDOW)) {
SendtoTFTLN(AC_msg_bed_heating_done);
hotbed_state = AC_heater_temp_reached;
}
}
}
void ChironTFT::SendFileList(int8_t startindex) {
// Respond to panel request for 4 files starting at index
#if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPGM("## SendFileList ## ", startindex);
#endif
SendtoTFTLN(F("FN "));
filenavigator.getFiles(startindex, panel_type, 4);
SendtoTFTLN(F("END"));
}
void ChironTFT::SelectFile() {
if (panel_type <= AC_panel_new) {
strncpy(selectedfile, panel_command + 4, command_len - 3);
selectedfile[command_len - 4] = '\0';
}
else {
strncpy(selectedfile, panel_command + 4, command_len - 4);
selectedfile[command_len - 5] = '\0';
}
#if ACDEBUG(AC_FILE)
SERIAL_ECHOLNPGM(" Selected File: ",selectedfile);
#endif
switch (selectedfile[0]) {
case '/': // Valid file selected
SendtoTFTLN(AC_msg_sd_file_open_success);
break;
case '<': // .. (go up folder level)
filenavigator.upDIR();
SendtoTFTLN(AC_msg_sd_file_open_failed);
SendFileList( 0 );
break;
default: // enter sub folder
// for new panel remove the '.GCO' tag that was added to the end of the path
if (panel_type <= AC_panel_new)
selectedfile[strlen(selectedfile) - 4] = '\0';
filenavigator.changeDIR(selectedfile);
SendtoTFTLN(AC_msg_sd_file_open_failed);
SendFileList( 0 );
break;
}
}
void ChironTFT::ProcessPanelRequest() {
// Break these up into logical blocks // as its easier to navigate than one huge switch case!
int8_t tpos = FindToken('A');
// Panel request are 'A0' - 'A36'
if (tpos >= 0) {
const int8_t req = atoi(&panel_command[tpos + 1]);
// Information requests A0 - A8 and A33
if (req <= 8 || req == 33) PanelInfo(req);
// Simple Actions A9 - A28
else if (req <= 28) PanelAction(req);
// Process Initiation
else if (req <= 36) PanelProcess(req);
}
else {
#if AUTO_DETECT_CHIRON_TFT
// This may be a response to a panel type detection query
if (panel_type == AC_panel_unknown) {
tpos = FindToken('S'); // old panel will respond to 'SIZE' with 'SXY 480 320'
if (tpos >= 0) {
if (panel_command[tpos + 1] == 'X' && panel_command[tpos + 2] =='Y') {
panel_type = AC_panel_standard;
SERIAL_ECHOLNF(AC_msg_old_panel_detected);
}
}
else {
// new panel will respond to 'J200' with '[0]=0'
// it seems only after a power cycle so detection assumes a new panel
tpos = FindToken('[');
if (tpos >= 0) {
if (panel_command[tpos + 1] == '0' && panel_command[tpos + 2] ==']') {
panel_type = AC_panel_new;
SERIAL_ECHOLNF(AC_msg_new_panel_detected);
}
}
}
return;
}
#endif
SendtoTFTLN(); // Ignore unknown requests
}
}
void ChironTFT::PanelInfo(uint8_t req) {
// information requests A0-A8 and A33
switch (req) {
case 0: // A0 Get HOTEND Temp
SendtoTFT(F("A0V "));
TFTSer.println(getActualTemp_celsius(E0));
break;
case 1: // A1 Get HOTEND Target Temp
SendtoTFT(F("A1V "));
TFTSer.println(getTargetTemp_celsius(E0));
break;
case 2: // A2 Get BED Temp
SendtoTFT(F("A2V "));
TFTSer.println(getActualTemp_celsius(BED));
break;
case 3: // A3 Get BED Target Temp
SendtoTFT(F("A3V "));
TFTSer.println(getTargetTemp_celsius(BED));
break;
case 4: // A4 Get FAN Speed
SendtoTFT(F("A4V "));
TFTSer.println(getActualFan_percent(FAN0));
break;
case 5: // A5 Get Current Coordinates
SendtoTFT(F("A5V X: "));
TFTSer.print(getAxisPosition_mm(X));
SendtoTFT(F(" Y: "));
TFTSer.print(getAxisPosition_mm(Y));
SendtoTFT(F(" Z: "));
TFTSer.println(getAxisPosition_mm(Z));
break;
case 6: // A6 Get printing progress
if (isPrintingFromMedia()) {
SendtoTFT(F("A6V "));
TFTSer.println(ui8tostr2(getProgress_percent()));
}
else
SendtoTFTLN(F("A6V ---"));
break;
case 7: { // A7 Get Printing Time
uint32_t time = getProgress_seconds_elapsed() / 60;
SendtoTFT(F("A7V "));
TFTSer.print(ui8tostr2(time / 60));
SendtoTFT(F(" H "));
TFTSer.print(ui8tostr2(time % 60));
SendtoTFT(F(" M"));
#if ACDEBUG(AC_ALL)
SERIAL_ECHOLNPGM("Print time ", ui8tostr2(time / 60), ":", ui8tostr2(time % 60));
#endif
} break;
case 8: // A8 Get SD Card list A8 S0
if (!isMediaInserted()) safe_delay(500);
if (!isMediaInserted()) // Make sure the card is removed
SendtoTFTLN(AC_msg_no_sd_card);
else if (panel_command[3] == 'S')
SendFileList( atoi( &panel_command[4] ) );
break;
case 33: // A33 Get firmware info
SendtoTFT(F("J33 "));
// If there is an error recorded, show that instead of the FW version
if (!GetLastError()) SendtoTFTLN(F(SHORT_BUILD_VERSION));
break;
}
}
void ChironTFT::PanelAction(uint8_t req) {
switch (req) {
case 9: // A9 Pause SD print
if (isPrintingFromMedia()) {
SendtoTFTLN(AC_msg_pause);
pausePrint();
printer_state = AC_printer_pausing;
}
else
SendtoTFTLN(AC_msg_stop);
break;
case 10: // A10 Resume SD Print
if (pause_state == AC_paused_idle || printer_state == AC_printer_resuming_from_power_outage)
resumePrint();
else
setUserConfirmed();
break;
case 11: // A11 Stop SD print
if (isPrintingFromMedia()) {
printer_state = AC_printer_stopping;
stopPrint();
}
else {
if (printer_state == AC_printer_resuming_from_power_outage)
injectCommands(F("M1000 C")); // Cancel recovery
SendtoTFTLN(AC_msg_stop);
printer_state = AC_printer_idle;
}
break;
case 12: // A12 Kill printer
kill(); // from marlincore.h
break;
case 13: // A13 Select file
SelectFile();
break;
case 14: // A14 Start Printing
// Allows printer to restart the job if we don't want to recover
if (printer_state == AC_printer_resuming_from_power_outage) {
injectCommands(F("M1000 C")); // Cancel recovery
printer_state = AC_printer_idle;
}
#if ACDebugLevel >= 1
SERIAL_ECHOLNPGM("Print: ", selectedfile);
#endif
printFile(selectedfile);
SendtoTFTLN(AC_msg_print_from_sd_card);
break;
case 15: // A15 Resuming from outage
if (printer_state == AC_printer_resuming_from_power_outage) {
// Need to home here to restore the Z position
injectCommands(AC_cmnd_power_loss_recovery);
injectCommands(F("M1000")); // home and start recovery
}
break;
case 16: { // A16 Set HotEnd temp A17 S170
const float set_Htemp = atof(&panel_command[5]);
hotend_state = set_Htemp ? AC_heater_temp_set : AC_heater_off;
switch ((char)panel_command[4]) {
// Set Temp
case 'S': case 'C': setTargetTemp_celsius(set_Htemp, E0);
}
} break;
case 17: { // A17 Set bed temp
const float set_Btemp = atof(&panel_command[5]);
hotbed_state = set_Btemp ? AC_heater_temp_set : AC_heater_off;
if (panel_command[4] == 'S')
setTargetTemp_celsius(set_Btemp, BED);
} break;
case 18: // A18 Set Fan Speed
if (panel_command[4] == 'S')
setTargetFan_percent(atof(&panel_command[5]), FAN0);
break;
case 19: // A19 Motors off
if (!isPrinting()) {
stepper.disable_all_steppers();
SendtoTFTLN(AC_msg_ready);
}
break;
case 20: // A20 Read/write print speed
if (panel_command[4] == 'S')
setFeedrate_percent(atoi(&panel_command[5]));
else {
SendtoTFT(F("A20V "));
TFTSer.println(getFeedrate_percent());
}
break;
case 21: // A21 Home Axis A21 X
if (!isPrinting()) {
switch ((char)panel_command[4]) {
case 'X': injectCommands(F("G28X")); break;
case 'Y': injectCommands(F("G28Y")); break;
case 'Z': injectCommands(F("G28Z")); break;
case 'C': injectCommands_P(G28_STR); break;
}
}
break;
case 22: { // A22 Move Axis
// The commands have changed on the new panel
// Old TFT A22 X -1F1500 A22 X +1F1500
// New TFT A22 X-1.0 F1500 A22 X1.0 F1500
// Send a G-code-relative non-print move and let the controller deal with it
// G91 G0 <panel command> G90
if (!isPrinting()) { // Ignore request if printing
char MoveCmnd[30];
sprintf_P(MoveCmnd, PSTR("G91\nG0%s\nG90"), panel_command + 3);
#if ACDEBUG(AC_ACTION)
SERIAL_ECHOLNPGM("Move: ", MoveCmnd);
#endif
setSoftEndstopState(true); // enable endstops
injectCommands(MoveCmnd);
}
} break;
case 23: // A23 Preheat PLA
// Ignore request if printing
if (!isPrinting()) {
// Temps defined in configuration.h
setTargetTemp_celsius(PREHEAT_1_TEMP_BED, BED);
setTargetTemp_celsius(PREHEAT_1_TEMP_HOTEND, E0);
SendtoTFTLN();
hotbed_state = AC_heater_temp_set;
hotend_state = AC_heater_temp_set;
}
break;
case 24: // A24 Preheat ABS
// Ignore request if printing
if (!isPrinting()) {
setTargetTemp_celsius(PREHEAT_2_TEMP_BED, BED);
setTargetTemp_celsius(PREHEAT_2_TEMP_HOTEND, E0);
SendtoTFTLN();
hotbed_state = AC_heater_temp_set;
hotend_state = AC_heater_temp_set;
}
break;
case 25: // A25 Cool Down
// Ignore request if printing
if (!isPrinting()) {
setTargetTemp_celsius(0, E0);
setTargetTemp_celsius(0, BED);
SendtoTFTLN(AC_msg_ready);
hotbed_state = AC_heater_off;
hotend_state = AC_heater_off;
}
break;
case 26: // A26 Refresh SD
if (card.isMounted())card.release();
card.mount();
safe_delay(500);
filenavigator.reset();
break;
case 27: // A27 Servo Angles adjust
break;
case 28: // A28 Filament set A28 O/C
// Ignore request if printing
if (isPrinting()) break;
SendtoTFTLN();
break;
}
}
void ChironTFT::PanelProcess(uint8_t req) {
switch (req) {
case 29: { // A29 Read Mesh Point A29 X1 Y1
xy_uint8_t pos;
float pos_z;
pos.x = atoi(&panel_command[FindToken('X')+1]);
pos.y = atoi(&panel_command[FindToken('Y')+1]);
pos_z = getMeshPoint(pos);
SendtoTFT(F("A29V "));
TFTSer.println(pos_z * 100);
if (!isPrinting()) {
setSoftEndstopState(true); // disable endstops
// If the same meshpoint is selected twice in a row, move the head to that ready for adjustment
if ((selectedmeshpoint.x == pos.x) && (selectedmeshpoint.y == pos.y)) {
if (!isPositionKnown())
injectCommands_P(G28_STR); // home
if (isPositionKnown()) {
#if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPGM("Moving to mesh point at x: ", pos.x, " y: ", pos.y, " z: ", pos_z);
#endif
// Go up before moving
setAxisPosition_mm(3.0,Z);
setAxisPosition_mm(17 + (93 * pos.x), X);
setAxisPosition_mm(20 + (93 * pos.y), Y);
setAxisPosition_mm(0.0, Z);
#if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPGM("Current Z: ", getAxisPosition_mm(Z));
#endif
}
}
selectedmeshpoint.x = pos.x;
selectedmeshpoint.y = pos.y;
}
} break;
case 30: // A30 Auto leveling
if (FindToken('S') >= 0) { // Start probing New panel adds spaces..
// Ignore request if printing
if (isPrinting())
SendtoTFTLN(AC_msg_probing_not_allowed); // forbid auto leveling
else {
SendtoTFTLN(AC_msg_start_probing);
injectCommands(F("G28\nG29"));
printer_state = AC_printer_probing;
}
}
else
SendtoTFTLN(AC_msg_start_probing); // Just enter levelling menu
break;
case 31: // A31 Adjust all Probe Points
// The tokens can occur in different places on the new panel so we need to find it.
if (FindToken('C') >= 0) { // Restore and apply original offsets
if (!isPrinting()) {
injectCommands(F("M501\nM420 S1"));
selectedmeshpoint.x = selectedmeshpoint.y = 99;
SERIAL_ECHOLNF(AC_msg_mesh_changes_abandoned);
}
}
else if (FindToken('D') >= 0) { // Save Z Offset tables and restore leveling state
if (!isPrinting()) {
setAxisPosition_mm(1.0,Z); // Lift nozzle before any further movements are made
injectCommands(F("M500"));
SERIAL_ECHOLNF(AC_msg_mesh_changes_saved);
selectedmeshpoint.x = selectedmeshpoint.y = 99;
}
}
else if (FindToken('G') >= 0) { // Get current offset
SendtoTFT(F("A31V "));
// When printing use the live z Offset position
// we will use babystepping to move the print head
if (isPrinting())
TFTSer.println(live_Zoffset);
else {
TFTSer.println(getZOffset_mm());
selectedmeshpoint.x = selectedmeshpoint.y = 99;
}
}
else {
int8_t tokenpos = FindToken('S');
if (tokenpos >= 0) { // Set offset (adjusts all points by value)
float Zshift = atof(&panel_command[tokenpos+1]);
setSoftEndstopState(false); // disable endstops
// Allow temporary Z position nudging during print
// From the leveling panel use the all points UI to adjust the print pos.
if (isPrinting()) {
#if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPGM("Change Zoffset from:", live_Zoffset, " to ", live_Zoffset + Zshift);
#endif
if (isAxisPositionKnown(Z)) {
#if ACDEBUG(AC_INFO)
const float currZpos = getAxisPosition_mm(Z);
SERIAL_ECHOLNPGM("Nudge Z pos from ", currZpos, " to ", currZpos + constrain(Zshift, -0.05, 0.05));
#endif
// Use babystepping to adjust the head position
int16_t steps = mmToWholeSteps(constrain(Zshift,-0.05,0.05), Z);
#if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPGM("Steps to move Z: ", steps);
#endif
babystepAxis_steps(steps, Z);
live_Zoffset += Zshift;
}
SendtoTFT(F("A31V "));
TFTSer.println(live_Zoffset);
}
else {
GRID_LOOP(x, y) {
const xy_uint8_t pos { x, y };
const float currval = getMeshPoint(pos);
setMeshPoint(pos, constrain(currval + Zshift, AC_LOWEST_MESHPOINT_VAL, 2));
#if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPGM("Change mesh point X", x," Y",y ," from ", currval, " to ", getMeshPoint(pos) );
#endif
}
const float currZOffset = getZOffset_mm();
#if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPGM("Change probe offset from ", currZOffset, " to ", currZOffset + Zshift);
#endif
setZOffset_mm(currZOffset + Zshift);
SendtoTFT(F("A31V "));
TFTSer.println(getZOffset_mm());
if (isAxisPositionKnown(Z)) {
// Move Z axis
const float currZpos = getAxisPosition_mm(Z);
#if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPGM("Move Z pos from ", currZpos, " to ", currZpos + constrain(Zshift, -0.05, 0.05));
#endif
setAxisPosition_mm(currZpos+constrain(Zshift,-0.05,0.05),Z);
}
}
}
}
break;
case 32: // A32 clean leveling beep flag
// Ignore request if printing
//if (isPrinting()) break;
//injectCommands(F("M500\nM420 S1\nG1 Z10 F240\nG1 X0 Y0 F6000"));
//TFTSer.println();
break;
// A33 firmware info request see PanelInfo()
case 34: // A34 Adjust single mesh point A34 C/S X1 Y1 V123
if (panel_command[3] == 'C') { // Restore original offsets
injectCommands(F("M501\nM420 S1"));
selectedmeshpoint.x = selectedmeshpoint.y = 99;
//printer_state = AC_printer_idle;
}
else {
xy_uint8_t pos;
pos.x = atoi(&panel_command[5]);
pos.y = atoi(&panel_command[8]);
float currmesh = getMeshPoint(pos);
float newval = atof(&panel_command[11])/100;
#if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPGM("Change mesh point x:", pos.x, " y:", pos.y);
SERIAL_ECHOLNPGM("from ", currmesh, " to ", newval);
#endif
// Update Meshpoint
setMeshPoint(pos,newval);
if (printer_state == AC_printer_idle || printer_state == AC_printer_probing /*!isPrinting()*/) {
// if we are at the current mesh point indicated on the panel Move Z pos +/- 0.05mm
// (The panel changes the mesh value by +/- 0.05mm on each button press)
if (selectedmeshpoint.x == pos.x && selectedmeshpoint.y == pos.y) {
setSoftEndstopState(false);
float currZpos = getAxisPosition_mm(Z);
#if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPGM("Move Z pos from ", currZpos, " to ", currZpos + constrain(newval - currmesh, -0.05, 0.05));
#endif
setAxisPosition_mm(currZpos + constrain(newval - currmesh, -0.05, 0.05), Z);
}
}
}
break;
case 36: // A36 Auto leveling for new TFT bet that was a typo in the panel code!
SendtoTFTLN(AC_msg_start_probing);
break;
}
}
bool ChironTFT::GetLastError() {
switch (last_error) {
case AC_error_abnormal_temp_bed: SendtoTFTLN(AC_msg_error_bed_temp); break;
case AC_error_abnormal_temp_t0: SendtoTFTLN(AC_msg_error_hotend_temp); break;
case AC_error_noSD: SendtoTFTLN(AC_msg_error_sd_card); break;
case AC_error_powerloss: SendtoTFTLN(AC_msg_power_loss); break;
case AC_error_EEPROM: SendtoTFTLN(AC_msg_eeprom_version); break;
case AC_error_filament_runout: SendtoTFTLN(AC_msg_filament_out); break;
default: return false;
}
last_error = AC_error_none;
return true;
}
} // Anycubic namespace
#endif // ANYCUBIC_LCD_CHIRON

View File

@ -0,0 +1,89 @@
/**
* 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
/**
* lcd/extui/anycubic_chiron/chiron_tft.h
*
* Extensible_UI implementation for Anycubic Chiron
* Written By Nick Wells, 2020 [https://github.com/SwiftNick]
* (not affiliated with Anycubic, Ltd.)
*/
#include "chiron_tft_defs.h"
#include "../../../inc/MarlinConfigPre.h"
#include "../ui_api.h"
#if NONE(CHIRON_TFT_STANDARD, CHIRON_TFT_NEW)
#define AUTO_DETECT_CHIRON_TFT 1
#endif
namespace Anycubic {
class ChironTFT {
#if AUTO_DETECT_CHIRON_TFT
static panel_type_t panel_type;
#else
static constexpr panel_type_t panel_type = TERN(CHIRON_TFT_NEW, AC_panel_new, AC_panel_standard);
#endif
static last_error_t last_error;
static printer_state_t printer_state;
static paused_state_t pause_state;
static heater_state_t hotend_state;
static heater_state_t hotbed_state;
static xy_uint8_t selectedmeshpoint;
static char panel_command[MAX_CMND_LEN + 1];
static uint8_t command_len;
static char selectedfile[MAX_PATH_LEN + 1];
static float live_Zoffset;
static file_menu_t file_menu;
public:
static void Startup();
static void IdleLoop();
static void PrinterKilled(FSTR_P, FSTR_P);
static void MediaEvent(media_event_t);
static void TimerEvent(timer_event_t);
static void FilamentRunout();
static void ConfirmationRequest(const char * const);
static void StatusChange(const char * const);
static void PowerLossRecovery();
static void PrintComplete();
static void SendtoTFT(FSTR_P const=nullptr);
static void SendtoTFTLN(FSTR_P const=nullptr);
private:
static void DetectPanelType();
static bool ReadTFTCommand();
static int8_t FindToken(char);
static void CheckHeaters();
static void SendFileList(int8_t);
static void SelectFile();
static void InjectCommandandWait(PGM_P);
static void ProcessPanelRequest();
static void PanelInfo(uint8_t);
static void PanelAction(uint8_t);
static void PanelProcess(uint8_t);
static bool GetLastError();
};
extern ChironTFT Chiron;
} // Anycubic namespace

View File

@ -0,0 +1,182 @@
/**
* 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
/**
* lcd/extui/anycubic_chiron/chiron_defs.h
*
* Extensible_UI implementation for Anycubic Chiron
* Written By Nick Wells, 2020 [https://github.com/SwiftNick]
* (not affiliated with Anycubic, Ltd.)
*/
#include "../../../inc/MarlinConfigPre.h"
//#define ACDEBUGLEVEL 4
#if ACDEBUGLEVEL
// Bit-masks for selective debug:
enum ACDebugMask : uint8_t {
AC_INFO = 1,
AC_ACTION = 2,
AC_FILE = 4,
AC_PANEL = 8,
AC_MARLIN = 16,
AC_SOME = 32,
AC_ALL = 64
};
#define ACDEBUG(mask) ( ((mask) & ACDEBUGLEVEL) == mask ) // Debug flag macro
#else
#define ACDEBUG(mask) false
#endif
#define TFTSer LCD_SERIAL // Serial interface for TFT panel now uses marlinserial
#define MAX_FOLDER_DEPTH 4 // Limit folder depth TFT has a limit for the file path
#define MAX_CMND_LEN 16 * MAX_FOLDER_DEPTH // Maximum Length for a Panel command
#define MAX_PATH_LEN 16 * MAX_FOLDER_DEPTH // Maximum number of characters in a SD file path
#define AC_HEATER_FAULT_VALIDATION_TIME 5 // number of 1/2 second loops before signalling a heater fault
#define AC_LOWEST_MESHPOINT_VAL -10 // The lowest value you can set for a single mesh point offset
// TFT panel commands
#define AC_msg_sd_card_inserted F("J00")
#define AC_msg_sd_card_removed F("J01")
#define AC_msg_no_sd_card F("J02")
#define AC_msg_usb_connected F("J03")
#define AC_msg_print_from_sd_card F("J04")
#define AC_msg_pause F("J05")
#define AC_msg_nozzle_heating F("J06")
#define AC_msg_nozzle_heating_done F("J07")
#define AC_msg_bed_heating F("J08")
#define AC_msg_bed_heating_done F("J09")
#define AC_msg_nozzle_temp_abnormal F("J10")
#define AC_msg_kill_lcd F("J11")
#define AC_msg_ready F("J12")
#define AC_msg_low_nozzle_temp F("J13")
#define AC_msg_print_complete F("J14")
#define AC_msg_filament_out_alert F("J15")
#define AC_msg_stop F("J16")
#define AC_msg_main_board_has_reset F("J17")
#define AC_msg_paused F("J18")
#define AC_msg_j19_unknown F("J19")
#define AC_msg_sd_file_open_success F("J20")
#define AC_msg_sd_file_open_failed F("J21")
#define AC_msg_level_monitor_finished F("J22")
#define AC_msg_filament_out_block F("J23")
#define AC_msg_probing_not_allowed F("J24")
#define AC_msg_probing_complete F("J25")
#define AC_msg_start_probing F("J26")
#define AC_msg_version F("J27")
#define AC_msg_mesh_changes_abandoned F("Mesh changes abandoned, previous mesh restored.")
#define AC_msg_mesh_changes_saved F("Mesh changes saved.")
#define AC_msg_old_panel_detected F("Standard TFT panel detected!")
#define AC_msg_new_panel_detected F("New TFT panel detected!")
#define AC_msg_auto_panel_detection F("Auto detect panel type (assuming new panel)")
#define AC_msg_old_panel_set F("Set for standard TFT panel.")
#define AC_msg_new_panel_set F("Set for new TFT panel.")
#define AC_msg_powerloss_recovery F("Resuming from power outage! select the same SD file then press resume")
// Error messages must not contain spaces
#define AC_msg_error_bed_temp F("Abnormal_bed_temp")
#define AC_msg_error_hotend_temp F("Abnormal_hotend_temp")
#define AC_msg_error_sd_card F("SD_card_error")
#define AC_msg_filament_out F("Filament_runout")
#define AC_msg_power_loss F("Power_failure")
#define AC_msg_eeprom_version F("EEPROM_ver_wrong")
#define MARLIN_msg_start_probing PSTR("Probing Point 1/25")
#define MARLIN_msg_probing_failed PSTR("Probing Failed")
#define MARLIN_msg_ready PSTR(" Ready.")
#define MARLIN_msg_print_paused PSTR("Print Paused")
#define MARLIN_msg_print_aborted PSTR("Print Aborted")
#define MARLIN_msg_extruder_heating PSTR("E Heating...")
#define MARLIN_msg_bed_heating PSTR("Bed Heating...")
#define MARLIN_msg_EEPROM_version PSTR("EEPROM Version Error")
#define MARLIN_msg_nozzle_parked PSTR("Nozzle Parked")
#define MARLIN_msg_heater_timeout PSTR("Heater Timeout")
#define MARLIN_msg_reheating PSTR("Reheating...")
#define MARLIN_msg_reheat_done PSTR("Reheat finished.")
#define MARLIN_msg_filament_purging PSTR("Filament Purging...")
#define MARLIN_msg_special_pause PSTR("PB")
#define AC_cmnd_auto_unload_filament F("M701") // Use Marlin unload routine
#define AC_cmnd_auto_load_filament F("M702 M0 PB") // Use Marlin load routing then pause for user to clean nozzle
#define AC_cmnd_manual_load_filament F("M83\nG1 E50 F700\nM82") // replace the manual panel commands with something a little faster
#define AC_cmnd_manual_unload_filament F("M83\nG1 E-50 F1200\nM82")
#define AC_cmnd_enable_leveling F("M420SV")
#define AC_cmnd_power_loss_recovery F("G28XYR5\nG28Z") // Lift, home X and Y then home Z when in 'safe' position
#define AC_Test_for_OldPanel F("SIZE") // An old panel will respond with 'SXY 480 320' a new panel wont respond.
#define AC_Test_for_NewPanel F("J200") // A new panel will respond with '[0]=0 [1]=0' to '[19]=0 ' an old panel wont respond
namespace Anycubic {
enum heater_state_t : uint8_t {
AC_heater_off,
AC_heater_temp_set,
AC_heater_temp_reached
};
enum paused_state_t : uint8_t {
AC_paused_heater_timed_out,
AC_paused_purging_filament,
AC_paused_idle
};
enum printer_state_t : uint8_t {
AC_printer_booting,
AC_printer_idle,
AC_printer_probing,
AC_printer_printing,
AC_printer_pausing,
AC_printer_paused,
AC_printer_stopping,
AC_printer_resuming_from_power_outage
};
enum timer_event_t : uint8_t {
AC_timer_started,
AC_timer_paused,
AC_timer_stopped
};
enum media_event_t : uint8_t {
AC_media_inserted,
AC_media_removed,
AC_media_error
};
enum file_menu_t : uint8_t {
AC_menu_file,
AC_menu_command,
AC_menu_change_to_file,
AC_menu_change_to_command
};
enum panel_type_t : uint8_t { // order is important here as we assume new panel if type is unknown
AC_panel_unknown,
AC_panel_new,
AC_panel_standard
};
enum last_error_t : uint8_t {
AC_error_none,
AC_error_abnormal_temp_t0,
AC_error_abnormal_temp_bed,
AC_error_noSD,
AC_error_powerloss,
AC_error_filament_runout,
AC_error_EEPROM
};
} // Anycubic namespace

View File

@ -0,0 +1,124 @@
/**
* 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/>.
*
*/
/**
* lcd/extui/anycubic_i3mega/anycubic_extui.cpp
*/
#include "../../../inc/MarlinConfigPre.h"
#if ENABLED(ANYCUBIC_LCD_I3MEGA)
#include "anycubic_i3mega_lcd.h"
#include "../ui_api.h"
#include <Arduino.h> // for the ::tone() call
namespace ExtUI {
void onStartup() { AnycubicTFT.OnSetup(); }
void onIdle() { AnycubicTFT.OnCommandScan(); }
void onPrinterKilled(FSTR_P const error, FSTR_P const component) { AnycubicTFT.OnKillTFT(); }
void onMediaInserted() { AnycubicTFT.OnSDCardStateChange(true); }
void onMediaError() { AnycubicTFT.OnSDCardError(); }
void onMediaRemoved() { AnycubicTFT.OnSDCardStateChange(false); }
void onPlayTone(const uint16_t frequency, const uint16_t duration) {
TERN_(SPEAKER, ::tone(BEEPER_PIN, frequency, duration));
}
void onPrintTimerStarted() { AnycubicTFT.OnPrintTimerStarted(); }
void onPrintTimerPaused() { AnycubicTFT.OnPrintTimerPaused(); }
void onPrintTimerStopped() { AnycubicTFT.OnPrintTimerStopped(); }
void onFilamentRunout(const extruder_t extruder) { AnycubicTFT.OnFilamentRunout(); }
void onUserConfirmRequired(const char * const msg) { AnycubicTFT.OnUserConfirmRequired(msg); }
void onStatusChanged(const char * const msg) {}
void onHomingStart() {}
void onHomingDone() {}
void onPrintDone() {}
void onFactoryReset() {}
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) <= 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) <= eeprom_data_size);
// memcpy(&myDataStruct, buff, sizeof(myDataStruct));
}
void onPostprocessSettings() {
// Called after loading or resetting stored settings
}
void onSettingsStored(bool success) {
// Called after the entire EEPROM has been written,
// whether successful or not.
}
void onSettingsLoaded(bool success) {
// Called after the entire EEPROM has been read,
// whether successful or not.
}
#if HAS_MESH
void onLevelingStart() {}
void onLevelingDone() {}
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) {
// Called when any mesh points are updated
}
void onMeshUpdate(const int8_t xpos, const int8_t ypos, probe_state_t state) {
// Called when any mesh points are updated
}
#endif
#if ENABLED(POWER_LOSS_RECOVERY)
void onPowerLossResume() {
// Called on resume from power-loss
}
#endif
#if HAS_PID_HEATING
void onPidTuning(const result_t rst) {
// Called for temperature PID tuning result
}
#endif
void onSteppersDisabled() {}
void onSteppersEnabled() {}
}
#endif // ANYCUBIC_LCD_I3MEGA

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,95 @@
/**
* anycubic_i3mega_lcd.h --- Support for Anycubic i3 Mega TFT
* Created by Christian Hopp on 09.12.17.
* Improved by David Ramiro
* Converted to ExtUI by John BouAntoun 21 June 2020
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#pragma once
#include "../../../inc/MarlinConfigPre.h"
#include "../../../sd/SdFatConfig.h" // for the FILENAME_LENGTH macro
#define TFTBUFSIZE 4
#define TFT_MAX_CMD_SIZE 96
enum AnycubicMediaPrintState {
AMPRINTSTATE_NOT_PRINTING,
AMPRINTSTATE_PRINTING,
AMPRINTSTATE_PAUSE_REQUESTED,
AMPRINTSTATE_PAUSED,
AMPRINTSTATE_STOP_REQUESTED
};
enum AnycubicMediaPauseState {
AMPAUSESTATE_NOT_PAUSED,
AMPAUSESTATE_PARKING,
AMPAUSESTATE_PARKED,
AMPAUSESTATE_FILAMENT_OUT,
AMPAUSESTATE_FILAMENT_PURGING,
AMPAUSESTATE_HEATER_TIMEOUT,
AMPAUSESTATE_REHEATING,
AMPAUSESTATE_REHEAT_FINISHED
};
class AnycubicTFTClass {
public:
AnycubicTFTClass();
static void OnSetup();
static void OnCommandScan();
static void OnKillTFT();
static void OnSDCardStateChange(bool);
static void OnSDCardError();
static void OnFilamentRunout();
static void OnUserConfirmRequired(const char *);
static void OnPrintTimerStarted();
static void OnPrintTimerPaused();
static void OnPrintTimerStopped();
private:
static char TFTcmdbuffer[TFTBUFSIZE][TFT_MAX_CMD_SIZE];
static int TFTbuflen, TFTbufindr, TFTbufindw;
static char serial3_char;
static int serial3_count;
static char *TFTstrchr_pointer;
static uint8_t SpecialMenu;
static AnycubicMediaPrintState mediaPrintingState;
static AnycubicMediaPauseState mediaPauseState;
static float CodeValue();
static bool CodeSeen(char);
static bool IsNozzleHomed();
static void RenderCurrentFileList();
static void RenderSpecialMenu(uint16_t);
static void RenderCurrentFolder(uint16_t);
static void GetCommandFromTFT();
static void CheckSDCardChange();
static void CheckPauseState();
static void CheckPrintCompletion();
static void HandleSpecialMenu();
static void DoSDCardStateCheck();
static void DoFilamentRunoutCheck();
static void StartPrint();
static void PausePrint();
static void ResumePrint();
static void StopPrint();
static char SelectedDirectory[30];
static char SelectedFile[FILENAME_LENGTH];
};
extern AnycubicTFTClass AnycubicTFT;
extern const char G28_STR[];

View File

@ -0,0 +1,271 @@
/**
* 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 HAS_DGUS_LCD_CLASSIC
#if HOTENDS > 2
#warning "More than 2 hotends not implemented on DGUS Display UI."
#endif
#include "../ui_api.h"
#include "../../../MarlinCore.h"
#include "../../../module/motion.h"
#include "../../../gcode/queue.h"
#include "../../../module/planner.h"
#include "../../../libs/duration_t.h"
#include "../../../module/printcounter.h"
#if ENABLED(POWER_LOSS_RECOVERY)
#include "../../../feature/powerloss.h"
#endif
#include "DGUSDisplay.h"
#include "DGUSVPVariable.h"
#include "DGUSDisplayDef.h"
DGUSDisplay dgusdisplay;
#ifdef DEBUG_DGUSLCD_COMM
#define DEBUGLCDCOMM_ECHOPGM DEBUG_ECHOPGM
#else
#define DEBUGLCDCOMM_ECHOPGM(...) NOOP
#endif
// Preamble... 2 Bytes, usually 0x5A 0xA5, but configurable
constexpr uint8_t DGUS_HEADER1 = 0x5A;
constexpr uint8_t DGUS_HEADER2 = 0xA5;
constexpr uint8_t DGUS_CMD_WRITEVAR = 0x82;
constexpr uint8_t DGUS_CMD_READVAR = 0x83;
#if ENABLED(DEBUG_DGUSLCD)
bool dguslcd_local_debug; // = false;
#endif
void DGUSDisplay::InitDisplay() {
#ifndef LCD_BAUDRATE
#define LCD_BAUDRATE 115200
#endif
LCD_SERIAL.begin(LCD_BAUDRATE);
if (TERN1(POWER_LOSS_RECOVERY, !recovery.valid())) { // If no Power-Loss Recovery is needed...
TERN_(DGUS_LCD_UI_MKS, delay(LOGO_TIME_DELAY)); // Show the logo for a little while
}
RequestScreen(TERN(SHOW_BOOTSCREEN, DGUSLCD_SCREEN_BOOT, DGUSLCD_SCREEN_MAIN));
}
void DGUSDisplay::WriteVariable(uint16_t adr, const void *values, uint8_t valueslen, bool isstr) {
const char* myvalues = static_cast<const char*>(values);
bool strend = !myvalues;
WriteHeader(adr, DGUS_CMD_WRITEVAR, valueslen);
while (valueslen--) {
char x;
if (!strend) x = *myvalues++;
if ((isstr && !x) || strend) {
strend = true;
x = ' ';
}
LCD_SERIAL.write(x);
}
}
void DGUSDisplay::WriteVariable(uint16_t adr, uint16_t value) {
value = (value & 0xFFU) << 8U | (value >> 8U);
WriteVariable(adr, static_cast<const void*>(&value), sizeof(uint16_t));
}
void DGUSDisplay::WriteVariable(uint16_t adr, int16_t value) {
value = (value & 0xFFU) << 8U | (value >> 8U);
WriteVariable(adr, static_cast<const void*>(&value), sizeof(uint16_t));
}
void DGUSDisplay::WriteVariable(uint16_t adr, uint8_t value) {
WriteVariable(adr, static_cast<const void*>(&value), sizeof(uint8_t));
}
void DGUSDisplay::WriteVariable(uint16_t adr, int8_t value) {
WriteVariable(adr, static_cast<const void*>(&value), sizeof(int8_t));
}
void DGUSDisplay::WriteVariable(uint16_t adr, long value) {
union { long l; char lb[4]; } endian;
char tmp[4];
endian.l = value;
tmp[0] = endian.lb[3];
tmp[1] = endian.lb[2];
tmp[2] = endian.lb[1];
tmp[3] = endian.lb[0];
WriteVariable(adr, static_cast<const void*>(&tmp), sizeof(long));
}
void DGUSDisplay::WriteVariablePGM(uint16_t adr, const void *values, uint8_t valueslen, bool isstr) {
const char* myvalues = static_cast<const char*>(values);
bool strend = !myvalues;
WriteHeader(adr, DGUS_CMD_WRITEVAR, valueslen);
while (valueslen--) {
char x;
if (!strend) x = pgm_read_byte(myvalues++);
if ((isstr && !x) || strend) {
strend = true;
x = ' ';
}
LCD_SERIAL.write(x);
}
}
void DGUSDisplay::ProcessRx() {
#if ENABLED(SERIAL_STATS_RX_BUFFER_OVERRUNS)
if (!LCD_SERIAL.available() && LCD_SERIAL.buffer_overruns()) {
// Overrun, but reset the flag only when the buffer is empty
// We want to extract as many as valid datagrams possible...
DEBUG_ECHOPGM("OVFL");
rx_datagram_state = DGUS_IDLE;
//LCD_SERIAL.reset_rx_overun();
LCD_SERIAL.flush();
}
#endif
uint8_t receivedbyte;
while (LCD_SERIAL.available()) {
switch (rx_datagram_state) {
case DGUS_IDLE: // Waiting for the first header byte
receivedbyte = LCD_SERIAL.read();
//DEBUGLCDCOMM_ECHOPGM("< ", receivedbyte);
if (DGUS_HEADER1 == receivedbyte) rx_datagram_state = DGUS_HEADER1_SEEN;
break;
case DGUS_HEADER1_SEEN: // Waiting for the second header byte
receivedbyte = LCD_SERIAL.read();
//DEBUGLCDCOMM_ECHOPGM(" ", receivedbyte);
rx_datagram_state = (DGUS_HEADER2 == receivedbyte) ? DGUS_HEADER2_SEEN : DGUS_IDLE;
break;
case DGUS_HEADER2_SEEN: // Waiting for the length byte
rx_datagram_len = LCD_SERIAL.read();
//DEBUGLCDCOMM_ECHOPGM(" (", rx_datagram_len, ") ");
// Telegram min len is 3 (command and one word of payload)
rx_datagram_state = WITHIN(rx_datagram_len, 3, DGUS_RX_BUFFER_SIZE) ? DGUS_WAIT_TELEGRAM : DGUS_IDLE;
break;
case DGUS_WAIT_TELEGRAM: // wait for complete datagram to arrive.
if (LCD_SERIAL.available() < rx_datagram_len) return;
Initialized = true; // We've talked to it, so we defined it as initialized.
uint8_t command = LCD_SERIAL.read();
//DEBUGLCDCOMM_ECHOPGM("# ", command);
uint8_t readlen = rx_datagram_len - 1; // command is part of len.
unsigned char tmp[rx_datagram_len - 1];
unsigned char *ptmp = tmp;
while (readlen--) {
receivedbyte = LCD_SERIAL.read();
//DEBUGLCDCOMM_ECHOPGM(" ", 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]) {
//DEBUGLCDCOMM_ECHOPGM(">");
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];
//const uint8_t dlen = tmp[2] << 1; // Convert to Bytes. (Display works with words)
//DEBUG_ECHOPGM(" vp=", vp, " dlen=", dlen);
DGUS_VP_Variable ramcopy;
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_ECHOLNPGM(" VPVar not found:", vp);
rx_datagram_state = DGUS_IDLE;
break;
}
// discard anything else
rx_datagram_state = DGUS_IDLE;
}
}
}
size_t DGUSDisplay::GetFreeTxBuffer() { return SERIAL_GET_TX_BUFFER_FREE(); }
void DGUSDisplay::WriteHeader(uint16_t adr, uint8_t cmd, uint8_t payloadlen) {
LCD_SERIAL.write(DGUS_HEADER1);
LCD_SERIAL.write(DGUS_HEADER2);
LCD_SERIAL.write(payloadlen + 3);
LCD_SERIAL.write(cmd);
LCD_SERIAL.write(adr >> 8);
LCD_SERIAL.write(adr & 0xFF);
}
void DGUSDisplay::WritePGM(const char str[], uint8_t len) {
while (len--) LCD_SERIAL.write(pgm_read_byte(str++));
}
void DGUSDisplay::loop() {
// Protect against recursion. ProcessRx() may indirectly call idle() when injecting G-code commands.
if (!no_reentrance) {
no_reentrance = true;
ProcessRx();
no_reentrance = false;
}
}
rx_datagram_state_t DGUSDisplay::rx_datagram_state = DGUS_IDLE;
uint8_t DGUSDisplay::rx_datagram_len = 0;
bool DGUSDisplay::Initialized = false,
DGUSDisplay::no_reentrance = false;
// 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_ECHOPGM("populate_VPVar ", VP);
const DGUS_VP_Variable *pvp = DGUSLCD_FindVPVar(VP);
//DEBUG_ECHOLNPGM(" pvp ", (uint16_t )pvp);
if (!pvp) return false;
memcpy_P(ramcopy, pvp, sizeof(DGUS_VP_Variable));
return true;
}
#endif // HAS_DGUS_LCD_CLASSIC

View File

@ -0,0 +1,125 @@
/**
* 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
/**
* lcd/extui/dgus/DGUSDisplay.h
*/
#include "../../../inc/MarlinConfigPre.h"
#include <stdlib.h> // size_t
//#define DEBUG_DGUSLCD
//#define DEBUG_DGUSLCD_COMM
#if HAS_BED_PROBE
#include "../../../module/probe.h"
#endif
#include "DGUSVPVariable.h"
enum DGUSLCD_Screens : uint8_t;
//#define DEBUG_DGUSLCD
#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;
constexpr uint16_t swap16(const uint16_t value) { return (value & 0xFFU) << 8U | (value >> 8U); }
// Low-Level access to the display.
class DGUSDisplay {
public:
DGUSDisplay() = default;
static void InitDisplay();
// 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);
// Utility functions for bridging ui_api and dbus
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);
// 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 initialized it.
// (both boils down that the display answered to our chatting)
static bool isInitialized() { return Initialized; }
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 rx_datagram_state_t rx_datagram_state;
static uint8_t rx_datagram_len;
static bool Initialized, no_reentrance;
};
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); }
///
const uint16_t* DGUSLCD_FindScreenVPMapList(uint8_t screen);
/// Find the flash address of a DGUS_VP_Variable for the VP.
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.
bool populate_VPVar(const uint16_t VP, DGUS_VP_Variable * const ramcopy);

View File

@ -0,0 +1,57 @@
/**
* 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
/**
* lcd/extui/dgus/DGUSDisplayDef.h
* Defines the interaction between Marlin and the display firmware
*/
#include "DGUSVPVariable.h"
#include <stdint.h>
// 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_ORIGIN)
#include "origin/DGUSDisplayDef.h"
#elif ENABLED(DGUS_LCD_UI_MKS)
#include "mks/DGUSDisplayDef.h"
#elif ENABLED(DGUS_LCD_UI_FYSETC)
#include "fysetc/DGUSDisplayDef.h"
#elif ENABLED(DGUS_LCD_UI_HIPRECY)
#include "hiprecy/DGUSDisplayDef.h"
#endif

View File

@ -0,0 +1,738 @@
/**
* 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 HAS_DGUS_LCD_CLASSIC
#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
DGUSScreenHandlerClass ScreenHandler;
uint16_t DGUSScreenHandler::ConfirmVP;
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;
void (*DGUSScreenHandler::confirm_action_cb)() = nullptr;
#if ENABLED(SDSUPPORT)
int16_t DGUSScreenHandler::top_file = 0,
DGUSScreenHandler::file_to_print = 0;
ExtUI::FileList filelist;
#endif
#if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
filament_data_t filament_data;
#endif
void DGUSScreenHandler::sendinfoscreen(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const 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);
}
#ifdef VP_MSGSTR4
if (populate_VPVar(VP_MSGSTR4, &ramcopy)) {
ramcopy.memadr = (void*) line4;
l4inflash ? DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenHandler::DGUSLCD_SendStringToDisplay(ramcopy);
}
#endif
}
void DGUSScreenHandler::HandleUserConfirmationPopUp(uint16_t VP, PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1, bool l2, bool l3, bool l4) {
if (current_screen == DGUSLCD_SCREEN_CONFIRM) // Already showing a pop up, so we need to cancel that first.
PopToOldScreen();
ConfirmVP = VP;
sendinfoscreen(line1, line2, line3, line4, l1, l2, l3, l4);
GotoScreen(DGUSLCD_SCREEN_CONFIRM);
}
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_ECHOPGM(" DGUS_LCD_SendWordValueToDisplay ", var.VP);
//DEBUG_ECHOLNPGM(" data ", *(uint16_t *)var.memadr);
if (var.size > 1)
dgusdisplay.WriteVariable(var.VP, *(int16_t*)var.memadr);
else
dgusdisplay.WriteVariable(var.VP, *(int8_t*)var.memadr);
}
}
// 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_ECHOPGM(" DGUS_LCD_SendWordValueToDisplay ", var.VP);
//DEBUG_ECHOLNPGM(" data ", *(uint16_t *)var.memadr);
uint16_t tmp = *(uint8_t *) var.memadr + 1; // +1 -> avoid rounding issues for the display.
tmp = map(tmp, 0, 255, 0, 100);
dgusdisplay.WriteVariable(var.VP, tmp);
}
}
// Send the current print progress to the display.
void DGUSScreenHandler::DGUSLCD_SendPrintProgressToDisplay(DGUS_VP_Variable &var) {
//DEBUG_ECHOPGM(" DGUSLCD_SendPrintProgressToDisplay ", var.VP);
uint16_t tmp = ExtUI::getProgress_percent();
//DEBUG_ECHOLNPGM(" data ", tmp);
dgusdisplay.WriteVariable(var.VP, tmp);
}
// 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);
DEBUG_ECHOLNPGM("FAN value get:", value);
*(uint8_t*)var.memadr = map(constrain(value, 0, 100), 0, 100, 0, 255);
DEBUG_ECHOLNPGM("FAN value change:", *(uint8_t*)var.memadr);
}
}
// 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;
value /= 10;
float valuesend = 0;
switch (var.VP) {
default: return;
#if HAS_HOTEND
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 HAS_MULTI_HOTEND
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();
char buf[22];
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();
char buf[10];
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
void DGUSScreenHandler::DGUSLCD_SendFanStatusToDisplay(DGUS_VP_Variable &var) {
if (var.memadr) {
DEBUG_ECHOPGM(" DGUSLCD_SendFanStatusToDisplay ", var.VP);
DEBUG_ECHOLNPGM(" 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);
}
}
#endif
// Send heater status value to the display.
void DGUSScreenHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var) {
if (var.memadr) {
DEBUG_ECHOPGM(" DGUSLCD_SendHeaterStatusToDisplay ", var.VP);
DEBUG_ECHOLNPGM(" 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)
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_ECHOPGM(" DGUSLCD_SendWaitingStatusToDisplay ", var.VP);
//DEBUG_ECHOLNPGM(" data ", swap16(index));
if (period++ > DGUS_UI_WAITING_STATUS_PERIOD) {
dgusdisplay.WriteVariable(var.VP, index);
//DEBUG_ECHOLNPGM(" data ", swap16(index));
if (++index >= DGUS_UI_WAITING_STATUS) index = 0;
period = 0;
}
}
#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_ECHOPGM("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_ECHOPGM("new topfile adjusted:", top_file);
}
else if (!filelist.isAtRootDir()) {
IF_DISABLED(DGUS_LCD_UI_MKS, filelist.upDir());
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();
sendinfoscreen(F("NOTICE"), nullptr, F("SD card error"), nullptr, true, true, true, true);
SetupConfirmAction(nullptr);
GotoScreen(DGUSLCD_SCREEN_POPUP);
}
#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;
while ((ret = (uint16_t*) pgm_read_ptr(&(map->VPList)))) {
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_ECHOLNPGM("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();
ForceCompleteUpdate(); // hint to send all data.
}
void DGUSScreenHandler::HandleTemperatureChanged(DGUS_VP_Variable &var, void *val_ptr) {
celsius_t newvalue = swap16(*(uint16_t*)val_ptr);
celsius_t acceptedvalue;
switch (var.VP) {
default: return;
#if HAS_HOTEND
case VP_T_E0_Set:
NOMORE(newvalue, HEATER_0_MAXTEMP);
thermalManager.setTargetHotend(newvalue, 0);
acceptedvalue = thermalManager.degTargetHotend(0);
break;
#endif
#if HAS_MULTI_HOTEND
case VP_T_E1_Set:
NOMORE(newvalue, HEATER_1_MAXTEMP);
thermalManager.setTargetHotend(newvalue, 1);
acceptedvalue = thermalManager.degTargetHotend(1);
break;
#endif
#if HAS_HEATED_BED
case VP_T_Bed_Set:
NOMORE(newvalue, BED_MAXTEMP);
thermalManager.setTargetBed(newvalue);
acceptedvalue = thermalManager.degTargetBed();
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);
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
}
void DGUSScreenHandler::HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_ptr) {
#if HAS_EXTRUDERS
uint16_t newvalue = swap16(*(uint16_t*)val_ptr);
uint8_t target_extruder;
switch (var.VP) {
default: return;
case VP_Flowrate_E0: target_extruder = 0; break;
#if HAS_MULTI_EXTRUDER
case VP_Flowrate_E1: target_extruder = 1; break;
#endif
}
planner.set_flow(target_extruder, newvalue);
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
#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 HAS_HOTEND
case VP_MOVE_E0: target_extruder = ExtUI::extruder_t::E0; break;
#if HAS_MULTI_EXTRUDER
case VP_MOVE_E1: target_extruder = ExtUI::extruder_t::E1; break;
#endif
#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");
const int16_t lock = swap16(*(uint16_t*)val_ptr);
queue.enqueue_one_now(lock ? F("M18") : F("M17"));
}
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());
settings.reset();
settings.save();
break;
case 2: settings.load(); break;
case 3: settings.save(); break;
}
}
void DGUSScreenHandler::HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("HandleStepPerMMChanged");
uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
DEBUG_ECHOLNPGM("value_raw:", value_raw);
float value = (float)value_raw / 10;
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_ECHOLNPGM("value:", value);
ExtUI::setAxisSteps_per_mm(value, axis);
DEBUG_ECHOLNPGM("value_set:", ExtUI::getAxisSteps_per_mm(axis));
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
return;
}
void DGUSScreenHandler::HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("HandleStepPerMMExtruderChanged");
uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
DEBUG_ECHOLNPGM("value_raw:", value_raw);
float value = (float)value_raw / 10;
ExtUI::extruder_t extruder;
switch (var.VP) {
default: return;
#if HAS_EXTRUDERS
case VP_E0_STEP_PER_MM: extruder = ExtUI::extruder_t::E0; break;
#if HAS_MULTI_EXTRUDER
case VP_E1_STEP_PER_MM: extruder = ExtUI::extruder_t::E1; break;
#endif
#endif
}
DEBUG_ECHOLNPGM("value:", value);
ExtUI::setAxisSteps_per_mm(value, extruder);
DEBUG_ECHOLNPGM("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
}
#if HAS_PID_HEATING
void DGUSScreenHandler::HandlePIDAutotune(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("HandlePIDAutotune");
char buf[32] = {0};
switch (var.VP) {
default: break;
#if ENABLED(PIDTEMP)
#if HAS_HOTEND
case VP_PID_AUTOTUNE_E0: // Autotune Extruder 0
sprintf_P(buf, PSTR("M303 E%d C5 S210 U1"), ExtUI::extruder_t::E0);
queue.enqueue_one_now(buf);
break;
#endif
#if HAS_MULTI_HOTEND
case VP_PID_AUTOTUNE_E1:
sprintf_P(buf, PSTR("M303 E%d C5 S210 U1"), ExtUI::extruder_t::E1);
queue.enqueue_one_now(buf);
break;
#endif
#endif
#if ENABLED(PIDTEMPBED)
case VP_PID_AUTOTUNE_BED:
queue.enqueue_one_now(F("M303 E-1 C5 S70 U1"));
break;
#endif
}
#if ENABLED(DGUS_UI_WAITING)
sendinfoscreen(F("PID is autotuning"), F("please wait"), NUL_STR, NUL_STR, true, true, true, true);
GotoScreen(DGUSLCD_SCREEN_WAITING);
#endif
}
#endif // HAS_PID_HEATING
#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);
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
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 HAS_HOTEND
case VP_E0_CONTROL:
#if HAS_MULTI_HOTEND
case VP_E1_CONTROL:
#if HOTENDS >= 3
case VP_E2_CONTROL:
#endif
#endif
preheat_temp = PREHEAT_1_TEMP_HOTEND;
break;
#endif
#if HAS_HEATED_BED
case VP_BED_CONTROL:
preheat_temp = PREHEAT_1_TEMP_BED;
break;
#endif
}
*(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");
const uint16_t preheat_option = swap16(*(uint16_t*)val_ptr);
switch (preheat_option) {
default:
switch (var.VP) {
default: return;
case VP_E0_BED_PREHEAT: TERN_(HAS_HOTEND, ui.preheat_all(0)); break;
#if DISABLED(DGUS_LCD_UI_HIPRECY) && HAS_MULTI_HOTEND
case VP_E1_BED_PREHEAT: ui.preheat_all(1); break;
#endif
}
case 7: break; // Custom preheat
case 9: thermalManager.cooldown(); break; // Cool down
}
// Go to the preheat screen to show the heating progress
GotoScreen(DGUSLCD_SCREEN_PREHEAT);
}
#endif // DGUS_PREHEAT_UI
#if ENABLED(POWER_LOSS_RECOVERY)
void DGUSScreenHandler::HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr) {
uint16_t value = swap16(*(uint16_t*)val_ptr);
if (value) {
queue.inject(F("M1000"));
dgusdisplay.WriteVariable(VP_SD_Print_Filename, filelist.filename(), 32, true);
GotoScreen(PLR_SCREEN_RECOVER);
}
else {
recovery.cancel();
GotoScreen(PLR_SCREEN_CANCEL);
}
}
#endif
void DGUSScreenHandler::UpdateNewScreen(DGUSLCD_Screens newscreen, bool popup) {
DEBUG_ECHOLNPGM("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_ECHOLNPGM("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_ECHOPGM(" UpdateScreenVPData Screen: ", current_screen);
const uint16_t *VPList = DGUSLCD_FindScreenVPMapList(current_screen);
if (!VPList) {
DEBUG_ECHOLNPGM(" NO SCREEN FOR: ", current_screen);
ScreenComplete = true;
return; // nothing to do, likely a bug or boring screen.
}
// Round-robin updating of all VPs.
VPList += update_ptr;
bool sent_one = false;
do {
uint16_t VP = pgm_read_word(VPList);
DEBUG_ECHOPGM(" VP: ", VP);
if (!VP) {
update_ptr = 0;
DEBUG_ECHOLNPGM(" UpdateScreenVPData done");
ScreenComplete = true;
return; // Screen completed.
}
if (VP == skipVP) { skipVP = 0; continue; }
DGUS_VP_Variable rcpy;
if (populate_VPVar(VP, &rcpy)) {
uint8_t expected_tx = 6 + rcpy.size; // expected overhead is 6 bytes + payload.
// 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_ECHOPGM(" calling handler for ", rcpy.VP);
sent_one = true;
rcpy.send_to_display_handler(rcpy);
}
else {
// auto x=dgusdisplay.GetFreeTxBuffer();
//DEBUG_ECHOLNPGM(" tx almost full: ", x);
//DEBUG_ECHOPGM(" update_ptr ", update_ptr);
ScreenComplete = false;
return; // please call again!
}
}
} 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_ECHOLNPGM("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_CLASSIC

View File

@ -0,0 +1,73 @@
/**
* 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
/**
* lcd/extui/dgus/DGUSScreenHandler.h
*/
#include "../../../inc/MarlinConfigPre.h"
#include "../ui_api.h"
#if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
typedef struct {
ExtUI::extruder_t extruder; // which extruder to operate
uint8_t action; // load or unload
bool heated; // heating done ?
float purge_length; // the length to extrude before unload, prevent filament jam
} filament_data_t;
extern filament_data_t filament_data;
#endif
#if ENABLED(DGUS_LCD_UI_ORIGIN)
#include "origin/DGUSScreenHandler.h"
#elif ENABLED(DGUS_LCD_UI_MKS)
#include "mks/DGUSScreenHandler.h"
#elif ENABLED(DGUS_LCD_UI_FYSETC)
#include "fysetc/DGUSScreenHandler.h"
#elif ENABLED(DGUS_LCD_UI_HIPRECY)
#include "hiprecy/DGUSScreenHandler.h"
#endif
extern DGUSScreenHandlerClass ScreenHandler;
// 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 size of the var cannot be determined automatically (e.g., 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 \
}

View File

@ -0,0 +1,241 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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 specifying whether the strings are in RAM or FLASH.
static void sendinfoscreen(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) {
sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash);
}
static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) {
sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash);
}
static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const 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 on the Confirm screen.
static void ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr);
// Update data after going to a new screen (by display or by GotoScreen)
// remember to store the last-displayed screen so it can be restored.
// (e.g., for popup 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 void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; }
// Has all VPs sent to the screen
static bool IsScreenComplete() { return ScreenComplete; }
static DGUSLCD_Screens getCurrentScreen() { return current_screen; }
static void SetupConfirmAction( void (*f)()) { confirm_action_cb = f; }
protected:
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)();
};

View File

@ -0,0 +1,49 @@
/**
* 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 <stdint.h>
/**
* DGUSVPVariable.h
*
* Created on: Feb 9, 2019
* Author: tobi
*/
struct DGUS_VP_Variable {
uint16_t VP;
void* memadr; // If nullptr, the value cannot be uploaded to the display.
uint8_t size;
// Callback that will be called if the display modified the value.
// nullptr makes it readonly for the display.
void (*set_by_display_handler)(DGUS_VP_Variable &var, void *val_ptr);
void (*send_to_display_handler)(DGUS_VP_Variable &var);
template<typename T>
DGUS_VP_Variable& operator =(T &o) {
*(T*)memadr = o; // warning this is not typesafe.
// TODO: Call out the display or mark as dirty for the next update.
return *this;
}
};

View File

@ -0,0 +1,163 @@
/**
* 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/>.
*
*/
/**
* lcd/extui/dgus/dgus_extui.cpp
*/
#include "../../../inc/MarlinConfigPre.h"
#if HAS_DGUS_LCD_CLASSIC
#include "../ui_api.h"
#include "DGUSDisplay.h"
#include "DGUSDisplayDef.h"
#include "DGUSScreenHandler.h"
namespace ExtUI {
void onStartup() {
dgusdisplay.InitDisplay();
ScreenHandler.UpdateScreenVPData();
}
void onIdle() { ScreenHandler.loop(); }
void onPrinterKilled(FSTR_P const error, FSTR_P const) {
ScreenHandler.sendinfoscreen(GET_TEXT_F(MSG_HALTED), error, FPSTR(NUL_STR), GET_TEXT_F(MSG_PLEASE_RESET), true, true, true, true);
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) {}
void onPrintTimerStarted() {}
void onPrintTimerPaused() {}
void onPrintTimerStopped() {}
void onFilamentRunout(const extruder_t extruder) {}
void onUserConfirmRequired(const char * const msg) {
if (msg) {
ScreenHandler.sendinfoscreen(F("Please confirm."), nullptr, msg, nullptr, true, true, false, true);
ScreenHandler.SetupConfirmAction(setUserConfirmed);
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_POPUP);
}
else if (ScreenHandler.getCurrentScreen() == DGUSLCD_SCREEN_POPUP) {
ScreenHandler.SetupConfirmAction(nullptr);
ScreenHandler.PopToOldScreen();
}
}
void onStatusChanged(const char * const msg) { ScreenHandler.setstatusmessage(msg); }
void onHomingStart() {}
void onHomingDone() {}
void onPrintDone() {}
void onFactoryReset() {}
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) <= 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) <= eeprom_data_size);
// memcpy(&myDataStruct, buff, sizeof(myDataStruct));
}
void onPostprocessSettings() {
// Called after loading or resetting stored settings
}
void onSettingsStored(bool success) {
// Called after the entire EEPROM has been written,
// whether successful or not.
}
void onSettingsLoaded(bool success) {
// Called after the entire EEPROM has been read,
// whether successful or not.
}
#if HAS_MESH
void onLevelingStart() {}
void onLevelingDone() {}
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) {
// Called when any mesh points are updated
}
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const probe_state_t state) {
// Called to indicate a special condition
}
#endif
#if ENABLED(POWER_LOSS_RECOVERY)
void onPowerLossResume() {
// Called on resume from power-loss
IF_DISABLED(DGUS_LCD_UI_MKS, 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_STARTED:
ScreenHandler.setstatusmessagePGM(GET_TEXT(MSG_PID_AUTOTUNE));
break;
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() {}
void onSteppersEnabled() {}
}
#endif // HAS_DGUS_LCD_CLASSIC

View File

@ -0,0 +1,478 @@
/**
* 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 VPs changed by George Fu in 2019 for Marlin */
#include "../../../../inc/MarlinConfigPre.h"
#if ENABLED(DGUS_LCD_UI_FYSETC)
#include "DGUSDisplayDef.h"
#include "../DGUSDisplay.h"
#include "../DGUSScreenHandler.h"
#include "../../../../module/temperature.h"
#include "../../../../module/motion.h"
#include "../../../../module/planner.h"
#include "../../ui_api.h"
#include "../../../marlinui.h"
#if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
uint16_t distanceToMove = 10;
#endif
const uint16_t VPList_Boot[] PROGMEM = {
VP_MARLIN_VERSION,
0x0000
};
const uint16_t VPList_Main[] PROGMEM = {
// VP_M117, for completeness, but it cannot be auto-uploaded.
#if HAS_HOTEND
VP_T_E0_Is, VP_T_E0_Set, VP_E0_STATUS,
#endif
#if HAS_MULTI_HOTEND
VP_T_E1_Is, VP_T_E1_Set,
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set, VP_BED_STATUS,
#endif
#if HAS_FAN
VP_Fan0_Percentage, VP_FAN0_STATUS,
#endif
VP_XPos, VP_YPos, VP_ZPos,
VP_Fan0_Percentage,
VP_Feedrate_Percentage,
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
VP_PrintProgress_Percentage,
#endif
0x0000
};
const uint16_t VPList_Temp[] PROGMEM = {
#if HAS_HOTEND
VP_T_E0_Is, VP_T_E0_Set,
#endif
#if HAS_MULTI_HOTEND
VP_T_E1_Is, VP_T_E1_Set,
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set,
#endif
0x0000
};
const uint16_t VPList_Status[] PROGMEM = {
// VP_M117, for completeness, but it cannot be auto-uploaded
#if HAS_HOTEND
VP_T_E0_Is, VP_T_E0_Set,
#endif
#if HAS_MULTI_HOTEND
VP_T_E1_Is, VP_T_E1_Set,
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set,
#endif
#if HAS_FAN
VP_Fan0_Percentage,
#endif
VP_XPos, VP_YPos, VP_ZPos,
VP_Fan0_Percentage,
VP_Feedrate_Percentage,
VP_PrintProgress_Percentage,
0x0000
};
const uint16_t VPList_Status2[] PROGMEM = {
// VP_M117, for completeness, but it cannot be auto-uploaded
#if HAS_HOTEND
VP_Flowrate_E0,
#if HAS_MULTI_EXTRUDER
VP_Flowrate_E1,
#endif
#endif
VP_PrintProgress_Percentage,
VP_PrintTime,
0x0000
};
const uint16_t VPList_Preheat[] PROGMEM = {
#if HAS_HOTEND
VP_T_E0_Is, VP_T_E0_Set,
#endif
#if HAS_MULTI_HOTEND
VP_T_E1_Is, VP_T_E1_Set,
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set,
#endif
0x0000
};
const uint16_t VPList_ManualMove[] PROGMEM = {
VP_XPos, VP_YPos, VP_ZPos,
0x0000
};
const uint16_t VPList_ManualExtrude[] PROGMEM = {
#if HAS_HOTEND
VP_T_E0_Is, VP_T_E0_Set,
#if HAS_MULTI_EXTRUDER
VP_T_E1_Is, VP_T_E1_Set,
#endif
#endif
VP_EPos,
0x0000
};
const uint16_t VPList_FanAndFeedrate[] PROGMEM = {
VP_Feedrate_Percentage, VP_Fan0_Percentage,
0x0000
};
const uint16_t VPList_SD_FlowRates[] PROGMEM = {
VP_Flowrate_E0, VP_Flowrate_E1,
0x0000
};
const uint16_t VPList_Filament_heating[] PROGMEM = {
#if HAS_HOTEND
VP_T_E0_Is, VP_T_E0_Set,
VP_E0_FILAMENT_LOAD_UNLOAD,
#if HAS_MULTI_EXTRUDER
VP_T_E1_Is, VP_T_E1_Set,
VP_E1_FILAMENT_LOAD_UNLOAD,
#endif
#endif
0x0000
};
const uint16_t VPList_Filament_load_unload[] PROGMEM = {
#if HAS_HOTEND
VP_E0_FILAMENT_LOAD_UNLOAD,
#if HAS_MULTI_EXTRUDER
VP_E1_FILAMENT_LOAD_UNLOAD,
#endif
#endif
0x0000
};
const uint16_t VPList_SDFileList[] PROGMEM = {
VP_SD_FileName0, VP_SD_FileName1, VP_SD_FileName2, VP_SD_FileName3, VP_SD_FileName4,
0x0000
};
const uint16_t VPList_SD_PrintManipulation[] PROGMEM = {
VP_PrintProgress_Percentage, VP_PrintTime,
#if HAS_HOTEND
VP_T_E0_Is, VP_T_E0_Set,
#endif
#if HAS_MULTI_HOTEND
VP_T_E1_Is, VP_T_E1_Set,
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set,
#endif
#if HAS_FAN
VP_Fan0_Percentage,
#if FAN_COUNT > 1
VP_Fan1_Percentage,
#endif
#endif
VP_Flowrate_E0,
0x0000
};
const uint16_t VPList_SDPrintTune[] PROGMEM = {
#if HAS_HOTEND
VP_T_E0_Is, VP_T_E0_Set, VP_Flowrate_E0,
#if HAS_MULTI_EXTRUDER
VP_T_E1_Is, VP_T_E1_Set, VP_Flowrate_E1, // ERROR: Flowrate is per-extruder, not per-hotend
#endif
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set,
#endif
VP_Feedrate_Percentage,
VP_SD_Print_ProbeOffsetZ,
0x0000
};
const uint16_t VPList_StepPerMM[] PROGMEM = {
VP_X_STEP_PER_MM,
VP_Y_STEP_PER_MM,
VP_Z_STEP_PER_MM,
#if HAS_EXTRUDERS
VP_E0_STEP_PER_MM,
#if HAS_MULTI_EXTRUDER
VP_E1_STEP_PER_MM,
#endif
#endif
0x0000
};
const uint16_t VPList_PIDE0[] PROGMEM = {
#if ENABLED(PIDTEMP)
VP_E0_PID_P,
VP_E0_PID_I,
VP_E0_PID_D,
#endif
0x0000
};
const uint16_t VPList_PIDBED[] PROGMEM = {
#if ENABLED(PIDTEMP)
VP_BED_PID_P,
VP_BED_PID_I,
VP_BED_PID_D,
#endif
0x0000
};
const uint16_t VPList_Infos[] PROGMEM = {
VP_MARLIN_VERSION,
VP_PrintTime,
#if ENABLED(PRINTCOUNTER)
VP_PrintAccTime,
VP_PrintsTotal,
#endif
0x0000
};
const uint16_t VPList_PIDTuningWaiting[] PROGMEM = {
VP_WAITING_STATUS,
0x0000
};
const uint16_t VPList_FLCPreheat[] PROGMEM = {
#if HAS_HOTEND
VP_T_E0_Is, VP_T_E0_Set,
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set,
#endif
0x0000
};
const uint16_t VPList_FLCPrinting[] PROGMEM = {
#if HAS_HOTEND
VP_SD_Print_ProbeOffsetZ,
#endif
0x0000
};
const uint16_t VPList_Z_Offset[] PROGMEM = {
#if HAS_HOTEND
VP_SD_Print_ProbeOffsetZ,
#endif
0x0000
};
const struct VPMapping VPMap[] PROGMEM = {
{ DGUSLCD_SCREEN_BOOT, VPList_Boot },
{ DGUSLCD_SCREEN_MAIN, VPList_Main },
{ DGUSLCD_SCREEN_TEMPERATURE, VPList_Temp },
{ DGUSLCD_SCREEN_STATUS, VPList_Status },
{ DGUSLCD_SCREEN_STATUS2, VPList_Status2 },
{ DGUSLCD_SCREEN_PREHEAT, VPList_Preheat },
{ DGUSLCD_SCREEN_MANUALMOVE, VPList_ManualMove },
{ DGUSLCD_SCREEN_MANUALEXTRUDE, VPList_ManualExtrude },
{ DGUSLCD_SCREEN_FILAMENT_HEATING, VPList_Filament_heating },
{ DGUSLCD_SCREEN_FILAMENT_LOADING, VPList_Filament_load_unload },
{ DGUSLCD_SCREEN_FILAMENT_UNLOADING, VPList_Filament_load_unload },
{ DGUSLCD_SCREEN_SDPRINTMANIPULATION, VPList_SD_PrintManipulation },
{ DGUSLCD_SCREEN_SDFILELIST, VPList_SDFileList },
{ DGUSLCD_SCREEN_SDPRINTTUNE, VPList_SDPrintTune },
{ DGUSLCD_SCREEN_WAITING, VPList_PIDTuningWaiting },
{ DGUSLCD_SCREEN_FLC_PREHEAT, VPList_FLCPreheat },
{ DGUSLCD_SCREEN_FLC_PRINTING, VPList_FLCPrinting },
{ DGUSLCD_SCREEN_Z_OFFSET, VPList_Z_Offset },
{ DGUSLCD_SCREEN_STEPPERMM, VPList_StepPerMM },
{ DGUSLCD_SCREEN_PID_E, VPList_PIDE0 },
{ DGUSLCD_SCREEN_PID_BED, VPList_PIDBED },
{ DGUSLCD_SCREEN_INFOS, VPList_Infos },
{ 0 , nullptr } // List is terminated with an nullptr as table entry.
};
const char MarlinVersion[] PROGMEM = SHORT_BUILD_VERSION;
const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
// Helper to detect touch events
VPHELPER(VP_SCREENCHANGE, nullptr, ScreenHandler.ScreenChangeHook, nullptr),
VPHELPER(VP_SCREENCHANGE_ASK, nullptr, ScreenHandler.ScreenChangeHookIfIdle, nullptr),
#if ENABLED(SDSUPPORT)
VPHELPER(VP_SCREENCHANGE_WHENSD, nullptr, ScreenHandler.ScreenChangeHookIfSD, nullptr),
#endif
VPHELPER(VP_CONFIRMED, nullptr, ScreenHandler.ScreenConfirmedOK, nullptr),
VPHELPER(VP_TEMP_ALL_OFF, nullptr, ScreenHandler.HandleAllHeatersOff, nullptr),
#if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
VPHELPER(VP_MOVE_OPTION, &distanceToMove, ScreenHandler.HandleManualMoveOption, nullptr),
#endif
#if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
VPHELPER(VP_MOVE_X, &distanceToMove, ScreenHandler.HandleManualMove, nullptr),
VPHELPER(VP_MOVE_Y, &distanceToMove, ScreenHandler.HandleManualMove, nullptr),
VPHELPER(VP_MOVE_Z, &distanceToMove, ScreenHandler.HandleManualMove, nullptr),
VPHELPER(VP_HOME_ALL, &distanceToMove, ScreenHandler.HandleManualMove, nullptr),
#else
VPHELPER(VP_MOVE_X, nullptr, ScreenHandler.HandleManualMove, nullptr),
VPHELPER(VP_MOVE_Y, nullptr, ScreenHandler.HandleManualMove, nullptr),
VPHELPER(VP_MOVE_Z, nullptr, ScreenHandler.HandleManualMove, nullptr),
VPHELPER(VP_HOME_ALL, nullptr, ScreenHandler.HandleManualMove, nullptr),
#endif
VPHELPER(VP_MOTOR_LOCK_UNLOK, nullptr, ScreenHandler.HandleMotorLockUnlock, nullptr),
#if ENABLED(POWER_LOSS_RECOVERY)
VPHELPER(VP_POWER_LOSS_RECOVERY, nullptr, ScreenHandler.HandlePowerLossRecovery, nullptr),
#endif
VPHELPER(VP_SETTINGS, nullptr, ScreenHandler.HandleSettings, nullptr),
#if ENABLED(SINGLE_Z_CALIBRATION)
VPHELPER(VP_Z_CALIBRATE, nullptr, ScreenHandler.HandleZCalibration, nullptr),
#endif
#if ENABLED(FIRST_LAYER_CAL)
VPHELPER(VP_Z_FIRST_LAYER_CAL, nullptr, ScreenHandler.HandleFirstLayerCal, nullptr),
#endif
{ .VP = VP_MARLIN_VERSION, .memadr = (void*)MarlinVersion, .size = VP_MARLIN_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM },
// 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 },
// Temperature Data
#if HAS_HOTEND
VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>),
VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleTemperatureChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Flowrate_E0, &planner.flow_percentage[ExtUI::extruder_t::E0], ScreenHandler.HandleFlowRateChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_EPos, &destination.e, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
VPHELPER(VP_MOVE_E0, nullptr, ScreenHandler.HandleManualExtrude, nullptr),
VPHELPER(VP_E0_CONTROL, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleHeaterControl, nullptr),
VPHELPER(VP_E0_STATUS, &thermalManager.temp_hotend[0].target, nullptr, ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay),
#if ENABLED(DGUS_PREHEAT_UI)
VPHELPER(VP_E0_BED_PREHEAT, nullptr, ScreenHandler.HandlePreheat, nullptr),
#endif
#if ENABLED(PIDTEMP)
VPHELPER(VP_E0_PID_P, &thermalManager.temp_hotend[0].pid.Kp, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
VPHELPER(VP_E0_PID_I, &thermalManager.temp_hotend[0].pid.Ki, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
VPHELPER(VP_E0_PID_D, &thermalManager.temp_hotend[0].pid.Kd, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
VPHELPER(VP_PID_AUTOTUNE_E0, nullptr, ScreenHandler.HandlePIDAutotune, nullptr),
#endif
#if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
VPHELPER(VP_E0_FILAMENT_LOAD_UNLOAD, nullptr, ScreenHandler.HandleFilamentOption, ScreenHandler.HandleFilamentLoadUnload),
#endif
#endif
#if HAS_MULTI_HOTEND
VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>),
VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Flowrate_E1, &planner.flow_percentage[ExtUI::extruder_t::E1], ScreenHandler.HandleFlowRateChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay), // ERROR: Flow is per-extruder, not per-hotend
VPHELPER(VP_MOVE_E1, nullptr, ScreenHandler.HandleManualExtrude, nullptr),
VPHELPER(VP_E1_CONTROL, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleHeaterControl, nullptr),
VPHELPER(VP_E1_STATUS, &thermalManager.temp_hotend[1].target, nullptr, ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay),
#if ENABLED(PIDTEMP)
VPHELPER(VP_PID_AUTOTUNE_E1, nullptr, ScreenHandler.HandlePIDAutotune, nullptr),
#endif
VPHELPER(VP_E1_FILAMENT_LOAD_UNLOAD, nullptr, ScreenHandler.HandleFilamentOption, ScreenHandler.HandleFilamentLoadUnload),
#endif
#if HAS_HEATED_BED
VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, ScreenHandler.HandleHeaterControl, nullptr),
VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay),
#if ENABLED(PIDTEMPBED)
VPHELPER(VP_BED_PID_P, &thermalManager.temp_bed.pid.Kp, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
VPHELPER(VP_BED_PID_I, &thermalManager.temp_bed.pid.Ki, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
VPHELPER(VP_BED_PID_D, &thermalManager.temp_bed.pid.Kd, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
VPHELPER(VP_PID_AUTOTUNE_BED, nullptr, ScreenHandler.HandlePIDAutotune, nullptr),
#endif
#endif
// Fan Data
#if HAS_FAN
#define FAN_VPHELPER(N) \
VPHELPER(VP_Fan##N##_Percentage, &thermalManager.fan_speed[N], ScreenHandler.DGUSLCD_PercentageToUint8, ScreenHandler.DGUSLCD_SendPercentageToDisplay), \
VPHELPER(VP_FAN##N##_CONTROL, &thermalManager.fan_speed[N], ScreenHandler.HandleFanControl, nullptr), \
VPHELPER(VP_FAN##N##_STATUS, &thermalManager.fan_speed[N], nullptr, ScreenHandler.DGUSLCD_SendFanStatusToDisplay),
REPEAT(FAN_COUNT, FAN_VPHELPER)
#endif
// Feedrate
VPHELPER(VP_Feedrate_Percentage, &feedrate_percentage, ScreenHandler.DGUSLCD_SetValueDirectly<int16_t>, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
// Position Data
VPHELPER(VP_XPos, &current_position.x, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
VPHELPER(VP_YPos, &current_position.y, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
VPHELPER(VP_ZPos, &current_position.z, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
// Print Progress
VPHELPER(VP_PrintProgress_Percentage, nullptr, nullptr, ScreenHandler.DGUSLCD_SendPrintProgressToDisplay),
// Print Time
VPHELPER_STR(VP_PrintTime, nullptr, VP_PrintTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintTimeToDisplay),
#if ENABLED(PRINTCOUNTER)
VPHELPER_STR(VP_PrintAccTime, nullptr, VP_PrintAccTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintAccTimeToDisplay),
VPHELPER_STR(VP_PrintsTotal, nullptr, VP_PrintsTotal_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintsTotalToDisplay),
#endif
VPHELPER(VP_X_STEP_PER_MM, &planner.settings.axis_steps_per_mm[X_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
VPHELPER(VP_Y_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Y_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
VPHELPER(VP_Z_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Z_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
#if HAS_EXTRUDERS
VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
#if HAS_MULTI_EXTRUDER
VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
#endif
#endif
// SDCard File listing.
#if ENABLED(SDSUPPORT)
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(VP_SD_ResumePauseAbort, nullptr, ScreenHandler.DGUSLCD_SD_ResumePauseAbort, nullptr),
VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, ScreenHandler.DGUSLCD_SD_ReallyAbort, nullptr),
VPHELPER(VP_SD_Print_Setting, nullptr, ScreenHandler.DGUSLCD_SD_PrintTune, nullptr),
#if HAS_BED_PROBE
VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe.offset.z, ScreenHandler.HandleProbeOffsetZChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<2>),
#if ENABLED(BABYSTEPPING)
VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, ScreenHandler.HandleLiveAdjustZ, nullptr),
#endif
#endif
#endif
#if ENABLED(DGUS_UI_WAITING)
VPHELPER(VP_WAITING_STATUS, nullptr, nullptr, ScreenHandler.DGUSLCD_SendWaitingStatusToDisplay),
#endif
// Messages for the User, shared by the popup and the kill screen. They can't 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_FYSETC

View File

@ -0,0 +1,296 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "../DGUSDisplayDef.h"
enum DGUSLCD_Screens : uint8_t {
DGUSLCD_SCREEN_BOOT = 0,
DGUSLCD_SCREEN_MAIN = 1,
DGUSLCD_SCREEN_STATUS = 1,
DGUSLCD_SCREEN_STATUS2 = 1,
DGUSLCD_SCREEN_TEMPERATURE = 10,
DGUSLCD_SCREEN_PREHEAT = 18,
DGUSLCD_SCREEN_POWER_LOSS = 100,
DGUSLCD_SCREEN_MANUALMOVE = 192,
DGUSLCD_SCREEN_UTILITY = 120,
DGUSLCD_SCREEN_FILAMENT_HEATING = 146,
DGUSLCD_SCREEN_FILAMENT_LOADING = 148,
DGUSLCD_SCREEN_FILAMENT_UNLOADING = 158,
DGUSLCD_SCREEN_MANUALEXTRUDE = 160,
DGUSLCD_SCREEN_SDFILELIST = 71,
DGUSLCD_SCREEN_SDPRINTMANIPULATION = 73,
DGUSLCD_SCREEN_SDPRINTTUNE = 75,
DGUSLCD_SCREEN_FLC_PREHEAT = 94,
DGUSLCD_SCREEN_FLC_PRINTING = 96,
DGUSLCD_SCREEN_STEPPERMM = 212,
DGUSLCD_SCREEN_PID_E = 214,
DGUSLCD_SCREEN_PID_BED = 218,
DGUSLCD_SCREEN_Z_OFFSET = 222,
DGUSLCD_SCREEN_INFOS = 36,
DGUSLCD_SCREEN_CONFIRM = 240,
DGUSLCD_SCREEN_KILL = 250, ///< Kill Screen. Must always be 250 (to be able to display "Error wrong LCD Version")
DGUSLCD_SCREEN_WAITING = 251,
DGUSLCD_SCREEN_POPUP = 252, ///< special target, popup screen will also return this code to say "return to previous screen"
DGUSLCD_SCREEN_UNUSED = 255
};
// 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.
// Storage space for the Killscreen messages. 0x1100 - 0x1200 . Reused for the popup.
constexpr uint16_t VP_MSGSTR1 = 0x1100;
constexpr uint8_t VP_MSGSTR1_LEN = 0x20; // might be more place for it...
constexpr uint16_t VP_MSGSTR2 = 0x1140;
constexpr uint8_t VP_MSGSTR2_LEN = 0x20;
constexpr uint16_t VP_MSGSTR3 = 0x1180;
constexpr uint8_t VP_MSGSTR3_LEN = 0x20;
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 = 0x2001; // 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 = 0x2010; // 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_PREHEAT = 0x2222;
//constexpr uint16_t VP_E2_BED_PREHEAT = 0x2224;
//constexpr uint16_t VP_E3_BED_PREHEAT = 0x2226;
//constexpr uint16_t VP_E4_BED_PREHEAT = 0x2228;
//constexpr uint16_t VP_E5_BED_PREHEAT = 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;
// Calibrate Z
constexpr uint16_t VP_Z_CALIBRATE = 0x2430;
// First layer cal
constexpr uint16_t VP_Z_FIRST_LAYER_CAL = 0x2500; // Data: 0 - Cancel first layer cal progress, >0 filament type have loaded
// Firmware version on the boot screen.
constexpr uint16_t VP_MARLIN_VERSION = 0x3000;
constexpr uint8_t VP_MARLIN_VERSION_LEN = 16; // there is more space on the display, if needed.
// Place for status messages.
constexpr uint16_t VP_M117 = 0x3020;
constexpr uint8_t VP_M117_LEN = 0x20;
// Temperatures.
constexpr uint16_t VP_T_E0_Is = 0x3060; // 4 Byte Integer
constexpr uint16_t VP_T_E0_Set = 0x3062; // 2 Byte Integer
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 = 0x3080; // 4 Byte Integer
constexpr uint16_t VP_T_Bed_Set = 0x3082; // 2 Byte Integer
constexpr uint16_t VP_Flowrate_E0 = 0x3090; // 2 Byte Integer
constexpr uint16_t VP_Flowrate_E1 = 0x3092; // 2 Byte Integer
// reserved for up to 6 Extruders:
//constexpr uint16_t VP_Flowrate_E2 = 0x3094;
//constexpr uint16_t VP_Flowrate_E3 = 0x3096;
//constexpr uint16_t VP_Flowrate_E4 = 0x3098;
//constexpr uint16_t VP_Flowrate_E5 = 0x309A;
constexpr uint16_t VP_Fan0_Percentage = 0x3100; // 2 Byte Integer (0..100)
constexpr uint16_t VP_Fan1_Percentage = 0x3102; // 2 Byte Integer (0..100)
constexpr uint16_t VP_Fan2_Percentage = 0x3104; // 2 Byte Integer (0..100)
constexpr uint16_t VP_Fan3_Percentage = 0x3106; // 2 Byte Integer (0..100)
constexpr uint16_t VP_Feedrate_Percentage = 0x3108; // 2 Byte Integer (0..100)
// Actual Position
constexpr uint16_t VP_XPos = 0x3110; // 4 Byte Fixed point number; format xxx.yy
constexpr uint16_t VP_YPos = 0x3112; // 4 Byte Fixed point number; format xxx.yy
constexpr uint16_t VP_ZPos = 0x3114; // 4 Byte Fixed point number; format xxx.yy
constexpr uint16_t VP_EPos = 0x3120; // 4 Byte Fixed point number; format xxx.yy
constexpr uint16_t VP_PrintProgress_Percentage = 0x3130; // 2 Byte Integer (0..100)
constexpr uint16_t VP_PrintTime = 0x3140;
constexpr uint16_t VP_PrintTime_LEN = 32;
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;
// SDCard File Listing
constexpr uint16_t VP_SD_FileName_LEN = 32; // LEN is shared for all entries.
constexpr uint16_t DGUS_SD_FILESPERSCREEN = 5; // FIXME move that info to the display and read it from there.
constexpr uint16_t VP_SD_FileName0 = 0x3200;
constexpr uint16_t VP_SD_FileName1 = 0x3220;
constexpr uint16_t VP_SD_FileName2 = 0x3240;
constexpr uint16_t VP_SD_FileName3 = 0x3260;
constexpr uint16_t VP_SD_FileName4 = 0x3280;
constexpr uint16_t VP_SD_Print_ProbeOffsetZ = 0x32A0; //
constexpr uint16_t VP_SD_Print_Filename = 0x32C0;
// 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_E1_PID_P = 0x3706; // at the moment , 2 byte unsigned int , 0~1638.4
constexpr uint16_t VP_E1_PID_I = 0x3708;
constexpr uint16_t VP_E1_PID_D = 0x370A;
constexpr uint16_t VP_BED_PID_P = 0x3710;
constexpr uint16_t VP_BED_PID_I = 0x3712;
constexpr uint16_t VP_BED_PID_D = 0x3714;
// Waiting 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;

View File

@ -0,0 +1,423 @@
/**
* 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_FYSETC)
#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)
extern ExtUI::FileList filelist;
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(DGUSLCD_SCREEN_SDPRINTMANIPULATION);
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_ECHOLNPGM("\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_ECHOLNPGM("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, don't 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_ECHOPGM(" homing ", AS_CHAR(axiscode));
char buf[6] = "G28 X";
buf[4] = axiscode;
//DEBUG_ECHOPGM(" ", buf);
queue.enqueue_one_now(buf);
//DEBUG_ECHOLNPGM(" ✓");
ForceCompleteUpdate();
return;
}
else {
// movement
DEBUG_ECHOPGM(" move ", AS_CHAR(axiscode));
bool old_relative_mode = relative_mode;
if (!relative_mode) {
//DEBUG_ECHOPGM(" G91");
queue.enqueue_now(F("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_ECHOPGM(" ", 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_ECHOPGM(" ", buf);
}
// while (!enqueue_and_echo_command(buf)) idle();
//DEBUG_ECHOLNPGM(" ✓ ");
if (!old_relative_mode) {
//DEBUG_ECHOPGM("G90");
queue.enqueue_now(F("G90"));
//DEBUG_ECHOPGM(" ✓ ");
}
}
ForceCompleteUpdate();
DEBUG_ECHOLNPGM("manmv done.");
return;
cannotmove:
DEBUG_ECHOLNPGM(" cannot move ", AS_CHAR(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_ECHOLNPGM("V1:", rawvalue);
float value = (float)rawvalue / 10;
DEBUG_ECHOLNPGM("V2:", value);
float newvalue = 0;
switch (var.VP) {
default: return;
#if HAS_HOTEND
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 HAS_MULTI_HOTEND
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_ECHOLNPGM("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 HAS_HOTEND
thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E0);
#if HAS_MULTI_HOTEND
thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E1);
#endif
#endif
GotoScreen(DGUSLCD_SCREEN_UTILITY);
}
else { // Go to the preheat screen to show the heating progress
switch (var.VP) {
default: return;
#if HAS_HOTEND
case VP_E0_FILAMENT_LOAD_UNLOAD:
filament_data.extruder = ExtUI::extruder_t::E0;
thermalManager.setTargetHotend(e_temp, filament_data.extruder);
break;
#endif
#if HAS_MULTI_HOTEND
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, BOOTSCREEN_TIMEOUT)) {
booted = true;
GotoScreen(TERN0(POWER_LOSS_RECOVERY, recovery.valid()) ? DGUSLCD_SCREEN_POWER_LOSS : DGUSLCD_SCREEN_MAIN);
}
#endif
return IsScreenComplete();
}
#endif // DGUS_LCD_UI_FYSETC

View File

@ -0,0 +1,31 @@
/**
* 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 "../DGUSScreenHandlerBase.h"
typedef DGUSScreenHandler DGUSScreenHandlerClass;
#if ENABLED(POWER_LOSS_RECOVERY)
#define PLR_SCREEN_RECOVER DGUSLCD_SCREEN_SDPRINTMANIPULATION
#define PLR_SCREEN_CANCEL DGUSLCD_SCREEN_STATUS
#endif

View File

@ -0,0 +1,471 @@
/**
* 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 VPs changed by George Fu in 2019 for Marlin */
#include "../../../../inc/MarlinConfigPre.h"
#if ENABLED(DGUS_LCD_UI_HIPRECY)
#include "DGUSDisplayDef.h"
#include "../DGUSDisplay.h"
#include "../DGUSScreenHandler.h"
#include "../../../../module/temperature.h"
#include "../../../../module/motion.h"
#include "../../../../module/planner.h"
#include "../../ui_api.h"
#include "../../../marlinui.h"
#if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
uint16_t distanceToMove = 10;
#endif
const uint16_t VPList_Boot[] PROGMEM = {
VP_MARLIN_VERSION,
0x0000
};
const uint16_t VPList_Main[] PROGMEM = {
// VP_M117, for completeness, but it cannot be auto-uploaded.
#if HAS_HOTEND
VP_T_E0_Is, VP_T_E0_Set, VP_E0_STATUS,
#if HAS_MULTI_HOTEND
VP_T_E1_Is, VP_T_E1_Set,
#endif
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set, VP_BED_STATUS,
#endif
#if HAS_FAN
VP_Fan0_Percentage, VP_FAN0_STATUS,
#endif
VP_XPos, VP_YPos, VP_ZPos,
VP_Fan0_Percentage,
VP_Feedrate_Percentage,
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
VP_PrintProgress_Percentage,
#endif
0x0000
};
const uint16_t VPList_Temp[] PROGMEM = {
#if HAS_HOTEND
VP_T_E0_Is, VP_T_E0_Set,
#if HAS_MULTI_HOTEND
VP_T_E1_Is, VP_T_E1_Set,
#endif
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set,
#endif
0x0000
};
const uint16_t VPList_Status[] PROGMEM = {
// VP_M117, for completeness, but it cannot be auto-uploaded
#if HAS_HOTEND
VP_T_E0_Is, VP_T_E0_Set,
#if HAS_MULTI_HOTEND
VP_T_E1_Is, VP_T_E1_Set,
#endif
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set,
#endif
#if HAS_FAN
VP_Fan0_Percentage,
#endif
VP_XPos, VP_YPos, VP_ZPos,
VP_Fan0_Percentage,
VP_Feedrate_Percentage,
VP_PrintProgress_Percentage,
0x0000
};
const uint16_t VPList_Status2[] PROGMEM = {
// VP_M117, for completeness, but it cannot be auto-uploaded
#if HAS_HOTEND
VP_Flowrate_E0,
#if HAS_MULTI_HOTEND
VP_Flowrate_E1,
#endif
#endif
VP_PrintProgress_Percentage,
VP_PrintTime,
0x0000
};
const uint16_t VPList_Preheat[] PROGMEM = {
#if HAS_HOTEND
VP_T_E0_Is, VP_T_E0_Set,
#if HAS_MULTI_HOTEND
VP_T_E1_Is, VP_T_E1_Set,
#endif
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set,
#endif
0x0000
};
const uint16_t VPList_ManualMove[] PROGMEM = {
VP_XPos, VP_YPos, VP_ZPos,
0x0000
};
const uint16_t VPList_ManualExtrude[] PROGMEM = {
#if HAS_HOTEND
VP_T_E0_Is, VP_T_E0_Set,
#if HAS_MULTI_HOTEND
VP_T_E1_Is, VP_T_E1_Set,
#endif
#endif
VP_EPos,
0x0000
};
const uint16_t VPList_FanAndFeedrate[] PROGMEM = {
VP_Feedrate_Percentage, VP_Fan0_Percentage,
0x0000
};
const uint16_t VPList_SD_FlowRates[] PROGMEM = {
VP_Flowrate_E0, VP_Flowrate_E1,
0x0000
};
const uint16_t VPList_Filament_heating[] PROGMEM = {
#if HAS_HOTEND
VP_T_E0_Is, VP_T_E0_Set,
VP_E0_FILAMENT_LOAD_UNLOAD,
#if HAS_MULTI_HOTEND
VP_T_E1_Is, VP_T_E1_Set,
#endif
#endif
0x0000
};
const uint16_t VPList_Filament_load_unload[] PROGMEM = {
#if HAS_HOTEND
VP_E0_FILAMENT_LOAD_UNLOAD,
#if HAS_MULTI_HOTEND
VP_E1_FILAMENT_LOAD_UNLOAD,
#endif
#endif
0x0000
};
const uint16_t VPList_SDFileList[] PROGMEM = {
VP_SD_FileName0, VP_SD_FileName1, VP_SD_FileName2, VP_SD_FileName3, VP_SD_FileName4,
0x0000
};
const uint16_t VPList_SD_PrintManipulation[] PROGMEM = {
VP_PrintProgress_Percentage, VP_PrintTime,
#if HAS_HOTEND
VP_T_E0_Is, VP_T_E0_Set,
#if HAS_MULTI_HOTEND
VP_T_E1_Is, VP_T_E1_Set,
#endif
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set,
#endif
#if HAS_FAN
VP_Fan0_Percentage,
#if FAN_COUNT > 1
VP_Fan1_Percentage,
#endif
#endif
VP_Flowrate_E0,
0x0000
};
const uint16_t VPList_SDPrintTune[] PROGMEM = {
#if HAS_HOTEND
VP_T_E0_Is, VP_T_E0_Set,
#if HAS_MULTI_HOTEND
VP_T_E1_Is, VP_T_E1_Set,
#endif
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set,
#endif
VP_Feedrate_Percentage,
#if HAS_FAN
VP_Fan0_Percentage,
#endif
VP_Flowrate_E0,
VP_SD_Print_ProbeOffsetZ,
0x0000
};
const uint16_t VPList_StepPerMM[] PROGMEM = {
VP_X_STEP_PER_MM,
VP_Y_STEP_PER_MM,
VP_Z_STEP_PER_MM,
OPTITEM(HAS_HOTEND, VP_E0_STEP_PER_MM)
OPTITEM(HAS_MULTI_HOTEND, VP_E1_STEP_PER_MM)
0x0000
};
const uint16_t VPList_PIDE0[] PROGMEM = {
#if ENABLED(PIDTEMP)
VP_E0_PID_P, VP_E0_PID_I, VP_E0_PID_D,
#endif
0x0000
};
const uint16_t VPList_PIDBED[] PROGMEM = {
#if ENABLED(PIDTEMP)
VP_BED_PID_P,
VP_BED_PID_I,
VP_BED_PID_D,
#endif
0x0000
};
const uint16_t VPList_Infos[] PROGMEM = {
VP_MARLIN_VERSION,
VP_PrintTime,
#if ENABLED(PRINTCOUNTER)
VP_PrintAccTime,
VP_PrintsTotal,
#endif
0x0000
};
const uint16_t VPList_PIDTuningWaiting[] PROGMEM = {
VP_WAITING_STATUS,
0x0000
};
const uint16_t VPList_FLCPreheat[] PROGMEM = {
#if HAS_HOTEND
VP_T_E0_Is, VP_T_E0_Set,
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set,
#endif
0x0000
};
const uint16_t VPList_FLCPrinting[] PROGMEM = {
#if HAS_HOTEND
VP_SD_Print_ProbeOffsetZ,
#endif
0x0000
};
const uint16_t VPList_Z_Offset[] PROGMEM = {
#if HAS_HOTEND
VP_SD_Print_ProbeOffsetZ,
#endif
0x0000
};
const struct VPMapping VPMap[] PROGMEM = {
{ DGUSLCD_SCREEN_BOOT, VPList_Boot },
{ DGUSLCD_SCREEN_MAIN, VPList_Main },
{ DGUSLCD_SCREEN_TEMPERATURE, VPList_Temp },
{ DGUSLCD_SCREEN_STATUS, VPList_Status },
{ DGUSLCD_SCREEN_STATUS2, VPList_Status2 },
{ DGUSLCD_SCREEN_PREHEAT, VPList_Preheat },
{ DGUSLCD_SCREEN_MANUALMOVE, VPList_ManualMove },
{ DGUSLCD_SCREEN_Z_OFFSET, VPList_Z_Offset },
{ DGUSLCD_SCREEN_MANUALEXTRUDE, VPList_ManualExtrude },
{ DGUSLCD_SCREEN_FILAMENT_HEATING, VPList_Filament_heating },
{ DGUSLCD_SCREEN_FILAMENT_LOADING, VPList_Filament_load_unload },
{ DGUSLCD_SCREEN_FILAMENT_UNLOADING, VPList_Filament_load_unload },
{ DGUSLCD_SCREEN_SDPRINTMANIPULATION, VPList_SD_PrintManipulation },
{ DGUSLCD_SCREEN_SDFILELIST, VPList_SDFileList },
{ DGUSLCD_SCREEN_SDPRINTTUNE, VPList_SDPrintTune },
{ DGUSLCD_SCREEN_WAITING, VPList_PIDTuningWaiting },
{ DGUSLCD_SCREEN_FLC_PREHEAT, VPList_FLCPreheat },
{ DGUSLCD_SCREEN_FLC_PRINTING, VPList_FLCPrinting },
{ DGUSLCD_SCREEN_STEPPERMM, VPList_StepPerMM },
{ DGUSLCD_SCREEN_PID_E, VPList_PIDE0 },
{ DGUSLCD_SCREEN_PID_BED, VPList_PIDBED },
{ DGUSLCD_SCREEN_INFOS, VPList_Infos },
{ 0 , nullptr } // List is terminated with an nullptr as table entry.
};
const char MarlinVersion[] PROGMEM = SHORT_BUILD_VERSION;
const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
// Helper to detect touch events
VPHELPER(VP_SCREENCHANGE, nullptr, ScreenHandler.ScreenChangeHook, nullptr),
VPHELPER(VP_SCREENCHANGE_ASK, nullptr, ScreenHandler.ScreenChangeHookIfIdle, nullptr),
#if ENABLED(SDSUPPORT)
VPHELPER(VP_SCREENCHANGE_WHENSD, nullptr, ScreenHandler.ScreenChangeHookIfSD, nullptr),
#endif
VPHELPER(VP_CONFIRMED, nullptr, ScreenHandler.ScreenConfirmedOK, nullptr),
VPHELPER(VP_TEMP_ALL_OFF, nullptr, ScreenHandler.HandleAllHeatersOff, nullptr),
#if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
VPHELPER(VP_MOVE_OPTION, &distanceToMove, ScreenHandler.HandleManualMoveOption, nullptr),
#endif
#if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
VPHELPER(VP_MOVE_X, &distanceToMove, ScreenHandler.HandleManualMove, nullptr),
VPHELPER(VP_MOVE_Y, &distanceToMove, ScreenHandler.HandleManualMove, nullptr),
VPHELPER(VP_MOVE_Z, &distanceToMove, ScreenHandler.HandleManualMove, nullptr),
VPHELPER(VP_HOME_ALL, &distanceToMove, ScreenHandler.HandleManualMove, nullptr),
#else
VPHELPER(VP_MOVE_X, nullptr, ScreenHandler.HandleManualMove, nullptr),
VPHELPER(VP_MOVE_Y, nullptr, ScreenHandler.HandleManualMove, nullptr),
VPHELPER(VP_MOVE_Z, nullptr, ScreenHandler.HandleManualMove, nullptr),
VPHELPER(VP_HOME_ALL, nullptr, ScreenHandler.HandleManualMove, nullptr),
#endif
VPHELPER(VP_MOTOR_LOCK_UNLOK, nullptr, ScreenHandler.HandleMotorLockUnlock, nullptr),
#if ENABLED(POWER_LOSS_RECOVERY)
VPHELPER(VP_POWER_LOSS_RECOVERY, nullptr, ScreenHandler.HandlePowerLossRecovery, nullptr),
#endif
VPHELPER(VP_SETTINGS, nullptr, ScreenHandler.HandleSettings, nullptr),
#if ENABLED(SINGLE_Z_CALIBRATION)
VPHELPER(VP_Z_CALIBRATE, nullptr, ScreenHandler.HandleZCalibration, nullptr),
#endif
#if ENABLED(FIRST_LAYER_CAL)
VPHELPER(VP_Z_FIRST_LAYER_CAL, nullptr, ScreenHandler.HandleFirstLayerCal, nullptr),
#endif
{ .VP = VP_MARLIN_VERSION, .memadr = (void*)MarlinVersion, .size = VP_MARLIN_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM },
// 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 },
// Temperature Data
#if HAS_HOTEND
VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>),
VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleTemperatureChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Flowrate_E0, &planner.flow_percentage[ExtUI::extruder_t::E0], ScreenHandler.HandleFlowRateChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_EPos, &destination.e, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
VPHELPER(VP_MOVE_E0, nullptr, ScreenHandler.HandleManualExtrude, nullptr),
VPHELPER(VP_E0_CONTROL, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleHeaterControl, nullptr),
VPHELPER(VP_E0_STATUS, &thermalManager.temp_hotend[0].target, nullptr, ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay),
#if ENABLED(DGUS_PREHEAT_UI)
VPHELPER(VP_E0_BED_PREHEAT, nullptr, ScreenHandler.HandlePreheat, nullptr),
#endif
#if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
VPHELPER(VP_E0_FILAMENT_LOAD_UNLOAD, nullptr, ScreenHandler.HandleFilamentOption, ScreenHandler.HandleFilamentLoadUnload),
#endif
#if ENABLED(PIDTEMP)
VPHELPER(VP_E0_PID_P, &thermalManager.temp_hotend[0].pid.Kp, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
VPHELPER(VP_E0_PID_I, &thermalManager.temp_hotend[0].pid.Ki, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
VPHELPER(VP_E0_PID_D, &thermalManager.temp_hotend[0].pid.Kd, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
VPHELPER(VP_PID_AUTOTUNE_E0, nullptr, ScreenHandler.HandlePIDAutotune, nullptr),
#endif
#endif
#if HAS_MULTI_HOTEND
VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>),
VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Flowrate_E1, nullptr, ScreenHandler.HandleFlowRateChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_MOVE_E1, nullptr, ScreenHandler.HandleManualExtrude, nullptr),
VPHELPER(VP_E1_CONTROL, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleHeaterControl, nullptr),
VPHELPER(VP_E1_STATUS, &thermalManager.temp_hotend[1].target, nullptr, ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay),
#endif
#if HAS_HEATED_BED
VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, ScreenHandler.HandleHeaterControl, nullptr),
VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay),
#if ENABLED(PIDTEMPBED)
VPHELPER(VP_BED_PID_P, &thermalManager.temp_bed.pid.Kp, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
VPHELPER(VP_BED_PID_I, &thermalManager.temp_bed.pid.Ki, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
VPHELPER(VP_BED_PID_D, &thermalManager.temp_bed.pid.Kd, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
VPHELPER(VP_PID_AUTOTUNE_BED, nullptr, ScreenHandler.HandlePIDAutotune, nullptr),
#endif
#endif
// Fan Data
#if HAS_FAN
#define FAN_VPHELPER(N) \
VPHELPER(VP_Fan##N##_Percentage, &thermalManager.fan_speed[N], ScreenHandler.DGUSLCD_PercentageToUint8, ScreenHandler.DGUSLCD_SendPercentageToDisplay), \
VPHELPER(VP_FAN##N##_CONTROL, &thermalManager.fan_speed[N], ScreenHandler.HandleFanControl, nullptr), \
VPHELPER(VP_FAN##N##_STATUS, &thermalManager.fan_speed[N], nullptr, ScreenHandler.DGUSLCD_SendFanStatusToDisplay),
REPEAT(FAN_COUNT, FAN_VPHELPER)
#endif
// Feedrate
VPHELPER(VP_Feedrate_Percentage, &feedrate_percentage, ScreenHandler.DGUSLCD_SetValueDirectly<int16_t>, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
// Position Data
VPHELPER(VP_XPos, &current_position.x, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
VPHELPER(VP_YPos, &current_position.y, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
VPHELPER(VP_ZPos, &current_position.z, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
// Print Progress
VPHELPER(VP_PrintProgress_Percentage, nullptr, nullptr, ScreenHandler.DGUSLCD_SendPrintProgressToDisplay),
// Print Time
VPHELPER_STR(VP_PrintTime, nullptr, VP_PrintTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintTimeToDisplay),
#if ENABLED(PRINTCOUNTER)
VPHELPER_STR(VP_PrintAccTime, nullptr, VP_PrintAccTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintAccTimeToDisplay),
VPHELPER_STR(VP_PrintsTotal, nullptr, VP_PrintsTotal_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintsTotalToDisplay),
#endif
VPHELPER(VP_X_STEP_PER_MM, &planner.settings.axis_steps_per_mm[X_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
VPHELPER(VP_Y_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Y_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
VPHELPER(VP_Z_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Z_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
#if HAS_HOTEND
VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
#if HAS_MULTI_HOTEND
VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
#endif
#endif
// SDCard File listing.
#if ENABLED(SDSUPPORT)
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(VP_SD_ResumePauseAbort, nullptr, ScreenHandler.DGUSLCD_SD_ResumePauseAbort, nullptr),
VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, ScreenHandler.DGUSLCD_SD_ReallyAbort, nullptr),
VPHELPER(VP_SD_Print_Setting, nullptr, ScreenHandler.DGUSLCD_SD_PrintTune, nullptr),
#if HAS_BED_PROBE
VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe.offset.z, ScreenHandler.HandleProbeOffsetZChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<2>),
#if ENABLED(BABYSTEPPING)
VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, ScreenHandler.HandleLiveAdjustZ, nullptr),
#endif
#endif
#endif
#if ENABLED(DGUS_UI_WAITING)
VPHELPER(VP_WAITING_STATUS, nullptr, nullptr, ScreenHandler.DGUSLCD_SendWaitingStatusToDisplay),
#endif
// Messages for the User, shared by the popup and the kill screen. They can't 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_HIPRECY

View File

@ -0,0 +1,292 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "../DGUSDisplayDef.h"
enum DGUSLCD_Screens : uint8_t {
DGUSLCD_SCREEN_BOOT = 160,
DGUSLCD_SCREEN_MAIN = 1,
DGUSLCD_SCREEN_STATUS = 1,
DGUSLCD_SCREEN_STATUS2 = 1,
DGUSLCD_SCREEN_POWER_LOSS = 17,
DGUSLCD_SCREEN_TEMPERATURE = 40,
DGUSLCD_SCREEN_MANUALMOVE = 86,
DGUSLCD_SCREEN_PREHEAT = 48,
DGUSLCD_SCREEN_UTILITY = 70,
DGUSLCD_SCREEN_FILAMENT_HEATING = 80,
DGUSLCD_SCREEN_FILAMENT_LOADING = 76,
DGUSLCD_SCREEN_FILAMENT_UNLOADING = 82,
DGUSLCD_SCREEN_MANUALEXTRUDE = 84,
DGUSLCD_SCREEN_Z_OFFSET = 88,
DGUSLCD_SCREEN_SDFILELIST = 3,
DGUSLCD_SCREEN_SDPRINTMANIPULATION = 7,
DGUSLCD_SCREEN_SDPRINTTUNE = 9,
DGUSLCD_SCREEN_FLC_PREHEAT = 94,
DGUSLCD_SCREEN_FLC_PRINTING = 96,
DGUSLCD_SCREEN_STEPPERMM = 122,
DGUSLCD_SCREEN_PID_E = 126,
DGUSLCD_SCREEN_PID_BED = 128,
DGUSLCD_SCREEN_INFOS = 131,
DGUSLCD_SCREEN_CONFIRM = 240,
DGUSLCD_SCREEN_KILL = 250, ///< Kill Screen. Must always be 250 (to be able to display "Error wrong LCD Version")
DGUSLCD_SCREEN_WAITING = 251,
DGUSLCD_SCREEN_POPUP = 252, ///< special target, popup screen will also return this code to say "return to previous screen"
DGUSLCD_SCREEN_UNUSED = 255
};
// 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.
// Storage space for the Killscreen messages. 0x1100 - 0x1200 . Reused for the popup.
constexpr uint16_t VP_MSGSTR1 = 0x1100;
constexpr uint8_t VP_MSGSTR1_LEN = 0x20; // might be more place for it...
constexpr uint16_t VP_MSGSTR2 = 0x1140;
constexpr uint8_t VP_MSGSTR2_LEN = 0x20;
constexpr uint16_t VP_MSGSTR3 = 0x1180;
constexpr uint8_t VP_MSGSTR3_LEN = 0x20;
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 = 0x2001; // 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 = 0x2010; // 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_PREHEAT = 0x2222;
//constexpr uint16_t VP_E2_BED_PREHEAT = 0x2224;
//constexpr uint16_t VP_E3_BED_PREHEAT = 0x2226;
//constexpr uint16_t VP_E4_BED_PREHEAT = 0x2228;
//constexpr uint16_t VP_E5_BED_PREHEAT = 0x222A;
// Filament load and unload
constexpr uint16_t VP_E0_FILAMENT_LOAD_UNLOAD = 0x2300;
// 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;
// Calibrate Z
constexpr uint16_t VP_Z_CALIBRATE = 0x2430;
// First layer cal
constexpr uint16_t VP_Z_FIRST_LAYER_CAL = 0x2500; // Data: 0 - Cancel first layer cal progress, >0 filament type have loaded
// Firmware version on the boot screen.
constexpr uint16_t VP_MARLIN_VERSION = 0x3000;
constexpr uint8_t VP_MARLIN_VERSION_LEN = 16; // there is more space on the display, if needed.
// Place for status messages.
constexpr uint16_t VP_M117 = 0x3020;
constexpr uint8_t VP_M117_LEN = 0x20;
// Temperatures.
constexpr uint16_t VP_T_E0_Is = 0x3060; // 4 Byte Integer
constexpr uint16_t VP_T_E0_Set = 0x3062; // 2 Byte Integer
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 = 0x3080; // 4 Byte Integer
constexpr uint16_t VP_T_Bed_Set = 0x3082; // 2 Byte Integer
constexpr uint16_t VP_Flowrate_E0 = 0x3090; // 2 Byte Integer
constexpr uint16_t VP_Flowrate_E1 = 0x3092; // 2 Byte Integer
// reserved for up to 6 Extruders:
//constexpr uint16_t VP_Flowrate_E2 = 0x3094;
//constexpr uint16_t VP_Flowrate_E3 = 0x3096;
//constexpr uint16_t VP_Flowrate_E4 = 0x3098;
//constexpr uint16_t VP_Flowrate_E5 = 0x309A;
constexpr uint16_t VP_Fan0_Percentage = 0x3100; // 2 Byte Integer (0..100)
constexpr uint16_t VP_Fan1_Percentage = 0x3102; // 2 Byte Integer (0..100)
constexpr uint16_t VP_Fan2_Percentage = 0x3104; // 2 Byte Integer (0..100)
constexpr uint16_t VP_Fan3_Percentage = 0x3106; // 2 Byte Integer (0..100)
constexpr uint16_t VP_Feedrate_Percentage = 0x3108; // 2 Byte Integer (0..100)
// Actual Position
constexpr uint16_t VP_XPos = 0x3110; // 4 Byte Fixed point number; format xxx.yy
constexpr uint16_t VP_YPos = 0x3112; // 4 Byte Fixed point number; format xxx.yy
constexpr uint16_t VP_ZPos = 0x3114; // 4 Byte Fixed point number; format xxx.yy
constexpr uint16_t VP_EPos = 0x3120; // 4 Byte Fixed point number; format xxx.yy
constexpr uint16_t VP_PrintProgress_Percentage = 0x3130; // 2 Byte Integer (0..100)
constexpr uint16_t VP_PrintTime = 0x3140;
constexpr uint16_t VP_PrintTime_LEN = 32;
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;
// SDCard File Listing
constexpr uint16_t VP_SD_FileName_LEN = 32; // LEN is shared for all entries.
constexpr uint16_t DGUS_SD_FILESPERSCREEN = 5; // FIXME move that info to the display and read it from there.
constexpr uint16_t VP_SD_FileName0 = 0x3200;
constexpr uint16_t VP_SD_FileName1 = 0x3220;
constexpr uint16_t VP_SD_FileName2 = 0x3240;
constexpr uint16_t VP_SD_FileName3 = 0x3260;
constexpr uint16_t VP_SD_FileName4 = 0x3280;
constexpr uint16_t VP_SD_Print_ProbeOffsetZ = 0x32A0; //
constexpr uint16_t VP_SD_Print_Filename = 0x32C0; //
// 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;
// Waiting 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;

View File

@ -0,0 +1,423 @@
/**
* 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_HIPRECY)
#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)
extern ExtUI::FileList filelist;
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_ECHOLNPGM("\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_ECHOLNPGM("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, don't 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_ECHOPGM(" homing ", AS_CHAR(axiscode));
char buf[6] = "G28 X";
buf[4] = axiscode;
//DEBUG_ECHOPGM(" ", buf);
queue.enqueue_one_now(buf);
//DEBUG_ECHOLNPGM(" ✓");
ForceCompleteUpdate();
return;
}
else {
// movement
DEBUG_ECHOPGM(" move ", AS_CHAR(axiscode));
bool old_relative_mode = relative_mode;
if (!relative_mode) {
//DEBUG_ECHOPGM(" G91");
queue.enqueue_now(F("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_ECHOPGM(" ", 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_ECHOPGM(" ", buf);
}
// while (!enqueue_and_echo_command(buf)) idle();
//DEBUG_ECHOLNPGM(" ✓ ");
if (!old_relative_mode) {
//DEBUG_ECHOPGM("G90");
queue.enqueue_now(F("G90"));
//DEBUG_ECHOPGM(" ✓ ");
}
}
ForceCompleteUpdate();
DEBUG_ECHOLNPGM("manmv done.");
return;
cannotmove:
DEBUG_ECHOLNPGM(" cannot move ", AS_CHAR(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_ECHOLNPGM("V1:", rawvalue);
float value = (float)rawvalue / 10;
DEBUG_ECHOLNPGM("V2:", value);
float newvalue = 0;
switch (var.VP) {
default: return;
#if HAS_HOTEND
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 HAS_MULTI_HOTEND
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_ECHOLNPGM("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 HAS_HOTEND
thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E0);
#if HAS_MULTI_HOTEND
thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E1);
#endif
#endif
GotoScreen(DGUSLCD_SCREEN_UTILITY);
}
else { // Go to the preheat screen to show the heating progress
switch (var.VP) {
default: return;
#if HAS_HOTEND
case VP_E0_FILAMENT_LOAD_UNLOAD:
filament_data.extruder = ExtUI::extruder_t::E0;
thermalManager.setTargetHotend(e_temp, filament_data.extruder);
break;
#endif
#if HAS_MULTI_HOTEND
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, BOOTSCREEN_TIMEOUT)) {
booted = true;
GotoScreen(TERN0(POWER_LOSS_RECOVERY, recovery.valid()) ? DGUSLCD_SCREEN_POWER_LOSS : DGUSLCD_SCREEN_MAIN);
}
#endif
return IsScreenComplete();
}
#endif // DGUS_LCD_UI_HIPRECY

View File

@ -0,0 +1,31 @@
/**
* 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 "../DGUSScreenHandlerBase.h"
typedef DGUSScreenHandler DGUSScreenHandlerClass;
#if ENABLED(POWER_LOSS_RECOVERY)
#define PLR_SCREEN_RECOVER DGUSLCD_SCREEN_SDPRINTMANIPULATION
#define PLR_SCREEN_CANCEL DGUSLCD_SCREEN_STATUS
#endif

View File

@ -0,0 +1,802 @@
/**
* 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_MKS)
#include "DGUSDisplayDef.h"
#include "../DGUSDisplay.h"
#include "../DGUSScreenHandler.h"
#include "../../../../module/temperature.h"
#include "../../../../module/motion.h"
#include "../../../../module/planner.h"
#include "../../ui_api.h"
#include "../../../marlinui.h"
#if HAS_STEALTHCHOP
#include "../../../../module/stepper/trinamic.h"
#endif
#if ENABLED(POWER_LOSS_RECOVERY)
#include "../../../../feature/powerloss.h"
#endif
#if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
uint16_t distanceToMove = 10;
#endif
uint16_t manualMoveStep = 1;
uint16_t distanceFilament = 10;
uint16_t filamentSpeed_mm_s = 25;
float ZOffset_distance = 0.1;
float mesh_adj_distance = 0.01;
float Z_distance = 0.1;
//struct { uint16_t h, m, s; } dgus_time;
//
// Persistent settings
//
xy_int_t mks_corner_offsets[5]; // Initialized by settings.load()
xyz_int_t mks_park_pos; // Initialized by settings.load()
celsius_t mks_min_extrusion_temp; // Initialized by settings.load()
void MKS_reset_settings() {
constexpr xy_int_t init_dgus_level_offsets[5] = {
{ 20, 20 }, { 20, 20 },
{ 20, 20 }, { 20, 20 },
{ X_CENTER, Y_CENTER }
};
mks_language_index = MKS_SimpleChinese;
COPY(mks_corner_offsets, init_dgus_level_offsets);
mks_park_pos.set(20, 20, 10);
mks_min_extrusion_temp = 0;
}
xyz_pos_t position_before_pause;
constexpr feedRate_t park_speed_xy = TERN(NOZZLE_PARK_FEATURE, NOZZLE_PARK_XY_FEEDRATE, 100),
park_speed_z = TERN(NOZZLE_PARK_FEATURE, NOZZLE_PARK_Z_FEEDRATE, 5);
void MKS_pause_print_move() {
queue.exhaust();
position_before_pause = current_position;
// Save the current position, the raise amount, and 'already raised'
TERN_(POWER_LOSS_RECOVERY, if (recovery.enabled) recovery.save(true, mks_park_pos.z, true));
destination.z = _MIN(current_position.z + mks_park_pos.z, Z_MAX_POS);
prepare_internal_move_to_destination(park_speed_z);
destination.set(X_MIN_POS + mks_park_pos.x, Y_MIN_POS + mks_park_pos.y);
prepare_internal_move_to_destination(park_speed_xy);
}
void MKS_resume_print_move() {
destination.set(position_before_pause.x, position_before_pause.y);
prepare_internal_move_to_destination(park_speed_xy);
destination.z = position_before_pause.z;
prepare_internal_move_to_destination(park_speed_z);
TERN_(POWER_LOSS_RECOVERY, if (recovery.enabled) recovery.save(true));
}
float z_offset_add = 0;
xyz_int_t tmc_step; // = { 0, 0, 0 }
uint16_t lcd_default_light = 50;
EX_FILAMENT_DEF ex_filament;
RUNOUT_MKS_DEF runout_mks;
NOZZLE_PARK_DEF nozzle_park_mks;
const uint16_t VPList_Boot[] PROGMEM = {
VP_MARLIN_VERSION,
0x0000
};
#define MKSLIST_E_ITEM(N) VP_T_E##N##_Is, VP_T_E##N##_Set,
const uint16_t VPList_Main[] PROGMEM = {
// VP_M117, for completeness, but it cannot be auto-uploaded.
#if HAS_HOTEND
MKSLIST_E_ITEM(0) VP_E0_STATUS,
#if HAS_MULTI_HOTEND
MKSLIST_E_ITEM(1) VP_E1_STATUS,
#endif
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set, VP_BED_STATUS,
#endif
#if HAS_FAN
VP_Fan0_Percentage, VP_FAN0_STATUS,
#endif
VP_XPos, VP_YPos, VP_ZPos,
VP_Fan0_Percentage,
VP_Feedrate_Percentage,
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
VP_PrintProgress_Percentage,
#endif
0x0000
};
const uint16_t MKSList_Home[] PROGMEM = {
// E Temp
REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
// HB Temp
VP_T_Bed_Is, VP_T_Bed_Set,
// FAN
VP_Fan0_Percentage,
// Language
// VP_HOME_Dis,
0x0000
};
const uint16_t MKSList_Setting[] PROGMEM = {
// E Temp
REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
// HB Temp
VP_T_Bed_Is, VP_T_Bed_Set,
// FAN
VP_Fan0_Percentage,
// Language
VP_Setting_Dis,
0x0000
};
const uint16_t MKSList_Tool[] PROGMEM = {
// E Temp
REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
// HB Temp
VP_T_Bed_Is, VP_T_Bed_Set,
// FAN
VP_Fan0_Percentage,
// Language
VP_Tool_Dis,
// LCD BLK
VP_LCD_BLK,
0x0000
};
const uint16_t MKSList_EXTRUE[] PROGMEM = {
// E Temp
REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
// HB Temp
VP_T_Bed_Is, VP_T_Bed_Set,
// FAN
VP_Fan0_Percentage,
VP_Filament_distance,
VP_Filament_speed,
0x0000
};
const uint16_t MKSList_LEVEL[] PROGMEM = {
// E Temp
REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
// HB Temp
VP_T_Bed_Is, VP_T_Bed_Set,
// FAN
VP_Fan0_Percentage,
0x0000
};
const uint16_t MKSList_MOVE[] PROGMEM = {
// E Temp
REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
// HB Temp
VP_T_Bed_Is, VP_T_Bed_Set,
// FAN
VP_Fan0_Percentage,
0x0000
};
const uint16_t MKSList_Print[] PROGMEM = {
// E Temp
REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
// HB Temp
VP_T_Bed_Is, VP_T_Bed_Set,
// FAN
VP_Fan0_Percentage,
// Print Percent
VP_PrintProgress_Percentage,
VP_PrintTime,
VP_Flowrate_E0,
VP_Flowrate_E1,
VP_Feedrate_Percentage,
VP_PrintTime_H,
VP_PrintTime_M,
VP_PrintTime_S,
VP_XPos,
VP_YPos,
VP_ZPos,
0x0000
};
const uint16_t MKSList_SD_File[] PROGMEM = {
VP_SD_FileName0, VP_SD_FileName1,
VP_SD_FileName2, VP_SD_FileName3,
VP_SD_FileName4, VP_SD_FileName5,
VP_SD_FileName6, VP_SD_FileName7,
VP_SD_FileName8, VP_SD_FileName9,
0x0000
};
const uint16_t MKSList_TempOnly[] PROGMEM = {
// E Temp
REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
// HB Temp
VP_T_Bed_Is, VP_T_Bed_Set,
// FAN
VP_Fan0_Percentage,
// LCD BLK
VP_LCD_BLK,
0x0000
};
const uint16_t MKSList_Pluse[] PROGMEM = {
// E Temp
REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
// HB Temp
VP_T_Bed_Is, VP_T_Bed_Set,
// FAN
VP_Fan0_Percentage,
// Pluse
VP_X_STEP_PER_MM,
VP_Y_STEP_PER_MM,
VP_Z_STEP_PER_MM,
VP_E0_STEP_PER_MM,
VP_E1_STEP_PER_MM,
0x0000
};
const uint16_t MKSList_MaxSpeed[] PROGMEM = {
// E Temp
REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
// HB Temp
VP_T_Bed_Is, VP_T_Bed_Set,
// FAN
VP_Fan0_Percentage,
// Pluse
VP_X_MAX_SPEED,
VP_Y_MAX_SPEED,
VP_Z_MAX_SPEED,
VP_E0_MAX_SPEED,
VP_E1_MAX_SPEED,
0x0000
};
const uint16_t MKSList_MaxAcc[] PROGMEM = {
// E Temp
REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
// HB Temp
VP_T_Bed_Is, VP_T_Bed_Set,
// FAN
VP_Fan0_Percentage,
// ACC
VP_ACC_SPEED,
VP_X_ACC_MAX_SPEED,
VP_Y_ACC_MAX_SPEED,
VP_Z_ACC_MAX_SPEED,
VP_E0_ACC_MAX_SPEED,
VP_E1_ACC_MAX_SPEED,
0x0000
};
const uint16_t MKSList_PID[] PROGMEM = {
// E Temp
REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
// HB Temp
VP_T_Bed_Is, VP_T_Bed_Set,
// FAN
VP_Fan0_Percentage,
// PID
VP_E0_PID_P,
VP_E0_PID_I,
VP_E0_PID_D,
0x0000
};
const uint16_t MKSList_Level_Point[] PROGMEM = {
// E Temp
REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
// HB Temp
VP_T_Bed_Is, VP_T_Bed_Set,
// FAN
VP_Fan0_Percentage,
// Level Point
VP_Level_Point_One_X,
VP_Level_Point_One_Y,
VP_Level_Point_Two_X,
VP_Level_Point_Two_Y,
VP_Level_Point_Three_X,
VP_Level_Point_Three_Y,
VP_Level_Point_Four_X,
VP_Level_Point_Four_Y,
VP_Level_Point_Five_X,
VP_Level_Point_Five_Y,
0x0000
};
const uint16_t MKSList_Level_PrintConfig[] PROGMEM = {
VP_T_E0_Set,
VP_T_E1_Set,
VP_T_Bed_Set,
VP_Flowrate_E0,
VP_Flowrate_E1,
VP_Fan0_Percentage,
VP_Feedrate_Percentage,
0x0000
};
const uint16_t MKSList_PrintPauseConfig[] PROGMEM = {
// E Temp
REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
// HB Temp
VP_T_Bed_Is, VP_T_Bed_Set,
VP_X_PARK_POS,
VP_Y_PARK_POS,
VP_Z_PARK_POS,
0x0000
};
const uint16_t MKSList_MotoConfig[] PROGMEM = {
// E Temp
REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
// HB Temp
VP_T_Bed_Is, VP_T_Bed_Set,
VP_TRAVEL_SPEED,
VP_FEEDRATE_MIN_SPEED,
VP_T_F_SPEED,
0x0000
};
const uint16_t MKSList_EX_Config[] PROGMEM = {
// E Temp
REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
// HB Temp
VP_T_Bed_Is, VP_T_Bed_Set,
VP_MIN_EX_T,VP_Min_EX_T_E,
0x0000
};
const uint16_t MKSTMC_Config[] PROGMEM = {
// E Temp
REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
// HB Temp
VP_T_Bed_Is, VP_T_Bed_Set,
VP_MIN_EX_T,
VP_TMC_X_STEP,
VP_TMC_Y_STEP,
VP_TMC_Z_STEP,
VP_TMC_X1_Current,
VP_TMC_Y1_Current,
VP_TMC_X_Current,
VP_TMC_Y_Current,
VP_TMC_Z_Current,
VP_TMC_E0_Current,
VP_TMC_E1_Current,
VP_TMC_Z1_Current,
0x0000
};
const uint16_t MKSAuto_Level[] PROGMEM = {
VP_MESH_LEVEL_POINT_DIS,
VP_ZPos,
0x0000
};
const uint16_t MKSOffset_Config[] PROGMEM = {
// E Temp
REPEAT(EXTRUDERS, MKSLIST_E_ITEM)
VP_OFFSET_X,
VP_OFFSET_Y,
VP_OFFSET_Z,
0x0000
};
const uint16_t MKSBabyStep[] PROGMEM = {
VP_ZOffset_DE_DIS,
0x0000
};
const uint16_t MKSList_About[] PROGMEM = {
// Marlin version
VP_MARLIN_VERSION,
// H43 Version
VP_MKS_H43_VERSION,
VP_MKS_H43_UpdataVERSION,
0x0000
};
// Page data updata
const struct VPMapping VPMap[] PROGMEM = {
{ MKSLCD_SCREEN_BOOT, VPList_Boot }, // Boot Page to show logo 0
{ MKSLCD_SCREEN_HOME, MKSList_Home }, // Home, Page 1
{ MKSLCD_SCREEN_SETTING, MKSList_Setting }, // Setting, Page 2
{ MKSLCD_SCREEM_TOOL, MKSList_Tool }, // Page 3
{ MKSLCD_SCREEN_EXTRUDE_P1, MKSList_EXTRUE }, // Page 4
{ MKSLCD_SCREEN_EXTRUDE_P2, MKSList_EXTRUE }, // Page 11
{ MKSLCD_PAUSE_SETTING_EX, MKSList_EXTRUE }, // Page 57
{ MKSLCD_PAUSE_SETTING_EX2, MKSList_EXTRUE }, // Page 61
{ MKSLCD_SCREEN_LEVEL, MKSList_LEVEL }, // Page 5
{ MKSLCD_SCREEN_MOVE, MKSList_MOVE }, // Page 6
{ MKSLCD_SCREEN_PRINT, MKSList_Print }, // Page 7
{ MKSLCD_SCREEN_PAUSE, MKSList_Print }, // Page 26
{ MKSLCD_SCREEN_CHOOSE_FILE, MKSList_SD_File }, // Page 15
{ MKSLCD_SCREEN_MOTOR_PLUSE, MKSList_Pluse }, // Page 51
{ MKSLCD_SCREEN_MOTOR_SPEED, MKSList_MaxSpeed }, // Page 55
{ MKSLCD_SCREEN_MOTOR_ACC_MAX, MKSList_MaxAcc }, // Page 53
{ MKSLCD_SCREEN_LEVEL_DATA, MKSList_Level_Point }, // Page 48
{ MKSLCD_PrintPause_SET, MKSList_PrintPauseConfig }, // Page 49
{ MKSLCD_FILAMENT_DATA, MKSList_SD_File }, // Page 50
{ MKSLCD_SCREEN_Config, MKSList_TempOnly }, // Page 46
{ MKSLCD_SCREEN_Config_MOTOR, MKSList_MotoConfig }, // Page 47
{ MKSLCD_PID, MKSList_PID }, // Page 56
{ MKSLCD_ABOUT, MKSList_About }, // Page 36
{ MKSLCD_SCREEN_PRINT_CONFIG, MKSList_Level_PrintConfig }, // Page 60
{ MKSLCD_SCREEN_EX_CONFIG, MKSList_EX_Config }, // Page 65
{ MKSLCD_SCREEN_TMC_Config, MKSTMC_Config }, // Page 70
{ MKSLCD_AUTO_LEVEL, MKSAuto_Level }, // Page 73
{ MKSLCD_Screen_Offset_Config, MKSOffset_Config }, // Page 30
{ MKSLCD_Screen_PMove, MKSList_MOVE }, // Page 64
{ MKSLCD_Screen_Baby, MKSBabyStep }, // Page 71
//{ MKSLCD_SCREEN_LEVEL_DATA, MKSList_SD_File},
//{ MKSLCD_SCREEN_HOME, VPList_Boot },
{ 0, nullptr } // List is terminated with an nullptr as table entry.
};
const char MarlinVersion[] PROGMEM = SHORT_BUILD_VERSION;
const char H43Version[] PROGMEM = "MKS H43_V1.30";
const char Updata_Time[] PROGMEM = STRING_DISTRIBUTION_DATE;
const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
// Helper to detect touch events
VPHELPER(VP_SCREENCHANGE, nullptr, ScreenHandler.ScreenChangeHook, nullptr),
VPHELPER(VP_SCREENCHANGE_ASK, nullptr, ScreenHandler.ScreenChangeHookIfIdle, nullptr),
#if ENABLED(SDSUPPORT)
VPHELPER(VP_SCREENCHANGE_WHENSD, nullptr, ScreenHandler.ScreenChangeHookIfSD, nullptr),
#endif
VPHELPER(VP_CONFIRMED, nullptr, ScreenHandler.ScreenConfirmedOK, nullptr),
// Back Button
VPHELPER(VP_BACK_PAGE, nullptr, ScreenHandler.ScreenBackChange, nullptr),
VPHELPER(VP_TEMP_ALL_OFF, nullptr, ScreenHandler.HandleAllHeatersOff, nullptr),
VPHELPER(VP_MOVE_X, nullptr, ScreenHandler.HandleManualMove, nullptr),
VPHELPER(VP_MOVE_Y, nullptr, ScreenHandler.HandleManualMove, nullptr),
VPHELPER(VP_MOVE_Z, nullptr, ScreenHandler.HandleManualMove, nullptr),
VPHELPER(VP_HOME_ALL, nullptr, ScreenHandler.HandleManualMove, nullptr),
VPHELPER(VP_X_HOME, nullptr, ScreenHandler.HandleManualMove, nullptr),
VPHELPER(VP_Y_HOME, nullptr, ScreenHandler.HandleManualMove, nullptr),
VPHELPER(VP_Z_HOME, nullptr, ScreenHandler.HandleManualMove, nullptr),
VPHELPER(VP_MOVE_DISTANCE, &manualMoveStep, ScreenHandler.GetManualMovestep, nullptr),
VPHELPER(VP_MOTOR_LOCK_UNLOK, nullptr, ScreenHandler.HandleManualMove, nullptr),
VPHELPER(VP_LEVEL_POINT, nullptr, ScreenHandler.ManualAssistLeveling, nullptr),
#if ENABLED(POWER_LOSS_RECOVERY)
VPHELPER(VP_POWER_LOSS_RECOVERY, nullptr, ScreenHandler.HandlePowerLossRecovery, nullptr),
#endif
VPHELPER(VP_SETTINGS, nullptr, ScreenHandler.HandleSettings, nullptr),
#if ENABLED(SINGLE_Z_CALIBRATION)
VPHELPER(VP_Z_CALIBRATE, nullptr, ScreenHandler.HandleZCalibration, nullptr),
#endif
#if ENABLED(FIRST_LAYER_CAL)
VPHELPER(VP_Z_FIRST_LAYER_CAL, nullptr, ScreenHandler.HandleFirstLayerCal, nullptr),
#endif
{.VP = VP_MARLIN_VERSION, .memadr = (void *)MarlinVersion, .size = VP_MARLIN_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM},
// 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},
{.VP = VP_MKS_H43_VERSION, .memadr = (void *)H43Version, .size = VP_MKS_H43_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM},
{.VP = VP_MKS_H43_UpdataVERSION, .memadr = (void *)Updata_Time, .size = VP_MKS_H43_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM},
// Temperature Data
#if HAS_HOTEND
VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>),
VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleTemperatureChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Flowrate_E0, &planner.flow_percentage[ExtUI::extruder_t::E0], ScreenHandler.HandleFlowRateChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_EPos, &destination.e, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
VPHELPER(VP_MOVE_E0, nullptr, ScreenHandler.HandleManualExtrude, nullptr),
VPHELPER(VP_E0_CONTROL, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleHeaterControl, nullptr),
VPHELPER(VP_E0_STATUS, &thermalManager.temp_hotend[0].target, nullptr, ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay),
#if ENABLED(DGUS_PREHEAT_UI)
VPHELPER(VP_E0_BED_PREHEAT, nullptr, ScreenHandler.HandlePreheat, nullptr),
#endif
#if ENABLED(PIDTEMP)
VPHELPER(VP_E0_PID_P, &thermalManager.temp_hotend[0].pid.Kp, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
VPHELPER(VP_E0_PID_I, &thermalManager.temp_hotend[0].pid.Ki, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
VPHELPER(VP_E0_PID_D, &thermalManager.temp_hotend[0].pid.Kd, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
VPHELPER(VP_PID_AUTOTUNE_E0, nullptr, ScreenHandler.HandlePIDAutotune, nullptr),
#endif
#if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
VPHELPER(VP_LOAD_Filament, nullptr, ScreenHandler.FilamentLoad, nullptr),
VPHELPER(VP_UNLOAD_Filament, nullptr, ScreenHandler.FilamentUnLoad, nullptr),
VPHELPER(VP_Filament_distance, &distanceFilament, ScreenHandler.GetManualFilament, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Filament_speed, &filamentSpeed_mm_s, ScreenHandler.GetManualFilamentSpeed, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#endif
#endif
#if HAS_MULTI_HOTEND
VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>),
VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Flowrate_E1, &planner.flow_percentage[ExtUI::extruder_t::E1], ScreenHandler.HandleFlowRateChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_MOVE_E1, nullptr, ScreenHandler.HandleManualExtrude, nullptr),
VPHELPER(VP_E1_CONTROL, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleHeaterControl, nullptr),
VPHELPER(VP_E1_STATUS, &thermalManager.temp_hotend[1].target, nullptr, ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay),
#if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
VPHELPER(VP_Filament_distance, &distanceFilament, ScreenHandler.GetManualFilament, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_Filament_speed, &filamentSpeed_mm_s, ScreenHandler.GetManualFilamentSpeed, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#endif
#if ENABLED(PIDTEMP)
VPHELPER(VP_PID_AUTOTUNE_E1, nullptr, ScreenHandler.HandlePIDAutotune, nullptr),
#endif
VPHELPER(VP_E1_FILAMENT_LOAD_UNLOAD, nullptr, ScreenHandler.HandleFilamentOption, ScreenHandler.HandleFilamentLoadUnload),
#endif
#if HAS_HEATED_BED
VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>),
VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, ScreenHandler.HandleHeaterControl, nullptr),
VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay),
#if ENABLED(PIDTEMPBED)
VPHELPER(VP_BED_PID_P, &thermalManager.temp_bed.pid.Kp, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
VPHELPER(VP_BED_PID_I, &thermalManager.temp_bed.pid.Ki, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
VPHELPER(VP_BED_PID_D, &thermalManager.temp_bed.pid.Kd, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
VPHELPER(VP_PID_AUTOTUNE_BED, nullptr, ScreenHandler.HandlePIDAutotune, nullptr),
#endif
#endif
// Fan Data
#if HAS_FAN
#define FAN_VPHELPER(N) \
VPHELPER(VP_Fan##N##_Percentage, &thermalManager.fan_speed[N], ScreenHandler.DGUSLCD_SetUint8, ScreenHandler.DGUSLCD_SendFanToDisplay), \
VPHELPER(VP_FAN##N##_CONTROL, &thermalManager.fan_speed[N], ScreenHandler.HandleFanControl, nullptr), \
VPHELPER(VP_FAN##N##_STATUS, &thermalManager.fan_speed[N], nullptr, ScreenHandler.DGUSLCD_SendFanStatusToDisplay),
REPEAT(FAN_COUNT, FAN_VPHELPER)
#endif
// Feedrate
VPHELPER(VP_Feedrate_Percentage, &feedrate_percentage, ScreenHandler.DGUSLCD_SetValueDirectly<int16_t>, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
// Position Data
VPHELPER(VP_XPos, &current_position.x, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
VPHELPER(VP_YPos, &current_position.y, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
VPHELPER(VP_ZPos, &current_position.z, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
// Level Point Set
VPHELPER(VP_Level_Point_One_X, &mks_corner_offsets[0].x, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_One_Y, &mks_corner_offsets[0].y, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Two_X, &mks_corner_offsets[1].x, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Two_Y, &mks_corner_offsets[1].y, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Three_X, &mks_corner_offsets[2].x, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Three_Y, &mks_corner_offsets[2].y, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Four_X, &mks_corner_offsets[3].x, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Four_Y, &mks_corner_offsets[3].y, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Five_X, &mks_corner_offsets[4].x, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Five_Y, &mks_corner_offsets[4].y, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
// Print Progress
VPHELPER(VP_PrintProgress_Percentage, nullptr, nullptr, ScreenHandler.DGUSLCD_SendPrintProgressToDisplay),
// LCD Control
VPHELPER(VP_LCD_BLK, &lcd_default_light, ScreenHandler.LCD_BLK_Adjust, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
// SD File - Back
VPHELPER(VP_SD_FileSelect_Back, nullptr, ScreenHandler.SD_FileBack, nullptr),
// Print Time
VPHELPER_STR(VP_PrintTime, nullptr, VP_PrintTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintTimeToDisplay),
#if ENABLED(PRINTCOUNTER)
VPHELPER_STR(VP_PrintAccTime, nullptr, VP_PrintAccTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintAccTimeToDisplay),
VPHELPER_STR(VP_PrintsTotal, nullptr, VP_PrintsTotal_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintsTotalToDisplay),
#endif
VPHELPER(VP_X_STEP_PER_MM, &planner.settings.axis_steps_per_mm[X_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_Y_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Y_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_Z_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Z_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_X_MAX_SPEED, &planner.settings.max_feedrate_mm_s[X_AXIS], ScreenHandler.HandleMaxSpeedChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_Y_MAX_SPEED, &planner.settings.max_feedrate_mm_s[Y_AXIS], ScreenHandler.HandleMaxSpeedChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_Z_MAX_SPEED, &planner.settings.max_feedrate_mm_s[Z_AXIS], ScreenHandler.HandleMaxSpeedChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
#if HAS_HOTEND
VPHELPER(VP_E0_MAX_SPEED, &planner.settings.max_feedrate_mm_s[E_AXIS_N(0)], ScreenHandler.HandleExtruderMaxSpeedChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
#if HAS_MULTI_HOTEND
VPHELPER(VP_E1_MAX_SPEED, &planner.settings.max_feedrate_mm_s[E_AXIS_N(1)], ScreenHandler.HandleExtruderMaxSpeedChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
#endif
#endif
VPHELPER(VP_X_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[X_AXIS], ScreenHandler.HandleMaxAccChange, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Y_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[Y_AXIS], ScreenHandler.HandleMaxAccChange, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Z_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[Z_AXIS], ScreenHandler.HandleMaxAccChange, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#if HAS_HOTEND
VPHELPER(VP_E0_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(0)], ScreenHandler.HandleExtruderAccChange, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#if HAS_MULTI_HOTEND
VPHELPER(VP_E1_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)], ScreenHandler.HandleExtruderAccChange, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#endif
#endif
VPHELPER(VP_TRAVEL_SPEED, (uint16_t *)&planner.settings.travel_acceleration, ScreenHandler.HandleTravelAccChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_FEEDRATE_MIN_SPEED, (uint16_t *)&planner.settings.min_feedrate_mm_s, ScreenHandler.HandleFeedRateMinChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_T_F_SPEED, (uint16_t *)&planner.settings.min_travel_feedrate_mm_s, ScreenHandler.HandleMin_T_F, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_ACC_SPEED, (uint16_t *)&planner.settings.acceleration, ScreenHandler.HandleAccChange, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_X_PARK_POS, &mks_park_pos.x, ScreenHandler.GetParkPos, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Y_PARK_POS, &mks_park_pos.y, ScreenHandler.GetParkPos, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Z_PARK_POS, &mks_park_pos.z, ScreenHandler.GetParkPos, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#if ENABLED(PREVENT_COLD_EXTRUSION)
VPHELPER(VP_MIN_EX_T, &thermalManager.extrude_min_temp, ScreenHandler.HandleGetExMinTemp, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#endif
#if ENABLED(SENSORLESS_HOMING) // TMC SENSORLESS Setting
#if X_HAS_STEALTHCHOP
VPHELPER(VP_TMC_X_STEP, &tmc_step.x, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendTMCStepValue),
#endif
#if Y_HAS_STEALTHCHOP
VPHELPER(VP_TMC_Y_STEP, &tmc_step.y, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendTMCStepValue),
#endif
#if Z_HAS_STEALTHCHOP
VPHELPER(VP_TMC_Z_STEP, &tmc_step.z, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendTMCStepValue),
#endif
#endif
#if HAS_TRINAMIC_CONFIG // TMC Current Setting
#if AXIS_IS_TMC(X)
VPHELPER(VP_TMC_X_Current, &stepperX.val_mA, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#endif
#if AXIS_IS_TMC(Y)
VPHELPER(VP_TMC_Y_Current, &stepperY.val_mA, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#endif
#if AXIS_IS_TMC(Z)
VPHELPER(VP_TMC_Z_Current, &stepperZ.val_mA, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#endif
#if AXIS_IS_TMC(E0)
VPHELPER(VP_TMC_E0_Current, &stepperE0.val_mA, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#endif
#if AXIS_IS_TMC(E1)
VPHELPER(VP_TMC_E1_Current, &stepperE1.val_mA, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#endif
#if AXIS_IS_TMC(X2)
VPHELPER(VP_TMC_X1_Current, &stepperX2.val_mA, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#endif
#if AXIS_IS_TMC(Y2)
VPHELPER(VP_TMC_Y1_Current, &stepperY2.val_mA, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#endif
#if AXIS_IS_TMC(Z2)
VPHELPER(VP_TMC_Z1_Current, &stepperZ2.val_mA, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#endif
#endif
VPHELPER(VP_EEPROM_CTRL, nullptr, ScreenHandler.EEPROM_CTRL, nullptr),
VPHELPER(VP_LEVEL_BUTTON, nullptr, ScreenHandler.Level_Ctrl, nullptr),
VPHELPER(VP_LANGUAGE_CHANGE, nullptr, ScreenHandler.LanguageChange, nullptr),
//VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, ScreenHandler.HandleLiveAdjustZ, nullptr),
VPHELPER(VP_SD_Print_LiveAdjustZ_Confirm, nullptr, ScreenHandler.ZoffsetConfirm, nullptr),
VPHELPER(VP_ZOffset_Distance,nullptr ,ScreenHandler.GetZoffsetDistance, nullptr),
VPHELPER(VP_MESH_LEVEL_ADJUST, nullptr, ScreenHandler.MeshLevelDistanceConfig, nullptr),
VPHELPER(VP_MESH_LEVEL_POINT,nullptr, ScreenHandler.MeshLevel,nullptr),
#if ENABLED(PREVENT_COLD_EXTRUSION)
VPHELPER(VP_Min_EX_T_E, &thermalManager.extrude_min_temp, ScreenHandler.GetMinExtrudeTemp, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#endif
VPHELPER(VP_AutoTurnOffSw, nullptr, ScreenHandler.GetTurnOffCtrl, nullptr),
#if HAS_HOTEND
VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
#if HAS_MULTI_HOTEND
VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
#endif
#endif
// SDCard File listing
#if ENABLED(SDSUPPORT)
VPHELPER(VP_SD_FileSelected, nullptr, ScreenHandler.DGUSLCD_SD_FileSelected, nullptr),
VPHELPER(VP_SD_ScrollEvent, nullptr, ScreenHandler.DGUSLCD_SD_ScrollFilelist, 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),
VPHELPER_STR(VP_SD_FileName6, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename),
VPHELPER_STR(VP_SD_FileName7, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename),
VPHELPER_STR(VP_SD_FileName8, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename),
VPHELPER_STR(VP_SD_FileName9, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename),
VPHELPER(VP_SD_ResumePauseAbort, nullptr, ScreenHandler.DGUSLCD_SD_ResumePauseAbort, nullptr),
VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, ScreenHandler.DGUSLCD_SD_ReallyAbort, nullptr),
VPHELPER(VP_SD_Print_Setting, nullptr, ScreenHandler.DGUSLCD_SD_PrintTune, nullptr),
#if ENABLED(BABYSTEPPING)
VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, ScreenHandler.HandleLiveAdjustZ, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<2>),
VPHELPER(VP_ZOffset_DE_DIS, &z_offset_add, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
#endif
#if HAS_BED_PROBE
VPHELPER(VP_OFFSET_X, &probe.offset.x, ScreenHandler.GetOffsetValue,ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
VPHELPER(VP_OFFSET_Y, &probe.offset.y, ScreenHandler.GetOffsetValue,ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
VPHELPER(VP_OFFSET_Z, &probe.offset.z, ScreenHandler.GetOffsetValue,ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
#endif
#else
VPHELPER(VP_SD_FileSelected, nullptr, ScreenHandler.PrintReturn, nullptr),
#endif
#if ENABLED(DGUS_UI_WAITING)
VPHELPER(VP_WAITING_STATUS, nullptr, nullptr, ScreenHandler.DGUSLCD_SendWaitingStatusToDisplay),
#endif
// Messages for the User, shared by the popup and the kill screen. They can't 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},
{.VP = VP_MSGSTR1, .memadr = nullptr, .size = VP_MSGSTR1_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplay_Language},
{.VP = VP_MSGSTR2, .memadr = nullptr, .size = VP_MSGSTR2_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplay_Language},
{.VP = VP_MSGSTR3, .memadr = nullptr, .size = VP_MSGSTR3_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplay_Language},
{.VP = VP_MSGSTR4, .memadr = nullptr, .size = VP_MSGSTR4_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplay_Language},
VPHELPER(0, 0, 0, 0) // must be last entry.
};
#endif // DGUS_LCD_UI_MKS

View File

@ -0,0 +1,712 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "../DGUSDisplayDef.h"
//#define DGUS_MKS_RUNOUT_SENSOR
#define LOGO_TIME_DELAY TERN(USE_MKS_GREEN_UI, 8000, 1500)
#if ENABLED(DGUS_MKS_RUNOUT_SENSOR)
#define MT_DET_1_PIN 1
#define MT_DET_2_PIN 2
#define MT_DET_PIN_STATE LOW
#endif
#define MKS_FINSH
extern uint16_t manualMoveStep;
extern uint16_t distanceFilament;
extern uint16_t filamentSpeed_mm_s;
extern float ZOffset_distance;
extern float mesh_adj_distance;
extern float Z_distance;
//extern struct { uint16_t h, m, s; } dgus_time;
extern xy_int_t mks_corner_offsets[5];
extern xyz_int_t mks_park_pos;
extern celsius_t mks_min_extrusion_temp;
void MKS_reset_settings(); // Restore persistent settings to defaults
void MKS_pause_print_move();
void MKS_resume_print_move();
extern float z_offset_add;
extern xyz_int_t tmc_step;
extern uint16_t lcd_default_light;
#if X_HAS_STEALTHCHOP
extern uint16_t tmc_x_current;
#endif
#if Y_HAS_STEALTHCHOP
extern uint16_t tmc_y_current;
#endif
#if Z_HAS_STEALTHCHOP
extern uint16_t tmc_z_current;
#endif
#if E0_HAS_STEALTHCHOP
extern uint16_t tmc_e0_current;
#endif
#if E1_HAS_STEALTHCHOP
extern uint16_t tmc_e1_current;
#endif
typedef enum {
EX_HEATING,
EX_HEAT_STARUS,
EX_CHANGING,
EX_CHANGE_STATUS,
EX_NONE,
} EX_STATUS_DEF;
typedef struct {
//uint8_t ex_change_flag:1;
//uint8_t ex_heat_flag:1;
uint8_t ex_load_unload_flag:1; //0:unload 1:load
EX_STATUS_DEF ex_status;
uint32_t ex_tick_start;
uint32_t ex_tick_end;
uint32_t ex_speed;
uint32_t ex_length;
uint32_t ex_need_time;
} EX_FILAMENT_DEF;
extern EX_FILAMENT_DEF ex_filament;
typedef enum {
UNRUNOUT_STATUS,
RUNOUT_STATUS,
RUNOUT_WAITING_STATUS,
RUNOUT_BEGIN_STATUS,
} RUNOUT_MKS_STATUS_DEF;
typedef struct {
RUNOUT_MKS_STATUS_DEF runout_status;
uint8_t pin_status;
uint8_t de_count;
uint8_t de_times;
} RUNOUT_MKS_DEF;
extern RUNOUT_MKS_DEF runout_mks;
typedef struct {
uint8_t print_pause_start_flag:1;
uint8_t runout_flag:1;
bool blstatus;
uint16_t x_pos;
uint16_t y_pos;
uint16_t z_pos;
} NOZZLE_PARK_DEF;
extern NOZZLE_PARK_DEF nozzle_park_mks;
enum DGUSLCD_Screens : uint8_t {
#if ENABLED(USE_MKS_GREEN_UI)
DGUSLCD_SCREEN_BOOT = 33,
DGUSLCD_SCREEN_MAIN = 60,
DGUSLCD_SCREEN_STATUS = 60,
DGUSLCD_SCREEN_STATUS2 = 60,
DGUSLCD_SCREEN_PREHEAT = 18,
DGUSLCD_SCREEN_POWER_LOSS = 100,
DGUSLCD_SCREEN_MANUALMOVE = 192,
DGUSLCD_SCREEN_UTILITY = 120,
DGUSLCD_SCREEN_FILAMENT_UNLOADING = 158,
DGUSLCD_SCREEN_SDFILELIST = 15,
DGUSLCD_SCREEN_SDPRINTMANIPULATION = 15,
DGUSLCD_SCREEN_SDPRINTTUNE = 17,
MKSLCD_SCREEN_BOOT = 33,
MKSLCD_SCREEN_HOME = 60, // MKS main page
MKSLCD_SCREEN_SETTING = 62, // MKS Setting page / no wifi whit
MKSLCD_SCREEM_TOOL = 64, // MKS Tool page
MKSLCD_SCREEN_EXTRUDE_P1 = 75,
MKSLCD_SCREEN_EXTRUDE_P2 = 77,
MKSLCD_SCREEN_LEVEL = 73,
MKSLCD_AUTO_LEVEL = 81,
MKSLCD_SCREEN_MOVE = 66,
MKSLCD_SCREEN_PRINT = 68,
MKSLCD_SCREEN_PAUSE = 70,
MKSLCD_SCREEN_CHOOSE_FILE = 87,
MKSLCD_SCREEN_NO_CHOOSE_FILE = 88,
MKSLCD_SCREEN_Config = 101,
MKSLCD_SCREEN_Config_MOTOR = 103,
MKSLCD_SCREEN_MOTOR_PLUSE = 104,
MKSLCD_SCREEN_MOTOR_SPEED = 102,
MKSLCD_SCREEN_MOTOR_ACC_MAX = 105,
MKSLCD_SCREEN_PRINT_CONFIG = 72,
MKSLCD_SCREEN_LEVEL_DATA = 106,
MKSLCD_PrintPause_SET = 107,
MKSLCD_FILAMENT_DATA = 50,
MKSLCD_ABOUT = 83,
MKSLCD_PID = 108,
MKSLCD_PAUSE_SETTING_MOVE = 98,
MKSLCD_PAUSE_SETTING_EX = 96,
MKSLCD_PAUSE_SETTING_EX2 = 97,
MKSLCD_SCREEN_PRINT_CONFIRM = 94,
MKSLCD_SCREEN_EX_CONFIG = 112,
MKSLCD_SCREEN_EEP_Config = 89,
MKSLCD_SCREEN_PrintDone = 92,
MKSLCD_SCREEN_TMC_Config = 111,
MKSLCD_Screen_Offset_Config = 109,
MKSLCD_Screen_PMove = 98,
MKSLCD_Screen_Baby = 79,
#else
DGUSLCD_SCREEN_BOOT = 120,
DGUSLCD_SCREEN_MAIN = 1,
DGUSLCD_SCREEN_STATUS = 1,
DGUSLCD_SCREEN_STATUS2 = 1,
DGUSLCD_SCREEN_PREHEAT = 18,
DGUSLCD_SCREEN_POWER_LOSS = 100,
DGUSLCD_SCREEN_MANUALMOVE = 192,
DGUSLCD_SCREEN_UTILITY = 120,
DGUSLCD_SCREEN_FILAMENT_UNLOADING = 158,
DGUSLCD_SCREEN_SDFILELIST = 15,
DGUSLCD_SCREEN_SDPRINTMANIPULATION = 15,
DGUSLCD_SCREEN_SDPRINTTUNE = 17,
MKSLCD_SCREEN_BOOT = 0,
MKSLCD_SCREEN_HOME = 1, // MKS main page
MKSLCD_SCREEN_SETTING = 2, // MKS Setting page / no wifi whit
MKSLCD_SCREEM_TOOL = 3, // MKS Tool page
MKSLCD_SCREEN_EXTRUDE_P1 = 4,
MKSLCD_SCREEN_EXTRUDE_P2 = 11,
MKSLCD_SCREEN_LEVEL = 5,
MKSLCD_AUTO_LEVEL = 73,
MKSLCD_SCREEN_LEVEL_PRESS = 9,
MKSLCD_SCREEN_MOVE = 6,
MKSLCD_SCREEN_PRINT = 7,
MKSLCD_SCREEN_PRINT_PRESS = 13,
MKSLCD_SCREEN_PAUSE = 26,
MKSLCD_SCREEN_PAUSE_PRESS = 26,
MKSLCD_SCREEN_CHOOSE_FILE = 15,
MKSLCD_SCREEN_NO_CHOOSE_FILE = 17,
MKSLCD_SCREEN_Config = 46,
MKSLCD_SCREEN_Config_MOTOR = 47,
MKSLCD_SCREEN_MOTOR_PLUSE = 51,
MKSLCD_SCREEN_MOTOR_SPEED = 55,
MKSLCD_SCREEN_MOTOR_ACC_MAX = 53,
MKSLCD_SCREEN_PRINT_CONFIG = 60,
MKSLCD_SCREEN_LEVEL_DATA = 48,
MKSLCD_PrintPause_SET = 49,
MKSLCD_FILAMENT_DATA = 50,
MKSLCD_ABOUT = 36,
MKSLCD_PID = 56,
MKSLCD_PAUSE_SETTING_MOVE = 58,
MKSLCD_PAUSE_SETTING_EX = 57,
MKSLCD_PAUSE_SETTING_EX2 = 61,
MKSLCD_SCREEN_NO_FILE = 42,
MKSLCD_SCREEN_PRINT_CONFIRM = 43,
MKSLCD_SCREEN_EX_CONFIG = 65,
MKSLCD_SCREEN_EEP_Config = 20,
MKSLCD_SCREEN_PrintDone = 25,
MKSLCD_SCREEN_TMC_Config = 70,
MKSLCD_Screen_Offset_Config = 30,
MKSLCD_Screen_PMove = 64,
MKSLCD_Screen_Baby = 71,
#endif
DGUSLCD_SCREEN_CONFIRM = 240,
DGUSLCD_SCREEN_KILL = 250, ///< Kill Screen. Must always be 250 (to be able to display "Error wrong LCD Version")
DGUSLCD_SCREEN_WAITING = 251,
DGUSLCD_SCREEN_POPUP = 252, ///< special target, popup screen will also return this code to say "return to previous screen"
DGUSLCD_SCREEN_UNUSED = 255
};
// Place for status messages.
constexpr uint16_t VP_M117 = 0x7020;
constexpr uint8_t VP_M117_LEN = 0x20;
// Heater status
constexpr uint16_t VP_E0_STATUS = 0x3410;
constexpr uint16_t VP_E1_STATUS = 0x3412;
//constexpr uint16_t VP_E2_STATUS = 0x3414;
//constexpr uint16_t VP_E3_STATUS = 0x3416;
//constexpr uint16_t VP_E4_STATUS = 0x3418;
//constexpr uint16_t VP_E5_STATUS = 0x341A;
constexpr uint16_t VP_MOVE_OPTION = 0x3500;
// // 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_E1_PID_P = 0x3706; // at the moment , 2 byte unsigned int , 0~1638.4
// constexpr uint16_t VP_E1_PID_I = 0x3708;
// constexpr uint16_t VP_E1_PID_D = 0x370A;
// constexpr uint16_t VP_BED_PID_P = 0x3710;
// constexpr uint16_t VP_BED_PID_I = 0x3712;
// constexpr uint16_t VP_BED_PID_D = 0x3714;
// Waiting 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;
/*************************************************************************************************************************
*************************************************************************************************************************
* DGUS for MKS Mem layout
************************************************************************************************************************
************************************************************************************************************************/
#if ENABLED(MKS_FINSH)
/* -------------------------------0x1000-0x1FFF------------------------------- */
constexpr uint16_t VP_MSGSTR1 = 0x1100;
constexpr uint8_t VP_MSGSTR1_LEN = 0x20; // might be more place for it...
constexpr uint16_t VP_MSGSTR2 = 0x1140;
constexpr uint8_t VP_MSGSTR2_LEN = 0x20;
constexpr uint16_t VP_MSGSTR3 = 0x1180;
constexpr uint8_t VP_MSGSTR3_LEN = 0x20;
constexpr uint16_t VP_MSGSTR4 = 0x11C0;
constexpr uint8_t VP_MSGSTR4_LEN = 0x20;
constexpr uint16_t VP_MARLIN_VERSION = 0x1A00;
constexpr uint8_t VP_MARLIN_VERSION_LEN = 16; // there is more space on the display, if needed.
constexpr uint16_t VP_SCREENCHANGE_ASK = 0x1500;
constexpr uint16_t VP_SCREENCHANGE = 0x1501; // 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 = 0x1502; // Turn all heaters off. Value arbitrary ;)=
constexpr uint16_t VP_SCREENCHANGE_WHENSD = 0x1503; // "Print" Button touched -- go only there if there is an SD Card.
constexpr uint16_t VP_CONFIRMED = 0x1510; // OK on confirm screen.
constexpr uint16_t VP_BACK_PAGE = 0x1600;
constexpr uint16_t VP_SETTINGS = 0x1620;
// Power loss recovery
constexpr uint16_t VP_POWER_LOSS_RECOVERY = 0x1680;
/* -------------------------------0x2000-0x2FFF------------------------------- */
// Temperatures.
constexpr uint16_t VP_T_E0_Is = 0x2000; // 4 Byte Integer
constexpr uint16_t VP_T_E0_Set = 0x2004; // 2 Byte Integer
constexpr uint16_t VP_T_E1_Is = 0x2008; // 4 Byte Integer
constexpr uint16_t VP_T_E1_Set = 0x200B; // 2 Byte Integer
constexpr uint16_t VP_T_E2_Is = 0x2010; // 4 Byte Integer
constexpr uint16_t VP_T_E2_Set = 0x2014; // 2 Byte Integer
constexpr uint16_t VP_T_E3_Is = 0x2018; // 4 Byte Integer
constexpr uint16_t VP_T_E3_Set = 0x201B; // 2 Byte Integer
constexpr uint16_t VP_T_E4_Is = 0x2020; // 4 Byte Integer
constexpr uint16_t VP_T_E4_Set = 0x2024; // 2 Byte Integer
constexpr uint16_t VP_T_E5_Is = 0x2028; // 4 Byte Integer
constexpr uint16_t VP_T_E5_Set = 0x202B; // 2 Byte Integer
constexpr uint16_t VP_T_E6_Is = 0x2030; // 4 Byte Integer
constexpr uint16_t VP_T_E6_Set = 0x2034; // 2 Byte Integer
constexpr uint16_t VP_T_E7_Is = 0x2038; // 4 Byte Integer
constexpr uint16_t VP_T_E7_Set = 0x203B; // 2 Byte Integer
constexpr uint16_t VP_T_Bed_Is = 0x2040; // 4 Byte Integer
constexpr uint16_t VP_T_Bed_Set = 0x2044; // 2 Byte Integer
constexpr uint16_t VP_Min_EX_T_E = 0x2100;
constexpr uint16_t VP_Flowrate_E0 = 0x2200; // 2 Byte Integer
constexpr uint16_t VP_Flowrate_E1 = 0x2202; // 2 Byte Integer
constexpr uint16_t VP_Flowrate_E2 = 0x2204;
constexpr uint16_t VP_Flowrate_E3 = 0x2206;
constexpr uint16_t VP_Flowrate_E4 = 0x2208;
constexpr uint16_t VP_Flowrate_E5 = 0x220A;
constexpr uint16_t VP_Flowrate_E6 = 0x220C;
constexpr uint16_t VP_Flowrate_E7 = 0x220E;
// Move
constexpr uint16_t VP_MOVE_X = 0x2300;
constexpr uint16_t VP_MOVE_Y = 0x2302;
constexpr uint16_t VP_MOVE_Z = 0x2304;
constexpr uint16_t VP_MOVE_E0 = 0x2310;
constexpr uint16_t VP_MOVE_E1 = 0x2312;
constexpr uint16_t VP_MOVE_E2 = 0x2314;
constexpr uint16_t VP_MOVE_E3 = 0x2316;
constexpr uint16_t VP_MOVE_E4 = 0x2318;
constexpr uint16_t VP_MOVE_E5 = 0x231A;
constexpr uint16_t VP_MOVE_E6 = 0x231C;
constexpr uint16_t VP_MOVE_E7 = 0x231E;
constexpr uint16_t VP_HOME_ALL = 0x2320;
constexpr uint16_t VP_MOTOR_LOCK_UNLOK = 0x2330;
constexpr uint16_t VP_MOVE_DISTANCE = 0x2334;
constexpr uint16_t VP_X_HOME = 0x2336;
constexpr uint16_t VP_Y_HOME = 0x2338;
constexpr uint16_t VP_Z_HOME = 0x233A;
// Fan Control Buttons , switch between "off" and "on"
constexpr uint16_t VP_FAN0_CONTROL = 0x2350;
constexpr uint16_t VP_FAN1_CONTROL = 0x2352;
constexpr uint16_t VP_FAN2_CONTROL = 0x2354;
constexpr uint16_t VP_FAN3_CONTROL = 0x2356;
constexpr uint16_t VP_FAN4_CONTROL = 0x2358;
constexpr uint16_t VP_FAN5_CONTROL = 0x235A;
constexpr uint16_t VP_LANGUAGE_CHANGE = 0x2380;
constexpr uint16_t VP_LANGUAGE_CHANGE1 = 0x2382;
constexpr uint16_t VP_LANGUAGE_CHANGE2 = 0x2384;
constexpr uint16_t VP_LANGUAGE_CHANGE3 = 0x2386;
constexpr uint16_t VP_LANGUAGE_CHANGE4 = 0x2388;
constexpr uint16_t VP_LANGUAGE_CHANGE5 = 0x238A;
// LEVEL
constexpr uint16_t VP_LEVEL_POINT = 0x2400;
constexpr uint16_t VP_MESH_LEVEL_POINT = 0x2410;
constexpr uint16_t VP_MESH_LEVEL_ADJUST = 0x2412;
constexpr uint16_t VP_MESH_LEVEL_DIP = 0x2414;
constexpr uint16_t VP_MESH_LEVEL_POINT_X = 0x2416;
constexpr uint16_t VP_MESH_LEVEL_POINT_Y = 0x2418;
constexpr uint16_t VP_LEVEL_BUTTON = 0x2420;
constexpr uint16_t VP_MESH_LEVEL_POINT_DIS = 0x2422;
constexpr uint16_t VP_MESH_LEVEL_BACK = 0x2424;
constexpr uint16_t VP_E0_FILAMENT_LOAD_UNLOAD = 0x2500;
constexpr uint16_t VP_E1_FILAMENT_LOAD_UNLOAD = 0x2504;
constexpr uint16_t VP_LOAD_Filament = 0x2508;
// constexpr uint16_t VP_LOAD_UNLOAD_Cancle = 0x250A;
constexpr uint16_t VP_UNLOAD_Filament = 0x250B;
constexpr uint16_t VP_Filament_distance = 0x2600;
constexpr uint16_t VP_Filament_speed = 0x2604;
constexpr uint16_t VP_MIN_EX_T = 0x2606;
constexpr uint16_t VP_E1_Filament_distance = 0x2614;
constexpr uint16_t VP_E1_Filament_speed = 0x2616;
constexpr uint16_t VP_E1_MIN_EX_T = 0x2618;
constexpr uint16_t VP_Fan0_Percentage = 0x2700; // 2 Byte Integer (0..100)
constexpr uint16_t VP_Fan1_Percentage = 0x2702; // 2 Byte Integer (0..100)
constexpr uint16_t VP_Fan2_Percentage = 0x2704; // 2 Byte Integer (0..100)
constexpr uint16_t VP_Fan3_Percentage = 0x2706; // 2 Byte Integer (0..100)
constexpr uint16_t VP_Feedrate_Percentage = 0x2708; // 2 Byte Integer (0..100)
// Fan status
constexpr uint16_t VP_FAN0_STATUS = 0x2710;
constexpr uint16_t VP_FAN1_STATUS = 0x2712;
constexpr uint16_t VP_FAN2_STATUS = 0x2714;
constexpr uint16_t VP_FAN3_STATUS = 0x2716;
// Step per mm
constexpr uint16_t VP_X_STEP_PER_MM = 0x2900; // at the moment , 2 byte unsigned int , 0~1638.4
constexpr uint16_t VP_Y_STEP_PER_MM = 0x2904;
constexpr uint16_t VP_Z_STEP_PER_MM = 0x2908;
constexpr uint16_t VP_E0_STEP_PER_MM = 0x2910;
constexpr uint16_t VP_E1_STEP_PER_MM = 0x2912;
constexpr uint16_t VP_E2_STEP_PER_MM = 0x2914;
constexpr uint16_t VP_E3_STEP_PER_MM = 0x2916;
constexpr uint16_t VP_E4_STEP_PER_MM = 0x2918;
constexpr uint16_t VP_E5_STEP_PER_MM = 0x291A;
constexpr uint16_t VP_E6_STEP_PER_MM = 0x291C;
constexpr uint16_t VP_E7_STEP_PER_MM = 0x291E;
constexpr uint16_t VP_X_MAX_SPEED = 0x2A00;
constexpr uint16_t VP_Y_MAX_SPEED = 0x2A04;
constexpr uint16_t VP_Z_MAX_SPEED = 0x2A08;
constexpr uint16_t VP_E0_MAX_SPEED = 0x2A0C;
constexpr uint16_t VP_E1_MAX_SPEED = 0x2A10;
constexpr uint16_t VP_X_ACC_MAX_SPEED = 0x2A28;
constexpr uint16_t VP_Y_ACC_MAX_SPEED = 0x2A2C;
constexpr uint16_t VP_Z_ACC_MAX_SPEED = 0x2A30;
constexpr uint16_t VP_E0_ACC_MAX_SPEED = 0x2A34;
constexpr uint16_t VP_E1_ACC_MAX_SPEED = 0x2A38;
constexpr uint16_t VP_TRAVEL_SPEED = 0x2A3C;
constexpr uint16_t VP_FEEDRATE_MIN_SPEED = 0x2A40;
constexpr uint16_t VP_T_F_SPEED = 0x2A44;
constexpr uint16_t VP_ACC_SPEED = 0x2A48;
/* -------------------------------0x3000-0x3FFF------------------------------- */
// Buttons on the SD-Card File listing.
constexpr uint16_t VP_SD_ScrollEvent = 0x3020; // 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 = 0x3022; // Number of file field selected.
constexpr uint16_t VP_SD_FileSelectConfirm = 0x3024; // (This is a virtual VP and emulated by the Confirm Screen when a file has been confirmed)
constexpr uint16_t VP_SD_ResumePauseAbort = 0x3026; // Resume(Data=0), Pause(Data=1), Abort(Data=2) SD Card prints
constexpr uint16_t VP_SD_AbortPrintConfirmed = 0x3028; // Abort print confirmation (virtual, will be injected by the confirm dialog)
constexpr uint16_t VP_SD_Print_Setting = 0x3040;
constexpr uint16_t VP_SD_Print_LiveAdjustZ = 0x3050; // Data: 0 down, 1 up
constexpr uint16_t VP_SD_Print_LiveAdjustZ_Confirm = 0x3060;
constexpr uint16_t VP_ZOffset_Distance = 0x3070;
constexpr uint16_t VP_ZOffset_DE_DIS = 0x3080;
constexpr uint16_t VP_SD_FileSelect_Back = 0x3082;
// SDCard File Listing
constexpr uint16_t VP_SD_FileName_LEN = 32; // LEN is shared for all entries.
constexpr uint16_t DGUS_SD_FILESPERSCREEN = 10; // FIXME move that info to the display and read it from there.
constexpr uint16_t VP_SD_FileName0 = 0x3100;
constexpr uint16_t VP_SD_FileName1 = 0x3120;
constexpr uint16_t VP_SD_FileName2 = 0x3140;
constexpr uint16_t VP_SD_FileName3 = 0x3160;
constexpr uint16_t VP_SD_FileName4 = 0x3180;
constexpr uint16_t VP_SD_FileName5 = 0x31A0;
constexpr uint16_t VP_SD_FileName6 = 0x31C0;
constexpr uint16_t VP_SD_FileName7 = 0x31E0;
constexpr uint16_t VP_SD_FileName8 = 0x3200;
constexpr uint16_t VP_SD_FileName9 = 0x3220;
constexpr uint16_t VP_SD_Print_ProbeOffsetZ = 0x32A0;
constexpr uint16_t VP_SD_Print_Baby = 0x32B0;
constexpr uint16_t VP_SD_Print_Filename = 0x32C0;
// X Y Z Point
constexpr uint16_t VP_XPos = 0x3300; // 4 Byte Fixed point number; format xxx.yy
constexpr uint16_t VP_YPos = 0x3302; // 4 Byte Fixed point number; format xxx.yy
constexpr uint16_t VP_ZPos = 0x3304; // 4 Byte Fixed point number; format xxx.yy
constexpr uint16_t VP_EPos = 0x3306; // 4 Byte Fixed point number; format xxx.yy
// Print
constexpr uint16_t VP_PrintProgress_Percentage = 0x3330; // 2 Byte Integer (0..100)
constexpr uint16_t VP_PrintTime = 0x3340;
constexpr uint16_t VP_PrintTime_LEN = 32;
constexpr uint16_t VP_PrintAccTime = 0x3360;
constexpr uint16_t VP_PrintAccTime_LEN = 32;
constexpr uint16_t VP_PrintsTotal = 0x3380;
constexpr uint16_t VP_PrintsTotal_LEN = 16;
constexpr uint16_t VP_File_Pictutr0 = 0x3400;
constexpr uint16_t VP_File_Pictutr1 = 0x3402;
constexpr uint16_t VP_File_Pictutr2 = 0x3404;
constexpr uint16_t VP_File_Pictutr3 = 0x3406;
constexpr uint16_t VP_File_Pictutr4 = 0x3408;
constexpr uint16_t VP_File_Pictutr5 = 0x340A;
constexpr uint16_t VP_File_Pictutr6 = 0x340C;
constexpr uint16_t VP_File_Pictutr7 = 0x340E;
constexpr uint16_t VP_File_Pictutr8 = 0x3410;
constexpr uint16_t VP_File_Pictutr9 = 0x3412;
constexpr uint16_t VP_BED_STATUS = 0x341C;
constexpr uint16_t VP_TMC_X_STEP = 0x3430;
constexpr uint16_t VP_TMC_Y_STEP = 0x3432;
constexpr uint16_t VP_TMC_Z_STEP = 0x3434;
constexpr uint16_t VP_TMC_X1_Current = 0x3436;
constexpr uint16_t VP_TMC_Y1_Current = 0x3438;
constexpr uint16_t VP_TMC_X_Current = 0x343A;
constexpr uint16_t VP_TMC_Y_Current = 0x343C;
constexpr uint16_t VP_TMC_Z_Current = 0x343E;
constexpr uint16_t VP_TMC_E0_Current = 0x3440;
constexpr uint16_t VP_TMC_E1_Current = 0x3442;
constexpr uint16_t VP_TMC_Z1_Current = 0x3444;
constexpr uint16_t VP_PrintTime_H = 0x3500;
constexpr uint16_t VP_PrintTime_M = 0x3502;
constexpr uint16_t VP_PrintTime_S = 0x3504;
// 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_E1_PID_P = 0x3706; // at the moment , 2 byte unsigned int , 0~1638.4
constexpr uint16_t VP_E1_PID_I = 0x3708;
constexpr uint16_t VP_E1_PID_D = 0x370A;
constexpr uint16_t VP_BED_PID_P = 0x3710;
constexpr uint16_t VP_BED_PID_I = 0x3712;
constexpr uint16_t VP_BED_PID_D = 0x3714;
constexpr uint16_t VP_EEPROM_CTRL = 0x3720;
constexpr uint16_t VP_OFFSET_X = 0x3724;
constexpr uint16_t VP_OFFSET_Y = 0x3728;
constexpr uint16_t VP_OFFSET_Z = 0x372B;
// PID autotune
constexpr uint16_t VP_PID_AUTOTUNE_E0 = 0x3800;
constexpr uint16_t VP_PID_AUTOTUNE_E1 = 0x3802;
constexpr uint16_t VP_PID_AUTOTUNE_E2 = 0x3804;
constexpr uint16_t VP_PID_AUTOTUNE_E3 = 0x3806;
constexpr uint16_t VP_PID_AUTOTUNE_E4 = 0x3808;
constexpr uint16_t VP_PID_AUTOTUNE_E5 = 0x380A;
constexpr uint16_t VP_PID_AUTOTUNE_BED = 0x380C;
// Calibrate Z
constexpr uint16_t VP_Z_CALIBRATE = 0x3810;
constexpr uint16_t VP_AutoTurnOffSw = 0x3812;
constexpr uint16_t VP_LCD_BLK = 0x3814;
constexpr uint16_t VP_X_PARK_POS = 0x3900;
constexpr uint16_t VP_Y_PARK_POS = 0x3902;
constexpr uint16_t VP_Z_PARK_POS = 0x3904;
/* -------------------------------0x4000-0x4FFF------------------------------- */
// Heater Control Buttons , triged between "cool down" and "heat PLA" state
constexpr uint16_t VP_E0_CONTROL = 0x4010;
constexpr uint16_t VP_E1_CONTROL = 0x4012;
//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 = 0x401C;
// Preheat
constexpr uint16_t VP_E0_BED_PREHEAT = 0x4020;
constexpr uint16_t VP_E1_BED_PREHEAT = 0x4022;
//constexpr uint16_t VP_E2_BED_PREHEAT = 0x4024;
//constexpr uint16_t VP_E3_BED_PREHEAT = 0x4026;
//constexpr uint16_t VP_E4_BED_PREHEAT = 0x4028;
//constexpr uint16_t VP_E5_BED_PREHEAT = 0x402A;
// Filament load and unload
// constexpr uint16_t VP_E0_FILAMENT_LOAD_UNLOAD = 0x4030;
// constexpr uint16_t VP_E1_FILAMENT_LOAD_UNLOAD = 0x4032;
// Settings store , reset
// Level data
constexpr uint16_t VP_Level_Point_One_X = 0x4100;
constexpr uint16_t VP_Level_Point_One_Y = 0x4102;
constexpr uint16_t VP_Level_Point_Two_X = 0x4104;
constexpr uint16_t VP_Level_Point_Two_Y = 0x4106;
constexpr uint16_t VP_Level_Point_Three_X = 0x4108;
constexpr uint16_t VP_Level_Point_Three_Y = 0x410A;
constexpr uint16_t VP_Level_Point_Four_X = 0x410C;
constexpr uint16_t VP_Level_Point_Four_Y = 0x410E;
constexpr uint16_t VP_Level_Point_Five_X = 0x4110;
constexpr uint16_t VP_Level_Point_Five_Y = 0x4112;
/* H43 Version */
constexpr uint16_t VP_MKS_H43_VERSION = 0x4A00; // MKS H43 V1.0.0
constexpr uint16_t VP_MKS_H43_VERSION_LEN = 16;
constexpr uint16_t VP_MKS_H43_UpdataVERSION = 0x4A10; // MKS H43 V1.0.0
constexpr uint16_t VP_MKS_H43_UpdataVERSION_LEN = 16;
/* -------------------------------0x5000-0xFFFF------------------------------- */
constexpr uint16_t VP_HOME_Dis = 0x5000;
constexpr uint16_t VP_Setting_Dis = 0x5010;
constexpr uint16_t VP_Tool_Dis = 0x5020;
constexpr uint16_t VP_Printing_Dis = 0x5030;
constexpr uint16_t VP_Language_Dis = 0x5080;
constexpr uint16_t VP_LossPoint_Dis = 0x5090;
constexpr uint16_t VP_PrintPauseConfig_Dis = 0x5120;
constexpr uint16_t VP_MotorPluse_Dis = 0x5140;
constexpr uint16_t VP_MotorMaxSpeed_Dis = 0x5150;
constexpr uint16_t VP_MotorMaxAcc_Dis = 0x5160;
constexpr uint16_t VP_X_Pluse_Dis = 0x5170;
constexpr uint16_t VP_Y_Pluse_Dis = 0x5180;
constexpr uint16_t VP_Z_Pluse_Dis = 0x5190;
constexpr uint16_t VP_E0_Pluse_Dis = 0x51A0;
constexpr uint16_t VP_E1_Pluse_Dis = 0x51B0;
constexpr uint16_t VP_X_Max_Speed_Dis = 0x5280;
constexpr uint16_t VP_Y_Max_Speed_Dis = 0x5290;
constexpr uint16_t VP_Z_Max_Speed_Dis = 0x52A0;
constexpr uint16_t VP_E0_Max_Speed_Dis = 0x52B0;
constexpr uint16_t VP_E1_Max_Speed_Dis = 0x52C0;
constexpr uint16_t VP_X_Max_Acc_Speed_Dis = 0x51E0;
constexpr uint16_t VP_Y_Max_Acc_Speed_Dis = 0x51F0;
constexpr uint16_t VP_Z_Max_Acc_Speed_Dis = 0x5200;
constexpr uint16_t VP_E0_Max_Acc_Speed_Dis = 0x5210;
constexpr uint16_t VP_E1_Max_Acc_Speed_Dis = 0x5220;
constexpr uint16_t VP_PrintTime_Dis = 0x5470;
constexpr uint16_t VP_E0_Temp_Dis = 0x5310;
constexpr uint16_t VP_E1_Temp_Dis = 0x5320;
constexpr uint16_t VP_HB_Temp_Dis = 0x5330;
constexpr uint16_t VP_Feedrate_Dis = 0x5350;
constexpr uint16_t VP_PrintAcc_Dis = 0x5340;
constexpr uint16_t VP_Fan_Speed_Dis = 0x5360;
constexpr uint16_t VP_Min_Ex_Temp_Dis = 0x5380;
constexpr uint16_t VP_X_PARK_POS_Dis = 0x53E0;
constexpr uint16_t VP_Y_PARK_POS_Dis = 0x53F0;
constexpr uint16_t VP_Z_PARK_POS_Dis = 0x5400;
constexpr uint16_t VP_TravelAcc_Dis = 0x5440;
constexpr uint16_t VP_FeedRateMin_Dis = 0x5450;
constexpr uint16_t VP_TravelFeeRateMin_Dis = 0x5460;
constexpr uint16_t VP_ACC_Dis = 0x5480;
constexpr uint16_t VP_Extrusion_Dis = 0x5230;
constexpr uint16_t VP_HeatBed_Dis = 0x5240;
constexpr uint16_t VP_Printting_Dis = 0x5430;
constexpr uint16_t VP_FactoryDefaults_Dis = 0x54C0;
constexpr uint16_t VP_StoreSetting_Dis = 0x54B0;
constexpr uint16_t VP_Info_EEPROM_2_Dis = 0x54D0;
constexpr uint16_t VP_Info_EEPROM_1_Dis = 0x54E0;
constexpr uint16_t VP_AutoLevel_1_Dis = 0x55F0;
constexpr uint16_t VP_TMC_X_Step_Dis = 0x5530;
constexpr uint16_t VP_TMC_Y_Step_Dis = 0x5540;
constexpr uint16_t VP_TMC_Z_Step_Dis = 0x5550;
constexpr uint16_t VP_TMC_X1_Current_Dis = 0x5560;
constexpr uint16_t VP_TMC_Y1_Current_Dis = 0x5570;
constexpr uint16_t VP_TMC_X_Current_Dis = 0x5580;
constexpr uint16_t VP_TMC_Y_Current_Dis = 0x5590;
constexpr uint16_t VP_TMC_Z_Current_Dis = 0x55A0;
constexpr uint16_t VP_TMC_E0_Current_Dis = 0x55B0;
constexpr uint16_t VP_TMC_E1_Current_Dis = 0x55C0;
constexpr uint16_t VP_TMC_Z1_Current_Dis = 0x55E0;
constexpr uint16_t VP_AutoLEVEL_INFO1 = 0x5600;
constexpr uint16_t VP_EX_TEMP_INFO1_Dis = 0x5610;
constexpr uint16_t VP_EX_TEMP_INFO2_Dis = 0x5620;
constexpr uint16_t VP_EX_TEMP_INFO3_Dis = 0x5630;
constexpr uint16_t VP_LCD_BLK_Dis = 0x56A0;
constexpr uint16_t VP_Info_PrintFinish_1_Dis = 0x5C00;
constexpr uint16_t VP_Info_PrintFinish_2_Dis = 0x5C10;
constexpr uint16_t VP_Length_Dis = 0x5B00;
constexpr uint16_t VP_PrintConfrim_Info_Dis = 0x5B90;
constexpr uint16_t VP_StopPrintConfrim_Info_Dis = 0x5B80;
constexpr uint16_t VP_Point_One_Dis = 0x5BA0;
constexpr uint16_t VP_Point_Two_Dis = 0x5BB0;
constexpr uint16_t VP_Point_Three_Dis = 0x5BC0;
constexpr uint16_t VP_Point_Four_Dis = 0x5BD0;
constexpr uint16_t VP_Point_Five_Dis = 0x5BE0;
constexpr uint16_t VP_Print_Dis = 0x5250;
constexpr uint16_t VP_About_Dis = 0x5A00;
constexpr uint16_t VP_Config_Dis = 0x5A10;
constexpr uint16_t VP_Filament_Dis = 0x5A20;
constexpr uint16_t VP_Move_Dis = 0x5A30;
constexpr uint16_t VP_Level_Dis = 0x5A50;
constexpr uint16_t VP_Speed_Dis = 0x5A70;
constexpr uint16_t VP_InOut_Dis = 0x5A80;
constexpr uint16_t VP_MotorConfig_Dis = 0x5100;
constexpr uint16_t VP_LevelConfig_Dis = 0x5110;
constexpr uint16_t VP_Advance_Dis = 0x5130;
constexpr uint16_t VP_TemperatureConfig_Dis = 0x5390;
#endif // MKS_FINSH

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,116 @@
/**
* 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 "../DGUSScreenHandlerBase.h"
enum DGUSLCD_Screens : uint8_t;
class DGUSScreenHandlerMKS : public DGUSScreenHandler {
public:
DGUSScreenHandlerMKS() = default;
#if 0
static void sendinfoscreen_ch(const uint16_t *line1, const uint16_t *line2, const uint16_t *line3, const uint16_t *line4);
static void sendinfoscreen_en(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4);
static void sendinfoscreen(const void *line1, const void *line2, const void *line3, const void *line4, uint16_t language);
#endif
static void ScreenBackChange(DGUS_VP_Variable &var, void *val_ptr);
static void EEPROM_CTRL(DGUS_VP_Variable &var, void *val_ptr);
static void LanguageChange(DGUS_VP_Variable &var, void *val_ptr);
static void GetOffsetValue(DGUS_VP_Variable &var, void *val_ptr);
static void Level_Ctrl(DGUS_VP_Variable &var, void *val_ptr);
static void MeshLevel(DGUS_VP_Variable &var, void *val_ptr);
static void MeshLevelDistanceConfig(DGUS_VP_Variable &var, void *val_ptr);
static void ManualAssistLeveling(DGUS_VP_Variable &var, void *val_ptr);
static void ZoffsetConfirm(DGUS_VP_Variable &var, void *val_ptr);
static void Z_offset_select(DGUS_VP_Variable &var, void *val_ptr);
static void GetManualMovestep(DGUS_VP_Variable &var, void *val_ptr);
static void GetZoffsetDistance(DGUS_VP_Variable &var, void *val_ptr);
static void GetMinExtrudeTemp(DGUS_VP_Variable &var, void *val_ptr);
static void GetParkPos(DGUS_VP_Variable &var, void *val_ptr);
#if ENABLED(PREVENT_COLD_EXTRUSION)
static void HandleGetExMinTemp(DGUS_VP_Variable &var, void *val_ptr);
#endif
static void DGUS_LanguageDisplay(uint8_t var);
static void TMC_ChangeConfig(DGUS_VP_Variable &var, void *val_ptr);
static void GetTurnOffCtrl(DGUS_VP_Variable &var, void *val_ptr);
static void LanguagePInit();
static void DGUS_Runout_Idle();
static void DGUS_RunoutInit();
static void DGUS_ExtrudeLoadInit();
static void LCD_BLK_Adjust(DGUS_VP_Variable &var, void *val_ptr);
static void SD_FileBack(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 HandleMaxSpeedChange(DGUS_VP_Variable &var, void *val_ptr);
static void HandleExtruderMaxSpeedChange(DGUS_VP_Variable &var, void *val_ptr);
static void HandleAccChange(DGUS_VP_Variable &var, void *val_ptr);
static void HandleMaxAccChange(DGUS_VP_Variable &var, void *val_ptr);
static void HandleExtruderAccChange(DGUS_VP_Variable &var, void *val_ptr);
static void HandleChangeLevelPoint(DGUS_VP_Variable &var, void *val_ptr);
static void HandleTravelAccChange(DGUS_VP_Variable &var, void *val_ptr);
static void HandleFeedRateMinChange(DGUS_VP_Variable &var, void *val_ptr);
static void HandleMin_T_F(DGUS_VP_Variable &var, void *val_ptr);
#if HAS_PID_HEATING
static void FilamentLoadUnload(DGUS_VP_Variable &var, void *val_ptr, const int filamentDir);
static void FilamentLoad(DGUS_VP_Variable &var, void *val_ptr);
static void FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr);
static void GetManualFilament(DGUS_VP_Variable &var, void *val_ptr);
static void GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_ptr);
#endif
#if ENABLED(SDSUPPORT)
// Marlin informed us about SD print completion.
static void SDPrintingFinished();
#else
static void PrintReturn(DGUS_VP_Variable &var, void *val_ptr);
#endif
static void DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var);
static void DGUSLCD_SendBabyStepToDisplay(DGUS_VP_Variable &var);
static void DGUSLCD_SendFanToDisplay(DGUS_VP_Variable &var);
static void DGUSLCD_SendGbkToDisplay(DGUS_VP_Variable &var);
static void DGUSLCD_SendStringToDisplay_Language(DGUS_VP_Variable &var);
static void DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var);
static void DGUSLCD_SetUint8(DGUS_VP_Variable &var, void *val_ptr);
static bool loop();
};
enum MKS_Choose : uint8_t { MKS_Language_Choose, MKS_Language_NoChoose };
enum MKS_Language : uint8_t { MKS_SimpleChinese, MKS_English };
extern MKS_Language mks_language_index;
extern bool DGUSAutoTurnOff;
#if ENABLED(POWER_LOSS_RECOVERY)
#define PLR_SCREEN_RECOVER MKSLCD_SCREEN_PRINT
#define PLR_SCREEN_CANCEL MKSLCD_SCREEN_HOME
#endif
typedef DGUSScreenHandlerMKS DGUSScreenHandlerClass;

View File

@ -0,0 +1,279 @@
/**
* 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/>.
*
*/
/**
* lcd/extui/dgus/origin/DGUSDisplayDef.cpp
*/
#include "../../../../inc/MarlinConfigPre.h"
#if ENABLED(DGUS_LCD_UI_ORIGIN)
#include "DGUSDisplayDef.h"
#include "../DGUSDisplay.h"
#include "../DGUSScreenHandler.h"
#include "../../../../module/temperature.h"
#include "../../../../module/motion.h"
#include "../../../../module/planner.h"
#include "../../../marlinui.h"
#include "../../ui_api.h"
#if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
uint16_t distanceToMove = 10;
#endif
using namespace ExtUI;
const uint16_t VPList_Boot[] PROGMEM = {
VP_MARLIN_VERSION,
0x0000
};
const uint16_t VPList_Main[] PROGMEM = {
// VP_M117, for completeness, but it cannot be auto-uploaded.
0x0000
};
const uint16_t VPList_Temp[] PROGMEM = {
#if HAS_HOTEND
VP_T_E0_Is, VP_T_E0_Set,
#if HAS_MULTI_HOTEND
VP_T_E1_Is, VP_T_E1_Set,
#endif
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set,
#endif
0x0000
};
const uint16_t VPList_Status[] PROGMEM = {
// VP_M117, for completeness, but it cannot be auto-uploaded
#if HAS_HOTEND
VP_T_E0_Is, VP_T_E0_Set,
#if HAS_MULTI_HOTEND
VP_T_E1_Is, VP_T_E1_Set,
#endif
#endif
#if HAS_HEATED_BED
VP_T_Bed_Is, VP_T_Bed_Set,
#endif
#if HAS_FAN
VP_Fan0_Percentage,
#endif
VP_XPos, VP_YPos, VP_ZPos,
VP_Fan0_Percentage,
VP_Feedrate_Percentage,
VP_PrintProgress_Percentage,
0x0000
};
const uint16_t VPList_Status2[] PROGMEM = {
// VP_M117, for completeness, but it cannot be auto-uploaded
#if HAS_HOTEND
VP_Flowrate_E0,
#if HAS_MULTI_HOTEND
VP_Flowrate_E1,
#endif
#endif
VP_PrintProgress_Percentage,
VP_PrintTime,
0x0000
};
const uint16_t VPList_ManualMove[] PROGMEM = { VP_XPos, VP_YPos, VP_ZPos, 0x0000 };
const uint16_t VPList_ManualExtrude[] PROGMEM = { VP_EPos, 0x0000 };
const uint16_t VPList_FanAndFeedrate[] PROGMEM = { VP_Feedrate_Percentage, VP_Fan0_Percentage, 0x0000 };
const uint16_t VPList_SD_FlowRates[] PROGMEM = { VP_Flowrate_E0, VP_Flowrate_E1, 0x0000 };
const uint16_t VPList_SDFileList[] PROGMEM = { VP_SD_FileName0, VP_SD_FileName1, VP_SD_FileName2, VP_SD_FileName3, VP_SD_FileName4, 0x0000 };
const uint16_t VPList_SD_PrintManipulation[] PROGMEM = { VP_PrintProgress_Percentage, VP_PrintTime, 0x0000 };
const struct VPMapping VPMap[] PROGMEM = {
{ DGUSLCD_SCREEN_BOOT, VPList_Boot },
{ DGUSLCD_SCREEN_MAIN, VPList_Main },
{ DGUSLCD_SCREEN_TEMPERATURE, VPList_Temp },
{ DGUSLCD_SCREEN_STATUS, VPList_Status },
{ DGUSLCD_SCREEN_STATUS2, VPList_Status2 },
{ DGUSLCD_SCREEN_MANUALMOVE, VPList_ManualMove },
{ DGUSLCD_SCREEN_MANUALEXTRUDE, VPList_ManualExtrude },
{ DGUSLCD_SCREEN_FANANDFEEDRATE, VPList_FanAndFeedrate },
{ DGUSLCD_SCREEN_FLOWRATES, VPList_SD_FlowRates },
{ DGUSLCD_SCREEN_SDPRINTMANIPULATION, VPList_SD_PrintManipulation },
{ DGUSLCD_SCREEN_SDFILELIST, VPList_SDFileList },
{ 0 , nullptr } // List is terminated with an nullptr as table entry.
};
const char MarlinVersion[] PROGMEM = SHORT_BUILD_VERSION;
const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
// Helper to detect touch events
VPHELPER(VP_SCREENCHANGE, nullptr, ScreenHandler.ScreenChangeHook, nullptr),
VPHELPER(VP_SCREENCHANGE_ASK, nullptr, ScreenHandler.ScreenChangeHookIfIdle, nullptr),
#if ENABLED(SDSUPPORT)
VPHELPER(VP_SCREENCHANGE_WHENSD, nullptr, ScreenHandler.ScreenChangeHookIfSD, nullptr),
#endif
VPHELPER(VP_CONFIRMED, nullptr, ScreenHandler.ScreenConfirmedOK, nullptr),
VPHELPER(VP_TEMP_ALL_OFF, nullptr, ScreenHandler.HandleAllHeatersOff, nullptr),
#if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
VPHELPER(VP_MOVE_OPTION, &distanceToMove, ScreenHandler.HandleManualMoveOption, nullptr),
#endif
#if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
VPHELPER(VP_MOVE_X, &distanceToMove, ScreenHandler.HandleManualMove, nullptr),
VPHELPER(VP_MOVE_Y, &distanceToMove, ScreenHandler.HandleManualMove, nullptr),
VPHELPER(VP_MOVE_Z, &distanceToMove, ScreenHandler.HandleManualMove, nullptr),
VPHELPER(VP_HOME_ALL, &distanceToMove, ScreenHandler.HandleManualMove, nullptr),
#else
VPHELPER(VP_MOVE_X, nullptr, ScreenHandler.HandleManualMove, nullptr),
VPHELPER(VP_MOVE_Y, nullptr, ScreenHandler.HandleManualMove, nullptr),
VPHELPER(VP_MOVE_Z, nullptr, ScreenHandler.HandleManualMove, nullptr),
VPHELPER(VP_HOME_ALL, nullptr, ScreenHandler.HandleManualMove, nullptr),
#endif
VPHELPER(VP_MOTOR_LOCK_UNLOK, nullptr, ScreenHandler.HandleMotorLockUnlock, nullptr),
#if ENABLED(POWER_LOSS_RECOVERY)
VPHELPER(VP_POWER_LOSS_RECOVERY, nullptr, ScreenHandler.HandlePowerLossRecovery, nullptr),
#endif
VPHELPER(VP_SETTINGS, nullptr, ScreenHandler.HandleSettings, nullptr),
{ .VP = VP_MARLIN_VERSION, .memadr = (void*)MarlinVersion, .size = VP_MARLIN_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM },
// 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 },
// Temperature Data
#if HAS_HOTEND
VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>),
VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Flowrate_E0, nullptr, ScreenHandler.HandleFlowRateChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_EPos, &destination.e, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
VPHELPER(VP_MOVE_E0, nullptr, ScreenHandler.HandleManualExtrude, nullptr),
VPHELPER(VP_E0_CONTROL, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleHeaterControl, nullptr),
VPHELPER(VP_E0_STATUS, &thermalManager.temp_hotend[0].target, nullptr, ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay),
#if ENABLED(DGUS_PREHEAT_UI)
VPHELPER(VP_E0_BED_PREHEAT, nullptr, ScreenHandler.HandlePreheat, nullptr),
#endif
#if ENABLED(PIDTEMP)
VPHELPER(VP_E0_PID_P, &thermalManager.temp_hotend[0].pid.Kp, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
VPHELPER(VP_E0_PID_I, &thermalManager.temp_hotend[0].pid.Ki, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
VPHELPER(VP_E0_PID_D, &thermalManager.temp_hotend[0].pid.Kd, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
VPHELPER(VP_PID_AUTOTUNE_E0, nullptr, ScreenHandler.HandlePIDAutotune, nullptr),
#endif
#if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
VPHELPER(VP_E0_FILAMENT_LOAD_UNLOAD, nullptr, ScreenHandler.HandleFilamentOption, ScreenHandler.HandleFilamentLoadUnload),
#endif
#endif
#if HAS_MULTI_HOTEND
VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>),
VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Flowrate_E1, nullptr, ScreenHandler.HandleFlowRateChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_MOVE_E1, nullptr, ScreenHandler.HandleManualExtrude, nullptr),
VPHELPER(VP_E1_CONTROL, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleHeaterControl, nullptr),
VPHELPER(VP_E1_STATUS, &thermalManager.temp_hotend[1].target, nullptr, ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay),
#if ENABLED(PIDTEMP)
VPHELPER(VP_PID_AUTOTUNE_E1, nullptr, ScreenHandler.HandlePIDAutotune, nullptr),
#endif
#endif
#if HAS_HEATED_BED
VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>),
VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, ScreenHandler.HandleHeaterControl, nullptr),
VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay),
#if ENABLED(PIDTEMPBED)
VPHELPER(VP_BED_PID_P, &thermalManager.temp_bed.pid.Kp, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
VPHELPER(VP_BED_PID_I, &thermalManager.temp_bed.pid.Ki, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
VPHELPER(VP_BED_PID_D, &thermalManager.temp_bed.pid.Kd, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID),
#endif
#endif
// Fan Data
#if HAS_FAN
#define FAN_VPHELPER(N) \
VPHELPER(VP_Fan##N##_Percentage, &thermalManager.fan_speed[N], ScreenHandler.DGUSLCD_PercentageToUint8, ScreenHandler.DGUSLCD_SendPercentageToDisplay), \
VPHELPER(VP_FAN##N##_CONTROL, &thermalManager.fan_speed[N], ScreenHandler.HandleFanControl, nullptr), \
VPHELPER(VP_FAN##N##_STATUS, &thermalManager.fan_speed[N], nullptr, ScreenHandler.DGUSLCD_SendFanStatusToDisplay),
REPEAT(FAN_COUNT, FAN_VPHELPER)
#endif
// Feedrate
VPHELPER(VP_Feedrate_Percentage, &feedrate_percentage, ScreenHandler.DGUSLCD_SetValueDirectly<int16_t>, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
// Position Data
VPHELPER(VP_XPos, &current_position.x, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
VPHELPER(VP_YPos, &current_position.y, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
VPHELPER(VP_ZPos, &current_position.z, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
// Print Progress
VPHELPER(VP_PrintProgress_Percentage, nullptr, nullptr, ScreenHandler.DGUSLCD_SendPrintProgressToDisplay),
// Print Time
VPHELPER_STR(VP_PrintTime, nullptr, VP_PrintTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintTimeToDisplay),
#if ENABLED(PRINTCOUNTER)
VPHELPER_STR(VP_PrintAccTime, nullptr, VP_PrintAccTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintAccTimeToDisplay),
VPHELPER_STR(VP_PrintsTotal, nullptr, VP_PrintsTotal_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintsTotalToDisplay),
#endif
VPHELPER(VP_X_STEP_PER_MM, &planner.settings.axis_steps_per_mm[X_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
VPHELPER(VP_Y_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Y_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
VPHELPER(VP_Z_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Z_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
#if HAS_HOTEND
VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
#if HAS_MULTI_HOTEND
VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
#endif
#endif
// SDCard File listing.
#if ENABLED(SDSUPPORT)
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(VP_SD_ResumePauseAbort, nullptr, ScreenHandler.DGUSLCD_SD_ResumePauseAbort, nullptr),
VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, ScreenHandler.DGUSLCD_SD_ReallyAbort, nullptr),
VPHELPER(VP_SD_Print_Setting, nullptr, ScreenHandler.DGUSLCD_SD_PrintTune, nullptr),
#if HAS_BED_PROBE
VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe.offset.z, ScreenHandler.HandleProbeOffsetZChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<2>),
#if ENABLED(BABYSTEPPING)
VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, ScreenHandler.HandleLiveAdjustZ, nullptr),
#endif
#endif
#endif
#if ENABLED(DGUS_UI_WAITING)
VPHELPER(VP_WAITING_STATUS, nullptr, nullptr, ScreenHandler.DGUSLCD_SendWaitingStatusToDisplay),
#endif
// Messages for the User, shared by the popup and the kill screen. They can't be autouploaded as we do not buffer content.
{ .VP = VP_MSGSTR1, .memadr = nullptr, .size = VP_MSGSTR1_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM },
{ .VP = VP_MSGSTR2, .memadr = nullptr, .size = VP_MSGSTR2_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM },
{ .VP = VP_MSGSTR3, .memadr = nullptr, .size = VP_MSGSTR3_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM },
{ .VP = VP_MSGSTR4, .memadr = nullptr, .size = VP_MSGSTR4_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM },
VPHELPER(0, 0, 0, 0) // must be last entry.
};
#endif // DGUS_LCD_UI_ORIGIN

View File

@ -0,0 +1,282 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "../DGUSDisplayDef.h"
enum DGUSLCD_Screens : uint8_t {
DGUSLCD_SCREEN_BOOT = 0,
DGUSLCD_SCREEN_MAIN = 10,
DGUSLCD_SCREEN_TEMPERATURE = 20,
DGUSLCD_SCREEN_STATUS = 30,
DGUSLCD_SCREEN_STATUS2 = 32,
DGUSLCD_SCREEN_MANUALMOVE = 40,
DGUSLCD_SCREEN_MANUALEXTRUDE = 42,
DGUSLCD_SCREEN_FANANDFEEDRATE = 44,
DGUSLCD_SCREEN_FLOWRATES = 46,
DGUSLCD_SCREEN_SDFILELIST = 50,
DGUSLCD_SCREEN_SDPRINTMANIPULATION = 52,
DGUSLCD_SCREEN_POWER_LOSS = 100,
DGUSLCD_SCREEN_PREHEAT = 120,
DGUSLCD_SCREEN_UTILITY = 110,
DGUSLCD_SCREEN_FILAMENT_HEATING = 146,
DGUSLCD_SCREEN_FILAMENT_LOADING = 148,
DGUSLCD_SCREEN_FILAMENT_UNLOADING = 158,
DGUSLCD_SCREEN_SDPRINTTUNE = 170,
DGUSLCD_SCREEN_CONFIRM = 240,
DGUSLCD_SCREEN_KILL = 250, ///< Kill Screen. Must always be 250 (to be able to display "Error wrong LCD Version")
DGUSLCD_SCREEN_WAITING = 251,
DGUSLCD_SCREEN_POPUP = 252, ///< special target, popup screen will also return this code to say "return to previous screen"
DGUSLCD_SCREEN_UNUSED = 255
};
// 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.
// Storage space for the Killscreen messages. 0x1100 - 0x1200 . Reused for the popup.
constexpr uint16_t VP_MSGSTR1 = 0x1100;
constexpr uint8_t VP_MSGSTR1_LEN = 0x20; // might be more place for it...
constexpr uint16_t VP_MSGSTR2 = 0x1140;
constexpr uint8_t VP_MSGSTR2_LEN = 0x20;
constexpr uint16_t VP_MSGSTR3 = 0x1180;
constexpr uint8_t VP_MSGSTR3_LEN = 0x20;
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 = 0x2001; // 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 = 0x2010; // 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_MARLIN_VERSION = 0x3000;
constexpr uint8_t VP_MARLIN_VERSION_LEN = 16; // there is more space on the display, if needed.
// Place for status messages.
constexpr uint16_t VP_M117 = 0x3020;
constexpr uint8_t VP_M117_LEN = 0x20;
// Temperatures.
constexpr uint16_t VP_T_E0_Is = 0x3060; // 4 Byte Integer
constexpr uint16_t VP_T_E0_Set = 0x3062; // 2 Byte Integer
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 = 0x3080; // 4 Byte Integer
constexpr uint16_t VP_T_Bed_Set = 0x3082; // 2 Byte Integer
constexpr uint16_t VP_Flowrate_E0 = 0x3090; // 2 Byte Integer
constexpr uint16_t VP_Flowrate_E1 = 0x3092; // 2 Byte Integer
// reserved for up to 6 Extruders:
//constexpr uint16_t VP_Flowrate_E2 = 0x3094;
//constexpr uint16_t VP_Flowrate_E3 = 0x3096;
//constexpr uint16_t VP_Flowrate_E4 = 0x3098;
//constexpr uint16_t VP_Flowrate_E5 = 0x309A;
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 = 0x3102; // 2 Byte Integer (0..100)
constexpr uint16_t VP_PrintProgress_Percentage = 0x3104; // 2 Byte Integer (0..100)
constexpr uint16_t VP_PrintTime = 0x3106;
constexpr uint16_t VP_PrintTime_LEN = 10;
constexpr uint16_t VP_PrintAccTime = 0x3160;
constexpr uint16_t VP_PrintAccTime_LEN = 32;
constexpr uint16_t VP_PrintsTotal = 0x3180;
constexpr uint16_t VP_PrintsTotal_LEN = 16;
// Actual Position
constexpr uint16_t VP_XPos = 0x3110; // 4 Byte Fixed point number; format xxx.yy
constexpr uint16_t VP_YPos = 0x3112; // 4 Byte Fixed point number; format xxx.yy
constexpr uint16_t VP_ZPos = 0x3114; // 4 Byte Fixed point number; format xxx.yy
constexpr uint16_t VP_EPos = 0x3120; // 4 Byte Fixed point number; format xxx.yy
// SDCard File Listing
constexpr uint16_t VP_SD_FileName_LEN = 32; // LEN is shared for all entries.
constexpr uint16_t DGUS_SD_FILESPERSCREEN = 5; // FIXME move that info to the display and read it from there.
constexpr uint16_t VP_SD_FileName0 = 0x3200;
constexpr uint16_t VP_SD_FileName1 = 0x3220;
constexpr uint16_t VP_SD_FileName2 = 0x3240;
constexpr uint16_t VP_SD_FileName3 = 0x3260;
constexpr uint16_t VP_SD_FileName4 = 0x3280;
constexpr uint16_t VP_SD_Print_ProbeOffsetZ = 0x32A0; //
constexpr uint16_t VP_SD_Print_Filename = 0x32C0; //
// 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;
// Waiting 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;

View File

@ -0,0 +1,423 @@
/**
* 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_ORIGIN)
#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)
extern ExtUI::FileList filelist;
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_STATUS);
}
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(DGUSLCD_SCREEN_SDPRINTMANIPULATION);
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_ECHOLNPGM("\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_ECHOLNPGM("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, don't 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_ECHOPGM(" homing ", AS_CHAR(axiscode));
char buf[6] = "G28 X";
buf[4] = axiscode;
//DEBUG_ECHOPGM(" ", buf);
queue.enqueue_one_now(buf);
//DEBUG_ECHOLNPGM(" ✓");
ForceCompleteUpdate();
return;
}
else {
// movement
DEBUG_ECHOPGM(" move ", AS_CHAR(axiscode));
bool old_relative_mode = relative_mode;
if (!relative_mode) {
//DEBUG_ECHOPGM(" G91");
queue.enqueue_now(F("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_ECHOPGM(" ", 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_ECHOPGM(" ", buf);
}
// while (!enqueue_and_echo_command(buf)) idle();
//DEBUG_ECHOLNPGM(" ✓ ");
if (!old_relative_mode) {
//DEBUG_ECHOPGM("G90");
queue.enqueue_now(F("G90"));
//DEBUG_ECHOPGM(" ✓ ");
}
}
ForceCompleteUpdate();
DEBUG_ECHOLNPGM("manmv done.");
return;
cannotmove:
DEBUG_ECHOLNPGM(" cannot move ", AS_CHAR(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_ECHOLNPGM("V1:", rawvalue);
float value = (float)rawvalue / 10;
DEBUG_ECHOLNPGM("V2:", value);
float newvalue = 0;
switch (var.VP) {
default: return;
#if HAS_HOTEND
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 HAS_MULTI_HOTEND
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_ECHOLNPGM("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 HAS_HOTEND
thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E0);
#if HAS_MULTI_HOTEND
thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E1);
#endif
#endif
GotoScreen(DGUSLCD_SCREEN_UTILITY);
}
else { // Go to the preheat screen to show the heating progress
switch (var.VP) {
default: return;
#if HAS_HOTEND
case VP_E0_FILAMENT_LOAD_UNLOAD:
filament_data.extruder = ExtUI::extruder_t::E0;
thermalManager.setTargetHotend(e_temp, filament_data.extruder);
break;
#endif
#if HAS_MULTI_HOTEND
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, BOOTSCREEN_TIMEOUT)) {
booted = true;
GotoScreen(TERN0(POWER_LOSS_RECOVERY, recovery.valid()) ? DGUSLCD_SCREEN_POWER_LOSS : DGUSLCD_SCREEN_MAIN);
}
#endif
return IsScreenComplete();
}
#endif // DGUS_LCD_UI_ORIGIN

View File

@ -0,0 +1,31 @@
/**
* 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 "../DGUSScreenHandlerBase.h"
typedef DGUSScreenHandler DGUSScreenHandlerClass;
#if ENABLED(POWER_LOSS_RECOVERY)
#define PLR_SCREEN_RECOVER DGUSLCD_SCREEN_SDPRINTMANIPULATION
#define PLR_SCREEN_CANCEL DGUSLCD_SCREEN_STATUS
#endif

View File

@ -0,0 +1,409 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 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_RELOADED)
#include "DGUSDisplay.h"
#include "config/DGUS_Addr.h"
#include "config/DGUS_Constants.h"
#include "definition/DGUS_VPList.h"
#include "../ui_api.h"
#include "../../../gcode/gcode.h"
long map_precise(float x, long in_min, long in_max, long out_min, long out_max) {
return LROUND((x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min);
}
uint8_t DGUSDisplay::gui_version = 0;
uint8_t DGUSDisplay::os_version = 0;
uint8_t DGUSDisplay::volume = 255;
uint8_t DGUSDisplay::brightness = 100;
DGUSDisplay::rx_datagram_state_t DGUSDisplay::rx_datagram_state = DGUS_IDLE;
uint8_t DGUSDisplay::rx_datagram_len = 0;
bool DGUSDisplay::initialized = false;
void DGUSDisplay::Loop() {
ProcessRx();
}
void DGUSDisplay::Init() {
LCD_SERIAL.begin(LCD_BAUDRATE);
ReadVersions();
}
void DGUSDisplay::Read(uint16_t addr, uint8_t size) {
WriteHeader(addr, DGUS_READVAR, size);
LCD_SERIAL.write(size);
}
void DGUSDisplay::Write(uint16_t addr, const void* data_ptr, uint8_t size) {
if (!data_ptr) return;
WriteHeader(addr, DGUS_WRITEVAR, size);
const char* data = static_cast<const char*>(data_ptr);
while (size--) {
LCD_SERIAL.write(*data++);
}
}
void DGUSDisplay::WriteString(uint16_t addr, const void* data_ptr, uint8_t size, bool left, bool right, bool use_space) {
if (!data_ptr) return;
WriteHeader(addr, DGUS_WRITEVAR, size);
const char* data = static_cast<const char*>(data_ptr);
size_t len = strlen(data);
uint8_t left_spaces = 0;
uint8_t right_spaces = 0;
if (len < size) {
if (!len) {
right_spaces = size;
}
else if ((left && right) || (!left && !right)) {
left_spaces = (size - len) / 2;
right_spaces = size - len - left_spaces;
}
else if (left) {
right_spaces = size - len;
}
else {
left_spaces = size - len;
}
}
else {
len = size;
}
while (left_spaces--) {
LCD_SERIAL.write(' ');
}
while (len--) {
LCD_SERIAL.write(*data++);
}
while (right_spaces--) {
LCD_SERIAL.write(use_space ? ' ' : '\0');
}
}
void DGUSDisplay::WriteStringPGM(uint16_t addr, const void* data_ptr, uint8_t size, bool left, bool right, bool use_space) {
if (!data_ptr) return;
WriteHeader(addr, DGUS_WRITEVAR, size);
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;
if (len < size) {
if (!len) {
right_spaces = size;
}
else if ((left && right) || (!left && !right)) {
left_spaces = (size - len) / 2;
right_spaces = size - len - left_spaces;
}
else if (left) {
right_spaces = size - len;
}
else {
left_spaces = size - len;
}
}
else {
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');
}
}
void DGUSDisplay::ReadVersions() {
if (gui_version != 0 && os_version != 0) return;
Read(DGUS_VERSION, 1);
}
void DGUSDisplay::SwitchScreen(DGUS_Screen screen) {
DEBUG_ECHOLNPGM("SwitchScreen ", (uint8_t)screen);
const uint8_t command[] = { 0x5A, 0x01, 0x00, (uint8_t)screen };
Write(0x84, command, sizeof(command));
}
void DGUSDisplay::PlaySound(uint8_t start, uint8_t len, uint8_t volume) {
if (volume == 0) volume = DGUSDisplay::volume;
if (volume == 0) return;
DEBUG_ECHOLNPGM("PlaySound ", start, ":", len, "\nVolume ", volume);
const uint8_t command[] = { start, len, volume, 0x00 };
Write(0xA0, command, sizeof(command));
}
void DGUSDisplay::EnableControl(DGUS_Screen screen, DGUS_ControlType type, DGUS_Control control) {
DEBUG_ECHOLNPGM("EnableControl ", (uint8_t)control, "\nScreen ", (uint8_t)screen, "\nType ", (uint8_t)type);
const uint8_t command[] = { 0x5A, 0xA5, 0x00, (uint8_t)screen, (uint8_t)control, type, 0x00, 0x01 };
Write(0xB0, command, sizeof(command));
FlushTx();
delay(50);
}
void DGUSDisplay::DisableControl(DGUS_Screen screen, DGUS_ControlType type, DGUS_Control control) {
DEBUG_ECHOLNPGM("DisableControl ", (uint8_t)control, "\nScreen ", (uint8_t)screen, "\nType ", (uint8_t)type);
const uint8_t command[] = { 0x5A, 0xA5, 0x00, (uint8_t)screen, (uint8_t)control, type, 0x00, 0x00 };
Write(0xB0, command, sizeof(command));
FlushTx();
delay(50);
}
uint8_t DGUSDisplay::GetBrightness() {
return brightness;
}
uint8_t DGUSDisplay::GetVolume() {
return map_precise(volume, 0, 255, 0, 100);
}
void DGUSDisplay::SetBrightness(uint8_t new_brightness) {
brightness = constrain(new_brightness, 0, 100);
new_brightness = map_precise(brightness, 0, 100, 5, 100);
DEBUG_ECHOLNPGM("SetBrightness ", new_brightness);
const uint8_t command[] = { new_brightness, new_brightness };
Write(0x82, command, sizeof(command));
}
void DGUSDisplay::SetVolume(uint8_t new_volume) {
volume = map_precise(constrain(new_volume, 0, 100), 0, 100, 0, 255);
DEBUG_ECHOLNPGM("SetVolume ", volume);
const uint8_t command[] = { volume, 0x00 };
Write(0xA1, command, sizeof(command));
}
void DGUSDisplay::ProcessRx() {
#if ENABLED(LCD_SERIAL_STATS_RX_BUFFER_OVERRUNS)
if (!LCD_SERIAL.available() && LCD_SERIAL.buffer_overruns()) {
// Overrun, but reset the flag only when the buffer is empty
// We want to extract as many as valid datagrams possible...
DEBUG_ECHOPGM("OVFL");
rx_datagram_state = DGUS_IDLE;
//LCD_SERIAL.reset_rx_overun();
LCD_SERIAL.flush();
}
#endif
uint8_t receivedbyte;
while (LCD_SERIAL.available()) {
switch (rx_datagram_state) {
case DGUS_IDLE: // Waiting for the first header byte
receivedbyte = LCD_SERIAL.read();
DEBUG_ECHOPGM("< ", receivedbyte);
if (DGUS_HEADER1 == receivedbyte) rx_datagram_state = DGUS_HEADER1_SEEN;
break;
case DGUS_HEADER1_SEEN: // Waiting for the second header byte
receivedbyte = LCD_SERIAL.read();
DEBUG_ECHOPGM(" ", receivedbyte);
rx_datagram_state = (DGUS_HEADER2 == receivedbyte) ? DGUS_HEADER2_SEEN : DGUS_IDLE;
break;
case DGUS_HEADER2_SEEN: // Waiting for the length byte
rx_datagram_len = LCD_SERIAL.read();
DEBUG_ECHOPGM(" (", rx_datagram_len, ") ");
// Telegram min len is 3 (command and one word of payload)
rx_datagram_state = WITHIN(rx_datagram_len, 3, DGUS_RX_BUFFER_SIZE) ? DGUS_WAIT_TELEGRAM : DGUS_IDLE;
break;
case DGUS_WAIT_TELEGRAM: // wait for complete datagram to arrive.
if (LCD_SERIAL.available() < rx_datagram_len) return;
initialized = true; // We've talked to it, so we defined it as initialized.
uint8_t command = LCD_SERIAL.read();
DEBUG_ECHOPGM("# ", command);
uint8_t readlen = rx_datagram_len - 1; // command is part of len.
unsigned char tmp[rx_datagram_len - 1];
unsigned char *ptmp = tmp;
while (readlen--) {
receivedbyte = LCD_SERIAL.read();
DEBUG_ECHOPGM(" ", receivedbyte);
*ptmp++ = receivedbyte;
}
DEBUG_ECHOPGM(" # ");
// mostly we'll get this: 5A A5 03 82 4F 4B -- ACK on 0x82, so discard it.
if (command == DGUS_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_READVAR) {
const uint16_t addr = tmp[0] << 8 | tmp[1];
const uint8_t dlen = tmp[2] << 1; // Convert to Bytes. (Display works with words)
DEBUG_ECHOPGM("addr=", addr, " dlen=", dlen, "> ");
if (addr == DGUS_VERSION && dlen == 2) {
DEBUG_ECHOLNPGM("VERSIONS");
gui_version = tmp[3];
os_version = tmp[4];
rx_datagram_state = DGUS_IDLE;
break;
}
DGUS_VP vp;
if (!DGUS_PopulateVP((DGUS_Addr)addr, &vp)) {
DEBUG_ECHOLNPGM("VP not found");
rx_datagram_state = DGUS_IDLE;
break;
}
if (!vp.rx_handler) {
DEBUG_ECHOLNPGM("VP found, no handler.");
rx_datagram_state = DGUS_IDLE;
break;
}
gcode.reset_stepper_timeout();
if (!vp.size) {
DEBUG_EOL();
vp.rx_handler(vp, nullptr);
rx_datagram_state = DGUS_IDLE;
break;
}
if (vp.flags & VPFLAG_RXSTRING) {
unsigned char buffer[vp.size];
memset(buffer, 0, vp.size);
for (uint8_t i = 0; i < dlen; i++) {
if (i >= vp.size) break;
if (i + 1 < dlen && tmp[i + 3] == 0xFF && tmp[i + 4] == 0xFF)
break;
buffer[i] = tmp[i + 3];
}
DEBUG_EOL();
vp.rx_handler(vp, buffer);
rx_datagram_state = DGUS_IDLE;
break;
}
if (dlen != vp.size) {
DEBUG_ECHOLNPGM("VP found, size mismatch.");
rx_datagram_state = DGUS_IDLE;
break;
}
DEBUG_EOL();
vp.rx_handler(vp, &tmp[3]);
rx_datagram_state = DGUS_IDLE;
break;
}
DEBUG_ECHOLNPGM(">");
rx_datagram_state = DGUS_IDLE;
break;
}
}
}
size_t DGUSDisplay::GetFreeTxBuffer() {
#ifdef LCD_SERIAL_GET_TX_BUFFER_FREE
return LCD_SERIAL_GET_TX_BUFFER_FREE();
#else
return SIZE_MAX;
#endif
}
void DGUSDisplay::FlushTx() {
#ifdef ARDUINO_ARCH_STM32
LCD_SERIAL.flush();
#else
LCD_SERIAL.flushTX();
#endif
}
void DGUSDisplay::WriteHeader(uint16_t addr, uint8_t command, uint8_t len) {
LCD_SERIAL.write(DGUS_HEADER1);
LCD_SERIAL.write(DGUS_HEADER2);
LCD_SERIAL.write(len + 3);
LCD_SERIAL.write(command);
LCD_SERIAL.write(addr >> 8);
LCD_SERIAL.write(addr & 0xFF);
}
bool DGUS_PopulateVP(const DGUS_Addr addr, DGUS_VP * const buffer) {
const DGUS_VP *ret = vp_list;
do {
const uint16_t *paddr = (uint16_t *)(&ret->addr);
const uint16_t addrcheck = pgm_read_word(paddr);
if (addrcheck == 0) break;
if ((DGUS_Addr)addrcheck == addr) {
memcpy_P(buffer, ret, sizeof(*ret));
return true;
}
} while (++ret);
DEBUG_ECHOLNPGM("VP not found: ", (uint16_t)addr);
return false;
}
#endif // DGUS_LCD_UI_RELOADED

View File

@ -0,0 +1,174 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
/* DGUS implementation written by coldtobi in 2019 for Marlin */
#include "config/DGUS_Screen.h"
#include "config/DGUS_Control.h"
#include "definition/DGUS_VP.h"
#include "../../../inc/MarlinConfigPre.h"
#include "../../../MarlinCore.h"
#define DEBUG_OUT ENABLED(DEBUG_DGUSLCD)
#include "../../../core/debug_out.h"
#define Swap16(val) ((uint16_t)(((uint16_t)(val) >> 8) |\
((uint16_t)(val) << 8)))
// Low-Level access to the display.
class DGUSDisplay {
public:
enum DGUS_ControlType : uint8_t {
VARIABLE_DATA_INPUT = 0x00,
POPUP_WINDOW = 0x01,
INCREMENTAL_ADJUST = 0x02,
SLIDER_ADJUST = 0x03,
RTC_SETTINGS = 0x04,
RETURN_KEY_CODE = 0x05,
TEXT_INPUT = 0x06,
FIRMWARE_SETTINGS = 0x07
};
DGUSDisplay() = default;
static void Init();
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);
template<typename T>
static void Write(uint16_t addr, T data) {
Write(addr, static_cast<const void*>(&data), sizeof(T));
}
// 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)
// Read GUI and OS version from screen
static void ReadVersions();
// Force display into another screen.
static void SwitchScreen(DGUS_Screen screen);
// Play sounds using the display speaker.
// 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);
// Enable/disable a specific touch control.
// type: control type.
// control: index of the control on the page (set during screen development).
static void EnableControl(DGUS_Screen screen, DGUS_ControlType type, DGUS_Control control);
static void DisableControl(DGUS_Screen screen, DGUS_ControlType type, DGUS_Control control);
static uint8_t GetBrightness();
static uint8_t GetVolume();
// Set the display brightness/volume, ranging 0 - 100
static void SetBrightness(uint8_t brightness);
static void SetVolume(uint8_t volume);
// Periodic tasks, eg. Rx-Queue handling.
static void Loop();
// Helper for users of this class to estimate if an interaction would be blocking.
static size_t GetFreeTxBuffer();
static void FlushTx();
// Checks two things: Can we confirm the presence of the display and has we initialized it.
// (both boils down that the display answered to our chatting)
static bool IsInitialized() {
return initialized;
}
static uint8_t gui_version;
static uint8_t os_version;
template<typename T>
static T SwapBytes(const T value) {
union {
T val;
char byte[sizeof(T)];
} src, dst;
src.val = value;
LOOP_L_N(i, sizeof(T)) dst.byte[i] = src.byte[sizeof(T) - i - 1];
return dst.val;
}
template<typename T_in, typename T_out, uint8_t decimals>
T_out FromFixedPoint(const T_in value) {
return (T_out)((float)value / POW(10, decimals));
}
template<typename T_in, typename T_out, uint8_t decimals>
T_out ToFixedPoint(const T_in value) {
return (T_out)LROUND((float)value * POW(10, decimals));
}
private:
enum dgus_header : uint8_t {
DGUS_HEADER1 = 0x5A,
DGUS_HEADER2 = 0xA5
};
enum dgus_command : uint8_t {
DGUS_WRITEVAR = 0x82,
DGUS_READVAR = 0x83
};
enum rx_datagram_state_t : 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.
};
enum dgus_system_addr : uint16_t {
DGUS_VERSION = 0x000f // OS/GUI version
};
static void WriteHeader(uint16_t addr, uint8_t command, uint8_t len);
static void ProcessRx();
static uint8_t volume;
static uint8_t brightness;
static rx_datagram_state_t rx_datagram_state;
static uint8_t rx_datagram_len;
static bool initialized;
};
template<> inline uint16_t DGUSDisplay::SwapBytes(const uint16_t value) {
return ((value << 8) | (value >> 8));
}
extern DGUSDisplay dgus_display;
/// Helper to populate a DGUS_VP for a given VP. Return false if not found.
extern bool DGUS_PopulateVP(const DGUS_Addr addr, DGUS_VP * const buffer);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,122 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 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 "definition/DGUS_VP.h"
namespace DGUSRxHandler {
void ScreenChange(DGUS_VP &, void *);
#if ENABLED(SDSUPPORT)
void Scroll(DGUS_VP &, void *);
void SelectFile(DGUS_VP &, void *);
void PrintFile(DGUS_VP &, void *);
#endif
void PrintAbort(DGUS_VP &, void *);
void PrintPause(DGUS_VP &, void *);
void PrintResume(DGUS_VP &, void *);
void Feedrate(DGUS_VP &, void *);
void Flowrate(DGUS_VP &, void *);
void BabystepSet(DGUS_VP &, void *);
void Babystep(DGUS_VP &, void *);
void TempPreset(DGUS_VP &, void *);
void TempTarget(DGUS_VP &, void *);
void TempCool(DGUS_VP &, void *);
void Steppers(DGUS_VP &, void *);
void ZOffset(DGUS_VP &, void *);
void ZOffsetStep(DGUS_VP &, void *);
void ZOffsetSetStep(DGUS_VP &, void *);
void MoveToPoint(DGUS_VP &, void *);
void Probe(DGUS_VP &, void *);
void DisableABL(DGUS_VP &, void *);
void FilamentSelect(DGUS_VP &, void *);
void FilamentLength(DGUS_VP &, void *);
void FilamentMove(DGUS_VP &, void *);
void Home(DGUS_VP &, void *);
void Move(DGUS_VP &, void *);
void MoveStep(DGUS_VP &, void *);
void MoveSetStep(DGUS_VP &, void *);
void GcodeClear(DGUS_VP &, void *);
void GcodeExecute(DGUS_VP &, void *);
void ResetEEPROM(DGUS_VP &, void *);
void SettingsExtra(DGUS_VP &, void *);
void PIDSelect(DGUS_VP &, void *);
void PIDSetTemp(DGUS_VP &, void *);
void PIDRun(DGUS_VP &, void *);
#if ENABLED(POWER_LOSS_RECOVERY)
void PowerLossAbort(DGUS_VP &, void *);
void PowerLossResume(DGUS_VP &, void *);
#endif
void WaitAbort(DGUS_VP &, void *);
void WaitContinue(DGUS_VP &, void *);
void FanSpeed(DGUS_VP &, void *);
void Volume(DGUS_VP &, void *);
void Brightness(DGUS_VP &, void *);
void Debug(DGUS_VP &, void *);
void StringToExtra(DGUS_VP &, void *);
template<typename T>
void IntegerToExtra(DGUS_VP &vp, void *data_ptr) {
if (!vp.size || !vp.extra) return;
switch (vp.size) {
default: return;
case 1: {
const uint8_t data = *(uint8_t*)data_ptr;
*(T*)vp.extra = (T)data;
break;
}
case 2: {
const uint16_t data = Swap16(*(uint16_t*)data_ptr);
*(T*)vp.extra = (T)data;
break;
}
case 4: {
const uint32_t data = dgus_display.SwapBytes(*(uint32_t*)data_ptr);
*(T*)vp.extra = (T)data;
break;
}
}
}
}

View File

@ -0,0 +1,517 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 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_RELOADED)
#include "DGUSScreenHandler.h"
#include "DGUSDisplay.h"
#include "definition/DGUS_ScreenAddrList.h"
#include "definition/DGUS_ScreenSetup.h"
#include "../../../gcode/queue.h"
uint8_t DGUSScreenHandler::debug_count = 0;
#if ENABLED(SDSUPPORT)
ExtUI::FileList DGUSScreenHandler::filelist;
uint16_t DGUSScreenHandler::filelist_offset = 0;
int16_t DGUSScreenHandler::filelist_selected = -1;
#endif
DGUS_Data::StepSize DGUSScreenHandler::offset_steps = DGUS_Data::StepSize::MMP1;
DGUS_Data::StepSize DGUSScreenHandler::move_steps = DGUS_Data::StepSize::MM10;
uint16_t DGUSScreenHandler::probing_icons[] = { 0, 0 };
DGUS_Data::Extruder DGUSScreenHandler::filament_extruder = DGUS_Data::Extruder::CURRENT;
uint16_t DGUSScreenHandler::filament_length = DGUS_DEFAULT_FILAMENT_LEN;
char DGUSScreenHandler::gcode[] = "";
DGUS_Data::Heater DGUSScreenHandler::pid_heater = DGUS_Data::Heater::H0;
uint16_t DGUSScreenHandler::pid_temp = DGUS_PLA_TEMP_HOTEND;
uint8_t DGUSScreenHandler::pid_cycles = 5;
bool DGUSScreenHandler::settings_ready = false;
bool DGUSScreenHandler::booted = false;
DGUS_Screen DGUSScreenHandler::current_screen = DGUS_Screen::BOOT;
DGUS_Screen DGUSScreenHandler::new_screen = DGUS_Screen::BOOT;
bool DGUSScreenHandler::full_update = false;
DGUS_Screen DGUSScreenHandler::wait_return_screen = DGUS_Screen::HOME;
bool DGUSScreenHandler::wait_continue = false;
bool DGUSScreenHandler::leveling_active = false;
millis_t DGUSScreenHandler::status_expire = 0;
millis_t DGUSScreenHandler::eeprom_save = 0;
const char DGUS_MSG_HOMING_REQUIRED[] PROGMEM = "Homing required",
DGUS_MSG_BUSY[] PROGMEM = "Busy",
DGUS_MSG_UNDEF[] PROGMEM = "-",
DGUS_MSG_HOMING[] PROGMEM = "Homing...",
DGUS_MSG_FW_OUTDATED[] PROGMEM = "DWIN GUI/OS update required",
DGUS_MSG_ABL_REQUIRED[] PROGMEM = "Auto bed leveling required";
const char DGUS_CMD_HOME[] PROGMEM = "G28",
DGUS_CMD_EEPROM_SAVE[] PROGMEM = "M500";
void DGUSScreenHandler::Init() {
dgus_display.Init();
MoveToScreen(DGUS_Screen::BOOT, true);
}
void DGUSScreenHandler::Ready() {
dgus_display.PlaySound(1);
}
void DGUSScreenHandler::Loop() {
if (!settings_ready || current_screen == DGUS_Screen::KILL) {
return;
}
const millis_t ms = ExtUI::safe_millis();
static millis_t next_event_ms = 0;
if (new_screen != DGUS_Screen::BOOT) {
const DGUS_Screen screen = new_screen;
new_screen = DGUS_Screen::BOOT;
if (current_screen == screen)
TriggerFullUpdate();
else
MoveToScreen(screen);
return;
}
if (!booted && ELAPSED(ms, 3000)) {
booted = true;
dgus_display.ReadVersions();
if (current_screen == DGUS_Screen::BOOT)
MoveToScreen(DGUS_Screen::HOME);
return;
}
if (ELAPSED(ms, next_event_ms) || full_update) {
next_event_ms = ms + DGUS_UPDATE_INTERVAL_MS;
if (!SendScreenVPData(current_screen, full_update))
DEBUG_ECHOLNPGM("SendScreenVPData failed");
return;
}
if (current_screen == DGUS_Screen::WAIT
&& ((wait_continue && !wait_for_user)
|| (!wait_continue && IsPrinterIdle()))
) {
MoveToScreen(wait_return_screen, true);
return;
}
if (current_screen == DGUS_Screen::LEVELING_PROBING && IsPrinterIdle()) {
dgus_display.PlaySound(3);
SetStatusMessage(ExtUI::getMeshValid() ? F("Probing successful") : F("Probing failed"));
MoveToScreen(DGUS_Screen::LEVELING_AUTOMATIC);
return;
}
if (status_expire > 0 && ELAPSED(ms, status_expire)) {
SetStatusMessage(FPSTR(NUL_STR), 0);
return;
}
if (eeprom_save > 0 && ELAPSED(ms, eeprom_save) && IsPrinterIdle()) {
eeprom_save = 0;
queue.enqueue_now_P(DGUS_CMD_EEPROM_SAVE);
return;
}
dgus_display.Loop();
}
void DGUSScreenHandler::PrinterKilled(FSTR_P const error, FSTR_P const component) {
SetMessageLinePGM(FTOP(error), 1);
SetMessageLinePGM(FTOP(component), 2);
SetMessageLinePGM(NUL_STR, 3);
SetMessageLinePGM(GET_TEXT(MSG_PLEASE_RESET), 4);
dgus_display.PlaySound(3, 1, 200);
MoveToScreen(DGUS_Screen::KILL, true);
}
void DGUSScreenHandler::UserConfirmRequired(const char * const msg) {
dgus_screen_handler.SetMessageLinePGM(NUL_STR, 1);
dgus_screen_handler.SetMessageLine(msg, 2);
dgus_screen_handler.SetMessageLinePGM(NUL_STR, 3);
dgus_screen_handler.SetMessageLinePGM(NUL_STR, 4);
dgus_display.PlaySound(3);
dgus_screen_handler.ShowWaitScreen(current_screen, true);
}
void DGUSScreenHandler::SettingsReset() {
dgus_display.SetVolume(DGUS_DEFAULT_VOLUME);
dgus_display.SetBrightness(DGUS_DEFAULT_BRIGHTNESS);
if (!settings_ready) {
settings_ready = true;
Ready();
}
SetStatusMessage(F("EEPROM reset"));
}
void DGUSScreenHandler::StoreSettings(char *buff) {
eeprom_data_t data;
static_assert(sizeof(data) <= ExtUI::eeprom_data_size, "sizeof(eeprom_data_t) > eeprom_data_size.");
data.initialized = true;
data.volume = dgus_display.GetVolume();
data.brightness = dgus_display.GetBrightness();
data.abl_okay = (ExtUI::getLevelingActive() && ExtUI::getMeshValid());
memcpy(buff, &data, sizeof(data));
}
void DGUSScreenHandler::LoadSettings(const char *buff) {
eeprom_data_t data;
static_assert(sizeof(data) <= ExtUI::eeprom_data_size, "sizeof(eeprom_data_t) > eeprom_data_size.");
memcpy(&data, buff, sizeof(data));
dgus_display.SetVolume(data.initialized ? data.volume : DGUS_DEFAULT_VOLUME);
dgus_display.SetBrightness(data.initialized ? data.brightness : DGUS_DEFAULT_BRIGHTNESS);
if (data.initialized) {
leveling_active = (data.abl_okay && ExtUI::getMeshValid());
ExtUI::setLevelingActive(leveling_active);
}
}
void DGUSScreenHandler::ConfigurationStoreWritten(bool success) {
if (!success)
SetStatusMessage(F("EEPROM write failed"));
}
void DGUSScreenHandler::ConfigurationStoreRead(bool success) {
if (!success) {
SetStatusMessage(F("EEPROM read failed"));
}
else if (!settings_ready) {
settings_ready = true;
Ready();
}
}
void DGUSScreenHandler::PlayTone(const uint16_t frequency, const uint16_t duration) {
UNUSED(duration);
if (frequency >= 1 && frequency <= 255) {
if (duration >= 1 && duration <= 255)
dgus_display.PlaySound((uint8_t)frequency, (uint8_t)duration);
else
dgus_display.PlaySound((uint8_t)frequency);
}
}
void DGUSScreenHandler::MeshUpdate(const int8_t xpos, const int8_t ypos) {
if (current_screen != DGUS_Screen::LEVELING_PROBING) {
if (current_screen == DGUS_Screen::LEVELING_AUTOMATIC)
TriggerFullUpdate();
return;
}
uint8_t point = ypos * GRID_MAX_POINTS_X + xpos;
probing_icons[point < 16 ? 0 : 1] |= (1U << (point % 16));
if (xpos >= GRID_MAX_POINTS_X - 1 && ypos >= GRID_MAX_POINTS_Y - 1 && !ExtUI::getMeshValid())
probing_icons[0] = probing_icons[1] = 0;
TriggerFullUpdate();
}
void DGUSScreenHandler::PrintTimerStarted() {
TriggerScreenChange(DGUS_Screen::PRINT_STATUS);
}
void DGUSScreenHandler::PrintTimerPaused() {
dgus_display.PlaySound(3);
TriggerFullUpdate();
}
void DGUSScreenHandler::PrintTimerStopped() {
if (current_screen != DGUS_Screen::PRINT_STATUS && current_screen != DGUS_Screen::PRINT_ADJUST)
return;
dgus_display.PlaySound(3);
TriggerScreenChange(DGUS_Screen::PRINT_FINISHED);
}
void DGUSScreenHandler::FilamentRunout(const ExtUI::extruder_t extruder) {
char buffer[21];
snprintf_P(buffer, sizeof(buffer), PSTR("Filament runout E%d"), extruder);
SetStatusMessage(buffer);
dgus_display.PlaySound(3);
}
#if ENABLED(SDSUPPORT)
void DGUSScreenHandler::SDCardInserted() {
if (current_screen == DGUS_Screen::HOME)
TriggerScreenChange(DGUS_Screen::PRINT);
}
void DGUSScreenHandler::SDCardRemoved() {
if (current_screen == DGUS_Screen::PRINT)
TriggerScreenChange(DGUS_Screen::HOME);
}
void DGUSScreenHandler::SDCardError() {
SetStatusMessage(GET_TEXT_F(MSG_MEDIA_READ_ERROR));
if (current_screen == DGUS_Screen::PRINT)
TriggerScreenChange(DGUS_Screen::HOME);
}
#endif // SDSUPPORT
#if ENABLED(POWER_LOSS_RECOVERY)
void DGUSScreenHandler::PowerLossResume() {
MoveToScreen(DGUS_Screen::POWERLOSS, true);
}
#endif // POWER_LOSS_RECOVERY
#if HAS_PID_HEATING
void DGUSScreenHandler::PidTuning(const ExtUI::result_t rst) {
switch (rst) {
case ExtUI::PID_STARTED:
SetStatusMessage(GET_TEXT_F(MSG_PID_AUTOTUNE));
break;
case ExtUI::PID_BAD_EXTRUDER_NUM:
SetStatusMessage(GET_TEXT_F(MSG_PID_BAD_EXTRUDER_NUM));
break;
case ExtUI::PID_TEMP_TOO_HIGH:
SetStatusMessage(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH));
break;
case ExtUI::PID_TUNING_TIMEOUT:
SetStatusMessage(GET_TEXT_F(MSG_PID_TIMEOUT));
break;
case ExtUI::PID_DONE:
SetStatusMessage(GET_TEXT_F(MSG_PID_AUTOTUNE_DONE));
break;
default:
return;
}
dgus_display.PlaySound(3);
}
#endif // HAS_PID_HEATING
void DGUSScreenHandler::SetMessageLine(const char* msg, uint8_t line) {
switch (line) {
default: return;
case 1:
dgus_display.WriteString((uint16_t)DGUS_Addr::MESSAGE_Line1, msg, DGUS_LINE_LEN, true, true);
break;
case 2:
dgus_display.WriteString((uint16_t)DGUS_Addr::MESSAGE_Line2, msg, DGUS_LINE_LEN, true, true);
break;
case 3:
dgus_display.WriteString((uint16_t)DGUS_Addr::MESSAGE_Line3, msg, DGUS_LINE_LEN, true, true);
break;
case 4:
dgus_display.WriteString((uint16_t)DGUS_Addr::MESSAGE_Line4, msg, DGUS_LINE_LEN, true, true);
break;
}
}
void DGUSScreenHandler::SetMessageLinePGM(PGM_P msg, uint8_t line) {
switch (line) {
default: return;
case 1:
dgus_display.WriteStringPGM((uint16_t)DGUS_Addr::MESSAGE_Line1, msg, DGUS_LINE_LEN, true, true);
break;
case 2:
dgus_display.WriteStringPGM((uint16_t)DGUS_Addr::MESSAGE_Line2, msg, DGUS_LINE_LEN, true, true);
break;
case 3:
dgus_display.WriteStringPGM((uint16_t)DGUS_Addr::MESSAGE_Line3, msg, DGUS_LINE_LEN, true, true);
break;
case 4:
dgus_display.WriteStringPGM((uint16_t)DGUS_Addr::MESSAGE_Line4, msg, DGUS_LINE_LEN, true, true);
break;
}
}
void DGUSScreenHandler::SetStatusMessage(const char* msg, const millis_t duration) {
dgus_display.WriteString((uint16_t)DGUS_Addr::MESSAGE_Status, msg, DGUS_STATUS_LEN, false, true);
status_expire = (duration > 0 ? ExtUI::safe_millis() + duration : 0);
}
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);
status_expire = (duration > 0 ? ExtUI::safe_millis() + duration : 0);
}
void DGUSScreenHandler::ShowWaitScreen(DGUS_Screen return_screen, bool has_continue) {
if (return_screen != DGUS_Screen::WAIT) {
wait_return_screen = return_screen;
}
wait_continue = has_continue;
TriggerScreenChange(DGUS_Screen::WAIT);
}
DGUS_Screen DGUSScreenHandler::GetCurrentScreen() {
return current_screen;
}
void DGUSScreenHandler::TriggerScreenChange(DGUS_Screen screen) {
new_screen = screen;
}
void DGUSScreenHandler::TriggerFullUpdate() {
full_update = true;
}
void DGUSScreenHandler::TriggerEEPROMSave() {
eeprom_save = ExtUI::safe_millis() + 500;
}
bool DGUSScreenHandler::IsPrinterIdle() {
return (!ExtUI::commandsInQueue()
&& !ExtUI::isMoving());
}
const DGUS_Addr* DGUSScreenHandler::FindScreenAddrList(DGUS_Screen screen) {
DGUS_ScreenAddrList list;
const DGUS_ScreenAddrList *map = screen_addr_list_map;
do {
memcpy_P(&list, map, sizeof(*map));
if (!list.addr_list) break;
if (list.screen == screen) {
return list.addr_list;
}
} while (++map);
return nullptr;
}
bool DGUSScreenHandler::CallScreenSetup(DGUS_Screen screen) {
DGUS_ScreenSetup setup;
const DGUS_ScreenSetup *list = screen_setup_list;
do {
memcpy_P(&setup, list, sizeof(*list));
if (!setup.setup_fn) break;
if (setup.screen == screen) {
return setup.setup_fn();
}
} while (++list);
return true;
}
void DGUSScreenHandler::MoveToScreen(DGUS_Screen screen, bool abort_wait) {
if (current_screen == DGUS_Screen::KILL) {
return;
}
if (current_screen == DGUS_Screen::WAIT) {
if (screen != DGUS_Screen::WAIT) {
wait_return_screen = screen;
}
if (!abort_wait) return;
if (wait_continue && wait_for_user) {
ExtUI::setUserConfirmed();
}
}
if (!CallScreenSetup(screen)) return;
if (!SendScreenVPData(screen, true)) {
DEBUG_ECHOLNPGM("SendScreenVPData failed");
return;
}
current_screen = screen;
dgus_display.SwitchScreen(current_screen);
}
bool DGUSScreenHandler::SendScreenVPData(DGUS_Screen screen, bool complete_update) {
if (complete_update) {
full_update = false;
}
const DGUS_Addr *list = FindScreenAddrList(screen);
while (true) {
if (!list) return true; // Nothing left to send
const uint16_t addr = pgm_read_word(list++);
if (!addr) return true; // Nothing left to send
DGUS_VP vp;
if (!DGUS_PopulateVP((DGUS_Addr)addr, &vp)) continue; // Invalid VP
if (!vp.tx_handler) continue; // Nothing to send
if (!complete_update && !(vp.flags & VPFLAG_AUTOUPLOAD)) continue; // Unnecessary VP
uint8_t expected_tx = 6 + vp.size; // 6 bytes header + payload.
const millis_t try_until = ExtUI::safe_millis() + 1000;
while (expected_tx > dgus_display.GetFreeTxBuffer()) {
if (ELAPSED(ExtUI::safe_millis(), try_until)) return false; // Stop trying after 1 second
dgus_display.FlushTx(); // Flush the TX buffer
delay(50);
}
vp.tx_handler(vp);
}
}
#endif // DGUS_LCD_UI_RELOADED

View File

@ -0,0 +1,151 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 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 "config/DGUS_Addr.h"
#include "config/DGUS_Data.h"
#include "config/DGUS_Screen.h"
#include "config/DGUS_Constants.h"
#include "../ui_api.h"
#include "../../../inc/MarlinConfigPre.h"
class DGUSScreenHandler {
public:
DGUSScreenHandler() = default;
static void Init();
static void Ready();
static void Loop();
static void PrinterKilled(FSTR_P const error, FSTR_P const component);
static void UserConfirmRequired(const char * const msg);
static void SettingsReset();
static void StoreSettings(char *buff);
static void LoadSettings(const char *buff);
static void ConfigurationStoreWritten(bool success);
static void ConfigurationStoreRead(bool success);
static void PlayTone(const uint16_t frequency, const uint16_t duration);
static void MeshUpdate(const int8_t xpos, const int8_t ypos);
static void PrintTimerStarted();
static void PrintTimerPaused();
static void PrintTimerStopped();
static void FilamentRunout(const ExtUI::extruder_t extruder);
#if ENABLED(SDSUPPORT)
/// 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
#if ENABLED(POWER_LOSS_RECOVERY)
static void PowerLossResume();
#endif
#if HAS_PID_HEATING
static void PidTuning(const ExtUI::result_t rst);
#endif
static void SetMessageLine(const char* msg, uint8_t line);
static void SetMessageLinePGM(PGM_P msg, uint8_t line);
static void SetStatusMessage(const char* msg, const millis_t duration = DGUS_STATUS_EXPIRATION_MS);
static void SetStatusMessage(FSTR_P const msg, const millis_t duration = DGUS_STATUS_EXPIRATION_MS);
static void ShowWaitScreen(DGUS_Screen return_screen, bool has_continue = false);
static DGUS_Screen GetCurrentScreen();
static void TriggerScreenChange(DGUS_Screen screen);
static void TriggerFullUpdate();
static void TriggerEEPROMSave();
static bool IsPrinterIdle();
static uint8_t debug_count;
#if ENABLED(SDSUPPORT)
static ExtUI::FileList filelist;
static uint16_t filelist_offset;
static int16_t filelist_selected;
#endif
static DGUS_Data::StepSize offset_steps;
static DGUS_Data::StepSize move_steps;
static uint16_t probing_icons[2];
static DGUS_Data::Extruder filament_extruder;
static uint16_t filament_length;
static char gcode[DGUS_GCODE_LEN + 1];
static DGUS_Data::Heater pid_heater;
static uint16_t pid_temp;
static uint8_t pid_cycles;
static bool wait_continue;
static bool leveling_active;
private:
static const DGUS_Addr* FindScreenAddrList(DGUS_Screen screen);
static bool CallScreenSetup(DGUS_Screen screen);
static void MoveToScreen(DGUS_Screen screen, bool abort_wait = false);
static bool SendScreenVPData(DGUS_Screen screen, bool complete_update);
static bool settings_ready;
static bool booted;
static DGUS_Screen current_screen;
static DGUS_Screen new_screen;
static bool full_update;
static DGUS_Screen wait_return_screen;
static millis_t status_expire;
static millis_t eeprom_save;
typedef struct {
bool initialized;
uint8_t volume;
uint8_t brightness;
bool abl_okay;
} eeprom_data_t;
};
extern DGUSScreenHandler dgus_screen_handler;
extern const char DGUS_MSG_HOMING_REQUIRED[],
DGUS_MSG_BUSY[],
DGUS_MSG_UNDEF[],
DGUS_MSG_HOMING[],
DGUS_MSG_FW_OUTDATED[],
DGUS_MSG_ABL_REQUIRED[];
extern const char DGUS_CMD_HOME[],
DGUS_CMD_EEPROM_SAVE[];

View File

@ -0,0 +1,209 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 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_RELOADED)
#include "DGUSSetupHandler.h"
#include "DGUSDisplay.h"
#include "DGUSScreenHandler.h"
#include "../../../gcode/queue.h"
#if ENABLED(SDSUPPORT)
bool DGUSSetupHandler::Print() {
dgus_screen_handler.filelist.refresh();
while (!dgus_screen_handler.filelist.isAtRootDir()) {
dgus_screen_handler.filelist.upDir();
}
dgus_screen_handler.filelist_offset = 0;
dgus_screen_handler.filelist_selected = -1;
return true;
}
#endif
bool DGUSSetupHandler::PrintStatus() {
if (ExtUI::isPrinting() || ExtUI::isPrintingPaused()) {
return true;
}
dgus_screen_handler.TriggerScreenChange(DGUS_Screen::PRINT_FINISHED);
return false;
}
bool DGUSSetupHandler::PrintAdjust() {
if (ExtUI::isPrinting() || ExtUI::isPrintingPaused()) {
return true;
}
dgus_screen_handler.TriggerScreenChange(DGUS_Screen::PRINT_FINISHED);
return false;
}
bool DGUSSetupHandler::LevelingMenu() {
ExtUI::setLevelingActive(dgus_screen_handler.leveling_active);
if (!dgus_screen_handler.IsPrinterIdle()) {
dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_BUSY));
return false;
}
if (ExtUI::isPositionKnown()) {
if (ExtUI::getAxisPosition_mm(ExtUI::Z) < 10.0f) {
queue.enqueue_now(F("G0Z10"));
}
return true;
}
dgus_screen_handler.SetMessageLinePGM(NUL_STR, 1);
dgus_screen_handler.SetMessageLinePGM(DGUS_MSG_HOMING, 2);
dgus_screen_handler.SetMessageLinePGM(NUL_STR, 3);
dgus_screen_handler.SetMessageLinePGM(NUL_STR, 4);
dgus_screen_handler.ShowWaitScreen(DGUS_Screen::LEVELING_MENU);
queue.enqueue_now_P(DGUS_CMD_HOME);
return false;
}
bool DGUSSetupHandler::LevelingManual() {
ExtUI::setLevelingActive(false);
if (ExtUI::isPositionKnown()) {
return true;
}
if (!dgus_screen_handler.IsPrinterIdle()) {
dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_BUSY));
return false;
}
dgus_screen_handler.SetMessageLinePGM(NUL_STR, 1);
dgus_screen_handler.SetMessageLinePGM(DGUS_MSG_HOMING, 2);
dgus_screen_handler.SetMessageLinePGM(NUL_STR, 3);
dgus_screen_handler.SetMessageLinePGM(NUL_STR, 4);
dgus_screen_handler.ShowWaitScreen(DGUS_Screen::LEVELING_MANUAL);
queue.enqueue_now_P(DGUS_CMD_HOME);
return false;
}
bool DGUSSetupHandler::LevelingOffset() {
dgus_screen_handler.offset_steps = DGUS_Data::StepSize::MMP1;
if (!dgus_screen_handler.IsPrinterIdle()) {
dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_BUSY));
return false;
}
if (ExtUI::isPositionKnown()) {
if (ExtUI::getAxisPosition_mm(ExtUI::Z) < 4.0f) {
queue.enqueue_now(F("G0Z4"));
}
char buffer[20];
snprintf_P(buffer, sizeof(buffer), PSTR("G0X%dY%d"), DGUS_LEVEL_CENTER_X, DGUS_LEVEL_CENTER_Y);
queue.enqueue_one_now(buffer);
queue.enqueue_now(F("G0Z0"));
return true;
}
dgus_screen_handler.SetMessageLinePGM(NUL_STR, 1);
dgus_screen_handler.SetMessageLinePGM(DGUS_MSG_HOMING, 2);
dgus_screen_handler.SetMessageLinePGM(NUL_STR, 3);
dgus_screen_handler.SetMessageLinePGM(NUL_STR, 4);
dgus_screen_handler.ShowWaitScreen(DGUS_Screen::LEVELING_OFFSET);
queue.enqueue_now_P(DGUS_CMD_HOME);
return false;
}
bool DGUSSetupHandler::LevelingAutomatic() {
if (ExtUI::getMeshValid()) {
dgus_screen_handler.leveling_active = true;
ExtUI::setLevelingActive(true);
}
return true;
}
bool DGUSSetupHandler::LevelingProbing() {
dgus_screen_handler.probing_icons[0] = 0;
dgus_screen_handler.probing_icons[1] = 0;
return true;
}
bool DGUSSetupHandler::Filament() {
dgus_screen_handler.filament_extruder = DGUS_Data::Extruder::CURRENT;
dgus_screen_handler.filament_length = DGUS_DEFAULT_FILAMENT_LEN;
return true;
}
bool DGUSSetupHandler::Move() {
dgus_screen_handler.move_steps = DGUS_Data::StepSize::MM10;
if (!dgus_screen_handler.IsPrinterIdle()) {
dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_BUSY));
return false;
}
return true;
}
bool DGUSSetupHandler::Gcode() {
ZERO(dgus_screen_handler.gcode);
if (dgus_display.gui_version < 0x30 || dgus_display.os_version < 0x21) {
dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_FW_OUTDATED));
return false;
}
return true;
}
bool DGUSSetupHandler::PID() {
dgus_screen_handler.pid_heater = DGUS_Data::Heater::H0;
dgus_screen_handler.pid_temp = DGUS_PLA_TEMP_HOTEND;
return true;
}
bool DGUSSetupHandler::Infos() {
dgus_screen_handler.debug_count = 0;
return true;
}
#endif // DGUS_LCD_UI_RELOADED

View File

@ -0,0 +1,42 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 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
namespace DGUSSetupHandler {
#if ENABLED(SDSUPPORT)
bool Print();
#endif
bool PrintStatus();
bool PrintAdjust();
bool LevelingMenu();
bool LevelingOffset();
bool LevelingManual();
bool LevelingAutomatic();
bool LevelingProbing();
bool Filament();
bool Move();
bool Gcode();
bool PID();
bool Infos();
}

View File

@ -0,0 +1,618 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 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_RELOADED)
#include "DGUSTxHandler.h"
#include "DGUSScreenHandler.h"
#include "config/DGUS_Data.h"
#include "../ui_api.h"
#include "../../../module/stepper.h"
#include "../../../module/printcounter.h"
#if ENABLED(ADVANCED_PAUSE_FEATURE)
#include "../../../feature/pause.h"
#endif
#if ENABLED(SDSUPPORT)
void DGUSTxHandler::SetFileControlState(int file, bool state) {
DGUS_Control control;
switch (file) {
default: return;
case 0:
control = DGUS_Control::FILE0;
break;
case 1:
control = DGUS_Control::FILE1;
break;
case 2:
control = DGUS_Control::FILE2;
break;
case 3:
control = DGUS_Control::FILE3;
break;
case 4:
control = DGUS_Control::FILE4;
break;
}
if (state) {
dgus_display.EnableControl(DGUS_Screen::PRINT,
DGUSDisplay::RETURN_KEY_CODE,
control);
}
else {
dgus_display.DisableControl(DGUS_Screen::PRINT,
DGUSDisplay::RETURN_KEY_CODE,
control);
}
}
void DGUSTxHandler::FileType(DGUS_VP &vp) {
// Batch send
uint16_t data[DGUS_FILE_COUNT];
for (int i = 0; i < DGUS_FILE_COUNT; i++) {
if (!dgus_screen_handler.filelist.seek(dgus_screen_handler.filelist_offset + i)) {
data[i] = Swap16((uint16_t)DGUS_Data::SDType::NONE);
SetFileControlState(i, false);
continue;
}
data[i] = dgus_screen_handler.filelist.isDir() ?
Swap16((uint16_t)DGUS_Data::SDType::DIRECTORY)
: Swap16((uint16_t)DGUS_Data::SDType::FILE);
SetFileControlState(i, true);
}
dgus_display.Write((uint16_t)vp.addr, data, sizeof(*data) * DGUS_FILE_COUNT);
}
void DGUSTxHandler::FileName(DGUS_VP &vp) {
uint8_t offset;
switch (vp.addr) {
default: return;
case DGUS_Addr::SD_FileName0:
offset = 0;
break;
case DGUS_Addr::SD_FileName1:
offset = 1;
break;
case DGUS_Addr::SD_FileName2:
offset = 2;
break;
case DGUS_Addr::SD_FileName3:
offset = 3;
break;
case DGUS_Addr::SD_FileName4:
offset = 4;
break;
}
if (dgus_screen_handler.filelist.seek(dgus_screen_handler.filelist_offset + offset)) {
dgus_display.WriteString((uint16_t)vp.addr, dgus_screen_handler.filelist.filename(), vp.size);
}
else {
dgus_display.WriteStringPGM((uint16_t)vp.addr, NUL_STR, vp.size);
}
}
void DGUSTxHandler::ScrollIcons(DGUS_VP &vp) {
uint16_t icons = 0;
if (!dgus_screen_handler.filelist.isAtRootDir()) {
icons |= (uint16_t)DGUS_Data::ScrollIcon::GO_BACK;
dgus_display.EnableControl(DGUS_Screen::PRINT,
DGUSDisplay::RETURN_KEY_CODE,
DGUS_Control::GO_BACK);
}
else {
dgus_display.DisableControl(DGUS_Screen::PRINT,
DGUSDisplay::RETURN_KEY_CODE,
DGUS_Control::GO_BACK);
}
if (dgus_screen_handler.filelist_offset > 0) {
icons |= (uint16_t)DGUS_Data::ScrollIcon::UP;
dgus_display.EnableControl(DGUS_Screen::PRINT,
DGUSDisplay::RETURN_KEY_CODE,
DGUS_Control::SCROLL_UP);
}
else {
dgus_display.DisableControl(DGUS_Screen::PRINT,
DGUSDisplay::RETURN_KEY_CODE,
DGUS_Control::SCROLL_UP);
}
if (dgus_screen_handler.filelist_offset + DGUS_FILE_COUNT < dgus_screen_handler.filelist.count()) {
icons |= (uint16_t)DGUS_Data::ScrollIcon::DOWN;
dgus_display.EnableControl(DGUS_Screen::PRINT,
DGUSDisplay::RETURN_KEY_CODE,
DGUS_Control::SCROLL_DOWN);
}
else {
dgus_display.DisableControl(DGUS_Screen::PRINT,
DGUSDisplay::RETURN_KEY_CODE,
DGUS_Control::SCROLL_DOWN);
}
dgus_display.Write((uint16_t)vp.addr, Swap16(icons));
}
void DGUSTxHandler::SelectedFileName(DGUS_VP &vp) {
if (dgus_screen_handler.filelist_selected < 0
|| !dgus_screen_handler.filelist.seek(dgus_screen_handler.filelist_selected)) {
dgus_display.WriteStringPGM((uint16_t)vp.addr, NUL_STR, vp.size);
return;
}
dgus_display.WriteString((uint16_t)vp.addr, dgus_screen_handler.filelist.filename(), vp.size);
}
#endif // SDSUPPORT
void DGUSTxHandler::PositionZ(DGUS_VP &vp) {
float position = ExtUI::isAxisPositionKnown(ExtUI::Z) ?
planner.get_axis_position_mm(Z_AXIS)
: 0;
const int16_t data = dgus_display.ToFixedPoint<float, int16_t, 1>(position);
dgus_display.Write((uint16_t)vp.addr, Swap16(data));
}
void DGUSTxHandler::Ellapsed(DGUS_VP &vp) {
char buffer[21];
duration_t(print_job_timer.duration()).toString(buffer);
dgus_display.WriteString((uint16_t)vp.addr, buffer, vp.size);
}
void DGUSTxHandler::Percent(DGUS_VP &vp) {
uint16_t progress;
switch (vp.addr) {
default: return;
case DGUS_Addr::STATUS_Percent:
progress = constrain(ExtUI::getProgress_percent(), 0, 100);
break;
case DGUS_Addr::STATUS_Percent_Complete:
progress = 100;
break;
}
dgus_display.Write((uint16_t)DGUS_Addr::STATUS_Percent, Swap16(progress));
}
void DGUSTxHandler::StatusIcons(DGUS_VP &vp) {
uint16_t icons = 0;
if (ExtUI::isPrinting()) {
icons |= (uint16_t)DGUS_Data::StatusIcon::PAUSE;
dgus_display.EnableControl(DGUS_Screen::PRINT_STATUS,
DGUSDisplay::POPUP_WINDOW,
DGUS_Control::PAUSE);
}
else {
dgus_display.DisableControl(DGUS_Screen::PRINT_STATUS,
DGUSDisplay::POPUP_WINDOW,
DGUS_Control::PAUSE);
}
if (ExtUI::isPrintingPaused()) {
icons |= (uint16_t)DGUS_Data::StatusIcon::RESUME;
dgus_display.EnableControl(DGUS_Screen::PRINT_STATUS,
DGUSDisplay::POPUP_WINDOW,
DGUS_Control::RESUME);
}
else {
dgus_display.DisableControl(DGUS_Screen::PRINT_STATUS,
DGUSDisplay::POPUP_WINDOW,
DGUS_Control::RESUME);
}
dgus_display.Write((uint16_t)vp.addr, Swap16(icons));
}
void DGUSTxHandler::Flowrate(DGUS_VP &vp) {
int16_t flowrate;
switch (vp.addr) {
default: return;
case DGUS_Addr::ADJUST_Flowrate_CUR:
flowrate = ExtUI::getFlow_percent(TERN(HAS_MULTI_EXTRUDER, ExtUI::getActiveTool(), ExtUI::E0));
break;
#if HAS_MULTI_EXTRUDER
case DGUS_Addr::ADJUST_Flowrate_E0:
flowrate = ExtUI::getFlow_percent(ExtUI::E0);
break;
case DGUS_Addr::ADJUST_Flowrate_E1:
flowrate = ExtUI::getFlow_percent(ExtUI::E1);
break;
#endif
}
dgus_display.Write((uint16_t)vp.addr, Swap16(flowrate));
}
void DGUSTxHandler::TempMax(DGUS_VP &vp) {
uint16_t temp;
switch (vp.addr) {
default: return;
case DGUS_Addr::TEMP_Max_Bed:
temp = BED_MAX_TARGET;
break;
case DGUS_Addr::TEMP_Max_H0:
temp = HEATER_0_MAXTEMP - HOTEND_OVERSHOOT;
break;
#if HAS_MULTI_HOTEND
case DGUS_Addr::TEMP_Max_H1:
temp = HEATER_1_MAXTEMP - HOTEND_OVERSHOOT;
break;
#endif
}
dgus_display.Write((uint16_t)vp.addr, Swap16(temp));
}
void DGUSTxHandler::StepperStatus(DGUS_VP &vp) {
const bool motor_on = stepper.axis_enabled.bits & (_BV(NUM_AXES) - 1);
dgus_display.Write((uint16_t)vp.addr, Swap16(uint16_t(motor_on ? DGUS_Data::Status::ENABLED : DGUS_Data::Status::DISABLED)));
}
void DGUSTxHandler::StepIcons(DGUS_VP &vp) {
if (!vp.extra) return;
uint16_t icons = 0;
DGUS_Data::StepSize size = *(DGUS_Data::StepSize*)vp.extra;
switch (size) {
case DGUS_Data::StepSize::MM10:
icons |= (uint16_t)DGUS_Data::StepIcon::MM10;
break;
case DGUS_Data::StepSize::MM1:
icons |= (uint16_t)DGUS_Data::StepIcon::MM1;
break;
case DGUS_Data::StepSize::MMP1:
icons |= (uint16_t)DGUS_Data::StepIcon::MMP1;
break;
case DGUS_Data::StepSize::MMP01:
icons |= (uint16_t)DGUS_Data::StepIcon::MMP01;
break;
}
dgus_display.Write((uint16_t)vp.addr, Swap16(icons));
}
void DGUSTxHandler::ABLDisableIcon(DGUS_VP &vp) {
uint16_t data;
if (ExtUI::getLevelingActive()) {
data = (uint16_t)DGUS_Data::Status::ENABLED;
dgus_display.EnableControl(DGUS_Screen::LEVELING_AUTOMATIC,
DGUSDisplay::RETURN_KEY_CODE,
DGUS_Control::DISABLE);
}
else {
data = (uint16_t)DGUS_Data::Status::DISABLED;
dgus_display.DisableControl(DGUS_Screen::LEVELING_AUTOMATIC,
DGUSDisplay::RETURN_KEY_CODE,
DGUS_Control::DISABLE);
}
dgus_display.Write((uint16_t)vp.addr, Swap16(data));
}
void DGUSTxHandler::ABLGrid(DGUS_VP &vp) {
// Batch send
int16_t data[DGUS_LEVEL_GRID_SIZE];
xy_uint8_t point;
int16_t fixed;
for (int i = 0; i < DGUS_LEVEL_GRID_SIZE; i++) {
point.x = i % (GRID_MAX_POINTS_X);
point.y = i / (GRID_MAX_POINTS_X);
fixed = dgus_display.ToFixedPoint<float, int16_t, 3>(ExtUI::getMeshPoint(point));
data[i] = Swap16(fixed);
}
dgus_display.Write((uint16_t)vp.addr, data, sizeof(*data) * DGUS_LEVEL_GRID_SIZE);
}
void DGUSTxHandler::FilamentIcons(DGUS_VP &vp) {
uint16_t icons = 0;
switch (dgus_screen_handler.filament_extruder) {
default: return;
case DGUS_Data::Extruder::CURRENT:
#if HAS_MULTI_EXTRUDER
switch (ExtUI::getActiveTool()) {
default: break;
case ExtUI::E0:
icons |= (uint16_t)DGUS_Data::ExtruderIcon::E0;
break;
case ExtUI::E1:
icons |= (uint16_t)DGUS_Data::ExtruderIcon::E1;
break;
}
break;
#endif
case DGUS_Data::Extruder::E0:
icons |= (uint16_t)DGUS_Data::ExtruderIcon::E0;
break;
case DGUS_Data::Extruder::E1:
icons |= (uint16_t)DGUS_Data::ExtruderIcon::E1;
break;
}
dgus_display.Write((uint16_t)vp.addr, Swap16(icons));
}
void DGUSTxHandler::BLTouch(DGUS_VP &vp) {
#if ENABLED(BLTOUCH)
dgus_display.EnableControl(DGUS_Screen::SETTINGS_MENU2,
DGUSDisplay::RETURN_KEY_CODE,
DGUS_Control::EXTRA2);
dgus_display.Write((uint16_t)vp.addr, Swap16((uint16_t)DGUS_Data::Status::ENABLED));
#else
dgus_display.DisableControl(DGUS_Screen::SETTINGS_MENU2,
DGUSDisplay::RETURN_KEY_CODE,
DGUS_Control::EXTRA2);
dgus_display.Write((uint16_t)vp.addr, Swap16((uint16_t)DGUS_Data::Status::DISABLED));
#endif
}
void DGUSTxHandler::PIDIcons(DGUS_VP &vp) {
uint16_t icons = 0;
switch (dgus_screen_handler.pid_heater) {
default: return;
case DGUS_Data::Heater::BED:
icons |= (uint16_t)DGUS_Data::HeaterIcon::BED;
break;
case DGUS_Data::Heater::H0:
icons |= (uint16_t)DGUS_Data::HeaterIcon::H0;
break;
case DGUS_Data::Heater::H1:
icons |= (uint16_t)DGUS_Data::HeaterIcon::H1;
break;
}
dgus_display.Write((uint16_t)vp.addr, Swap16(icons));
}
void DGUSTxHandler::PIDKp(DGUS_VP &vp) {
float value;
switch (dgus_screen_handler.pid_heater) {
default: return;
#if ENABLED(PIDTEMPBED)
case DGUS_Data::Heater::BED:
value = ExtUI::getBedPIDValues_Kp();
break;
#endif
#if ENABLED(PIDTEMP)
case DGUS_Data::Heater::H0:
value = ExtUI::getPIDValues_Kp(ExtUI::E0);
break;
#if HAS_MULTI_HOTEND
case DGUS_Data::Heater::H1:
value = ExtUI::getPIDValues_Kp(ExtUI::E1);
break;
#endif
#endif
}
const int32_t data = dgus_display.ToFixedPoint<float, int32_t, 2>(value);
dgus_display.Write((uint16_t)vp.addr, dgus_display.SwapBytes(data));
}
void DGUSTxHandler::PIDKi(DGUS_VP &vp) {
float value;
switch (dgus_screen_handler.pid_heater) {
default: return;
#if ENABLED(PIDTEMPBED)
case DGUS_Data::Heater::BED:
value = ExtUI::getBedPIDValues_Ki();
break;
#endif
#if ENABLED(PIDTEMP)
case DGUS_Data::Heater::H0:
value = ExtUI::getPIDValues_Ki(ExtUI::E0);
break;
#if HAS_MULTI_HOTEND
case DGUS_Data::Heater::H1:
value = ExtUI::getPIDValues_Ki(ExtUI::E1);
break;
#endif
#endif
}
const int32_t data = dgus_display.ToFixedPoint<float, int32_t, 2>(value);
dgus_display.Write((uint16_t)vp.addr, dgus_display.SwapBytes(data));
}
void DGUSTxHandler::PIDKd(DGUS_VP &vp) {
float value;
switch (dgus_screen_handler.pid_heater) {
default: return;
#if ENABLED(PIDTEMPBED)
case DGUS_Data::Heater::BED:
value = ExtUI::getBedPIDValues_Kd();
break;
#endif
#if ENABLED(PIDTEMP)
case DGUS_Data::Heater::H0:
value = ExtUI::getPIDValues_Kd(ExtUI::E0);
break;
#if HAS_MULTI_HOTEND
case DGUS_Data::Heater::H1:
value = ExtUI::getPIDValues_Kd(ExtUI::E1);
break;
#endif
#endif
}
const int32_t data = dgus_display.ToFixedPoint<float, int32_t, 2>(value);
dgus_display.Write((uint16_t)vp.addr, dgus_display.SwapBytes(data));
}
void DGUSTxHandler::BuildVolume(DGUS_VP &vp) {
char buffer[vp.size];
snprintf_P(buffer, vp.size, PSTR("%dx%dx%d"), X_BED_SIZE, Y_BED_SIZE, (Z_MAX_POS - Z_MIN_POS));
dgus_display.WriteString((uint16_t)vp.addr, buffer, vp.size);
}
void DGUSTxHandler::TotalPrints(DGUS_VP &vp) {
#if ENABLED(PRINTCOUNTER)
dgus_display.Write((uint16_t)vp.addr, dgus_display.SwapBytes(print_job_timer.getStats().totalPrints));
#else
UNUSED(vp);
#endif
}
void DGUSTxHandler::FinishedPrints(DGUS_VP &vp) {
#if ENABLED(PRINTCOUNTER)
dgus_display.Write((uint16_t)vp.addr, dgus_display.SwapBytes(print_job_timer.getStats().finishedPrints));
#else
UNUSED(vp);
#endif
}
void DGUSTxHandler::PrintTime(DGUS_VP &vp) {
#if ENABLED(PRINTCOUNTER)
char buffer[21];
ExtUI::getTotalPrintTime_str(buffer);
dgus_display.WriteString((uint16_t)vp.addr, buffer, vp.size);
#else
dgus_display.WriteStringPGM((uint16_t)vp.addr, DGUS_MSG_UNDEF, vp.size);
#endif
}
void DGUSTxHandler::LongestPrint(DGUS_VP &vp) {
#if ENABLED(PRINTCOUNTER)
char buffer[21];
ExtUI::getLongestPrint_str(buffer);
dgus_display.WriteString((uint16_t)vp.addr, buffer, vp.size);
#else
dgus_display.WriteStringPGM((uint16_t)vp.addr, DGUS_MSG_UNDEF, vp.size);
#endif
}
void DGUSTxHandler::FilamentUsed(DGUS_VP &vp) {
#if ENABLED(PRINTCOUNTER)
char buffer[21];
ExtUI::getFilamentUsed_str(buffer);
dgus_display.WriteString((uint16_t)vp.addr, buffer, vp.size);
#else
dgus_display.WriteStringPGM((uint16_t)vp.addr, DGUS_MSG_UNDEF, vp.size);
#endif
}
void DGUSTxHandler::WaitIcons(DGUS_VP &vp) {
uint16_t icons = 0;
if (ExtUI::isPrintingPaused()) {
icons |= (uint16_t)DGUS_Data::WaitIcon::ABORT;
dgus_display.EnableControl(DGUS_Screen::WAIT,
DGUSDisplay::POPUP_WINDOW,
DGUS_Control::ABORT);
}
else {
dgus_display.DisableControl(DGUS_Screen::WAIT,
DGUSDisplay::POPUP_WINDOW,
DGUS_Control::ABORT);
}
if (dgus_screen_handler.wait_continue) {
icons |= (uint16_t)DGUS_Data::WaitIcon::CONTINUE;
dgus_display.EnableControl(DGUS_Screen::WAIT,
DGUSDisplay::RETURN_KEY_CODE,
DGUS_Control::CONTINUE);
}
else {
dgus_display.DisableControl(DGUS_Screen::WAIT,
DGUSDisplay::RETURN_KEY_CODE,
DGUS_Control::CONTINUE);
}
dgus_display.Write((uint16_t)vp.addr, Swap16(icons));
}
void DGUSTxHandler::FanSpeed(DGUS_VP &vp) {
uint16_t fan_speed;
switch (vp.addr) {
default: return;
case DGUS_Addr::FAN0_Speed: fan_speed = ExtUI::getTargetFan_percent(ExtUI::FAN0); break;
}
dgus_display.Write((uint16_t)vp.addr, Swap16(fan_speed));
}
void DGUSTxHandler::Volume(DGUS_VP &vp) {
const uint16_t volume = dgus_display.GetVolume();
dgus_display.Write((uint16_t)vp.addr, Swap16(volume));
}
void DGUSTxHandler::Brightness(DGUS_VP &vp) {
const uint16_t brightness = dgus_display.GetBrightness();
dgus_display.Write((uint16_t)vp.addr, Swap16(brightness));
}
void DGUSTxHandler::ExtraToString(DGUS_VP &vp) {
if (!vp.size || !vp.extra) return;
dgus_display.WriteString((uint16_t)vp.addr, vp.extra, vp.size, true, false, false);
}
void DGUSTxHandler::ExtraPGMToString(DGUS_VP &vp) {
if (!vp.size || !vp.extra) return;
dgus_display.WriteStringPGM((uint16_t)vp.addr, vp.extra, vp.size, true, false, false);
}
#endif // DGUS_LCD_UI_RELOADED

View File

@ -0,0 +1,126 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 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 "definition/DGUS_VP.h"
namespace DGUSTxHandler {
#if ENABLED(SDSUPPORT)
void SetFileControlState(int, bool);
void FileType(DGUS_VP &);
void FileName(DGUS_VP &);
void ScrollIcons(DGUS_VP &);
void SelectedFileName(DGUS_VP &);
#endif
void PositionZ(DGUS_VP &);
void Ellapsed(DGUS_VP &);
void Percent(DGUS_VP &);
void StatusIcons(DGUS_VP &);
void Flowrate(DGUS_VP &);
void TempMax(DGUS_VP &);
void StepperStatus(DGUS_VP &);
void StepIcons(DGUS_VP &);
void ABLDisableIcon(DGUS_VP &);
void ABLGrid(DGUS_VP &);
void FilamentIcons(DGUS_VP &);
void BLTouch(DGUS_VP &);
void PIDIcons(DGUS_VP &);
void PIDKp(DGUS_VP &);
void PIDKi(DGUS_VP &);
void PIDKd(DGUS_VP &);
void BuildVolume(DGUS_VP &);
void TotalPrints(DGUS_VP &);
void FinishedPrints(DGUS_VP &);
void PrintTime(DGUS_VP &);
void LongestPrint(DGUS_VP &);
void FilamentUsed(DGUS_VP &);
void WaitIcons(DGUS_VP &);
void FanSpeed(DGUS_VP &);
void Volume(DGUS_VP &);
void Brightness(DGUS_VP &);
void ExtraToString(DGUS_VP &);
void ExtraPGMToString(DGUS_VP &);
template<typename T>
void ExtraToInteger(DGUS_VP &vp) {
if (!vp.size || !vp.extra) return;
switch (vp.size) {
default: return;
case 1: {
const uint8_t data = (uint8_t)(*(T*)vp.extra);
dgus_display.Write((uint16_t)vp.addr, data);
break;
}
case 2: {
const uint16_t data = (uint16_t)(*(T*)vp.extra);
dgus_display.Write((uint16_t)vp.addr, Swap16(data));
break;
}
case 4: {
const uint32_t data = (uint32_t)(*(T*)vp.extra);
dgus_display.Write((uint16_t)vp.addr, dgus_display.SwapBytes(data));
break;
}
}
}
template<typename T, uint8_t decimals>
void ExtraToFixedPoint(DGUS_VP &vp) {
if (!vp.size || !vp.extra) return;
switch (vp.size) {
default: return;
case 1: {
const uint8_t data = dgus_display.ToFixedPoint<T, uint8_t, decimals>(*(T*)vp.extra);
dgus_display.Write((uint16_t)vp.addr, data);
break;
}
case 2: {
const uint16_t data = dgus_display.ToFixedPoint<T, uint16_t, decimals>(*(T*)vp.extra);
dgus_display.Write((uint16_t)vp.addr, Swap16(data));
break;
}
case 4: {
const uint32_t data = dgus_display.ToFixedPoint<T, uint32_t, decimals>(*(T*)vp.extra);
dgus_display.Write((uint16_t)vp.addr, dgus_display.SwapBytes(data));
break;
}
}
}
}

View File

@ -0,0 +1,173 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 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
constexpr uint8_t DGUS_LINE_LEN = 32;
constexpr uint8_t DGUS_STATUS_LEN = 32;
constexpr uint8_t DGUS_FILE_COUNT = 5;
constexpr uint8_t DGUS_FILENAME_LEN = 32;
constexpr uint8_t DGUS_ELLAPSED_LEN = 15;
constexpr uint8_t DGUS_LEVEL_GRID_SIZE = 25;
constexpr uint8_t DGUS_MACHINE_LEN = 24;
constexpr uint8_t DGUS_BUILDVOLUME_LEN = 24;
constexpr uint8_t DGUS_VERSION_LEN = 16;
constexpr uint8_t DGUS_PRINTTIME_LEN = 24;
constexpr uint8_t DGUS_LONGESTPRINT_LEN = 24;
constexpr uint8_t DGUS_FILAMENTUSED_LEN = 24;
constexpr uint8_t DGUS_GCODE_LEN = 32;
enum class DGUS_Addr : uint16_t {
MESSAGE_Line1 = 0x1100, // 0x1100 - 0x111F
MESSAGE_Line2 = 0x1120, // 0x1120 - 0x113F
MESSAGE_Line3 = 0x1140, // 0x1140 - 0x115F
MESSAGE_Line4 = 0x1160, // 0x1160 - 0x117F
// READ-ONLY VARIABLES
SCREENCHANGE = 0x2000, // Screen change request. Data contains target screen in low byte.
SCREENCHANGE_SD = 0x2001, // Only change if SD card present.
SCREENCHANGE_Idle = 0x2002, // Only change if not printing.
SCREENCHANGE_Printing = 0x2003, // Only change if printing.
SD_SelectFile = 0x2004, // Data: file index (0-4)
SD_Scroll = 0x2005, // Data: DGUS_Data::Scroll
SD_Print = 0x2006,
STATUS_Abort = 0x2007, // Popup / Data: DGUS_Data::Popup
STATUS_Pause = 0x2008, // Popup / Data: DGUS_Data::Popup
STATUS_Resume = 0x2009, // Popup / Data: DGUS_Data::Popup
ADJUST_SetFeedrate = 0x200A, // Type: Integer (16 bits signed)
ADJUST_SetFlowrate_CUR = 0x200B, // Type: Integer (16 bits signed)
#if HAS_MULTI_EXTRUDER
ADJUST_SetFlowrate_E0 = 0x200C, // Type: Integer (16 bits signed)
ADJUST_SetFlowrate_E1 = 0x200D, // Type: Integer (16 bits signed)
#endif
ADJUST_SetBabystep = 0x200E, // Type: Fixed point, 2 decimals (16 bits signed)
ADJUST_Babystep = 0x200F, // Data: DGUS_Data::Adjust
TEMP_Preset = 0x2010, // Popup / Data: DGUS_Data::TempPreset
TEMP_SetTarget_Bed = 0x2011, // Type: Integer (16 bits signed)
TEMP_SetTarget_H0 = 0x2012, // Type: Integer (16 bits signed)
#if HAS_MULTI_HOTEND
TEMP_SetTarget_H1 = 0x2013, // Type: Integer (16 bits signed)
#endif
TEMP_Cool = 0x2014, // Data: DGUS_Data::Heater
STEPPER_Control = 0x2015, // Popup / Data: DGUS_Data::Control
LEVEL_OFFSET_Set = 0x2016, // Type: Fixed point, 2 decimals (16 bits signed)
LEVEL_OFFSET_Step = 0x2017, // Data: DGUS_Data::Adjust
LEVEL_OFFSET_SetStep = 0x2018, // Data: DGUS_Data::StepSize
LEVEL_MANUAL_Point = 0x2019, // Data: point index (1-5)
LEVEL_AUTO_Probe = 0x201A,
LEVEL_AUTO_Disable = 0x201B,
FILAMENT_Select = 0x201C, // Data: DGUS_Data::Extruder
FILAMENT_SetLength = 0x201D, // Type: Integer (16 bits unsigned)
FILAMENT_Move = 0x201E, // Data: DGUS_Data::FilamentMove
MOVE_Home = 0x201F, // Data: DGUS_Data::Axis
MOVE_SetX = 0x2020, // Type: Fixed point, 1 decimal (16 bits signed)
MOVE_SetY = 0x2021, // Type: Fixed point, 1 decimal (16 bits signed)
MOVE_SetZ = 0x2022, // Type: Fixed point, 1 decimal (16 bits signed)
MOVE_Step = 0x2023, // Data: DGUS_Data::MoveDirection
MOVE_SetStep = 0x2024, // Data: DGUS_Data::StepSize
GCODE_Clear = 0x2025,
GCODE_Execute = 0x2026,
EEPROM_Reset = 0x2027, // Popup / Data: DGUS_Data::Popup
SETTINGS2_Extra = 0x2028, // Data: DGUS_Data::Extra
PID_Select = 0x2029, // Data: DGUS_Data::Heater
PID_SetTemp = 0x202A, // Type: Integer (16 bits unsigned)
PID_Run = 0x202B,
POWERLOSS_Abort = 0x202C, // Popup / Data: DGUS_Data::Popup
POWERLOSS_Resume = 0x202D, // Popup / Data: DGUS_Data::Popup
WAIT_Abort = 0x202E, // Popup / Data: DGUS_Data::Popup
WAIT_Continue = 0x202F,
// WRITE-ONLY VARIABLES
MESSAGE_Status = 0x3000, // 0x3000 - 0x301F
SD_Type = 0x3020, // 0x3020 - 0x3024 / Data: DGUS_Data::SDType
SD_FileName0 = 0x3025, // 0x3025 - 0x3044
SD_FileName1 = 0x3045, // 0x3045 - 0x3064
SD_FileName2 = 0x3065, // 0x3065 - 0x3084
SD_FileName3 = 0x3085, // 0x3085 - 0x30A4
SD_FileName4 = 0x30A5, // 0x30A5 - 0x30C4
SD_ScrollIcons = 0x30C5, // Bits: DGUS_Data::ScrollIcon
SD_SelectedFileName = 0x30C6, // 0x30C6 - 0x30E5
STATUS_PositionZ = 0x30E6, // Type: Fixed point, 1 decimal (16 bits signed)
STATUS_Ellapsed = 0x30E7, // 0x30E7 - 0x30F5
STATUS_Percent = 0x30F6, // Type: Integer (16 bits unsigned)
STATUS_Icons = 0x30F7, // Bits: DGUS_Data::StatusIcon
ADJUST_Feedrate = 0x30F8, // Type: Integer (16 bits signed)
ADJUST_Flowrate_CUR = 0x30F9, // Type: Integer (16 bits signed)
#if HAS_MULTI_EXTRUDER
ADJUST_Flowrate_E0 = 0x30FA, // Type: Integer (16 bits signed)
ADJUST_Flowrate_E1 = 0x30FB, // Type: Integer (16 bits signed)
#endif
TEMP_Current_Bed = 0x30FC, // Type: Integer (16 bits signed)
TEMP_Target_Bed = 0x30FD, // Type: Integer (16 bits signed)
TEMP_Max_Bed = 0x30FE, // Type: Integer (16 bits unsigned)
TEMP_Current_H0 = 0x30FF, // Type: Integer (16 bits signed)
TEMP_Target_H0 = 0x3100, // Type: Integer (16 bits signed)
TEMP_Max_H0 = 0x3101, // Type: Integer (16 bits unsigned)
#if HAS_MULTI_HOTEND
TEMP_Current_H1 = 0x3102, // Type: Integer (16 bits signed)
TEMP_Target_H1 = 0x3103, // Type: Integer (16 bits signed)
TEMP_Max_H1 = 0x3104, // Type: Integer (16 bits unsigned)
#endif
STEPPER_Status = 0x3105, // Data: DGUS_Data::Status
LEVEL_OFFSET_Current = 0x3106, // Type: Fixed point, 2 decimals (16 bits signed)
LEVEL_OFFSET_StepIcons = 0x3107, // Bits: DGUS_Data::StepIcon
LEVEL_AUTO_DisableIcon = 0x3108, // Data: DGUS_Data::Status
LEVEL_AUTO_Grid = 0x3109, // 0x3109 - 0x3121 / Type: Fixed point, 3 decimals (16 bits signed)
LEVEL_PROBING_Icons1 = 0x3122, // Type: Integer (16 bits unsigned) / Each bit represents a grid point
LEVEL_PROBING_Icons2 = 0x3123, // Type: Integer (16 bits unsigned) / Each bit represents a grid point
FILAMENT_ExtruderIcons = 0x3124, // Data: DGUS_Data::ExtruderIcon
FILAMENT_Length = 0x3125, // Type: Integer (16 bits unsigned)
MOVE_CurrentX = 0x3126, // Type: Fixed point, 1 decimal (16 bits signed)
MOVE_CurrentY = 0x3127, // Type: Fixed point, 1 decimal (16 bits signed)
MOVE_CurrentZ = 0x3128, // Type: Fixed point, 1 decimal (16 bits signed)
MOVE_StepIcons = 0x3129, // Bits: DGUS_Data::StepIcon
SETTINGS2_BLTouch = 0x312A, // Data: DGUS_Data::Status
PID_HeaterIcons = 0x312B, // Data: DGUS_Data::HeaterIcon
PID_Temp = 0x312C, // Type: Integer (16 bits unsigned)
PID_Kp = 0x312D, // Type: Fixed point, 2 decimals (32 bits signed)
PID_Ki = 0x312F, // Type: Fixed point, 2 decimals (32 bits signed)
PID_Kd = 0x3131, // Type: Fixed point, 2 decimals (32 bits signed)
INFOS_Machine = 0x3133, // 0x3133 - 0x314A
INFOS_BuildVolume = 0x314B, // 0x314B - 0x3162
INFOS_Version = 0x3163, // 0x3163 - 0x3172
INFOS_TotalPrints = 0x3173, // Type: Integer (16 bits unsigned)
INFOS_FinishedPrints = 0x3174, // Type: Integer (16 bits unsigned)
INFOS_PrintTime = 0x3175, // 0x3175 - 0x318C
INFOS_LongestPrint = 0x318D, // 0x318D - 0x31A4
INFOS_FilamentUsed = 0x31A5, // 0x31A5 - 0x31BC
WAIT_Icons = 0x31BD, // Bits: DGUS_Data::WaitIcon
// READ-WRITE VARIABLES
FAN0_Speed = 0x4000, // Type: Integer (16 bits unsigned) / Data: fan speed as percent (0-100)
GCODE_Data = 0x4001, // 0x4001 - 0x4020
PID_Cycles = 0x4021, // Type: Integer (16 bits unsigned)
VOLUME_Level = 0x4022, // Type: Integer (16 bits unsigned) / Data: volume as percent (0-100)
BRIGHTNESS_Level = 0x4023, // Type: Integer (16 bits unsigned) / Data: brightness as percent (0-100)
// SPECIAL CASES
STATUS_Percent_Complete = 0x5000, // Same as STATUS_Percent, but always 100%
INFOS_Debug = 0x5001,
};

View File

@ -0,0 +1,96 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 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 "../../../../inc/MarlinConfigPre.h"
#include "DGUS_Addr.h"
static_assert((DGUS_LEVEL_GRID_SIZE == GRID_MAX_POINTS_X * GRID_MAX_POINTS_Y), "DGUS_LEVEL_GRID_SIZE incompatible with current mesh.");
#ifndef DGUS_DEFAULT_VOLUME
#define DGUS_DEFAULT_VOLUME 50
#endif
#ifndef DGUS_DEFAULT_BRIGHTNESS
#define DGUS_DEFAULT_BRIGHTNESS 100
#endif
#ifndef DGUS_STATUS_EXPIRATION_MS
#define DGUS_STATUS_EXPIRATION_MS 30000
#endif
#ifndef DGUS_PRINT_BABYSTEP
#define DGUS_PRINT_BABYSTEP 0.01f
#endif
#ifndef DGUS_PLA_TEMP_HOTEND
#define DGUS_PLA_TEMP_HOTEND 200
#endif
#ifndef DGUS_PLA_TEMP_BED
#define DGUS_PLA_TEMP_BED 60
#endif
#ifndef DGUS_ABS_TEMP_HOTEND
#define DGUS_ABS_TEMP_HOTEND 240
#endif
#ifndef DGUS_ABS_TEMP_BED
#define DGUS_ABS_TEMP_BED 80
#endif
#ifndef DGUS_PETG_TEMP_HOTEND
#define DGUS_PETG_TEMP_HOTEND 240
#endif
#ifndef DGUS_PETG_TEMP_BED
#define DGUS_PETG_TEMP_BED 60
#endif
#ifndef DGUS_DEFAULT_FILAMENT_LEN
#define DGUS_DEFAULT_FILAMENT_LEN 10
#endif
#ifndef BED_TRAMMING_Z_HOP
#define BED_TRAMMING_Z_HOP 4.0
#endif
#ifndef BED_TRAMMING_HEIGHT
#define BED_TRAMMING_HEIGHT 0.0
#endif
static_assert(BED_TRAMMING_Z_HOP >= 0, "BED_TRAMMING_Z_HOP must be >= 0. Please update your configuration.");
#ifndef DGUS_LEVEL_CENTER_X
#define DGUS_LEVEL_CENTER_X ((X_BED_SIZE) / 2)
#endif
#ifndef DGUS_LEVEL_CENTER_Y
#define DGUS_LEVEL_CENTER_Y ((Y_BED_SIZE) / 2)
#endif
#if ENABLED(BLTOUCH)
#ifndef DGUS_RESET_BLTOUCH
#define DGUS_RESET_BLTOUCH "M999\nM280P0S160"
#endif
#endif

View File

@ -0,0 +1,50 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 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 class DGUS_Control : uint8_t {
// PRINT
FILE0 = 1, // RETURN_KEY_CODE
FILE1 = 2, // RETURN_KEY_CODE
FILE2 = 3, // RETURN_KEY_CODE
FILE3 = 4, // RETURN_KEY_CODE
FILE4 = 5, // RETURN_KEY_CODE
GO_BACK = 6, // RETURN_KEY_CODE
SCROLL_UP = 7, // RETURN_KEY_CODE
SCROLL_DOWN = 8, // RETURN_KEY_CODE
// PRINT_STATUS
PAUSE = 1, // POPUP_WINDOW
RESUME = 2, // POPUP_WINDOW
// LEVELING_AUTOMATIC
DISABLE = 5, // RETURN_KEY_CODE
// SETTINGS_MENU2
EXTRA2 = 6, // RETURN_KEY_CODE
// WAIT
ABORT = 1, // POPUP_WINDOW
CONTINUE = 2 // RETURN_KEY_CODE
};

View File

@ -0,0 +1,148 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 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 <inttypes.h>
namespace DGUS_Data {
// RX constants
enum class Scroll : uint8_t {
GO_BACK = 0,
UP = 1,
DOWN = 2
};
enum class Popup : uint8_t {
CONFIRMED = 1
};
enum class Adjust : uint8_t {
INCREMENT = 0,
DECREMENT = 1
};
enum class TempPreset : uint8_t {
PLA = 1,
ABS = 2,
PETG = 3
};
enum class Extruder : int8_t {
CURRENT = -1,
E0 = 0,
E1 = 1
};
enum class Heater : int8_t {
ALL = -2,
BED = -1,
H0 = 0,
H1 = 1
};
enum class Control : uint8_t {
ENABLE = 1,
DISABLE = 2
};
enum class StepSize : uint8_t {
MM10 = 0, // 10mm
MM1 = 1, // 1mm
MMP1 = 2, // 0.1mm
MMP01 = 3 // 0.01mm
};
enum class FilamentMove : uint8_t {
RETRACT = 0,
EXTRUDE = 1
};
enum class Axis : uint8_t {
X_Y_Z = 0,
X_Y = 1,
Z = 2
};
enum class MoveDirection : uint8_t {
XP = 0, // X+
XM = 1, // X-
YP = 2, // Y+
YM = 3, // Y-
ZP = 4, // Z+
ZM = 5 // Z-
};
enum class Extra : uint8_t {
BUTTON1 = 0,
BUTTON2 = 1
};
// TX constants
enum class SDType : uint16_t {
NONE = 0,
FILE = 1,
DIRECTORY = 2
};
enum class ScrollIcon : uint16_t {
GO_BACK = 1U << 0,
UP = 1U << 1,
DOWN = 1U << 2
};
enum class StatusIcon : uint16_t {
PAUSE = 1U << 0,
RESUME = 1U << 1
};
enum class Status : uint16_t {
DISABLED = 0,
ENABLED = 1
};
enum class StepIcon : uint16_t {
MM10 = 1U << 0, // 10mm
MM1 = 1U << 1, // 1mm
MMP1 = 1U << 2, // 0.1mm
MMP01 = 1U << 3 // 0.01mm
};
enum class ExtruderIcon : uint16_t {
E0 = 1U << 0,
E1 = 1U << 1
};
enum class HeaterIcon : uint16_t {
BED = 1U << 0,
H0 = 1U << 1,
H1 = 1U << 2
};
enum class WaitIcon : uint16_t {
ABORT = 1U << 0,
CONTINUE = 1U << 1
};
};

View File

@ -0,0 +1,52 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 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 class DGUS_Screen : uint8_t {
BOOT = 0,
HOME = 1,
PRINT = 2,
PRINT_STATUS = 3,
PRINT_ADJUST = 4,
PRINT_FINISHED = 5,
TEMP_MENU = 6,
TEMP_MANUAL = 7,
FAN = 8,
SETTINGS_MENU = 9,
LEVELING_MENU = 10,
LEVELING_OFFSET = 11,
LEVELING_MANUAL = 12,
LEVELING_AUTOMATIC = 13,
LEVELING_PROBING = 14,
FILAMENT = 15,
MOVE = 16,
GCODE = 17,
SETTINGS_MENU2 = 18,
PID = 19,
VOLUME = 20,
BRIGHTNESS = 21,
INFOS = 22,
DEBUG = 240,
POWERLOSS = 248,
WAIT = 249,
KILL = 250
};

View File

@ -0,0 +1,240 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 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_RELOADED)
#include "DGUS_ScreenAddrList.h"
#include "../../ui_api.h"
constexpr DGUS_Addr LIST_HOME[] PROGMEM = {
DGUS_Addr::TEMP_Current_H0,
DGUS_Addr::TEMP_Target_H0,
DGUS_Addr::TEMP_Current_Bed,
DGUS_Addr::TEMP_Target_Bed,
(DGUS_Addr)0
};
#if ENABLED(SDSUPPORT)
constexpr DGUS_Addr LIST_PRINT[] PROGMEM = {
DGUS_Addr::SD_Type,
DGUS_Addr::SD_FileName0,
DGUS_Addr::SD_FileName1,
DGUS_Addr::SD_FileName2,
DGUS_Addr::SD_FileName3,
DGUS_Addr::SD_FileName4,
DGUS_Addr::SD_ScrollIcons,
DGUS_Addr::SD_SelectedFileName,
(DGUS_Addr)0
};
#endif
constexpr DGUS_Addr LIST_PRINT_STATUS[] PROGMEM = {
DGUS_Addr::TEMP_Current_H0,
DGUS_Addr::TEMP_Target_H0,
DGUS_Addr::TEMP_Current_Bed,
DGUS_Addr::TEMP_Target_Bed,
DGUS_Addr::STATUS_PositionZ,
DGUS_Addr::STATUS_Ellapsed,
DGUS_Addr::STATUS_Percent,
DGUS_Addr::STATUS_Icons,
(DGUS_Addr)0
};
constexpr DGUS_Addr LIST_PRINT_ADJUST[] PROGMEM = {
DGUS_Addr::TEMP_Target_H0,
DGUS_Addr::TEMP_Target_Bed,
DGUS_Addr::FAN0_Speed,
DGUS_Addr::ADJUST_Feedrate,
DGUS_Addr::ADJUST_Flowrate_CUR,
DGUS_Addr::LEVEL_OFFSET_Current,
(DGUS_Addr)0
};
constexpr DGUS_Addr LIST_PRINT_FINISHED[] PROGMEM = {
DGUS_Addr::TEMP_Current_H0,
DGUS_Addr::TEMP_Target_H0,
DGUS_Addr::TEMP_Current_Bed,
DGUS_Addr::TEMP_Target_Bed,
DGUS_Addr::STATUS_PositionZ,
DGUS_Addr::STATUS_Ellapsed,
DGUS_Addr::STATUS_Percent_Complete,
(DGUS_Addr)0
};
constexpr DGUS_Addr LIST_TEMP_MENU[] PROGMEM = {
DGUS_Addr::TEMP_Current_H0,
DGUS_Addr::TEMP_Target_H0,
DGUS_Addr::TEMP_Current_Bed,
DGUS_Addr::TEMP_Target_Bed,
(DGUS_Addr)0
};
constexpr DGUS_Addr LIST_TEMP_MANUAL[] PROGMEM = {
DGUS_Addr::TEMP_Current_H0,
DGUS_Addr::TEMP_Target_H0,
DGUS_Addr::TEMP_Max_H0,
DGUS_Addr::TEMP_Current_Bed,
DGUS_Addr::TEMP_Target_Bed,
DGUS_Addr::TEMP_Max_Bed,
(DGUS_Addr)0
};
constexpr DGUS_Addr LIST_FAN[] PROGMEM = {
DGUS_Addr::FAN0_Speed,
(DGUS_Addr)0
};
constexpr DGUS_Addr LIST_SETTINGS_MENU[] PROGMEM = {
DGUS_Addr::STEPPER_Status,
(DGUS_Addr)0
};
constexpr DGUS_Addr LIST_LEVELING_OFFSET[] PROGMEM = {
DGUS_Addr::LEVEL_OFFSET_Current,
DGUS_Addr::LEVEL_OFFSET_StepIcons,
(DGUS_Addr)0
};
constexpr DGUS_Addr LIST_LEVELING_MANUAL[] PROGMEM = {
DGUS_Addr::TEMP_Current_H0,
DGUS_Addr::TEMP_Target_H0,
DGUS_Addr::TEMP_Current_Bed,
DGUS_Addr::TEMP_Target_Bed,
(DGUS_Addr)0
};
constexpr DGUS_Addr LIST_LEVELING_AUTOMATIC[] PROGMEM = {
DGUS_Addr::TEMP_Current_H0,
DGUS_Addr::TEMP_Target_H0,
DGUS_Addr::TEMP_Current_Bed,
DGUS_Addr::TEMP_Target_Bed,
DGUS_Addr::LEVEL_AUTO_DisableIcon,
DGUS_Addr::LEVEL_AUTO_Grid,
(DGUS_Addr)0
};
constexpr DGUS_Addr LIST_LEVELING_PROBING[] PROGMEM = {
DGUS_Addr::LEVEL_PROBING_Icons1,
DGUS_Addr::LEVEL_PROBING_Icons2,
(DGUS_Addr)0
};
constexpr DGUS_Addr LIST_FILAMENT[] PROGMEM = {
DGUS_Addr::TEMP_Current_H0,
DGUS_Addr::TEMP_Target_H0,
DGUS_Addr::FILAMENT_ExtruderIcons,
DGUS_Addr::FILAMENT_Length,
(DGUS_Addr)0
};
constexpr DGUS_Addr LIST_MOVE[] PROGMEM = {
DGUS_Addr::MOVE_CurrentX,
DGUS_Addr::MOVE_CurrentY,
DGUS_Addr::MOVE_CurrentZ,
DGUS_Addr::MOVE_StepIcons,
(DGUS_Addr)0
};
constexpr DGUS_Addr LIST_GCODE[] PROGMEM = {
DGUS_Addr::GCODE_Data,
(DGUS_Addr)0
};
constexpr DGUS_Addr LIST_SETTINGS_MENU2[] PROGMEM = {
DGUS_Addr::SETTINGS2_BLTouch,
(DGUS_Addr)0
};
constexpr DGUS_Addr LIST_PID[] PROGMEM = {
DGUS_Addr::PID_HeaterIcons,
DGUS_Addr::PID_Temp,
DGUS_Addr::PID_Cycles,
DGUS_Addr::PID_Kp,
DGUS_Addr::PID_Ki,
DGUS_Addr::PID_Kd,
(DGUS_Addr)0
};
constexpr DGUS_Addr LIST_VOLUME[] PROGMEM = {
DGUS_Addr::VOLUME_Level,
(DGUS_Addr)0
};
constexpr DGUS_Addr LIST_BRIGHTNESS[] PROGMEM = {
DGUS_Addr::BRIGHTNESS_Level,
(DGUS_Addr)0
};
constexpr DGUS_Addr LIST_INFOS[] PROGMEM = {
DGUS_Addr::INFOS_Machine,
DGUS_Addr::INFOS_BuildVolume,
DGUS_Addr::INFOS_Version,
DGUS_Addr::INFOS_TotalPrints,
DGUS_Addr::INFOS_FinishedPrints,
DGUS_Addr::INFOS_PrintTime,
DGUS_Addr::INFOS_LongestPrint,
DGUS_Addr::INFOS_FilamentUsed,
(DGUS_Addr)0
};
constexpr DGUS_Addr LIST_WAIT[] PROGMEM = {
DGUS_Addr::WAIT_Icons,
(DGUS_Addr)0
};
#define MAP_HELPER(SCREEN, LIST) \
{ .screen = SCREEN, \
.addr_list = LIST }
const struct DGUS_ScreenAddrList screen_addr_list_map[] PROGMEM = {
MAP_HELPER(DGUS_Screen::HOME, LIST_HOME),
#if ENABLED(SDSUPPORT)
MAP_HELPER(DGUS_Screen::PRINT, LIST_PRINT),
#endif
MAP_HELPER(DGUS_Screen::PRINT_STATUS, LIST_PRINT_STATUS),
MAP_HELPER(DGUS_Screen::PRINT_ADJUST, LIST_PRINT_ADJUST),
MAP_HELPER(DGUS_Screen::PRINT_FINISHED, LIST_PRINT_FINISHED),
MAP_HELPER(DGUS_Screen::TEMP_MENU, LIST_TEMP_MENU),
MAP_HELPER(DGUS_Screen::TEMP_MANUAL, LIST_TEMP_MANUAL),
MAP_HELPER(DGUS_Screen::FAN, LIST_FAN),
MAP_HELPER(DGUS_Screen::SETTINGS_MENU, LIST_SETTINGS_MENU),
MAP_HELPER(DGUS_Screen::LEVELING_OFFSET, LIST_LEVELING_OFFSET),
MAP_HELPER(DGUS_Screen::LEVELING_MANUAL, LIST_LEVELING_MANUAL),
MAP_HELPER(DGUS_Screen::LEVELING_AUTOMATIC, LIST_LEVELING_AUTOMATIC),
MAP_HELPER(DGUS_Screen::LEVELING_PROBING, LIST_LEVELING_PROBING),
MAP_HELPER(DGUS_Screen::FILAMENT, LIST_FILAMENT),
MAP_HELPER(DGUS_Screen::MOVE, LIST_MOVE),
MAP_HELPER(DGUS_Screen::GCODE, LIST_GCODE),
MAP_HELPER(DGUS_Screen::SETTINGS_MENU2, LIST_SETTINGS_MENU2),
MAP_HELPER(DGUS_Screen::PID, LIST_PID),
MAP_HELPER(DGUS_Screen::VOLUME, LIST_VOLUME),
MAP_HELPER(DGUS_Screen::BRIGHTNESS, LIST_BRIGHTNESS),
MAP_HELPER(DGUS_Screen::INFOS, LIST_INFOS),
MAP_HELPER(DGUS_Screen::WAIT, LIST_WAIT),
MAP_HELPER((DGUS_Screen)0, nullptr)
};
#endif // DGUS_LCD_UI_RELOADED

View File

@ -0,0 +1,32 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 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 "../config/DGUS_Screen.h"
#include "../config/DGUS_Addr.h"
struct DGUS_ScreenAddrList {
DGUS_Screen screen;
const DGUS_Addr *addr_list;
};
extern const struct DGUS_ScreenAddrList screen_addr_list_map[];

View File

@ -0,0 +1,57 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 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_RELOADED)
#include "DGUS_ScreenSetup.h"
#include "../DGUSSetupHandler.h"
#include "../../ui_api.h"
#define SETUP_HELPER(SCREEN, SETUP) \
{ .screen = SCREEN, \
.setup_fn = SETUP }
const struct DGUS_ScreenSetup screen_setup_list[] PROGMEM = {
#if ENABLED(SDSUPPORT)
SETUP_HELPER(DGUS_Screen::PRINT, &DGUSSetupHandler::Print),
#endif
SETUP_HELPER(DGUS_Screen::PRINT_STATUS, &DGUSSetupHandler::PrintStatus),
SETUP_HELPER(DGUS_Screen::PRINT_ADJUST, &DGUSSetupHandler::PrintAdjust),
SETUP_HELPER(DGUS_Screen::LEVELING_MENU, &DGUSSetupHandler::LevelingMenu),
SETUP_HELPER(DGUS_Screen::LEVELING_OFFSET, &DGUSSetupHandler::LevelingOffset),
SETUP_HELPER(DGUS_Screen::LEVELING_MANUAL, &DGUSSetupHandler::LevelingManual),
SETUP_HELPER(DGUS_Screen::LEVELING_AUTOMATIC, &DGUSSetupHandler::LevelingAutomatic),
SETUP_HELPER(DGUS_Screen::LEVELING_PROBING, &DGUSSetupHandler::LevelingProbing),
SETUP_HELPER(DGUS_Screen::FILAMENT, &DGUSSetupHandler::Filament),
SETUP_HELPER(DGUS_Screen::MOVE, &DGUSSetupHandler::Move),
SETUP_HELPER(DGUS_Screen::GCODE, &DGUSSetupHandler::Gcode),
SETUP_HELPER(DGUS_Screen::PID, &DGUSSetupHandler::PID),
SETUP_HELPER(DGUS_Screen::INFOS, &DGUSSetupHandler::Infos),
SETUP_HELPER((DGUS_Screen)0, nullptr)
};
#endif // DGUS_LCD_UI_RELOADED

View File

@ -0,0 +1,31 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 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 "../config/DGUS_Screen.h"
struct DGUS_ScreenSetup {
DGUS_Screen screen;
bool (*setup_fn)(void);
};
extern const struct DGUS_ScreenSetup screen_setup_list[];

View File

@ -0,0 +1,40 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 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 "../config/DGUS_Addr.h"
#define VPFLAG_NONE 0
#define VPFLAG_AUTOUPLOAD (1U << 0) // Upload on every DGUS update
#define VPFLAG_RXSTRING (1U << 1) // Treat the received data as a string (terminated with 0xFFFF)
struct DGUS_VP {
DGUS_Addr addr;
uint8_t size;
uint8_t flags;
void *extra;
// Callback that will be called if the display modified the value.
// nullptr makes it readonly for the display.
void (*rx_handler)(DGUS_VP &, void *);
void (*tx_handler)(DGUS_VP &);
};

View File

@ -0,0 +1,368 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 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_RELOADED)
#include "DGUS_VPList.h"
#include "../config/DGUS_Addr.h"
#include "../DGUSScreenHandler.h"
#include "../DGUSRxHandler.h"
#include "../DGUSTxHandler.h"
#include "../../ui_api.h"
#include "../../../../module/probe.h"
#include "../../../../module/motion.h"
#include "../../../../module/temperature.h"
const char DGUS_MACHINENAME[] PROGMEM = MACHINE_NAME;
const char DGUS_MARLINVERSION[] PROGMEM = SHORT_BUILD_VERSION;
#define VP_HELPER(ADDR, SIZE, FLAGS, EXTRA, RXHANDLER, TXHANDLER) \
{ .addr = ADDR, \
.size = SIZE, \
.flags = FLAGS, \
.extra = EXTRA, \
.rx_handler = RXHANDLER, \
.tx_handler = TXHANDLER }
#define VP_HELPER_WORD(ADDR, FLAGS, EXTRA, RXHANDLER, TXHANDLER) \
VP_HELPER(ADDR, 2, FLAGS, EXTRA, RXHANDLER, TXHANDLER)
#define VP_HELPER_DWORD(ADDR, FLAGS, EXTRA, RXHANDLER, TXHANDLER) \
VP_HELPER(ADDR, 4, FLAGS, EXTRA, RXHANDLER, TXHANDLER)
#define VP_HELPER_RX(ADDR, RXHANDLER) \
VP_HELPER_WORD(ADDR, VPFLAG_NONE, nullptr, RXHANDLER, nullptr)
#define VP_HELPER_RX_NODATA(ADDR, RXHANDLER) \
VP_HELPER(ADDR, 0, VPFLAG_NONE, nullptr, RXHANDLER, nullptr)
#define VP_HELPER_TX(ADDR, TXHANDLER) \
VP_HELPER_WORD(ADDR, VPFLAG_NONE, nullptr, nullptr, TXHANDLER)
#define VP_HELPER_TX_SIZE(ADDR, SIZE, TXHANDLER) \
VP_HELPER(ADDR, SIZE, VPFLAG_NONE, nullptr, nullptr, TXHANDLER)
#define VP_HELPER_TX_EXTRA(ADDR, EXTRA, TXHANDLER) \
VP_HELPER_WORD(ADDR, VPFLAG_NONE, EXTRA, nullptr, TXHANDLER)
#define VP_HELPER_TX_AUTO(ADDR, EXTRA, TXHANDLER) \
VP_HELPER_WORD(ADDR, VPFLAG_AUTOUPLOAD, EXTRA, nullptr, TXHANDLER)
const struct DGUS_VP vp_list[] PROGMEM = {
// READ-ONLY VARIABLES
VP_HELPER_RX(DGUS_Addr::SCREENCHANGE, &DGUSRxHandler::ScreenChange),
VP_HELPER_RX(DGUS_Addr::SCREENCHANGE_SD, &DGUSRxHandler::ScreenChange),
VP_HELPER_RX(DGUS_Addr::SCREENCHANGE_Idle, &DGUSRxHandler::ScreenChange),
VP_HELPER_RX(DGUS_Addr::SCREENCHANGE_Printing, &DGUSRxHandler::ScreenChange),
#if ENABLED(SDSUPPORT)
VP_HELPER_RX(DGUS_Addr::SD_SelectFile, &DGUSRxHandler::SelectFile),
VP_HELPER_RX(DGUS_Addr::SD_Scroll, &DGUSRxHandler::Scroll),
VP_HELPER_RX_NODATA(DGUS_Addr::SD_Print, &DGUSRxHandler::PrintFile),
#endif
VP_HELPER_RX(DGUS_Addr::STATUS_Abort, &DGUSRxHandler::PrintAbort),
VP_HELPER_RX(DGUS_Addr::STATUS_Pause, &DGUSRxHandler::PrintPause),
VP_HELPER_RX(DGUS_Addr::STATUS_Resume, &DGUSRxHandler::PrintResume),
VP_HELPER_RX(DGUS_Addr::ADJUST_SetFeedrate, &DGUSRxHandler::Feedrate),
VP_HELPER_RX(DGUS_Addr::ADJUST_SetFlowrate_CUR, &DGUSRxHandler::Flowrate),
#if HAS_MULTI_EXTRUDER
VP_HELPER_RX(DGUS_Addr::ADJUST_SetFlowrate_E0, &DGUSRxHandler::Flowrate),
VP_HELPER_RX(DGUS_Addr::ADJUST_SetFlowrate_E1, &DGUSRxHandler::Flowrate),
#endif
VP_HELPER_RX(DGUS_Addr::ADJUST_SetBabystep, &DGUSRxHandler::BabystepSet),
VP_HELPER_RX(DGUS_Addr::ADJUST_Babystep, &DGUSRxHandler::Babystep),
VP_HELPER_RX(DGUS_Addr::TEMP_Preset, &DGUSRxHandler::TempPreset),
VP_HELPER_RX(DGUS_Addr::TEMP_SetTarget_Bed, &DGUSRxHandler::TempTarget),
VP_HELPER_RX(DGUS_Addr::TEMP_SetTarget_H0, &DGUSRxHandler::TempTarget),
#if HAS_MULTI_HOTEND
VP_HELPER_RX(DGUS_Addr::TEMP_SetTarget_H1, &DGUSRxHandler::TempTarget),
#endif
VP_HELPER_RX(DGUS_Addr::TEMP_Cool, &DGUSRxHandler::TempCool),
VP_HELPER_RX(DGUS_Addr::STEPPER_Control, &DGUSRxHandler::Steppers),
VP_HELPER_RX(DGUS_Addr::LEVEL_OFFSET_Set, &DGUSRxHandler::ZOffset),
VP_HELPER_RX(DGUS_Addr::LEVEL_OFFSET_Step, &DGUSRxHandler::ZOffsetStep),
VP_HELPER_RX(DGUS_Addr::LEVEL_OFFSET_SetStep, &DGUSRxHandler::ZOffsetSetStep),
VP_HELPER_RX(DGUS_Addr::LEVEL_MANUAL_Point, &DGUSRxHandler::MoveToPoint),
VP_HELPER_RX_NODATA(DGUS_Addr::LEVEL_AUTO_Probe, &DGUSRxHandler::Probe),
VP_HELPER_RX_NODATA(DGUS_Addr::LEVEL_AUTO_Disable,
&DGUSRxHandler::DisableABL),
VP_HELPER_RX(DGUS_Addr::FILAMENT_Select, &DGUSRxHandler::FilamentSelect),
VP_HELPER_RX(DGUS_Addr::FILAMENT_SetLength, &DGUSRxHandler::FilamentLength),
VP_HELPER_RX(DGUS_Addr::FILAMENT_Move, &DGUSRxHandler::FilamentMove),
VP_HELPER_RX(DGUS_Addr::MOVE_Home, &DGUSRxHandler::Home),
VP_HELPER_RX(DGUS_Addr::MOVE_SetX, &DGUSRxHandler::Move),
VP_HELPER_RX(DGUS_Addr::MOVE_SetY, &DGUSRxHandler::Move),
VP_HELPER_RX(DGUS_Addr::MOVE_SetZ, &DGUSRxHandler::Move),
VP_HELPER_RX(DGUS_Addr::MOVE_Step, &DGUSRxHandler::MoveStep),
VP_HELPER_RX(DGUS_Addr::MOVE_SetStep, &DGUSRxHandler::MoveSetStep),
VP_HELPER_RX_NODATA(DGUS_Addr::GCODE_Clear, &DGUSRxHandler::GcodeClear),
VP_HELPER_RX_NODATA(DGUS_Addr::GCODE_Execute, &DGUSRxHandler::GcodeExecute),
VP_HELPER_RX(DGUS_Addr::EEPROM_Reset, &DGUSRxHandler::ResetEEPROM),
VP_HELPER_RX(DGUS_Addr::SETTINGS2_Extra, &DGUSRxHandler::SettingsExtra),
VP_HELPER_RX(DGUS_Addr::PID_Select, &DGUSRxHandler::PIDSelect),
VP_HELPER_RX(DGUS_Addr::PID_SetTemp, &DGUSRxHandler::PIDSetTemp),
VP_HELPER_RX_NODATA(DGUS_Addr::PID_Run, &DGUSRxHandler::PIDRun),
#if ENABLED(POWER_LOSS_RECOVERY)
VP_HELPER_RX(DGUS_Addr::POWERLOSS_Abort, &DGUSRxHandler::PowerLossAbort),
VP_HELPER_RX(DGUS_Addr::POWERLOSS_Resume, &DGUSRxHandler::PowerLossResume),
#endif
VP_HELPER_RX(DGUS_Addr::WAIT_Abort, &DGUSRxHandler::WaitAbort),
VP_HELPER_RX_NODATA(DGUS_Addr::WAIT_Continue, &DGUSRxHandler::WaitContinue),
// WRITE-ONLY VARIABLES
#if ENABLED(SDSUPPORT)
VP_HELPER_TX(DGUS_Addr::SD_Type, &DGUSTxHandler::FileType),
VP_HELPER_TX_SIZE(DGUS_Addr::SD_FileName0,
DGUS_FILENAME_LEN,
&DGUSTxHandler::FileName),
VP_HELPER_TX_SIZE(DGUS_Addr::SD_FileName1,
DGUS_FILENAME_LEN,
&DGUSTxHandler::FileName),
VP_HELPER_TX_SIZE(DGUS_Addr::SD_FileName2,
DGUS_FILENAME_LEN,
&DGUSTxHandler::FileName),
VP_HELPER_TX_SIZE(DGUS_Addr::SD_FileName3,
DGUS_FILENAME_LEN,
&DGUSTxHandler::FileName),
VP_HELPER_TX_SIZE(DGUS_Addr::SD_FileName4,
DGUS_FILENAME_LEN,
&DGUSTxHandler::FileName),
VP_HELPER_TX(DGUS_Addr::SD_ScrollIcons, &DGUSTxHandler::ScrollIcons),
VP_HELPER_TX_SIZE(DGUS_Addr::SD_SelectedFileName,
DGUS_FILENAME_LEN,
&DGUSTxHandler::SelectedFileName),
#endif
VP_HELPER_TX_AUTO(DGUS_Addr::STATUS_PositionZ,
nullptr,
&DGUSTxHandler::PositionZ),
VP_HELPER(DGUS_Addr::STATUS_Ellapsed,
DGUS_ELLAPSED_LEN,
VPFLAG_AUTOUPLOAD,
nullptr,
nullptr,
&DGUSTxHandler::Ellapsed),
VP_HELPER_TX_AUTO(DGUS_Addr::STATUS_Percent,
nullptr,
&DGUSTxHandler::Percent),
VP_HELPER_TX(DGUS_Addr::STATUS_Icons, &DGUSTxHandler::StatusIcons),
VP_HELPER_TX_AUTO(DGUS_Addr::ADJUST_Feedrate,
&feedrate_percentage,
&DGUSTxHandler::ExtraToInteger<int16_t>),
VP_HELPER_TX_AUTO(DGUS_Addr::ADJUST_Flowrate_CUR,
nullptr,
&DGUSTxHandler::Flowrate),
#if HAS_MULTI_EXTRUDER
VP_HELPER_TX_AUTO(DGUS_Addr::ADJUST_Flowrate_E0,
nullptr,
&DGUSTxHandler::Flowrate),
VP_HELPER_TX_AUTO(DGUS_Addr::ADJUST_Flowrate_E1,
nullptr,
&DGUSTxHandler::Flowrate),
#endif
VP_HELPER_TX_AUTO(DGUS_Addr::TEMP_Current_Bed,
&thermalManager.temp_bed.celsius,
&DGUSTxHandler::ExtraToInteger<float>),
VP_HELPER_TX_AUTO(DGUS_Addr::TEMP_Target_Bed,
&thermalManager.temp_bed.target,
&DGUSTxHandler::ExtraToInteger<int16_t>),
VP_HELPER_TX(DGUS_Addr::TEMP_Max_Bed, &DGUSTxHandler::TempMax),
VP_HELPER_TX_AUTO(DGUS_Addr::TEMP_Current_H0,
&thermalManager.temp_hotend[ExtUI::heater_t::H0].celsius,
&DGUSTxHandler::ExtraToInteger<float>),
VP_HELPER_TX_AUTO(DGUS_Addr::TEMP_Target_H0,
&thermalManager.temp_hotend[ExtUI::heater_t::H0].target,
&DGUSTxHandler::ExtraToInteger<int16_t>),
VP_HELPER_TX(DGUS_Addr::TEMP_Max_H0, &DGUSTxHandler::TempMax),
#if HAS_MULTI_HOTEND
VP_HELPER_TX_AUTO(DGUS_Addr::TEMP_Current_H1,
&thermalManager.temp_hotend[ExtUI::heater_t::H1].celsius,
&DGUSTxHandler::ExtraToInteger<float>),
VP_HELPER_TX_AUTO(DGUS_Addr::TEMP_Target_H1,
&thermalManager.temp_hotend[ExtUI::heater_t::H1].target,
&DGUSTxHandler::ExtraToInteger<int16_t>),
VP_HELPER_TX(DGUS_Addr::TEMP_Max_H1, &DGUSTxHandler::TempMax),
#endif
VP_HELPER_TX_AUTO(DGUS_Addr::STEPPER_Status,
nullptr,
&DGUSTxHandler::StepperStatus),
VP_HELPER_TX_AUTO(DGUS_Addr::LEVEL_OFFSET_Current,
&probe.offset.z,
(&DGUSTxHandler::ExtraToFixedPoint<float, 2>)),
VP_HELPER_TX_EXTRA(DGUS_Addr::LEVEL_OFFSET_StepIcons,
&DGUSScreenHandler::offset_steps,
&DGUSTxHandler::StepIcons),
VP_HELPER_TX_AUTO(DGUS_Addr::LEVEL_AUTO_DisableIcon,
nullptr,
&DGUSTxHandler::ABLDisableIcon),
VP_HELPER_TX(DGUS_Addr::LEVEL_AUTO_Grid, &DGUSTxHandler::ABLGrid),
VP_HELPER_TX_EXTRA(DGUS_Addr::LEVEL_PROBING_Icons1,
&DGUSScreenHandler::probing_icons[0],
&DGUSTxHandler::ExtraToInteger<uint16_t>),
VP_HELPER_TX_EXTRA(DGUS_Addr::LEVEL_PROBING_Icons2,
&DGUSScreenHandler::probing_icons[1],
&DGUSTxHandler::ExtraToInteger<uint16_t>),
VP_HELPER_TX(DGUS_Addr::FILAMENT_ExtruderIcons, &DGUSTxHandler::FilamentIcons),
VP_HELPER_TX_EXTRA(DGUS_Addr::FILAMENT_Length,
&DGUSScreenHandler::filament_length,
&DGUSTxHandler::ExtraToInteger<uint16_t>),
VP_HELPER_TX_AUTO(DGUS_Addr::MOVE_CurrentX,
&current_position.x,
(&DGUSTxHandler::ExtraToFixedPoint<float, 1>)),
VP_HELPER_TX_AUTO(DGUS_Addr::MOVE_CurrentY,
&current_position.y,
(&DGUSTxHandler::ExtraToFixedPoint<float, 1>)),
VP_HELPER_TX_AUTO(DGUS_Addr::MOVE_CurrentZ,
&current_position.z,
(&DGUSTxHandler::ExtraToFixedPoint<float, 1>)),
VP_HELPER_TX_EXTRA(DGUS_Addr::MOVE_StepIcons,
&DGUSScreenHandler::move_steps,
&DGUSTxHandler::StepIcons),
VP_HELPER_TX(DGUS_Addr::SETTINGS2_BLTouch, &DGUSTxHandler::BLTouch),
VP_HELPER_TX(DGUS_Addr::PID_HeaterIcons, &DGUSTxHandler::PIDIcons),
VP_HELPER_TX_EXTRA(DGUS_Addr::PID_Temp,
&DGUSScreenHandler::pid_temp,
&DGUSTxHandler::ExtraToInteger<uint16_t>),
VP_HELPER_DWORD(DGUS_Addr::PID_Kp,
VPFLAG_AUTOUPLOAD,
nullptr,
nullptr,
&DGUSTxHandler::PIDKp),
VP_HELPER_DWORD(DGUS_Addr::PID_Ki,
VPFLAG_AUTOUPLOAD,
nullptr,
nullptr,
&DGUSTxHandler::PIDKi),
VP_HELPER_DWORD(DGUS_Addr::PID_Kd,
VPFLAG_AUTOUPLOAD,
nullptr,
nullptr,
&DGUSTxHandler::PIDKd),
VP_HELPER(DGUS_Addr::INFOS_Machine,
DGUS_MACHINE_LEN,
VPFLAG_NONE,
(void*)DGUS_MACHINENAME,
nullptr,
&DGUSTxHandler::ExtraPGMToString),
VP_HELPER_TX_SIZE(DGUS_Addr::INFOS_BuildVolume,
DGUS_BUILDVOLUME_LEN,
&DGUSTxHandler::BuildVolume),
VP_HELPER(DGUS_Addr::INFOS_Version,
DGUS_VERSION_LEN,
VPFLAG_NONE,
(void*)DGUS_MARLINVERSION,
nullptr,
&DGUSTxHandler::ExtraPGMToString),
VP_HELPER_TX(DGUS_Addr::INFOS_TotalPrints, &DGUSTxHandler::TotalPrints),
VP_HELPER_TX(DGUS_Addr::INFOS_FinishedPrints, &DGUSTxHandler::FinishedPrints),
VP_HELPER_TX_SIZE(DGUS_Addr::INFOS_PrintTime,
DGUS_PRINTTIME_LEN,
&DGUSTxHandler::PrintTime),
VP_HELPER_TX_SIZE(DGUS_Addr::INFOS_LongestPrint,
DGUS_LONGESTPRINT_LEN,
&DGUSTxHandler::LongestPrint),
VP_HELPER_TX_SIZE(DGUS_Addr::INFOS_FilamentUsed,
DGUS_FILAMENTUSED_LEN,
&DGUSTxHandler::FilamentUsed),
VP_HELPER_TX(DGUS_Addr::WAIT_Icons, &DGUSTxHandler::WaitIcons),
// READ-WRITE VARIABLES
VP_HELPER(DGUS_Addr::FAN0_Speed,
2,
VPFLAG_AUTOUPLOAD,
nullptr,
&DGUSRxHandler::FanSpeed,
&DGUSTxHandler::FanSpeed),
VP_HELPER(DGUS_Addr::GCODE_Data,
DGUS_GCODE_LEN,
VPFLAG_RXSTRING,
(void*)DGUSScreenHandler::gcode,
&DGUSRxHandler::StringToExtra,
&DGUSTxHandler::ExtraToString),
VP_HELPER(DGUS_Addr::PID_Cycles,
2,
VPFLAG_NONE,
&DGUSScreenHandler::pid_cycles,
&DGUSRxHandler::IntegerToExtra<uint8_t>,
&DGUSTxHandler::ExtraToInteger<uint8_t>),
VP_HELPER(DGUS_Addr::VOLUME_Level,
2,
VPFLAG_NONE,
nullptr,
&DGUSRxHandler::Volume,
&DGUSTxHandler::Volume),
VP_HELPER(DGUS_Addr::BRIGHTNESS_Level,
2,
VPFLAG_NONE,
nullptr,
&DGUSRxHandler::Brightness,
&DGUSTxHandler::Brightness),
// SPECIAL CASES
VP_HELPER_TX(DGUS_Addr::STATUS_Percent_Complete, &DGUSTxHandler::Percent),
VP_HELPER_RX_NODATA(DGUS_Addr::INFOS_Debug, &DGUSRxHandler::Debug),
VP_HELPER((DGUS_Addr)0, 0, VPFLAG_NONE, nullptr, nullptr, nullptr)
};
#endif // DGUS_LCD_UI_RELOADED

View File

@ -0,0 +1,26 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 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 "DGUS_VP.h"
extern const struct DGUS_VP vp_list[];

View File

@ -0,0 +1,143 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 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/>.
*
*/
/**
* lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp
*/
#include "../../../inc/MarlinConfigPre.h"
#if ENABLED(DGUS_LCD_UI_RELOADED)
#include "../ui_api.h"
#include "DGUSScreenHandler.h"
namespace ExtUI {
void onStartup() { dgus_screen_handler.Init(); }
void onIdle() {
static bool processing = false;
// Prevent recursion
if (!processing) {
processing = true;
dgus_screen_handler.Loop();
processing = false;
}
}
void onPrinterKilled(FSTR_P const error, FSTR_P const component) {
dgus_screen_handler.PrinterKilled(error, component);
}
void onMediaInserted() { TERN_(SDSUPPORT, dgus_screen_handler.SDCardInserted()); }
void onMediaError() { TERN_(SDSUPPORT, dgus_screen_handler.SDCardError()); }
void onMediaRemoved() { TERN_(SDSUPPORT, dgus_screen_handler.SDCardRemoved()); }
void onPlayTone(const uint16_t frequency, const uint16_t duration) {
dgus_screen_handler.PlayTone(frequency, duration);
}
void onPrintTimerStarted() {
dgus_screen_handler.PrintTimerStarted();
}
void onPrintTimerPaused() {
dgus_screen_handler.PrintTimerPaused();
}
void onPrintTimerStopped() {
dgus_screen_handler.PrintTimerStopped();
}
void onFilamentRunout(const extruder_t extruder) {
dgus_screen_handler.FilamentRunout(extruder);
}
void onUserConfirmRequired(const char * const msg) {
dgus_screen_handler.UserConfirmRequired(msg);
}
void onStatusChanged(const char * const msg) {
dgus_screen_handler.SetStatusMessage(msg);
}
void onHomingStart() {}
void onHomingDone() {}
void onPrintDone() {}
void onFactoryReset() {
dgus_screen_handler.SettingsReset();
}
void onStoreSettings(char *buff) {
dgus_screen_handler.StoreSettings(buff);
}
void onLoadSettings(const char *buff) {
dgus_screen_handler.LoadSettings(buff);
}
void onPostprocessSettings() {}
void onSettingsStored(bool success) {
dgus_screen_handler.ConfigurationStoreWritten(success);
}
void onSettingsLoaded(bool success) {
dgus_screen_handler.ConfigurationStoreRead(success);
}
#if HAS_MESH
void onLevelingStart() {}
void onLevelingDone() {}
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) {
dgus_screen_handler.MeshUpdate(xpos, ypos);
}
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const probe_state_t state) {
if (state == G29_POINT_FINISH)
dgus_screen_handler.MeshUpdate(xpos, ypos);
}
#endif
#if ENABLED(POWER_LOSS_RECOVERY)
void onPowerLossResume() {
// Called on resume from power-loss
dgus_screen_handler.PowerLossResume();
}
#endif
#if HAS_PID_HEATING
void onPidTuning(const result_t rst) {
// Called for temperature PID tuning result
dgus_screen_handler.PidTuning(rst);
}
#endif
void onSteppersDisabled() {}
void onSteppersEnabled() {}
}
#endif // DGUS_LCD_UI_RELOADED

View File

@ -0,0 +1,137 @@
/*********************
* example.cpp *
*********************/
/****************************************************************************
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#include "../../../inc/MarlinConfigPre.h"
#if BOTH(EXTUI_EXAMPLE, EXTENSIBLE_UI)
#include "../ui_api.h"
// To implement a new UI, complete the functions below and
// read or update Marlin's state using the methods in the
// ExtUI methods in "../ui_api.h"
//
// Although it may be possible to access other state
// variables from Marlin, using the API here possibly
// helps ensure future compatibility.
namespace ExtUI {
void onStartup() {
/* Initialize the display module here. The following
* routines are available for access to the GPIO pins:
*
* SET_OUTPUT(pin)
* SET_INPUT_PULLUP(pin)
* SET_INPUT(pin)
* WRITE(pin,value)
* READ(pin)
*/
}
void onIdle() {}
void onPrinterKilled(FSTR_P const error, FSTR_P const component) {}
void onMediaInserted() {}
void onMediaError() {}
void onMediaRemoved() {}
void onPlayTone(const uint16_t frequency, const uint16_t duration) {}
void onPrintTimerStarted() {}
void onPrintTimerPaused() {}
void onPrintTimerStopped() {}
void onFilamentRunout(const extruder_t extruder) {}
void onUserConfirmRequired(const char * const msg) {}
void onStatusChanged(const char * const msg) {}
void onHomingStart() {}
void onHomingDone() {}
void onPrintDone() {}
void onFactoryReset() {}
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) <= 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) <= eeprom_data_size);
// memcpy(&myDataStruct, buff, sizeof(myDataStruct));
}
void onPostprocessSettings() {
// Called after loading or resetting stored settings
}
void onSettingsStored(bool success) {
// Called after the entire EEPROM has been written,
// whether successful or not.
}
void onSettingsLoaded(bool success) {
// Called after the entire EEPROM has been read,
// whether successful or not.
}
#if HAS_MESH
void onLevelingStart() {}
void onLevelingDone() {}
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) {
// Called when any mesh points are updated
}
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const probe_state_t state) {
// Called to indicate a special condition
}
#endif
#if ENABLED(POWER_LOSS_RECOVERY)
void onPowerLossResume() {
// Called on resume from power-loss
}
#endif
#if HAS_PID_HEATING
void onPidTuning(const result_t rst) {
// Called for temperature PID tuning result
switch (rst) {
case PID_STARTED: break;
case PID_BAD_EXTRUDER_NUM: break;
case PID_TEMP_TOO_HIGH: break;
case PID_TUNING_TIMEOUT: break;
case PID_DONE: break;
}
}
#endif
void onSteppersDisabled() {}
void onSteppersEnabled() {}
}
#endif // EXTUI_EXAMPLE && EXTENSIBLE_UI

View File

@ -0,0 +1,552 @@
/*********************
* flash_storage.cpp *
*********************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#include "../config.h"
#if ENABLED(TOUCH_UI_FTDI_EVE)
#include "../ftdi_eve_lib/ftdi_eve_lib.h"
#include "media_file_reader.h"
#include "flash_storage.h"
// The following must be changed whenever the layout of the flash
// data is changed in a manner that would render the data invalid.
constexpr uint32_t flash_eeprom_version = 1;
/* SPI Flash Memory Map:
*
* The following offsets and sizes are specified in 4k erase units:
*
* Page Size Description
* 0 16 DATA STORAGE AREA
* 16 1 VERSIONING DATA
* 17 inf MEDIA STORAGE AREA
*/
#define DATA_STORAGE_SIZE_64K
using namespace FTDI::SPI;
using namespace FTDI::SPI::most_significant_byte_first;
bool UIFlashStorage::is_present = false;
#ifdef SPI_FLASH_SS
/************************** SPI Flash Chip Interface **************************/
void SPIFlash::wait_while_busy() {
uint8_t status;
safe_delay(1);
do {
spi_flash_select();
spi_write_8(READ_STATUS_1);
status = spi_read_8();
spi_flash_deselect();
safe_delay(1);
} while (status & 1);
}
void SPIFlash::erase_sector_4k(uint32_t addr) {
spi_flash_select();
spi_write_8(WRITE_ENABLE);
spi_flash_deselect();
spi_flash_select();
spi_write_8(ERASE_4K);
spi_write_24(addr);
spi_flash_deselect();
wait_while_busy();
}
void SPIFlash::erase_sector_64k(uint32_t addr) {
spi_flash_select();
spi_write_8(WRITE_ENABLE);
spi_flash_deselect();
spi_flash_select();
spi_write_8(ERASE_64K);
spi_write_24(addr);
spi_flash_deselect();
wait_while_busy();
}
void SPIFlash::spi_write_begin(uint32_t addr) {
spi_flash_select();
spi_write_8(WRITE_ENABLE);
spi_flash_deselect();
spi_flash_select();
spi_write_8(PAGE_PROGRAM);
spi_write_24(addr);
}
void SPIFlash::spi_write_end() {
spi_flash_deselect();
wait_while_busy();
}
void SPIFlash::spi_read_begin(uint32_t addr) {
spi_flash_select();
spi_write_8(READ_DATA);
spi_write_24(addr);
}
void SPIFlash::spi_read_end() {
spi_flash_deselect();
}
void SPIFlash::erase_chip() {
spi_flash_select();
spi_write_8(WRITE_ENABLE);
spi_flash_deselect();
spi_flash_select();
spi_write_8(ERASE_CHIP);
spi_flash_deselect();
wait_while_busy();
}
void SPIFlash::read_jedec_id(uint8_t &manufacturer_id, uint8_t &device_type, uint8_t &capacity) {
spi_flash_select();
spi_write_8(READ_JEDEC_ID);
manufacturer_id = spi_recv();
device_type = spi_recv();
capacity = spi_recv();
spi_flash_deselect ();
}
/* This function writes "size" bytes from "data" starting at addr, while properly
* taking into account the special case of writing across a 256 byte page boundary.
* Returns the addr directly after the write.
*/
uint32_t SPIFlash::write(uint32_t addr, const void *_data, size_t size) {
const uint8_t *data = (const uint8_t*) _data;
while (size) {
const uint32_t page_start = addr & 0xFFFF00ul;
const uint32_t page_end = page_start + 256;
const uint32_t write_size = min(page_end - addr, size);
spi_write_begin(addr);
spi_write_bulk<ram_write>(data, write_size);
spi_write_end();
addr += write_size;
size -= write_size;
data += write_size;
}
return addr;
}
uint32_t SPIFlash::read(uint32_t addr, void *data, size_t size) {
spi_read_begin(addr);
spi_read_bulk(data, size);
spi_read_end();
return addr + size;
}
/********************************** UTILITY ROUTINES *********************************/
bool UIFlashStorage::check_known_device() {
uint8_t manufacturer_id, device_type, capacity;
read_jedec_id(manufacturer_id, device_type, capacity);
const bool is_known =
((manufacturer_id == 0xEF) && (device_type == 0x40) && (capacity == 0x15)) || // unknown
((manufacturer_id == 0x01) && (device_type == 0x40) && (capacity == 0x15)) || // Cypress S25FL116K
((manufacturer_id == 0xEF) && (device_type == 0x14) && (capacity == 0x15)) || // Winbond W25Q16JV
((manufacturer_id == 0x1F) && (device_type == 0x86) && (capacity == 0x01)) ; // Adesto AT255F161
if (!is_known) {
SERIAL_ECHO_MSG("Unable to locate supported SPI Flash Memory.");
SERIAL_ECHO_MSG(" Manufacturer ID, got: ", manufacturer_id);
SERIAL_ECHO_MSG(" Device Type , got: ", device_type);
SERIAL_ECHO_MSG(" Capacity , got: ", capacity);
}
return is_known;
}
void UIFlashStorage::initialize() {
for (uint8_t i = 0; i < 10; i++) {
if (check_known_device()) {
is_present = true;
break;
}
safe_delay(1000);
}
}
/**************************** DATA STORAGE AREA (first 4K or 64k) ********************/
#ifdef DATA_STORAGE_SIZE_64K
constexpr uint32_t data_storage_area_size = 64 * 1024; // Large erase unit
#else
constexpr uint32_t data_storage_area_size = 4 * 1024; // Small erase unit
#endif
/* In order to provide some degree of wear leveling, each data write to the
* SPI Flash chip is appended to data that was already written before, until
* the data storage area is completely filled. New data is written preceded
* with a 32-bit delimiter 'LULZ', so that we can distinguish written and
* unwritten data:
*
* 'LULZ' <--- 1st record delimiter
* <data_byte>
* <data_byte>
* <data_byte>
* 'LULZ' <--- 2nd record delimiter
* <data_byte>
* <data_byte>
* <data_byte>
* ...
* 'LULZ' <--- Last record delimiter
* <data_byte>
* <data_byte>
* <data_byte>
* 0xFF <--- Start of free space
* 0xFF
* ...
*
* This function walks down the data storage area, verifying that the
* delimiters are either 'LULZ' or 0xFFFFFFFF. In the case that an invalid
* delimiter is found, this function returns -1, indicating that the Flash
* data is invalid (this will happen if the block_size changed with respect
* to earlier firmware). Otherwise, it returns the offset of the last
* valid delimiter 'LULZ', indicating the most recently written data.
*/
int32_t UIFlashStorage::get_config_read_offset(uint32_t block_size) {
uint16_t stride = 4 + block_size;
int32_t read_offset = -1;
for (uint32_t offset = 0; offset < (data_storage_area_size - stride); offset += stride) {
uint32_t delim;
spi_read_begin(offset);
spi_read_bulk (&delim, sizeof(delim));
spi_read_end();
switch (delim) {
case 0xFFFFFFFFul: return read_offset;
case delimiter: read_offset = offset; break;
default:
SERIAL_ECHO_MSG("Invalid delimiter in Flash: ", delim);
return -1;
}
}
SERIAL_ECHO_MSG("No LULZ delimiter found.");
return -1;
}
/* This function returns the offset at which new data should be
* appended, or -1 if the Flash needs to be erased */
int32_t UIFlashStorage::get_config_write_offset(uint32_t block_size) {
int32_t read_offset = get_config_read_offset(block_size);
if (read_offset == -1) return -1; // The SPI flash is invalid
int32_t write_offset = read_offset + 4 + block_size;
if ((write_offset + 4 + block_size) > data_storage_area_size) {
SERIAL_ECHO_MSG("Not enough free space in Flash.");
return -1; // Not enough free space
}
return write_offset;
}
bool UIFlashStorage::verify_config_data(const void *data, size_t size) {
if (!is_present) return false;
int32_t read_addr = get_config_read_offset(size);
if (read_addr == -1) return false;
uint32_t delim;
spi_read_begin(read_addr);
spi_read_bulk (&delim, sizeof(delim));
bool ok = spi_verify_bulk(data,size);
spi_read_end();
return ok && delim == delimiter;
}
bool UIFlashStorage::read_config_data(void *data, size_t size) {
if (!is_present) return false;
int32_t read_addr = get_config_read_offset(size);
if (read_addr == -1) return false;
uint32_t delim;
spi_read_begin(read_addr);
spi_read_bulk (&delim, sizeof(delim));
spi_read_bulk (data, size);
spi_read_end();
return delim == delimiter;
}
void UIFlashStorage::write_config_data(const void *data, size_t size) {
if (!is_present) {
SERIAL_ECHO_MSG("SPI Flash chip not present. Not saving UI settings.");
return;
}
// Since Flash storage has a limited number of write cycles,
// make sure that the data is different before rewriting.
if (verify_config_data(data, size)) {
SERIAL_ECHO_MSG("UI settings already written, skipping write.");
return;
}
int16_t write_addr = get_config_write_offset(size);
if (write_addr == -1) {
SERIAL_ECHO_START();
SERIAL_ECHOPGM("Erasing UI settings from SPI Flash... ");
#ifdef DATA_STORAGE_SIZE_64K
erase_sector_64k(0);
#else
erase_sector_4k(0);
#endif
write_addr = 0;
SERIAL_ECHOLNPGM("DONE");
}
SERIAL_ECHO_START();
SERIAL_ECHOPGM("Writing UI settings to SPI Flash (offset ", write_addr, ")...");
const uint32_t delim = delimiter;
write_addr = write(write_addr, &delim, sizeof(delim));
write_addr = write(write_addr, data, size);
SERIAL_ECHOLNPGM("DONE");
}
/************************** VERSIONING INFO AREA ************************/
/* The version info area follows the data storage area. If the version
* is incorrect, the data on the chip is invalid and format_flash should
* be called.
*/
typedef struct {
uint32_t magic;
uint32_t version;
} flash_version_info;
constexpr uint32_t version_info_addr = data_storage_area_size;
constexpr uint32_t version_info_size = 4 * 1024; // Small erase unit
bool UIFlashStorage::is_valid() {
flash_version_info info;
spi_read_begin(version_info_addr);
spi_read_bulk (&info, sizeof(flash_version_info));
spi_read_end();
return info.magic == delimiter && info.version == flash_eeprom_version;
}
void UIFlashStorage::write_version_info() {
flash_version_info info;
info.magic = delimiter;
info.version = flash_eeprom_version;
spi_write_begin(version_info_addr);
spi_write_bulk<ram_write>(&info, sizeof(flash_version_info));
spi_write_end();
}
/**************************** MEDIA STORAGE AREA *****************************/
/* The media storage area follows the versioning info area. It consists
* of a file index followed by the data for one or more media files.
*
* The file index consists of an array of 32-bit file sizes. If a file
* is not present, the file's size will be set to 0xFFFFFFFF
*/
constexpr uint32_t media_storage_addr = version_info_addr + version_info_size;
constexpr uint8_t media_storage_slots = 4;
void UIFlashStorage::format_flash() {
SERIAL_ECHO_START(); SERIAL_ECHOPGM("Erasing SPI Flash...");
SPIFlash::erase_chip();
SERIAL_ECHOLNPGM("DONE");
write_version_info();
}
uint32_t UIFlashStorage::get_media_file_start(uint8_t slot) {
uint32_t addr = media_storage_addr + sizeof(uint32_t) * media_storage_slots;
spi_read_begin(media_storage_addr);
for (uint8_t i = 0; i < slot; i++)
addr += spi_read_32();
spi_read_end();
return addr;
}
void UIFlashStorage::set_media_file_size(uint8_t slot, uint32_t size) {
spi_write_begin(media_storage_addr + sizeof(uint32_t) * slot);
spi_write_32(size);
spi_write_end();
}
uint32_t UIFlashStorage::get_media_file_size(uint8_t slot) {
spi_read_begin(media_storage_addr + sizeof(uint32_t) * slot);
uint32_t size = spi_read_32();
spi_read_end();
return size;
}
/* Writes a media file from the SD card/USB flash drive into a slot on the SPI Flash. Media
* files must be written sequentially following by a chip erase and it is not possible to
* overwrite files. */
UIFlashStorage::error_t UIFlashStorage::write_media_file(FSTR_P filename, uint8_t slot) {
#if ENABLED(SDSUPPORT)
uint32_t addr;
uint8_t buff[write_page_size];
strcpy_P((char*)buff, FTOP(filename));
MediaFileReader reader;
if (!reader.open((char*) buff)) {
SERIAL_ECHO_MSG("Unable to find media file");
return FILE_NOT_FOUND;
}
if (get_media_file_size(slot) != 0xFFFFFFFFUL) {
SERIAL_ECHO_MSG("Media file already exists");
return WOULD_OVERWRITE;
}
SERIAL_ECHO_START(); SERIAL_ECHOPGM("Writing SPI Flash...");
set_media_file_size(slot, reader.size());
addr = get_media_file_start(slot);
// Write out the file itself
for (;;) {
const int16_t nBytes = reader.read(buff, write_page_size);
if (nBytes == -1) {
SERIAL_ECHOLNPGM("Failed to read from file");
return READ_ERROR;
}
addr = write(addr, buff, nBytes);
if (nBytes != write_page_size) break;
TERN_(EXTENSIBLE_UI, ExtUI::yield());
}
SERIAL_ECHOLNPGM("DONE");
SERIAL_ECHO_START(); SERIAL_ECHOPGM("Verifying SPI Flash...");
bool verifyOk = true;
// Verify the file index
if (get_media_file_start(slot+1) != (get_media_file_start(slot) + reader.size())) {
SERIAL_ECHOLNPGM("File index verification failed. ");
verifyOk = false;
}
// Verify the file itself
addr = get_media_file_start(slot);
reader.rewind();
while (verifyOk) {
const int16_t nBytes = reader.read(buff, write_page_size);
if (nBytes == -1) {
SERIAL_ECHOPGM("Failed to read from file");
verifyOk = false;
break;
}
spi_read_begin(addr);
if (!spi_verify_bulk(buff, nBytes)) {
verifyOk = false;
spi_read_end();
break;
}
spi_read_end();
addr += nBytes;
if (nBytes != write_page_size) break;
TERN_(EXTENSIBLE_UI, ExtUI::yield());
};
if (verifyOk) {
SERIAL_ECHOLNPGM("DONE");
return SUCCESS;
}
else {
SERIAL_ECHOLNPGM("FAIL");
return VERIFY_ERROR;
}
#else
return VERIFY_ERROR;
#endif // SDSUPPORT
}
bool UIFlashStorage::BootMediaReader::isAvailable(uint32_t slot) {
if (!is_present) return false;
bytes_remaining = get_media_file_size(slot);
if (bytes_remaining != 0xFFFFFFFFUL) {
SERIAL_ECHO_MSG("Boot media file size:", bytes_remaining);
addr = get_media_file_start(slot);
return true;
}
return false;
}
int16_t UIFlashStorage::BootMediaReader::read(void *data, const size_t size) {
if (bytes_remaining == 0xFFFFFFFFUL) return -1;
if (size > bytes_remaining)
return read(data, bytes_remaining);
if (size > 0) {
spi_read_begin(addr);
spi_read_bulk(data, size);
spi_read_end();
addr += size;
bytes_remaining -= size;
}
return size;
}
int16_t UIFlashStorage::BootMediaReader::read(void *obj, void *data, const size_t size) {
return reinterpret_cast<UIFlashStorage::BootMediaReader*>(obj)->read(data, size);
}
#else
void UIFlashStorage::initialize() {}
bool UIFlashStorage::is_valid() {return true;}
void UIFlashStorage::write_config_data(const void *, size_t) {}
bool UIFlashStorage::verify_config_data(const void *, size_t) {return false;}
bool UIFlashStorage::read_config_data(void *, size_t ) {return false;}
UIFlashStorage::error_t UIFlashStorage::write_media_file(FSTR_P, uint8_t) {return FILE_NOT_FOUND;}
void UIFlashStorage::format_flash() {}
bool UIFlashStorage::BootMediaReader::isAvailable(uint32_t) {return false;}
int16_t UIFlashStorage::BootMediaReader::read(void *, const size_t) {return -1;}
int16_t UIFlashStorage::BootMediaReader::read(void *, void *, const size_t) {return -1;}
#endif // SPI_FLASH_SS
#endif // TOUCH_UI_FTDI_EVE

View File

@ -0,0 +1,106 @@
/*******************
* flash_storage.h *
*******************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
class SPIFlash {
public:
static constexpr uint32_t erase_unit_size = 4 * 1024; // Minimum erase unit
static constexpr uint32_t write_page_size = 256; // Minimum page write unit
enum {
READ_STATUS_1 = 0x05,
READ_STATUS_2 = 0x35,
READ_STATUS_3 = 0x33,
WRITE_ENABLE = 0x06,
WRITE_DISABLE = 0x04,
READ_ID = 0x90,
READ_JEDEC_ID = 0x9F,
READ_DATA = 0x03,
PAGE_PROGRAM = 0x02,
ERASE_4K = 0x20,
ERASE_64K = 0xD8,
ERASE_CHIP = 0xC7
};
static void wait_while_busy();
static void erase_sector_4k(uint32_t addr);
static void erase_sector_64k(uint32_t addr);
static void erase_chip ();
static void read_jedec_id(uint8_t &manufacturer_id, uint8_t &device_type, uint8_t &capacity);
static void spi_read_begin(uint32_t addr);
static void spi_read_end();
static void spi_write_begin(uint32_t addr);
static void spi_write_end();
static uint32_t write(uint32_t addr, const void *data, size_t size);
static uint32_t read(uint32_t addr, void *data, size_t size);
};
class UIFlashStorage : private SPIFlash {
private:
static bool is_present;
static int32_t get_config_read_offset(uint32_t block_size);
static int32_t get_config_write_offset(uint32_t block_size);
static uint32_t get_media_file_start(uint8_t slot);
static void set_media_file_size(uint8_t slot, uint32_t size);
static uint32_t get_media_file_size(uint8_t slot);
static constexpr uint32_t delimiter = 0x4D524C4E; // 'MRLN'
public:
enum error_t {
SUCCESS,
FILE_NOT_FOUND,
READ_ERROR,
VERIFY_ERROR,
WOULD_OVERWRITE
};
static void initialize ();
static void format_flash ();
static bool check_known_device();
static bool is_valid ();
static void write_version_info();
static void write_config_data (const void *data, size_t size);
static bool verify_config_data (const void *data, size_t size);
static bool read_config_data (void *data, size_t size);
static error_t write_media_file (FSTR_P filename, uint8_t slot = 0);
class BootMediaReader;
};
class UIFlashStorage::BootMediaReader {
private:
uint32_t addr;
uint32_t bytes_remaining;
public:
bool isAvailable(uint32_t slot = 0);
int16_t read(void *buffer, size_t const size);
static int16_t read(void *obj, void *buffer, const size_t size);
};

View File

@ -0,0 +1,61 @@
/************************
* media_filereader.cpp *
************************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#include "../config.h"
#if ENABLED(TOUCH_UI_FTDI_EVE)
#include "media_file_reader.h"
#if ENABLED(SDSUPPORT)
bool MediaFileReader::open(const char *filename) {
root = CardReader::getroot();
return file.open(&root, filename, O_READ);
}
int16_t MediaFileReader::read(void *buff, size_t bytes) {
return file.read(buff, bytes);
}
void MediaFileReader::close() {
file.close();
}
uint32_t MediaFileReader::size() {
return file.fileSize();
}
void MediaFileReader::rewind() {
file.rewind();
}
int16_t MediaFileReader::read(void *obj, void *buff, size_t bytes) {
return reinterpret_cast<MediaFileReader*>(obj)->read(buff, bytes);
}
#else
bool MediaFileReader::open(const char*) {return -1;}
int16_t MediaFileReader::read(void *, size_t) {return 0;}
void MediaFileReader::close() {}
uint32_t MediaFileReader::size() {return 0;}
void MediaFileReader::rewind() {}
int16_t MediaFileReader::read(void *, void *, size_t) {return 0;}
#endif
#endif // TOUCH_UI_FTDI_EVE

View File

@ -0,0 +1,46 @@
/**********************
* media_filereader.h *
**********************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#pragma once
#include "../../../../inc/MarlinConfigPre.h"
#if ENABLED(SDSUPPORT)
#include "../../../../sd/SdFile.h"
#include "../../../../sd/cardreader.h"
#endif
class MediaFileReader {
private:
#if ENABLED(SDSUPPORT)
SdFile root, file;
#endif
public:
bool open(const char *filename);
int16_t read(void *buff, size_t bytes);
uint32_t size();
void rewind();
void close();
static int16_t read(void *obj, void *buff, size_t bytes);
};

View File

@ -0,0 +1,102 @@
/*************************
* advanced_settings.cpp *
*************************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#include "../config.h"
#include "../screens.h"
#ifdef FTDI_BIO_ADVANCED_SETTINGS_MENU
using namespace FTDI;
using namespace Theme;
#define GRID_COLS 2
#define GRID_ROWS 9
void AdvancedSettingsMenu::onRedraw(draw_mode_t what) {
if (what & BACKGROUND) {
CommandProcessor cmd;
cmd.cmd(CLEAR_COLOR_RGB(Theme::bg_color))
.cmd(CLEAR(true,true,true));
}
if (what & FOREGROUND) {
CommandProcessor cmd;
cmd.colors(normal_btn)
.font(Theme::font_medium)
.tag(2) .button(BTN_POS(1,1), BTN_SIZE(1,1), GET_TEXT_F(MSG_DISPLAY_MENU))
.enabled(ENABLED(HAS_TRINAMIC_CONFIG))
.tag(3) .button(BTN_POS(1,2), BTN_SIZE(1,1), GET_TEXT_F(MSG_TMC_CURRENT))
.enabled(ENABLED(HAS_TRINAMIC_CONFIG))
.tag(4) .button(BTN_POS(1,3), BTN_SIZE(1,1), GET_TEXT_F(MSG_TMC_HOMING_THRS))
.tag(5) .button(BTN_POS(1,4), BTN_SIZE(1,1), GET_TEXT_F(MSG_LCD_ENDSTOPS))
.enabled(ENABLED(HAS_MULTI_HOTEND))
.tag(6) .button(BTN_POS(1,5), BTN_SIZE(1,1), GET_TEXT_F(MSG_OFFSETS_MENU))
.tag(7) .button(BTN_POS(2,1), BTN_SIZE(1,1), GET_TEXT_F(MSG_STEPS_PER_MM))
.tag(8) .button(BTN_POS(2,2), BTN_SIZE(1,1), GET_TEXT_F(MSG_MAX_SPEED))
.tag(9) .button(BTN_POS(2,3), BTN_SIZE(1,1), GET_TEXT_F(MSG_ACCELERATION))
.tag(10) .button(BTN_POS(2,4), BTN_SIZE(1,1), GET_TEXT_F(TERN(HAS_JUNCTION_DEVIATION, MSG_JUNCTION_DEVIATION, MSG_JERK)))
.enabled(ENABLED(BACKLASH_GCODE))
.tag(11) .button(BTN_POS(2,5), BTN_SIZE(1,1), GET_TEXT_F(MSG_BACKLASH))
.enabled(ENABLED(LIN_ADVANCE))
.tag(12) .button(BTN_POS(1,6), BTN_SIZE(2,1), GET_TEXT_F(MSG_LINEAR_ADVANCE))
.tag(13) .button(BTN_POS(1,7), BTN_SIZE(2,1), GET_TEXT_F(MSG_INTERFACE))
.tag(14) .button(BTN_POS(1,8), BTN_SIZE(2,1), GET_TEXT_F(MSG_RESTORE_DEFAULTS))
.colors(action_btn)
.tag(1) .button( BTN_POS(1,9), BTN_SIZE(2,1), GET_TEXT_F(MSG_BUTTON_DONE));
}
}
bool AdvancedSettingsMenu::onTouchEnd(uint8_t tag) {
using namespace ExtUI;
switch (tag) {
case 1: SaveSettingsDialogBox::promptToSaveSettings(); break;
case 2: GOTO_SCREEN(DisplayTuningScreen); break;
#if HAS_TRINAMIC_CONFIG
case 3: GOTO_SCREEN(StepperCurrentScreen); break;
case 4: GOTO_SCREEN(StepperBumpSensitivityScreen); break;
#endif
case 5: GOTO_SCREEN(EndstopStatesScreen); break;
#if HAS_MULTI_HOTEND
case 6: GOTO_SCREEN(NozzleOffsetScreen); break;
#endif
case 7: GOTO_SCREEN(StepsScreen); break;
case 8: GOTO_SCREEN(MaxVelocityScreen); break;
case 9: GOTO_SCREEN(DefaultAccelerationScreen); break;
case 10: GOTO_SCREEN(TERN(HAS_JUNCTION_DEVIATION, JunctionDeviationScreen, JerkScreen)); break;
#if ENABLED(BACKLASH_GCODE)
case 11: GOTO_SCREEN(BacklashCompensationScreen); break;
#endif
#if ENABLED(LIN_ADVANCE)
case 12: GOTO_SCREEN(LinearAdvanceScreen); break;
#endif
case 13: GOTO_SCREEN(InterfaceSettingsScreen); break;
case 14: GOTO_SCREEN(RestoreFailsafeDialogBox); break;
default: return false;
}
return true;
}
#endif // FTDI_BIO_ADVANCED_SETTINGS_MENU

View File

@ -0,0 +1,32 @@
/***********************
* advanced_settings.h *
***********************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#pragma once
#define FTDI_BIO_ADVANCED_SETTINGS_MENU
#define FTDI_BIO_ADVANCED_SETTINGS_MENU_CLASS AdvancedSettingsMenu
class AdvancedSettingsMenu : public BaseScreen, public CachedScreen<ADVANCED_SETTINGS_SCREEN_CACHE> {
public:
static void onRedraw(draw_mode_t);
static bool onTouchEnd(uint8_t tag);
};

View File

@ -0,0 +1,56 @@
/************************
* confirm_home_xyz.cpp *
************************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#include "../config.h"
#include "../screens.h"
#ifdef FTDI_BIO_CONFIRM_HOME_E
using namespace FTDI;
void BioConfirmHomeE::onRedraw(draw_mode_t) {
drawMessage(GET_TEXT_F(MSG_HOME_E_WARNING));
drawYesNoButtons(1);
}
bool BioConfirmHomeE::onTouchEnd(uint8_t tag) {
switch (tag) {
case 1:
#if defined(AXIS_LEVELING_COMMANDS) && defined(PARK_AND_RELEASE_COMMANDS)
SpinnerDialogBox::enqueueAndWait(F(
"G28 E\n"
AXIS_LEVELING_COMMANDS "\n"
PARK_AND_RELEASE_COMMANDS
));
#endif
current_screen.forget();
break;
case 2:
GOTO_SCREEN(StatusScreen);
break;
default:
return DialogBoxBaseClass::onTouchEnd(tag);
}
return true;
}
#endif // FTDI_BIO_CONFIRM_HOME_E

View File

@ -0,0 +1,32 @@
/********************
* confirm_home_e.h *
********************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#pragma once
#define FTDI_BIO_CONFIRM_HOME_E
#define FTDI_BIO_CONFIRM_HOME_E_CLASS BioConfirmHomeE
class BioConfirmHomeE : public DialogBoxBaseClass, public UncachedScreen {
public:
static void onRedraw(draw_mode_t);
static bool onTouchEnd(uint8_t tag);
};

View File

@ -0,0 +1,55 @@
/************************
* confirm_home_xyz.cpp *
************************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#include "../config.h"
#include "../screens.h"
#ifdef FTDI_BIO_CONFIRM_HOME_XYZ
using namespace FTDI;
void BioConfirmHomeXYZ::onRedraw(draw_mode_t) {
drawMessage(GET_TEXT_F(MSG_HOME_XYZ_WARNING));
drawYesNoButtons(1);
}
bool BioConfirmHomeXYZ::onTouchEnd(uint8_t tag) {
switch (tag) {
case 1:
#ifdef PARK_AND_RELEASE_COMMANDS
SpinnerDialogBox::enqueueAndWait(F(
"G28\n"
PARK_AND_RELEASE_COMMANDS
));
#endif
current_screen.forget();
break;
case 2:
GOTO_SCREEN(StatusScreen);
break;
default:
return DialogBoxBaseClass::onTouchEnd(tag);
}
return true;
}
#endif // FTDI_BIO_CONFIRM_HOME_XYZ

View File

@ -0,0 +1,32 @@
/**********************
* confirm_home_xyz.h *
**********************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#pragma once
#define FTDI_BIO_CONFIRM_HOME_XYZ
#define FTDI_BIO_CONFIRM_HOME_XYZ_CLASS BioConfirmHomeXYZ
class BioConfirmHomeXYZ : public DialogBoxBaseClass, public UncachedScreen {
public:
static void onRedraw(draw_mode_t);
static bool onTouchEnd(uint8_t tag);
};

View File

@ -0,0 +1,85 @@
/*****************
* main_menu.cpp *
*****************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#include "../config.h"
#include "../screens.h"
#ifdef FTDI_BIO_MAIN_MENU
using namespace FTDI;
using namespace Theme;
#define GRID_COLS 2
#define GRID_ROWS 10
void MainMenu::onRedraw(draw_mode_t what) {
if (what & BACKGROUND) {
CommandProcessor cmd;
cmd.cmd(CLEAR_COLOR_RGB(Theme::bg_color))
.cmd(CLEAR(true,true,true))
.tag(0);
}
if (what & FOREGROUND) {
CommandProcessor cmd;
cmd.cmd(COLOR_RGB(bg_text_enabled))
.font(font_large).text( BTN_POS(1,1), BTN_SIZE(2,1), GET_TEXT_F(MSG_MAIN))
.colors(normal_btn)
.font(font_medium)
.tag(2).button(BTN_POS(1,2), BTN_SIZE(2,1), GET_TEXT_F(MSG_MOVE_TO_HOME))
.tag(3).button(BTN_POS(1,3), BTN_SIZE(2,1), GET_TEXT_F(MSG_RAISE_PLUNGER))
.tag(4).button(BTN_POS(1,4), BTN_SIZE(2,1), GET_TEXT_F(MSG_RELEASE_XY_AXIS))
.tag(5).button(BTN_POS(1,5), BTN_SIZE(2,1), GET_TEXT_F(MSG_AUTOLEVEL_X_AXIS))
.tag(6).button(BTN_POS(1,6), BTN_SIZE(2,1), GET_TEXT_F(MSG_BED_TEMPERATURE))
.tag(7).button(BTN_POS(1,7), BTN_SIZE(2,1), GET_TEXT_F(MSG_INTERFACE))
.tag(8).button(BTN_POS(1,8), BTN_SIZE(2,1), GET_TEXT_F(MSG_ADVANCED_SETTINGS))
.tag(9).button(BTN_POS(1,9), BTN_SIZE(2,1), GET_TEXT_F(MSG_INFO_MENU))
.colors(action_btn)
.tag(1).button(BTN_POS(1,10), BTN_SIZE(2,1), GET_TEXT_F(MSG_BUTTON_DONE));
}
}
bool MainMenu::onTouchEnd(uint8_t tag) {
using namespace ExtUI;
const bool e_homed = isAxisPositionKnown(E0);
switch (tag) {
case 1: SaveSettingsDialogBox::promptToSaveSettings(); break;
case 2: GOTO_SCREEN(BioConfirmHomeXYZ); break;
case 3: SpinnerDialogBox::enqueueAndWait(e_homed ? F("G0 E0 F120") : F("G112")); break;
case 4: StatusScreen::unlockMotors(); break;
#ifdef AXIS_LEVELING_COMMANDS
case 5: SpinnerDialogBox::enqueueAndWait(F(AXIS_LEVELING_COMMANDS)); break;
#endif
case 6: GOTO_SCREEN(TemperatureScreen); break;
case 7: GOTO_SCREEN(InterfaceSettingsScreen); break;
case 8: GOTO_SCREEN(AdvancedSettingsMenu); break;
case 9: GOTO_SCREEN(AboutScreen); break;
default:
return false;
}
return true;
}
#endif // FTDI_BIO_MAIN_MENU

View File

@ -0,0 +1,32 @@
/*****************
* main_menu.cpp *
*****************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#pragma once
#define FTDI_BIO_MAIN_MENU
#define FTDI_BIO_MAIN_MENU_CLASS MainMenu
class MainMenu : public BaseScreen, public CachedScreen<MENU_SCREEN_CACHE> {
public:
static void onRedraw(draw_mode_t);
static bool onTouchEnd(uint8_t tag);
};

View File

@ -0,0 +1,151 @@
/***************************
* printing_dialog_box.cpp *
***************************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#include "../config.h"
#include "../screens.h"
#ifdef FTDI_BIO_PRINTING_DIALOG_BOX
using namespace FTDI;
using namespace ExtUI;
using namespace Theme;
#define GRID_COLS 2
#define GRID_ROWS 9
void BioPrintingDialogBox::draw_status_message(draw_mode_t what, const char *cmsg) {
if (what & BACKGROUND) {
CommandProcessor cmd;
cmd.cmd(COLOR_RGB(bg_text_enabled))
.tag(0);
draw_text_box(cmd, BTN_POS(1,2), BTN_SIZE(2,2), cmsg, OPT_CENTER, font_large);
}
}
void BioPrintingDialogBox::draw_progress(draw_mode_t what) {
if (what & FOREGROUND) {
CommandProcessor cmd;
cmd.font(font_large)
.text(BTN_POS(1,1), BTN_SIZE(2,2), isPrinting() ? F("Printing...") : F("Finished."))
.tag(1)
.font(font_xlarge);
draw_circular_progress(cmd, BTN_POS(1,4), BTN_SIZE(2,3), getProgress_percent(), theme_dark, theme_darkest);
}
}
void BioPrintingDialogBox::draw_time_remaining(draw_mode_t what) {
if (what & FOREGROUND) {
const uint32_t elapsed = getProgress_seconds_elapsed();
const uint8_t hrs = elapsed/3600;
const uint8_t min = (elapsed/60)%60;
char time_str[10];
sprintf_P(time_str, PSTR("%02dh %02dm"), hrs, min);
CommandProcessor cmd;
cmd.font(font_large)
.text(BTN_POS(1,7), BTN_SIZE(2,2), time_str);
}
}
void BioPrintingDialogBox::draw_interaction_buttons(draw_mode_t what) {
if (what & FOREGROUND) {
CommandProcessor cmd;
cmd.colors(normal_btn)
.font(font_medium)
.colors(isPrinting() ? action_btn : normal_btn)
.tag(2).button(BTN_POS(1,9), BTN_SIZE(1,1), F("Menu"))
.enabled(isPrinting() ? TERN0(SDSUPPORT, isPrintingFromMedia()) : 1)
.tag(3)
.colors(isPrinting() ? normal_btn : action_btn)
.button(BTN_POS(2,9), BTN_SIZE(1,1), isPrinting() ? F("Cancel") : F("Back"));
}
}
void BioPrintingDialogBox::onRedraw(draw_mode_t what) {
if (what & FOREGROUND) {
draw_progress(FOREGROUND);
draw_time_remaining(FOREGROUND);
draw_interaction_buttons(FOREGROUND);
}
}
bool BioPrintingDialogBox::onTouchEnd(uint8_t tag) {
switch (tag) {
case 1: GOTO_SCREEN(FeedratePercentScreen); break;
case 2: GOTO_SCREEN(TuneMenu); break;
case 3:
if (isPrinting())
GOTO_SCREEN(ConfirmAbortPrintDialogBox);
else
GOTO_SCREEN(StatusScreen);
break;
default: return false;
}
return true;
}
void BioPrintingDialogBox::setStatusMessage(FSTR_P fmsg) {
#ifdef __AVR__
char buff[strlen_P(FTOP(fmsg)) + 1];
strcpy_P(buff, FTOP(fmsg));
setStatusMessage(buff);
#else
setStatusMessage(FTOP(fmsg));
#endif
}
void BioPrintingDialogBox::setStatusMessage(const char *cmsg) {
CommandProcessor cmd;
cmd.cmd(CMD_DLSTART)
.cmd(CLEAR_COLOR_RGB(bg_color))
.cmd(CLEAR(true,true,true));
draw_status_message(BACKGROUND, cmsg);
draw_progress(BACKGROUND);
draw_time_remaining(BACKGROUND);
draw_interaction_buttons(BACKGROUND);
storeBackground();
#if ENABLED(TOUCH_UI_DEBUG)
SERIAL_ECHO_MSG("New status message: ", cmsg);
#endif
if (AT_SCREEN(BioPrintingDialogBox))
current_screen.onRefresh();
}
void BioPrintingDialogBox::onIdle() {
reset_menu_timeout();
if (refresh_timer.elapsed(STATUS_UPDATE_INTERVAL)) {
onRefresh();
refresh_timer.start();
}
BaseScreen::onIdle();
}
void BioPrintingDialogBox::show() {
GOTO_SCREEN(BioPrintingDialogBox);
}
#endif // FTDI_BIO_PRINTING_DIALOG_BOX

View File

@ -0,0 +1,44 @@
/*************************
* printing_dialog_box.h *
*************************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#pragma once
#define FTDI_BIO_PRINTING_DIALOG_BOX
#define FTDI_BIO_PRINTING_DIALOG_BOX_CLASS BioPrintingDialogBox
class BioPrintingDialogBox : public BaseScreen, public CachedScreen<PRINTING_SCREEN_CACHE,PRINTING_SCREEN_DL_SIZE> {
private:
static void draw_status_message(draw_mode_t, const char * const);
static void draw_progress(draw_mode_t);
static void draw_time_remaining(draw_mode_t);
static void draw_interaction_buttons(draw_mode_t);
public:
static void onRedraw(draw_mode_t);
static void show();
static void setStatusMessage(const char *);
static void setStatusMessage(FSTR_P);
static void onIdle();
static bool onTouchEnd(uint8_t tag);
};

View File

@ -0,0 +1,105 @@
/*************
* screens.h *
*************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
/********************************* DL CACHE SLOTS ******************************/
// In order to reduce SPI traffic, we cache display lists (DL) in RAMG. This
// is done using the CLCD::DLCache class, which takes a unique ID for each
// cache location. These IDs are defined here:
enum {
STATUS_SCREEN_CACHE,
MENU_SCREEN_CACHE,
TUNE_SCREEN_CACHE,
ALERT_BOX_CACHE,
SPINNER_CACHE,
ADVANCED_SETTINGS_SCREEN_CACHE,
TEMPERATURE_SCREEN_CACHE,
STEPS_SCREEN_CACHE,
MAX_FEEDRATE_SCREEN_CACHE,
MAX_VELOCITY_SCREEN_CACHE,
MAX_ACCELERATION_SCREEN_CACHE,
DEFAULT_ACCELERATION_SCREEN_CACHE,
FLOW_PERCENT_SCREEN_CACHE,
ZOFFSET_SCREEN_CACHE,
STEPPER_CURRENT_SCREEN_CACHE,
STEPPER_BUMP_SENSITIVITY_SCREEN_CACHE,
PRINTING_SCREEN_CACHE,
FILES_SCREEN_CACHE,
INTERFACE_SETTINGS_SCREEN_CACHE,
INTERFACE_SOUNDS_SCREEN_CACHE,
LOCK_SCREEN_CACHE,
DISPLAY_TIMINGS_SCREEN_CACHE
};
// To save MCU RAM, the status message is "baked" in to the status screen
// cache, so we reserve a large chunk of memory for the DL cache
#define STATUS_SCREEN_DL_SIZE 4096
#define ALERT_BOX_DL_SIZE 3072
#define SPINNER_DL_SIZE 3072
#define FILE_SCREEN_DL_SIZE 4160
#define PRINTING_SCREEN_DL_SIZE 2048
/************************* MENU SCREEN DECLARATIONS *************************/
#include "../generic/base_screen.h"
#include "../generic/base_numeric_adjustment_screen.h"
#include "../generic/dialog_box_base_class.h"
#include "../generic/boot_screen.h"
#include "../generic/about_screen.h"
#include "../generic/kill_screen.h"
#include "../generic/alert_dialog_box.h"
#include "../generic/spinner_dialog_box.h"
#include "../generic/restore_failsafe_dialog_box.h"
#include "../generic/save_settings_dialog_box.h"
#include "../generic/confirm_start_print_dialog_box.h"
#include "../generic/confirm_abort_print_dialog_box.h"
#include "../generic/confirm_user_request_alert_box.h"
#include "../generic/touch_calibration_screen.h"
#include "../generic/move_axis_screen.h"
#include "../generic/steps_screen.h"
#include "../generic/feedrate_percent_screen.h"
#include "../generic/max_velocity_screen.h"
#include "../generic/max_acceleration_screen.h"
#include "../generic/default_acceleration_screen.h"
#include "../generic/temperature_screen.h"
#include "../generic/interface_sounds_screen.h"
#include "../generic/interface_settings_screen.h"
#include "../generic/lock_screen.h"
#include "../generic/endstop_state_screen.h"
#include "../generic/display_tuning_screen.h"
#include "../generic/media_player_screen.h"
#include "../generic/statistics_screen.h"
#include "../generic/stepper_current_screen.h"
#include "../generic/stepper_bump_sensitivity_screen.h"
#include "../generic/leveling_menu.h"
#include "../generic/z_offset_screen.h"
#include "../generic/files_screen.h"
#include "status_screen.h"
#include "main_menu.h"
#include "tune_menu.h"
#include "advanced_settings.h"
#include "printing_dialog_box.h"
#include "confirm_home_xyz.h"
#include "confirm_home_e.h"

View File

@ -0,0 +1,376 @@
/*********************
* status_screen.cpp *
*********************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2019 - Cocoa Press *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#include "../config.h"
#include "../screens.h"
#ifdef FTDI_BIO_STATUS_SCREEN
#if ENABLED(TOUCH_UI_PORTRAIT)
#include "ui_portrait.h"
#else
#include "ui_landscape.h"
#endif
#define GRID_COLS 2
#define GRID_ROWS 9
#define POLY(A) PolyUI::poly_reader_t(A, sizeof(A)/sizeof(A[0]))
const uint8_t shadow_depth = 5;
const float max_speed = 1.00;
const float min_speed = 0.02;
const float emax_speed = 2.00;
const float emin_speed = 0.70;
using namespace FTDI;
using namespace Theme;
using namespace ExtUI;
float StatusScreen::increment;
bool StatusScreen::jog_xy;
bool StatusScreen::fine_motion;
void StatusScreen::unlockMotors() {
injectCommands(F("M84 XY"));
jog_xy = false;
}
void StatusScreen::draw_temperature(draw_mode_t what) {
CommandProcessor cmd;
PolyUI ui(cmd, what);
int16_t x, y, h, v;
cmd.tag(15);
if (what & BACKGROUND) {
cmd.cmd(COLOR_RGB(bg_color));
// The LulzBot Bio shows the temperature for
// the bed.
#if ENABLED(TOUCH_UI_PORTRAIT)
// Draw touch surfaces
ui.bounds(POLY(target_temp), x, y, h, v);
cmd.rectangle(x, y, h, v);
ui.bounds(POLY(actual_temp), x, y, h, v);
cmd.rectangle(x, y, h, v);
#else
ui.bounds(POLY(bed_temp), x, y, h, v);
cmd.rectangle(x, y, h, v);
#endif
ui.bounds(POLY(bed_icon), x, y, h, v);
cmd.rectangle(x, y, h, v);
// Draw bed icon
cmd.cmd(BITMAP_SOURCE(Bed_Heat_Icon_Info))
.cmd(BITMAP_LAYOUT(Bed_Heat_Icon_Info))
.cmd(BITMAP_SIZE (Bed_Heat_Icon_Info))
.cmd(COLOR_RGB(shadow_rgb))
.icon (x + 2, y + 2, h, v, Bed_Heat_Icon_Info, icon_scale * 2)
.cmd(COLOR_RGB(bg_text_enabled))
.icon (x, y, h, v, Bed_Heat_Icon_Info, icon_scale * 2);
#if ENABLED(TOUCH_UI_USE_UTF8)
load_utf8_bitmaps(cmd); // Restore font bitmap handles
#endif
}
if (what & FOREGROUND) {
char str[15];
cmd.cmd(COLOR_RGB(bg_text_enabled));
cmd.font(font_medium);
#if ENABLED(TOUCH_UI_PORTRAIT)
if (!isHeaterIdle(BED) && getTargetTemp_celsius(BED) > 0)
format_temp(str, getTargetTemp_celsius(BED));
else
strcpy_P(str, GET_TEXT(MSG_BED));
ui.bounds(POLY(target_temp), x, y, h, v);
cmd.text(x, y, h, v, str);
format_temp(str, getActualTemp_celsius(BED));
ui.bounds(POLY(actual_temp), x, y, h, v);
cmd.text(x, y, h, v, str);
#else
if (!isHeaterIdle(BED) && getTargetTemp_celsius(BED) > 0)
format_temp_and_temp(str, getActualTemp_celsius(BED), getTargetTemp_celsius(BED));
else
format_temp_and_idle(str, getActualTemp_celsius(BED));
ui.bounds(POLY(bed_temp), x, y, h, v);
cmd.text(x, y, h, v, str);
#endif
}
}
void StatusScreen::draw_syringe(draw_mode_t what) {
int16_t x, y, h, v;
const float fill_level = (
#ifdef E_MAX_POS
1.0 - min(1.0, max(0.0, getAxisPosition_mm(E0) / E_MAX_POS))
#else
0.75
#endif
);
const bool e_homed = TERN1(TOUCH_UI_LULZBOT_BIO, isAxisPositionKnown(E0));
CommandProcessor cmd;
PolyUI ui(cmd, what);
if (what & BACKGROUND) {
// Paint the shadow for the syringe
ui.color(shadow_rgb);
ui.shadow(POLY(syringe_outline), shadow_depth);
}
if (what & FOREGROUND && e_homed) {
// Paint the syringe icon
ui.color(syringe_rgb);
ui.fill(POLY(syringe_outline));
ui.color(fluid_rgb);
ui.bounds(POLY(syringe_fluid), x, y, h, v);
cmd.cmd(SAVE_CONTEXT());
cmd.cmd(SCISSOR_XY(x,y + v * (1.0 - fill_level)));
cmd.cmd(SCISSOR_SIZE(h, v * fill_level));
ui.fill(POLY(syringe_fluid), false);
cmd.cmd(RESTORE_CONTEXT());
ui.color(stroke_rgb);
ui.fill(POLY(syringe));
}
}
void StatusScreen::draw_arrows(draw_mode_t what) {
const bool e_homed = TERN1(TOUCH_UI_LULZBOT_BIO, isAxisPositionKnown(E0)),
z_homed = isAxisPositionKnown(Z);
CommandProcessor cmd;
PolyUI ui(cmd, what);
ui.button_fill (fill_rgb);
ui.button_stroke(stroke_rgb, 28);
ui.button_shadow(shadow_rgb, shadow_depth);
constexpr uint8_t style = PolyUI::REGULAR;
if ((what & BACKGROUND) || jog_xy) {
ui.button(1, POLY(x_neg), style);
ui.button(2, POLY(x_pos), style);
ui.button(3, POLY(y_neg), style);
ui.button(4, POLY(y_pos), style);
}
if ((what & BACKGROUND) || z_homed) {
ui.button(5, POLY(z_neg), style);
ui.button(6, POLY(z_pos), style);
}
if ((what & BACKGROUND) || e_homed) {
ui.button(7, POLY(e_neg), style);
ui.button(8, POLY(e_pos), style);
}
}
void StatusScreen::draw_fine_motion(draw_mode_t what) {
int16_t x, y, h, v;
CommandProcessor cmd;
PolyUI ui(cmd, what);
cmd.font(
#if ENABLED(TOUCH_UI_PORTRAIT)
font_medium
#else
font_small
#endif
)
.tag(16);
if (what & BACKGROUND) {
ui.bounds(POLY(fine_label), x, y, h, v);
cmd.cmd(COLOR_RGB(bg_text_enabled))
.text(x, y, h, v, GET_TEXT_F(MSG_FINE_MOTION));
}
if (what & FOREGROUND) {
ui.bounds(POLY(fine_toggle), x, y, h, v);
cmd.colors(ui_toggle)
.toggle2(x, y, h, v, GET_TEXT_F(MSG_NO), GET_TEXT_F(MSG_YES), fine_motion);
}
}
void StatusScreen::draw_overlay_icons(draw_mode_t what) {
const bool e_homed = TERN1(TOUCH_UI_LULZBOT_BIO, isAxisPositionKnown(E0)),
z_homed = isAxisPositionKnown(Z);
CommandProcessor cmd;
PolyUI ui(cmd, what);
if (what & FOREGROUND) {
ui.button_fill (fill_rgb);
ui.button_stroke(stroke_rgb, 28);
ui.button_shadow(shadow_rgb, shadow_depth);
constexpr uint8_t style = PolyUI::REGULAR;
if (!jog_xy) ui.button(12, POLY(padlock), style);
if (!e_homed) ui.button(13, POLY(home_e), style);
if (!z_homed) ui.button(14, POLY(home_z), style);
}
}
void StatusScreen::draw_buttons(draw_mode_t what) {
int16_t x, y, h, v;
const bool has_media = isMediaInserted() && !isPrintingFromMedia();
CommandProcessor cmd;
PolyUI ui(cmd, what);
ui.bounds(POLY(usb_btn), x, y, h, v);
cmd.font(font_medium)
.colors(normal_btn)
.enabled(has_media)
.colors(has_media ? action_btn : normal_btn)
.tag(9).button(x, y, h, v,
isPrintingFromMedia() ?
GET_TEXT_F(MSG_PRINTING) :
GET_TEXT_F(MSG_BUTTON_MEDIA)
);
ui.bounds(POLY(menu_btn), x, y, h, v);
cmd.colors(!has_media ? action_btn : normal_btn).tag(10).button(x, y, h, v, GET_TEXT_F(MSG_BUTTON_MENU));
}
void StatusScreen::loadBitmaps() {
// Load the bitmaps for the status screen
constexpr uint32_t base = ftdi_memory_map::RAM_G;
CLCD::mem_write_pgm(base + Bed_Heat_Icon_Info.RAMG_offset, Bed_Heat_Icon, sizeof(Bed_Heat_Icon));
// Load fonts for internationalization
#if ENABLED(TOUCH_UI_USE_UTF8)
load_utf8_data(base + UTF8_FONT_OFFSET);
#endif
}
void StatusScreen::onRedraw(draw_mode_t what) {
if (what & BACKGROUND) {
CommandProcessor cmd;
cmd.cmd(CLEAR_COLOR_RGB(bg_color))
.cmd(CLEAR(true,true,true))
.tag(0);
}
draw_syringe(what);
draw_temperature(what);
draw_arrows(what);
draw_overlay_icons(what);
draw_buttons(what);
draw_fine_motion(what);
}
bool StatusScreen::onTouchStart(uint8_t) {
increment = 0;
return true;
}
bool StatusScreen::onTouchEnd(uint8_t tag) {
switch (tag) {
case 1:
case 2:
case 3:
case 4:
case 12:
if (!jog_xy) {
jog_xy = true;
injectCommands(F("M17"));
}
jog({ 0, 0, 0 });
break;
case 5:
case 6:
jog({ 0, 0, 0 });
break;
case 9: GOTO_SCREEN(FilesScreen); break;
case 10: GOTO_SCREEN(MainMenu); break;
case 13: GOTO_SCREEN(BioConfirmHomeE); break;
case 14: SpinnerDialogBox::enqueueAndWait(F("G28Z")); break;
case 15: GOTO_SCREEN(TemperatureScreen); break;
case 16: fine_motion = !fine_motion; break;
default: return false;
}
// If a passcode is enabled, the LockScreen will prevent the
// user from proceeding.
LockScreen::check_passcode();
return true;
}
bool StatusScreen::onTouchHeld(uint8_t tag) {
if (tag >= 1 && tag <= 4 && !jog_xy) return false;
const float s = min_speed + (fine_motion ? 0 : (max_speed - min_speed) * sq(increment));
switch (tag) {
case 1: jog({-s, 0, 0}); break;
case 2: jog({ s, 0, 0}); break;
case 4: jog({ 0, -s, 0}); break; // NOTE: Y directions inverted because bed rather than needle moves
case 3: jog({ 0, s, 0}); break;
case 5: jog({ 0, 0, -s}); break;
case 6: jog({ 0, 0, s}); break;
case 7: case 8:
{
if (ExtUI::isMoving()) return false;
const feedRate_t feedrate = emin_speed + (fine_motion ? 0 : (emax_speed - emin_speed) * sq(increment));
const float increment = 0.25 * feedrate * (tag == 7 ? -1 : 1);
MoveAxisScreen::setManualFeedrate(E0, feedrate);
UI_INCREMENT(AxisPosition_mm, E0);
current_screen.onRefresh();
break;
}
default:
return false;
}
increment = min(1.0f, increment + 0.1f);
return false;
}
void StatusScreen::setStatusMessage(FSTR_P fstr) {
BioPrintingDialogBox::setStatusMessage(fstr);
}
void StatusScreen::setStatusMessage(const char * const str) {
BioPrintingDialogBox::setStatusMessage(str);
}
void StatusScreen::onIdle() {
reset_menu_timeout();
if (refresh_timer.elapsed(STATUS_UPDATE_INTERVAL)) {
if (!EventLoop::is_touch_held())
onRefresh();
if (isPrintingFromMedia())
BioPrintingDialogBox::show();
refresh_timer.start();
}
}
#endif // FTDI_BIO_STATUS_SCREEN

View File

@ -0,0 +1,56 @@
/*********************
* status_screen.cpp *
*********************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2019 - Cocoa Press *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#pragma once
#define FTDI_BIO_STATUS_SCREEN
#define FTDI_BIO_STATUS_SCREEN_CLASS StatusScreen
class StatusScreen : public BaseScreen, public CachedScreen<STATUS_SCREEN_CACHE> {
private:
static float increment;
static bool jog_xy;
static bool fine_motion;
static void draw_progress(draw_mode_t what);
static void draw_temperature(draw_mode_t what);
static void draw_syringe(draw_mode_t what);
static void draw_arrows(draw_mode_t what);
static void draw_overlay_icons(draw_mode_t what);
static void draw_fine_motion(draw_mode_t what);
static void draw_buttons(draw_mode_t what);
public:
static void loadBitmaps();
static void unlockMotors();
static void setStatusMessage(const char *);
static void setStatusMessage(FSTR_P);
static void onRedraw(draw_mode_t);
static bool onTouchStart(uint8_t tag);
static bool onTouchHeld(uint8_t tag);
static bool onTouchEnd(uint8_t tag);
static void onIdle();
};

View File

@ -0,0 +1,76 @@
/*****************
* tune_menu.cpp *
*****************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#include "../config.h"
#include "../screens.h"
#ifdef FTDI_BIO_TUNE_MENU
using namespace FTDI;
using namespace Theme;
using namespace ExtUI;
#define GRID_COLS 2
#define GRID_ROWS 8
void TuneMenu::onRedraw(draw_mode_t what) {
if (what & BACKGROUND) {
CommandProcessor cmd;
cmd.cmd(CLEAR_COLOR_RGB(bg_color))
.cmd(CLEAR(true,true,true))
.cmd(COLOR_RGB(bg_text_enabled))
.tag(0)
.font(font_large)
.text( BTN_POS(1,1), BTN_SIZE(2,1), GET_TEXT_F(MSG_PRINT_MENU));
}
if (what & FOREGROUND) {
CommandProcessor cmd;
cmd.colors(normal_btn)
.font(font_medium)
.enabled( isPrinting()).tag(2).button(BTN_POS(1,2), BTN_SIZE(2,1), GET_TEXT_F(MSG_PRINT_SPEED))
.tag(3).button(BTN_POS(1,3), BTN_SIZE(2,1), GET_TEXT_F(MSG_BED_TEMPERATURE))
.enabled(TERN_(BABYSTEPPING, true))
.tag(4).button(BTN_POS(1,4), BTN_SIZE(2,1), GET_TEXT_F(MSG_NUDGE_NOZZLE))
.enabled(!isPrinting()).tag(5).button(BTN_POS(1,5), BTN_SIZE(2,1), GET_TEXT_F(MSG_MOVE_TO_HOME))
.enabled(!isPrinting()).tag(6).button(BTN_POS(1,6), BTN_SIZE(2,1), GET_TEXT_F(MSG_RAISE_PLUNGER))
.enabled(!isPrinting()).tag(7).button(BTN_POS(1,7), BTN_SIZE(2,1), GET_TEXT_F(MSG_RELEASE_XY_AXIS))
.colors(action_btn) .tag(1).button(BTN_POS(1,8), BTN_SIZE(2,1), GET_TEXT_F(MSG_BUTTON_DONE));
}
}
bool TuneMenu::onTouchEnd(uint8_t tag) {
switch (tag) {
case 1: GOTO_PREVIOUS(); break;
case 2: GOTO_SCREEN(FeedratePercentScreen); break;
case 3: GOTO_SCREEN(TemperatureScreen); break;
case 4: GOTO_SCREEN(NudgeNozzleScreen); break;
case 5: GOTO_SCREEN(BioConfirmHomeXYZ); break;
case 6: SpinnerDialogBox::enqueueAndWait(F("G0 E0 F120")); break;
case 7: StatusScreen::unlockMotors(); break;
default:
return false;
}
return true;
}
#endif // FTDI_BIO_TUNE_MENU

View File

@ -0,0 +1,35 @@
/***************
* tune_menu.h *
***************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#pragma once
#define FTDI_BIO_TUNE_MENU
#define FTDI_BIO_TUNE_MENU_CLASS TuneMenu
class TuneMenu : public BaseScreen, public CachedScreen<TUNE_SCREEN_CACHE> {
private:
static void pausePrint();
static void resumePrint();
public:
static void onRedraw(draw_mode_t);
static bool onTouchEnd(uint8_t tag);
};

View File

@ -0,0 +1,61 @@
/******************
* ui_landscape.h *
******************/
/****************************************************************************
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
/**
* This file was auto-generated using "svg2cpp.py"
*
* The encoding consists of x,y pairs with the min and max scaled to
* 0x0000 and 0xFFFE. A single 0xFFFF in the data stream indicates the
* start of a new closed path.
*/
#pragma once
constexpr float x_min = 0.000000;
constexpr float x_max = 480.000000;
constexpr float y_min = 0.000000;
constexpr float y_max = 272.000000;
const PROGMEM uint16_t z_neg[] = {0x7950, 0x51EA, 0x824E, 0x51EA, 0x824E, 0x71E2, 0x86CD, 0x71E2, 0x7DCF, 0x81DF, 0x74D1, 0x71E2, 0x7950, 0x71E2, 0x7950, 0x51EA};
const PROGMEM uint16_t z_pos[] = {0x7950, 0x41EE, 0x824E, 0x41EE, 0x824E, 0x21F5, 0x86CD, 0x21F5, 0x7DCF, 0x11F9, 0x74D0, 0x21F5, 0x7950, 0x21F5, 0x7950, 0x41EE};
const PROGMEM uint16_t y_neg[] = {0x3479, 0x56CF, 0x3EC6, 0x56CF, 0x3747, 0x7281, 0x3C6D, 0x7281, 0x2E61, 0x8059, 0x27D4, 0x7281, 0x2CFA, 0x7281, 0x3479, 0x56CF};
const PROGMEM uint16_t y_pos[] = {0x3BF9, 0x3B1D, 0x4645, 0x3B1D, 0x4DC4, 0x1F6B, 0x52EB, 0x1F6B, 0x4C5E, 0x1192, 0x3E52, 0x1F6B, 0x4378, 0x1F6B, 0x3BF9, 0x3B1D};
const PROGMEM uint16_t x_neg[] = {0x350E, 0x4209, 0x314E, 0x4FE2, 0x1CB5, 0x4FE2, 0x1AD6, 0x56CF, 0x1449, 0x48F6, 0x2255, 0x3B1D, 0x2075, 0x4209, 0x350E, 0x4209};
const PROGMEM uint16_t x_pos[] = {0x498C, 0x4209, 0x45CC, 0x4FE2, 0x5A65, 0x4FE2, 0x5885, 0x56CF, 0x6691, 0x48F6, 0x6004, 0x3B1D, 0x5E25, 0x4209, 0x498C, 0x4209};
const PROGMEM uint16_t syringe_fluid[] = {0xB4E9, 0x78BE, 0xBB12, 0x7C44, 0xBDE3, 0x7C44, 0xC426, 0x78BE, 0xC426, 0x250D, 0xB4E9, 0x250D, 0xB4E9, 0x78BE};
const PROGMEM uint16_t syringe[] = {0xB8AD, 0x6BB1, 0xB8AD, 0x6E0C, 0xBE02, 0x6E0C, 0xBE02, 0x6BB1, 0xFFFF, 0xB8AD, 0x6248, 0xB8AD, 0x64A2, 0xBE02, 0x64A2, 0xBE02, 0x6248, 0xFFFF, 0xB8AD, 0x58DF, 0xB8AD, 0x5B39, 0xBE02, 0x5B39, 0xBE02, 0x58DF, 0xFFFF, 0xB8AD, 0x4F75, 0xB8AD, 0x51D0, 0xBE02, 0x51D0, 0xBE02, 0x4F75, 0xFFFF, 0xB8AD, 0x460C, 0xB8AD, 0x4866, 0xBE02, 0x4866, 0xBE02, 0x460C, 0xFFFF, 0xB8AD, 0x3CA3, 0xB8AD, 0x3EFD, 0xBE02, 0x3EFD, 0xBE02, 0x3CA3, 0xFFFF, 0xB8AD, 0x3339, 0xB8AD, 0x3594, 0xBE02, 0x3594, 0xBE02, 0x3339, 0xFFFF, 0xB396, 0x110A, 0xB396, 0x1818, 0xB995, 0x1818, 0xB995, 0x22AD, 0xB396, 0x22AD, 0xB396, 0x7ADA, 0xB995, 0x7E61, 0xB995, 0x88F5, 0xBB95, 0x88F5, 0xBB95, 0xA8B4, 0xBD94, 0xAC3B, 0xBD94, 0x88F5, 0xBF94, 0x88F5, 0xBF94, 0x7E61, 0xC593, 0x7ADA, 0xC593, 0x22AD, 0xBF94, 0x22AD, 0xBF94, 0x1818, 0xC593, 0x1818, 0xC593, 0x110A, 0xFFFF, 0xBB95, 0x1818, 0xBD94, 0x1818, 0xBD94, 0x22AD, 0xBB95, 0x22AD, 0xBB95, 0x1818, 0xFFFF, 0xB596, 0x2634, 0xC393, 0x2634, 0xC393, 0x7753, 0xBD94, 0x7ADA, 0xBB95, 0x7ADA, 0xB596, 0x7753, 0xB596, 0x2634};
const PROGMEM uint16_t syringe_outline[] = {0xB396, 0x110A, 0xB396, 0x1818, 0xB995, 0x1818, 0xB995, 0x22AD, 0xB396, 0x22AD, 0xB396, 0x7ADA, 0xB995, 0x7E61, 0xB995, 0x88F5, 0xBB95, 0x88F5, 0xBB95, 0xA8B4, 0xBD94, 0xAC3B, 0xBD94, 0x88F5, 0xBF94, 0x88F5, 0xBF94, 0x7E61, 0xC593, 0x7ADA, 0xC593, 0x22AD, 0xBF94, 0x22AD, 0xBF94, 0x1818, 0xC593, 0x1818, 0xC593, 0x110A, 0xB396, 0x110A};
const PROGMEM uint16_t padlock[] = {0x3FE3, 0x2A04, 0x3D34, 0x2AF9, 0x3AFF, 0x2D93, 0x397D, 0x316D, 0x38E8, 0x3626, 0x38E8, 0x3A14, 0x39B3, 0x3C8F, 0x3B50, 0x3C8F, 0x3C1C, 0x3A14, 0x3C1C, 0x363C, 0x3C6B, 0x33A9, 0x3D3A, 0x3193, 0x3E6C, 0x302D, 0x3FE3, 0x2FAA, 0x415A, 0x302D, 0x428C, 0x3192, 0x435B, 0x33A8, 0x43AB, 0x363C, 0x43AB, 0x4492, 0x38C3, 0x4492, 0x3741, 0x45AC, 0x36A1, 0x4856, 0x36A1, 0x5C41, 0x3741, 0x5EEC, 0x38C3, 0x6005, 0x4703, 0x6005, 0x4886, 0x5EEC, 0x4925, 0x5C41, 0x4925, 0x4856, 0x4886, 0x45AC, 0x4703, 0x4492, 0x46DE, 0x362B, 0x4649, 0x316D, 0x44C7, 0x2D92, 0x4292, 0x2AF9};
const PROGMEM uint16_t home_z[] = {0x80BB, 0x2B43, 0x712C, 0x46B9, 0x750F, 0x46B9, 0x750F, 0x622F, 0x7CD7, 0x622F, 0x7CD7, 0x5474, 0x849F, 0x5474, 0x849F, 0x622F, 0x8C67, 0x622F, 0x8C67, 0x46B9, 0x904B, 0x46B9, 0x8A48, 0x3C1D, 0x8A48, 0x2ECD, 0x8664, 0x2ECD, 0x8664, 0x3540};
const PROGMEM uint16_t usb_btn[] = {0x0558, 0xC0D6, 0x3BDB, 0xC0D6, 0x3BDB, 0xF431, 0x0558, 0xF431, 0x0558, 0xC0D6};
const PROGMEM uint16_t menu_btn[] = {0x416B, 0xC0D6, 0x77EE, 0xC0D6, 0x77EE, 0xF431, 0x416B, 0xF431, 0x416B, 0xC0D6};
const PROGMEM uint16_t e_pos[] = {0xE04E, 0x5E7B, 0xE94C, 0x5E7B, 0xE94C, 0x7E74, 0xEDCB, 0x7E74, 0xE4CD, 0x8E70, 0xDBCF, 0x7E74, 0xE04E, 0x7E74, 0xE04E, 0x5E7B};
const PROGMEM uint16_t e_neg[] = {0xE04E, 0x4E7F, 0xE94C, 0x4E7F, 0xE94C, 0x2E87, 0xEDCB, 0x2E87, 0xE4CD, 0x1E8A, 0xDBCF, 0x2E87, 0xE04E, 0x2E87, 0xE04E, 0x4E7F};
const PROGMEM uint16_t home_e[] = {0xD705, 0x3885, 0xC775, 0x53FB, 0xCB59, 0x53FB, 0xCB59, 0x6F71, 0xD321, 0x6F71, 0xD321, 0x61B6, 0xDAE9, 0x61B6, 0xDAE9, 0x6F71, 0xE2B1, 0x6F71, 0xE2B1, 0x53FB, 0xE695, 0x53FB, 0xE092, 0x495F, 0xE092, 0x3C0E, 0xDCAE, 0x3C0E, 0xDCAE, 0x4281};
const PROGMEM uint16_t fine_label[] = {0x0D92, 0x9444, 0x5211, 0x9444, 0x5211, 0xA9EA, 0x0D92, 0xA9EA};
const PROGMEM uint16_t fine_toggle[] = {0x56E7, 0x9444, 0x8007, 0x9444, 0x8007, 0xA9EA, 0x56E7, 0xA9EA};
const PROGMEM uint16_t h1_temp[] = {0x9C2B, 0xDD3B, 0xBBDE, 0xDD3B, 0xBBDE, 0xFA57, 0x9C2B, 0xFA57};
const PROGMEM uint16_t h1_label[] = {0x9C2B, 0xBE8F, 0xBBDC, 0xBE8F, 0xBBDC, 0xDBAA, 0x9C2B, 0xDBAA};
const PROGMEM uint16_t h0_temp[] = {0x7BD0, 0xDD3B, 0x9B83, 0xDD3B, 0x9B83, 0xFA57, 0x7BD0, 0xFA57};
const PROGMEM uint16_t h0_label[] = {0x7BD0, 0xBE8F, 0x9B83, 0xBE8F, 0x9B83, 0xDBAA, 0x7BD0, 0xDBAA};
const PROGMEM uint16_t h2_temp[] = {0xBC86, 0xDD3B, 0xDC39, 0xDD3B, 0xDC39, 0xFA57, 0xBC86, 0xFA57};
const PROGMEM uint16_t h2_label[] = {0xBC86, 0xBE8F, 0xDC37, 0xBE8F, 0xDC37, 0xDBAA, 0xBC86, 0xDBAA};
const PROGMEM uint16_t h3_temp[] = {0xDCE2, 0xDD0D, 0xFC95, 0xDD0D, 0xFC95, 0xFA28, 0xDCE2, 0xFA28};
const PROGMEM uint16_t h3_label[] = {0xDCE2, 0xBE60, 0xFC92, 0xBE60, 0xFC92, 0xDB7C, 0xDCE2, 0xDB7C};
const PROGMEM uint16_t actual_temp[] = {0xCDF6, 0xD037, 0xF7CA, 0xD037, 0xF7CA, 0xF424, 0xCDF6, 0xF424};
const PROGMEM uint16_t bed_icon[] = {0xCDF6, 0xA5CC, 0xF7CA, 0xA5CC, 0xF7CA, 0xC9B9, 0xCDF6, 0xC9B9};

View File

@ -0,0 +1,54 @@
/*****************
* ui_portrait.h *
*****************/
/****************************************************************************
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
/**
* This file was auto-generated using "svg2cpp.py"
*
* The encoding consists of x,y pairs with the min and max scaled to
* 0x0000 and 0xFFFE. A single 0xFFFF in the data stream indicates the
* start of a new closed path.
*/
#pragma once
constexpr float x_min = 0.000000;
constexpr float x_max = 272.000000;
constexpr float y_min = 0.000000;
constexpr float y_max = 480.000000;
const PROGMEM uint16_t z_neg[] = {0xC9B1, 0x96B3, 0xD990, 0x96B3, 0xD990, 0xA8D0, 0xE17F, 0xA8D0, 0xD1A0, 0xB1DF, 0xC1C2, 0xA8D0, 0xC9B1, 0xA8D0, 0xC9B1, 0x96B3};
const PROGMEM uint16_t z_pos[] = {0xC9B1, 0x8DA4, 0xD990, 0x8DA4, 0xD990, 0x7B86, 0xE17F, 0x7B86, 0xD1A0, 0x7277, 0xC1C2, 0x7B86, 0xC9B1, 0x7B86, 0xC9B1, 0x8DA4};
const PROGMEM uint16_t y_neg[] = {0x5037, 0x9979, 0x6264, 0x9979, 0x5529, 0xA92A, 0x5E3F, 0xA92A, 0x4575, 0xB103, 0x39E6, 0xA92A, 0x42FC, 0xA92A, 0x5037, 0x9979};
const PROGMEM uint16_t y_pos[] = {0x5D72, 0x89C7, 0x6F9F, 0x89C7, 0x7CDA, 0x7A15, 0x85F0, 0x7A15, 0x7A61, 0x723D, 0x6197, 0x7A15, 0x6AAD, 0x7A15, 0x5D72, 0x89C7};
const PROGMEM uint16_t x_neg[] = {0x513D, 0x8DB3, 0x4AA0, 0x958C, 0x2647, 0x958C, 0x22F8, 0x9979, 0x1769, 0x91A0, 0x3033, 0x89C7, 0x2CE4, 0x8DB3, 0x513D, 0x8DB3};
const PROGMEM uint16_t x_pos[] = {0x7566, 0x8DB3, 0x6EC9, 0x958C, 0x9322, 0x958C, 0x8FD4, 0x9979, 0xA89E, 0x91A0, 0x9D0E, 0x89C7, 0x99C0, 0x8DB3, 0x7566, 0x8DB3};
const PROGMEM uint16_t syringe_fluid[] = {0x7D1D, 0x4A0F, 0x87FC, 0x4C0E, 0x8CF4, 0x4C0E, 0x9801, 0x4A0F, 0x9801, 0x1AA2, 0x7D1D, 0x1AA2, 0x7D1D, 0x4A0F};
const PROGMEM uint16_t syringe[] = {0x83C2, 0x42AA, 0x83C2, 0x43FF, 0x8D2C, 0x43FF, 0x8D2C, 0x42AA, 0xFFFF, 0x83C2, 0x3D54, 0x83C2, 0x3EAA, 0x8D2C, 0x3EAA, 0x8D2C, 0x3D54, 0xFFFF, 0x83C2, 0x37FF, 0x83C2, 0x3954, 0x8D2C, 0x3954, 0x8D2C, 0x37FF, 0xFFFF, 0x83C2, 0x32AA, 0x83C2, 0x33FF, 0x8D2C, 0x33FF, 0x8D2C, 0x32AA, 0xFFFF, 0x83C2, 0x2D54, 0x83C2, 0x2EAA, 0x8D2C, 0x2EAA, 0x8D2C, 0x2D54, 0xFFFF, 0x83C2, 0x27FF, 0x83C2, 0x2955, 0x8D2C, 0x2955, 0x8D2C, 0x27FF, 0xFFFF, 0x83C2, 0x22AA, 0x83C2, 0x23FF, 0x8D2C, 0x23FF, 0x8D2C, 0x22AA, 0xFFFF, 0x7AC7, 0x0F4B, 0x7AC7, 0x134A, 0x855B, 0x134A, 0x855B, 0x1949, 0x7AC7, 0x1949, 0x7AC7, 0x4B40, 0x855B, 0x4D40, 0x855B, 0x533F, 0x88E2, 0x533F, 0x88E2, 0x653C, 0x8C69, 0x673C, 0x8C69, 0x533F, 0x8FF0, 0x533F, 0x8FF0, 0x4D40, 0x9A85, 0x4B40, 0x9A85, 0x1949, 0x8FF0, 0x1949, 0x8FF0, 0x134A, 0x9A85, 0x134A, 0x9A85, 0x0F4B, 0xFFFF, 0x88E2, 0x134A, 0x8C69, 0x134A, 0x8C69, 0x1949, 0x88E2, 0x1949, 0x88E2, 0x134A, 0xFFFF, 0x7E4D, 0x1B49, 0x96FE, 0x1B49, 0x96FE, 0x4941, 0x8C69, 0x4B40, 0x88E2, 0x4B40, 0x7E4D, 0x4941, 0x7E4D, 0x1B49};
const PROGMEM uint16_t syringe_outline[] = {0x7AC7, 0x0F4B, 0x7AC7, 0x134A, 0x855B, 0x134A, 0x855B, 0x1949, 0x7AC7, 0x1949, 0x7AC7, 0x4B40, 0x855B, 0x4D40, 0x855B, 0x533F, 0x88E2, 0x533F, 0x88E2, 0x653C, 0x8C69, 0x673C, 0x8C69, 0x533F, 0x8FF0, 0x533F, 0x8FF0, 0x4D40, 0x9A85, 0x4B40, 0x9A85, 0x1949, 0x8FF0, 0x1949, 0x8FF0, 0x134A, 0x9A85, 0x134A, 0x9A85, 0x0F4B, 0x7AC7, 0x0F4B};
const PROGMEM uint16_t padlock[] = {0x645A, 0x8017, 0x5F9E, 0x80A1, 0x5BBA, 0x821B, 0x5911, 0x844A, 0x580A, 0x86F7, 0x580A, 0x8931, 0x5970, 0x8A98, 0x5C49, 0x8A98, 0x5DB0, 0x8931, 0x5DB0, 0x8703, 0x5E3C, 0x858E, 0x5FAA, 0x845F, 0x61C5, 0x8394, 0x645A, 0x834A, 0x66F0, 0x8394, 0x690C, 0x845F, 0x6A7A, 0x858D, 0x6B07, 0x8703, 0x6B07, 0x8F23, 0x57C8, 0x8F23, 0x551E, 0x8FC3, 0x5404, 0x9145, 0x5404, 0x9C8F, 0x551E, 0x9E11, 0x57C8, 0x9EB1, 0x70EE, 0x9EB1, 0x7398, 0x9E11, 0x74B2, 0x9C8F, 0x74B2, 0x9145, 0x7398, 0x8FC3, 0x70EE, 0x8F23, 0x70AC, 0x86FA, 0x6FA5, 0x844A, 0x6CFD, 0x821B, 0x6917, 0x80A1};
const PROGMEM uint16_t home_z[] = {0xD6C9, 0x80CC, 0xBB53, 0x905B, 0xC231, 0x905B, 0xC231, 0x9FEB, 0xCFEC, 0x9FEB, 0xCFEC, 0x9823, 0xDDA7, 0x9823, 0xDDA7, 0x9FEB, 0xEB62, 0x9FEB, 0xEB62, 0x905B, 0xF240, 0x905B, 0xE7A3, 0x8A58, 0xE7A3, 0x82CD, 0xE0C6, 0x82CD, 0xE0C6, 0x8674};
const PROGMEM uint16_t home_e[] = {0xB94F, 0x25AA, 0x9DD8, 0x353A, 0xA4B6, 0x353A, 0xA4B6, 0x44C9, 0xB271, 0x44C9, 0xB271, 0x3D02, 0xC02C, 0x3D02, 0xC02C, 0x44C9, 0xCDE7, 0x44C9, 0xCDE7, 0x353A, 0xD4C5, 0x353A, 0xCA28, 0x2F36, 0xCA28, 0x27AB, 0xC34B, 0x27AB, 0xC34B, 0x2B53};
const PROGMEM uint16_t bed_icon[] = {0x1764, 0x2C4C, 0x6135, 0x2C4C, 0x6135, 0x40A8, 0x1764, 0x40A8};
const PROGMEM uint16_t actual_temp[] = {0x1764, 0x466F, 0x6135, 0x466F, 0x6135, 0x5ACB, 0x1764, 0x5ACB};
const PROGMEM uint16_t target_temp[] = {0x1764, 0x1228, 0x6135, 0x1228, 0x6135, 0x2684, 0x1764, 0x2684};
const PROGMEM uint16_t fine_label[] = {0x1AA7, 0xC6D2, 0x9387, 0xC6D2, 0x9387, 0xD316, 0x1AA7, 0xD316};
const PROGMEM uint16_t fine_toggle[] = {0x9C10, 0xC6D2, 0xE4A3, 0xC6D2, 0xE4A3, 0xD316, 0x9C10, 0xD316};
const PROGMEM uint16_t usb_btn[] = {0x0B68, 0xE880, 0x7B1A, 0xE880, 0x7B1A, 0xF94B, 0x0B68, 0xF94B, 0x0B68, 0xE880};
const PROGMEM uint16_t menu_btn[] = {0x84E3, 0xE880, 0xF495, 0xE880, 0xF495, 0xF94B, 0x84E3, 0xF94B, 0x84E3, 0xE880};
const PROGMEM uint16_t e_pos[] = {0xC9B1, 0x3B2D, 0xD990, 0x3B2D, 0xD990, 0x4D4B, 0xE17F, 0x4D4B, 0xD1A0, 0x565A, 0xC1C2, 0x4D4B, 0xC9B1, 0x4D4B, 0xC9B1, 0x3B2D};
const PROGMEM uint16_t e_neg[] = {0xC9B1, 0x321E, 0xD990, 0x321E, 0xD990, 0x2000, 0xE17F, 0x2000, 0xD1A0, 0x16F1, 0xC1C2, 0x2000, 0xC9B1, 0x2000, 0xC9B1, 0x321E};

View File

@ -0,0 +1,95 @@
/*****************************************
* cocoa_press/advance_settings_menu.cpp *
*****************************************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#include "../config.h"
#include "../screens.h"
#ifdef COCOA_ADVANCED_SETTINGS_MENU
using namespace FTDI;
using namespace ExtUI;
using namespace Theme;
#define GRID_COLS 3
#define GRID_ROWS 4
#define STEPS_PER_MM_POS BTN_POS(1,1), BTN_SIZE(1,1)
#define TMC_CURRENT_POS BTN_POS(2,1), BTN_SIZE(1,1)
#define LIN_ADVANCE_POS BTN_POS(3,1), BTN_SIZE(1,1)
#define VELOCITY_POS BTN_POS(1,2), BTN_SIZE(1,1)
#define ACCELERATION_POS BTN_POS(2,2), BTN_SIZE(1,1)
#define JERK_POS BTN_POS(3,2), BTN_SIZE(1,1)
#define DISPLAY_POS BTN_POS(1,3), BTN_SIZE(1,1)
#define INTERFACE_POS BTN_POS(2,3), BTN_SIZE(1,1)
#define ENDSTOPS_POS BTN_POS(3,3), BTN_SIZE(1,1)
#define RESTORE_DEFAULTS_POS BTN_POS(1,4), BTN_SIZE(2,1)
#define BACK_POS BTN_POS(3,4), BTN_SIZE(1,1)
void AdvancedSettingsMenu::onRedraw(draw_mode_t what) {
if (what & BACKGROUND) {
CommandProcessor cmd;
cmd.cmd(CLEAR_COLOR_RGB(Theme::bg_color))
.cmd(CLEAR(true,true,true));
}
if (what & FOREGROUND) {
CommandProcessor cmd;
cmd.colors(normal_btn)
.font(Theme::font_medium)
.tag(2) .button(STEPS_PER_MM_POS, GET_TEXT_F(MSG_STEPS_PER_MM))
.enabled(ENABLED(HAS_TRINAMIC_CONFIG))
.tag(3) .button(TMC_CURRENT_POS, GET_TEXT_F(MSG_TMC_CURRENT))
.enabled(ENABLED(LIN_ADVANCE))
.tag(4) .button(LIN_ADVANCE_POS, GET_TEXT_F(MSG_LINEAR_ADVANCE))
.tag(5) .button(VELOCITY_POS, GET_TEXT_F(MSG_MAX_SPEED))
.tag(6) .button(ACCELERATION_POS, GET_TEXT_F(MSG_ACCELERATION))
.tag(7) .button(JERK_POS, GET_TEXT_F(TERN(HAS_JUNCTION_DEVIATION, MSG_JUNCTION_DEVIATION, MSG_JERK)))
.tag(8) .button(ENDSTOPS_POS, GET_TEXT_F(MSG_LCD_ENDSTOPS))
.tag(9) .button(INTERFACE_POS, GET_TEXT_F(MSG_INTERFACE))
.tag(10).button(DISPLAY_POS, GET_TEXT_F(MSG_DISPLAY_MENU))
.tag(11).button(RESTORE_DEFAULTS_POS, GET_TEXT_F(MSG_RESTORE_DEFAULTS))
.colors(action_btn)
.tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE));
}
}
bool AdvancedSettingsMenu::onTouchEnd(uint8_t tag) {
switch (tag) {
case 1: SaveSettingsDialogBox::promptToSaveSettings(); break;
case 2: GOTO_SCREEN(StepsScreen); break;
#if HAS_TRINAMIC_CONFIG
case 3: GOTO_SCREEN(StepperCurrentScreen); break;
#endif
#if ENABLED(LIN_ADVANCE)
case 4: GOTO_SCREEN(LinearAdvanceScreen); break;
#endif
case 5: GOTO_SCREEN(MaxVelocityScreen); break;
case 6: GOTO_SCREEN(DefaultAccelerationScreen); break;
case 7: GOTO_SCREEN(TERN(HAS_JUNCTION_DEVIATION, JunctionDeviationScreen, JerkScreen)); break;
case 8: GOTO_SCREEN(EndstopStatesScreen); break;
case 9: GOTO_SCREEN(InterfaceSettingsScreen); LockScreen::check_passcode(); break;
case 10: GOTO_SCREEN(DisplayTuningScreen); break;
case 11: GOTO_SCREEN(RestoreFailsafeDialogBox); LockScreen::check_passcode(); break;
default: return false;
}
return true;
}
#endif // COCOA_ADVANCED_SETTINGS_MENU

View File

@ -0,0 +1,32 @@
/***************************************
* cocoa_press/advance_settings_menu.h *
***************************************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#pragma once
#define COCOA_ADVANCED_SETTINGS_MENU
#define COCOA_ADVANCED_SETTINGS_MENU_CLASS AdvancedSettingsMenu
class AdvancedSettingsMenu : public BaseScreen, public CachedScreen<ADVANCED_SETTINGS_SCREEN_CACHE> {
public:
static void onRedraw(draw_mode_t);
static bool onTouchEnd(uint8_t tag);
};

View File

@ -0,0 +1,60 @@
/****************************************************************************
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
/**
* This file was auto-generated using "svg2cpp.py"
*
* The encoding consists of x,y pairs with the min and max scaled to
* 0x0000 and 0xFFFE. A single 0xFFFF in the data stream indicates the
* start of a new closed path.
*/
#pragma once
constexpr float x_min = 0.000000;
constexpr float x_max = 480.000000;
constexpr float y_min = 0.000000;
constexpr float y_max = 272.000000;
const PROGMEM uint16_t syringe_outline[] = {0xED96, 0x14F0, 0xE65D, 0x10E9, 0xDED2, 0x0F9C, 0xD74B, 0x110E, 0xD01B, 0x1543, 0xCE80, 0x1836, 0xCE0A, 0x1C3A, 0xCE0F, 0x27AD, 0xCF0A, 0x2BD3, 0xD127, 0x2E5B, 0xD2A1, 0x2FF0, 0xD2A2, 0x9FC9, 0xD407, 0xA97A, 0xD7B9, 0xB10C, 0xD7BF, 0xBB58, 0xD978, 0xC2BE, 0xDD55, 0xC6EB, 0xDD58, 0xD159, 0xDE3B, 0xD3A8, 0xDFCF, 0xD3AF, 0xE0B8, 0xD04C, 0xE0B8, 0xC6EB, 0xE4A7, 0xC299, 0xE652, 0xBAF6, 0xE652, 0xB10C, 0xEA2E, 0xA8EA, 0xEB6C, 0x9E86, 0xEB6C, 0x2F58, 0xEF3C, 0x2B4E, 0xF003, 0x2583, 0xEFFD, 0x1AC2, 0xED96, 0x14F0, 0xED96, 0x14F0};
const PROGMEM uint16_t syringe_fluid[] = {0xDE73, 0x2512, 0xDA0C, 0x261D, 0xD5B8, 0x29A0, 0xD4AE, 0x2D87, 0xD4AE, 0x9F60, 0xD585, 0xA63B, 0xDE44, 0xA9DE, 0xE32A, 0xA942, 0xE7E3, 0xA6A5, 0xE930, 0xA342, 0xE95D, 0x9C1D, 0xE95B, 0x31B8, 0xE955, 0x2B63, 0xE867, 0x2A67, 0xE790, 0x28DE, 0xE342, 0x25CB, 0xDE73, 0x2512};
const PROGMEM uint16_t syringe[] = {0xED91, 0x1502, 0xE658, 0x10FB, 0xDECE, 0x0FAE, 0xD746, 0x1120, 0xD016, 0x1555, 0xCE7B, 0x1848, 0xCE05, 0x1C4D, 0xCE0A, 0x27BF, 0xCF05, 0x2BE5, 0xD122, 0x2E6E, 0xD29C, 0x3002, 0xD29D, 0x9FDB, 0xD402, 0xA98C, 0xD7B4, 0xB11F, 0xD7BA, 0xBB6A, 0xD973, 0xC2D1, 0xDD50, 0xC6FD, 0xDD53, 0xD16C, 0xDE36, 0xD3BA, 0xDFCA, 0xD3C2, 0xE0B3, 0xD05E, 0xE0B3, 0xC6FD, 0xE4A2, 0xC2AB, 0xE64D, 0xBB09, 0xE64D, 0xB11F, 0xEA29, 0xA8FC, 0xEB67, 0x9E98, 0xEB67, 0x2F6B, 0xEF37, 0x2B60, 0xEFFE, 0x2595, 0xEFF8, 0x1AD5, 0xED91, 0x1502, 0xED91, 0x1502, 0xFFFF, 0xD1CF, 0x1A7E, 0xD84F, 0x16DB, 0xDF19, 0x15A9, 0xE5E0, 0x16EA, 0xEC5B, 0x1AA4, 0xEC9D, 0x1D34, 0xEC9D, 0x20CC, 0xE5F1, 0x1D41, 0xDF02, 0x1C12, 0xD812, 0x1D41, 0xD166, 0x20CC, 0xD16C, 0x1B45, 0xD1CF, 0x1A7E, 0xFFFF, 0xE3BD, 0xACFD, 0xDE8E, 0xAF4F, 0xD988, 0xAC0F, 0xD7CC, 0xA8CD, 0xDD1C, 0xAAA9, 0xE287, 0xAA5B, 0xE655, 0xA8BE, 0xE3BD, 0xACFD, 0xFFFF, 0xE802, 0x2DC5, 0xE809, 0x343C, 0xE808, 0x9FC8, 0xE7E3, 0xA296, 0xE70D, 0xA4B1, 0xE2C9, 0xA70E, 0xDE4E, 0xA790, 0xD6A1, 0xA457, 0xD5FF, 0x9F2B, 0xD5FF, 0x2DFD, 0xD6B2, 0x2B72, 0xDA78, 0x2861, 0xDE9D, 0x276F, 0xE300, 0x2824, 0xE70D, 0x2B13, 0xE7FF, 0x2DB6, 0xE800, 0x2DC5, 0xE802, 0x2DC5, 0xFFFF, 0xE2ED, 0xBA8B, 0xE1CC, 0xBF52, 0xDF1C, 0xC165, 0xDC64, 0xBF99, 0xDB1B, 0xBAFF, 0xDB19, 0xB433, 0xDF04, 0xB552, 0xE2EF, 0xB438, 0xE2ED, 0xBA8B, 0xFFFF, 0xEC09, 0x2893, 0xE925, 0x2A08, 0xE57D, 0x261D, 0xE149, 0x246F, 0xDBDE, 0x24A0, 0xD6BC, 0x2795, 0xD484, 0x2A46, 0xD1C0, 0x2853, 0xD166, 0x251E, 0xD80D, 0x2151, 0xDF02, 0x200C, 0xE5F6, 0x2151, 0xEC9D, 0x251E, 0xEC09, 0x2893};
const PROGMEM uint16_t park_btn[] = {0x0AAA, 0x0E1E, 0x57FF, 0x0E1E, 0x57FF, 0x33C3, 0x0AAA, 0x33C3, 0x0AAA, 0x0E1E};
const PROGMEM uint16_t pause_btn[] = {0x47FF, 0xCA58, 0x7FFF, 0xCA58, 0x7FFF, 0xEFFE, 0x47FF, 0xEFFE, 0x47FF, 0xCA58};
const PROGMEM uint16_t load_chocolate_btn[] = {0x0AAA, 0x3D2C, 0x57FF, 0x3D2C, 0x57FF, 0x62D2, 0x0AAA, 0x62D2, 0x0AAA, 0x3D2C};
const PROGMEM uint16_t preheat_chocolate_btn[] = {0x0AAA, 0x6C3B, 0x57FF, 0x6C3B, 0x57FF, 0x91E0, 0x0AAA, 0x91E0, 0x0AAA, 0x6C3B};
const PROGMEM uint16_t menu_btn[] = {0x0AAA, 0x9B4A, 0x57FF, 0x9B4A, 0x57FF, 0xC0EF, 0x0AAA, 0xC0EF, 0x0AAA, 0x9B4A};
const PROGMEM uint16_t print_btn[] = {0x0AAA, 0xCA58, 0x42AA, 0xCA58, 0x42AA, 0xEFFE, 0x0AAA, 0xEFFE, 0x0AAA, 0xCA58};
const PROGMEM uint16_t stop_btn[] = {0x8554, 0xCA58, 0xBD53, 0xCA58, 0xBD53, 0xEFFE, 0x8554, 0xEFFE, 0x8554, 0xCA58};
const PROGMEM uint16_t print_time_hms[] = {0x62A9, 0xA968, 0x8FFE, 0xA968, 0x8FFE, 0xC0EF, 0x62A9, 0xC0EF, 0x62A9, 0xA968};
const PROGMEM uint16_t print_time_percent[] = {0x8FFE, 0xA968, 0xBD53, 0xA968, 0xBD53, 0xC0EF, 0x8FFE, 0xC0EF, 0x8FFE, 0xA968};
const PROGMEM uint16_t print_time_label[] = {0x62A9, 0x91E0, 0xBD53, 0x91E0, 0xBD53, 0xA986, 0x62A9, 0xA986, 0x62A9, 0x91E0};
const PROGMEM uint16_t h3_temp[] = {0x62A9, 0x75A4, 0x8FFE, 0x75A4, 0x8FFE, 0x8D2C, 0x62A9, 0x8D2C, 0x62A9, 0x75A4};
const PROGMEM uint16_t h3_label[] = {0x62A9, 0x5E1D, 0x8FFE, 0x5E1D, 0x8FFE, 0x75A4, 0x62A9, 0x75A4, 0x62A9, 0x5E1D};
const PROGMEM uint16_t chocolate_label[] = {0x62A9, 0x12D2, 0xBD53, 0x12D2, 0xBD53, 0x2A5A, 0x62A9, 0x2A5A, 0x62A9, 0x12D2};
const PROGMEM uint16_t h0_label[] = {0x62A9, 0x2A5A, 0x8FFE, 0x2A5A, 0x8FFE, 0x41E1, 0x62A9, 0x41E1, 0x62A9, 0x2A5A};
const PROGMEM uint16_t h0_temp[] = {0x62A9, 0x41E1, 0x8FFE, 0x41E1, 0x8FFE, 0x5968, 0x62A9, 0x5968, 0x62A9, 0x41E1};
const PROGMEM uint16_t h1_label[] = {0x8FFE, 0x2A5A, 0xBD53, 0x2A5A, 0xBD53, 0x41E1, 0x8FFE, 0x41E1, 0x8FFE, 0x2A5A};
const PROGMEM uint16_t h1_temp[] = {0x8FFE, 0x41E1, 0xBD53, 0x41E1, 0xBD53, 0x5968, 0x8FFE, 0x5968, 0x8FFE, 0x41E1};
const PROGMEM uint16_t h2_label[] = {0x8FFE, 0x5E1D, 0xBD53, 0x5E1D, 0xBD53, 0x75A4, 0x8FFE, 0x75A4, 0x8FFE, 0x5E1D};
const PROGMEM uint16_t h2_temp[] = {0x8FFE, 0x75A4, 0xBD53, 0x75A4, 0xBD53, 0x8D2C, 0x8FFE, 0x8D2C, 0x8FFE, 0x75A4};
const PROGMEM uint16_t extrude_btn[] = {0xC859, 0xDD2B, 0xF5AE, 0xDD2B, 0xF5AE, 0xEFFE, 0xC859, 0xEFFE, 0xC859, 0xDD2B};
const PROGMEM uint16_t load_screen_extrude[] = {0x25FB, 0x89AE, 0x2F58, 0x89AE, 0x2F58, 0xAAF6, 0x3406, 0xAAF6, 0x2AAA, 0xBB9A, 0x214D, 0xAAF6, 0x25FB, 0xAAF6, 0x25FB, 0x89AE};
const PROGMEM uint16_t load_screen_retract[] = {0x25FC, 0x790A, 0x2F58, 0x790A, 0x2F58, 0x57C2, 0x3406, 0x57C2, 0x2AAA, 0x471D, 0x214D, 0x57C2, 0x25FC, 0x57C2, 0x25FC, 0x790A};
const PROGMEM uint16_t load_screen_back_btn[] = {0x1555, 0xCA58, 0xC553, 0xCA58, 0xC553, 0xEFFE, 0x1555, 0xEFFE, 0x1555, 0xCA58};
const PROGMEM uint16_t load_screen_unload_btn[] = {0x4AAA, 0x8EBD, 0xC553, 0x8EBD, 0xC553, 0xB463, 0x4AAA, 0xB463, 0x4AAA, 0x8EBD};
const PROGMEM uint16_t load_screen_load_btn[] = {0x4AAA, 0x5322, 0xC553, 0x5322, 0xC553, 0x78C7, 0x4AAA, 0x78C7, 0x4AAA, 0x5322};
const PROGMEM uint16_t load_sreen_title[] = {0x4AAA, 0x1787, 0xC553, 0x1787, 0xC553, 0x3D2C, 0x4AAA, 0x3D2C, 0x4AAA, 0x1787};
const PROGMEM uint16_t load_screen_increment[] = {0x1555, 0x2E1D, 0x3FFF, 0x2E1D, 0x3FFF, 0x3D2C, 0x1555, 0x3D2C, 0x1555, 0x2E1D};

View File

@ -0,0 +1,91 @@
/*********************************
* cocoa_press/leveling_menu.cpp *
*********************************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#include "../config.h"
#include "../screens.h"
#if ENABLED(COCOA_LEVELING_MENU)
#if BOTH(HAS_BED_PROBE, BLTOUCH)
#include "../../../../feature/bltouch.h"
#endif
using namespace FTDI;
using namespace ExtUI;
using namespace Theme;
#define GRID_COLS 3
#define GRID_ROWS 5
#define BED_MESH_TITLE_POS BTN_POS(1,1), BTN_SIZE(3,1)
#define PROBE_BED_POS BTN_POS(1,2), BTN_SIZE(1,1)
#define SHOW_MESH_POS BTN_POS(2,2), BTN_SIZE(1,1)
#define EDIT_MESH_POS BTN_POS(3,2), BTN_SIZE(1,1)
#define BLTOUCH_TITLE_POS BTN_POS(1,3), BTN_SIZE(3,1)
#define BLTOUCH_RESET_POS BTN_POS(1,4), BTN_SIZE(1,1)
#define BLTOUCH_TEST_POS BTN_POS(2,4), BTN_SIZE(1,1)
#define BACK_POS BTN_POS(1,5), BTN_SIZE(3,1)
void LevelingMenu::onRedraw(draw_mode_t what) {
if (what & BACKGROUND) {
CommandProcessor cmd;
cmd.cmd(CLEAR_COLOR_RGB(Theme::bg_color))
.cmd(CLEAR(true,true,true))
.tag(0);
}
if (what & FOREGROUND) {
CommandProcessor cmd;
cmd.font(font_large)
.cmd(COLOR_RGB(bg_text_enabled))
.text(BED_MESH_TITLE_POS, GET_TEXT_F(MSG_BED_LEVELING))
.text(BLTOUCH_TITLE_POS, GET_TEXT_F(MSG_BLTOUCH))
.font(font_medium).colors(normal_btn)
.tag(2).button(PROBE_BED_POS, GET_TEXT_F(MSG_PROBE_BED))
.enabled(ENABLED(HAS_MESH))
.tag(3).button(SHOW_MESH_POS, GET_TEXT_F(MSG_MESH_VIEW))
.enabled(ENABLED(HAS_MESH))
.tag(4).button(EDIT_MESH_POS, GET_TEXT_F(MSG_EDIT_MESH))
#undef GRID_COLS
#define GRID_COLS 2
.tag(5).button(BLTOUCH_RESET_POS, GET_TEXT_F(MSG_BLTOUCH_RESET))
.tag(6).button(BLTOUCH_TEST_POS, GET_TEXT_F(MSG_BLTOUCH_SELFTEST))
#undef GRID_COLS
#define GRID_COLS 3
.colors(action_btn)
.tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE));
}
}
bool LevelingMenu::onTouchEnd(uint8_t tag) {
switch (tag) {
case 1: GOTO_PREVIOUS(); break;
case 2: BedMeshViewScreen::doProbe(); break;
case 3: BedMeshViewScreen::show(); break;
case 4: BedMeshEditScreen::show(); break;
case 5: injectCommands(F("M280 P0 S60")); break;
case 6: SpinnerDialogBox::enqueueAndWait(F("M280 P0 S90\nG4 P100\nM280 P0 S120")); break;
default: return false;
}
return true;
}
#endif // COCOA_LEVELING_MENU

View File

@ -0,0 +1,32 @@
/*******************************
* cocoa_press/leveling_menu.h *
******************************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#pragma once
#define COCOA_LEVELING_MENU
#define COCOA_LEVELING_MENU_CLASS LevelingMenu
class LevelingMenu : public BaseScreen, public CachedScreen<LEVELING_SCREEN_CACHE> {
public:
static void onRedraw(draw_mode_t);
static bool onTouchEnd(uint8_t tag);
};

View File

@ -0,0 +1,218 @@
/**********************************
* cocoa_press/load_chocolate.cpp *
**********************************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2020 - Cocoa Press *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#include "../config.h"
#include "../screens.h"
#include "../screen_data.h"
#ifdef COCOA_LOAD_CHOCOLATE_SCREEN
#include "cocoa_press_ui.h"
#define POLY(A) PolyUI::poly_reader_t(A, sizeof(A)/sizeof(A[0]))
const uint8_t shadow_depth = 5;
using namespace ExtUI;
using namespace FTDI;
using namespace Theme;
constexpr static LoadChocolateScreenData &mydata = screen_data.LoadChocolateScreen;
void LoadChocolateScreen::draw_syringe(draw_mode_t what) {
#if ENABLED(COCOA_PRESS_CHOCOLATE_LEVEL_SENSOR)
const float fill_level = get_chocolate_fill_level();
#else
constexpr float fill_level = 1.0f;
#endif
CommandProcessor cmd;
PolyUI ui(cmd, what);
if (what & BACKGROUND) {
// Paint the shadow for the syringe
ui.color(shadow_rgb);
ui.shadow(POLY(syringe_outline), shadow_depth);
}
if (what & FOREGROUND) {
int16_t x, y, h, v;
// Paint the syringe icon
ui.color(syringe_rgb);
ui.fill(POLY(syringe_outline));
ui.color(fluid_rgb);
ui.bounds(POLY(syringe_fluid), x, y, h, v);
cmd.cmd(SAVE_CONTEXT());
cmd.cmd(SCISSOR_XY(x,y + v * (1.0 - fill_level)));
cmd.cmd(SCISSOR_SIZE(h, v * fill_level));
ui.fill(POLY(syringe_fluid), false);
cmd.cmd(RESTORE_CONTEXT());
ui.color(stroke_rgb);
ui.fill(POLY(syringe));
}
}
void LoadChocolateScreen::draw_buttons(draw_mode_t what) {
int16_t x, y, h, v;
CommandProcessor cmd;
PolyUI ui(cmd, what);
cmd.font(font_medium).colors(normal_btn);
ui.bounds(POLY(load_screen_unload_btn), x, y, h, v);
cmd.tag(2).button(x, y, h, v, GET_TEXT_F(MSG_FULL_UNLOAD));
ui.bounds(POLY(load_screen_load_btn), x, y, h, v);
cmd.tag(3).button(x, y, h, v, GET_TEXT_F(MSG_FULL_LOAD));
ui.bounds(POLY(load_screen_back_btn), x, y, h, v);
cmd.tag(1).colors(action_btn).button(x, y, h, v, GET_TEXT_F(MSG_BUTTON_DONE));
}
void LoadChocolateScreen::draw_text(draw_mode_t what) {
if (what & BACKGROUND) {
int16_t x, y, h, v;
CommandProcessor cmd;
PolyUI ui(cmd, what);
cmd.font(font_medium).cmd(COLOR_RGB(bg_text_enabled));
ui.bounds(POLY(load_sreen_title), x, y, h, v);
cmd.tag(2).text(x, y, h, v, GET_TEXT_F(MSG_LOAD_UNLOAD));
ui.bounds(POLY(load_screen_increment), x, y, h, v);
cmd.tag(3).text(x, y, h, v, GET_TEXT_F(MSG_INCREMENT));
}
}
void LoadChocolateScreen::draw_arrows(draw_mode_t what) {
CommandProcessor cmd;
PolyUI ui(cmd, what);
ui.button_fill (fill_rgb);
ui.button_stroke(stroke_rgb, 28);
ui.button_shadow(shadow_rgb, shadow_depth);
constexpr uint8_t style = PolyUI::REGULAR;
ui.button(4, POLY(load_screen_extrude), style);
ui.button(5, POLY(load_screen_retract), style);
}
void LoadChocolateScreen::onEntry() {
mydata.repeat_tag = 0;
}
void LoadChocolateScreen::onRedraw(draw_mode_t what) {
if (what & BACKGROUND) {
CommandProcessor cmd;
cmd.cmd(CLEAR_COLOR_RGB(bg_color))
.cmd(CLEAR(true,true,true))
.tag(0);
}
draw_syringe(what);
draw_arrows(what);
draw_buttons(what);
draw_text(what);
}
bool LoadChocolateScreen::onTouchStart(uint8_t) {
mydata.repeat_tag = 0;
return true;
}
bool LoadChocolateScreen::onTouchEnd(uint8_t tag) {
using namespace ExtUI;
switch (tag) {
case 2:
mydata.repeat_tag = (mydata.repeat_tag == 2) ? 0 : 2;
break;
case 3:
mydata.repeat_tag = (mydata.repeat_tag == 3) ? 0 : 3;
break;
case 1: GOTO_PREVIOUS(); break;
}
return true;
}
void LoadChocolateScreen::setManualFeedrateAndIncrement(float feedrate_mm_s, float &increment_mm) {
// Compute increment so feedrate so that the tool lags the adjuster when it is
// being held down, this allows enough margin for the planner to
// connect segments and even out the motion.
ExtUI::setFeedrate_mm_s(feedrate_mm_s);
increment_mm = feedrate_mm_s / ((TOUCH_REPEATS_PER_SECOND) * 0.80f);
}
bool LoadChocolateScreen::onTouchHeld(uint8_t tag) {
if (ExtUI::isMoving()) return false; // Don't allow moves to accumulate
float increment;
setManualFeedrateAndIncrement(20, increment);
#define UI_INCREMENT_AXIS(axis) UI_INCREMENT(AxisPosition_mm, axis);
#define UI_DECREMENT_AXIS(axis) UI_DECREMENT(AxisPosition_mm, axis);
switch (tag) {
case 2: {
if (get_chocolate_fill_level() < 0.1) {
mydata.repeat_tag = 0;
return false;
}
UI_INCREMENT_AXIS(E0);
break;
}
case 3: {
if (get_chocolate_fill_level() > 0.75) {
mydata.repeat_tag = 0;
return false;
}
UI_DECREMENT_AXIS(E0);
break;
}
case 4:
UI_INCREMENT_AXIS(E0);
break;
case 5:
UI_DECREMENT_AXIS(E0);
break;
default: return false;
}
#undef UI_DECREMENT_AXIS
#undef UI_INCREMENT_AXIS
return false;
}
void LoadChocolateScreen::onIdle() {
reset_menu_timeout();
if (mydata.repeat_tag) onTouchHeld(mydata.repeat_tag);
if (refresh_timer.elapsed(STATUS_UPDATE_INTERVAL)) {
if (!EventLoop::is_touch_held())
onRefresh();
refresh_timer.start();
}
BaseScreen::onIdle();
}
#endif // COCOA_LOAD_CHOCOLATE_SCREEN

View File

@ -0,0 +1,47 @@
/********************************
* cocoa_press/load_chocolate.h *
********************************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2020 - Cocoa Press *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#pragma once
#define COCOA_LOAD_CHOCOLATE_SCREEN
#define COCOA_LOAD_CHOCOLATE_SCREEN_CLASS LoadChocolateScreen
struct LoadChocolateScreenData {
uint8_t repeat_tag;
};
class LoadChocolateScreen : public BaseScreen, public CachedScreen<LOAD_CHOCOLATE_SCREEN_CACHE> {
private:
static void draw_syringe(draw_mode_t what);
static void draw_arrows(draw_mode_t what);
static void draw_buttons(draw_mode_t what);
static void draw_text(draw_mode_t what);
public:
static void setManualFeedrateAndIncrement(float feedrate_mm_s, float &increment);
static void onEntry();
static void onIdle();
static void onRedraw(draw_mode_t);
static bool onTouchStart(uint8_t tag);
static bool onTouchEnd(uint8_t tag);
static bool onTouchHeld(uint8_t tag);
};

View File

@ -0,0 +1,100 @@
/*****************************
* cocoa_press/main_menu.cpp *
*****************************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2019 - Cocoa Press *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#include "../config.h"
#include "../screens.h"
#ifdef COCOA_MAIN_MENU
using namespace FTDI;
using namespace Theme;
#define GRID_COLS 2
#define GRID_ROWS 6
#define ZPROBE_ZOFFSET_POS BTN_POS(1,1), BTN_SIZE(1,1)
#define MOVE_XYZ_POS BTN_POS(1,2), BTN_SIZE(1,1)
#define TEMPERATURE_POS BTN_POS(2,1), BTN_SIZE(1,1)
#define MOVE_E_POS BTN_POS(2,2), BTN_SIZE(1,1)
#define SPEED_POS BTN_POS(1,3), BTN_SIZE(1,1)
#define FLOW_POS BTN_POS(2,3), BTN_SIZE(1,1)
#define ADVANCED_SETTINGS_POS BTN_POS(1,4), BTN_SIZE(1,1)
#define DISABLE_STEPPERS_POS BTN_POS(2,4), BTN_SIZE(1,1)
#define LEVELING_POS BTN_POS(1,5), BTN_SIZE(1,1)
#define ABOUT_PRINTER_POS BTN_POS(2,5), BTN_SIZE(1,1)
#define BACK_POS BTN_POS(1,6), BTN_SIZE(2,1)
void MainMenu::onRedraw(draw_mode_t what) {
if (what & BACKGROUND) {
CommandProcessor cmd;
cmd.cmd(CLEAR_COLOR_RGB(Theme::bg_color))
.cmd(CLEAR(true,true,true));
}
if (what & FOREGROUND) {
CommandProcessor cmd;
cmd.colors(normal_btn)
.font(Theme::font_medium)
.tag( 2).button(MOVE_XYZ_POS, GET_TEXT_F(MSG_XYZ_MOVE))
.tag( 3).button(TEMPERATURE_POS, GET_TEXT_F(MSG_TEMPERATURE))
.enabled(BOTH(HAS_LEVELING, HAS_BED_PROBE))
.tag( 4).button(ZPROBE_ZOFFSET_POS, GET_TEXT_F(MSG_ZPROBE_ZOFFSET))
.tag( 5).button(MOVE_E_POS, GET_TEXT_F(MSG_E_MOVE))
.tag( 6).button(SPEED_POS, GET_TEXT_F(MSG_PRINT_SPEED))
.tag( 7).button(FLOW_POS, GET_TEXT_F(MSG_FLOW))
.tag( 8).button(ADVANCED_SETTINGS_POS, GET_TEXT_F(MSG_ADVANCED_SETTINGS))
.tag( 9).button(DISABLE_STEPPERS_POS, GET_TEXT_F(MSG_DISABLE_STEPPERS))
.enabled(ENABLED(HAS_LEVELING))
.tag(10).button(LEVELING_POS, GET_TEXT_F(MSG_LEVELING))
.tag(11).button(ABOUT_PRINTER_POS, GET_TEXT_F(MSG_INFO_MENU))
.colors(action_btn)
.tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE));
}
}
bool MainMenu::onTouchEnd(uint8_t tag) {
using namespace ExtUI;
switch (tag) {
case 1: SaveSettingsDialogBox::promptToSaveSettings(); break;
case 2: GOTO_SCREEN(MoveXYZScreen); break;
case 3: GOTO_SCREEN(TemperatureScreen); break;
#if BOTH(HAS_LEVELING, HAS_BED_PROBE)
case 4: GOTO_SCREEN(ZOffsetScreen); break;
#endif
case 5: GOTO_SCREEN(MoveEScreen); break;
case 6: GOTO_SCREEN(FeedratePercentScreen); break;
case 7: GOTO_SCREEN(FlowPercentScreen); break;
case 8: GOTO_SCREEN(AdvancedSettingsMenu); break;
case 9: injectCommands(F("M84")); break;
#if HAS_LEVELING
case 10: GOTO_SCREEN(LevelingMenu); break;
#endif
case 11: GOTO_SCREEN(AboutScreen); break;
default:
return false;
}
return true;
}
#endif // COCOA_MAIN_MENU

View File

@ -0,0 +1,33 @@
/***************************
* cocoa_press/main_menu.h *
***************************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2019 - Cocoa Press *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#pragma once
#define COCOA_MAIN_MENU
#define COCOA_MAIN_MENU_CLASS MainMenu
class MainMenu : public BaseScreen, public CachedScreen<MENU_SCREEN_CACHE> {
public:
static void onRedraw(draw_mode_t);
static bool onTouchEnd(uint8_t tag);
};

View File

@ -0,0 +1,63 @@
/*********************************
* cocoa_press/move_e_screen.cpp *
*********************************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2019 - Cocoa Press *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#include "../config.h"
#include "../screens.h"
#include "../screen_data.h"
#ifdef COCOA_MOVE_E_SCREEN
using namespace FTDI;
using namespace ExtUI;
constexpr static MoveAxisScreenData &mydata = screen_data.MoveAxisScreen;
void MoveEScreen::onRedraw(draw_mode_t what) {
widgets_t w(what);
w.precision(1, DEFAULT_MIDRANGE);
w.units(GET_TEXT_F(MSG_UNITS_MM));
w.heading( GET_TEXT_F(MSG_E_MOVE));
w.color(Theme::e_axis);
#if EXTRUDERS == 1
w.adjuster( 8, GET_TEXT_F(MSG_AXIS_E), mydata.e_rel[0], canMove(E0));
#elif HAS_MULTI_EXTRUDER
w.adjuster( 8, GET_TEXT_F(MSG_AXIS_E1), mydata.e_rel[0], canMove(E0));
w.adjuster( 10, GET_TEXT_F(MSG_AXIS_E2), mydata.e_rel[1], canMove(E1));
#if EXTRUDERS > 2
w.adjuster( 12, GET_TEXT_F(MSG_AXIS_E3), mydata.e_rel[2], canMove(E2));
#endif
#if EXTRUDERS > 3
w.adjuster( 14, GET_TEXT_F(MSG_AXIS_E4), mydata.e_rel[3], canMove(E3));
#endif
#endif
w.increments();
}
void MoveEScreen::onIdle() {
if (refresh_timer.elapsed(STATUS_UPDATE_INTERVAL)) {
onRefresh();
refresh_timer.start();
}
BaseScreen::onIdle();
}
#endif // COCOA_MOVE_E_SCREEN

View File

@ -0,0 +1,33 @@
/*******************************
* cocoa_press/move_e_screen.h *
*******************************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2019 - Cocoa Press *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#pragma once
#define COCOA_MOVE_E_SCREEN
#define COCOA_MOVE_E_SCREEN_CLASS MoveEScreen
class MoveEScreen : public BaseMoveAxisScreen, public CachedScreen<MOVE_E_SCREEN_CACHE> {
public:
static void onRedraw(draw_mode_t);
static void onIdle();
};

View File

@ -0,0 +1,52 @@
/***********************************
* cocoa_press/move_xyz_screen.cpp *
***********************************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2019 - Cocoa Press *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#include "../config.h"
#include "../screens.h"
#include "../screen_data.h"
#ifdef COCOA_MOVE_XYZ_SCREEN
using namespace FTDI;
using namespace ExtUI;
void MoveXYZScreen::onRedraw(draw_mode_t what) {
widgets_t w(what);
w.precision(1);
w.units(GET_TEXT_F(MSG_UNITS_MM));
w.heading( GET_TEXT_F(MSG_XYZ_MOVE));
w.home_buttons(20);
w.color(Theme::x_axis).adjuster( 2, GET_TEXT_F(MSG_AXIS_X), getAxisPosition_mm(X), canMove(X));
w.color(Theme::y_axis).adjuster( 4, GET_TEXT_F(MSG_AXIS_Y), getAxisPosition_mm(Y), canMove(Y));
w.color(Theme::z_axis).adjuster( 6, GET_TEXT_F(MSG_AXIS_Z), getAxisPosition_mm(Z), canMove(Z));
w.increments();
}
void MoveXYZScreen::onIdle() {
if (refresh_timer.elapsed(STATUS_UPDATE_INTERVAL)) {
onRefresh();
refresh_timer.start();
}
BaseScreen::onIdle();
}
#endif // COCOA_MOVE_XYZ_SCREEN

View File

@ -0,0 +1,33 @@
/*********************************
* cocoa_press/move_xyz_screen.h *
*********************************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2019 - Cocoa Press *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#pragma once
#define COCOA_MOVE_XYZ_SCREEN
#define COCOA_MOVE_XYZ_SCREEN_CLASS MoveXYZScreen
class MoveXYZScreen : public BaseMoveAxisScreen, public CachedScreen<MOVE_XYZ_SCREEN_CACHE> {
public:
static void onRedraw(draw_mode_t);
static void onIdle();
};

View File

@ -0,0 +1,116 @@
/********************************
* cocoa_press/preheat_menu.cpp *
********************************/
/****************************************************************************
* Written By Marcio Teixeira 2020 - Cocoa Press *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#include "../config.h"
#include "../screens.h"
#ifdef COCOA_PREHEAT_MENU
using namespace FTDI;
using namespace ExtUI;
using namespace Theme;
#define GRID_COLS 2
#define GRID_ROWS 5
void PreheatMenu::onRedraw(draw_mode_t what) {
const int16_t w = TERN0(COCOA_PRESS_EXTRA_HEATER, has_extra_heater() ? BTN_W(1) : BTN_W(2));
const int16_t h = BTN_H(1);
if (what & BACKGROUND) {
CommandProcessor cmd;
cmd.cmd(CLEAR_COLOR_RGB(Theme::bg_color))
.cmd(CLEAR(true,true,true))
.tag(0)
.cmd(COLOR_RGB(bg_text_enabled))
.font(Theme::font_medium)
.text( BTN_POS(1,1), w, h, GET_TEXT_F(MSG_SELECT_CHOCOLATE_TYPE));
#if ENABLED(COCOA_PRESS_EXTRA_HEATER)
if (has_extra_heater()) {
cmd.text( BTN_POS(2,1), w, h, GET_TEXT_F(MSG_EXTERNAL));
}
#endif
}
if (what & FOREGROUND) {
CommandProcessor cmd;
cmd.font(Theme::font_medium)
.colors(normal_btn)
.tag(2).button(BTN_POS(1,2), w, h, F("Dark Chocolate"))
.tag(3).button(BTN_POS(1,3), w, h, F("Milk Chocolate"))
.tag(4).button(BTN_POS(1,4), w, h, F("White Chocolate"));
#if ENABLED(COCOA_PRESS_EXTRA_HEATER)
if (has_extra_heater()) {
cmd.tag(5).button(BTN_POS(2,2), w, h, F("Dark Chocolate"))
.tag(6).button(BTN_POS(2,3), w, h, F("Milk Chocolate"))
.tag(7).button(BTN_POS(2,4), w, h, F("White Chocolate"));
}
#endif
cmd.colors(action_btn)
.tag(1) .button(BTN_POS(1,5), BTN_SIZE(2,1), GET_TEXT_F(MSG_BUTTON_DONE));
}
}
bool PreheatMenu::onTouchEnd(uint8_t tag) {
switch (tag) {
case 1: GOTO_PREVIOUS(); break;
case 2:
#ifdef COCOA_PRESS_PREHEAT_DARK_CHOCOLATE_INT_SCRIPT
injectCommands(F(COCOA_PRESS_PREHEAT_DARK_CHOCOLATE_INT_SCRIPT));
#endif
GOTO_SCREEN(PreheatTimerScreen);
break;
case 3:
#ifdef COCOA_PRESS_PREHEAT_MILK_CHOCOLATE_INT_SCRIPT
injectCommands(F(COCOA_PRESS_PREHEAT_MILK_CHOCOLATE_INT_SCRIPT));
#endif
GOTO_SCREEN(PreheatTimerScreen);
break;
case 4:
#ifdef COCOA_PRESS_PREHEAT_WHITE_CHOCOLATE_INT_SCRIPT
injectCommands(F(COCOA_PRESS_PREHEAT_WHITE_CHOCOLATE_INT_SCRIPT));
#endif
GOTO_SCREEN(PreheatTimerScreen);
break;
case 5:
#ifdef COCOA_PRESS_PREHEAT_DARK_CHOCOLATE_EXT_SCRIPT
injectCommands(F(COCOA_PRESS_PREHEAT_DARK_CHOCOLATE_EXT_SCRIPT));
#endif
GOTO_SCREEN(PreheatTimerScreen);
break;
case 6:
#ifdef COCOA_PRESS_PREHEAT_MILK_CHOCOLATE_EXT_SCRIPT
injectCommands(F(COCOA_PRESS_PREHEAT_MILK_CHOCOLATE_EXT_SCRIPT));
#endif
GOTO_SCREEN(PreheatTimerScreen);
break;
case 7:
#ifdef COCOA_PRESS_PREHEAT_WHITE_CHOCOLATE_EXT_SCRIPT
injectCommands(F(COCOA_PRESS_PREHEAT_WHITE_CHOCOLATE_EXT_SCRIPT));
#endif
GOTO_SCREEN(PreheatTimerScreen);
break;
default: return false;
}
return true;
}
#endif // COCOA_PREHEAT_MENU

View File

@ -0,0 +1,31 @@
/******************************
* cocoa_press/preheat_menu.h *
******************************/
/****************************************************************************
* Written By Marcio Teixeira 2020 - Cocoa Press *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#pragma once
#define COCOA_PREHEAT_MENU
#define COCOA_PREHEAT_MENU_CLASS PreheatMenu
class PreheatMenu : public BaseScreen, public CachedScreen<PREHEAT_MENU_CACHE> {
public:
static void onRedraw(draw_mode_t);
static bool onTouchEnd(uint8_t tag);
};

View File

@ -0,0 +1,161 @@
/***************************************
* cocoapress/preheat_timer_screen.cpp *
***************************************/
/****************************************************************************
* Written By Marcio Teixeira 2019 - Cocoa Press *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#include "../config.h"
#include "../screens.h"
#include "../screen_data.h"
#ifdef COCOA_PREHEAT_SCREEN
using namespace FTDI;
using namespace ExtUI;
using namespace Theme;
constexpr static PreheatTimerScreenData &mydata = screen_data.PreheatTimerScreen;
#define GRID_COLS 2
#define GRID_ROWS 8
#define HEADER_POS BTN_POS(2,1), BTN_SIZE(1,2)
#define NOZZLE_ADJ_POS BTN_POS(2,3), BTN_SIZE(1,2)
#define BODY_ADJ_POS BTN_POS(2,5), BTN_SIZE(1,2)
#define CHAMBER_ADJ_POS BTN_POS(2,7), BTN_SIZE(1,2)
#define PROGRESS_POS BTN_POS(1,1), BTN_SIZE(1,7)
#define BACK_POS BTN_POS(1,8), BTN_SIZE(1,1)
void PreheatTimerScreen::draw_message(draw_mode_t what) {
if (what & BACKGROUND) {
CommandProcessor cmd;
cmd.cmd(CLEAR_COLOR_RGB(bg_color))
.cmd(CLEAR(true,true,true))
.cmd(COLOR_RGB(bg_text_enabled))
.tag(0);
draw_text_box(cmd, HEADER_POS, GET_TEXT_F(MSG_HEATING), OPT_CENTER, font_large);
}
}
uint16_t PreheatTimerScreen::secondsRemaining() {
const uint32_t elapsed_sec = (millis() - mydata.start_ms) / 1000;
return (COCOA_PRESS_PREHEAT_SECONDS > elapsed_sec) ? COCOA_PRESS_PREHEAT_SECONDS - elapsed_sec : 0;
}
void PreheatTimerScreen::draw_time_remaining(draw_mode_t what) {
if (what & FOREGROUND) {
const uint16_t elapsed_sec = secondsRemaining();
const uint8_t min = elapsed_sec / 60,
sec = elapsed_sec % 60;
char str[10];
sprintf_P(str, PSTR("%02d:%02d"), min, sec);
CommandProcessor cmd;
cmd.font(font_xlarge);
draw_circular_progress(cmd, PROGRESS_POS, float(secondsRemaining()) * 100 / COCOA_PRESS_PREHEAT_SECONDS, str, theme_dark, theme_darkest);
}
}
void PreheatTimerScreen::draw_interaction_buttons(draw_mode_t what) {
if (what & FOREGROUND) {
CommandProcessor cmd;
cmd.colors(normal_btn)
.font(font_medium)
.tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE));
}
}
void PreheatTimerScreen::draw_adjuster(draw_mode_t what, uint8_t tag, FSTR_P label, float value, int16_t x, int16_t y, int16_t w, int16_t h) {
#define SUB_COLS 9
#define SUB_ROWS 2
CommandProcessor cmd;
cmd.tag(0)
.font(font_small);
if (what & BACKGROUND) {
cmd.text( SUB_POS(1,1), SUB_SIZE(9,1), label)
.button(SUB_POS(1,2), SUB_SIZE(5,1), F(""), OPT_FLAT);
}
if (what & FOREGROUND) {
char str[32];
dtostrf(value, 5, 1, str);
strcat_P(str, PSTR(" "));
strcat_P(str, (const char*) GET_TEXT_F(MSG_UNITS_C));
cmd.text(SUB_POS(1,2), SUB_SIZE(5,1), str)
.font(font_medium)
.tag(tag ).button(SUB_POS(6,2), SUB_SIZE(2,1), F("-"))
.tag(tag+1).button(SUB_POS(8,2), SUB_SIZE(2,1), F("+"));
}
}
void PreheatTimerScreen::onEntry() {
mydata.start_ms = millis();
}
void PreheatTimerScreen::onRedraw(draw_mode_t what) {
draw_message(what);
draw_time_remaining(what);
draw_interaction_buttons(what);
draw_adjuster(what, 2, GET_TEXT_F(MSG_NOZZLE), getTargetTemp_celsius(E0), NOZZLE_ADJ_POS);
draw_adjuster(what, 4, GET_TEXT_F(MSG_BODY), getTargetTemp_celsius(E1), BODY_ADJ_POS);
draw_adjuster(what, 6, GET_TEXT_F(MSG_CHAMBER), getTargetTemp_celsius(CHAMBER), CHAMBER_ADJ_POS);
}
bool PreheatTimerScreen::onTouchHeld(uint8_t tag) {
const float increment = (tag == 6 || tag == 7) ? 1 : 0.1;
switch (tag) {
case 2: UI_DECREMENT(TargetTemp_celsius, E0); break;
case 3: UI_INCREMENT(TargetTemp_celsius, E0); break;
case 4: UI_DECREMENT(TargetTemp_celsius, E1); break;
case 5: UI_INCREMENT(TargetTemp_celsius, E1); break;
case 6: UI_DECREMENT(TargetTemp_celsius, CHAMBER); break;
case 7: UI_INCREMENT(TargetTemp_celsius, CHAMBER); break;
default:
return false;
}
return true;
}
bool PreheatTimerScreen::onTouchEnd(uint8_t tag) {
switch (tag) {
case 1: GOTO_PREVIOUS(); return true;
default: return current_screen.onTouchHeld(tag);
}
return false;
}
void PreheatTimerScreen::onIdle() {
if (secondsRemaining() == 0) {
AlertDialogBox::show(GET_TEXT_F(MSG_PREHEAT_FINISHED));
// Remove SaveSettingsDialogBox from the stack
// so the alert box doesn't return to me.
current_screen.forget();
}
reset_menu_timeout();
if (refresh_timer.elapsed(STATUS_UPDATE_INTERVAL)) {
onRefresh();
refresh_timer.start();
}
BaseScreen::onIdle();
}
#endif // COCOA_PREHEAT_SCREEN

View File

@ -0,0 +1,46 @@
/*********************************
* cocoapress/preheat_screen.cpp *
*********************************/
/****************************************************************************
* Written By Marcio Teixeira 2019 - Cocoa Press *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#pragma once
#define COCOA_PREHEAT_SCREEN
#define COCOA_PREHEAT_SCREEN_CLASS PreheatTimerScreen
struct PreheatTimerScreenData {
uint32_t start_ms;
};
class PreheatTimerScreen : public BaseScreen, public CachedScreen<PREHEAT_TIMER_SCREEN_CACHE> {
private:
static uint16_t secondsRemaining();
static void draw_message(draw_mode_t);
static void draw_time_remaining(draw_mode_t);
static void draw_interaction_buttons(draw_mode_t);
static void draw_adjuster(draw_mode_t, uint8_t tag, FSTR_P label, float value, int16_t x, int16_t y, int16_t w, int16_t h);
public:
static void onRedraw(draw_mode_t);
static void onEntry();
static void onIdle();
static bool onTouchHeld(uint8_t tag);
static bool onTouchEnd(uint8_t tag);
};

Some files were not shown because too many files have changed in this diff Show More