diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 1bb1c8eb..34d8ff39 100755 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -254,7 +254,7 @@ // PATCH START: Knutwurst #if ENABLED(ANYCUBIC_TOUCHSCREEN) - #include "lcd/anycubic_touchscreen.h" + #include "lcd/extui/knutwurst/anycubic_touchscreen.h" #endif // PATCH END: Knutwurst @@ -353,7 +353,7 @@ void startOrResumeJob() { TERN_(GCODE_REPEAT_MARKERS, repeat.reset()); TERN_(CANCEL_OBJECTS, cancelable.reset()); TERN_(LCD_SHOW_E_TOTAL, e_move_accumulator = 0); - #if ENABLED(SET_REMAINING_TIME) + #if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME) ui.reset_remaining_time(); #endif } @@ -890,10 +890,6 @@ void idle(bool no_stepper_sleep/*=false*/) { TERN_(MAX7219_DEBUG, max7219.idle_tasks()); // PATCH START: Knutwurst - #ifdef ANYCUBIC_TOUCHSCREEN - AnycubicTouchscreen.CommandScan(); - #endif - #ifdef ENDSTOP_BEEP EndstopBeep(); #endif @@ -1011,12 +1007,6 @@ void kill(FSTR_P const lcd_error/*=nullptr*/, FSTR_P const lcd_component/*=nullp // "Error:Printer halted. kill() called!" SERIAL_ERROR_MSG(STR_ERR_KILLED); - // PATCH START: Knutwurst - #ifdef ANYCUBIC_TOUCHSCREEN - AnycubicTouchscreen.KillTFT(); - #endif - // PATCH END: Knutwurst - #ifdef ACTION_ON_KILL hostui.kill(); #endif @@ -1292,12 +1282,6 @@ void setup() { #endif SERIAL_ECHOLNPGM("start"); - // PATCH START: Knutwurst - #ifdef ANYCUBIC_TOUCHSCREEN - AnycubicTouchscreen.Setup(); - #endif - // PATCH END: Knutwurst - // Set up these pins early to prevent suicide #if HAS_KILL SETUP_LOG("KILL_PIN"); @@ -1796,13 +1780,6 @@ void loop() { endstops.event_handler(); - // PATCH START: Knutwurst - idle(); - #ifdef ANYCUBIC_TOUCHSCREEN - AnycubicTouchscreen.CommandScan(); - #endif - // PATCH END: Knutwurst - TERN_(HAS_TFT_LVGL_UI, printer_state_polling()); TERN_(MARLIN_TEST_BUILD, runPeriodicTests()); diff --git a/Marlin/src/gcode/anycubic_tft_debug/M9999.cpp b/Marlin/src/gcode/anycubic_tft_debug/M9999.cpp index 354c746f..7b3628f6 100644 --- a/Marlin/src/gcode/anycubic_tft_debug/M9999.cpp +++ b/Marlin/src/gcode/anycubic_tft_debug/M9999.cpp @@ -24,7 +24,7 @@ #if BOTH(ANYCUBIC_TFT_DEBUG, KNUTWURST_DGUS2_TFT) -#include "../../lcd/anycubic_touchscreen.h" +#include "../../lcd/extui/knutwurst/anycubic_touchscreen.h" #include "../gcode.h" void GcodeSuite::M9999() { @@ -38,4 +38,4 @@ void GcodeSuite::M9999() { } #endif -// PATCH END: KNUTWURST \ No newline at end of file +// PATCH END: KNUTWURST diff --git a/Marlin/src/gcode/control/M80_M81.cpp b/Marlin/src/gcode/control/M80_M81.cpp index a1658eb2..6bfe92a8 100755 --- a/Marlin/src/gcode/control/M80_M81.cpp +++ b/Marlin/src/gcode/control/M80_M81.cpp @@ -31,7 +31,7 @@ // PATCH START: Knutwurst #if ENABLED(ANYCUBIC_TOUCHSCREEN) - #include "../../lcd/anycubic_touchscreen.h" + #include "../../lcd/extui/knutwurst/anycubic_touchscreen.h" #endif // PATCH END: Knutwurst diff --git a/Marlin/src/gcode/feature/pause/M600.cpp b/Marlin/src/gcode/feature/pause/M600.cpp index fc8c8ab9..912be2fb 100755 --- a/Marlin/src/gcode/feature/pause/M600.cpp +++ b/Marlin/src/gcode/feature/pause/M600.cpp @@ -32,7 +32,7 @@ // PATCH START: Knutwurst #ifdef ANYCUBIC_TOUCHSCREEN - #include "../../../lcd/anycubic_touchscreen.h" + #include "../../../lcd/extui/knutwurst/anycubic_touchscreen.h" #include "../../../sd/cardreader.h" #endif // PATCH END: Knutwurst diff --git a/Marlin/src/gcode/temp/M104_M109.cpp b/Marlin/src/gcode/temp/M104_M109.cpp index 707f8c60..68bfefe0 100644 --- a/Marlin/src/gcode/temp/M104_M109.cpp +++ b/Marlin/src/gcode/temp/M104_M109.cpp @@ -39,7 +39,7 @@ #include "../../MarlinCore.h" // for startOrResumeJob, etc. #ifdef ANYCUBIC_TOUCHSCREEN - #include "../../lcd/anycubic_touchscreen.h" + #include "../../lcd/extui/knutwurst/anycubic_touchscreen.h" #endif #if ENABLED(PRINTJOB_TIMER_AUTOSTART) diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 545d5534..46b6ec65 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -471,7 +471,7 @@ #endif // Extensible UI serial touch screens. (See src/lcd/extui) -#if ANY(HAS_DGUS_LCD, MALYAN_LCD, TOUCH_UI_FTDI_EVE, ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, NEXTION_TFT) +#if ANY(HAS_DGUS_LCD, MALYAN_LCD, TOUCH_UI_FTDI_EVE, ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, ANYCUBIC_TOUCHSCREEN, NEXTION_TFT) // PATCH: knutwurst #define IS_EXTUI 1 #define EXTENSIBLE_UI #endif diff --git a/Marlin/src/lcd/anycubic_touchscreen.cpp b/Marlin/src/lcd/extui/knutwurst/anycubic_touchscreen.cpp similarity index 98% rename from Marlin/src/lcd/anycubic_touchscreen.cpp rename to Marlin/src/lcd/extui/knutwurst/anycubic_touchscreen.cpp index 60529165..08298ba5 100755 --- a/Marlin/src/lcd/anycubic_touchscreen.cpp +++ b/Marlin/src/lcd/extui/knutwurst/anycubic_touchscreen.cpp @@ -24,21 +24,21 @@ #include #include -#include "../gcode/queue.h" -#include "../gcode/parser.h" -#include "../feature/e_parser.h" -#include "../feature/pause.h" -#include "../feature/bedlevel/bedlevel.h" -#include "../libs/buzzer.h" -#include "../libs/numtostr.h" -#include "../module/planner.h" -#include "../module/printcounter.h" -#include "../module/temperature.h" -#include "../module/motion.h" -#include "../module/probe.h" -#include "../module/settings.h" -#include "../module/stepper.h" -#include "../sd/cardreader.h" +#include "../../../gcode/queue.h" +#include "../../../gcode/parser.h" +#include "../../../feature/e_parser.h" +#include "../../../feature/pause.h" +#include "../../../feature/bedlevel/bedlevel.h" +#include "../../../libs/buzzer.h" +#include "../../../libs/numtostr.h" +#include "../../../module/planner.h" +#include "../../../module/printcounter.h" +#include "../../../module/temperature.h" +#include "../../../module/motion.h" +#include "../../../module/probe.h" +#include "../../../module/settings.h" +#include "../../../module/stepper.h" +#include "../../../sd/cardreader.h" #ifdef ANYCUBIC_TOUCHSCREEN #include "./anycubic_touchscreen.h" @@ -1267,6 +1267,20 @@ #endif } + void AnycubicTouchscreenClass::SDCardStateChange(bool isInserted) { + #if ENABLED(ANYCUBIC_TFT_DEBUG) + SERIAL_ECHOLNPGM("TFT Serial Debug: SDCardStateChange event triggered...", isInserted); + #endif + CheckSDCardChange(); + } + + void AnycubicTouchscreenClass::SDCardError() { + #if ENABLED(ANYCUBIC_TFT_DEBUG) + SERIAL_ECHOLNPGM("TFT Serial Debug: SDCardError event triggered..."); + #endif + SENDLINE_DBG_PGM("J21", "TFT Serial Debug: SD Card Error ... J21"); + } + void AnycubicTouchscreenClass::CheckHeaterError() { if ((thermalManager.degHotend(0) < 5) || (thermalManager.degHotend(0) > 300)) { if (HeaterCheckCount > 600000) { @@ -1443,6 +1457,9 @@ } } + void AnycubicTouchscreenClass::UserConfirmRequired(const char * const msg) { + // TODO: implement to make advanced pause, filament change, etc. work again + } static boolean TFTcomment_mode = false; diff --git a/Marlin/src/lcd/anycubic_touchscreen.h b/Marlin/src/lcd/extui/knutwurst/anycubic_touchscreen.h similarity index 98% rename from Marlin/src/lcd/anycubic_touchscreen.h rename to Marlin/src/lcd/extui/knutwurst/anycubic_touchscreen.h index dc08110c..c0c9d29e 100755 --- a/Marlin/src/lcd/anycubic_touchscreen.h +++ b/Marlin/src/lcd/extui/knutwurst/anycubic_touchscreen.h @@ -25,9 +25,8 @@ // #include "../inc/MarlinConfig.h" // #include "../module/configuration_store.h" -#include "./src/inc/MarlinConfigPre.h" -#include "./src/feature/bedlevel/bedlevel.h" -#include "src/module/probe.h" +#include "../../../inc/MarlinConfigPre.h" +#include "../../../module/probe.h" enum axis_t : uint8_t { X, Y, Z, X2, Y2, Z2, Z3, Z4 }; @@ -253,6 +252,9 @@ void BedHeatingDone(); void HeatingDone(); void HeatingStart(); void FilamentRunout(); +void UserConfirmRequired(const char *); +void SDCardStateChange(bool); +void SDCardError(); void KillTFT(); #if BOTH(ANYCUBIC_TFT_DEBUG, KNUTWURST_DGUS2_TFT) void Command(const char * const command); diff --git a/Marlin/src/lcd/extui/knutwurst/knutwurst_extui.cpp b/Marlin/src/lcd/extui/knutwurst/knutwurst_extui.cpp new file mode 100644 index 00000000..a4bd2113 --- /dev/null +++ b/Marlin/src/lcd/extui/knutwurst/knutwurst_extui.cpp @@ -0,0 +1,122 @@ +/** + * 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 . + * + */ + +/** + * lcd/extui/knutwurst/knutwurst_extui.cpp + */ + +#include "../../../inc/MarlinConfigPre.h" + +#if ENABLED(ANYCUBIC_TOUCHSCREEN) + +#include "anycubic_touchscreen.h" +#include "../ui_api.h" + +#include // for the ::tone() call + +namespace ExtUI { + void onStartup() { AnycubicTouchscreen.Setup(); } + void onIdle() { AnycubicTouchscreen.CommandScan(); } + void onPrinterKilled(FSTR_P const error, FSTR_P const component) { AnycubicTouchscreen.KillTFT(); } + void onMediaInserted() { AnycubicTouchscreen.SDCardStateChange(true); } + void onMediaError() { AnycubicTouchscreen.SDCardError(); } + void onMediaRemoved() { AnycubicTouchscreen.SDCardStateChange(false); } + void onPlayTone(const uint16_t frequency, const uint16_t duration) { + TERN_(SPEAKER, ::tone(BEEPER_PIN, frequency, duration)); + } + void onPrintTimerStarted() { } + void onPrintTimerPaused() { } + void onPrintTimerStopped() { } + void onFilamentRunout(const extruder_t extruder) { AnycubicTouchscreen.FilamentRunout(); } + void onUserConfirmRequired(const char * const msg) { AnycubicTouchscreen.UserConfirmRequired(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_TOUCHSCREEN