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

Add support for TFT and touch screens #18130

Merged
merged 106 commits into from
Jul 30, 2020

Conversation

jmz52
Copy link
Contributor

@jmz52 jmz52 commented May 27, 2020

Description

Add support for TFT and touch screens

Benefits

Marlin can use TFT screen with optional touch panel

Related Issues

#18129

jmz52 added 2 commits May 27, 2020 11:10
Fix compilation errors for STM32F103 with HAL STM32
Add support for 320x240 TFT with touch screen
TFT screen can be connected to 16-bit FSMC or dedicated SPI interface
Low-level IO implemented for HAL STM32 only
@xC0000005
Copy link
Contributor

What board would I build for to enable this? I'd like to hack around with the Ledge and Chitu boards to see if I can get their LCDs running with it.

@jmz52
Copy link
Contributor Author

jmz52 commented May 30, 2020

Build environment is defined in extra_config.ini

Board pins are defined in pins_custom.h

Check that BEEPER_PIN is disabled in your configuration.

@jmz52
Copy link
Contributor Author

jmz52 commented Jun 3, 2020

@xC0000005
I've added support for STM32F4 in Vx and Zx variants.
Tested on black STM32F407VE and STM32F407ZE boards with ILI9341 display.
Touch works in both SPI and software SPI modes.
This probably means that code will work on F103Vx, but I no hardware to test it.

Build environments. USB and SD are disabled to avoid some configuration problems I did not have time to look at.

[env:black_STM32F407ZE]
platform          = ststm32
board             = black_f407ze
framework        = arduino
platform_packages = framework-arduinoststm32@${common.arduinoststm32_ver}
build_flags       = ${common.build_flags} -DARDUINO_ARCH_STM32 -IMarlin/src/HAL/STM32
  -DTARGET_STM32F4 -DARDUINO_BLACK_F407ZE
  -DMOTHERBOARD=BOARD_CUSTOM -DDISABLE_GENERIC_SERIALUSB
  -DHAL_SRAM_MODULE_ENABLED
  -DHAS_GRAPHICAL_TFT -DHAS_FSMC_TFT -DTFT_320x240 -DTOUCH_SCREEN
  -DULTIPANEL -DLCD_HEIGHT=6
  -DNO_LCD_REINIT
build_unflags     = -std=gnu++11
src_filter        = ${common.default_src_filter} +<src/HAL/STM32>
lib_deps =

[env:black_STM32F407VE]
platform          = ststm32
board             = black_f407ve
framework        = arduino
platform_packages = framework-arduinoststm32@${common.arduinoststm32_ver}
build_flags       = ${common.build_flags} -DARDUINO_ARCH_STM32 -IMarlin/src/HAL/STM32
  -DTARGET_STM32F4 -DARDUINO_BLACK_F407VE
  -DMOTHERBOARD=BOARD_CUSTOM -DDISABLE_GENERIC_SERIALUSB
  -DHAL_SRAM_MODULE_ENABLED
  -DHAS_GRAPHICAL_TFT -DHAS_FSMC_TFT -DTFT_320x240 -DTOUCH_SCREEN
  -DULTIPANEL -DLCD_HEIGHT=6
  -DNO_LCD_REINIT
build_unflags     = -std=gnu++11
src_filter        = ${common.default_src_filter} +<src/HAL/STM32>
lib_deps =

@xC0000005
Copy link
Contributor

xC0000005 commented Jun 3, 2020 via email

@thinkyhead
Copy link
Member

thinkyhead commented Jun 11, 2020

So far there's no place where HAS_GRAPHICAL_TFT, HAS_SPI_TFT, HAS_FSMC_TFT, or TOUCH_SCREEN are defined. Those will need to go into Conditionals_LCD.h based on the user's configured LCD.

@jmz52
Copy link
Contributor Author

jmz52 commented Jun 12, 2020

So far there's no place where HAS_GRAPHICAL_TFT, HAS_SPI_TFT, HAS_FSMC_TFT, or TOUCH_SCREEN are defined. Those will need to go into Conditionals_LCD.h based on the user's configured LCD.

Yes, this is my 'top 3' list

  • Implement UI for UBL
  • Conditionals and sanity checks
  • Touch screen calibration UI

@thinkyhead thinkyhead merged commit 117df87 into MarlinFirmware:bugfix-2.0.x Jul 30, 2020
*/

#include "tft_image.h"
#include "cstddef"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This include is breaking arduino builds on my build actions.

https://github.com/jeffeb3/MarlinBuilder/runs/927540216?check_suite_focus=true#step:10:781

/home/jeffe/Downloads/arduino-1.8.13/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_RAMBO -DARDUINO_ARCH_AVR -I/home/jeffe/Downloads/arduino-1.8.13/hardware/arduino/avr/cores/arduino -I/home/jeffe/.arduino15/packages/rambo/hardware/avr/1.0.1/variants/rambo /tmp/arduino_build_926809/sketch/src/lcd/tft/tft_image.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
Alternatives for cstddef: []
ResolveLibrary(cstddef)
  -> candidates: []
/tmp/arduino_build_926809/sketch/src/lcd/tft/tft_image.cpp:24:10: fatal error: cstddef: No such file or directory
 #include "cstddef"
          ^~~~~~~~~
compilation terminated.
exit status 1
Error compiling for board RAMBo.

It is building in platformio. But not with arduino.

I'm still trying to figure out where my repo fits into all of this, and the best way to get tests upstream. But I figured I should point this out now, while this merge is fresh.

domrim pushed a commit to domrim/Marlin that referenced this pull request Aug 2, 2020
@mapfde
Copy link

mapfde commented Aug 8, 2020

Hi.

I used the code from the PR to help Mr. Nelson with testing and porting Marlin to the Lerdge-S board. (His codebase: https://github.com/xC0000005/Marlin/tree/LerdgePlusLCD)

Today, I migrated my configuration to the latest bugfix codebase. With the older code (https://github.com/mapfde/Marlin/tree/xC0000005-LerdgePlusLCD), the TFT image was fine and clear, with the latest bugfix, there is a pattern of thin vertical shade stripes on the display overlaying the image. TFT and touch both work, so it is purely cosmetical, but still irritating.

@rhapsodyv
Copy link
Member

Ported to STM32F1 :-)

Speaka pushed a commit to Speaka/Marlin that referenced this pull request Aug 13, 2020
@mattdog01
Copy link

Hello Team,
I'm not sure what I am doing wrong but I keep getting the following error when I try to use my Robin V2.3 and TFT v1.0 with the mks_robin_stm32 build. Any thoughts?

Marlin\src\HAL\STM32\HAL_SPI.cpp:136:8: error: #error "SS_PIN not defined!"
136 | #error "SS_PIN not defined!"
| ^~~~~
*** [.pio\build\mks_robin_stm32\src\src\HAL\STM32\HAL_SPI.cpp.o] Error 1

@mattdog01
Copy link

If I try to use the mks_robin build it completes but the touch screen doesn't work.

@rhapsodyv
Copy link
Member

If I try to use the mks_robin build it completes but the touch screen doesn't work.

This UI is widely supported by a variety of boards and TFT, including LPC lately.
Seems you have an outdated repository or some missing configs.
Try with an updated marlin version. And try asking help on the discord marlin server.

@mattdog01
Copy link

mattdog01 commented Aug 30, 2020 via email

albertogg pushed a commit to albertogg/Marlin that referenced this pull request Aug 31, 2020
@mattdog01
Copy link

mattdog01 commented Sep 1, 2020 via email

@jmz52 jmz52 mentioned this pull request Sep 11, 2020
30 tasks
@rhapsodyv rhapsodyv mentioned this pull request Sep 13, 2020
9 tasks
vgadreau pushed a commit to vgadreau/Marlin that referenced this pull request Dec 9, 2020
ahmetcemturan pushed a commit to ahmetcemturan/Marlin that referenced this pull request Jan 21, 2021
ahmetcemturan added a commit to ahmetcemturan/Marlin that referenced this pull request Jan 23, 2021
kageurufu pushed a commit to CR30-Users/Marlin-CR30 that referenced this pull request Apr 30, 2021
// Timer Definitions (optional)
// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin
#define TIMER_TONE TIM3
#define TIMER_SERVO TIM2
Copy link
Member

@thinkyhead thinkyhead Jul 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmz52, @rhapsodyv — Do you have any recollections why we specified these timers instead of 6 and 7 ? I'm trying to find out more for the benefit of #22369.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each timer can have one or more capabilities:

  • Allow Slave mode
  • Trigger source
  • Channels
  • PWM support
  • Combined Channels
  • Clock source
  • and a few other options
  • Nothing of these, just call the IRQ periodically

So, we need to chose timers according with the feature we need to use. It's ok if we use a timer that support PWM for something that don't need PWM (ex: just periodic irq calling), but we may run out of PWM timers if we don't chose wisely.

The thing with TIM6 and TIM7 is that they don't support any special feature: TIM6 and TIM7 are just "periodic callers of the IRQ". So, by the default, the variants try to alloc this two timers for this two things that don't need any special option.

TIM3 and TIM2 support a lot of options, so it's best to keep them free for a FAN or something else (but the PIN must match the timer too).

The change from #22369 seems good, keeping good defaults and moving the customisation (TIM2/TIM3) to build flags.

Copy link
Contributor

@tpruvot tpruvot Jul 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i used those to do like the VARIANT_Zx ... which have the same amount of timers... and reduce the differences... Most of specific ones are on RC/RE boards which have less timers and less pins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.