Archive for the 'Technical' Category

Android Drawable Resources

Doing some work on testing SmsDroidway on different Android SDK/Platform levels and I noticed that some of the nice default icons were missing from my UI. A quick google showed that this was not uncommon and that the best practice was to import the resources to your project locally to make yourself platform agnostic, though you then don’t necessarily match in with the platform.

The Android Eclipse project folder structure has a ‘res’ folder that contains Drawables, layouts, menus and values. However, the Drawables tend to be split by High, Medium and Low DPI folders, in fact some of the ADT tools create icons for you into these folders. This means that to import from the SDK folders you have to go and grab the the images from the folders individually, this just struck me as too much effort/pain.

So… I weighed up creating an Eclipse plugin to steal them from the SDK folders and push them into your project, and, to be honest, this would have been my preferred method. But I don’t have time to get up to speed with the plugin framework to create a UI, to access the ADT preferences and all the other stuff it should do.

However, I do have time to write a quick (and admittedly bit dirty) C# Winforms application that can do this.

So that is what I did, this is the wonderfully named “Android Resource Transferer”. I could probably brand it better 🙂

At the top you select your destination eclipse android folder, the Shell browse dialog is validated on exit to confirm the folder looks android like. This is a pain, the FolderBrowseDlg doesn’t support custom validation or subclassing, so I had to just put it in a loop with some delegate validation function passed.

Next you can choose to either use the SDK as the source or a Donor Project. The Tab selection is your active method.

The SDK Browse process includes some checks to make sure it looks like the SDK root folder. The SDK includes a platform level on the left, you can see my Android internals platforms listed there. You can then use whatever icon you think looks best.

A big difference from the eclipse ADT tool here is that the search box uses your search string as a  “contains” method, so you can focus on keywords and not if it starts with ic_ or whatever like you must in ADT.

The list of resources includes a nmeonic of [HMLN] to indicate which DPI are available for a particular resource, being [H]igh, [M]edium, [L]ow, [N]eutral. The selected resource is previewed at the highest DPI on the right.

The final step is to hit import and the drawable will be put in your project, it will even create the right folder if it doesn’t exist.

Back in Eclipse you will have to refresh to see you results and might have to do a clean to get the drawable IDs propagating through the project.

You can download the tool here. I can probably downgrade it from .NET 4 if needed, and I expect it to run under Mono, since there isn’t anything too complex in there. We won’t be releasing the source to this tool as it isn’t to the standard we normally work, being a quick tool to aid our development work, on the other hand, we haven’t obfuscated it at all, so if you run reflector over it you will see that it isn’t deliberately malicious 🙂

Why software engineers are bad for electronics

Since I’m responsible for the hardware side of CASL I thought I’d share this article from Rugged Circuits about how easy it can be to kill one of the Arduino boards we use for happy prototyping. As we say about each other, we each know enough of the others expertise to be dangerous!
This is why I try to make sure our designs can withstand software engineers, after that users should be the easy ones…

10 Ways to Destroy an Arduino


CASL has been working on Atmel AVR programming using the excellent Arduino rapid prototype platform. Conveniently we’ve been using supplied boards as we could source them at Jaycar, just a few minutes drive away.

My own previous experience has been some PIC solutions,and a bit of FPGA work (I’ve also got some really old stuff like 6800 and MCS48…) , so this was interesting trying out another processer architecture and the provided development environment, the Arduino IDE.

I liked the boards, I liked the prevalance of libraries but hated the IDE… I’m coming from a Visual Studio background or Emacs, so I’m used to actually seeing my errors and having some extra control.

It wasn’t long until I had Visual Micro Arduino installed in VS2010, but even that wasn’t great (good plugin, but still using the FDH toolchain of the IDE). So I downloaded AVR Studio.

Now, we were talking I was seeing warnings, errors and lots of new stuff. I’ve spent a bit of time now configuring up templates for Arduino development, cleaned up the libraries and made new additions to the core (fancy subsrcribing to Pin Change Interrupts? How about multiple subscribers to Interrupt handlers?).

I should be going back and doing a QA on the code, when that’s done CASL will release an AVR Studio template for Arduino boards and also look to push the architecture changes back into the mainline of the Arduino sources.