How-to: Set up a RasPi 3 with 800x480 touchscreen and Touch UI

User-Generated tips and tricks for the Rostock Max, Orion, H1.1, or H1 Printers
User avatar
626Pilot
ULTIMATE 3D JEDDI
Posts: 1716
Joined: Tue May 14, 2013 12:52 pm

How-to: Set up a RasPi 3 with 800x480 touchscreen and Touch UI

Postby 626Pilot » Sat Aug 27, 2016 7:00 am

The point of this exercise is to get this up and running:

OctoPi.jpg

Sources of information used in this tutorial:
My writeup on getting the WaveShare LCD and touchscreen digitizer to work
BillyBlaze's Boot to Browser
kusti8's guide to installing Chromium on Raspberry Pi

You will need these parts:
The display connects to the Raspberry Pi in two ways: through the pin header, which supplies power and allows the touch screen digitizer to communicate; and through a HDMI bridge PCB that's included with the display. Because of that hardware bridge, you can only plug the touchscreen in the right way. Do so now, but don't plug in the Pi yet.


OctoPi Setup
====================================
Follow the steps on this page. There, you can download a version of Raspbian that has had OctoPrint and some extras (webcam, etc.) built in. Skip the "Installing from source" section.

Please note: Some tutorials tell you that you need to 'sudo raspi-config' and then have it expand the filesystem. The OctoPi distribution does that for you automatically, so there's no need!

After the image is done flashing to your SD card - which will take a LONG time - open the 'boot' partition and find the file: config.txt

Delete EVERYTHING in it, and replace with the following (you may have to scroll to see all of this):

Code: Select all

disable_overscan=1
framebuffer_width=800
framebuffer_height=480
hdmi_force_hotplug=1

hdmi_group=2
hdmi_mode=1
hdmi_mode=87
hdmi_cvt 800 480 60 6 0 0 0

max_usb_current=1

dtparam=i2c_arm=on
dtparam=i2s=on
dtparam=spi=on

dtparam=audio=on
start_x=1
gpu_mem=128
dtparam=spi=on
dtparam=i2c_arm=on
dtoverlay=w1-gpio

#device_tree_overlay=w1-gpio-pullup=on
#device_tree_param=gpiopin=4
#device_tree_param=extpullup=1

device_tree_overlay=ads7846
device_tree_param=cs=1
device_tree_param=penirq=25
device_tree_param=penirq_pull=2
device_tree_param=speed=50000

device_tree_param=keep_vref_on=0
device_tree_param=pmax=255
device_tree_param=xohms=150
device_tree_param=xmin=200
device_tree_param=xmax=3900
device_tree_param=ymin=200
device_tree_param=ymax=3900

You can do this at the same time you're editing octopi-network.txt, according to the instructions I linked on the OctoPrint site. (That file is also on the "boot" partition.)

Once you're done with all that, safely unmount/eject the SD card, put it into the slot on the bottom of the Pi, and plug in the power supply. You should get a boot screen that looks like this:

Pi booting.jpg

If you see a bunch of static looking stuff on the right side of the screen, it's because something went wrong with editing config.txt. If what you see is just like the above image, you did it right!

NOTE: The first time you boot the OS on your Pi, it will run a bunch of "first boot" tasks that will make it take awhile to finish booting. Subsequent booting should complete in well under a minute!

Once the Pi is done booting, you will need to bring it up in a browser. The OctoPrint interface should pop up a window asking you to specify a username and password for access control. Either set that up, or tell it to skip that. Please note that if you set up access control, it will apply to the touchscreen along with any other Web client, meaning that it will be read-only unless you log in through the touch screen.

After you choose what to do about access control, the interface will probably tell you that there's a new version of OctoPrint available, and ask whether to update. Say Yes. This will take a few minutes, and then OctoPrint will restart.

After it's done restarting, the OctoPrint interface will ask you to reload. Once that's done, click Settings -> Plugin Manager -> Get More. From that screen, you can install Touch UI. Do so. It will tell you that you need to restart OctoPrint before the plugin will work. Click System -> Restart OctoPrint -> Proceed.


Set up & calibrate the touchscreen
====================================
Log into your Pi according to the instructions on the OctoPrint site that I linked above. Then, do this:

Code: Select all

sudo -s
aptitude install libts-bin
export TSLIB_TSDEVICE=/dev/input/event0
export TSLIB_FBDEVICE=/dev/fb0
ts_calibrate

That will let you calibrate the touch screen digitizer. You can use the stylus that comes with the touch screen, or a cell phone/tablet stylus, or the cap of a pen (if it comes to a point), etc. I recommend against using a fingertip to do it. You want the calibration to be as fine as possible, so go SLOWLY and do your very best to tap the very center of where it tells you to. When the program finishes, it'll dump some numbers to the console, and write some values to /etc/pointercal.

Reboot the Pi:

Code: Select all

sudo init 6

Then, do this:

Code: Select all

sudo -s
export TSLIB_TSDEVICE=/dev/input/event0
export TSLIB_FBDEVICE=/dev/fb0
ts_test

If that works, you're good to go with the touchscreen setup! The only thing left to do is to get the Pi set up to automatically launch a browser when it starts, and to load OctoPrint in that browser.


Set up boot-to-browser
====================================
In the Pi terminal, do this:

Code: Select all

wget -qO - http://bintray.com/user/downloadSubjectPublicKey?username=bintray | sudo apt-key add -
echo "deb http://dl.bintray.com/kusti8/chromium-rpi jessie main" | sudo tee -a /etc/apt/sources.list
apt-get update
apt-get install --no-install-recommends xinit xserver-xorg xserver-xorg-video-fbdev x11-xserver-utils matchbox unclutter
apt-get install chromium-browser rpi-youtube -y

That will install XFree86, Linux's window manager, as well as Chromium, the open-source browser that Chrome is based on. This will take quite a while to complete.

Once everything finishes installing, do this:

Code: Select all

nano /usr/share/X11/xorg.conf.d/99-fbdev.conf
(text editor opens... paste the following)

Code: Select all

Section "Device"
  Identifier "myfb"
  Driver "fbdev"
  Option "fbdev" "/dev/fb0"
EndSection

Save and exit (Ctrl+O, enter, Ctrl+X)

Allow X11 to run as anybody:

Code: Select all

sed -i 's/allowed_users=console/allowed_users=anybody/' /etc/X11/Xwrapper.config

At this point, your prompt will look like "root@octopi:/home/pi#"

Press Ctrl+D to log out of root, which will return you to normal user mode, causing your prompt to look like "pi@octopi:~ $"

Now, get the Touch UI boot files, and install them so the system boots directly into the browser:

Code: Select all

git clone https://github.com/BillyBlaze/OctoPrint-TouchUI-autostart.git ~/TouchUI-autostart/
sudo cp ~/TouchUI-autostart/touchui.init /etc/init.d/touchui
sudo chmod +x /etc/init.d/touchui
sudo cp ~/TouchUI-autostart/touchui.default /etc/default/touchui
sudo update-rc.d touchui defaults

This will leave a directory called TouchUI-autostart in your home directory. Leave that there. You still need it after the install.

Finally, reboot your Pi:

Code: Select all

sudo init 6

After this, you should see the same bootup screen from the screenshot above (with four raspberries at the top). After about ten seconds, the screen should go blank, as X starts and loads Chromium. Ten seconds after that, you should see this:

TouchUI booting.jpg

About twenty seconds later, you should see OctoPrint's status screen (machine status, file, timelapse, etc.) The tabs and menu are all at the top of the screen. Scrolling is done by dragging a fingertip or stylus up/down on the screen. You won't need to scroll much, if ever. If you use the on-screen terminal, be advised that the terminal screen itself is scrollable, and it can be a little tricky to scroll back to the top of the screen and access the different tabs.

Connect to your Raspberry Pi according to the instructions linked above, set an access password when prompted, then click Settings and tell OctoPrint everything it needs to know about your printer. See the section below if you're connecting to a RAMBo.

I'm working on a printable enclosure for this. Stay tuned.


Connecting to a RAMBo
====================================
I recently got an Eris, which uses the RAMBo Mini controller. I found that at first, the temperature updates only came once a minute or so. That's no good! I went into Settings -> Features and enabled the following:
  • Send a checksum with every command
  • Support TargetExtr%n/TargetBed target temperature format
  • Disable detection of external heatups
That seems to have fixed it. I can get temperature updates as frequently as I like now.

I've also been using OctoPi with a Smoothieboard for the last month or so, and it isn't necessary to turn on any of these options. Additionally, OctoPi connects to my Smoothieboard automatically when it starts, but it never seems to do this successfully with my Eris' RAMBo. You'll need to tap the system menu (3 horizontal bars, top left), then tap Connection, verify everything's correct, then tap Connect. It will take a moment. After that, the system menu icon will flash green a few times, and you should have access to the movement controls on the tab with the joypad icon.


Homing
====================================
There are two home icons on the Control tab (joypad icon). The first will only tell the printer to move to homed position, which is useful for Cartesian systems, but not for Deltas. Instead, click the home icon between the up and down arrows. That sends G28, and homes the printer properly.


Shutting Down
====================================
DO NOT!!! just unplug your Raspberry Pi. It's running Linux, a full-fledged operating system. As such, it needs to be shut down properly! Tap the system menu (three horizontal bars, top left), then tap System, then Shutdown, then Proceed. If you screw this up, there's a risk that you may corrupt the SD card, at which point you'd have to reinstall the image and start this tutorial from scratch. Fortunately, Raspbian uses a journaling filesystem. If there's an accidental power loss, you'll probably be OK.
Last edited by 626Pilot on Tue Aug 30, 2016 1:07 am, edited 3 times in total.

dc42
Printmaster!
Posts: 304
Joined: Mon Mar 07, 2016 10:17 am

Re: How-to: Set up a RasPi 3 with 800x480 touchscreen and Touch UI

Postby dc42 » Sun Aug 28, 2016 4:03 pm

Kudos to you for publishing such a detailed description of how to get this working!

For anyone with Duet electronics, there is a much easier way to get a 800x480 touch UI working:

* Buy a PanelDue display controller and a compatible 5 or 7 inch screen;
* Connect it to the Duet. It just works. No need for any fancy startup or shutdown sequence.

In fairness, you may not get the same level of fancy graphics as you can on an Octopi, although if anyone suggests some useful graphics that can be added then I'll consider implementing them in the firmware - if nobody else does first. But you do get a touch keyboard to enter gcode commands.

Support for Panel Due in Repetier is is currently being worked on, and support in Smoothieware has been promised for a looong time.

User avatar
626Pilot
ULTIMATE 3D JEDDI
Posts: 1716
Joined: Tue May 14, 2013 12:52 pm

Re: How-to: Set up a RasPi 3 with 800x480 touchscreen and Touch UI

Postby 626Pilot » Sun Aug 28, 2016 10:57 pm

BONUS:

Say you want to give your Pi its own IP address, rather than getting a random one from DHCP. There are two ways to facilitate this. The first is to edit /etc/dhcpcd.conf, and put this at the end:

Code: Select all

interface wlan0
static ip_address=x.x.x.x/24
static routers=x.x.x.x
static domain_name_servers=x.x.x.x

This assumes that you're using wireless LAN. If you are using a hard wired connection, specify eth0 instead of wlan0. If you're editing the file on a Linux machine, you will need to do so as root.

The second way is to log into your router/network switch/whatever hardware is serving DHCP, and set it up to always give the same IP to a given MAC address. You can get the MAC address of your network adapter by logging into the Pi and typing /sbin/ifconfig wlan0 or /sbin/ifconfig eth0. There will be a number after HWAddr, like 12:34:56:78:9A:BC. That's the number to plug into the DHCP server.

The second way is how any network admin will tell you to do it. If you don't care, the first way is pretty easy.

Qdeathstar
Printmaster!
Posts: 622
Joined: Wed Apr 13, 2016 7:42 pm

Re: How-to: Set up a RasPi 3 with 800x480 touchscreen and Touch UI

Postby Qdeathstar » Sun Aug 28, 2016 11:53 pm

fwiw the second way is better because it reduces the risk of ip conflicts, since you are telling the router (which gives out ip addresses) which IP address to reserve for the pi... but as long as you choose an IP address that lies outside of your routers dhcp table the chance is negligible...

I think most routers now days try to keep a certain device on one IP address anyway.. so as long as you don't have a huge amount of devices it doesn't matter.

User avatar
626Pilot
ULTIMATE 3D JEDDI
Posts: 1716
Joined: Tue May 14, 2013 12:52 pm

Re: How-to: Set up a RasPi 3 with 800x480 touchscreen and Touch UI

Postby 626Pilot » Tue Aug 30, 2016 1:19 am

Qdeathstar wrote:fwiw the second way is better because it reduces the risk of ip conflicts, since you are telling the router (which gives out ip addresses) which IP address to reserve for the pi... but as long as you choose an IP address that lies outside of your routers dhcp table the chance is negligible...

I give my printers static IPs outside the DHCP range, and I also give them DNS entries on the local network so I don't have to remember the IPs.

User avatar
DeltaCon
Printmaster!
Posts: 585
Joined: Sat Nov 14, 2015 5:01 am
Location: Wessem, The Netherlands
Contact:

Re: How-to: Set up a RasPi 3 with 800x480 touchscreen and Touch UI

Postby DeltaCon » Tue Aug 30, 2016 4:24 am

DHCP gives out different addresses after the lease time has expired. At this time of year (after the summervacations) we frequently experience that users switch off printers and other networked apparatus, and after two or three weeks they "suddenly don't work anymore" ;-)

Lease time can be configured in DHCP and is mostly standardly configured as 1 day or 1 week. After that the device in question will most likely receive an other IP addres.

Personally I prefer to build a list of reservations in the DHCP server, because that also acts as documentation of your IP addresses. Also after switching Internet routers by your ISP (those guys don't consider anything!) your device wil get an IP address in the same range as your PC / laptop and that takes the hassle out of reconfiguring your equipment. Just a consideration of an IT guy ;-)
I am DeltaCon, I have a delta, my name is Con, I am definitely PRO delta! ;-)
Rostock V2 / E3D V6 / Raymond Style Heatchamber on the way!

PS.: Sorry for the avatar, that's my other hobby!

User avatar
Eaglezsoar
ULTIMATE 3D JEDDI
Posts: 7185
Joined: Sun Apr 01, 2012 5:26 pm

Re: How-to: Set up a RasPi 3 with 800x480 touchscreen and Touch UI

Postby Eaglezsoar » Wed Aug 31, 2016 1:16 am

This is excellent information and I thank you for taking the time to post it.
“ Do Not Regret Growing Older. It is a Privilege Denied to Many. ”

Qdeathstar
Printmaster!
Posts: 622
Joined: Wed Apr 13, 2016 7:42 pm

Re: How-to: Set up a RasPi 3 with 800x480 touchscreen and Touch UI

Postby Qdeathstar » Wed Oct 19, 2016 11:49 pm

Hi,

i am attempting this... but i am finding it frustrating. My Raspberry Pi displays blocks instead of letters for the font. Eg, if i type in "Q" instead of the letter Q, i get an evil looking square block... similar to what you'd see on a character display if you turn the contrast up to much....


It it show "octopi login" but when i type it is just squares... some letters, like 1 2 or 3 show up... I'm at a loss.

User avatar
rurwin
Printmaster!
Posts: 68
Joined: Sat Sep 24, 2016 10:43 am
Contact:

Re: How-to: Set up a RasPi 3 with 800x480 touchscreen and Touch UI

Postby rurwin » Thu Oct 20, 2016 4:47 am

That sounds like you have a font issue. It should be possible to configure Chrome to use a specific font instead of the one a web page mandates.


People trying this who are not in the USA may have an issue with getting WiFi working.
The WiFi standard allows different radio channels in different parts of the world. Over here in the UK we can use two channels that the USA can't and it's different again in Japan. The Raspberry Pi defaults to a safe legal configuration with the minimum number of channels, which will be a problem if your router has chosen one of the others.

To fix that you will need to select the Internationalisation options in raspi-config and tell it where you are.

Qdeathstar
Printmaster!
Posts: 622
Joined: Wed Apr 13, 2016 7:42 pm

Re: How-to: Set up a RasPi 3 with 800x480 touchscreen and Touch UI

Postby Qdeathstar » Thu Oct 20, 2016 11:50 pm

Thanks, I was able to change the keyboard settings via ssh and now i am up and running :D

Qdeathstar
Printmaster!
Posts: 622
Joined: Wed Apr 13, 2016 7:42 pm

Re: How-to: Set up a RasPi 3 with 800x480 touchscreen and Touch UI

Postby Qdeathstar » Fri Oct 21, 2016 4:32 pm

Got it going... Now printing a case... Would have had it done last night but it failed halfway though... Layer separation... Not sure what happened but I'm going to try to turn the fan.

TMIB
Printmaster!
Posts: 53
Joined: Mon Jan 11, 2016 4:58 pm

Re: How-to: Set up a RasPi 3 with 800x480 touchscreen and Touch UI

Postby TMIB » Tue Oct 25, 2016 4:37 pm

Thanks for writing this up! I ordered the parts and will be setting it up next week sometime. I'd love to see your take on a case and mount, too.

User avatar
626Pilot
ULTIMATE 3D JEDDI
Posts: 1716
Joined: Tue May 14, 2013 12:52 pm

Re: How-to: Set up a RasPi 3 with 800x480 touchscreen and Touch UI

Postby 626Pilot » Tue Oct 25, 2016 5:01 pm

I made a case for it. It was really nice! Unfortunately, I still hadn't been taking my own advice about how awful SketchUp is, so the model was ruined. That crappy program, as it is often wont to do, decided to move a vertex somewhere, throwing the entire thing out of whack by some fraction of a degree. I thought of all the time I had spent, hours of designing and printing and fixing, thrown into the trash.

That one event is what spurred me to finally move on to Autodesk Fusion 360. I've been going through some tutorials, and I've imported all my MAX Metal mods into it. I think I can have the custom enclosure for this done in November. In the mean time, you might want to do my dimensional accuracy calibration, so everything prints at exactly the right size.

BillyBlaze
Noob
Posts: 1
Joined: Mon Dec 26, 2016 10:23 am

Re: How-to: Set up a RasPi 3 with 800x480 touchscreen and Touch UI

Postby BillyBlaze » Mon Dec 26, 2016 11:08 am

First off thank you very much for this complete how-to, this is very helpful.

However, sadly some things have changed lately.
1) The chromium-browser has been added to the main repository. Adding bintray.com is now unnecessary, since the main repository has prio over bintray. You can combine the two 'apt-get install' and drop 'rpi-youtube'.
2) Depending on your OctoPi build you may need to upgrade the kernal to get the latest Chromium browser working. If you have issues with LSB-headers or starting Chromium, then please read step 9 from BillyBlaze's Boot to Browser


Return to “General Tips 'N Tricks”

Who is online

Users browsing this forum: No registered users and 4 guests