8bit [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=38294 Waveshare 128x128 pixel LCD display with controller is perfect for Pico-8 <img style="margin-bottom:16px" border=0 src="https://www.lexaloffle.com/bbs/files/38294/waveshare.png" alt="" /> <h3>At 128 x 128 pixels, the Waveshare 1.44 inch display with controller is a perfect fit for Pico-8.</h3> <p>The screen Driver being installed, requires a Waveshare 1.44&quot; 128x128 pixel colour LCD display, with joystick &amp; 3 buttons which utilises an ST7735S controller.</p> <p>Amazon UK link: <a href="https://www.amazon.co.uk/gp/product/B077YK8161">https://www.amazon.co.uk/gp/product/B077YK8161</a><br /> Amazon US link: <a href="https://www.amazon.com/waveshare-1-44inch-LCD-HAT-Interface/dp/B0781BNC9L/">https://www.amazon.com/waveshare-1-44inch-LCD-HAT-Interface/dp/B0781BNC9L/</a></p> <p>Built, tested and confirmed working with both Raspbian Stretch lite and Buster lite-based images.</p> <p>Begin by writing a fresh Raspbian Stretch or Buster Lite image to a 4GB or larger MicroSD card using your favoured image writing tool.</p> <h3>Caution:</h3> <h3>Raspbian Buster appears to generate more heat after short periods on a Pi ZeroWH than Stretch does.</h3> <h3>Whichever image you begin your build with, please monitor CPU temperature during use. I won't be held responsible for a baked Pi!</h3> <p>A Pi ZeroW can be set-up headless if a properly configured &quot;wpa_supplicant.conf&quot; and a blank file named &quot;ssh&quot; are copied to the root of the MicroSD card, after writing the image but before unplugging and inserting into the Pi.</p> <p><strong>ON FIRST BOOT</strong></p> <p>SSH into the Pi or plug-in a keyboard and monitor. Login with username &quot;pi&quot; and password &quot;raspberry&quot;</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>sudo raspi-config</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p><strong>Expand the filesystem<br /> Set boot to CLI with auto-login<br /> enable SPI<br /> disable VNC<br /> disable serial</strong></p> <p>I recommend changing the default password from &quot;raspberry&quot; to something more secure while you're still in raspi-config.</p> <p>You may also wish to change the hostname while you're in here. I named mine pico8, so I can ssh to pico8.local from other machines for maintenance.</p> <p>Exit raspi-config and reboot with</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>sudo reboot</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Once rebooted, login as pi, then update and upgrade the OS and programs:</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>sudo apt-get update sudo apt-get upgrade</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Reboot once again and re-login if recommended by the upgrade process</p> <p><strong>Let's begin by getting Pico8 running on the Pi</strong></p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>sudo apt-get install libasound2-dev wiringpi wget https://t.co/jZy96cDeCC?amp=1 -O sndio-1.2.0.tar.gz tar -xf sndio-1.2.0.tar.gz cd sndio-1.2.0 ./configure make sudo make install cd ~</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p><strong>Use SFTP (or USB) to transfer your personal Pico download zip file into /home/pi folder</strong></p> <p>Unzip your Pico8 Raspberry Pi zip file into /home/pi.<br /> This should create a /home/pi/pico-8 folder, which will contain all of the files required to run Pico8.</p> <p><strong>Now we&rsquo;ll get the Waveshare 1.44&quot; 128x128 pixel LCD display hat working on the Pi</strong></p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>cd ~ sudo apt-get install git 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 cd ~ wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.59.tar.gz tar zxvf bcm2835-1.59.tar.gz cd bcm2835-1.59/ ./configure make sudo make check sudo make install</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Open and edit the modules file to enable the additional modules required to make the LCD function.</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>sudo nano /etc/modules</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Append the two lines below to the end of the file, save and exit.</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>spi-bcm2835 fbtft_device</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>We need to create a new file for the fbtft configuration</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>sudo nano /etc/modprobe.d/fbtft.conf</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Add the following lines to the empty file and save it.</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre># /etc/modprobe.d/fbtft.conf options fbtft_device name=adafruit18_green gpios=reset:27,dc:25,cs:8,led:24 speed=40000000 bgr=1 fps=60 custom=1 height=128 width=128 rotate=180</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Fortunately for us, Adafruit created a GPIO controller driver, so let's use this to make the Waveshare hat's controller and buttons work in pico-8.</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>cd ~ curl https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/retrogame.sh &gt;retrogame.sh sudo bash retrogame.sh</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>On the option screen, Select &ldquo;6 buttons + joystick&rdquo;. We&rsquo;ll edit the resulting config file a little later to fit the 3 button and joystick layout of our hat.</p> <p>Once installed; at the reboot prompt, type &ldquo;N&rdquo; so as NOT to reboot your Pi.</p> <p>Now we&rsquo;ll edit the configuration file installed and used by Adafruit&rsquo;s retrogamer driver, to configure the correct number of buttons for the Waveshare hat.</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>sudo nano /boot/retrogame.cfg</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Use CTRL-K to remove all lines from the file and paste the following lines into the now empty file before saving it and exiting nano.</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>LEFT 5 # Joypad left RIGHT 26 # Joypad right UP 6 # Joypad up DOWN 19 # Joypad down Z 20 # Button 3 X 16 # Button 2 ESC 21 # Button 1</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Please ensure each entry is on a separate line as displayed above.</p> <p>At this stage, we can set the correct display settings for the Waveshare 128x128 LCD within the file config.txt</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>sudo nano /boot/config.txt</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Add to the end of the file and beginning on a new/empty line, the following lines:</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>display_rotate=1 hdmi_group=2 hdmi_mode=87 hdmi_cvt=128 128 60 1 0 0 0 hdmi_force_hotplug=1</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Save the file and exit nano.</p> <p>Now let's put this all together and have Pico-8 run in &quot;splore&quot; mode at boot.</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>sudo nano /etc/rc.local</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>This file should should be as below. (All we're adding to the file are three lines near the end, each beginning with sudo):</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will &quot;exit 0&quot; on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. # Print the IP address _IP=$(hostname -I) || true if [ &quot;$_IP&quot; ]; then printf &quot;My IP address is %s\n&quot; &quot;$_IP&quot; fi sudo /usr/local/bin/fbcp &amp; sudo /usr/local/bin/retrogame &amp; sudo /home/pi/pico-8/pico8 -splore &amp; exit 0 </pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Save this file and exit nano.</p> <p>Shutdown and power-off the pi with</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>sudo shutdown now</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Wait for the pi to shutdown, unplug the power-cable and connect the Waveshare LCD hat onto the GPIO connectors.</p> <h3>Be careful to connect the hat in the correct orientation, onto all 40 GPIO pins.</h3> <p>Plug-in, power-up and enjoy all colourful 128x128 pixels of Pico-8 glory on a tiny, square display and in complete silence!</p> <p>Connect the Pi to the Internet via Wi-Fi (ZeroW), then use the joystick and KEY2 to update and download Pico-8 programs directly to the Pi.</p> <p><strong>KEY1 functions as Escape<br /> KEY2 functions as X<br /> KEY3 functions as Z</strong></p> https://www.lexaloffle.com/bbs/?tid=34934 https://www.lexaloffle.com/bbs/?tid=34934 Sat, 03 Aug 2019 11:33:01 UTC