Clay Dowling's Occasional Musings

I'd love to say that I'm gonna be a power blogger with lots of important stuff to say, so that I could promise weekly or even daily postings. The reality is that I'm a dude with a job and a family and too many hobbies, so you'll get posts when I really have something to say. Occasionally they'll even be worth reading.

Better Tests Through Mocking

www.larkwire.com_static_content_images_ipad_lbna1_northernmockingbird.jpg

If you have even a moderately complex application, writing tests can be a real pain. You either wind up writing complex, fragile tests, or you skip it altogether. There is a third path: fake out all of the parts that you aren't testing in this test. You can examine the fake parts to see what has been done with them, and you can make them respond however you want to your program.

→ Read more...

2016/02/10 22:43 · clay · 0 Comments

Reading Buttons with GPIO

One of the better things to do with a GPIO bus is read inputs. The Raspberry PI can only read digital inputs directly, i.e. on or off. Conveniently, that's also the modes of a momentary switch.

There aren't any new gpio functions here. The biggest difference is that we're setting one of our pins (pin 22 in this case) to be an input.

The setup for reading buttons

→ Read more...

2016/02/09 13:13 · clay

Blinking lights with GPIO

In my last post we looked at a basic query of the GPIO bus just to show that we could read it. This time I want to actually control something. Blinking a light is the IoT equivalent of Hello World, so we'll try that. In this setup, the anode (short lead) of the LED is connected to pin 19 by a smaller resistor, and the cathode (long lead) is connected to the 3v ground bar.

→ Read more...

2016/02/08 21:24 · clay · 0 Comments

C++11 Array Iteration

I've just gotten to play with the C++11 for extensions for the first time. It's really cool, especially the ability to iterate over a plain old array. Dig this code from my current hobby project:

→ Read more...

2016/01/29 22:22 · clay · 0 Comments

Programming the GPIO on a Raspberry Pi

If you read my previous piece on putting FreeBSD on a Raspberry Pi, you're probably now wondering what exactly you're going to do with this little box. Fortunately I have invested the effort to work out some basics of handling GPIO on FreeBSD and a Raspberry Pi. Because of why I chose FreeBSD, I've also implemented it in C: my first choice for tackling new problems in systems programming.

→ Read more...