Archive for the ‘Uncategorized’Category

Configuring Pi 3 with a TFT touchscreen and GPIO buttons

A while back I built a pair of sound-reactive LED towers which were on display a few times, at some local Chicago events.

To plug into the DJ mixer output required a relatively expensive device to get the stereo signals (with external gain control) seen by a computer running processing.org as a microphone input.  Also, it was a relatively bulky affair to have yet another laptop sitting next to the mixer when the artist wasn’t using it to make the music.

Recently I discovered that starting with the 3.1 release, Processing can now run on a Raspberry Pi and has built-in ability to manipulate the GPIO ports.  This blog entry highlights the release.  This is exciting news as now the laptop can be replaced by a Pi 3 with a small touchscreen.

Here is a video of the light towers in action.

The towers each have 8 panels with 60 individually addressable RGB LEDs.  These pictures show off more of the visual esthetic and the cutaway view reveals something of the construction.  The LED strips are hidden in a channel in the wood supports which side illuminate acrylic panels (backed with just a strip of white cardboard).  The acrylic is impregnated with a diffuser which reflects the edge-lit light 90 degrees to exit out of the faces of the panels.  The white cardboard reflects the 1/2 of the light that would otherwise be directed inwards.   The acrylic is produced by Evonik and is called Acrylite EndLighten.  The towers themselves only require 110 VAC power.  The data frames to control the LED strips are sent wirelessly from the processing script using an Open Pixel Control  module which maps points on the processing screen into frames sent to a Fadecandy server running inside a OpenWRT Wifi device which is then physically connected to a Fadecandy board.  I used TP-Link TL-MR3040 WiFi devices to run OpenWRT and added the Fadecandy server application into the img file used to reflash the WiFi devices.  The Fadecandy GIT repository can be found here.

IMG_1689 IMG_1682

This is the assembled Raspberry Pi 3 w/ 2.8″ TFT Capacitive Touchscreen mirroring the HDMI frame buffer in a Zebra case without the top cover.

Pi 3 w/ 2.8" TFT Capacitive Touchscreen HDMI framebuffer

There were a lot of possible paths to follow in getting this build working the way I wanted it to be.  Most of my Google searching turned up outdated examples, particularly due to the changes introduced in the 4.4 kernel with /boot/config.txt use of overlays.  Adafruit had this very nice looking tutorial of how to get the touchscreen working with their version of the Jassie Raspbian os image.  The inclusion of how to use FBCP was of particular interest as mirroring the HDMI output is important for displaying processing scripts with the 2D or 3D graphics libraries.  Their Raspbian image was based on an older kernel and updating the os (sudo apt-get update; sudo apt-get dist-upgrade) turned out not to just work.

After much tinkering, these are the steps that worked for me.  (note that I working with OSX 10.11)

  1. Download the latest Raspbian Jessie image here.
  2. Extract the .img file using “The Unarchiver.app” as opposed to the built-in “Archive Utility.app” as I saw many comments that the default app caused issues.
  3. I chose a 32GB Samsung EVO Plus (model MB-MC32D) micro SD.  It has a red background.
  4. Flash the SD card with the extracted image file.  Instructions for doing this can be found easily.  I used the following procedure:
    • open a terminal window and change to the directory with the extracted image file
    • $ diskutil list
    • note the device path of the SD card (eg: /dev/disk4)
    • unmount the SD card, replace disk4 with what was discovered in the previous step
    • $ diskutil unmountDisk /dev/disk4
    • flash the SD card, again update rdisk4 and also make sure the if= filename is correct
    • $ sudo dd if=./2016-05-27-raspbian-jessie.img of=/dev/rdisk4 bs=1m
    • this will take at least 5 minutes to complete, but it is possible to see some status without interrupting the transfer, by pressing ctrl-t
    • exit the terminal window and eject the SD card
  5. Insert the SD card into the Pi and hook it up to an HDMI monitor.  You will need a keyboard and mouse as well.
  6. Open a terminal window
    • disable power management for the onboard WiFi module for stability
    • $ sudo nano /etc/network/if-up.d/wlan0
      #!/bin/bash
      iwconfig wlan0 power off
      
    • $ sudo chmod +x /etc/network/if-up.d/wlan0
    • $ sudo raspi-config
    • select Expand Filesystem and reboot
  7. Configure the WiFi as usual from icon at the top of the desktop
  8. Open a terminal window
    1. install updates
    2. $ sudo apt-get update
    3. $ sudo apt-get dist-upgrade
    4. install build utility
    5. $ sudo apt-get install cmake
    6. fetch the FBCP source, compile and install
    7. $ git clone https://github.com/tasanakorn/rpi-fbcp
    8. $ mkdir ./rpi-fbcp/fbcp/build
    9. $ cd ./rpi-fbcp/fbcp/build
    10. $ cmake ..
    11. $ make
    12. $ sudo install fbcp /usr/local/bin/fbcp
    13. configure the touchscreen by uncommenting, changing or adding the following config entries
    14. $ sudo nano /boot/config.txt
      # match console size
      framebuffer_width=640
      framebuffer_height=480
      
      # force 640x480 VGA on HDMI
      hdmi_force_hotplug=1
      hdmi_group=2
      hdmi_mode=4
      
      # 2.8" Capacitive 320x240 Touchscreen
      dtoverlay=pitft28-capacitive,rotate=90,speed=80000000,fps=60
      dtoverlay=pitft28-capacitive,touch-swapxy=true,touch-invx=true
      
    15. expose touchscreen events
    16. $ sudo nano /etc/udev/rules.d/95-ft6206.rules
      SUBSYSTEM=="input", ATTRS{name}=="ft6236", ENV{DEVNAME}=="*event*", SYMLINK+="input/touchscreen"
      
    17. select an easier to read console font
    18. $ sudo dpkg-reconfigure console-setup
      • UTF-8
      • “Guess optimal character set”
      • Terminus
      • 6×12 (framebuffer only)
    19. remove extra GLES library see this issue
    20. $ sudo aptitude remove libgles2-mesa
    21. install processing
    22. $ curl https://processing.org/download/install-arm.sh | sudo sh
    23. disable auto monitor-off
    24. $ sudo nano /etc/lightdm/lightdm.conf
      xserver-command=X -s 0 -dpms
      
  9. Reboot

The touchscreen should now display the 640×480 desktop scaled down to the 320×240 PiTFT screen.  This makes things look less crisp but has the advantage that connecting to an external HDMI display will work and that most apps need the larger dimensions be usable.  Note that many HDMI displays will not be able to handle a 320×240 HDMI signal.

FBCP stands for frame buffer copy, which rescales and mirrors the HDMI framebuffer (/dev/fb0) onto the PiTFT framebuffer (/dev/fb1)

The version of the 2.8″ PiTFT I got from Adafruit, comes with 4 buttons and I created this test Python script to demonstrate not only how to use the RPi.GPIO library, but how to manipulate the PiTFT backlight (so as to not burn-in the screen), use multi-threaded event handlers, and shutdown the os to safely disconnect the power.

I created this script as: /home/pi/pitft_buttons.py  (chmod +c pitft_buttons.py to make it executable) and test by typing ./pitft_buttons.py.  Note that pressing the bottom right button (#27) will ask for authentication for powering off the Pi.  See below to set this script running as a service, in which case, the user will not be asked for authentication.

#!/usr/bin/env python2.7

# example code tested with Pi 3
# Raspibian Jassie (4.4 kernel): https://www.raspberrypi.org/downloads/raspbian/
# Adafruit 2.8" Capacitive Touchscreen: https://www.adafruit.com/products/2423
# for running on startup see: https://learn.adafruit.com/running-programs-automatically-on-your-tiny-computer/systemd-writing-and-enabling-a-service
# make sure to update the ExecStart= entry in the Adafruit script after copying from the example

import subprocess
import time
import RPi.GPIO as GPIO

# list of BCM channels from RPO.GPIO (printed on the Adafruit PCB next to each button)
channel_list = [17, 22, 23, 27]
backlightOn = True

# event handler to toggle the TFT backlight
def toggleBacklight(channel):
    global backlightOn
    if backlightOn:
        backlightOn = False
        backlight.start(0)
    else:
        backlightOn = True
        backlight.start(100)

# event handler to manage button presses
def buttonEvent(channel):
    startTime = time.time()
    while GPIO.input(channel) == GPIO.LOW:
        time.sleep(0.02)
    print "Button #%d pressed for %f seconds." % (channel, time.time() - startTime)

# event handler to manage Pi shutdown
def poweroff(channel):
    startTime = time.time()
    while GPIO.input(channel) == GPIO.LOW:
        time.sleep(0.02)
    if (time.time() - startTime) > 2:
        subprocess.call(['poweroff'], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

# initialize GPIO library
GPIO.setmode(GPIO.BCM)
GPIO.setup(channel_list, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(18, GPIO.OUT)
backlight = GPIO.PWM(18, 1000)
backlight.start(100)

print "Button #17 exits."
print "Button #22 toggles the TFT backlight."
print "Button #23 displayed the time the button is pressed."
print "!!! Pressing button #27 for at least 2 seconds, powers down the Pi !!!"

GPIO.add_event_detect(22, GPIO.FALLING, callback=toggleBacklight, bouncetime=200)
GPIO.add_event_detect(23, GPIO.FALLING, callback=buttonEvent, bouncetime=200)
GPIO.add_event_detect(27, GPIO.FALLING, callback=poweroff, bouncetime=200)

try:
    GPIO.wait_for_edge(17, GPIO.FALLING)
    print "Exit button pressed."

except:
    pass

# exit gracefully
backlight.stop()
GPIO.cleanup()

To install pitft_buttons.py as a service,

# pitft_buttons service file, start a daemon on startup
# file: /etc/systemd/system/pitft_buttons.service

[Unit]
Description=Start PiTFT buttons daemon

[Service]
RemainAfterExit=true
ExecStart=/usr/bin/python -u /home/pi/pitft_buttons.py

[Install]
WantedBy=multi-user.target

Run a processing sketch from a script or from a terminal window or ssh session.
$ DISPLAY=:0 processing-java –sketch=/home/pi/HelloWorld –present

16

07 2016

Of Biscuits and Pirates

A lively assist!

A lively assist!

Hark! Saturday eve a few weeks past our dear “Spoons” (AKA Gerald Gayares) held a feast of hearty proportions! Eggs were broken, strawberries destemmed, chives snipped, and oh the mushroom boiling! He was valiantly assisted in this effort by Shelly “Pickles” Gayares and a smattering of the Mighty Crew of PS:One who were drafted to the event.

 

A Hearty-har-har Hardtack

A Hearty-har-har Hardtack

Ye may be asking then: how to can I provoke such a feast of glory of mine own?

1: Firstly ye must be WISE! Tender biscuits and crispy yeasty waffles are not the product of a few hours of careless abandon. Ye must plan for your journey so as to have on hand all the necessary apparatus, provender, and mates to accomplish your goal. Spoon’s yon tender-crisp waffles had begun some twelve hours in advance! Supplies were amassed over the whole of the week. Mark yer book of accounting with a list of needs and wants. Timing be’ critical.

pirated-me

Gather A Crew!

2: Secondly ye must be BOLD and Seductive! Declare yer intentions. Claim thy time and place with loud hollering. Alert thy comrades old and new. Do ye be thinking that a person shall attend the quiet church mouse squeaking out a proclamation of a tidy crumb to be nibbled? NAY I say! Go instead to the weekly meeting and bellow out “FEAST” so that all may know of yer intended soiree. (In our case it be more like a sortie…) Then go to the town square (Google Groups) and post a list declaring your nefarious goal along with any needs of supplies and crew. If-n’ ye be the timid sort or of short time then promote yer-self a good first mate to advocate for your cause. There be’ many a good mate to be had at this port, especially for the cause of a good feeding.

 

pot-o-mushrooms-before

Pot-O’ Mushrooms

mushroom-gravey-after

Pot-O’ Victory

3.Thirdly ye must be STRONG! The day of yer tasty battle will not be kiddy pools and microwaves. There will be fire, a broad side of gloriously dirty dishes, and absent baking soda all bent on thwarting yer merrymaking. Command thy crew with vitality and they will follow you to the depths of this Cursed Sea and to the grocery store no matter what behemoth lays in wait, as long as they get fed.

 

 

 

 

 

With the aforementioned application of Wisdom in planning, and Boldness for comrades, and Strength in application ye shall have all a person needs to attain a tasty conquest. This is after all a maker space: Just do it.

waffly-goodness

Aged Yeasty Waffles of Joy

16

06 2016

House Number

This was a simple project that took a lot longer than it should have. Nothing fancy, just numbers welded from 1-1/4″ mild steel stock and 3/32 rods. Some of you may have seen me tackle it a few months back in the hot metals area. Due to a total lack of free time, I only now installed it on my house.

20160529_140934(1)

The rods are painted a color approximating the brick, making the numbers “float” about 1-1/2″ from the face of the wall.

31

05 2016

Yes, You Can (Document Small Projects)!

light cube

WP-White-Bar-550x10

Mohamed Dardiri took a professional looking photograph of a laser cut design he made and it was getting likes on Pinterest within minutes. You can do this, too! Photographing small projects using one of our light cubes gives you a nice, even lighting without any harsh shadows.

Read the rest of this entry →

30

05 2016

Event: Confectionery Combat! Chocolate VS Shelly and Gerald

shelly-and-gerald-vs-chocolate-smaller

 

What:
Confectionery Combat! Chocolate VS Shelly and Gerald:

When:
Friday February 12, 6:30-8:30 pm

 

We will start with a discussion on the evil ways of this culinary foe and tactics to successfully wage war against it.

We will be making truffles, roasting nuts, coating lots of things with chocolate, and “practicing” our feeble double boiler tempering skills.  Practice is the word! Just as in war there is no guarantee of success but at least in this we will have chocolate.

This event is open to PS:One members and their guests who want to watch, sample, and participate as the space allows. (There will probably be a cap at 10 people in that small kitchen) If you know you are coming give us a holler on the member group here so we can prepare excess supplies and plan our battle strategy.  The cost is free but donations to fund our efforts will encourage more such campaigns.

06

02 2016

Group Project: Making Toolboxes

20160121_232528Last Monday, NegativeK got the funny idea that he wanted to do a project to practice his sheetmetal work. 20ga mild steel sheet was ordered, and we collected in cold metals to make some very expensive tool trays.

 

Making a project like this, is a bit of a puzzle. Before we get to the tough stuff, we first do layout. 20160121_213737 Here’s Toba wishing we had a printer that would do the layout for him.

Once we all finished drawing lines all over our sheetmetal we had to come up with how we were going to make all the cuts.
20160121_201027That’s an 8″ shear. It makes cutting sheemetal a magical experience. It’s quiet, smooth, and pretty easy to control. The only thing to remember, is it’s like working with the tip of a pair of scissors. It cuts a long way in front of where you “see” it cutting, and if you reach the end of the cut, it makes a punch mark. Just… it’s steel instead of paper.

That does mean making inside cuts is a bit of a challenge. We all had unique approaches to dealing with the inside corners. Now that we have three and a half toolboxes, I think that the “best” method, would have been drilling holes at each inside corner. Instead, I twisted and wiggled out the metal, and used a file to clean up the corner.
20160121_213731Here’s my tool tray blank. All of the fold lines are marked, and it’s sitting on top of my tool tray handle. I didn’t get good shots of how we did the handles. They were definitely easier than the body of the tool tray. To go from that flat sheet of metal, to a three dimensional tool tray, requires a sheet metal brake.

20160121_221810Here’s Toba setting up to do his bends. NegativeK found that our brake won’t do seams well. As if that would stop us. We all ended up using a hammer to finish those folds.

Those folds were simple in description, but not so simple in practice. None of ours look machine made. But they do hide the sharp edges, and make the tool trays safe to use.
20160121_231527The handles, and sides were affixed to each other with the space’s spot welder.

Spot welding is a very quick method for joining metal. I’m glad we’ve got that tool in the space. I had suggested that we might rivet the parts together, but between drilling and attempting to rivet, we’d have spent two or three times longer affixing the parts together.

The welds also have the air of “professionally made.” Or at least “not in a garage” made.

20160121_232535At the end of the night, Here’s what we had. TachoKnight, Toba, NegativeK, and My boxes.
20160121_232418In the future, we won’t put the short guy furthest from the camera.

 

22

01 2016

NERP Tonite! systemd with Bonnie King

NERP is not exclusively Raspberry Pi, the small computer and embedded systems interest group at Pumping Station:One in Chicago. NERP meets every other Monday at 7pm at Pumping Station:One, 3519 N. Elston Ave. in Chicago.

Bonnie King is a Linux Administrator at Fermilab and works on the Scientific Linux distribution. At Nerp tonight, Bonnie will give us a tour of systemd. If you work with embedded linux, this is must have, must know material.

The architecture of systemd as it is used by Tizen. Several components, including telephony, bootmode, dlog and tizen service, are from Tizen and are not components of systemd

The architecture of systemd as it is used by Tizen. Several components, including telephony, bootmode, dlog and tizen service, are from Tizen and are not components of systemd

“Linux” is the kernel of an operating system. You generally can’t see it, feel it or touch it directly, but you know it’s there by what it does. At boot, the kernel launches “init”, the process with Process ID number 1. Everything else is started by by init. On my computer, init, PID 1 is /lib/systemd/systemd. systemd is “new”, sort of. It’s been around for several years, but has recently taken over lots of core system functions that have been provided by some very traditional Unix-based tools and utilities. When I look under the hood of my Ubuntu system, it looks very different than it did a couple of years ago. What goes for the desktop goes for embedded, too.

from http://freedesktop.org/wiki/Software/systemd/
“systemd is a suite of basic building blocks for a Linux system. It provides a system and service manager that runs as PID 1 and starts the rest of the system. systemd provides aggressive parallelization capabilities, uses socket and D-Bus activation for starting services, offers on-demand starting of daemons, keeps track of processes using Linux control groups, supports snapshotting and restoring of the system state, maintains mount and automount points and implements an elaborate transactional dependency-based service control logic. systemd supports SysV and LSB init scripts and works as a replacement for sysvinit. Other parts include a logging daemon, utilities to control basic system configuration like the hostname, date, locale, maintain a list of logged-in users and running containers and virtual machines, system accounts, runtime directories and settings, and daemons to manage simple network configuration, network time synchronization, log forwarding, and name resolution.”

A number of influential people in the Linux community have strong philosophical and practical differences with the design of systemd and the way in which it’s become ubiquitous across distros. Nevertheless, mainstream Linux continues to move toward systemd and away from System V and BSD init. systemd is installed by default in Ububntu since ver 15.04. (April 2015). If you work with Linux at a low level, for instance in embedded applications, a knowledge of systemd is a must have.

Find NERP and Pumping Station:One at

NERP – Not Exclusively Raspberry Pi

Chicago, IL
399 members

NERP is Not Exclusively Raspberry Pi, the small computer and embedded systems interest group at Pumping Station One in Chicago. (Chicago’s oldest and finest hackerspace.) NERP…

Next Meetup

Bring questions, demos, personal research, etc. to share.

Monday, Jan 18, 2016, 7:00 PM
10 Attending

Check out this Meetup Group →

and
http://pumpingstationone.org/

Doors open at 6:30pm.
NERP is free and open to the public.
Ed Bennett ed @ kinetics and electronics com
Tags: electronics, embedded, NERP, Open Source, Linux,
raspberry pi, hackerspace, Beagle Bone, Pumping Station One

18

01 2016

NERP TONITE! Drew shows us the C.H.I.P. $9 Linux SBC!

NERP is not exclusively Raspberry Pi, the small computer and embedded systems interest group at Pumping Station:One in Chicago. NERP meets every other Monday at 7pm at Pumping Station:One, 3519 N. Elston Ave. in Chicago.

In 2012 the cheapest Single Board Computer that could run Linux cost around $150.00. The prospect $35 Linux SBC with HDMI was loney talk. If it wasn’t vaporware, it certainly couldn’t be sustainable, we thought.

CHIP-computer

The RPi and its cronies and successors are very much here to stay. Even so, a $9 credit card sized linux SBC seems a bit “out there”, but here comes the C.H.I.P “The world’s First $9 Computer”.

The C.H.I.P. hasn’t shipped in volume yet, but Linux kernel hackers have been able to order alpha versions for testing and for fun. Tonight at NERP, PS:One’s Drew Fustini will demo his new C.H.I.P. board. Is it another game changer? We’ll see!

https://www.kickstarter.com/projects/1598272670/chip-the-worlds-first-9-computer.

NERP is not exclusively Raspberry Pi, the small computer and embedded systems interest group at Pumping Station:One in Chicago. NERP meets every other Monday at 7pm at Pumping Station:One, 3519 N. Elston Ave. in Chicago.

Find NERP and Pumping Station:One at
http://www.meetup.com/NERP-Not-Exclusively-Raspberry-Pi/
and
http://pumpingstationone.org/

Doors open at 6:30pm.
NERP is free and open to the public.
Ed Bennett ed @ kinetics and electronics com
Tags: electronics, embedded, NERP, Open Source,
raspberry pi, hackerspace, Beagle Bone, Element14, Pumping Station One
Tags: Beagle Bone, electronics, Element14, embedded, hackerspace, NERP, Open Source, Pumping Station: One, raspberry pi

26

10 2015

Why Discourse?

Why Discourse?

I’m not sure people understand maintenance burden.

Google groups has been a maintenance headache. Probably one of the smaller maintenance headaches, but still a problem.

With most of the system’s that PS:One has developed over the last several years, new member handling, auto admining of the 40 or so systems group member’s, etc has been automatic.

PS:One cycles through motivated individuals pretty quickly. If we ever come across a gap between an old productive member and a new ones, we lose something. There are a few ways to handle this: One is to stop burning people out, and to make sure that gap doesn’t exist. The other is to reduce the amount of information that can fall in that gap.

Per application user management is a great way to burn out technologically creative individuals. I’ve seen it happen a few times.

Our current systems approach is to reduce maintenance burden to deal with the first problem. The other is to make most of the tasks a systems person needs to carry out be automatic. Google Groups has not presented us with much as far as solutions to deal with these 2 problems. They offer no api to add or remove subscribers, and are notoriously difficult to write scraping tools for, and offer no guarantee of long term stability for scraping tools.

We have investigated a few potential solutions for mass communication in the membership. Most of these focus on web forum technology, as we are hitting the magic threshold where mailing lists are no longer the right solution due to message volume. So far discourse is the most promising.

Jeff Atwood Is one of the main developers and founders of discourse. Previously he started stack overflow with Joel Spolsky (the Joel on Software guy), and has been running a blog called coding horror since about 2004. He’s got some experience with online communities and a lot of opinions and practical experience on what makes them work well and what doesn’t, including a few very well known implementations of online discussion platforms. I don’t always agree with his technical and social decision minutia, but I have to understand that he’s coming from a wealth of experience, and has left the discourse discussion platform open to plugins and extension.

https://discourse.pumpingstationone.org

20

09 2015

Hack a Replacement Wacom Tablet USB Cable

usb-cable-hack

 

WP-White-Bar 550x20

Did you lose the USB to USB Micro B cable that connects your Wacom pen tablet to your computer? Don’t panic! This is not necessarily another propriety piece of equipment you can only get from the manufacturer. There is a quick fix.

The cable that comes with the Wacom may alarm you to have lost it; it looks unique, since the smaller Micro B end has a 90 degree angle turn. This is a design element possibly for aesthetics and maybe to prevent the cable from pulling out easily from the tablet while it is in use. You do not need a replacement cable exactly like the one that shipped from the manufacturer. What you need is a replacement cable that fits.

This is where cable replacement gets tricky because the Micro B port on the tablet is deep and very narrow. Most cheap, off the shelf cables have both ends encased in a massive brick of rubber that will not fit the tiny 6 mm tall by 12 mm wide Wacom Micro B opening. You can take any old cable and make it fit by whittling down the rubber as close as you can to the metal. A box cutter with a sharp, new blade works well. I tried to improve the look of this hacked cable with a single wrap of electrical tape, but had to then remove the tape as that still made the Micro B end too thick to attach.

If you want a neater cable to use for the long term, beyond this DIY quick fix, step away from the cable aisle in your electronics store and head over by the cell phone accessories. The Micro B cables marketed for smartphones tend to have a sleeker design, more color choices and smaller rubber grips which will insert into the Wacom. Bring your pen tablet with to make sure the cable you select will fit before you leave the store. Also, be sure you get a combined data and charging cable, since charging only cables that look similar are usually in the mix of products for cell phones.

03

09 2015