Abstract2actual
  • Home
  • Blog
  • Gallery
  • Buy stuff
  • Contact
  • About

Raspberry Pi Display Upgrade

8/24/2016

0 Comments

 
Picture
I've been successfully using a Raspberry Pi as a host controller for my Airwolf3D v5.5 since April of last year.  See my previous blog post about setting that up.  I really like that setup, but I want this rig to be more portable, and lugging around a 14 inch flat screen isn't very helpful there.  My awesome girlfriend bought me an Adafruit 2.8 inch PiTFT touchscreen for my birthday last year, and I finally got the nerve to set it up.  The installation was fraught with failure.  Mostly because of my lack ​​of attention to detail, and in part due to the scattered nature of the instructions.  This project consisted of 3 phases: hardware assembly, software installation & configuration, and designing a new case.  I'm not going to count unit testing, redesign, or user acceptance because any project manager worth their salt knows that these things just magically get done.

I used the Adafruit site as a reference but it's not exactly intuitive, as both the simple automagic installation and detailed installation instructions run together, so I wasn't really sure where to start.  I chose to follow the detailed instructions, just so I'd understand what was going on.  My first attempt was successful, but in trying to figure out how to get the desktop to boot to the new display, I blew everything up and had to re-image the micro SD.  Fortunately, I keep a copy of the last known good image on my laptop, so it only took 5 minutes to get the Pi back to its original state.  Installing the display software the second time was easier, but I accidentally clicked a link for the capacitive touch display instead of the resistive touch display and set the wrong configuration settings.  Third time's a charm, but I still couldn't get the desktop (X windows) to boot to the new display.  Thank Google for helping me eventually find it, buried in the instructions that I was looking at on the Adafruit site.  It was listed under "extras" in the installation instructions.  Ultimately, here is how I got this to work:
Hardware assembly part 1
Solder the tactile switches onto the PiTFT module
Software installation & configuration
​NOTE: Start with a raspberry pi that has a working install of Raspbian with network access.  Mine had the latest Octopi image.
Open a terminal window and execute the commands in bold text below:
Make sure it the Pi is up to date
    sudo apt-get update
Download the kernel
    curl -SLs https://apt.adafruit.com/add-pin | sudo bash
install the kernel
    sudo apt-get install raspberrypi-bootloader
Edit /boot/config.txt file to add device tree overlay
    sudo nano /boot/config.txt
    and add these lines at the end of the file
        [pi1]
        ​device_tree=bcm2708-rpi-b-plus.dtb
        ​[pi2]
        ​device_tree=bcm2709-rpi-2-b.dtb
        ​[all]
        ​dtparam=spi=on
        ​dtparam=i2c1=on
        ​dtparam=i2c_arm=on
        ​dtoverlay=pitft28r,rotate=90,speed=32000000,fps=20
    Save the file and exit

    sudo shutdown -h now
    Now install the TFT on the Pi and power it back on.  There won’t be anything on the TFT display yet, but we will test it now.
    Open a terminal window and run these three commands
    sudo mv /usr/share/X11/xorg.conf.d/99-fbturbo.conf ~
    export FRAMEBUFFER=/dev/fb1
    startx
If you did everything right, you should see the Pi desktop on the little display now.  :)

​Now we have to send the display back to the HDMI monitor to finish the work so open a terminal window in the little display and execute the following commands
    export FRAMEBUFFER=/dev/fb0
    startx
The desktop should now appear on your regular monitor
Now we’ll add support for the touchscreen  Open a terminal window and edit the module list
    sudo nano /etc/modules
        Add the following line at the end of the file
        stmpe-ts
    Save the file and and exit
Reboot by entering the following command
    sudo reboot
After the Pi reboots, check to make sure that the modules installed.  Open a terminal window and enter the following command
    dmesg
Somewhere in that message, you should see the below lines
Picture
Create a calibration configuration file
    sudo mkdir /etc/X11/xorg.conf.d
    sudo nano /etc/X11/xorg.conf.d/99-calibration.conf
    enter the following lines
        Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "stmpe-ts"
        Option  "Calibration"   "3800 200 200 3800"
        Option  "SwapAxes"      "1"
        EndSection
    Save the file and exit
Try sending the desktop  to the new TFT again
    FRAMEBUFFER=/dev/fb1 startx
If you did it right, the display will show up on the new TFT :)
Send the desktop back to the big monitor so we can finish the work
    FRAMEBUFFER=/dev/fb0 startx
Make the it so startx defaults to the TFT by editing the ~/.profile
    sudo nano ~/.profile
    Add this line near the top of the file
        export FRAMEBUFFER=/dev/fb1
    Save and exit the file
Enable booting X windows (the desktop) to the TFT by moving a file and editing it.
    sudo mv /usr/share/X11/xorg.conf.d/99-fbturbo.conf ~
    sudo nano /usr/share/X11/xorg.conf.d/99-pitft.conf
       Add the following lines
        Section "Device"
        Identifier "Adafruit PiTFT"
        Driver "fbdev"
        Option "fbdev" "/dev/fb1"
        EndSection
    Save the file and exit
If you want to use the left tactile switch as power off/on, edit the /etc modules file
    sudo nano /etc/modules
    Add the following line at the end of the file
        rpi_power_switch
    Save the file and exit
Create or edit the adafruit config file
    sudo nano /etc/modprobe.d/adafruit.conf
    add this line to the end of the file
        options rpi_power_switch gpio_pin=23 mode=0
    Save the file and exit
Make the switch active by running the following command
    sudo modprobe rpi_power_switch
If you press the left most switch on the display board, the pi should shut down.
Press the button again and the pi should boot to the TFT display

NOTE: ​If you ever want to run the display on the HDMI just open a terminal and enter the following
    FRAMEBUFFER=/dev/fb0 startx

Design and print the case

I desighed the case in Sketchup and made it available on Thingiverse as thing 1737249.
I printed the body on my Airwolf3D v5.5 and the covers on X3REX, my modified Prusa i3.
The design resolves the problem I've had with the micro SD slot on the Pi.  It's a springloaded slot, but the catch on the spring no longer works, so the card will not stay seated.  THe clip on the left side of the case not only holds the case together, it keeps the card in the slot.  I designed and printed the case, and found that the fit wasn't quite right, so with a few tweaks I fixed the alignment problems and re-printed.  v2 of the case came out just right.  I still have to work on the mast for the camera.  I want it to fold down and out of the way while the unit is in transport.

Hardware assembly part 2
Install the Pi and TFT in the case. 
Raspberry Pi TFT case.  #Abstract2Actual 3 days, 6 hours, 27 minutes
0 Comments



Leave a Reply.

    View my profile on LinkedIn

    TJ Emsley

    Lifetime tinkerer.

    Archives

    October 2022
    January 2021
    November 2020
    October 2020
    September 2020
    February 2018
    January 2018
    January 2017
    October 2016
    August 2016
    July 2016
    June 2016
    May 2015
    April 2015
    March 2015
    February 2015
    December 2014
    October 2014
    August 2014
    July 2014
    May 2014
    April 2014
    March 2014
    November 2013
    October 2013

    Categories

    All
    3d Design
    3d Printing
    Open Source

    RSS Feed




Proudly powered by Weebly