Skip to content

Commit

Permalink
Initial integration with DGUS EXTUI implementation #1
Browse files Browse the repository at this point in the history
I had to jump through some hoops because Marlin is
quit opinionated about the menu structure. We can't
make these just yet because then we will stall the project.

However, the general structure of the Marlin EXTUI
implementation is sound in my opinion, so we just
work around it for now so we can at least get the
spaghetti cleaned up what it is now.

This branch does currently build - but I would not run it yet.
  • Loading branch information
Sebazzz committed Sep 27, 2020
1 parent 6e4745b commit 0fc38a5
Show file tree
Hide file tree
Showing 15 changed files with 2,323 additions and 97 deletions.
151 changes: 151 additions & 0 deletions Marlin/src/lcd/extui/dgus_creality_lcd.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
/**
* 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_creality_lcd.cpp
*
* DGUS implementation written by coldtobi in 2019 for Marlin
*/

#include "../../inc/MarlinConfigPre.h"

#if ENABLED(DGUS_LCD_UI_CREALITY_TOUCH)

#include "ui_api.h"
#include "lib/dgus_creality/DGUSDisplay.h"
#include "lib/dgus_creality/DGUSDisplayDef.h"
#include "lib/dgus_creality/DGUSScreenHandler.h"

extern const char NUL_STR[];

namespace ExtUI {

void onStartup() {
dgusdisplay.InitDisplay();
ScreenHandler.UpdateScreenVPData();
}

void onIdle() { ScreenHandler.loop(); }

void onPrinterKilled(PGM_P const error, PGM_P const component) {
ScreenHandler.sendinfoscreen(GET_TEXT(MSG_HALTED), error, NUL_STR, GET_TEXT(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(PSTR("Please confirm."), msg, 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 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) <= ExtUI::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) <= ExtUI::eeprom_data_size);
// memcpy(&myDataStruct, buff, sizeof(myDataStruct));
}

void onConfigurationStoreWritten(bool success) {
// Called after the entire EEPROM has been written,
// whether successful or not.
}

void onConfigurationStoreRead(bool success) {
// Called after the entire EEPROM has been read,
// whether successful or not.
}

#if HAS_MESH
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) {
// Called when any mesh points are updated
}

void onMeshUpdate(const int8_t xpos, const int8_t ypos, const ExtUI::probe_state_t state) {
// Called to indicate a special condition
}
#endif

#if ENABLED(POWER_LOSS_RECOVERY)
void onPowerLossResume() {
// Called on resume from power-loss
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_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

}
#endif // HAS_DGUS_LCD
2 changes: 1 addition & 1 deletion Marlin/src/lcd/extui/dgus_lcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include "../../inc/MarlinConfigPre.h"

#if HAS_DGUS_LCD
#if HAS_DGUS_LCD && DISABLED(DGUS_LCD_UI_CREALITY_TOUCH)

#include "ui_api.h"
#include "lib/dgus/DGUSDisplay.h"
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include "../../../../inc/MarlinConfigPre.h"

#if HAS_DGUS_LCD
#if HAS_DGUS_LCD && DISABLED(DGUS_LCD_UI_CREALITY_TOUCH)

#if HOTENDS > 2
#error "More than 2 hotends not implemented on the Display UI design."
Expand Down
2 changes: 0 additions & 2 deletions Marlin/src/lcd/extui/lib/dgus/DGUSDisplayDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,4 @@ extern const struct DGUS_VP_Variable ListOfVP[];
#include "fysetc/DGUSDisplayDef.h"
#elif ENABLED(DGUS_LCD_UI_HIPRECY)
#include "hiprecy/DGUSDisplayDef.h"
#elif ENABLED(DGUS_LCD_UI_CREALITY_TOUCH)
#include "creality_touch/DGUSDisplayDef.h"
#endif
2 changes: 1 addition & 1 deletion Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "../../../../inc/MarlinConfigPre.h"

#if HAS_DGUS_LCD
#if HAS_DGUS_LCD && DISABLED(DGUS_LCD_UI_CREALITY_TOUCH)

#include "DGUSScreenHandler.h"
#include "DGUSDisplay.h"
Expand Down
65 changes: 0 additions & 65 deletions Marlin/src/lcd/extui/lib/dgus/creality_touch/DGUSDisplayDef.cpp

This file was deleted.

Loading

0 comments on commit 0fc38a5

Please sign in to comment.