Category: computers suck

  • … we stand in line for thee

    A little bit of silliness for Thanksgiving:

    This took almost no time to put together. The “speaker” is a Tim Hortons cup with a cheap piezo glued to the base. What makes the Arduino sing is the Tone Library running its RTTTL demo sketch, with the anthem itself pasted in from a rather old Nokia Ringtones library.

    Update: Here’s the code, such as it is. It’s just the Tone/examples/RTTTL code with the tune data pasted in. I’d been programming Arduino for about a year, so that was a semi-major achievement for me:

    It’s nice to revisit old code and find it was written by a friend, Brett Hagman of Rogue Robotics.

  • Arduino Uno USB invisible to OS X

    as posted on the forum:

    Just got my Uno after finding semi-permanent projects for two previous Duemilanoves. Upgraded to Arduino 0020. After rebooting, and power cycling the Uno, there’s still no serial port for the Uno.

    The board is noted under Linux, which reports an unknown device with ID 2341:0001. On my MacBook (10.6.4), System Profiler lists:
    Code:

    Communication Device:
    
      Product ID:	0x0001
      Vendor ID:	0x2341
      Version:	 0.00
      Speed:	Up to 12 Mb/sec
      Location ID:	0x24110000
      Current Available (mA):	500
      Current Required (mA):	Unknown (Device has not been configured) 
    
    

    There are no /dev/tty* or /dev/cu* devices that correspond to the device.

  • Netflix vs Zip.ca

    So, Netflix Canada launched today. As a (fairly) loyal Zip.ca subscriber, I was worried, but to be honest, I can do without putting DVDs in the mail every week. Since we can watch Netflix on the Wii, I thought I’d sign up for a trial month.

    I tried to find things I’d want to see. Netflix is drawing blanks. I took my list of 30 movies I have queued at Zip to see how they compare. It’s not so good:

    # Title Zip.ca Netflix
    1 A Single Man ✓ ✗
    2 The Dish ✓ ✗
    3 Becoming Jane ✓ ✗
    4 October Sky ✓ ✓
    5 Playtime ✓ ✗
    6 The Commitments ✓ ✗
    7 The Cove ✓ ✗
    8 Storytelling ✓ ✗
    9 Jay And Silent Bob Strike Back ✓ ✗
    10 Princess Mononoke ✓ ✗
    11 Kiki’s Delivery Service ✓ ✗
    12 Whisper of the Heart ✓ ✗
    13 Salesman ✓ ✗
    14 Festival Express ✓ ✗
    15 Fat Girl (A ma soeur!) ✓ ✗
    16 Adam ✓ ✗
    17 Micmacs (Micmacs à tire-larigot) ✓ ✗
    18 A Chorus Line ✓ ✗
    19 This is England ✓ ✓
    20 Crumb
    ✓ ✗
    21 The Harold Lloyd Comedy Collection ✓ ✗
    22 Old-Time Banjo Styles ✗ ✗
    23 Learning Mountain Dulcimer ✗ ✗
    24 Animation Greats! ✗ ✗
    25 Black Cat, White Cat ✗ ✗
    26 Northfork ✗ ✗
    27 Leningrad Cowboys: Total Balalaika Show ✗ ✗
    28 The Turning Point ✗ ✗
    29 Winter’s Bone ✗ ✗
    30 Hum Dil De Chuke Sanam ✗ ✗

    Available 70% 7%

    The unavailable titles at Zip are ones they know about, and will try to find. Not surprisingly, all of them are also not available from Netflix. The only ones I could watch at Netflix are October Sky and This Is England. And would you credit it, but didn’t the DVD for October Sky just arrive yesterday …

    Look, I know it’s early days, but Netflix needs to get a bunch better in the next 30 days. Oh, and it could do with some CanCon – it’s very weak there.

  • much improved HSV colour cycling LED on Arduino

    There were some flaws in the post HSV colour cycling LED on Arduino. This does much more what I wanted:

    /*
    HSV fade/bounce for Arduino - Stewart C. Russell - scruss.com - 2010/09/19
    
    Wiring:
    LED is RGB common cathode (SparkFun sku: COM-09264 or equivalent)
        * Digital pin  9 → 165Ω resistor → LED Red pin
        * Digital pin 10 → 100Ω resistor → LED Green pin
        * Digital pin 11 → 100Ω resistor → LED Blue pin
        * GND → LED common cathode.
    */
    
    #define RED                9 // pin for red LED; green on RED+1 pin, blue on RED+2 pin
    #define DELAY              2
    
    long rgb[3];
    long rgbval, k;
    float hsv[3] = {
      0.0, 0.5, 0.5
    };
    float hsv_min[3] = {
      0.0, 0.0, 0.4 // keep V term greater than 0 for smoothness
    };
    float hsv_max[3] = {
      6.0, 1.0, 1.0
    };
    float hsv_delta[3] = {
      0.0005, 0.00013, 0.00011
    };
    
    /*
    chosen LED SparkFun sku: COM-09264
     has Max Luminosity (RGB): (2800, 6500, 1200)mcd
     so we normalize them all to 1200 mcd -
     R  1200/2800  =  0.428571428571429   =   109/256
     G  1200/6500  =  0.184615384615385   =    47/256
     B  1200/1200  =  1.0                 =   256/256
     */
    long bright[3] = {
      109, 47, 256
    };
    
    void setup () {
      randomSeed(analogRead(4));
      for (k=0; k<3; k++) {
        pinMode(RED + k, OUTPUT);
        rgb[k]=0; // start with the LED off
        analogWrite(RED + k, rgb[k] * bright[k]/256);
        if (k>1 && random(100) > 50) {
          // randomly twiddle direction of saturation and value increment on startup
          hsv_delta[k] *= -1.0;
        }
      }
    }
    
    void loop() {
      for (k=0; k<3; k++) { // for all three HSV values
        hsv[k] += hsv_delta[k];
        if (k<1) { // hue sweeps simply upwards
          if (hsv[k] > hsv_max[k]) {
            hsv[k]=hsv_min[k];
          }    
        }
        else { // saturation or value bounce around
          if (hsv[k] > hsv_max[k] || hsv[k] < hsv_min[k]) {
            hsv_delta[k] *= -1.0;
            hsv[k] += hsv_delta[k];
          }
        }
        hsv[k] = constrain(hsv[k], hsv_min[k], hsv_max[k]); // keep values in range
      }
    
      rgbval=HSV_to_RGB(hsv[0], hsv[1], hsv[2]);
      rgb[0] = (rgbval & 0x00FF0000) >> 16; // there must be better ways
      rgb[1] = (rgbval & 0x0000FF00) >> 8;
      rgb[2] = rgbval & 0x000000FF;
    
      for (k=0; k<3; k++) { // for all three RGB values
        analogWrite(RED + k, rgb[k] * bright[k]/256);
      }
      delay(DELAY);
    }
    
    long HSV_to_RGB( float h, float s, float v ) {
      /*
         modified from Alvy Ray Smith's site:
       http://www.alvyray.com/Papers/hsv2rgb.htm
       H is given on [0, 6]. S and V are given on [0, 1].
       RGB is returned as a 24-bit long #rrggbb
       */
      int i;
      float m, n, f;
    
      // not very elegant way of dealing with out of range: return black
      if ((s<0.0) || (s>1.0) || (v<0.0) || (v>1.0)) {
        return 0L;
      }
    
      if ((h < 0.0) || (h > 6.0)) {
        return long( v * 255 ) + long( v * 255 ) * 256 + long( v * 255 ) * 65536;
      }
      i = floor(h);
      f = h - i;
      if ( !(i&1) ) {
        f = 1 - f; // if i is even
      }
      m = v * (1 - s);
      n = v * (1 - s * f);
      switch (i) {
      case 6:
      case 0: // RETURN_RGB(v, n, m)
        return long(v * 255 ) * 65536 + long( n * 255 ) * 256 + long( m * 255);
      case 1: // RETURN_RGB(n, v, m) 
        return long(n * 255 ) * 65536 + long( v * 255 ) * 256 + long( m * 255);
      case 2:  // RETURN_RGB(m, v, n)
        return long(m * 255 ) * 65536 + long( v * 255 ) * 256 + long( n * 255);
      case 3:  // RETURN_RGB(m, n, v)
        return long(m * 255 ) * 65536 + long( n * 255 ) * 256 + long( v * 255);
      case 4:  // RETURN_RGB(n, m, v)
        return long(n * 255 ) * 65536 + long( m * 255 ) * 256 + long( v * 255);
      case 5:  // RETURN_RGB(v, m, n)
        return long(v * 255 ) * 65536 + long( m * 255 ) * 256 + long( n * 255);
      }
    } 
    
  • my little nerd whiskers are quivering

    I notice that TheSource.ca has the BlueLine PowerCost Monitor at a good price. I also notice that the PowerCost uses 433MHz wireless, for which you can get a 433MHz Receiver Shield for Arduino. People have used this to receive data from home weather stations.

    It’s just a smop before I have my own network-connected meter now …

  • HSV colour cycling LED on Arduino

    Pretty much everyone tries the RGB colour cycler when they get their first Arduino. This variant cycles through the HSV colour wheel, though at fixed saturations and values.

    Code:

    // HSV fade/bounce for Arduino - scruss.com - 2010/09/12
    // Note that there's some legacy code left in here which seems to do nothing
    // but should do no harm ...
    
    // don't futz with these, illicit sums later
    #define RED       9 // pin for red LED
    #define GREEN    10 // pin for green - never explicitly referenced
    #define BLUE     11 // pin for blue - never explicitly referenced
    #define SIZE    255
    #define DELAY    10
    #define HUE_MAX  6.0
    #define HUE_DELTA 0.01
    
    long deltas[3] = {
      5, 6, 7 };
    long rgb[3];
    long rgbval;
    // for reasons unknown, if value !=0, the LED doesn't light. Hmm ...
    // and saturation seems to be inverted
    float hue=0.0, saturation=1.0, value=1.0;
    
    /*
    chosen LED SparkFun sku: COM-09264
     has Max Luminosity (RGB): (2800, 6500, 1200)mcd
     so we normalize them all to 1200 mcd -
     R  1200/2800  =  0.428571428571429   =   109/256
     G  1200/6500  =  0.184615384615385   =    47/256
     B  1200/1200  =  1.0                 =   256/256
     */
    long bright[3] = {
      109, 47, 256};
    
    long k, temp_value;
    
    void setup () {
      randomSeed(analogRead(4));
      for (k=0; k<3; k++) {
        pinMode(RED + k, OUTPUT);
        rgb[k]=0;
        analogWrite(RED + k, rgb[k] * bright[k]/256);
        if (random(100) > 50) {
          deltas[k] = -1 * deltas[k]; // randomize direction
        }
      }
    }
    
    void loop() {
      hue += HUE_DELTA;
      if (hue > HUE_MAX) {
        hue=0.0;
      }
      rgbval=HSV_to_RGB(hue, saturation, value);
      rgb[0] = (rgbval & 0x00FF0000) >> 16; // there must be better ways
      rgb[1] = (rgbval & 0x0000FF00) >> 8;
      rgb[2] = rgbval & 0x000000FF;
      for (k=0; k<3; k++) { // for all three colours
        analogWrite(RED + k, rgb[k] * bright[k]/256);
      }
      delay(DELAY);
    }
    
    long HSV_to_RGB( float h, float s, float v ) {
      /* modified from Alvy Ray Smith's site: http://www.alvyray.com/Papers/hsv2rgb.htm */
      // H is given on [0, 6]. S and V are given on [0, 1].
      // RGB is returned as a 24-bit long #rrggbb
      int i;
      float m, n, f;
    
      // not very elegant way of dealing with out of range: return black
      if ((s<0.0) || (s>1.0) || (v<0.0) || (v>1.0)) {
        return 0L;
      }
    
      if ((h < 0.0) || (h > 6.0)) {
        return long( v * 255 ) + long( v * 255 ) * 256 + long( v * 255 ) * 65536;
      }
      i = floor(h);
      f = h - i;
      if ( !(i&1) ) {
        f = 1 - f; // if i is even
      }
      m = v * (1 - s);
      n = v * (1 - s * f);
      switch (i) {
      case 6:
      case 0:
        return long(v * 255 ) * 65536 + long( n * 255 ) * 256 + long( m * 255);
      case 1:
        return long(n * 255 ) * 65536 + long( v * 255 ) * 256 + long( m * 255);
      case 2:
        return long(m * 255 ) * 65536 + long( v * 255 ) * 256 + long( n * 255);
      case 3:
        return long(m * 255 ) * 65536 + long( n * 255 ) * 256 + long( v * 255);
      case 4:
        return long(n * 255 ) * 65536 + long( m * 255 ) * 256 + long( v * 255);
      case 5:
        return long(v * 255 ) * 65536 + long( m * 255 ) * 256 + long( n * 255);
      }
    }
    

    The circuit is very simple:

    • Digital pin 9 → 165Ω resistor → LED Red pin
    • Digital pin 10 → 100Ω resistor → LED Green pin
    • Digital pin 11 → 100Ω resistor → LED Blue pin
    • GND → LED common cathode.

    The different resistor values are to provide a limited current to the Triple Output LED RGB – Diffused, as each channel has different requirements. The 165Ω resistor is actually two 330Ω in parallel; I didn’t have the right value, and this was the closest I could make with what I had.

  • old computers, new computer

    Had a bit of a clear-out yesterday. I dropped off

    • one Sempron-based PC
    • an ancient eMac
    • a built-like-a-tank Samsung laser printer
    • two monitors: one LCD, one flatscreen
    • two mini-itx boxen of undetermined operation
    • about six external USB drives
    • a DVD player with VGA output
    • a box of stuff, including various network thingies, an NSLU-2 and a KVM switch.

    at Free Geek Toronto. I’d heard about them from Colin at Mappy Hour, the monthly(ish) OpenStreetMap event. They have a very neat warehouse, and are definitely doing the right thing in getting surplus electronics either to people who need them, or properly recycled. On the (lengthy – 2 hours from the Junction to home, grr) drive back, I even heard a tiny CBC radio spot about them. Shame that the announcer almost said “old electronics crap” instead of “old electronics gear”, though …

    I just built a new linux box to replace a bunch of the stuff I just threw out. It’s a small and quiet MSI 6676-003BUS with a fanless Atom 510 processor. It plugs straight into the HDMI of the TV, and remote work is done with VLC or SSH. To cut down clutter, I’m using a cheapo Logitech® Cordless MediaBoard Pro for PLAYSTATION®3, which works just fine as a keyboard and mouse with a generic $10 bluetooth USB adaptor.

  • To view Ubuntu Remote Desktop under OS X …

    … you need to set a password — even a trivial one — on the Ubuntu Remote Desktop settings. OS X won’t connect to your remote desktop if you don’t set a password.

    That is all.

  • what NBC sounds like in canada

    This is what NBC sounds like in Canada. I guess it’s okay to have a message, but no need to get all Yankee Hotel Foxtrot about it. I snipped off the obnoxious taco ads; NBC is so ad-infested that they have to wedge them in their videos.

    I was trying to watch a Molly Lewis video, but it failed. Guess they forgot the WW in the web …

  • HTML Canvas string-rewriting fractal

    I’d hoped to have a working demo in here, but WordPress doesn’t like the <canvas> element, so here are a couple of static screendumps:

    looks like a buffalo being attacked by crinkle-cut chipsI wrote a routine in JavaScript that recursively rewrites strings of instructions, then interprets them as a simple turtle-like language to draw on the canvas. In my copious free time, I’ll release it as a simple web app that you can play with these L-systems. But you can do some fun stuff here until I get it written.

    (for more details, see Appendix C of H. Peitgen and D. Saupe, Eds. The Science of Fractal Images, New York: Springer, 1988.)

  • Guess the iPhone app

    Okay, so what’s this, just given its content warnings:

    You must be at least 17 years old to download this game.

    Frequent/Intense Profanity or Crude Humor
    Frequent/Intense Sexual Content or Nudity
    Frequent/Intense Mature/Suggestive Themes
    Frequent/Intense Simulated Gambling
    Frequent/Intense Cartoon or Fantasy Violence
    Frequent/Intense Alcohol, Tobacco, or Drug Use or References
    Frequent/Intense Realistic Violence
    Frequent/Intense Horror/Fear Themes

    ?
    Sounds pretty nasty, eh? Definitely not something for the kids.

    Wrong; it’s an ebook reader (specifically i2Reader). Just ‘cos Apple can’t control the content that you read on it, it slaps warnings all over it and makes you feel like a pariah just for looking at it.

  • MeltdownHorrid – an unsettled, stereotyped font

    I took the glyphs of an overused generic font, and subjected them repeatedly to the modern equivalent of stereotyping: rasterized them, then autotraced the bitmaps. As a side effect, all the character heights were lost, so everything’s the same size.

    Truetype: MeltdownHorrid.zip

  • PoorFish: an apology font

    Truetype font: PoorFish.zip.

    This is the first one I’ve done that hasn’t needed a printer or scanner. I exported the template to a single image (chargrid.png), then hand-wrote the characters using my graphics tablet on a new transparent layer in Gimp.

  • GrubblyScrub: a wax-resist font

    Again, the spacing needs work.

    File: GrubblyScrub.zip

  • CPC – a provisional bitmap font

    This isn’t quite right yet – characters aren’t encoded correctly, and it’s not quite as monospaced as it should be, but it has some nostalgia value. It’s the screen font used by the Amstrad CPC.

    Font: CPC-0.9.zip

  • AtkNoise – a corroded font

    File: AtkNoise. Probably best at as a display font.

    (The name’s from the process I used to make the font. I masked the font over greyscale noise at fairly low resolution, then applied Atkinson dithering, then fed the result through potrace. I’ve used this technique before.)

  • Handwriting font example: CrapHand

    And here’s the TrueType font of that: CrapHand.ttf. Enjoy!

  • creating a TrueType font from your handwriting with your scanner, your printer, and FontForge

    Hey, this post is super old!
    That means that installation and run instructions may not work as well, or even at all. Most of the *Ports Apple software repositories have given way to Homebrew: you may have some success on Mac (untested by me) if you brew install netpbm fontforge potrace. There’s also some font cleanup I’d recommend, like resolving overlaps, adding extrema, and rounding points to integer. One day I may update this post, but for now, I’m leaving it as is.

    This looks more than a bit like my handwriting

    because it is my handwriting! Sure, the spacing of the punctuation needs major work, and I could have fiddled with the baseline alignment, but it’s legible, which is more than can usually be said of my own chicken-scratch.

    This process is a little fiddly, but all the parts are free, and it uses free software. This all runs from the command line. I wrote and tested this on a Mac (with some packages installed from DarwinPorts), but it should run on Linux. It might need Cygwin under Windows; I don’t know.

    Software you will need:

    • a working Perl interpreter
    • NetPBM, the free graphics converter toolkit
    • FontForge, the amazing free font editor. (Yes, I said amazing. I didn’t say easy to use …)
    • autotrace or potrace so that FontForge can convert the scanned bitmaps to vectors
    • some kind of bitmap editor.

    You will need to download

    • fonttrace.pl – splits up a (very particular) bitmap grid into character cells
    • chargrid.pdf – the font grid template for printing

    Procedure:

    1. Print at least the first page of chargrid.pdf. The second page is guidelines that you can place under the page. This doesn’t work very well if you use thick paper.
    2. Draw your characters in the boxes. Keep well within the lines; there’s nothing clever about how fonttrace.pl splits the page up.
    3. Scan the page, making sure the page is as straight as possible and the scanner glass is spotless. You want to scan in greyscale or black and white.
    4. Crop/rotate/skew the page so the very corners of the character grid table are at the edges of the image, like this: I find it helpful at this stage to clean off any specks/macules. I also scale and threshold the image so I get a very dark image at 300-600dpi.
    5. Save the image as a Portable Bitmap (PBM). It has to be 1-bit black and white. You might want to put a new font in a new folder, as the next stage creates lots of files, and might overwrite your old work.
    6. Run fonttrace.pl like this:
      fonttrace.pl infile.pbm | sh
      If you miss out the call to the shell, it will just print out the commands it would have run to create the character tiles.
    7. This should result in a bunch of files called uniNNNN.png in the current folder, like these:

      W
      uni0057.png

      i
      uni0069.png

      s
      uni0073.png

      p
      uni0070.png

      y
      uni0079.png
    8. Fire up FontForge. You’ll want to create a New font. Now File→Import…, and use Image Template as the format. Point it at the first of the image tiles (uni0020.png), and Import.
    9. Select Edit→Select→All, then Element→Autotrace. You’ll see your characters appear in the main window.
    10. And that’s – almost – it. You’ll need to fiddle with (auto)spacing, set up some kerning tables, set the font name (in Element→Font Info … – and you’ll probably want to set the em scale to 1024, as TrueType fonts like powers of two), then File→Generate Fonts. Fontforge will throw you a bunch of warnings and suggestions, and I’d recommend reading the help to find out what they mean.

    There are a couple of limitations to the process:

    • Most of the above process could be written into a FontForge script to make things easier
    • Only ASCII characters are supported, to keep the number of scanned pages simple. Sorry. I’d really like to support more. You’re free to build on this.

    Lastly, a couple of extra files:

    • CrapHand2.pbm – a sample array drawn by me, gzipped for your inconvenience (and no, I don’t know why WordPress is changing the file extension to ‘pbm_’ either).
    • chargrid.ods – the OpenOffice spreadsheet used to make chargrid.pdf

    Have fun! Write nicely!