Debouncing a touch screen

I was coding up an Arduino app that allows a user to tap and drag on a touch screen to move an object. Everything went great but then I discovered that I could not interpret a drag motion. Whenever I dragged along the touchscreen the system would report that I was actually tapping and letting …

Advertisements

volatile

I love the volatile variable qualifier. I never had to use it until I started playing with an Arduino and so it was double the fun. When you mark a variable volatile you are telling the compiler to make no assumptions about the variable during compilation. For example, in a loop like:   the compiler …

pow(*,1./7.)

I was reading through some code (this file from the REBOUND N-body simulator) when I came across this function: and I got very curious as to how it worked, and why one would need it and mostly about whether it would generalize to arbitrary values of base and exponent. We see that we have an …

Computing orbits (1)

I want to simulate the orbits of planets and moons in our solar-system. They will form a carousel of gravitational bodies that my little spaceships will lift-off from, orbit around, and slingshot past, on their imaginary journeys of adventure and derring-do. The wikipedia article on orbit modeling is a nice introduction to some of the concepts involved. …

The marvelous bee odometer

You probably know that not only can bees compute the vector (direction and distance) to a discovered food source relative to their hive, but they can also convey this vector to their hive mates. Here, I'll talk a little bit about one component of this system - the Bee odometer: how do bees figure out …

Derived classes and std::vector

I want to talk about a fun corner of C++ I ran into recently. It has to do with how to handle calling member functions of a list of heterogenous objects. My use case was a bit like the following: say we have a bunch of different functions - a * x^2, b * x, …

Chromecast audio: command line

When I was casting about (I'm allowed one Dad pun per article. Oops, I mean bad pun. Sorry that was two much fun.)  for home audio solutions (It's what the kids call speakers these days) a friend of mine encouraged me to try out Google's Chromecast Audio device. And so another internet connected creature entered our …