I’ve been getting bored of my old domain, danielkennett.org, for a while. It’s long and boring, and is pretty much the only thing online that uses my real name. I don’t mind my real name being common online, but since I’m iKenndac on more or less every service I’m a member of, having my website be different seemed a bit weird.
A couple of weeks ago, I registered a nifty new domain: ikennd.ac. It’s perfect - short, sweet, and to the point. The problem is, though, that my blog had a big “danielkennett.org” logo on the top of it, and no other title or strapline. Replacing it with an “ikennd.ac” logo seems silly since I’ll be keeping the danielkennett.org domain alive for linking, and I was stumped.
That is, until today. A superb conversation popped up on Spotify’s internal IRC from Tobi, one of the designers, a slightly trimmed version of which I present here (I’m dan):
tobi: RIGHT
tobi: Time for weird theory
tobi: WHAT IF
tobi: “broken” was spelled “borken” from the beginning
dan: ?!
tobi: Then to enforce that something was broken, they broke the word
tobi: IE, they spelled “borken” -> “broken”
dan: But if it was spelled that way from the beginning, it wouldn’t be broken
dan: “borken” would be correct
tobi: yes, borken would be correct
tobi: NOWADAYS “broken” is correct
tobi: and borken is broken
tobi: but it may be turning back!
dan: And then hundreds of years later, people like you would be all “WHAT IF they spelled it ‘broken’ to break the word?!?!”
In it, I spontaneously came up with the phrase “Tales of an unchecked mind”, which is both a cheesy tagline and perfect for a blog, but more importantly at the time of writing had ZERO results on Google when the exact phrase was entered!
I changed it slightly to “Tales From An Unchecked Mind” and am now using it as the title for my blog. I’ve been wanting to make my blog more personal for a while now, including more writing about non-tech stuff along with an about.me-style page with my bio on it, and I think the new title will fit well.
We’ve been promised self-driving cars for years. Hell, even flying cars! Where are they? Nowhere, that’s where!
Well, I’ve decided to take this into my own hands. In my previous post I mentioned that I’ve got a “more ambitious” Arduino project in the works, and today it arrived:
It turns out that interfacing with an RC is dead-simple - both the servo and the speed controller use the servo electronic interface, which the Arduino has libraries for.
Over time, I want to be able to solve the following challenge:
Here’s a GPS coordinate: (x, y). Get there.
The constraints of the challenge will be along the lines of:
The environment will be a fairly open area with large obstacles (fields with trees, etc).
The car won’t have to worry about staying on roads.
The car should take a reactionary approach to navigation and not do a grid-search of the area.
The car should be able to go at a reasonable speed (> 10km/h or so).
The car should recognise potential dead-ends and stop in time.
The car should recognise when a fatal problem (like ending up upside-down) has occured and give up.
Given those constraints, the car will need at least the following sensors:
GPS
Gyroscope
Long-ish range distance (sonar or otherwise)
Long-ish range wireless for diagnostics and emergency-stops
Thankfully, all of those are available for the Arduino. A friend of mine immediately started talking about advanced algorithms and video analysis when I mentioned this idea, but I hope to keep it much simpler than that, and given the environment the car will be in I hope to be able to pull off something with this project.
This will be a long-term project, especially since winter is rapidly approaching and if it’s anything like last year’s we’ll be knee-deep in snow in less than a month. Still, I’ll build the car soon and at least get it moving a bit under Arduino control.
A month or so ago, I wrote a post
detailing how I put together an Arduino Mega 2560, a couple of chips and
a pile of wires to allow me to control the colour of a set of IKEA
Dioder RGB LED strips in software, then a follow-up post on
how to emulate Philips’ Ambilight technology to create a pleasing
ambient light effect behind your computer’s display.
Today, we’ll be tidying up the hardware side of the project from the
current sprawling mess of wires:
To a neat little box:
Creating an Arduino Shield for DIODER LED Strips
An Arduino shield is a circuit board that connects to an Arduino and
contains a certain number of electrical components that perform a
certain task — you can buy pre-made shields to give your Arduino an
ethernet port, a display, and so on. We’re going to make a shield that
stacks on top of the Arduino Mega 2560 and you can connect the LED
strips to.
On top of the things you already have, you’ll need the following (Links
to Swedish store):
Soldering Equipment. If you haven’t soldered electronics before, get
a strip board and some
spare components like resistors to practice with first.
Rather than step you through creating the board, I’ll simply leave you
with the circuit diagram to implement and some photos of my finished
board.
A few notes:
You’ll notice that the circuit diagram is a bit different to the one
originally presented in the first part of this series. This is to
make creating a circuit board easier, and I’ve gone back and updated
both the original post
and the code on GitHub for
this new layout.
You can probably make your board look way neater than mine!
The connector pins for the LEDs are right-angled because there’s not
enough space in the box for vertical pins and the LED connectors.
Angle the two sets of pins that aren’t hanging off the board upwards
slightly to make connection easier.
Once you’re completed the board, it will stack on top of the Arduino
Mega just fine. Cop a bit out of the box to allow the Dioder cables
through, and you’re set!
Moving Forward
As before, let me know on Twitter if
you’d like to share and thoughts or idea about this project. Now we have
a nice, neat box, in a couple of weeks I’ll post the final part of this
series — a System Preference pane with accompanying service to let the
lights respond to various system events, falling back to the ambient
lighting when nothing else is happening. After that, I’ll take a bit of
a break before starting the next, more ambitious, Arduino project.
A couple of weeks ago, I wrote a post
detailing the process of combining a set of colour-changing IKEA LED
strips, an Arduino, a few simple electronic components and a lot of
nerdiness into a project that allowed you to control the colour of the
LEDs though a simple application running on your computer.
Over the coming weeks and months, I’ll be presenting cool things you can
do with this project here on my blog. However, I wasplanning on
working up to this post, but since lots of people were enthusiastic
about this particular part (as can be seen from the screenshot of my
Facebook stream to the right), I jumped ahead a bit.
Now, Philips have a very similar system in a lot of their TVs, and as a
colleague at work who called me “Mr. Patent Infringer” pointed out, they
probably have a buttload of patents covering their technology.
So, please allow me to present…
An Ambient Lighting Solution Similar To But Legally Distinct From Philips® Ambilight®
So, what’s the challenge here? Well, actually, the core challenge is
pretty damn simple:
Sample the screen.
Push an appropriate colour based on the edges of the screen image to
the lights.
Philips’ hardware also does a fuckton of image processing to smoothly
animate between colours and even provides an “aggressiveness” setting to
control how sensitive the LEDs are to colour change. I’ll be leaving
this as an exercise to the reader for now.
So, I’m not going to lie — my first attempt at this, was, well, lame.
For a start, I learned that if you leak a screen’s worth of pixel data
every time the screen refreshes (that’s 2560 x 1440 x 4 bytes = just
over 14Mb per frame at up to 60Hz), things go very bad very quickly.
Once that was fixed, my technique was:
Register for screen update callbacks using
CGRegisterScreenRefreshCallback().
Every time I got one of those, render the entire screen image into a
new buffer.
Loop through allof the pixels in the top, bottom, left and right
1/4 rectangles of the image buffer.
Average the RGB values therein.
Push those to the Arduino.
As you might imagine, that method is rather inefficient. In fact, it’s
downright idiotic, and took nearly 60% of my CPU all the time.
As the implementation matured, various optimisations of course took
place — only an idiot would allocate a new buffer each time the image
changes, for instance. In addition, the
CGRegisterScreenRefreshCallback() callback looks like this:
Which provides a lovely rect array telling you which parts of the screen
image changed, which is perfect since we only care about parts of the
image.
Final Attempt: Passable, I guess
As I attempted to improve the efficiency of the project, I tried only
sampling every fourth pixel, scaling the image down, etc, since we
obviously don’t need every single pixel sampled to get a single average
colour that’s good enough for the lights. However, the very act of
rendering the screenshot into a pixel buffer was by far the most
intensive part of the whole thing. I was publicly fishing for help on
Twitter when @uliwitness reminded me that Core Image exists.
A few minutes later, I’d replaced 90% of my code with a call to a Core
Image Filter called CIAreaAverage, which calculates the average colour
of a given image. Since Core Image is badass and much better than me,
this actually causes all the work to be kept on the graphics card and
caused CPU usage to tumble.
The final project for this post contains two methods of calculating
colours:
Pick A Pixel: Literally pick a single pixel near each edge of the
screen and use that. Not very clever.
Average RGB: Use Core Image to calculate the average colour of the
edge rectangles of the scree as discussed above.
I was also planning on doing an Average Hue method too, since I was
expecting Average RGB to give brown every time (possibly a side-effect
of always getting shades of brown when mixing colours in art at school).
However, Average RGB works just fine so I never implemented it.
Removed AMSerialPort for my own DKSerialPort class. AMSerialPort was
buggy and didn’t work with connection speeds over 9600 baud.
DKSerialPort is also a lot smaller.
Created a class called ArduinoDioderCommunicationController, which
abstracts away all the work of communicating with the Arduino
running the included sketch. This allows future projects in this
series (and you, of course) to drop in the class and just push
colours without caring about how it all works.
Of course, I have to include a video of this project in action. The
colour changing is a little crappy since I don’t do any smoothing, and
unfortunately my camera picked up an odd flickering which isn’t visible
by the naked eye, but you get the idea:
Moving Forward
As before, let me know on Twitter if
you’d like to share and thoughts or idea about this project. In a week
or two I’ll put up another post discussing some more code to make the
LED strips respond to system events and so on.
I hope this is enough to get you started, though. Have fun!
A few weeks ago, it came to my attention that IKEA do a set of
colour-changeable LED strips. I’ve been looking for a decent way of
providing some lighting behind my computer to reduce eye-strain for a
long time, and these seemed perfect:
I was very pleased with them, but no self-respecting nerd would stop
here. Especially one who’s seen Philips’ Ambilight technology in
action!
Over a series of blog posts, I’ll be explaining how I built a simple
controller for IKEA Dioder lights using an Arduino Mega2560 unit, then moving on to
explore various ways to utilise this control in software for fun and
awesomeness.
In this post, I’ll be building an Arduino layout that controls the
Dioder LED strips, programming it to listen to messages on its serial
port and set the LED strips’ colours accordingly, then making a simple
Cocoa application in Xcode that sends messages to the unit to match the
strips to colour wells in a window on-screen.
Note: If you see a paragraph starting with Tangent:, you can
skip it without losing information on how to build this project.
I care not for your long and boring descriptions! Just give me the code and wiring diagrams!
You can grab the code over at the project’s homeon GitHub, which
includes both Arduino sketches for uploading to the device and Xcode
projects for controlling it. The Arduino sketches require the Arduino software and the Xcode projects
were written on Mac OS X 10.7.
Part 1: Creating the Arduino-based hardware layout
IKEA sell Dioder lights in a number of configurations — I went with the
set that includes four multicolour strips, a control box and a power
adapter (Store links:
Sweden/UK/USA).
The control box and power adapter won’t be used once they’re connected
to the Arduino, though.
The Dioder LED strips have 12VDC on a common anode, with three return
paths for the red, green and blue channels.
The layout here is fairly simple — power the Arduino with the 12V power
adapter, then tap into that for the anode on each LED strip.
PWM pins 2-13 (0 and 1 collide with
serial communication, which we’ll be using on this project) on the
Arduino are connected to the ULN2003 chips, which act as relays for the
red, green and blue cathodes from the LED strips. Finally, the ground
pins on the ULN2003s are connected to the Arduino’s ground to complete
the circuit.
Below are photos of the completed unit as well as a diagram of the
wiring. You may notice that the wiring in the photos isn’t quite the
same as in the wiring diagrams — that’s because I miswired the project
when I took photos of it. All code and future projects are based on the
wiring diagram.
Rather than stepping through the process of listening to the serial port
and controlling the PWM pins, I’m going to jump straight to what I
implemented for the Arduino to listen to messages on its serial port and
set the PWM output values accordingly. However, if you haven’t
programmed Arduino before, I strongly recommend visiting the Arduino reference guides and looking
at the sample projects included with the Arduino software to learn how
it all works — it’s a lot of fun!
The protocol I implemented is very simple — two constant header bytes,
12 “body” bytes (one for each red, green and blue pin over four separate
LED strips) and a checksum byte (a bitwise XOR of all the body bytes).
A message setting all connected LED strips to white/GBR(255,255,255)
Tangent: Originally, I’d implemented the protocol without headers or
checksums — the Arduino would listen to the serial port and push each 12
bytes it got to the PWM pins. However, this was such a dumb idea — if
you accidentally sent the wrong length of data or some other app sent
data to it (which happened more than once), you’d never be able to get
it back in sync! You can find the Arduino sketch that listens for that
“protocol” in the sample code repository linked below at Arduino
Projects/FourChannelRGBDumbListener/FourChannelRGBDumbListener.pde.
Don’t use it, though — it’s dumb!
You can grab the finished Arduino sketch over at the project’s home on GitHub, at
Arduino Projects/FourChannelRGBSmartListener/FourChannelRGBSmartListener.pde.
Part 3: Creating a Cocoa application to send messages to the Arduino
By now, you should have an Arduino successfully controlling your Dioder
LED strips. You can test this by connecting it all together (make sure
you connect the 12V adapter to the Arduino or the LED strips won’t be
powered) and switching on the Arduino — the Arduino sketch I wrote will
switch all four strips to white until told otherwise over the serial
port.
My Dioder LED strips are attached to the back of my iMac as shown in the
photo at the start of this post, so I made this very simple application
— choose the Arduino’s serial port from the menu, then change the colour
of the colour wells — the corresponding LED strip will change colour to
match!
The full Xcode project can be found over at the project’s home on GitHub, at
Xcode Projects/Dioder Colour Wells/Dioder Colour Wells.xcodeproj. Just
to show how cool this looks in real life, I recorded a video to show it
off:
Moving Forward
Hopefully you’ve got a few cool ideas on what to do next — let me know
on Twitter if you’d like to share! In a
week or two I’ll put up another post discussing some more advanced code
to make the LED strips respond to system events and so on. A little bit
further down the line, we’ll start to get to the juicy stuff like live
image processing for having the LEDs react to what’s on screen.
I hope this is enough to get you started, though. Have fun!
One year ago yesterday, my fiancé and I pulled up outside an apartment a
few kilometres south of Stockholm at 11am. We’d just spent the last four
days driving through equally driving rain from the UK through France,
Belgium, Germany, Denmark and Sweden. We’d camped each night in the
rain. We were wet, our tent was wet, our stuff was wet.
We breathed a sigh of relief. We were happy to finally arrive, even
through our journey had been gruelling but a lot of fun. We’d stopped by
the Nürburgring and the world’s largest model railway on the way, both
of which were amazing. We took a 15 minute break before hauling all of
our stuff up three flights of stairs into our apartment.
We’d just moved to Sweden. We were both nervous and excited about the
time ahead, comforting ourselves with the fact that we could “just move
back to England” if it didn’t work out.
The Present
One year later, and we’ve just moved into another flat — one with no
maximum term, which we’re happy about since we can stay here for decades
if we want to. Both my fiancé and I have jobs at Spotify, which we’re
both enjoying more than we thought a day job could be enjoyed.
Living in Sweden is completely normal now. We get up and go to work,
then come home again. Drive to the supermarket to do our shopping. Have
LAN parties with our friends. Living in the UK seems like a distant
dream — not a good one, at times.
Occasionally I’ll be doing something thoroughly normaland the enormity
of the last year will smack me in the face. Last time it happened, I was
driving, in my Volvo, to IKEA. A completely normal, British thing to
do. As I was driving, I noticed that the forest was nothing but pine
trees, which I thought was odd. Then, I remembered. “The forest is
nothing but pine trees because I live in fucking Sweden!” A smile
spread uncontrollably across my face as I remembered the year and a half
long buildup to moving, then one day packing as much stuff into the car
as we could and starting the trip across Europe.
I still can’t decide if what we did was “big” or not — I’ve met quite a
few people who travel between countries a lot, so if you ask them what
we did is no big deal. Then again, I remember talking to some of our
friends in the UK before we left and trying to convey to their
confused-looking faces why on earth we’d move away from the town where
we’d grown up, much less the country we live in — if you ask them, what
we did would probably be an enormous thing.
The Future
After all the uncertainty and worry that it’d be a disaster, we’ve only
been here for twelve months and I think we’re here to stay. Between my
fiancé and I, we have around 48 years of collective experience of living
in the UK and, well, we both were kind of expecting to miss the UK at
least a bit. Personally, I miss a few of my friends but otherwise
wouldn’t care if I never set foot in the country again. My fiancé is the
same, albeit also having a tightly-knit family in the UK. Sweden is by
no means perfect, but we seem to get on with the Swedish way of living
much more than the UK way.
It doesn’t hurt, of course, that Sweden is beautiful. Of course, the
UK is beautiful in places too, but the following snapshots were taken
within 30km of the capital city. Try that around London!
I’ve always known that Stockholm is small compared to London. I mean,
the population of Greater London is more than 80% of the population of
the entire of Sweden. However, I didn’t really realise how small it
is until I compared these two pictures I took. Obviously they’re not
idea (visibility is greater in the Stockholm photo), but the London
urban sprawl does on for as far as the eye can see!
A while ago, I posed an article
discussing Reeder’s UI, and how it doesn’t really fit in with a desktop
environment. That post got a lot of attention, and some people got
really angry with me and misquoted me and sent hysterical emails and so
on.
I still stand by the points made in that post, and the people mentioned
above seemed to think that I hated the whole app - which is untrue. I
still don’t really like many parts of the UI, but it’s still a beautiful
reading experience provided you memorise what all the unlabelled buttons
do.
iPhoneTracker came out
today, and it’s a bit shocking to find out my location is being stored
on my device. Indeed, my data goes back until the day I bought by phone
in July 2010.
For a moment, I was very unnerved. I don’t like the idea of my location
being stored in that much detail for so long. However, after actually
looking at my data (I know, right?) I’m not so outraged, but it’s
still pretty bad!
My conclusions based on cursory observation
The data is recording the locations of the cell towers, not yours.
If you don’t have a data connection, locations aren’t calculated.
Cell information isn’t saved and locations calculated once you have
data again.
A theory on wildly inaccurate results
Figure 2, below, shows locations in Sweden I’ve never been anywhere near
in my life - mainly the ones down the west coast and southeast coast
away from the big clumps.
I once visited a hotel with free WiFi. My iPad, only having WiFi to base
its location on, put my position smack on a Travelodge hundreds of mies
away. Turns out the base station used was moved from that Travelodge and
the location never updated.
I wonder if the same happens here? It doesn’t seem implausible that cell
towers are moved around without having their location updated in the
relevant database.
My opinion
Location data is an incredibly personal thing. Coupled with a
timestamp, you can infer all sorts of things about a person, and there
have been several projects that can predict the location of a person
based on historical location information like this. That they seem to be
collecting cell tower data as opposed to your own location makes this
less bad, but Apple really need to make it crystal clear to users
that they’re storing this information in cleartext all the time they’re
using their phones.
I’m not against the collection of this data at all. I understand that
this sort of data is recorded all the time, either on the handset in
question or by the networks themselves. My beef is that this data is
being saved, seemingly permanently, unencrypted and in plain view
for anyone to see, without telling me. It may well be buried in the
license agreement nobody reads through, but that’s not really an excuse.
Interesting parts of my location history
Figure 1: Driving through Germany. We stayed overnight down near
Belgium, then drove through Germany the next day before arriving near
Hamburg for another overnight stop. I had Data Roaming switched on for a
while at our stopovers, and occasionally switched it on throughout the
drive to check Twitter.
Figure 2: Driving through Sweden. My data is on permanently in Sweden,
of course, so the are a lot more cell towers here. There’s a very
interesting hole in the data towards the South, which isn’t a one-time
thing — this data was collected over three separate trips through the
country: one in August 2010, the other two in March 2011.
Figure 3: Sailing past England. This data is from two separate trips,
both in March 2011, on a ferry from Denmark to the UK. The ferry sailed
along the British coast before heading over the North Sea to Denmark.
When we were driving through Sweden to catch the ferry to England the
other day, my fiancé and I were discussing what we’d think it’d be like
returning to the country we grew up in after living away from it for six
months. She was worried that she’d feel at home and not want to leave
again. I doubted I’d feel that way, but wasn’t sure.
Boy, was I born in the wrong country. I’ve been here less than 48 hours
and I’m already counting the minutes before I can go home again.
This is the hardest thing in the world to describe, but England is…
dull. Not boring, but the colour palette seems to be muted. I thought I
was imagining things, but after chatting with a friend of mine back in
Sweden today, it seems I’m not alone. We share similar theories —
perhaps the significantly higher traffic levels make everything near the
roads dirty, or the higher pollution levels coupled with higher rainfall
covers everything in dirt, but there’s a definite difference.
I miss the clear air. The modern communications infrastructure. Being
able to drive somewhere without joining a queue of traffic. The
inability for anyone in Sweden to comprehend why on Earth I’d move
there without a Swedish girlfriend or family member forcing me. Hell,
even the damn traffic lights.
I miss home.
I don’t, however, miss the mosquitoes that’ll be waiting when it gets
warmer. Little fuckers.