Skip to content

swkim01/waveshare-dtoverlays

Repository files navigation

WaveShare SpotPear 3.2" and 3.5/4.0" LCD Device Tree Overlays for the Raspberry PI

This is Device Tree Overlays of WaveShare SpotPear 3.2" TFT LCD and WaveShare SpotPear 3.5" TFT LCD for the Raspberry PI and PI 2 using notro's FBTFT driver.

Note that the waveshare 3.5/4.0" lcd's overlay is almost same with JBTek overlay.

Requirements

  • GNU Coreutils
  • GNU Make
  • dtc (device tree compiler)

Installation

1.) Clone this repo onto your pi

git clone https://github.com/swkim01/waveshare-dtoverlays.git
cd waveshare-dtoverlays

2.) Compile the device tree overlay binary objects:

make

3.) Install the device tree overlay binary files to /boot/overlays using:

sudo make install

4.) Reboot your raspberry pi

Display Server

1.) Wayland Server with DRM/KMS

You have to setup dtoverlay with drm parameter.

dtoverlay=waveshare35a,drm

After rebooting, you can get lcd drm output device(SPI-1) with following command.

$ wlr-randr

Then, modify ~/.config/wayfire.ini file to setup the device.

[output:SPI-1]
mode = 480x320@60000
transform = normal # or 90, 180, 270
scale = 1.0

2.) Legacy X Server with Framebuffer Driver

You have to setup dtoverlay without drm parameter.

dtoverlay=waveshare35a

Rotation

By default, the display is oriented in portrait mode, with its top toward its connectors (on the opposite side of the Raspberry Pi USB connectors). To rotate it, you can use the rotate dtoverlay parameter, which causes the display to rotate counter-clockwise. If you use the touchscreen, you will also want to rotate the touchscreen axes as well, by using the invertx, inverty and swapxy parameters.

For example, if you want the display in landscape mode with its top toward your Raspberry Pi HDMI connector, you can use:

dtoverlay=waveshare35b-v2,rotate=90,inverty=1,swapxy=1

To have the screen in landscape mode with its bottom toward your Raspberry Pi HDMI connector, you can use:

dtoverlay=waveshare35b-v2,rotate=270,invertx=1,swapxy=1

Touch Calibration

1.) Wayland Server with DRM/KMS

The touchscreens with wayland are handled by libinput and udev rules. At first you have to get the device name(like ADS7846 Touchscreen) by following command.

$ sudo libinput list-devices | grep Device

Modify ~/.config/wayfire.ini file to setup the device.

[input-device:ADS7846 Touchscreen]
output = SPI-1

Then, use coordinate transformation matrix.

  • Default : 1 0 0 0 1 0
  • clockwise 90 degree: 0 1 0 -1 0 1
  • clockwise 180 degree: -1 0 1 0 -1 1
  • clockwise 270 degree: 0 -1 1 1 0 0
  • inverting x: -1 0 1 0 1 0
  • inverting y: 1 0 0 0 -1 1
  • swapping x and y: 0 1 0 1 0 0

You have to add an udev file

$ sudo nano /etc/udev/rules.d/98-touchscreen-cal.rules

with

ATTRS{name}=="ADS7846 Touchscreen",ENV{LIBINPUT_CALIBRATION_MATRIX}="0 1 0 -1 0 1"

2.) Legacy X Server with Framebuffer Driver

To calibrate in detail, you can build a modified source of xinput-calibrator

$ sudo apt-get install git build-essential libx11-dev libxext-dev libxi-dev x11proto-input-dev
$ git clone https://github.com/kreijack/xinput_calibrator -b libinput
$ cd xinput_calibrator
$ ./autogen.sh
$ ./configure
$ make
$ sudo make install

Configure xinput_calibrator to autostart with X windows.

$ sudo cp -a scripts/xinput_calibrator_pointercal.sh /etc/X11/Xsession.d
$ echo "sudo /bin/sh /etc/X11/Xsession.d/xinput_calibrator_pointercal.sh" \
  | sudo tee -a /etc/xdg/lxsession/LXDE-pi/autostart

On first start of X windows a calibration window will be displayed.

startx

After calibration, the calibration file /etc/pointercal.xinput will be created automatically. Or instead you can create /usr/share/X11/xorg.conf.d/99-calibration.conf by executing xinput_calibrator or copy from /etc/pointercal.xinput.

Section "InputClass"
        Identifier "calibration"
        MatchProduct "ADS7846 Touchscreen"
        Option "TransformationMatrix" "0.016152 -1.137751 1.062519 1.126908 -0.005470 -0.064818 0.0 0.0 1.0"
EndSection

About

WaveShare SpotPear 3.2" and 3.5/4.0" TFT LCD overlays for the Raspberry PI and PI 2

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors