iPod Touch as Universal Remote

For some time (actually several years), I’ve been looking for what I consider to be the ultimate universal remote control. So far I haven’t found any.
After some thinking, I came to the conclusion to try and make my own. After some research, I’ve decided to try and “transform” a iPod Touch into a universal remote control.

This is the main parts of the project:
iPod Touch
This part of the project is the software on my iPod that is going to control and send IR codes. For this I need to jailbreak a iPod Touch to get serial i/o access (if only Apple could allow developers serial access to access external devices).
For version 1.0 I’m thinking about these features:

  • XML Parser
  • Serial I/O
  • A basic UI with some icons and sub-menus to control the devices. All this is to be read from a xml config file, including IR codes.
  • Handshake code to talk to my microcontroller
  • Code to send different IR codes to my microcontroller
  • Battery status?
  • A home made iPodserial cable

Microcontroller:
The microcontroller is going to consist of the following parts:

  • AVR 8Bit Microcontroller with picoPower technology (I want max duration from my battery)
  • A Serial port
  • An IR Transmitter
  • Battery
  • Breadboard or something to assemble it all on

Microcontroller code
To begin with, this is going to be written in C if possible. First I want to make a “proof-of-concept” code to transmit some hardcoded IR codes to make sure I can get this to work. Afterwards the remaining code will be implemented. So the main part of the code will be:

  • Serial interface
  • IR Interface
  • Main loop that listens on the serial interface. If it recieves a valid IR code (determined by SOM and EOM), it will send it out the IR transmitter, and then send back an ‘ok’ signal.
  • Enter power-save mode after 20 seconds, with an interrupt on the serial interface to wake on data
  • Handshake and possibly battery status code

If all this goes according to plan, I’m looking to add more functionality like:

  • Bluetooth support (mainly to controll my PS3)
  • WiFi support (to control lights and other stuff that uses WiFi)
  • Menu editor

Unfortunately I don’t got too much spare time now, so to begin with I’m going to play around with the iPod/iPhone SDK and make some basic UI and stuff to see what I can do.

Well, I’ll keep you posted, but it’ll probably be a while until next update…

Comments (1)

New to OpenSolaris 2008.05 – I was

Well, for my file server I decided to go with OpenSolaris because of ZFS. I’ve read several good things about it, so I wanted to test it out.

After using several Linux distros over the last years, I was a bit skeptic about the whole Solaris thing, but oh well…

The install went smooth, and after some poking around I decided to turn of the GUI (GDM/X). I didn’t need it since I’m just using SSH/PuTTY to log in to my server, so why do I want it running ?

After looking around on the net, I found the command to disable GDM:

pfexec svcadm disable gdm

Next problem, installing/updating packages. I’ve been used to apt for a long while now, and this was one of my bigger concerns when deciding to try OpenSolaris. But luckily they’d just added IPS (Integrated Package System I think), a system that reminds me of a package tool I’m used to using.
So, how does it work?

Refresh the package list:

pfexec pkg refresh

Search for a package (gcc in this case):

pfexec pkg search -r gcc

Generated this output at my system:
INDEX ACTION VALUE PACKAGE
basename link usr/bin/gcc pkg:/SUNWgcc@3.4.3-0.86
basename link usr/bin/gcc pkg:/SUNWgcc@3.4.3-0.79
basename link usr/bin/gcc pkg:/SUNWgcc@3.4.3-0.75
basename link usr/bin/gcc pkg:/SUNWgcc@3.4.3-0.86
basename link usr/bin/gcc pkg:/SUNWgcc@3.4.3-0.89
basename link usr/bin/gcc pkg:/SUNWgcc@3.4.3-0.90
basename link usr/bin/gcc pkg:/SUNWgcc@3.4.3-0.91
basename link usr/bin/gcc pkg:/SUNWgcc@3.4.3-0.93

Then, to install a package (gcc in this case):

pfexec pkg install SUNWgcc

Then I found out that there are other IPS repository’s that I can use (www.blastwave.org and sunfreeware.com). Now, how do I add them?

pfexec pkg set-authority -O http://pkg.sunfreeware.com:9000/ Companion
pfexec pkg set-authority -O http://blastwave.network.com:10000/ Blastwave

To see what repositories you have in your system, do:

pkg authority

I’ve noticed that it’s not always “pkg search” will find the package I’m looking for, so now I always check the package sites (http://blastwave.network.com:10000/ and http://pkg.sunfreeware.com:9000/) manually if I don’t get a hit with “pkg search”.

To do a ‘full’ update of your system:

It it always recommended to upgrade PKG to the latest version first so do this:

BUILD=`uname -v | sed s/snv_//`
pfexec pkg refresh
pfexec pkg install SUNWipkg@0.5.11-0.$BUILD
pfexec pkg install entire@0.5.11-0.$BUILD

pfexec pkg image-update

This will also create a ZFS snapshot of your current system before the upgrade, and then do a update.
Important:
Remeber to update GRUB afterwards like this:

beadm list (you’ll see an BE that has ‘Activate on reboot’=YES, notice this name.)

In the last versions, this won’t be the case by default. Then do ‘pfexec beadm activate name (name is the last entry, like opensolaris-x)

pfexec beadm mount opensolaris-x /mnt
pfexec /mnt/boot/solaris/bin/update_grub -R /mnt
pfexec beadm unmount opensolaris-x

Important:
If you have a pre build 93 system (run: ‘uname -v’ to see what you have), you MUST read this page: http://mail.opensolaris.org/pipermail/indiana-discuss/2008-July/007664.html. And it’s even more important if you have build 86 (as I had when installing from the latest OS2008.05).

Edit: Added some stuff to the ‘image-update’ part.

Comments (7)

Perl script to change desktop background in GNOME

For some reason, I don’t like having the same background for an extended amount of time (as in, more than 15 minutes). Call me crazy, but that’s just how it is.

So when I bought my current laptop (Asus G1S), it came pre-installed with Windows Vista Ultimate, so I figured I’d give it a try. With the sidebar thing I found an widget that changed my desktop background every 15 minutes or whatever I liked. Hmm, cool enough, but I don’t like that sidebar, and for some reason Win Vista always seem to run awfully slow on my computers (maybe it’s just me abusing them).

Anyways, after a few days, I’ve had enough with Vista. So I decided to give good old Win XP SP2 a try on this brand new baby. After an install, things are flying like crazy, but nothing is changing my desktop background :\

After some checking around, it seems that in a vanilla XP, it ain’t possible to change the desktop background by command line or even by API as far as I found. So I was stuck changing it manually.

A few weeks ago, I’d had enough of Windows XP (as I always do after a little while). I downloaded Ubunty Hardy, installed it, and always I was happy when I saw the comforting GNOME desktop. Ahhh.

But still, my background isn’t changing by itself o Must fix.
The “easy” solution (atleast in my head), write a perl script that manages it for me.

My starting point was this:

  • All my wallpapers are in one folder.
  • Not all images matches my desktop resolution.
  • I don’t really wanna think about what resolution I’m running, I want the script to figure it out themself.

So, this is what I ended up with:

You need Image:Size to be able to use this script. If you’re running Ubuntu, just do:
sudo apt-get install libimage-size-perl

#!/usr/bin/perl
use Image::Size;## Set this to 0 if you don’t want this program to do anything
$go = 1;

## Desktop background changer for GNOME
## By Anders Østhus (grapz666+perl@gmail.com)
## 27-04-2008
##
## You are free to use and spread this code as you like
## If you are spreading this code, or hacking on it for your own use
## I would appreciate a e-mail about it, just so I know that someone
## is actually useing it for something.
##
## Usage: ./wallpaper.pl /path/to/wallpapers/

if ($go eq 0) {
exit();
}

## Some variable declarations
@files = ();
$dir = “”;
$dir = @ARGV[0];
$previmg = “”;
$wall = “”;

## If you want a different background color, you can chage it here.
$bgcolor1 = “#000000″;
$bgcolor2 = “#000000″;

## Get the current image
$previmg = `gconftool -g /desktop/gnome/background/picture_filename`;
$wall = $previmg;

opendir(BIN, $dir) or die “Can’t open $dir: $!”;

while( defined ($file = readdir BIN) ) {
if ( $file eq “..”) {
} elsif ( $file eq “.”) {
} elsif ( $file eq “Thumbs.db”) {
} else {
push(@files, $file);
}
}

## Find out what resolution we are running…
## Current resolution ends up in $tmpres[3]
$res = `/usr/bin/xrandr | grep ‘*’`;
@tmpres = split(/ /, $res);
@subres = split(/x/, $tmpres[3]);

## As long as the selected image is the same as the previous image
## we select a new one
while ($wall eq $previmg) {
$wall = $dir . @files[&getRand];
}

## Get the resolution of the image
my ($size_x, $size_y) = Image::Size::imgsize($wall);

## Sets the background image
$cmd = `gconftool -s /desktop/gnome/background/picture_filename “$wall” -t string`;

## If the image is the same resolution as the desktop, set it centered
## If the image is smaller than the desktop, we keep it centered
## If the image is larger than the desktop, we set it to scaled
if ($subres[0] > $size_x || $subres[1] > $size_y) {
$cent = “centered”;
}
if ($subres[0] < $size_x || $subres[1] < $size_y) {
$cent = “scaled”;
}
if ($subres[0] eq $size_x && $subres[1] eq $size_y) {
$cent = “centered”;
}

## Sets scaling option and background color(s).
## Also sets ‘draw_background’ to ‘1′, incase something has turned it off.
$cmd2 = `gconftool -s /desktop/gnome/background/picture_options $cent -t string`;
$cmd3 = `gconftool -s /desktop/gnome/background/primary_color $bgcolor1 -t string`;
$cmd4 = `gconftool -s /desktop/gnome/background/secondary_color $bgcolor2 -t string`;
$cmd5 = `gconftool -s /desktop/gnome/background/draw_background 1 -t bool`;

closedir(BIN);

## The function that returns a random image from the image array
sub getRand {
my $range = scalar(@files);
return int(rand($range));
}

And then I’ve just added this line in my crontab:

*/5 * * * * /home/grapz/devel/perl/wallpaper.pl /media/sda5/wallpaper/

This makes sure that this script runs every 5 minutes, every day of the week, every week of the month, every month of the year and so on.

Comments (5)