This is my weblog... clicky on the linkies

Arbitrary colors for the Adafruit 1.8" TFT display

By John, 2 July, 2011

I love Adafruit. I especially love their little 1.8 inch TFT screen that you can hook up directly to an Arduino. It comes with a library, but one thing the library is missing is a method for generating arbitrary colors. The colors are in an odd packed 16 bit binary format, with 5 bits for red, 6 bits for green, and 5 bits for blue. They give you a few color constants to start out with, but I wanted arbitrary colors. So I re-familiarized myself with C's bit operators, wrote some code, and now you don't have to.

The first function assumes you're passing a value from 0 to 255. The second function lets you specify the mapping, so if you wanted to create a color based on values read from the analog pins, you could do that by specifying 0 and 1023 as the minimum and maximum values.

Sorry for the lack of formatting, I can't get the formatting to look right. It should cut and paste just fine.

uint16_t makeColor(int r, int g, int b)
{
return makeColor(r, g, b, 0, 255);
}

uint16_t makeColor(int r, int g, int b, int minimum, int maximum)
{
int red = map(r, minimum, maximum, 0, 32);
int green = map(g, minimum, maximum, 0, 64);
int blue = map(b, minimum, maximum, 0, 32);

uint16_t color = 0;

color = color | red;
color = color << 6;
color = color | green;
color = color << 5;
color = color | blue;

return color;
}

Popsicle recipes

By John, 25 June, 2011

We just got some popsicle molds for making your own popsicles at home. It's amazing, I've had two popsicles a day since we got them. Here's what we've made so far, all of them have been excellent:

Orange creamsicles: equal parts of: Orange juice concentrate, milk, and vanilla yogurt (these were amazing)
Blueberries and vanilla yogurt (SUPER yummy)
Orange juice
Lemon creamsicles: lemonade concentrate, water, milk, and half and half -- keep adding little bits of everything until it tastes good. Yes the lemonade curdles the milk but you're not drinking it, you're freezing it so who cares?

I made one with part orange juice part cherry juice as a test (we ran out of orange juice) but my daughter nabbed that one when I was at work.

I just put in some straight lemonade popsicles (going for lemon ice) and a brand new idea: spicy lemon creamsicle. Spicy Lemon Creamsicle: Chop a small Morita pepper. Cover with water for about 5 minutes, enough to start softening it. Add lemonade concentrate, half and half, and milk.

I have no idea if this is too much hot pepper or not. I guess I'll find out tomorrow morning!

UPDATE: WAY too much hot pepper.

Geof (not verified)

13 years 11 months ago

When you tweeted about the disaster this could be, I was wondering what the awful would be. I should have guessed pepper.

What I've been watching on Youtube

By John, 25 June, 2011

Richard Feynman on Confusion:

Hail to the King (stick with it, it gets ridiculous after about halfway through):

Suspicious Minds (I'm trying to figure this song out on harmonica):

Tags

Facebook comment of the week

By John, 18 June, 2011

It bugs me that some of my best writing is on Facebook where only a few friends will see it. So let me elevate this comment, which was in response to my friend Charlie. He started out with this question, regarding the particle/wave duality of light:

You can measure a wave and you can measure a particle - how can something be both?

My reply:

You just have to squint at it at the right angle.

It's like one of those pictures that is a duck that turns into a rabbit if you look at it long enough. What is it a picture of? A duck? No, it's a rabbit. A rabbit? No, it's a duck.

A duckrabbit? Now you're getting closer...

An optical illusion which looks like a duck facing left or a rabbit facing right

Member for

14 years

John

13 years 10 months ago

My 4yo says it looks like a rabbit that looks like a duck. My 2yo says it's a duck, and when I tried to point out how it looks like a rabbit, and asked him if he saw the rabbit, he said "I can't find it!"

Not hungry for breakfast

By John, 11 June, 2011

My four year old daughter is jumping around, excited about making cookies, because she just woke up and had a dream about making cookies. I explained we had to wait until Mommy and Daddy were ready to make cookies, and why don't you go eat some breakfast while you wait? She said "Dad, I'm not hungry for breakfast! I'm hungry for cookies!"

Update, later in the day: My daughter just ran in the room and said "Daaaaaad! Mom says that grapes are plants," in a tone of voice that indicated that her mother could quite possibly be the stupidest person on the planet for believing such a thing.

"Honey, grapes are plants." I said. She suddenly looked at me like I had two heads. "What do you think grapes are, honey?" I asked gently.

"Grapes are food," she said forcefully.

"Hmmm. Look, you remember the sugar peas in our garden, right? They're vines, growing on the fence. Now, are peas plants?"

"Yes."

"But you ate some yesterday. Are peas food?"

Pause. "Yes! Peas are food AND plants!"

"So what are grapes?"

"Grapes are plants... AND food!" Long pause while this sinks in. "I HAVE TO GO TELL MOM!"

Peggy's book is done!

By John, 9 June, 2011

My wife finally got her book up on Amazon!

The Naturally Frugal Baby

It's called The Naturally Frugal Baby: Financial Survival Strategies and Tactics for Having a Baby without Going Broke. This is the Second Edition (the first edition was only available on Lulu.com) and has been extensively updated and revised. Yay for Amazon!

If you'd rather have bits instead of atoms, you can still get it in e-Book form from Lulu.com. You can get the book cheaper from Lulu.com as well, but as Peggy points out, if you take advantage of free shipping from Amazon it works out to be about the same price either way.

[UPDATE]: The best review yet comes from my friend Mike on Facebook, who shared the link and commented: "I'M NOT HAVING A BABY. My friend's wife wrote a book about making and raising babies on a budget, and since many of the people on my FB are hellbent on breeding, I'm posting the link."

Booker T. Jones, or, A Story in Accidental Marketing

By John, 8 June, 2011

My car is in the shop for some transmission work (yeah, I know, FUN), and in a spectacular display of timing we just donated our previous car to Minnesota Teen Challenge. So I'm carless and my friend Nathan has been giving me rides. Nathan listens to 89.3 The Current, which I don't usually bother with because they are too eclectic and they probably aren't going to play my current favorite guilty obsession songs.

A song came up. Everything is Everything by Booker T. Jones. You may remember Booker T. Jones as the front man for Booker T. and the MGs:

I recognized the organ sound immediately, and looked up at the new foofy radio in Nathan's car, which, though some wizardry, it was displaying the song, 10 characters at a time. It took 45 seconds to display the whole song name.

As soon as I got home I bought the song on iTunes. So there you go Marketers: a little piece of completely uncollectible market data for you.

And for everyone else, here is the song, which rules: