Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "0" TFT Touch Calibration Settings #25579

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Marlin/src/HAL/STM32/tft/tft_spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Coun
TERN_(TFT_SHARED_IO, while (isBusy()));
}


void TFT_SPI::Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) {
DMAtx.Init.MemInc = MemoryIncrease;
HAL_DMA_Init(&DMAtx);
Expand Down
15 changes: 7 additions & 8 deletions Marlin/src/HAL/STM32F1/tft/tft_spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,25 +94,24 @@ uint32_t TFT_SPI::GetID() {
}

uint32_t TFT_SPI::ReadID(uint16_t Reg) {
#if !PIN_EXISTS(TFT_MISO)
return 0;
#else
uint8_t d = 0;
uint32_t data = 0;
uint32_t data = 0;

#if PIN_EXISTS(TFT_MISO)
SPIx.setClockDivider(SPI_CLOCK_DIV16);
DataTransferBegin(DATASIZE_8BIT);
WriteReg(Reg);

LOOP_L_N(i, 4) {
SPIx.read((uint8_t*)&d, 1);
uint8_t d;
SPIx.read(&d, 1);
data = (data << 8) | d;
}

DataTransferEnd();
SPIx.setClockDivider(SPI_CLOCK_MAX);

return data >> 7;
#endif

return data >> 7;
}

bool TFT_SPI::isBusy() {
Expand Down
41 changes: 14 additions & 27 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,24 +328,22 @@
#define IS_ULTIPANEL 1
#endif

// TFT Legacy Compatibility
// TFT Legacy options masquerade as TFT_GENERIC
#if ANY(FSMC_GRAPHICAL_TFT, SPI_GRAPHICAL_TFT, TFT_320x240, TFT_480x320, TFT_320x240_SPI, TFT_480x320_SPI, TFT_LVGL_UI_FSMC, TFT_LVGL_UI_SPI)
#define IS_LEGACY_TFT 1
#define TFT_GENERIC
#endif

#if ANY(FSMC_GRAPHICAL_TFT, TFT_320x240, TFT_480x320, TFT_LVGL_UI_FSMC)
#define TFT_INTERFACE_FSMC
#elif ANY(SPI_GRAPHICAL_TFT, TFT_320x240_SPI, TFT_480x320_SPI, TFT_LVGL_UI_SPI)
#define TFT_INTERFACE_SPI
#endif

#if EITHER(FSMC_GRAPHICAL_TFT, SPI_GRAPHICAL_TFT)
#define TFT_CLASSIC_UI
#elif ANY(TFT_320x240, TFT_480x320, TFT_320x240_SPI, TFT_480x320_SPI)
#define TFT_COLOR_UI
#elif EITHER(TFT_LVGL_UI_FSMC, TFT_LVGL_UI_SPI)
#define TFT_LVGL_UI
#if ANY(FSMC_GRAPHICAL_TFT, TFT_320x240, TFT_480x320, TFT_LVGL_UI_FSMC)
#define TFT_INTERFACE_FSMC
#elif ANY(SPI_GRAPHICAL_TFT, TFT_320x240_SPI, TFT_480x320_SPI, TFT_LVGL_UI_SPI)
#define TFT_INTERFACE_SPI
#endif
#if EITHER(FSMC_GRAPHICAL_TFT, SPI_GRAPHICAL_TFT)
#define TFT_CLASSIC_UI
#elif ANY(TFT_320x240, TFT_480x320, TFT_320x240_SPI, TFT_480x320_SPI)
#define TFT_COLOR_UI
#elif EITHER(TFT_LVGL_UI_FSMC, TFT_LVGL_UI_SPI)
#define TFT_LVGL_UI
#endif
#endif

// FSMC/SPI TFT Panels (LVGL)
Expand Down Expand Up @@ -1671,7 +1669,7 @@
#endif

#if ANY(HAS_SPI_TFT, HAS_FSMC_TFT, HAS_LTDC_TFT)
#include "../lcd/tft_io/tft_orientation.h"
#include "../lcd/tft_io/tft_orientation.h" // for TFT_COLOR_UI_PORTRAIT
#endif

#if ENABLED(TFT_RES_320x240)
Expand Down Expand Up @@ -1775,17 +1773,6 @@
#endif
#endif

// XPT2046_** Compatibility
#if !(defined(TOUCH_CALIBRATION_X) || defined(TOUCH_CALIBRATION_Y) || defined(TOUCH_OFFSET_X) || defined(TOUCH_OFFSET_Y) || defined(TOUCH_ORIENTATION))
#if defined(XPT2046_X_CALIBRATION) && defined(XPT2046_Y_CALIBRATION) && defined(XPT2046_X_OFFSET) && defined(XPT2046_Y_OFFSET)
#define TOUCH_CALIBRATION_X XPT2046_X_CALIBRATION
#define TOUCH_CALIBRATION_Y XPT2046_Y_CALIBRATION
#define TOUCH_OFFSET_X XPT2046_X_OFFSET
#define TOUCH_OFFSET_Y XPT2046_Y_OFFSET
#define TOUCH_ORIENTATION TOUCH_LANDSCAPE
#endif
#endif

#if X_HOME_DIR || (HAS_Y_AXIS && Y_HOME_DIR) || (HAS_Z_AXIS && Z_HOME_DIR) \
|| (HAS_I_AXIS && I_HOME_DIR) || (HAS_J_AXIS && J_HOME_DIR) || (HAS_K_AXIS && K_HOME_DIR) \
|| (HAS_U_AXIS && U_HOME_DIR) || (HAS_V_AXIS && V_HOME_DIR) || (HAS_W_AXIS && W_HOME_DIR)
Expand Down
21 changes: 20 additions & 1 deletion Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@
#define REINIT_NOISY_LCD 1 // Have the LCD re-init on SD insertion
#endif

#endif
#endif // HAS_MEDIA

/**
* Power Supply
Expand Down Expand Up @@ -3153,6 +3153,25 @@
#endif
#endif

// Touch Calibration
#if ANY(HAS_SPI_TFT, HAS_FSMC_TFT, HAS_LTDC_TFT)
#ifndef TOUCH_CALIBRATION_X
#define TOUCH_CALIBRATION_X 0
#endif
#ifndef TOUCH_CALIBRATION_Y
#define TOUCH_CALIBRATION_Y 0
#endif
#ifndef TOUCH_OFFSET_X
#define TOUCH_OFFSET_X 0
#endif
#ifndef TOUCH_OFFSET_Y
#define TOUCH_OFFSET_Y 0
#endif
#ifndef TOUCH_ORIENTATION
#define TOUCH_ORIENTATION TOUCH_LANDSCAPE
#endif
#endif

// Number of VFAT entries used. Each entry has 13 UTF-16 characters
#if ANY(SCROLL_LONG_FILENAMES, HAS_DWIN_E3V2, TFT_COLOR_UI)
#define VFAT_ENTRIES_LIMIT 5
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,4 +556,4 @@ U8G_PB_DEV(u8g_dev_tft_320x240_upscale_from_128x64, WIDTH, HEIGHT, PAGE_HEIGHT,

#endif // TOUCH_SCREEN_CALIBRATION

#endif // HAS_MARLINUI_U8GLIB && (FSMC_CS_PIN || HAS_SPI_GRAPHICAL_TFT)
#endif // HAS_MARLINUI_U8GLIB && (FSMC_CS_PIN || HAS_SPI_GRAPHICAL_TFT || HAS_LTDC_GRAPHICAL_TFT)
50 changes: 13 additions & 37 deletions Marlin/src/lcd/extui/mks_ui/draw_print_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ bool have_pre_pic(char *path) {
static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
uint8_t i, file_count = 0;
//switch (obj->mks_obj_id)
//{
if (obj->mks_obj_id == ID_P_UP) {
if (dir_offset[curDirLever].curPage > 0) {
// 2015.05.19
Expand All @@ -130,9 +128,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (dir_offset[curDirLever].cur_page_first_offset >= FILE_NUM)
list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_first_offset - FILE_NUM;

#if HAS_MEDIA
file_count = search_file();
#endif
TERN_(HAS_MEDIA, file_count = search_file());
if (file_count != 0) {
dir_offset[curDirLever].curPage--;
lv_clear_print_file();
Expand All @@ -144,9 +140,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (dir_offset[curDirLever].cur_page_last_offset > 0) {
list_file.Sd_file_cnt = 0;
list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_last_offset + 1;
#if HAS_MEDIA
file_count = search_file();
#endif
TERN_(HAS_MEDIA, file_count = search_file());
if (file_count != 0) {
dir_offset[curDirLever].curPage++;
lv_clear_print_file();
Expand All @@ -161,17 +155,13 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
int8_t *ch = (int8_t *)strrchr(list_file.curDirPath, '/');
if (ch) {
*ch = 0;
#if HAS_MEDIA
card.cdup();
#endif
TERN_(HAS_MEDIA, card.cdup());
dir_offset[curDirLever].curPage = 0;
dir_offset[curDirLever].cur_page_first_offset = 0;
dir_offset[curDirLever].cur_page_last_offset = 0;
curDirLever--;
list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_first_offset;
#if HAS_MEDIA
file_count = search_file();
#endif
TERN_(HAS_MEDIA, file_count = search_file());
lv_clear_print_file();
disp_gcode_icon(file_count);
}
Expand All @@ -189,9 +179,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
strcpy(list_file.curDirPath, list_file.file_name[i]);
curDirLever++;
list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_first_offset;
#if HAS_MEDIA
file_count = search_file();
#endif
TERN_(HAS_MEDIA, file_count = search_file());
lv_clear_print_file();
disp_gcode_icon(file_count);
}
Expand Down Expand Up @@ -396,8 +384,7 @@ int ascii2dec_test(char *ascii) {

void lv_gcode_file_read(uint8_t *data_buf) {
#if HAS_MEDIA
uint16_t i = 0, j = 0, k = 0;
uint16_t row_1 = 0;
uint16_t i = 0, j = 0, k = 0, row_1 = 0;
bool ignore_start = true;
char temp_test[200];
volatile uint16_t *p_index;
Expand Down Expand Up @@ -435,24 +422,13 @@ void lv_gcode_file_read(uint8_t *data_buf) {
break;
}
}
#if HAS_TFT_LVGL_UI_SPI
for (i = 0; i < 200;) {
p_index = (uint16_t *)(&public_buf[i]);

//Color = (*p_index >> 8);
//*p_index = Color | ((*p_index & 0xFF) << 8);
i += 2;
if (*p_index == 0x0000) *p_index = LV_COLOR_BACKGROUND.full;
}
#else // !HAS_TFT_LVGL_UI_SPI
for (i = 0; i < 200;) {
p_index = (uint16_t *)(&public_buf[i]);
//Color = (*p_index >> 8);
//*p_index = Color | ((*p_index & 0xFF) << 8);
i += 2;
if (*p_index == 0x0000) *p_index = LV_COLOR_BACKGROUND.full; // 0x18C3;
}
#endif // !HAS_TFT_LVGL_UI_SPI
for (i = 0; i < 200;) {
p_index = (uint16_t *)(&public_buf[i]);
//Color = (*p_index >> 8);
//*p_index = Color | ((*p_index & 0xFF) << 8);
i += 2;
if (*p_index == 0x0000) *p_index = LV_COLOR_BACKGROUND.full;
}
memcpy(data_buf, public_buf, 200);
#endif // HAS_MEDIA
}
Expand Down
32 changes: 16 additions & 16 deletions Marlin/src/lcd/extui/mks_ui/draw_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,16 @@
#define FILE_PRE_PIC_Y_OFFSET 0

#define PREVIEW_LITTLE_PIC_SIZE 40910 // 400*100+9*101+1
#define PREVIEW_SIZE 202720 // (PREVIEW_LITTLE_PIC_SIZE+800*200+201*9+1)
#define PREVIEW_SIZE 202720 // (PREVIEW_LITTLE_PIC_SIZE+800*200+201*9+1)

// machine parameter ui
#define PARA_UI_POS_X 10
#define PARA_UI_POS_Y 50
#define PARA_UI_POS_X 10
#define PARA_UI_POS_Y 50

#define PARA_UI_SIZE_X 450
#define PARA_UI_SIZE_Y 40
#define PARA_UI_SIZE_Y 40

#define PARA_UI_ARROW_V 12
#define PARA_UI_ARROW_V 12

#define PARA_UI_BACK_POS_X 400
#define PARA_UI_BACK_POS_Y 270
Expand All @@ -152,31 +152,31 @@

#define PARA_UI_VALUE_SIZE_X 370
#define PARA_UI_VALUE_POS_X 400
#define PARA_UI_VALUE_V 5
#define PARA_UI_VALUE_V 5

#define PARA_UI_STATE_POS_X 380
#define PARA_UI_STATE_V 2
#define PARA_UI_STATE_V 2

#define PARA_UI_VALUE_SIZE_X_2 200
#define PARA_UI_VALUE_POS_X_2 320
#define PARA_UI_VALUE_V_2 5
#define PARA_UI_VALUE_V_2 5

#define PARA_UI_VALUE_BTN_X_SIZE 70
#define PARA_UI_VALUE_BTN_Y_SIZE 28
#define PARA_UI_VALUE_BTN_X_SIZE 70
#define PARA_UI_VALUE_BTN_Y_SIZE 28

#define PARA_UI_BACK_BTN_X_SIZE 70
#define PARA_UI_BACK_BTN_Y_SIZE 40
#define PARA_UI_BACK_BTN_X_SIZE 70
#define PARA_UI_BACK_BTN_Y_SIZE 40

#define QRCODE_X 20
#define QRCODE_Y 40
#define QRCODE_X 20
#define QRCODE_Y 40
#define QRCODE_WIDTH 160

#else // ifdef TFT35
#else // !TFT35

#define TFT_WIDTH 320
#define TFT_HEIGHT 240

#endif // ifdef TFT35
#endif

#ifdef __cplusplus
extern "C" {
Expand Down
3 changes: 2 additions & 1 deletion Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@
#include <lvgl.h>

#include "../../../MarlinCore.h"
#include "../../marlinui.h"

#include "../../../inc/MarlinConfig.h"

#include HAL_PATH(../../.., tft/xpt2046.h)
#include "../../marlinui.h"
XPT2046 touch;

#if ENABLED(POWER_LOSS_RECOVERY)
Expand Down
2 changes: 0 additions & 2 deletions Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@

#include <lvgl.h>

//#define TFT_ROTATION TFT_ROTATE_180

extern uint8_t bmp_public_buf[14 * 1024];
extern uint8_t public_buf[513];

Expand Down
1 change: 1 addition & 0 deletions Marlin/src/lcd/extui/mks_ui/wifi_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1804,6 +1804,7 @@ void stopEspTransfer() {

W25QXX.init(SPI_QUARTER_SPEED);

// ?? Workaround for SPI / Servo issues ??
TERN_(HAS_TFT_LVGL_UI_SPI, SPI_TFT.spi_init(SPI_FULL_SPEED));
TERN_(HAS_SERVOS, servo_init());
TERN_(HAS_Z_SERVO_PROBE, probe.servo_probe_init());
Expand Down
7 changes: 3 additions & 4 deletions Marlin/src/lcd/tft/touch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,19 +266,18 @@ void Touch::hold(touch_control_t *control, millis_t delay) {
bool Touch::get_point(int16_t *x, int16_t *y) {
#if ENABLED(TFT_TOUCH_DEVICE_XPT2046)
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
bool is_touched = (touch_calibration.calibration.orientation == TOUCH_PORTRAIT ? io.getRawPoint(y, x) : io.getRawPoint(x, y));

const bool is_touched = (touch_calibration.calibration.orientation == TOUCH_PORTRAIT ? io.getRawPoint(y, x) : io.getRawPoint(x, y));
if (is_touched && touch_calibration.calibration.orientation != TOUCH_ORIENTATION_NONE) {
*x = int16_t((int32_t(*x) * touch_calibration.calibration.x) >> 16) + touch_calibration.calibration.offset_x;
*y = int16_t((int32_t(*y) * touch_calibration.calibration.y) >> 16) + touch_calibration.calibration.offset_y;
}
#else
bool is_touched = (TOUCH_ORIENTATION == TOUCH_PORTRAIT ? io.getRawPoint(y, x) : io.getRawPoint(x, y));
const bool is_touched = (TOUCH_ORIENTATION == TOUCH_PORTRAIT ? io.getRawPoint(y, x) : io.getRawPoint(x, y));
*x = uint16_t((uint32_t(*x) * TOUCH_CALIBRATION_X) >> 16) + TOUCH_OFFSET_X;
*y = uint16_t((uint32_t(*y) * TOUCH_CALIBRATION_Y) >> 16) + TOUCH_OFFSET_Y;
#endif
#elif ENABLED(TFT_TOUCH_DEVICE_GT911)
bool is_touched = (TOUCH_ORIENTATION == TOUCH_PORTRAIT ? io.getPoint(y, x) : io.getPoint(x, y));
const bool is_touched = (TOUCH_ORIENTATION == TOUCH_PORTRAIT ? io.getPoint(y, x) : io.getPoint(x, y));
#endif
#if HAS_TOUCH_SLEEP
if (is_touched)
Expand Down
10 changes: 0 additions & 10 deletions Marlin/src/lcd/tft_io/ili9488.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,6 @@
#define ILI9488_ADJCTL6 0xFC // Adjust Control 6
#define ILI9488_ADJCTL7 0xFF // Adjust Control 7

#if 0
// https://forum.mikroe.com/viewtopic.php?t=74586
#if ANY(MKS_ROBIN_TFT35, TFT_TRONXY_X5SA, ANYCUBIC_TFT35) // ILI9488
#define TFT_DRIVER ILI9488
#define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y)
#define TFT_RES_480x320
#define TFT_INTERFACE_FSMC
#endif
#endif

static const uint16_t ili9488_init[] = {
DATASIZE_8BIT,
ESC_REG(ILI9488_SWRESET), ESC_DELAY(120),
Expand Down
2 changes: 0 additions & 2 deletions Marlin/src/lcd/tft_io/tft_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
#error "DMA_MAX_SIZE is not configured for this platform."
#endif

#include "tft_orientation.h"

#ifndef TFT_DRIVER
#define TFT_DRIVER AUTO
#endif
Expand Down
Loading