Feature #839
closedIntegrate TFT-3.5inch Display
Added by Hammel over 3 years ago. Updated over 3 years ago.
100%
Description
See
- https://smile.amazon.com/gp/product/B07N38B86S/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1
- https://github.com/goodtft/LCD-show
- This has scripts (LCD35-show) that can be used as a basis for installing and configuring what's required. It could probably be made into a config opkg.
- https://github.com/goodtft/LCD-show/blob/master/etc/modprobe.d/fbtft.conf (it supported via fbtft)
- http://www.lcdwiki.com/3.5inch_RPi_Display
This display has only a 480x320 display area. I can scale icons to fit this but should expect that, because I'm not using EGL as a Cairo backend (yet) that things might be a little slow.
Updated by Hammel over 3 years ago
- Severity changed from 02 - High to 01 - Critical
Updated by Hammel over 3 years ago
- Status changed from New to In Progress
- % Done changed from 0 to 20
Looks like the model they sent me was actually an LCD-35, not an MHS-35.
Meta build created: lcdshow (not pushed yet).
Package available for testing.
Updated by Hammel over 3 years ago
The build seems to work on the dev platform if I use the following command from a terminal window.
FRAMEBUFFER=/dev/fb1 startx
This is with the HDMI plugged in and acting as the default display. Touchscreen works but might be rotated incorrectly - the display is in landscape mode but touchscreen appears to be in portrait mode. I'll deal with the touchscreen later.
So now I need to see how I can force the TFT to be used at boot. I might need to use fbcon on the cmdline or con2fbmap 1 1. But mostly I just need to find out if there are one or two fb devices when HDMI is not plugged in, then set the X.org startup to use the correct device. This could be done, potentially, by using different xorg.conf files and specifying the TFT device conf like so.
Section "Device" Identifier "Allwinner A10/A13/A20 FBDEV" Driver "fbturbo" Option "fbdev" "/dev/fb1" Option "SwapbuffersWait" "true" EndSection
Updated by Hammel over 3 years ago
Oh look - someone else is doing exactly what I'm doing. This could be really helpful.
Updated by Hammel over 3 years ago
I have scripts to switch from HDMI to TFT and back, but they're hacks that just rerun startx. Exiting the xterm that gets started from that drops me back to the last startx. So running pibox-tft puts me on the TFT and exiting that puts me back on the HDMI.
That's good enough for testing purposes to get the rest of the display working but not a production method of swapping. I need either fbcp or con2fbmap apparently.
The current problem is the display size. Setting the framebuffer wxh did squeeze the width but not the height.
I need to review the following links and gather information on how to complete this project:- https://github.com/notro/fbtft/wiki
- https://learn.watterott.com/hats/rpi-display/fbtft-install/
- https://learn.watterott.com/hats/rpi-display/faq/
- http://www.willprice.dev/2017/09/16/adventures-with-tft-screens-for-raspberry-pi.html
- https://www.raspberrypi.org/forums/viewtopic.php?t=111817#p1041032
- https://philipp-weissmann.de/touch-display-auf-raspberry-pi-mit-arch-linux/ (German)
- https://forum.armbian.com/topic/13221-fbtft-with-device-tree-overlay-on-mainline/ (DTS info) #
Updated by Hammel over 3 years ago
Turns out the display is working just fine. All I need to do is add
FRAMEBUFFER=/dev/fb1
export FRAMEBUFFER
to /etc/init.d/S99UI and the UI starts on the small display. Running pibox-hdmi on there will launch the HDMI display, albeit at the width of the TFT display.
Now I need to test the touchscreen. I should use xinput-calibrate and ts-calibrate for this. I can also do:
TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/event0 ts_test
TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/event0 ts_calibrate
An initial attempt at ts_test locked up the screen. I'll need to write some simplified scripts to make this easier to rerun since there is no shell history to rerun commands in the dev platform.
For xinput-calibrate I should be able copy the output from the following into an xorg.conf file.
DISPLAY=:0.0 xinput_calibrator
This doesn't work either. I just get "No calibratable devices found". Might need to set an environment variable to find the correct input event file.
Updated by Hammel over 3 years ago
- Subject changed from Integrate MHS-3.5inch RPi Display to Integrate TFT-3.5inch Display
Updated by Hammel over 3 years ago
The touchscreen is on event4, which I can see by running evtest with no arguments which gives me a list of events with associated names. I need a way to identify the event file in a script - evtest is interactive (at least without arguments).
To get the names of the devices you need an ioctl, which is not easy to call via a shell script. evtest.c has the scan_list() function that I could add to piboxlib/ptools/<new tool> to handle this.
Updated by Hammel over 3 years ago
Added pbeventlist to piboxlib. Needs to be tested on hardware, then used with the TBD scripts that I can use to test the touchscreen.
Updated by Hammel over 3 years ago
Preparing to test I found I wanted to switch back and forth between the TFT and HDMI. LCDShow-hdmi does this for LCDShow, but it's much simpler than that.
To go from TFT (after lcdshow package is installed) to HDMI- Edit config.txt
- Comment out framebuffer_<width,height>
- Comment out dtparam=i2c_arm=on
- Comment out dtparam-spi=on
- Comment out dtoverlay=tft35a:rotate=90
- Edit /etc/init.d/functions
- Change FRAMEBUFFER=/dev/fb1 to FRAMEBUFFER=/dev/fb0
- Reboot
That FRAMEBUFFER change also requires using that variable in /etc/init.d/S99UI.
I need to edit pibox-hdmi to comment these out or uncomment to go back to TFT and then do the reboot.
It's annoying that a reboot is required, but at least I can edit directly on the device for testing purposes. Editing with the TFT is very difficult due to the very small display, which requires very small fonts to get enough visible to be useful.
Updated by Hammel over 3 years ago
- % Done changed from 20 to 60
Getting closer. S99UI calls xinit directly instead of using startx. The latter honors the FRAMEBUFFER setting. The former is not. I need to find out why.
Updated by Hammel over 3 years ago
FRAMEBUFFER would need to be used to manually edit the xorg.conf file, which needs a Device section like so:
Section "Device" Identifier "Allwinner A10/A13/A20 FBDEV" Driver "fbturbo" Option "fbdev" "/dev/fb1" Option "SwapbuffersWait" "true" EndSection
So I can either have a copy of this that is edited by the pibox-hdmi script or I can have two copies with ".hdmi" and ".tft" suffices which the script chooses to symlink to the real xorg.conf.
Updated by Hammel over 3 years ago
- % Done changed from 60 to 80
This now works. The lcdshow package will handle support for switching to TFT displays, while the default in the dev platform is to always assume we're in HDMI mode (unless it's a touchscreen, which is still HDMI but a different xorg.conf).
I removed cruft from S99UI in the dev platform that was originally intended to handle TFT displays but it wasn't really doing anything and nothing was using what it did try to setup so it was useless. The updated init script is much simnpler.
Tested on the tft display with a small 5" hdmi display. The pibox-hdmi script handles switching back and forth just fine now.
Still need to test these changes on a PiBox Media System build and a kiosk build to make sure those work out-of-the-box.
Verified working on kiosk build.
Verified working on media system build.
Also: need to run calibration tests - see above comment (#829-8). I already have a script for this: pibox-touchtest. It should be in the rootfs already (after lcdshow package is installed).
Updated by Hammel over 3 years ago
- Status changed from In Progress to Closed
- % Done changed from 80 to 100
This is now working (except xinput-calibrator, which won't work with PiBox but we don't care because we use tslib directly anyway). All changes have been tested on hardware, committed and pushed.
Closing issue.