Clay Dowling's Occasional Musings

I write code, build things, and occasionally lead teams. I also share my thoughts or things I've learned about them, so that others can learn from my mistakes.

Better Tests Through Mocking

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

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

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

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...

2016/01/27 19:17 · clay