What I’ve been working on

Lately I’ve gotten interested in embedded devices. Starting with an Arduino Uno and a Sparkfun starter kit, I am designing an electronic level.

Arduino uses an ATMega microcontroller and a bootloader. Then using their free IDE, you write your program in C++. Upload it through USB and watch what happens! You can read input from a variety of sensors and transmit that input. Or use the input to do something.

I have my circuits designed and functioning. Next up is etching a prototype pcb and testing.

Mobile Platforms

I have recently started listening to the What Now? podcast (www.whatnowpodcast.com). It has me thinking about the different mobile platforms there are to program against. The main contenders are:

  • iPhone/iPod Touch
  • iPad
  • Android Phones
  • Android Tablets
  • Locked down Android Tablets (Kindle Fire, Nook Color and Nook Tablet)
  • Blackberry and their playbook tablet
  • Windows Phones

I have a developer’s account that allows me to test and release apps for iPhone/iPod Touch/iPad.  I have an iPhone 4, an iPad 1, and multiple iPod Touches.  I do not have any of the other devices (except my son has a Nook Color). I am not going to develop for Blackberry or Windows phones. I will develop for the iOS devices, and maybe port to Android devices if it seems economically feasible.

I have started development on a few iPhone apps, but have never released any. I have a few ideas for apps that may be viable, but I haven’t fleshed them out yet.

But what I got to thinking about is what they call “Binary” apps on the podcast. These are apps that sell maybe one copy a day. A good day would be two copies. I can understand not wanting to spend any more time on improving an app that has that little sales. I don’t understand removing an app from the app store that is selling. One of the guys on the podcast said he removed apps that don’t have much in sales. I would leave it there. Every little bit adds to the bottom line. It doesn’t cost you anything to keep selling it.

Maybe it’s the difference between full-time and part-time/hobby developers. Full-time developers need to make enough in sales in order to pay their mortgage and put food on the table. I have a full-time job that takes care of that, so anything I develop and sell is extra. Would I like to come up with the killer app that pays 3x what I make being an employee? Of course, but I also realize my chances of doing that are about the same as hitting the lottery million dollars jackpot.

Right now I am a hobby developer. I say that because I spend more than I take in from software development. My goal for this year is to get a paying app published in the App Store.

Converting a NSString to a NSDate

There are plenty of code snippets and tutorials online about how to convert a NSString to a NSDate. Unfortunately for me I could not just plug them into the iPhone app that I am writing.

Here’s what you typically see:

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MM-dd-yyyy hh:mm aaa"];

NSDate *aDate = [dateFormatter dateFromString:(NSString *)dateString];

This will create a NSDate object named aDate.  The only problem is that aDate will have the timezone of GMT.  It also assumes that the string passed in has an implied timezone of GMT.  I don’t have any problem with dates that have a timezone of GMT.  That’s how I store all the dates in the database.  When I later use NSDateFormatter stringFromDate it will convert the time component of the date to the system timezone (or local timezone if you change the timezone programmatically for the app).  So I get time conversion for “free” without having to worry about the timezone the device is currently in or daylight savings time.  Those are headaches I can do without!

My specific problem is that the string that I am converting to a date is based on local time for a different timezone than where I am at.  I am in Eastern/New York.  Some of the strings are Central, some are Mountain.  Since I am only dealing with two locations, I can hard-code the timezone based on another string that gives me the location name.

Here is what I am doing:

// Convert the date from another timezone to GMT time
- (NSDate *)MakeDateFromString:(NSString *)aDate forLocation:(NSString *)location withFormat:(NSString *)format{
     NSString *beginLocation = [location substringToIndex:1];
     NSString *timeZoneAbbr;
     if ([beginLocation isEqualToString:@"D"]) {
          timeZoneAbbr = @"MST";
     }
     else {
          timeZoneAbbr = @"CST";
     }

     NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
     [dateFormatter setDateFormat:format];
     NSDate *firstDate = [dateFformatter dateFromString:(NSString *)aDate];

     //firstDate is now converted to GMT time based on the timezone
     // the device is located in.  We do this by finding the difference 
     // between the timezone the string comes from and the local timezone.

     NSTimeZone* sourceTimeZone = [NSTimeZone timeZoneWithAbbreviation:timeZoneAbbr];
     NSTimeZone* destinationTimeZone = [NSTimeZone systemTimeZone];

     NSInteger sourceGMTOffset = [sourceTimeZone secondsFromGMTForDate:firstDate];
     NSInteger destinationGMTOffset = [destinationTimeZone secondsFromGMTForDate:firstDate];

     NSTimeInterval interval = destinationGMTOffset - sourceGMTOffset;
     NSDate* destinationDate = [[NSDate alloc] initWithTimeInterval:interval sinceDate:firstDate];

     // destinationDate is now GMT time, with the correction made 
     // between the origination timezone and the local timezone.
     return destinationDate;

This is how it works:
1. First, I determine the timezone of the local time passed to me. As I said, I only have two locations and can determine that by the first letter of the location.
2. Next I convert the string date passed in to be a date. This will be converted to GMT time, but if the time component of the string is not the same timezone as you are located it will be off by the difference in timezones.
3. Next I create two timezones, sourceTimeZone and destinationTimeZone. sourceTimeZone is for the time zone of the location. destinationTimeZone is for the system timezone.
4. I get the offset in seconds for each timezone from GMT.
5. I then create an interval for the difference between the timezone offsets.
6. That interval is used to adjust the original date created from the string.

My new iPhone app

I think I have finally come up with a good app idea and one that I know I will use. It will use the GPS and keep track of the addresses and times that I am out in the field. It will also have comment fields, so I can put customer names, ticket #s, etc in it. I will then make it so I can email some kind of report.

This will be a huge improvement over how I am tracking (or not) my tickets and overtime. Since I do timesheets for two weeks, I sometimes have trouble remembering where I was and for how long.

I already have some of the pieces coded, now I just have to put it all together!

My VZW iPhone experiences

Today I picked up an iPhone from the Verizon Wireless store. They activated it on iTunes and transferred my contacts from my old flip phone. The sales lady even put on the screen protector and made several trips to the back bringing out different clips/holsters until I found one I liked.

The 3G speed is good. I can’t think of when I would need to talk and surf the web at the same time. I guess since I never had the option previously I don’t know what I am missing :)

My only complaint is with the personal hotspot feature. I didn’t know that it cost extra. I guess I didn’t research it enough. If that isn’t bad enough, the sales lady showed me where to turn it on in the settings menu, but neglected to tell me there was an additional cost.

With the hotspot costing $20/mo for 2GB of data, I cannot justify paying it. My thought was to cancel the AT&T 3G on my iPad and use the wifi hotspot with the iPad. I am still canceling the 3G on the iPad and will just be using the wifi on it, just not through the iPhone.

My iPad Review

I have been meaning to write my impressions on the iPad. What finally spurred me on was an email I received from AT&T asking me to take a survey about the iPad.

Overall, I am very pleased with the iPad. It does almost everything I would want it to. I have the wifi + 3G version. Currently I use the unlimited monthly 3g.

The main thing that I find myself missing is printing. Once Apple figures out how to enable printing to a Mac or Windows shared printer, the iPad would be everything I need for light to medium computing.

For Apple’s iWork productivity suite, right now I have only used Numbers (their spreadsheet program). I can import Excel spreadsheets easily, but until I can export to Excel I don’t see myself using it as much as I would like. Think about this: you need to do some kind of inventory. You keep track of the inventory on your desktop in an Excel spreadsheet. You can easily email the excel sheet to your iPad. You can easily update the counts on your iPad. What you can’t do is email it back to your work computer. Your options (for email) are to send it as a PDF or as a Numbers spreadsheet. I guess I need to see if Excel can import a Numbers spreadsheet.

As for the 3g, I wish that I had the option to use it with Verizon. I made a trip to NY state last week. I didn’t have 3g coverage in NY at all. It was all on Edge (2g). 3g is slow enough. Edge is unbearable. Luckily I have 3g coverage where I live.

Facebook privacy

There has been a lot of news lately about Facebook and their privacy problems. Most of the reports, articles, etc have been in locations that only techies read. But it is starting to go mainstream. When you have a well known tech journalist announcing that he (Leo Laporte) is quitting Facebook on a national radio show, it shows that there is some growing momentum.

Leo stated his reasons for quitting Facebook as:

  1.  the privacy settings are too difficult for him to figure out, so how would a “normal, not technical” user be able to
  2. Facebook originally had a contract with its users that everything is private, now they are making everything public by default, and 
  3. as a public personality, he felt that to have a Facebook fan page was a tacit endorsement of Facebook and would mislead his audience, some of who are not technical (Leo has a national radio show where people call in for help with computers, etc. It is called The Tech Guy).

As an experiment, I logged into my oldest son’s Facebook page to tweak the privacy settings. Since he does not get on the computer much, I have gmail set up to get his email. After the third “friend” request that was a woman who had their profile picture of them wearing only underwear and all their wall posts were links to “the pictures I took of myself last night,” I decided that something had to give. So I logged into his account and changed the privacy settings.

Facebook’s privacy settings can be a bit daunting. A lot of the settings are defaulted to “Everyone,” which means that everyone can see that information even if they don’t have a Facebook page. Another setting defaults to making all your information searchable by Google and other search engines. I think one of the problems I was having with my son’s account is he put his birth year in wrong (had to, Facebook doesn’t allow 11 year olds to sign up. So he added 10 years to his birth year. Unfortunately that means Facebook thinks he is a 21yo male ). I changed his birth year so that it appears he is 13yo.

I am not going into all the settings I changed. Suffice it to say that most settings are either “only me” or “friends only.” Even changing the settings to “only me” was a challenge, as it was hidden behind the “Customize” menu option.

What I believe Facebook should do is change their privacy settings to a simple slider (sort of like the Privacy tab on Internet Explorer’s Internet Options panel. It should have a reasonable default that doesn’t make too much information public. Then there should be an Advanced button so that users can tweak their settings as desired. And most important, once they pick a default, they have to make a corporate decision (and publish it) that the default privacy can only be changed by them to more private. What I mean is that if they decide to change the default privacy, they will only change to more private, never to more public. If they think their users would be better served by one of the settings being made more public, they need to make that case. And the case they present should be compelling enough that the users would make the choice to change the setting. The only way the privacy settings can be moved to more public should be by the users, not the system.

Changing the privacy settings like this should solve the complaints about Facebook’s privacy settings being too complex and difficult to figure out. I think that to start out, there should be four choices:

  1. Paranoid (just because you’re paranoid doesn’t mean they aren’t after you :) )
  2. Worried (make the default for under 18yo)
  3. Normal (default)
  4. Public personality

Then put a link or button for advanced settings. Believe me, 90% or more of the users will never click the button. Or they won’t once Facebook earns back the user’s trust that they have squandered.