From 0badef42d58d04eec4aad0a91033e45fcead5e73 Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Tue, 2 Feb 2021 17:31:51 -0300 Subject: [PATCH] Touch Calibration Screen auto-save option (#20971) --- Marlin/Configuration.h | 4 ++++ Marlin/src/lcd/tft_io/touch_calibration.cpp | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index d888e62aaf..d0c00d4ef5 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -2457,6 +2457,10 @@ //#define TOUCH_OFFSET_Y 257 //#define TOUCH_ORIENTATION TOUCH_LANDSCAPE + #if BOTH(TOUCH_SCREEN_CALIBRATION, EEPROM_SETTINGS) + #define TOUCH_CALIBRATION_AUTO_SAVE // Auto save successful calibration values to EEPROM + #endif + #if ENABLED(TFT_COLOR_UI) //#define SINGLE_TOUCH_NAVIGATION #endif diff --git a/Marlin/src/lcd/tft_io/touch_calibration.cpp b/Marlin/src/lcd/tft_io/touch_calibration.cpp index 3c24d42734..0f9d25caeb 100644 --- a/Marlin/src/lcd/tft_io/touch_calibration.cpp +++ b/Marlin/src/lcd/tft_io/touch_calibration.cpp @@ -28,6 +28,10 @@ #define DEBUG_OUT ENABLED(DEBUG_TOUCH_CALIBRATION) #include "../../core/debug_out.h" +#if ENABLED(TOUCH_CALIBRATION_AUTO_SAVE) + #include "../../module/settings.h" +#endif + TouchCalibration touch_calibration; touch_calibration_t TouchCalibration::calibration; @@ -78,6 +82,7 @@ void TouchCalibration::validate_calibration() { SERIAL_ECHOLNPAIR("TOUCH_OFFSET_X ", calibration.offset_x); SERIAL_ECHOLNPAIR("TOUCH_OFFSET_Y ", calibration.offset_y); SERIAL_ECHO_TERNARY(calibration.orientation == TOUCH_LANDSCAPE, "TOUCH_ORIENTATION ", "TOUCH_LANDSCAPE", "TOUCH_PORTRAIT", "\n"); + TERN_(TOUCH_CALIBRATION_AUTO_SAVE, settings.save()); } }