OctoScreen Build


Overview

If you use OctoPrint to control your 3d printer, then you might be just as frustrated as me when you notice a print failing and you have to run to find a computer in order to cancel the print. In this project, I added a touchscreen to my 3d printer enclosure to control my OctoPrint server directly. Now I can start and stop prints directly from my enclosure rather than a computer, but I still get all the other benefits of having an OctoPrint server to control my Anycubic i3 Mega!

Parts List (Some Paid Links):

Touchscreen
GPIO Extension Ribbon
12V Panel Mount Plug
Buck Converter
12V Switch
12V Power Supply
LED Strip Extension Cable
LED Strip
3d printed parts:

Build Instructions

Hardware

First, I mounted all the hardware in the 3d printed parts I designed in order to make it easier to complete the soldering. The touchscreen mounted onto a faceplate and was held firm by a bracket on the back. That faceplate also help the buttons and attached to the main body of the electronics box. The electronics box had mounting holes for two buck converters and a Raspberry Pi, which will be running the OctoPrint server. 


Once I had all the electronics mounted, it was time to start soldering. Since I decided to wire 12V switches into the enclosure to allow me to turn the lights, the fan, and the entire enclosure off individually, I had a bit of extra soldering to do. The soldering took some time but was ultimately pretty simple to get done. The power input went to the power and ground poles on the button, and the output came from the Acc pole.  I wired the bottom switch to the top two switches power inputs as well, so that turning off the bottom switch would in-turn shut off the other two switches. 

Once the buttons were wired together, I needed to step the voltage down for the Raspberry Pi and the LEDs which both run off of 5 volts. To do that, I added some output wires to the bottom (main) switch, as well as the middle switch, that connected to some buck converters. 

The last step was to wire an LED strip connector to pin 21 on the Pi to be powered from one of the buck converters, a 12v fan connector to be powered by the top button, and the Raspberry Pi VIN to the output of the other buck converter. 

With all the soldering complete, I mounted the display faceplate onto the electronics box after connecting the Pi to the display via a GPIO ribbon cable, and I hot glued the fan and LED connectors to the back of the electronics box. 


Software

With all of the hardware setup complete, there are several steps I needed to run on the Raspberry Pi to prepare it for OctoScreen and the new touchscreen. Please don't feel overwhelmed if you are new to linux or the Raspberry Pi. None of these commands are too intense, and I tried to add some explanation of what is going on to help you. 

1. SSH Into The Pi

ssh pi@your-ip-address

2. Update Apt Package Manager

sudo apt-get update
sudo apt-get full-upgrade

3. Install Required Dependencies

sudo apt-get install git build-essential xorg-dev xutils-dev x11proto-dri2-dev
sudo apt-get install libgtk-3-0 xserver-xorg xinit x11-xserver-utils
sudo apt-get install libltdl-dev libtool automake libdrm-dev

4. Install and Build FBTurbo

git clone https://github.com/ssvb/xf86-video-fbturbo.git
cd xf86-video-fbturbo
autoreconf -vi
./configure --prefix=/usr
make
sudo make install
sudo cp xorg.conf /etc/X11/xorg.conf

5. Install OctoScreen

wget https://github.com/Z-Bolt/OctoScreen/releases/download/v2.5.1/octoscreen_2.5-1_armhf.deb
sudo dpkg -i octoscreen_2.5-1_armhf.deb

6. Adjust OctoScreen's Resolution

    Adjust OCTOSCREEN_RESOLUTION in /etc/octoscreen/config to 800x533. For me this was twice my screens resolution for some reason.

    sudo nano /etc/octoscreen/config

    7. Setup HDMI Clone to clone HDMI output

    sudo apt-get -y install cmake
    git clone https://github.com/tasanakorn/rpi-fbcp
    cd rpi-fbcp
    mkdir build
    cd build
    cmake ..
    make
    sudo install fbcp /usr/local/bin/fbcp

    8. Configure fbcp To Run At Boot

    sudo nano /etc/rc.local

    and add the following at the bottom of the file.

    /usr/local/bin/fbcp &

    9. Fix Screen Rotation

    Since I mounted my display upside down to make the GPIO ribbon cable fit better, I had to rotate the display and the touch inputs.

    sudo cp waveshare-dtoverlays/waveshare35a-overlay.dtb /boot/overlays/
    sudo nano /usr/share/X11/xorg.conf.d/40-libinput.conf 

    Change the Option line in the touchscreen input class to the following transformation matrix. Your matrix might be different depending on your screens rotation.

    Section "InputClass"
        Identifier "libinput touchscreen catchall"
        MatchIsTouchScreen "on"
        MacthDevicePath "/dev/input/event*"
        Driver "libinput"
        Option "TransformationMatrix" "0 1 0 1 0 0 0 0 1"
    EndSection

    10. Configure OctoScreen Resolution

    sudo nano /boot/config.txt

    Uncomment the following line and change the resolution to 800x533

    framebuffer_width=800
    framebuffer_height=533

    Add the following to configure fbcp resolution

    hdmi_cvt 800 533 60 6 0 0 0

    Add the following to configure the screens rotation. This may vary for your needs.

    dtoverlay=waveshare35a:rotate=270,swapxy=1 

    11. Remove the Boot Up Running Text

    Sudo nano /boot/cmdline.txt

    Remove the following from the cmdline.txt contents:

    console=tty1

    12. Replace OctoPrint Splash Screen with Custom Logo

    Create an image that is 230 pixels tall. Width isn't important, as long as it isn't ridiculously wide. Then, from your personal computer, copy the image over to the pi via SSH.

    Replace '/path/to/local/image' and 'your-pis-ip-address' with the path to your new image and the actual IP of your Pi.

    scp /path/to/local/image pi@your-pis-ip-address:/home/pi

    This will prompt you for a password. Next, you'll have to move it to the right directory within your Pi's folder structure.

    ssh pi@your-pis-ip-address
    //To rename the old image
    sudo mv /opt/octoscreen/styles/z-bolt/images/logo.png /opt/octoscreen/styles/z-bolt/images/logo-old.png
    //To move the new image into the proper directory and rename it to logo.png
    sudo cp ~/new/image/path.png /opt/octoscreen/styles/z-bolt/images/logo.png

    And there you have it! I could now boot up my Raspberry Pi and control OctoPrint using the touchscreen mounted onto my enclosure!

    Resources