I Like Big Buttons

The Premise

In early 2018, my friend Steve had an idea.  His church supports missionaries, and for fundraisers, they sell lunches to the congregation.  In the past, they had volunteers prepare and serve the food.  It was a lot of effort, and Steve thought that it could be improved.  He thought that having a restaurant make the food would allow them to charge a bit more for the food, and might draw more attention.  He was right of course, and now he wanted a way to engage the participants even more.  He wanted some kind of visual progress indicator.  something that would get people excited about participating in supporting the cause.

“What if we had a big button that people could push when they buy a lunch, and then have a big display of how many lunches we’ve sold?”

That sounded like a cool idea to me.  So, I set out to build just that.

The Architecture

button box setup
If this is a smart TV with a browser, the laptop can be eliminated

I tried to make this as simple as possible. No, really I did!  However, the constraints of the environment dictated otherwise.  I thought the simplest thing would be to have a button attached to a Raspberry Pi, which would be attached to a screen via an HDMI cable.  However, the display needed to be relatively far away from where people would be paying for lunch, and running a long HDMI cable was not acceptable.  Steve mentioned that they had an extra laptop that they could connect to the TV, so this seemed like a reasonable solution.

After some noodling, I decided that I’d have a big button box with a Raspberry Pi inside. The Pi would host a web server that publishes a page with the count on it.  The laptop connected to the TV would access the web page and display it on the TV.

Is this the simplest design?  Not by a long shot.  Would it be fun to build?  Absolutely!  I also like the idea that this solution is self-contained.  If the TV has a browser, then the laptop can be removed from the setup.

The Button Box Design

large button
That is one big button!
lit button
Ooh! Shiny!

The hardest and most interesting part of this project to me was the button box.  I’d been itching for a project to use the laser cutter at our makerspace, theLab.ms.  While I could have just used a tool to generate the dimensions of the box with appropriate notches for assembly, I decided it would be fun to figure it out on my own.  Here’s what I wound up with…

2D OpenSCAD layout
the 2D primitives in OpenSCAD were perfect for this project!

I made the first prototype with cardboard, which worked out perfectly!

Cardboard prototype
looks good so far!
cardboard prototype assembled
Everything fits with a reasonable amount of space for wiring

Happy with the results, I moved on to the 2nd prototype, which was made out of MDF scraps at the makerspace (I think I also got some hardboard in there, too).

MDF prototype bottom
All the holes lined up! The square plate on the lower left is the shutdown button.
detail on shutdown button
I mounted a momentary contact button upside down to serve as the shutdown button

Since this button box would be operated by non-technical folks, I decided I should add a shutdown feature to prevent damage to the SD card.  When the button is held for 2 seconds, a shutdown command is sent to the Pi.  Of course, nothing stops the user from just disconnecting power, but at least the capability is there.  Since the Pi doesn’t have any built-in capability to shutdown the OS, I added a momentary contact button to the bottom of the box to serve this purpose.

Everything was going great until I received my acrylic sheets.  I thought I was getting 3mm acrylic sheets, but I actually ordered 2mm acrylic sheets.  *sigh*.  But thankfully, I made the material thickness a variable in my OpenSCAD model, so I just needed to change that variable from a 3 to a 2, and adjust the placement of the power connector hole (that took a bunch of trial and error).

off my 1mm
PSA: 3mm does not equal 2mm

After the adjustments, I re-cut the box from the spare sheet of acrylic (always a good idea to get more than you absolutely need in case you make a mistake!).

final internal wiring
I really like the Perma-Proto hats from Adafruit!

To keep the wiring nice and clean, I used a Perma-Proto hat from Adafruit. I’ve used them in a few projects now and I’m hooked.  For the relatively small circuits I’m making, they’re perfect, and don’t add much to the footprint of the project.

finished box unlit
I like the way it turned out! Unfortunately, you can see along the top front edge where the acrylic cement leaked and marred the surface. A little acrylic cement goes a long way.
finished button box powered on and lit up
Who can resist a giant shiny button?

The RESTful Web App

I really enjoy projects that involve physical builds as well as software.  In the spirit of over-engineering things, I decided to make my counter a RESTful Web Service.  You can find the source code on bitbucket.  When the big button is pressed, python code sends an HTTP request to the web server, incrementing the stored count.  The web page showing the count updates every 1/2 second.  For the shutdown, holding the button on the bottom of the box sends another request that executes a graceful shutdown of the web server and the Raspberry Pi.

A Demonstration

Here is the whole thing in action!

Next Steps

  • Test it out in the target environment
  • I’d like to make the typeface fixed-width
  • There is code to set a target number.  I’d like to add some animation that is triggered when the goal is reached

did I mention I’m an idiot?

Oh, so the reason for my last post? I’m ashamed to admit this, but here goes…

One of the things that really irked me about Windows® was that there seemed to be no respect for what the user was doing. Popup windows or dialogs always took focus. This annoyed me to no end. Once I started using the Mac, I felt respected. Usually dialogs would pop up, but not take focus. Of course, this has its drawbacks, but it kept with the “OSX stays out of your way” concept that I appreciated.

Unfortunately, not all apps behave this way (Colloquy, I’m looking at you). So this morning, I’m logging in to IRC, and Colloquy pops up a dialog for my password (and it keeps *not* saving it – ugh). so I start typing. I’m not quite a touch typist, so I don’t always look at the screen. Next thing I notice is that an IRC window is up, and I’ve just typed my password into the IRC channel. Gah!!!!

So, I had to go and change passwords and update them in my passwords file. Let the comedy of errors begin.

<EOL>

grep saves the day…

first off, I’m a total idiot. I was updating my passwords file that I keep encrypted. However, when I went to remove the old file, I typed in the new file’s name and deleted it instead. D’oh!

well, as you might know, unix-like systems do not have an “undelete” facility. When you delete a file, it’s gone. Or so they say.

When you create a file on a unix-like system, or more specifically, an indexed file system, there are entries stored somewhere on disk that tell you (and the rest of the system) how and where to find those files. When you delete a file, that information is gone (depending on filesystem). Now, to the standard user, there is no way of knowing where that file is. In fact, parts of that file could be strewn over different parts of the disk. Things are sounding pretty grim, huh? To make matters worse, when new files are created, there’s the possibility that old files are being overwritten with new data.

“grep” is an old, old unix program that allows you to search for specified strings or regular expressions (e.g. any line containing the word `idiot`) in files. Well, those unix guys were pretty smart when they decided that “everything is a file”, including hard disks. So, you can ask grep to search the file that represents the hard drive in question and search for known strings.

The end result is that I retrieved my passwords (and thus, saving my marriage). It doesn’t change the fact that I’m a total idiot. In fact, knowing that I can recover data this way is probably going to ensure that it happens again. Oy.!

<EOL>

‘C’ is for Cookie…

‘C’ is for Cookie

Who doesn’t love credit card rewards points? By spending money, you receive "money" back. We’re being rewarded for our rampant consumerism and being encouraged to increase the madness. Ah, the smell of commerce. Anyway, I noticed that our CC has a program by which you can get bonus reward points for each dollar spent. Now, to receive these bonus points, you cannot merely spend your money at the places with which our Fine Institution® has made agreements. Oh no. You have to start your shopping session in their "special" mall.

So, I got to wondering how this was done. And so, a geek challenge was born. I suspected that they set cookies to achieve this tracking. So, I first set my browser to prompt me whenever a website wants to set a cookie. I then cleared all my cookies (you may not want to do this unless you’re really curious. You’ll find yourself setting preferences at each web site you frequent if you clear your cookies). With that done, I left the window that views cookies open, so I could inspect them as they are set.

10 page views and about 50 cookies later, I finally saw the cookie that tells the vendor to notify our Fine Institution® that the purchase was made after visiting their special mall.

This raises a serious problem. Let’s say I’m a paranoid user, and I don’t like cookies being set. In fact, I disable cookies for all sites. I don’t even want to see them. No cookies, no way for the vendor to see that I started off in the special mall. Hmmm. That’s not good. I want my points. So, does our Fine Institution have anything to address this issue? I didn’t see anything on their site, so I’m assuming they do not. I’ll call their customer service when I have a chance and am feeling particularly self-loathing.

Also, what happens if I have a link to said vendor that is specific to myself or my organization? Do I not qualify for the bonus points?

In reality, it’s pretty rare that someone completely disables cookies. It would be very difficult to survive on the modern web without them. I mean, in the few page views within the site of our Fine Institution®, I must have accepted at least 20 different cookies from no less than 5 different IP addresses.

Gone are the days of the stateless web. Yes, HTTP is still a stateless protocol, but the experience sure isn’t anymore.

<EOL>

Drupal Camp NYC 3 wrapup

Whew, Drupal Camp was like taking a drink from a waterhose. I met all kinds of folks from all levels of expertise. There were even Rails people there (gasp!). Anyway, I caught the tail-end of the performance discussion, attended an advanced theming session, and debated the downsides of server-side browser sniffing.

Overall, it was a great experience, and I’m pretty psyched about developing some new features for my own Drupal-based sites. In fact, I’m in the midst of redesigning therac25.net in Drupal. So, wiredgeek and I came up with a little rhyme that really succinctly states how I feel about Drupal:

Rose are red,
Drupal is blue.
PHP sucks,
but what can you do?

Session 2

1:21PM – Beginning modules. Finally some meat. I have been interested in developing my own modules for a while, but never knew where to get started. Here we go:

  • use api.drupal.org
  • hooks – create a dir for the module
  • create module_name.info file
  • create module_name.module file (no closing php tag, start with it, but don’t end with it)
  • if you’re creating something that makes new tables, you need a .install file. When you install and enable a module the first time, Drupal runs the hooks in the install file. The hook name is the name of the module file
  • in the uninstall file, free any variables you create
  • hook_nodeapi – operations on nodes that your module does NOT manage (on pre-existing node types) you can change weight to change execution order
  • hook_form_alter – cool

First Session

12:00 PM – CiviCRM – a few guys sitting in a room talking about CiviCRM, led by a guy who works for a competing CRM product. No one really knows a lot about CiviCRM, but we’re talking about various features and “what is it?” kind of stuff.

Drupal Camp NYC 3

10:19 AM – This is my first “unconference”. So far, we’ve had bagels and are now signing up/creating sessions for the day. It’s pretty chaotic, but that’s the beauty of it. Ken and I were thinking of doing this for a Rails Camp. Call it RuBarCamp or something.

lightbulb moment about iPhone and Safari for Windows ®

So, I watched the WWDC keynote, and I was like, “Why is Safari for Windows such a big deal that it is the ‘one last thing’ in Steve’s keynote?”

Well, it just hit me as I was reading this. Safari on Windows isn’t there to draw users to the Mac experience, it’s there so that people developing web apps for the iPhone have something to test with. The iPhone uses a “full version” of the Safari engine. Of course this needs to be tested, since each browser has its own quirks. There was no other way to test for safari than to buy a Mac. Until now.

Okay, now I can relax.

<EOL>

the “wow” starts now ™

The other night, I was chatting with Ken, and he mentioned that he was considering a purchase of Vista to run under Parallels on his new MacBook Pro. Being the loving friend, I naturally went into intervention mode. A few days later, I checked in with him. This is what Vista will do to a man…

KEN: still didn’t buy the license for Vista
it turns out that parallels has this setting to disable the pc clock
so XP never thinks it has to activate itself

MF54: nice!

KEN: still might buy it anyways
just to get some experience with vista

MF54: haha
you’re a glutton for punishment
tell you what
you give me $20
I’ll kick you in the nuts a few times
should be about the same experience

KEN: if I give you more money, will you give me the “ultimate edition”?

MF54: totally