Blog

  • But are they Stuggy?

    But are they Stuggy?

    Instagram filter used: Lo-fi

    Photo taken at: Highland Farms

    View in Instagram ⇒

  • LaunchPad MSP430 pomodoro timer using Energia

    I know a lot of people who bought the Texas Instruments MSP430 LaunchPad development kit but never really got into it. I’m one of them; the $4.30 purchase price was compelling, but the requirement to install a huge proprietary IDE (with its own embedded C dialect) was just too much.

    For this reason, Energia is great. It’s a fork of the Wiring/Arduino development environment for the MSP430. Looks just like Arduino, but quite red:

    The basics of the language are the same, although the pin names and functions are different from the Arduino. The basic board also has a red and a green LED, a user button, and the obligatory reset button.

    Just to try out Energia, I wanted a useful project that only used the onboard hardware. I came up with a version of a pomodoro timer, similar to the one used in The Pomodoro Technique® time management method. The one I made has the following features:

    • 25 minute “green light” work period
    • 5 minute “red light” rest period
    • At the end of the rest period, the green and red lights flash. You can choose to restart the timer (with the reset button), or turn the lights off with the user button.
    • You can turn the timer off at any time with the user button, and restart it from zero with the reset button.

    For me, this electronic version has several advantages over the wind-up official timer:

    • it doesn’t tick or ring distractingly
    • it’s cheaper than the real thing
    • it always resets to the same time.

    It does have a couple of possible disadvantages, though:

    • it doesn’t give an indication of time left
    • it’s not very accurate, since it uses the MSP430’s internal oscillator. Mine seems to give an approximately 26 minute work period, with a rest time that’s proportionally longer.

    Here’s the code (tested on a MSP-EXP430G2 board, version 1.4):

    /*
    
     launchpomodoro - simple task/rest timer for TMS430/Energia
    
     On reset: Green LED on for 25 minutes
     After 25 minutes: Red LED
     After 30 minutes: Flashing Red/Green LED (until reset)
     On button press: all lights off.
    
     scruss - 2012-10-15
    
     */
    
    // 25 minutes
    #define ENDWORKTIME 1500000
    // 30 minutes
    #define ENDRESTTIME 1800000
    
    unsigned long start=0;
    int red=1; // for light flashing state at end of rest time
    int green=0;
    
    void setup() {
      pinMode(GREEN_LED, OUTPUT);
      pinMode(RED_LED, OUTPUT);
      pinMode(PUSH2, INPUT);
      digitalWrite(GREEN_LED, HIGH); // start work
      digitalWrite(RED_LED, LOW); // stop rest
      start=millis();
    }
    
    void loop () {
      if ((millis()-start)>ENDWORKTIME) {
        digitalWrite(GREEN_LED, LOW); // stop work
        digitalWrite(RED_LED, HIGH); // start rest
      }
    
      if ((millis()-start)>ENDRESTTIME) {
        flicker(); // warn that we've overrun
      }
    
      if (digitalRead(PUSH2) == LOW) { // push quiet/off switch
        off();
      }
    }
    
    void flicker() { // toggle LEDs and wait a bit
      red=1-red;
      green=1-green;
      digitalWrite(GREEN_LED, green);
      digitalWrite(RED_LED, red);
      delay(333);
    }
    
    void off() { // appear to be off
      digitalWrite(GREEN_LED, LOW); // lights off
      digitalWrite(RED_LED, LOW);
      while (1) { // loop until reset
        delay(50);
      }
    }
    

    (or if you’d rather have the archived sketch: launchpomodoro-121015a.zip.)

    It would be trivial to port this to Arduino, but you would need some external LEDs, resistors and a pushbutton.

  • It’s the Avtomotive Bvilding!

    It’s the Avtomotive Bvilding!

    Instagram filter used: Lo-fi

    Photo taken at: Allstream Centre

    View in Instagram ⇒

  • optar: paper-based archiving

    Update, 2026: If you must mess with optar, this fork looks like it will build better: colindean / optar

    I’ve spent most of the day messing around with Twibright Optar, a way of creating printed archives of binary data that can be scanned back in and restored.  It looks like it was written as a proof-of-concept, as the only way to change options is to modify the code and recompile. Eppur si muove.

    To compile the code on OS X, I found I had to change this line in the Makefile from:

    LDFLAGS=-lm

    to

    LDFLAGS=-lm  `libpng-config --L_opts`

    After trying to print some samples at the default resolution, I had no luck, so for reliability I halved the data density settings in the file optar.h:

    #define XCROSSES 33 /* Number of crosses horizontally */
    #define YCROSSES 43 /* Number of crosses vertically */

    It’s quite important that your image prints and scans with a whole number of printer dots to image pixels. This used to be quite easy to do, before the advent of PDF’s “Scale to fit” misfeature, and also printer drivers that do a tonne of work in the background to “improve” the image. Add the mismatch between laser printer resolutions (300, 600, 1200 dpi …) and inkjets (360, 720, 1440 dpi …), and you’ve got lots of ways that this can go wrong.

    Thankfully, there’s one common resolution that works across both types of printers. If you output the image at 120 dpi, that’s 5 laser printer dots at 600 dpi, or six inkjet dots at 720 dpi. And there was peace in the kingdom.

    Here’s a demo, based on this:

    So I took this track (which I used to have as a 7″, got at a jumble sale in the mid-70s) and converted it to a really low quality MPEG-2.5: MichelinJingle8kbit — that’s 175KB for just shy of three minutes of music (which, at this bitrate, sounds like it’s played through a layer of socks at the bottom of the Marianas Trench, but still).

    Passing it through optar (which I wish wouldn’t produce PGM files; its output is mono) and bundling the pages into a PDF, I get this: optar_mj.pdf (760KB). Scanning that printout at 600dpi and running the pages through unoptar, I got this: optar1_mj.mp3. It’s the same as the input file, except padded with zeros at the end.

    Sometimes, the scanning and conversion doesn’t do so well:

    • mjoptar300dpi.mp3 — this is what happens when you scan at too low a resolution.
    • mjx.mp3 — I have no idea what went wrong here, but: glitchtastic!
  • Och shite, it’s Frightened Rabbit!

    Och shite, it’s Frightened Rabbit!

    Instagram filter used: Lo-fi

    Photo taken at: Virgin Mobile Mod Club

    View in Instagram ⇒

  • ATTiny programming board

    It’s amazing what you can do when you raid your parts bin …

    Featuring fully configurable M-F jumpers so I can program (pretty much) any Atmel ATTiny microcontroller up to 28 pins. Might be able to do some ATMegas too.

  • Ball’s Falls

    Ball’s Falls

    Instagram filter used: Lo-fi

    View in Instagram ⇒

  • Same old man ..,

    Same old man ..,

    Instagram filter used: X-Pro II

    View in Instagram ⇒

  • Happy Thanksgiving, You Hosers

    Happy Thanksgiving, You Hosers

    Instagram filter used: Hefe

    Photo taken at: Ball’s Falls Conservation Area & Centre For Conservation

    View in Instagram ⇒

  • Rocks

    Rocks

    Instagram filter used: Rise

    View in Instagram ⇒

  • Hey look, there at the back, a wooden tree, isn’t it a pretty one?

    Hey look, there at the back, a wooden tree, isn’t it a pretty one?

    Instagram filter used: X-Pro II

    Photo taken at: Ball’s Falls Conservation Area & Centre For Conservation

    View in Instagram ⇒

  • Major Organ

    Major Organ

    Instagram filter used: Lo-fi

    Photo taken at: Ball’s Falls Conservation Area & Centre For Conservation

    View in Instagram ⇒

  • Pipe organ

    Pipe organ

    Instagram filter used: Normal

    View in Instagram ⇒

  • Exploding colours

    Exploding colours

    Instagram filter used: Lo-fi

    View in Instagram ⇒

  • Painfully Slow Amstrad CPC Emulation on the Raspberry Pi

    Yeah, you can do it, but whether you should, I don’t know. Download the latest Arnold/Linux source, then (according to this post) after installing the dependencies, you just need to change

    TARGET_FMT=elf32-i386

    to

    TARGET_FMT=elf32-littlearm

    in src/Makefile.in.

    It works, for very slow values of “works”. Mind you, I was running it through a remote X session, so 2 fps is all I could have hoped for …