Wednesday, 5 October 2011

Metawatch phone based watch menus

So a common request is to add the ability to send a menu to the phone and have the phone draw it and send back the users selection. My first attempt at this is shown below.

To use it send a Message type "GeneralPurposeWatchMsg" with option set at 0x43. The length set to max and the first byte of the string is the Length of the original string in characters. The rest of the payload is a Huffman encoded space separated list of strings. These represents the menu items to display. The huffman encoding uses a fixed tree based on the frequency of characters in the English language. This allows us to send all the text in one message and hopefully keep latency to a minimum. I haven't got around to writing the java to encode the string but I have written a python script that generates the bye sequence needed for a given string which you can then place in a payload and send. For example to menu shown above (Ignore the bad layout that will be fixed!) the strings would be "toggle next back volup voldown". this string is 30 characters long so too long to fit in our payload but once encoded takes up just 20 characters.

On selection the watch sends back a GeneralPurposePhoneMsg with the type set to 0x43and the index of the menu item selected as the first byte of payload.

It's possible that menus with more items more like a list view would be required and up and down could be used to select items. This would be more useful for browsing music on the phone or other larger datasets.
I'll maybe have a go at this tomorrow.

Tuesday, 4 October 2011

Metawatch Music Controls in Firmware

Metawatch kinda has music controls but they can be kinda flaky. With my menu system in my modified firmware it was very easy to add. First I needed to send music messages to the watch but as you can't define your own messages i chose to use "GeneralPurposePhoneMsg" with an option of 0x42. The first byte in the payload would be the action. I used the constants already defined in MediaControl class.

I then added a Music menu to my firmware which took all of 10 minutes. This has none of the problems with the phone defined shortcuts overriding items. I'm in the middle of a refactor of the firmware and plan to have multiple home screens like the android launcher with the music controls being one.

All this code can be seen in these two commits:-