Tobias Frost
6 years ago
committed by
Scott Lahteine
113 changed files with 3444 additions and 1350 deletions
File diff suppressed because it is too large
@ -0,0 +1,236 @@ |
|||
/**
|
|||
* Marlin 3D Printer Firmware |
|||
* Copyright (C) 2019 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 <http://www.gnu.org/licenses/>.
|
|||
* |
|||
*/ |
|||
#pragma once |
|||
|
|||
/* DGUS implementation written by coldtobi in 2019 for Marlin */ |
|||
|
|||
#include "../../../../inc/MarlinConfigPre.h" |
|||
|
|||
#include "../../../../Marlin.h" |
|||
#include "DGUSVPVariable.h" |
|||
|
|||
enum DGUSLCD_Screens : uint8_t; |
|||
|
|||
#define DEBUG_OUT ENABLED(DEBUG_DGUSLCD) |
|||
#include "../../../../core/debug_out.h" |
|||
|
|||
typedef enum : uint8_t { |
|||
DGUS_IDLE, //< waiting for DGUS_HEADER1.
|
|||
DGUS_HEADER1_SEEN, //< DGUS_HEADER1 received
|
|||
DGUS_HEADER2_SEEN, //< DGUS_HEADER2 received
|
|||
DGUS_WAIT_TELEGRAM, //< LEN received, Waiting for to receive all bytes.
|
|||
} rx_datagram_state_t; |
|||
|
|||
// 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); |
|||
template<typename T> |
|||
static void WriteVariable(uint16_t adr, T value) { |
|||
WriteVariable(adr, static_cast<const void*>(&value), 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)
|
|||
|
|||
// 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 initiliazed it.
|
|||
// (both boils down that the display answered to our chatting)
|
|||
static inline 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); } |
|||
|
|||
class DGUSScreenVariableHandler { |
|||
public: |
|||
DGUSScreenVariableHandler() = default; |
|||
|
|||
static bool loop(); |
|||
|
|||
/// Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen
|
|||
/// The bools specifing whether the strings are in RAM or FLASH.
|
|||
static void sendinfoscreen(const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); |
|||
|
|||
static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); |
|||
|
|||
/// "M117" Message -- msg is a RAM ptr.
|
|||
static void setstatusmessage(const char* msg); |
|||
/// The same for messages from Flash
|
|||
static void setstatusmessagePGM(PGM_P const msg); |
|||
// Callback for VP "Display wants to change screen on idle printer"
|
|||
static void ScreenChangeHookIfIdle(DGUS_VP_Variable &var, void *val_ptr); |
|||
// Callback for VP "Screen has been changed"
|
|||
static void ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr); |
|||
// Callback for VP "All Heaters Off"
|
|||
static void HandleAllHeatersOff(DGUS_VP_Variable &var, void *val_ptr); |
|||
// Hook for "Change this temperature"
|
|||
static void HandleTemperatureChanged(DGUS_VP_Variable &var, void *val_ptr); |
|||
// Hook for "Change Flowrate"
|
|||
static void HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_ptr); |
|||
// Hook for manual 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); |
|||
|
|||
#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); |
|||
/// Send a single filename to the display.
|
|||
static void DGUSLCD_SD_SendFilename(DGUS_VP_Variable &var); |
|||
/// Marlin informed us that a new SD has been inserted.
|
|||
static void SDCardInserted(); |
|||
/// Marlin informed us that the SD Card has been removed().
|
|||
static void SDCardRemoved(); |
|||
/// Marlin informed us about a bad SD Card.
|
|||
static void SDCardError(); |
|||
#endif |
|||
|
|||
// OK Button the Confirm screen.
|
|||
static void ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr); |
|||
|
|||
// Update data after went to new screen (by display or by GotoScreen)
|
|||
// remember: store the last-displayed screen, so it can get returned to.
|
|||
// (e.g for pop up messages)
|
|||
static void UpdateNewScreen(DGUSLCD_Screens newscreen, bool popup=false); |
|||
|
|||
// Recall the remembered screen.
|
|||
static void PopToOldScreen(); |
|||
|
|||
// Make the display show the screen and update all VPs in it.
|
|||
static void GotoScreen(DGUSLCD_Screens screen, bool ispopup = false); |
|||
|
|||
static void UpdateScreenVPData(); |
|||
|
|||
// Helpers to convert and transfer data to the display.
|
|||
static void DGUSLCD_SendWordValueToDisplay(DGUS_VP_Variable &var); |
|||
static void DGUSLCD_SendStringToDisplay(DGUS_VP_Variable &var); |
|||
static void DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable &var); |
|||
static void DGUSLCD_SendPercentageToDisplay(DGUS_VP_Variable &var); |
|||
static void DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var); |
|||
|
|||
/// Send a value from 0..100 to a variable with a range from 0..255
|
|||
static void DGUSLCD_PercentageToUint8(DGUS_VP_Variable &var, void *val_ptr); |
|||
|
|||
template<typename T> |
|||
static void DGUSLCD_SetValueDirectly(DGUS_VP_Variable &var, void *val_ptr) { |
|||
if (!var.memadr) return; |
|||
union { unsigned char tmp[sizeof(T)]; T t; } x; |
|||
unsigned char *ptr = (unsigned char*)val_ptr; |
|||
for (uint8_t i = 0; i < sizeof(T); i++) 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); |
|||
union { long l; char lb[4]; } endian; |
|||
|
|||
char tmp[4]; |
|||
endian.l = f; |
|||
tmp[0] = endian.lb[3]; |
|||
tmp[1] = endian.lb[2]; |
|||
tmp[2] = endian.lb[1]; |
|||
tmp[3] = endian.lb[0]; |
|||
dgusdisplay.WriteVariable(var.VP, tmp, 4); |
|||
} |
|||
} |
|||
|
|||
/// Force an update of all VP on the current screen.
|
|||
static inline void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; } |
|||
/// Has all VPs sent to the screen
|
|||
static inline bool IsScreenComplete() { return ScreenComplete; } |
|||
|
|||
static inline DGUSLCD_Screens getCurrentScreen() { return current_screen; } |
|||
|
|||
static inline void SetupConfirmAction( void (*f)()) { confirm_action_cb = f; } |
|||
|
|||
private: |
|||
static DGUSLCD_Screens current_screen; ///< currently on screen
|
|||
static constexpr uint8_t NUM_PAST_SCREENS = 4; |
|||
static DGUSLCD_Screens past_screens[NUM_PAST_SCREENS]; ///< LIFO with past screens for the "back" button.
|
|||
|
|||
static uint8_t update_ptr; ///< Last sent entry in the VPList for the actual screen.
|
|||
static uint16_t skipVP; ///< When updating the screen data, skip this one, because the user is interacting with it.
|
|||
static bool ScreenComplete; ///< All VPs sent to screen?
|
|||
|
|||
static uint16_t ConfirmVP; ///< context for confirm screen (VP that will be emulated-sent on "OK").
|
|||
|
|||
#if ENABLED(SDSUPPORT) |
|||
static int16_t top_file; ///< file on top of file chooser
|
|||
static int16_t file_to_print; ///< touched file to be confirmed
|
|||
#endif |
|||
|
|||
static void (*confirm_action_cb)(); |
|||
}; |
|||
|
|||
extern DGUSScreenVariableHandler ScreenHandler; |
|||
|
|||
/// Find the flash address of a DGUS_VP_Variable for the VP.
|
|||
extern const DGUS_VP_Variable* DGUSLCD_FindVPVar(const uint16_t vp); |
|||
|
|||
/// Helper to populate a DGUS_VP_Variable for a given VP. Return false if not found.
|
|||
extern bool populate_VPVar(const uint16_t VP, DGUS_VP_Variable * const ramcopy); |
@ -0,0 +1,231 @@ |
|||
/**
|
|||
* Marlin 3D Printer Firmware |
|||
* Copyright (C) 2019 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 <http://www.gnu.org/licenses/>.
|
|||
* |
|||
*/ |
|||
|
|||
/* DGUS implementation written by coldtobi in 2019 for Marlin */ |
|||
|
|||
#include "../../../../inc/MarlinConfigPre.h" |
|||
|
|||
#if ENABLED(DGUS_LCD) |
|||
|
|||
#include "DGUSDisplayDefinition.h" |
|||
#include "DGUSDisplay.h" |
|||
|
|||
#include "../../../../module/temperature.h" |
|||
#include "../../../../module/motion.h" |
|||
|
|||
#include "../../../ultralcd.h" |
|||
|
|||
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 HOTENDS >= 1 |
|||
VP_T_E1_Is, VP_T_E1_Set, |
|||
#endif |
|||
#if HOTENDS >= 2 |
|||
VP_T_E2_I, VP_T_E2_S, |
|||
#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 HOTENDS >= 1 |
|||
VP_T_E1_Is, VP_T_E1_Set, |
|||
#endif |
|||
#if HOTENDS >= 2 |
|||
VP_T_E2_I, VP_T_E2_S, |
|||
#endif |
|||
#if HAS_HEATED_BED |
|||
VP_T_Bed_Is, VP_T_Bed_Set, |
|||
#endif |
|||
#if FAN_COUNT > 0 |
|||
VP_Fan_Percentage, |
|||
#endif |
|||
VP_XPos, VP_YPos, VP_ZPos, |
|||
VP_Fan_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 HOTENDS >= 1 |
|||
VP_Flowrate_E1, |
|||
#endif |
|||
#if HOTENDS >= 2 |
|||
VP_Flowrate_E2, |
|||
#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_Fan_Percentage, |
|||
0x0000 |
|||
}; |
|||
|
|||
const uint16_t VPList_SD_FlowRates[] PROGMEM = { |
|||
VP_Flowrate_E1, VP_Flowrate_E2, |
|||
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; |
|||
|
|||
// Helper to define a DGUS_VP_Variable for common use cases.
|
|||
#define VPHELPER(VPADR, VPADRVAR, RXFPTR, TXFPTR ) { .VP=VPADR, .memadr=VPADRVAR, .size=sizeof(VPADRVAR), \ |
|||
.set_by_display_handler = RXFPTR, .send_to_display_handler = TXFPTR } |
|||
|
|||
// Helper to define a DGUS_VP_Variable when the sizeo of the var cannot be determined automaticalyl (eg. a string)
|
|||
#define VPHELPER_STR(VPADR, VPADRVAR, STRLEN, RXFPTR, TXFPTR ) { .VP=VPADR, .memadr=VPADRVAR, .size=STRLEN, \ |
|||
.set_by_display_handler = RXFPTR, .send_to_display_handler = TXFPTR } |
|||
|
|||
const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { |
|||
// Helper to detect touch events
|
|||
VPHELPER(VP_SCREENCHANGE, nullptr, DGUSScreenVariableHandler::ScreenChangeHook, nullptr), |
|||
VPHELPER(VP_SCREENCHANGE_ASK, nullptr, DGUSScreenVariableHandler::ScreenChangeHookIfIdle, nullptr), |
|||
VPHELPER(VP_SCREENCHANGE_WHENSD, nullptr, DGUSScreenVariableHandler::ScreenChangeHookIfSD, nullptr), |
|||
VPHELPER(VP_CONFIRMED, nullptr, DGUSScreenVariableHandler::ScreenConfirmedOK, nullptr), |
|||
|
|||
VPHELPER(VP_TEMP_ALL_OFF, nullptr, &DGUSScreenVariableHandler::HandleAllHeatersOff, nullptr), |
|||
|
|||
VPHELPER(VP_MOVE_X, nullptr, &DGUSScreenVariableHandler::HandleManualMove, nullptr), |
|||
VPHELPER(VP_MOVE_Y, nullptr, &DGUSScreenVariableHandler::HandleManualMove, nullptr), |
|||
VPHELPER(VP_MOVE_Z, nullptr, &DGUSScreenVariableHandler::HandleManualMove, nullptr), |
|||
VPHELPER(VP_HOME_ALL, nullptr, &DGUSScreenVariableHandler::HandleManualMove, nullptr), |
|||
|
|||
{ .VP = VP_MARLIN_VERSION, .memadr = (void*)MarlinVersion, .size = VP_MARLIN_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler =&DGUSScreenVariableHandler::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 =&DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplay }, |
|||
|
|||
// Temperature Data
|
|||
#if HOTENDS >= 1 |
|||
VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[0].current, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<0>), |
|||
VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[0].target, DGUSScreenVariableHandler::HandleTemperatureChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay), |
|||
VPHELPER(VP_Flowrate_E1, nullptr, DGUSScreenVariableHandler::HandleFlowRateChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay), |
|||
VPHELPER(VP_EPos, &destination[3], nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<2>), |
|||
VPHELPER(VP_MOVE_E1, nullptr, &DGUSScreenVariableHandler::HandleManualExtrude, nullptr), |
|||
#endif |
|||
#if HOTENDS >= 2 |
|||
VPHELPER(VP_T_E2_I, &thermalManager.temp_hotend[1].current, nullptr, DGUSLCD_SendFloatAsLongValueToDisplay<0>), |
|||
VPHELPER(VP_T_E2_S, &thermalManager.temp_hotend[1].target, DGUSScreenVariableHandler::HandleTemperatureChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay), |
|||
VPHELPER(VP_Flowrate_E2, nullptr, DGUSScreenVariableHandler::HandleFlowRateChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay), |
|||
VPHELPER(VP_MOVE_E2, nullptr, &DGUSScreenVariableHandler::HandleManualExtrude, nullptr), |
|||
#endif |
|||
#if HOTENDS >= 3 |
|||
#error More than 2 Hotends currently not implemented on the Display UI design. |
|||
#endif |
|||
#if HAS_HEATED_BED |
|||
VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.current, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<0>), |
|||
VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, DGUSScreenVariableHandler::HandleTemperatureChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay), |
|||
#endif |
|||
|
|||
// Fan Data.
|
|||
#if FAN_COUNT > 0 |
|||
VPHELPER(VP_Fan_Percentage, &thermalManager.fan_speed[0], DGUSScreenVariableHandler::DGUSLCD_PercentageToUint8, &DGUSScreenVariableHandler::DGUSLCD_SendPercentageToDisplay), |
|||
#endif |
|||
|
|||
// Feedrate.
|
|||
VPHELPER(VP_Feedrate_Percentage, &feedrate_percentage, DGUSScreenVariableHandler::DGUSLCD_SetValueDirectly<int16_t>, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay ), |
|||
|
|||
// Position Data.
|
|||
VPHELPER(VP_XPos, ¤t_position[0], nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<2>), |
|||
VPHELPER(VP_YPos, ¤t_position[1], nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<2>), |
|||
VPHELPER(VP_ZPos, ¤t_position[2], nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<2>), |
|||
|
|||
// Print Progress.
|
|||
VPHELPER(VP_PrintProgress_Percentage, &MarlinUI::progress_bar_percent, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay ), |
|||
|
|||
// Print Time
|
|||
VPHELPER_STR(VP_PrintTime, nullptr, VP_PrintTime_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendPrintTimeToDisplay ), |
|||
|
|||
// SDCard File listing.
|
|||
#if ENABLED(SDSUPPORT) |
|||
VPHELPER(VP_SD_ScrollEvent, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ScrollFilelist, nullptr), |
|||
VPHELPER(VP_SD_FileSelected, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_FileSelected, nullptr), |
|||
VPHELPER(VP_SD_FileSelectConfirm, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_StartPrint, nullptr), |
|||
VPHELPER_STR(VP_SD_FileName0, nullptr, VP_SD_FileName_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_SendFilename ), |
|||
VPHELPER_STR(VP_SD_FileName1, nullptr, VP_SD_FileName_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_SendFilename ), |
|||
VPHELPER_STR(VP_SD_FileName2, nullptr, VP_SD_FileName_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_SendFilename ), |
|||
VPHELPER_STR(VP_SD_FileName3, nullptr, VP_SD_FileName_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_SendFilename ), |
|||
VPHELPER_STR(VP_SD_FileName4, nullptr, VP_SD_FileName_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_SendFilename ), |
|||
VPHELPER(VP_SD_ResumePauseAbort, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ResumePauseAbort, nullptr), |
|||
VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ReallyAbort, nullptr), |
|||
#endif |
|||
|
|||
// Messages for the User, shared by the popup and the kill screen. They cant be autouploaded as we do not buffer content.
|
|||
{ .VP = VP_MSGSTR1, .memadr = nullptr, .size = VP_MSGSTR1_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM }, |
|||
{ .VP = VP_MSGSTR2, .memadr = nullptr, .size = VP_MSGSTR2_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM }, |
|||
{ .VP = VP_MSGSTR3, .memadr = nullptr, .size = VP_MSGSTR3_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM }, |
|||
{ .VP = VP_MSGSTR4, .memadr = nullptr, .size = VP_MSGSTR4_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM }, |
|||
|
|||
VPHELPER(0, 0, 0, 0) // must be last entry.
|
|||
}; |
|||
|
|||
#endif // DGUS_LCD
|
@ -0,0 +1,192 @@ |
|||
/**
|
|||
* Marlin 3D Printer Firmware |
|||
* Copyright (C) 2019 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 <http://www.gnu.org/licenses/>.
|
|||
* |
|||
*/ |
|||
#pragma once |
|||
|
|||
/* DGUS implementation written by coldtobi in 2019 for Marlin */ |
|||
|
|||
#include "DGUSVPVariable.h" |
|||
|
|||
// This file defines the interaction between Marlin and the display firmware.
|
|||
|
|||
// information on which screen which VP is displayed
|
|||
// As this is a sparse table, two arrays are needed:
|
|||
// one to list the VPs of one screen and one to map screens to the lists.
|
|||
// (Strictly this would not be necessary, but allows to only send data the display needs and reducing load on Marlin)
|
|||
struct VPMapping { |
|||
const uint8_t screen; |
|||
const uint16_t *VPList; // The list is null-terminated.
|
|||
}; |
|||
|
|||
extern const struct VPMapping VPMap[]; |
|||
|
|||
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_CONFIRM = 240, |
|||
DGUSLCD_SCREEN_KILL = 250, ///< Kill Screen. Must always be 250 (to be able to display "Error wrong LCD Version")
|
|||
DGUSLCD_SCREEN_POPUP = 252, ///< special target, popup screen will also return this code to say "return to previous screen"
|
|||
DGUSLDC_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)
|
|||
|
|||
// 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_E1 = 0x2110; |
|||
constexpr uint16_t VP_MOVE_E2 = 0x2112; |
|||
//constexpr uint16_t VP_MOVE_E3 = 0x2114;
|
|||
//constexpr uint16_t VP_MOVE_E4 = 0x2116;
|
|||
//constexpr uint16_t VP_MOVE_E5 = 0x2118;
|
|||
//constexpr uint16_t VP_MOVE_E6 = 0x211A;
|
|||
constexpr uint16_t VP_HOME_ALL = 0x2120; |
|||
|
|||
// 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_E1_Is = 0x3060; // 4 Byte Integer
|
|||
constexpr uint16_t VP_T_E1_Set = 0x3062; // 2 Byte Integer
|
|||
constexpr uint16_t VP_T_E2_Is = 0x3064; // 4 Byte Integer
|
|||
|
|||
// reserved to support up to 6 Extruders:
|
|||
//constexpr uint16_t VP_T_E2_Set = 0x3066; // 2 Byte Integer
|
|||
//constexpr uint16_t VP_T_E3_Is = 0x3068; // 4 Byte Integer
|
|||
//constexpr uint16_t VP_T_E3_Set = 0x306A; // 2 Byte Integer
|
|||
//constexpr uint16_t VP_T_E4_Is = 0x306C; // 4 Byte Integer
|
|||
//constexpr uint16_t VP_T_E4_Set = 0x306E; // 2 Byte Integer
|
|||
//constexpr uint16_t VP_T_E5_Is = 0x3070; // 4 Byte Integer
|
|||
//constexpr uint16_t VP_T_E5_Set = 0x3072; // 2 Byte Integer
|
|||
//constexpr uint16_t VP_T_E5_Is = 0x3074; // 4 Byte Integer
|
|||
//constexpr uint16_t VP_T_E5_Set = 0x3076; // 2 Byte Integer
|
|||
//constexpr uint16_t VP_T_E6_Is = 0x3078; // 4 Byte Integer
|
|||
//constexpr uint16_t VP_T_E6_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_E1 = 0x3090; // 2 Byte Integer
|
|||
constexpr uint16_t VP_Flowrate_E2 = 0x3092; // 2 Byte Integer
|
|||
|
|||
// reserved for up to 6 Extruders:
|
|||
//constexpr uint16_t VP_Flowrate_E3 = 0x3094;
|
|||
//constexpr uint16_t VP_Flowrate_E4 = 0x3096;
|
|||
//constexpr uint16_t VP_Flowrate_E5 = 0x3098;
|
|||
//constexpr uint16_t VP_Flowrate_E6 = 0x309A;
|
|||
|
|||
constexpr uint16_t VP_Fan_Percentage = 0x3100; // 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; |
|||
|
|||
// 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; |
|||
|
|||
// 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_E1_Is = 0x5000; |
|||
constexpr uint16_t SP_T_E1_Set = 0x5010; |
|||
constexpr uint16_t SP_T_E2_Is = 0x5020; |
|||
constexpr uint16_t SP_T_Bed_Is = 0x5030; |
|||
constexpr uint16_t SP_T_Bed_Set = 0x5040; |
|||
|
|||
// List of VPs handled by Marlin / The Display.
|
|||
extern const struct DGUS_VP_Variable ListOfVP[]; |
@ -0,0 +1,47 @@ |
|||
/**
|
|||
* Marlin 3D Printer Firmware |
|||
* Copyright (C) 2019 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 <http://www.gnu.org/licenses/>.
|
|||
* |
|||
*/ |
|||
#pragma once |
|||
|
|||
/**
|
|||
* 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; |
|||
} |
|||
}; |
@ -0,0 +1,81 @@ |
|||
/**
|
|||
* Marlin 3D Printer Firmware |
|||
* Copyright (C) 2019 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 <http://www.gnu.org/licenses/>.
|
|||
* |
|||
*/ |
|||
|
|||
/**
|
|||
* extui_dgus_lcd.cpp |
|||
* |
|||
* DGUS implementation for Marlin by coldtobi, Feb-May 2019 |
|||
*/ |
|||
|
|||
#include "../inc/MarlinConfigPre.h" |
|||
|
|||
#if ENABLED(DGUS_LCD) |
|||
|
|||
#include "extensible_ui/ui_api.h" |
|||
#include "extensible_ui/lib/dgus/DGUSDisplay.h" |
|||
#include "extensible_ui/lib/dgus/DGUSDisplayDefinition.h" |
|||
|
|||
namespace ExtUI { |
|||
|
|||
void onStartup() { |
|||
dgusdisplay.InitDisplay(); |
|||
ScreenHandler.UpdateScreenVPData(); |
|||
} |
|||
|
|||
void onIdle() { ScreenHandler.loop(); } |
|||
|
|||
void onPrinterKilled(const char* msg) { |
|||
ScreenHandler.sendinfoscreen(PSTR(MSG_HALTED), msg, PSTR(""), PSTR(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() { ScreenHandler.SDCardInserted(); } |
|||
void onMediaError() { ScreenHandler.SDCardError(); } |
|||
void onMediaRemoved() { ScreenHandler.SDCardRemoved(); } |
|||
|
|||
void onPlayTone(const uint16_t frequency, const uint16_t duration) {} |
|||
void onPrintTimerStarted() {} |
|||
void onPrintTimerPaused() {} |
|||
void onPrintTimerStopped() {} |
|||
void onFilamentRunout() {} |
|||
|
|||
void onUserConfirmRequired(const char *msg) { |
|||
if (msg) { |
|||
ScreenHandler.sendinfoscreen(PSTR("Please confirm."), nullptr, msg, nullptr, true, true, false, true); |
|||
ScreenHandler.SetupConfirmAction(ExtUI::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 onFactoryReset() {} |
|||
void onLoadSettings() {} |
|||
void onStoreSettings() {} |
|||
} |
|||
|
|||
#endif // DGUS_LCD
|
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue