My first Arduino

Yesterday my wife decided to buy yet another sewing pattern book and I decided to tag along.  As a Kindle user, there’s usually very little for me to do at a bookstore.  I usually just look around the IT section of the magazine rack and thumb through the amazing Ubuntu magazine, or Nikkei Linux.  This time though, a magazine called “Otona no Kagaku” caught my eye.

 

 

“Otona no Kagaku” is magazine that comes with some kind of sience related device inside that you can put together.  There were all kinds of projects from synthesizers to airplanes, all sorts of fun.  Kids today are so lucky, I wish I had a magazine like that when I was a kid.

Anyway I’m too old for most of them to be interesting but one of them came with an Arduino board (branded as “Japanino”).  Since the magazine cost about as much as a new pre-assembled Arduino + shipping I decided to buy it.  The magazine is filled with a bunch of projects other than the one on the cover and explains how to go about doing them.  It’s amazing all the cool things people are doing with the Arduino. One guy uses an array of Arduinos to electricute himself in the face it seems.  To each his own I guess.

 

The Persistence of Vision project was really simple to set up.  Just a few screws and the website had all the software you needed already.  Here’s what the finished product looks like.

 


The IDE is really simple.  It’s amazing how low the bar is to get code onto these things.  Way back when (circa 2005) I still had to build a cross-compiler environment.  The language is like a C version of Processing, which is really intuitive and gets rid of having to write a boiler-plate event-loop in the main function.

Now I’m thinking about what to do next.  At work I’ve been experimenting with a presence system based on bluetooth which automatically locks the computer when I’m out of range.  Unfortunately Bluetooth has a pretty long range.  I wonder if there’s any NFC shields for the Arduino.  It’d be pretty cool if you could use your phone as a smart-card via NFC.

 

 

Announcing Better Mail

http://www.appbrain.com/api/api.nocache.js

About a year ago I bought the first Android phone available in Japan for the sole reason of making apps. Unfortunately I’ve had very few itches that needed scratching.

About a month ago that changed, because the built-in Gmail app has a fatal flaw.

The Problem

If you temporarily lose connectivity while sending an e-mail, the e-mail gets stuck in a “Sending…” limbo.  There’s no way to re-send the message.  It’s not even possible to edit the message.  It’s not in the outbox, and not in the sent folder.

When OhLife first started I spent 30 minutes writing my first journal entry.  Unfortunately I’ll never get to read that post again because it never finished sending.

Also the native app doesn’t support Japanese emoji.  Which means that sometimes I get what looks like blank e-mail from my wife or my friends which were actually just full of emoji.

I decided to do something about it.  So I started using the Gmail mobile web app which doesn’t have this problem. Pretty soon however I started to miss the integrated experience of the native app.

My Solution

Better Mail is a native android app with a WebView hardcoded to mail.google.com.  But that isn’t all, it also listens to the same new e-mail broadcast as the Gmail app.  It will notify you of new e-mail without a constantly running background process.  It also includes a native menu so that you can navigate without having to scroll all the way to the top. Also, since Better Gmail is a separate application it stays in memory longer than a web-page would which makes it much less painful to use.  I also took the time to fix some of my pet-peeves with Gmail’s notification style. For example, I added a “Quiet Mode” feature that automatically turns off sounds and vibrations when you get new e-mail at 2 in the morning.

The Price

A buck.  Making this application wasn’t trivial, since I had to do some reverse-engineering.  While the die-hard Free Software nut inside me has some reservations about using DRM, it does improve performance a bit.  And performance is the biggest problem.

I have a lot of ideas in the pipeline that I could work on if there’s enough interest.  Eventually I would like to try injecting my own javascript code into the page to provide an even deeper level of integration.

Update:

I’ve decided to work on bigger and better things.  The code is now Open-Source (GPL) and available for free!

The Future

This app is definitely a minimum value product, there’s plenty of room to expand.  If anyone has a feature request let me know via e-mail or in the comments.

How To Get etags Working in Emacs

You’ve been using Emacs for how long and you haven’t figured this out yet?

Yup.  Up until now I’ve never really needed to actually get etags working in Emacs.  I remember trying to figure it out long ago as a newbie and giving up.  It’s initially difficult because it’s not as simple as just saying “etags my-src-dir”, though once you have a couple of UNIX tools on your utility belt though, it’s practically as simple as “etags my-src-dir”.

Just show me the code.

Although there might be other more correct ways to do this, the following works fine for PHP:

    cd ~/src-code-top
    find . -name '*.php' -print | xargs etags

Woah find and xargs?

etags (unfortunately) only works on files and not directories.  Those files also have to be arguments and not stdin.  So we need to use find to give us a list of file names and xargs to convert each filename into an argument for etags.

Explain find.

find is a swiss army knife of file search but mostly you can just memorize “find . -name ‘*.filetype‘ -print”.  find needs 3 arguments, the directory to start looking in, some condition, and some action. The “.” tells it to look starting from the current directory. The “-name” part means find matching filenames (We use the single-quotes to keep bash from expanding). Finally -print tells it to print what it found one line at a time.

Explain xargs.

xargs takes lines from stdin and supplies it as the arguments to some other program.  Just what we need for etags. Although xargs is as versitile as find we don’t need to supply it with anything, the default behavior is fine.

Ok, now how do I use it in Emacs?

Just use M-x visit-tags-file and point it to your newly minted TAGS file.  After that you can easily find out where the hell that class/function is hiding just by doing “M-.” (You can also return to the file you came from by pressing M-*).  Of course “M-.” and “M-*” work in a stack like manner so you can keep “M-.”ing to dig as deep as you need to and easy get back by pressing “M-*” and equal number of times.

Integrating Qt3 programs in Ubuntu

If you’re like me and have discovered a couple of kick-ass Qt applications and are wondering how to make Qt programs look more like the default Ubuntu Human theme, I present you with a quick cheat sheet.

There’s luckily one KDE style available in the Ubuntu repositories that only depends on Qt, polymer. But the colors it uses are different from the Ubuntu colors, so here’s how to get them pretty close.

First you’ll need to install a couple of packages. You can either click on these links or search for them using synaptic.

Once you have them installed you can find qtconfig in System>Preferences>Qt3 Configuration.

First change the style to Polymer. Then click the Tune Palette. Here’s the colors that I used:

  • Background: Red: 239 Green: 235 Blue: 231
  • Button: Red: 245 Green: 242 Blue 239
  • Highlight: Red: 219 Green: 154 Blue: 86

You can change the color by clicking on the change color button when and inputing these numbers in the window that pops up.

Once you’ve changed those three, close the Tune Palette window and go to File>Save.

Now your installed Qt apps will blend in a lot better with your other GTK applications.

Here’s what it’ll look like:

Virtual Box OSE screenshot

Workrave

I learned about this program from Sacha Chua’s blog. Workrave is a cool time-to-take-a-break-reminder program that doesn’t just lock your screen (like the default typing break program in Ubuntu). It has micro-breaks which are great to remind me to get back to working on whatever I was supposed to be doing.

I wonder how my life would change if I made a program for my Treo that would make it vibrate every couple of minutes to remind me to keep my attention where it should be.

Ubuntu users can use the following link to get APT to install it for you: Install Workrave

EMobile D01NE on Ubuntu 7.04 Feisty Fawn

The EM D01NE is a (I think) HSDPA PCMCIA card. The driver for the modem comes with Ubuntu 7.04 (Maybe before). I get about 2Mbps from it (max is 3.8).

Getting this setup in Ubuntu is easier than getting it setup with Windows. The only gotcha is that you have to install Gnome-PPP first, since it doesn’t come with Ubuntu. I’ll try later using gnome-network-settings and report it in another post.

  • First install GNOME-PPP using synaptic or apt-get
  • Run it and press the setup button
  • Press the detect button, it should find /dev/ttyACM0
  • Speed: 460800
  • Phone Line: Tone
  • Volume: High
  • In the Init Strings change Init2 to ATH0E1
  • Leave Init 3 alone
  • Leave Dial prefix empty
  • Username: em
  • Password: em
  • Phone number *99***1# (Some people have success with just *99#)
  • Internet!

These instructions come from http://d.hatena.ne.jp/hayamiz/20070616/1181994636 (Japanese)