2009-12-31

Reality Blows: Strange LCD Problem and Strange Solution.

I spent the better part of two hours struggling with your average HD44780 driven 16x2 character LCD, even though I was using the LiquidCrystal library that comes with the arduino environment. My problem was the text I was printing out looks like this:


I tried a lot of things, like adding in delays here and there, even going so far as to use a subclass of LiquidCrystal which inserts a 2ms delay after each write to no avail. Then by a process of elimination, I found that if I reverse the order in which the lines were printed, i.e. print line 1 then line 0, the problem goes away:


Whiskey Tango Foxtrot.

Cheers,
Steve

Order Matters With XCode's Build Phrases

I use a custom script to insert the current git commit into GeoNote, so when I get bug reports I have a better idea of which version the user is running. The script is as below:

import os
from Foundation import NSMutableDictionary

version = os.popen4("/sw/bin/git rev-parse --short HEAD")[1].read()
info = os.environ['INFOPLIST_FILE']
print info
plist = NSMutableDictionary.dictionaryWithContentsOfFile_(info)
print plist
plist['revision'] = version[:-1]
plist.writeToFile_atomically_(info, 1)

This was added as a Run Script Build Phrase. The problem I noticed was that the commit short hash inserted into Info.plist was always one commit behind. After some head scratching, I realised this was because by default the new build phrase is inserted last, and the order matters! It isn't actually possible to reorder build phrases by drag and dropping the children nodes around. You have to do a head-insert by dragging a child to the parent, which inserts it at the top.


Voila, problem solved.

Cheers,
Steve

2009-12-22

Don't Worry About the Pirates.

So you are an indie musician, and you are worried about pirates – those naughty people who are allegedly stealing food off your table and from the mouth of your children.

Well I am here to tell you there is no need to worry – pirates may just be the best thing to ever happen to you.

First, let me tell you something that you probably don't want to hear – you are nobody. You are nobody in the sense that 99.9999% of the people on this planet has never heard of you. The only way to change this is to get your music into the ears of as many people as possible

Big artists do this – they have TV spots, radio spots, newspaper reviews. These are all ways to reach listeners without them paying anything.

This is also what you need to do, and pirates do this very well. If a single pirate distributed your music to two other pirates, and they in turn distribute to two more pirates and so forth, in a very short time you would have reached all of western civilisation.

Now I can see you getting puffed up, about to yell at me how this doesn't make you a dime. Just give me a second, will you?

The second thing I am going to tell you is that to a first approximation, you make money only from your fans. Remember that the word "fan" comes from fanatic – they are people who bought the Fellowship of the Ring when it first came out on DVD, then bought the Director's Cut, then bought the Special Limited Collector's Tin Box Edition , and then the Super Mega Ultra Edition that came with a Gandalf bust, then they did it again for the Two Towers, Return of the King, then for the whole damn series. These are people who have 12 versions of each Lord of The Rings trilogy, and will purchase the anniversary edition when it comes out in 2012 anyway.

The point is: your fans love you, they will buy your music, your merchandise, and go to your concerts even if they can get it for free – that is just how fans are.

Now the only way to get fans is to have people listen to your music, and as long as you have a non-zero conversion rate of joe-listener-to-fan, you come out on top. The more people you reach, the more fans you get, and the more money you make.

Just in case you don't get it yet, here it is in point form:

  • no one has heard of you
  • if no one has heard of you, you have no fans
  • you make money from fans
  • people become fans from listening to your music
  • pirates distribute your music to millions, even billions of people
  • this increases your fanbase
  • a larger fanbase means more money
  • a large enough fanbase means you have Made It Big

Got it?

Cheers,
Steve

Latching Power Supply With Electronic Turn Off



This circuit has (as far as I can tell), 0 off current, and 17mA on current. It is latched by the momentary push button, and can be turned off by applying >0.7V at the input as shown. It is intended for use with embedded interactive installation (e.g. an arduino) where the user pushes the button to turn the device on, and the device will turn itself off after some time to conserve battery.



It is a modified version of this circuit.


Cheers,

Steve

2009-12-17

Nice Work Australia Computer Society


You came to me during my first year in university, and sold yourself as the paragon of virtue and integrity - the kind organisation I would be foolish not to be associated with if I want to get anywhere in Australia doing software, or "Information Technology" as they call it now days.




I didn't join then, because I didn't have the money. I didn't join later because my career focus shifted away from software. I won't join now ever, because you have sold out.




I am referring to the honorary membership you awarded to none other than one Stephen Conroy, Internet Villain of the Year, 2009.




You had such nice things to say about him too:




“We are very pleased to honour Senator Conroy’s contribution and support of the significance of ICT to the economy and the key role of ICT professionals in Australia’s future,” said Mr Wells.



If I am so inclined as to read between the lines, I can't help but get the feeling you are thanking Mr. Conroy for pushing the Internet filter scheme, and in the process provided jobs for the programmers and technicians involved in the various trials and consultations.




“Senator Conroy has always encouraged the ACS in its role as the independent voice of the ICT profession, welcoming our input to various enquiries and working groups, and regularly attending key ACS events. We are grateful for his on-going support,” Mr Wells said.



I don't think Mr. Conroy is listening to your input, or learning from your events - he continues to believe filtering the Internet is doable, and not a waste of time and resources.




I reject you, Australia Computer Society, as "voice of the ICT profession". Your actions are deplorable and shows a lack of integrity. If I was a member, I would be ashamed.




Cheers,

Steve

2009-12-16

Yet Another Arduino Float Print Function

Note: in arduino-0017, floating point printing is supported by default. The function below is not necessary.

void floatPrint(float f, int places=6)
{
        int _d;
        if (f < 0)
        {
                Serial.print("-");
                f*=-1;
        }

        _d = (int)f;
        
        if (!places)
        {
                return;
        }

        Serial.print(_d, DEC);
        Serial.print('.');

        while(places--)
        {
                f-=_d;
                f*=10;
                _d = (int)f;
                Serial.print(_d, DEC);
        }
}

void floatPrintln(double f, int places=6)
{
        floatPrint(f, places);
        Serial.println();
}
Why another float print function? The ones I found wasn't too nice, one of which required long integers. Yuck. It was also fun, and now I know where to look for one in the future :P
Cheers,
Steve

2009-12-07

A subtle source of linker errors under XCode



If one source file is sourcecode.c.objc and another is sourcecode.cpp.objcpp, you will have problems if you try to call function defined in one file from the other. The resolve this either make them the same source type, or follow this guide.



This drove me nutty because the template I was working off has code set to sourcecode.cpp.objcpp, but XCode adds new classes as sourcecode.c.objc! To check the file type, use "Get Info" in the source file's context menu.



Cheers,

Steve