Seeed / 52Pi PiShow 2.8 device tree overlay

This post is about the PiShow 2.8″ Resistive Touch Display from Seeedstudio. I found this little 65K colors and 320×240 pixel touch display for $20 at one of there sales.

The documentation on there web page is not easy to understand and everything you need is already part of the standard operating system image.

I used some existing device tree overlay and merged them and changed the pins and adopted the settings from the seeed documentation.

The scree is showing the picture, the touch is working with my finger and the four buttons on the side are working too. I would call this a success.

Thanks to @notro for his guidance to make this example and his work in this area in general.

/*
 * Device Tree overlay for pishow 2.8
 *
 */

/dts-v1/;
/plugin/;

/ {
    compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";

    fragment@0 {
    target = <&spi0>;
    __overlay__ {
        status = "okay";

        spidev@0{
        status = "disabled";
        };

        spidev@1{
        status = "disabled";
        };
    };
    };

    fragment@1 {
    target = <&gpio>;
    __overlay__ {
        pishow_display_pins: pishow_display_pins {
        brcm,pins = <18 23 24 25>;
        brcm,function = <1 1 1 0>; /* out out out in */
        brcm,pull = <0>; /* none */
        };
            pishow_ts_pins: pishow_ts_pins {
        brcm,pins = <22>;
        brcm,function = <0>; /* in */
        };
        keypad_pins: keypad_pins {
        brcm,pins = <16 20 21 26>;
        brcm,function = <0>; /* in */
        brcm,pull = <1>; /* down */
        };
    };
    };

    fragment@2 {
    target = <&spi0>;
    __overlay__ {
        /* needed to avoid dtc warning */
        #address-cells = <1>;
        #size-cells = <0>;

        pishow28: pishow28@0{
        compatible = "ilitek,ili9341";
        reg = <0>;
        pinctrl-names = "default";
        pinctrl-0 = <&pishow_display_pins>,
                <&pishow_ts_pins>;

        spi-max-frequency = <32000000>;
        rotate = <270>;
        bgr;
        fps = <30>;
        buswidth = <8>;
        reset-gpios = <&gpio 23 0>;
        dc-gpios = <&gpio 24 0>;
        led-gpios = <&gpio 18 1>;
        debug = <0>;
        };

        pishow28_ts: pishow28_ts@1 {
        compatible = "ti,ads7846";
        reg = <1>;

        spi-max-frequency = <2000000>;
        interrupts = <22 2>; /* high-to-low edge triggered */
        interrupt-parent = <&gpio>;
        ti,keep-vref-on = <1>;
        pendown-gpio = <&gpio 22 0>;
        /* driver defaults */
        ti,x-min = /bits/ 16 <230>;
        ti,y-min = /bits/ 16 <200>;
        ti,x-max = /bits/ 16 <3900>;
        ti,y-max = /bits/ 16 <3700>;
        ti,pressure-min = /bits/ 16 <0>;
        ti,pressure-max = /bits/ 16 <0xFFFF>;
        ti,x-plate-ohms = /bits/ 16 <80>;
        ti,swap-xy = <1>;
        };
    };
    };
    fragment@3 {
    target-path = "/soc";
    __overlay__ {
        keypad: keypad {
        compatible = "gpio-keys";
        #address-cells = <1>;
        #size-cells = <0>;
        pinctrl-names = "default";
        pinctrl-0 = <&keypad_pins>;
        #status = "disabled";
        autorepeat;
        button@16 {
            label = "GPIO KEY_UP";
            linux,code = <103>;
            gpios = <&gpio 16 0>;
        };
        button@26 {
            label = "GPIO KEY_DOWN";
            linux,code = <108>;
            gpios = <&gpio 26 0>;
        };
        button@20 {
            label = "GPIO KEY_LEFT";
            linux,code = <105>;
            gpios = <&gpio 20 0>;
        };
        button@21 {
            label = "GPIO KEY_RIGHT";
            linux,code = <106>;
            gpios = <&gpio 21 0>;
        };
        };
    };
    };
    __overrides__ {
    speed =   <&pishow28>,"spi-max-frequency:0";
    rotate =  <&pishow28>,"rotate:0";
    fps =     <&pishow28>,"fps:0";
    debug =   <&pishow28>,"debug:0";
    swapxy =  <&pishow28_ts>,"ti,swap-xy;0";
    xmin =    <&pishow28_ts>,"ti,x-min;0";
    ymin =    <&pishow28_ts>,"ti,y-min;0";
    xmax =    <&pishow28_ts>,"ti,x-max;0";
    ymax =    <&pishow28_ts>,"ti,y-max;0";
    pmin =    <&pishow28_ts>,"ti,pressure-min;0";
    pmax =    <&pishow28_ts>,"ti,pressure-max;0";
    xohms =   <&pishow28_ts>,"ti,x-plate-ohms;0";
    #keypad =  <&keypad>,"status";
    };
};

I used this script to install the device tree compiler dtc. After the compiler was installed this command creates the dtbo file:

sudo dtc -@ -I dts -O dtb -o /boot/overlays/pishow28.dtbo pishow28.dts

The last step is to add “dtoverlay=pishow28” to the end of the “/boot/config.txt” file.

Plus the /etc/X11/xorg.conf.d/99-ads7846-cal.conf file that swaps the X and Y axis:

Section "InputClass"
    Identifier "Touchscreen"
    MatchProduct "ADS7846 Touchscreen"
    Option "InvertX" "1"
    Option "InvertY" "1"
    Option "SwapAxes" "0"
    Option "Calibration" "215 3800 129 3676"
EndSection

I also added one line in /etc/udev/rules.d/95-ads7846.rules file:

SUBSYSTEM=="input", KERNEL=="event[0-9]*", ATTRS{name}=="ADS7846*", SYMLINK+="input/touchscreen"

As an extra I did install the frame buffer copy tool to copy the main frame buffer to the new touch display frame buffer.

6 thoughts on “Seeed / 52Pi PiShow 2.8 device tree overlay”

  1. Thank you! This is very useful, but how to do the 1st step? How do you add the overlay that you describe. An extra description on that would make this post perfect 🙂

    1. If I had to copy the device overlay to a new Pi I would probably open a ssh terminal window and start a text editor. I love mc with mcedit. Just do a suso apt install mc on the Pi. Now just copy and past from the web page in the ssh window where mcedit was started and save via F2 and exit via F10. Give mc a try to copy or move files, I like it to make my life easier.

  2. Hi,
    I realise that this is an old post, however it’s been invaluable in helping me to get my PiShow 2.8″ Touchscreen working. I’ve successfully compiled the driver and the screen is working and touch overlay calibrated.
    The issue that I have is that it appears as if it is still defaulting to the native screen resolution of 720 x 480. Any windows on the desktop are only partially displayed and a browser window is cut off on the right.
    I’m loading Chromium with a web page and have forced Chromium to a smaller size (DISPLAY=:0.0 chromium-browser –window-size=240,320).

    Any suggestions on how to reduce the scale of the desktop to 240×320 (I’m running portrait mode)?

    Thanks in advance.
    I’ve tried adding Overscan setting to the /boot/config.txt

    1. I don’t remember having those issues when I used the display. If I remember right the frame buffer copy tool did take care of this. But it looks like this tool doesn’t work with the latest Raspbian version. Did you try raspi-config advanced option > resolution to change the resolution yet?

  3. Hi alpha,
    Yes I tried that, the lowest resolution is 720*480 and only appears to change the HDMI output, which says to me that the frame buffer isn’t pushing to the GPIO. I’ve tried all sorts of variations using overscan settings and forcing resolution in the boot config but no joy.
    I’ll see if I can get the frame buffer copy working as described in your original post. I’m running a Pi4 with the latest raspbian version.

Leave a Reply to George Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.