MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
16.28k stars 19.24k forks source link

[BUG] Touch screen not working #22208

Open lclrcarvalho opened 3 years ago

lclrcarvalho commented 3 years ago

Did you test the latest bugfix-2.0.x code?

Yes, and the problem still exists.

Bug Description

The touchscreen stopped working. Last version it still works is 2.0.8.2

Tested with most recent bugfix and still happens.

Usually I leave TOUCH_SCREEN_CALIBRATION commented, but uncommenting it just leaves the screen in calibration mode without reaction to touches.

I'm using MKS_ROBIN_TFT43 TFT_COLOR_UI

MKS_ROBIN_NANO35 environment

Bug Timeline

after 2.0.8.2

Expected behavior

Have marlin react to touches in the TFT

Actual behavior

No reaction to touch

Steps to Reproduce

  1. Turn on
  2. touch screen
  3. nothing happens

Version of Marlin Firmware

FIRMWARE_NAME:Marlin bugfix-2.0.x

Printer model

TWO TREES BLUER PLUS

Electronics

MKS Robin Nano V1.2

Add-ons

TFT with 480x272

Your Slicer

No response

Host Software

No response

Additional information & file uploads

Serial works, but it takes a simple G28 command takes the screen to the "Nozzle" screen and it's impossible to come out as touch doesn't work.

ellensp commented 3 years ago

Please attach your configuration files.

lclrcarvalho commented 3 years ago

configuration files for bugfix.zip

Here they are

ellensp commented 3 years ago

@rhapsodyv could you take a look at this?

rhapsodyv commented 3 years ago

Can you try enable:

#define TOUCH_SCREEN_CALIBRATION

and remove or comment (disable) this values:

  #define TOUCH_CALIBRATION_X   17653
  #define TOUCH_CALIBRATION_Y   11931
  #define TOUCH_OFFSET_X        -51
  #define TOUCH_OFFSET_Y        -51
  #define TOUCH_ORIENTATION     TOUCH_PORTRAIT

and test again?

lclrcarvalho commented 3 years ago

Hi,

After booting it goes to the calibration screen in "bottom left" and regardless where I touch it doesn't react at all.

I've also tried via octoprint sending a G28 command. It executes the command fine, but in the screen it flicks and ends up in "Top Left" with 2 plus signs (one in the top left and one in the bottom right).

So as I had tried before just uncommenting TOUCH_SCREEN_CALIBRATION, commenting my calibration settings doesn't cause any different behavior.

Maybe completely unrelated but while compiling I get a warning:

"In file included from Marlin\src\HAL\STM32\eeprom_flash.cpp:33:
C:\Users\Luis\.platformio\packages\framework-arduinoststm32\libraries\EEPROM\src/EEPROM.h:247:20: warning: 'EEPROM' defined but not used [-Wunused-variable]
  247 | static EEPROMClass EEPROM;
      |                    ^~~~~~"
rhapsodyv commented 3 years ago

if you use the env mks_robin_nano35_maple, do it works?

lclrcarvalho commented 3 years ago

I get the error in the beginning:

*** [C:\Users\Luis\.platformio\packages\framework-arduinoststm32-maple\STM32F1\variants\generic_stm32f103v\board.cpp] C:\Users\Luis\Documents\GitHub\Marlin\.pio\build\mks_robin_nano35_maple\.sconsign37.dblite: No such file or directory

So I can't build it... (I've tried deleting the .pio folder for a fresh compile)

rhapsodyv commented 3 years ago

just try again, these errors are temporary

lclrcarvalho commented 3 years ago

The touch screen now works :)

But after pressing the 4 corners (starting on "top left") it ends with the "Top left" screen with two plus signs and it hangs. This is something that happened to me in the past (like back in January), but only sometimes. Now happened consistently (at least it failed in 5 consecutive starts).

Compiling with my previous calibration figures, takes me to the menu and all seems fine now.

Out of curiosity as I couldn't find anything about the "maple" flavor, what's the difference ?

rhapsodyv commented 3 years ago

Thanks for the details. I will take a deeper look.

If it is working with _maple, but not with the other env, it seems some spi default config difference between these two envs.

The hang could be related with the auto save and eeprom settings

rhapsodyv commented 3 years ago

Can you test the env without _maple, but edit this line:

https://github.com/MarlinFirmware/Marlin/blob/4f8191b4818b97bd20eb9db2042dc07c97cce6cc/Marlin/src/HAL/STM32/tft/xpt2046.cpp#L56

Change it from:

SPIx.Init.BaudRatePrescaler  = SPI_BAUDRATEPRESCALER_8;

To:

SPIx.Init.BaudRatePrescaler  = SPI_BAUDRATEPRESCALER_64;

And test again?

lclrcarvalho commented 3 years ago

Yes, that fixes the touch screen issue. All seems ok.

Still if I turn on TOUCH_SCREEN_CALIBRATION the same behavior happens (as the maple version).

Should I create a different bug for that ?

rhapsodyv commented 3 years ago

Perfect! That confirm my suspect that the issue is related with spi speed defaults.

I will send a PR later.

You don’t need open a new issue for the touch calibration hang. I will take a look at it soon.

It hangs if you disable auto save?

lclrcarvalho commented 3 years ago

You are right, commenting

  //#if BOTH(TOUCH_SCREEN_CALIBRATION, EEPROM_SETTINGS)
  //  #define TOUCH_CALIBRATION_AUTO_SAVE // Auto save successful calibration values to EEPROM
  //#endif

Solves the issue.

After calibration goes into "Calibration Completed" and touching moves to the main screen.

thinkyhead commented 3 years ago

Please test the bugfix-2.0.x branch to see where it stands. If the problem has been resolved then we can close this issue. If the issue isn't resolved yet, then we should investigate further.

lclrcarvalho commented 3 years ago

Sorry for the delay.

The problem remains:

a0s commented 3 years ago

Same problem for me with MKS_ROBIN_TFT35

On not-maple env:

Commenting

//#if BOTH(TOUCH_SCREEN_CALIBRATION, EEPROM_SETTINGS)
  //  #define TOUCH_CALIBRATION_AUTO_SAVE // Auto save successful calibration values to EEPROM
  //#endif

didn't help

Replacing

SPIx.Init.BaudRatePrescaler  = SPI_BAUDRATEPRESCALER_64;

didn't help

UPD: With TFT_LVGL_UI and TOUCH_SCREEN i passed calibration test (very long, 5-7 cycles) with Calibration failed in the end :) but it works

rubyredrick commented 3 years ago

I think I'm seeing a similar issue.

Building for the Elegoo Neptune 2.

I get through the calibration, but then the main screen comes up and there is no response to touches.

For now I've gone back to using the TFT_COLOR_UI Configuration.h.txt Configuration_adv.h.txt

Bjohnson131 commented 2 years ago

I have just seen this too, tronXY x5sa pro. just downloaded 2.0.9 today.

Configs.zip

Here's the output of the touch calibration debug:


⸮⸮TouchCalibration - State: 0, x: 30, raw_x: 1829, y: 30, raw_y: 195
TouchCalibration - State: 1, x: 30, raw_x: 1786, y: 289, raw_y: 1801
TouchCalibration - State: 2, x: 449, raw_x: 187, y: 30, raw_y: 260
TouchCalibration - State: 3, x: 449, raw_x: 167, y: 289, raw_y: 1807
romass commented 1 year ago

Any updates on this thread? I have identical issue. After doing calibration Top L, Bottom L, Top R, Bottom R, it goes to the same state and freezes.

My config:

#define TOUCH_SCREEN
#if ENABLED(TOUCH_SCREEN)
  #define BUTTON_DELAY_EDIT  50 // (ms) Button repeat delay for edit screens
  #define BUTTON_DELAY_MENU 250 // (ms) Button repeat delay for menus

  //#define TOUCH_IDLE_SLEEP 300 // (s) Turn off the TFT backlight if set (5mn)

  #define TOUCH_SCREEN_CALIBRATION

  // XPT2046 Touch Screen calibration
  #define XPT2046_X_CALIBRATION 116903
  #define XPT2046_Y_CALIBRATION 10346
  #define XPT2046_X_OFFSET      -25
  #define XPT2046_Y_OFFSET      -22
  //#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
#endif
Bjohnson131 commented 1 year ago

Any updates on this thread? I have identical issue. After doing calibration Top L, Bottom L, Top R, Bottom R, it goes to the same state and freezes.

My config:

#define TOUCH_SCREEN
#if ENABLED(TOUCH_SCREEN)
  #define BUTTON_DELAY_EDIT  50 // (ms) Button repeat delay for edit screens
  #define BUTTON_DELAY_MENU 250 // (ms) Button repeat delay for menus

  //#define TOUCH_IDLE_SLEEP 300 // (s) Turn off the TFT backlight if set (5mn)

  #define TOUCH_SCREEN_CALIBRATION

  // XPT2046 Touch Screen calibration
  #define XPT2046_X_CALIBRATION 116903
  #define XPT2046_Y_CALIBRATION 10346
  #define XPT2046_X_OFFSET      -25
  #define XPT2046_Y_OFFSET      -22
  //#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
#endif

after a lot of working the issue, I eventually reinstalled over JTAG, and it started working.

TiNours38 commented 1 year ago

Hello just a quick update. Two Trees Bluer Plus (Blue-5) based on MKS Robin Nano v1.2 + MKS TFT43 (FSMC). Touch screen calibration didn't work until I applied @rhapsodyv SPI patch : changed to

SPIx.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64;

And it works

screen & touch screen config :

define MKS_ROBIN_TFT43

...

define TFT_COLOR_UI

...

define TOUCH_SCREEN

if ENABLED(TOUCH_SCREEN)

define BUTTON_DELAY_EDIT 50 // (ms) Button repeat delay for edit screens

define BUTTON_DELAY_MENU 250 // (ms) Button repeat delay for menus

// #define DISABLE_ENCODER // Disable the click encoder, if any // #define TOUCH_IDLE_SLEEP_MINS 5 // (minutes) Display Sleep after a period of inactivity. Set with M255 S.

define TOUCH_SCREEN_CALIBRATION

// // XPT2046 Touch Screen calibration // M995 : // Recv: TOUCH_CALIBRATION_X 16291 // Recv: TOUCH_CALIBRATION_Y 11142 // Recv: TOUCH_OFFSET_X -9 // Recv: TOUCH_OFFSET_Y -33

define XPT2046_X_CALIBRATION 15817

define XPT2046_Y_CALIBRATION 10748

define XPT2046_X_OFFSET -4

define XPT2046_Y_OFFSET -34

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

endif

many thanks !!

Wickeda1985 commented 1 month ago

Hey ich have This Promlem an have all the things do but it dont work can anybody upload The Firmware an Config ? Pls