Merge pull request #409 from stklcode/feature/extui
make custom Anycubic touchscreen implementation an ExtUI module
This commit is contained in:
@@ -254,7 +254,7 @@
|
|||||||
|
|
||||||
// PATCH START: Knutwurst
|
// PATCH START: Knutwurst
|
||||||
#if ENABLED(ANYCUBIC_TOUCHSCREEN)
|
#if ENABLED(ANYCUBIC_TOUCHSCREEN)
|
||||||
#include "lcd/anycubic_touchscreen.h"
|
#include "lcd/extui/knutwurst/anycubic_touchscreen.h"
|
||||||
#endif
|
#endif
|
||||||
// PATCH END: Knutwurst
|
// PATCH END: Knutwurst
|
||||||
|
|
||||||
@@ -353,7 +353,7 @@ void startOrResumeJob() {
|
|||||||
TERN_(GCODE_REPEAT_MARKERS, repeat.reset());
|
TERN_(GCODE_REPEAT_MARKERS, repeat.reset());
|
||||||
TERN_(CANCEL_OBJECTS, cancelable.reset());
|
TERN_(CANCEL_OBJECTS, cancelable.reset());
|
||||||
TERN_(LCD_SHOW_E_TOTAL, e_move_accumulator = 0);
|
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();
|
ui.reset_remaining_time();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -890,10 +890,6 @@ void idle(bool no_stepper_sleep/*=false*/) {
|
|||||||
TERN_(MAX7219_DEBUG, max7219.idle_tasks());
|
TERN_(MAX7219_DEBUG, max7219.idle_tasks());
|
||||||
|
|
||||||
// PATCH START: Knutwurst
|
// PATCH START: Knutwurst
|
||||||
#ifdef ANYCUBIC_TOUCHSCREEN
|
|
||||||
AnycubicTouchscreen.CommandScan();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ENDSTOP_BEEP
|
#ifdef ENDSTOP_BEEP
|
||||||
EndstopBeep();
|
EndstopBeep();
|
||||||
#endif
|
#endif
|
||||||
@@ -1011,12 +1007,6 @@ void kill(FSTR_P const lcd_error/*=nullptr*/, FSTR_P const lcd_component/*=nullp
|
|||||||
// "Error:Printer halted. kill() called!"
|
// "Error:Printer halted. kill() called!"
|
||||||
SERIAL_ERROR_MSG(STR_ERR_KILLED);
|
SERIAL_ERROR_MSG(STR_ERR_KILLED);
|
||||||
|
|
||||||
// PATCH START: Knutwurst
|
|
||||||
#ifdef ANYCUBIC_TOUCHSCREEN
|
|
||||||
AnycubicTouchscreen.KillTFT();
|
|
||||||
#endif
|
|
||||||
// PATCH END: Knutwurst
|
|
||||||
|
|
||||||
#ifdef ACTION_ON_KILL
|
#ifdef ACTION_ON_KILL
|
||||||
hostui.kill();
|
hostui.kill();
|
||||||
#endif
|
#endif
|
||||||
@@ -1292,12 +1282,6 @@ void setup() {
|
|||||||
#endif
|
#endif
|
||||||
SERIAL_ECHOLNPGM("start");
|
SERIAL_ECHOLNPGM("start");
|
||||||
|
|
||||||
// PATCH START: Knutwurst
|
|
||||||
#ifdef ANYCUBIC_TOUCHSCREEN
|
|
||||||
AnycubicTouchscreen.Setup();
|
|
||||||
#endif
|
|
||||||
// PATCH END: Knutwurst
|
|
||||||
|
|
||||||
// Set up these pins early to prevent suicide
|
// Set up these pins early to prevent suicide
|
||||||
#if HAS_KILL
|
#if HAS_KILL
|
||||||
SETUP_LOG("KILL_PIN");
|
SETUP_LOG("KILL_PIN");
|
||||||
@@ -1796,13 +1780,6 @@ void loop() {
|
|||||||
|
|
||||||
endstops.event_handler();
|
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_(HAS_TFT_LVGL_UI, printer_state_polling());
|
||||||
|
|
||||||
TERN_(MARLIN_TEST_BUILD, runPeriodicTests());
|
TERN_(MARLIN_TEST_BUILD, runPeriodicTests());
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#if BOTH(ANYCUBIC_TFT_DEBUG, KNUTWURST_DGUS2_TFT)
|
#if BOTH(ANYCUBIC_TFT_DEBUG, KNUTWURST_DGUS2_TFT)
|
||||||
|
|
||||||
#include "../../lcd/anycubic_touchscreen.h"
|
#include "../../lcd/extui/knutwurst/anycubic_touchscreen.h"
|
||||||
#include "../gcode.h"
|
#include "../gcode.h"
|
||||||
|
|
||||||
void GcodeSuite::M9999() {
|
void GcodeSuite::M9999() {
|
||||||
@@ -38,4 +38,4 @@ void GcodeSuite::M9999() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// PATCH END: KNUTWURST
|
// PATCH END: KNUTWURST
|
||||||
|
@@ -806,11 +806,6 @@ G29_TYPE GcodeSuite::G29() {
|
|||||||
bedlevel.set_grid(abl.gridSpacing, abl.probe_position_lf);
|
bedlevel.set_grid(abl.gridSpacing, abl.probe_position_lf);
|
||||||
COPY(bedlevel.z_values, abl.z_values);
|
COPY(bedlevel.z_values, abl.z_values);
|
||||||
TERN_(IS_KINEMATIC, bedlevel.extrapolate_unprobed_bed_level());
|
TERN_(IS_KINEMATIC, bedlevel.extrapolate_unprobed_bed_level());
|
||||||
|
|
||||||
#if ENABLED(KNUTWURST_TFT_LEVELING)
|
|
||||||
LCD_SERIAL.print("J25\r\n"); // Autoleveling done!
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bedlevel.refresh_bed_level();
|
bedlevel.refresh_bed_level();
|
||||||
|
|
||||||
bedlevel.print_leveling_grid();
|
bedlevel.print_leveling_grid();
|
||||||
|
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
// PATCH START: Knutwurst
|
// PATCH START: Knutwurst
|
||||||
#if ENABLED(ANYCUBIC_TOUCHSCREEN)
|
#if ENABLED(ANYCUBIC_TOUCHSCREEN)
|
||||||
#include "../../lcd/anycubic_touchscreen.h"
|
#include "../../lcd/extui/knutwurst/anycubic_touchscreen.h"
|
||||||
#endif
|
#endif
|
||||||
// PATCH END: Knutwurst
|
// PATCH END: Knutwurst
|
||||||
|
|
||||||
|
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
// PATCH START: Knutwurst
|
// PATCH START: Knutwurst
|
||||||
#ifdef ANYCUBIC_TOUCHSCREEN
|
#ifdef ANYCUBIC_TOUCHSCREEN
|
||||||
#include "../../../lcd/anycubic_touchscreen.h"
|
#include "../../../lcd/extui/knutwurst/anycubic_touchscreen.h"
|
||||||
#include "../../../sd/cardreader.h"
|
#include "../../../sd/cardreader.h"
|
||||||
#endif
|
#endif
|
||||||
// PATCH END: Knutwurst
|
// PATCH END: Knutwurst
|
||||||
|
@@ -39,7 +39,7 @@
|
|||||||
#include "../../MarlinCore.h" // for startOrResumeJob, etc.
|
#include "../../MarlinCore.h" // for startOrResumeJob, etc.
|
||||||
|
|
||||||
#ifdef ANYCUBIC_TOUCHSCREEN
|
#ifdef ANYCUBIC_TOUCHSCREEN
|
||||||
#include "../../lcd/anycubic_touchscreen.h"
|
#include "../../lcd/extui/knutwurst/anycubic_touchscreen.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(PRINTJOB_TIMER_AUTOSTART)
|
#if ENABLED(PRINTJOB_TIMER_AUTOSTART)
|
||||||
|
@@ -471,7 +471,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Extensible UI serial touch screens. (See src/lcd/extui)
|
// 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 IS_EXTUI 1
|
||||||
#define EXTENSIBLE_UI
|
#define EXTENSIBLE_UI
|
||||||
#endif
|
#endif
|
||||||
|
@@ -24,21 +24,21 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "../gcode/queue.h"
|
#include "../../../gcode/queue.h"
|
||||||
#include "../gcode/parser.h"
|
#include "../../../gcode/parser.h"
|
||||||
#include "../feature/e_parser.h"
|
#include "../../../feature/e_parser.h"
|
||||||
#include "../feature/pause.h"
|
#include "../../../feature/pause.h"
|
||||||
#include "../feature/bedlevel/bedlevel.h"
|
#include "../../../feature/bedlevel/bedlevel.h"
|
||||||
#include "../libs/buzzer.h"
|
#include "../../../libs/buzzer.h"
|
||||||
#include "../libs/numtostr.h"
|
#include "../../../libs/numtostr.h"
|
||||||
#include "../module/planner.h"
|
#include "../../../module/planner.h"
|
||||||
#include "../module/printcounter.h"
|
#include "../../../module/printcounter.h"
|
||||||
#include "../module/temperature.h"
|
#include "../../../module/temperature.h"
|
||||||
#include "../module/motion.h"
|
#include "../../../module/motion.h"
|
||||||
#include "../module/probe.h"
|
#include "../../../module/probe.h"
|
||||||
#include "../module/settings.h"
|
#include "../../../module/settings.h"
|
||||||
#include "../module/stepper.h"
|
#include "../../../module/stepper.h"
|
||||||
#include "../sd/cardreader.h"
|
#include "../../../sd/cardreader.h"
|
||||||
|
|
||||||
#ifdef ANYCUBIC_TOUCHSCREEN
|
#ifdef ANYCUBIC_TOUCHSCREEN
|
||||||
#include "./anycubic_touchscreen.h"
|
#include "./anycubic_touchscreen.h"
|
||||||
@@ -1267,6 +1267,20 @@
|
|||||||
#endif
|
#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() {
|
void AnycubicTouchscreenClass::CheckHeaterError() {
|
||||||
if ((thermalManager.degHotend(0) < 5) || (thermalManager.degHotend(0) > 300)) {
|
if ((thermalManager.degHotend(0) < 5) || (thermalManager.degHotend(0) > 300)) {
|
||||||
if (HeaterCheckCount > 600000) {
|
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;
|
static boolean TFTcomment_mode = false;
|
||||||
|
|
||||||
@@ -2316,5 +2333,11 @@
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLED(KNUTWURST_TFT_LEVELING)
|
||||||
|
void AnycubicTouchscreenClass::LevelingDone() {
|
||||||
|
SENDLINE_DBG_PGM("J25", "TFT Serial Debug: Auto leveling done... J25");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
AnycubicTouchscreenClass AnycubicTouchscreen;
|
AnycubicTouchscreenClass AnycubicTouchscreen;
|
||||||
#endif // ifdef ANYCUBIC_TOUCHSCREEN
|
#endif // ifdef ANYCUBIC_TOUCHSCREEN
|
@@ -25,9 +25,8 @@
|
|||||||
// #include "../inc/MarlinConfig.h"
|
// #include "../inc/MarlinConfig.h"
|
||||||
// #include "../module/configuration_store.h"
|
// #include "../module/configuration_store.h"
|
||||||
|
|
||||||
#include "./src/inc/MarlinConfigPre.h"
|
#include "../../../inc/MarlinConfigPre.h"
|
||||||
#include "./src/feature/bedlevel/bedlevel.h"
|
#include "../../../module/probe.h"
|
||||||
#include "src/module/probe.h"
|
|
||||||
|
|
||||||
|
|
||||||
enum axis_t : uint8_t { X, Y, Z, X2, Y2, Z2, Z3, Z4 };
|
enum axis_t : uint8_t { X, Y, Z, X2, Y2, Z2, Z3, Z4 };
|
||||||
@@ -253,10 +252,16 @@ void BedHeatingDone();
|
|||||||
void HeatingDone();
|
void HeatingDone();
|
||||||
void HeatingStart();
|
void HeatingStart();
|
||||||
void FilamentRunout();
|
void FilamentRunout();
|
||||||
|
void UserConfirmRequired(const char *);
|
||||||
|
void SDCardStateChange(bool);
|
||||||
|
void SDCardError();
|
||||||
void KillTFT();
|
void KillTFT();
|
||||||
#if BOTH(ANYCUBIC_TFT_DEBUG, KNUTWURST_DGUS2_TFT)
|
#if BOTH(ANYCUBIC_TFT_DEBUG, KNUTWURST_DGUS2_TFT)
|
||||||
void Command(const char * const command);
|
void Command(const char * const command);
|
||||||
#endif
|
#endif
|
||||||
|
#if ENABLED(KNUTWURST_TFT_LEVELING)
|
||||||
|
void LevelingDone();
|
||||||
|
#endif
|
||||||
char TFTstate = ANYCUBIC_TFT_STATE_IDLE;
|
char TFTstate = ANYCUBIC_TFT_STATE_IDLE;
|
||||||
|
|
||||||
/**
|
/**
|
127
Marlin/src/lcd/extui/knutwurst/knutwurst_extui.cpp
Normal file
127
Marlin/src/lcd/extui/knutwurst/knutwurst_extui.cpp
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
/**
|
||||||
|
* 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/knutwurst/knutwurst_extui.cpp
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "../../../inc/MarlinConfigPre.h"
|
||||||
|
|
||||||
|
#if ENABLED(ANYCUBIC_TOUCHSCREEN)
|
||||||
|
|
||||||
|
#include "anycubic_touchscreen.h"
|
||||||
|
#include "../ui_api.h"
|
||||||
|
|
||||||
|
#include <Arduino.h> // 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() {
|
||||||
|
#if ENABLED(KNUTWURST_TFT_LEVELING)
|
||||||
|
AnycubicTouchscreen.LevelingDone();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
Reference in New Issue
Block a user