Saturday 28 February 2015

WatchMaker - splitting seconds

WatchMaker (free and premium) gives you loads of tags, as I've previously discussed.  However, when I came to make my latest project, I found a couple of omissions.

The project that I'm currently working on a watch face based on The Clock by Gislain Bernoit...



This is a 56x66cm masterpiece that weighs almost 6.5kg, it's made up of 1,916 individual hand-soldered components, which took the artist hundreds of hours over 3 years to create.  It's truly one of a kind.

Having a circular screened Moto 360 watch, I decided to capture the middle part of the clock, in my homage to this amazing piece.  And given the spacing on the digital displays I found this meant displaying each digit individually.  So I needed 6 different text elements, and this is how they work...

  1. Hours in day (0-23) tens - there's a tag for this: {dh23tt}
  2. Hours in day (0-23) ones - there's a tag for this too: {dh23to}
  3. Minutes in hour (tens) - {dmt}
  4. Minutes in hour (ones) - {dmo}
  5. Seconds in minute (tens) - string.sub("{dsz}",1,1)
  6. Seconds in minute (ones) - string.sub("{dsz}",2,2)
As you can see, there were tags specifically for the hours and minutes that were already split, but there wasn't for seconds.  To get around this we can use "Seconds in minute (with leading zero)" {dsz} and then use the LUA string.sub command to split the two characters.

This is what I've come up with so far...


I'll be uploading it to FaceRepo once it's finished.




Monday 23 February 2015

WatchMaker - unpacking the .watch file

When you export a watch from WatchMaker, the app creates a ".watch" file.  This can then be imported by someone else, or uploaded to a face sharing website (such as FaceRepo) for others to enjoy.  

If you're like me though, you might be interested in how this ".watch" file is made up though, what it contains.  So let's take one of my first watch faces for example...



The file itself is a ZIP archive, so the first step is to extract the files.  Personally I prefer 7-Zip, but you can use the tool of your choice for this.

After you've unpacked the files, you should see a structure something like this...



The files included in this example are...

  • fonts
    • Roboto-Regular.ttf
  • images
    • battery_set_1.png
    • bg_premium5.jpg
    • hand_hour_22.png
    • hand_minute_22.png
  • preview.jpg
  • watch.xml

So any fonts and images that are used in the watch face are included in their respective folders.  For example, the "battery_set_1.png" is a Sprite that holds multiple images in one.  There is also the background ("bg_premium5.jpg") and both watch hands.

There is also a preview image ("preview.jpg") - this is the image that is displayed above, and it's also the one that FaceRepo uses.  There is currently a feature request to add a dimmed preview image to the ".watch" file as well.

The final file (watch.xml) is probably the most interesting, as this contains all of the settings and configuration of the watch face and the layers that make it up.  You can open this file to view in a web browser, or you can edit it in any text editor (I prefer Notepad++)...


This ".xml" file has a root <Watch> tag, with attributes that contain the settings for the watch face, and then a number of <Layer> tags, with attributes that contain the configuration for each layer.  Whilst you may or may not be familiar with XML, it should be easy enough to tell from the attributes and their values how these match up with the different properties in the WatchMaker app.  

This includes the layers of type "image" which have a "path" and those of type "text" which have a "font", both of which link to the included files above.  Also there's the "display" attribute, which is "b" for bright only, "d" for dimmed only and "bd" for always.

Next time I'm working on a complicated LUA script, I may well export it to Dropbox so I can write it on my laptop, then import it back into the WatchMaker app - much easier than typing curly braces on my phone keyboard!

Sunday 22 February 2015

WatchMaker - adding internet time

I was reading through the Feature Requests for WatchMaker and stumbled across this one for adding Internet time (@.beats).  Internet time was dreamt up by the Swatch corporation as part of their marketing campaign for their line of "Beat" watches in 1998.  Instead of hours and minutes, the day is divided up into 1000 parts called ".beats".  The idea was to have a time that was consistent around the word, so there are no timezones and no daylight savings.  0 beats starts at midnight in UTC+1.

I was interested in seeing what I could come up with, so I set about seeing what WatchMaker could do.

So I did some research, and according to Wikipedia, the calculation for converting from UTC+1 to beats is...
(UTC+1seconds + (UTC+1minutes * 60) + (UTC+1hours * 3600)) / 86.4

At first I thought that if I set the time settings in WatchMaker so that the Extra Time Zone 1 was UTC+1 (France)) then use the rotation values to calculate the beats.  If you divide these by 360 (the total rotational value) then you can calculate the percentage and from this work out the hours and minutes.  This worked ok, but the accuracy wasn't great.  It also meant that the setting would need to be changed during daylight savings time, which would be annoying.




So I decided to come at it more directly, going back to the original calculation.  So I converted the calculation into tags...
({ds} + ({dm} * 60) + ({dh23} * 3600)) / 86.4

Whilst many places will show the decimal part of the beats value, the value is supposed to be integer.  WatchMaker uses the LUA syntax, which includes some maths functions we can use...
math.floor(({ds} + ({dm} * 60) + ({dh23} * 3600)) / 86.4)

I'm in the UK, so currently in the "GMT" timezone, which means I need to add an hour onto the hours (GMT is UTC).  However, "BST" (British Summer Time which is UTC+1) is coming up in a few months, so I want to account for this as well.  This can be done using LUA conditionality (as discussed in a previous blog post)...
math.floor(({ds} + ({dm} * 60) + (({dh23} + ("{dz}"=="GMT" and 1 or 0)) * 3600)) / 86.4)

This checks for the "GMT" timezone (using the {dz} tag) and adds 1 if it is, otherwise it doesn't.  Obviously this will only work in the UK, but it would take a lot of conditional statements to account for the ~50 timezones (including daylight savings, etc).  So this would have to do for now.

The trouble with adding the extra hour is that it goes up to 1041 instead of 999, but as it should loop back to 0 instead of going on to 1000, then easiest way to fix this is to take the last 3 characters of the string.  Luckily LUA also gives us some string functions to use...
string.sub(math.floor(({ds} + ({dm} * 60) + (({dh23} + ("{dz}"=="GMT" and 1 or 0)) * 3600)) / 86.4),-3)

The "string.sub" method is used to create a substring, and the -3 means to take the last 3 characters.  

Personally I prefer to always display 3 characters, so "000" instead of "0".  The easiest way to do this, given the string manipulation that we're already doing, is to always add 1000 to the value.  This means that the value will go from 1041 to 2041, but as we're always taking the last three characters, the first character is not needed...
string.sub((math.floor(({ds} + ({dm} * 60) + (({dh23} + ("{dz}"=="GMT" and 1 or 0)) * 3600)) / 86.4) + 1000),-3)

I've not managed to fully test this, but I've been comparing it to other sources and it certainly seems to work correctly.  

I wanted to update this watch face to FaceRepo, but unfortunately I got an error message saying that there were copyright issues, so I'm guessing "Swatch" is a dirty word!  Here's what it looks like though...




I added the real time as well, because how many people really use internet time?  It was an interesting challenge though.  Hopefully the WatchMaker developer will be able to make more UTC time and timezone properties available, which will make this kind of calculation easier in future, across any timezone.


Thursday 19 February 2015

Tasker - making use of javascript

Yesterday I posted about using WatchMaker with Tasker for automation, and I built a watch face that used Tasker to update variables which were displayed on screen.  Here it is...


World Community Grid - 20 downloads


However, it bugged me that I couldn't quite get it to look right, I wanted to add thousand markers to the rank (#215,027) and points (181,052).  I couldn't figure out a way to do this in WatchMaker, or in Tasker, until I discovered the javascript option.  In Tasker you can add a step in the task which runs javascript, which can access the global variable that you've already set, re-format it, and then set the global variable again.  Here's what I did...




I'm not going to explain the javascript, because that's not really the point, but you can find out more about the javascript API and what's available in Tasker here... http://tasker.wikidot.com/userguide-en:javascript.

The end result is this...


It's a small difference, but I think it looks much better.  And I love that I found a way to make the watch display exactly the way I wanted.

Wednesday 18 February 2015

WatchMaker with Tasker for automation

Tasker is a very popular app for automation, in fact it describes itself as "Total Automation, From Settings to SMS".  I'm only just starting to use it, and I can already see that there's loads of potential.  In short, you create profiles, which get activated by certain conditions, and tasks, which are a series of actions and can be run when these profiles activate or de-activate.  I'm not going to go into too much detail though, as this is an Android Wear blog, and not an Android blog.  

Having said that, here's a WearTasker app, which allows you to trigger tasks directly from your watch, which could prove to be very handy!  There's also integration with WatchMaker, allowing you add a "tap action" to any element of the watch face, and the action can be to trigger a task.

What really interested me initially though was the ability for Tasker to set global variables, which can then be passed through to WatchMaker, allowing you to display values on your watch face which the phone can update.  

I was interested in doing a World Community Grid watch face.  World Community Grid enables anyone with a computer, smartphone or tablet to donate their unused computing power to advance cutting-edge scientific research on topics related to health, poverty and sustainability.  For all the work that you process, you are rewarded with points.  I wanted to see my points, and my current rank, right there on my watch!  This is what I came up with...

World Community Grid - 20 downloads

So I've already said that I don't want to do a full on Tasker review, but here's roughly what I did...

  1. Create a new task in Tasker
  2. Set Tasker variable %WCGUserName to "rik_lewis" (my username)
  3. Get my statistics as an xml stream from https://secure.worldcommunitygrid.org/stat/viewMemberInfo.do?userName=%WCGUserName&format=xml
  4. Split the results to get the bit between "<Points>" and "</Points>"
  5. Set Tasker variable %WCGPoints to the points value
  6. Split the results to get the bit between "<PointsRank>" and "</PointsRank>"
  7. Set Tasker variable %WCGPointsRank to the rank value
  8. Send both variables to WatchMaker
Here are some screenshots with more details...


Then create a new profile in Tasker which is triggered by time, repeating every hour, which runs your task...


This means that every hour the task will run and fetch the values, and send them through to the watch face.  To reference these variables in WatchMaker you use the tags {twcgpoints} and {twcgpointsrank} respectively.  In fact any Tasker variable is reference with the tag {t...}, which is nice and simple to remember.

All in all this works very well, and is so powerful when it comes to customising your watch.  Regularly fetching up-to-date data from the web is just one idea, you could also send the current wifi network name each time you connect, or hundreds of other things.

Tuesday 17 February 2015

WatchMaker - conditionality

One really simple but incredibly powerful feature in WatchMaker is the conditionality.  The conditions are in the format...

(CONDITION and (IF TRUE) or (IF FALSE))

For a developer or mathematician (or anyone who knows boolean logic) this is possibly not the most intuitive syntax, but it's straightforward to understand, and that's the point really.  It also works without the brackets, so you'll have to ignore the BODMAS rules.

I have particularly found these conditions useful when applied to the "Opacity" attribute, but you can actually apply them to anything.  I like creating battery indicators, like this...
  1. Click the plus icon to get a new layer
  2. Select the "Battery" type
  3. Choose "Watch Battery" at the bottom (or "Phone Battery")
  4. Choose your favourite battery set (4 designs to choose from)
  5. Position it where you want it, change the colour if required, etc

Now here comes the clever bit (even if I do say so myself).  In the "Opacity" attribute set the value to...

{bl}<25 and 100 or 0

So the watch battery level tag is {bl} and the condition is saying that when the battery level drops below 25 then the opacity should be 100 (100% visible), but otherwise the opacity should be 0 (0% visible).  This means that the battery indicator won't be there all the time, only when the battery level is low.  

You can create the same using the {pbl} tag for the phone battery level as well.  You can even put them in the same place, with whichever you feel is more important on top.  These means that they won't take up much space, in fact they'll hopefully never be visible!

I've made use of these battery indicators on my latest watch face, which I only uploaded yesterday...



This is obviously only one use of conditionality, but I'm sure I'll come up with plenty of other inventive uses moving forwards!

Monday 16 February 2015

WatchMaker - highly configurable

There's loads of great default functionality in WatchMaker, stuff that can be easily added in to your watch.  Basically it works in layers, so you add a background image, and then say the hour/minute markers round the edge, then the numbers, then the hands, etc., building it up as you go.  You can reorder the layers, duplicate them, delete them, etc.  It's really easy to do, and very intuitive.

When you click the big plus icon to add a new layer, you get the following types...

  • Text
  • Curved text
  • Watch background
  • Shape
  • Numbers
  • Hour+minute markers
  • Freeform markers
  • Watch hands
  • Image
  • Animated GIF
  • Date
  • Time
  • Weather
  • Moon phase
  • Battery
  • Compass
  • Wifi signal
  • Calendar
  • Countdown
  • Stopwatch
  • Expression

They are all very customisable, with the ability to reference many different tags.  For example, just for time you've got so many options (using 18:49 as the example time)...
  • {dh} - Hour in the day (1-12) - 6
  • {dh11} - Hour in the day (0-11) - 6
  • {dh24} - Hour in the day (1-24) - 18
  • {dh23} - Hour in the day (0-23) - 18
  • {dht} - Hour in day text (1-12) - six
  • {dh24t} - Hour in day text (1-24) - eighteen
  • {dhz} - Hour in day (1-12) (with leading zero) - 06
  • {dh11z} - Hour in day (0-11) (with leading zero) - 06
  • {dh24z} - Hour in day (1-24) (with leading zero) - 18
  • {dh23z} - Hour in day (0-23) (with leading zero) - 18
  • and 29 other tags!  Just for time!!

As you can see, there are just so many options, you can choose whatever you want.  

And if you can't find what you're after, check out the Feature Requests - this allows you to search for features that others have requested, and vote on the ones you like, as well as adding your own, for others to vote on.  You can vote on as many as you want, so please feel free to vote on all the stuff that I want :)

Next I want to talk about the conditionality that is simple and yet so powerful.

Sunday 15 February 2015

Job one - the watch face

For me, the first job on getting the watch was to find a watch face that I liked.  And I've found way too many that I like, and not enough time to try them all!  But what I really like is designing and building my own.

There are two main apps for that; Facer and WatchMaker.  I've played with both, and I have to say that the later is my favourite.  There are many discussions online, with people arguing either way, but at the end of the day I think it comes down to personal preference.  However, here's my list of reasons...

  1. WatchMaker can import Facer files (.face) as well as it's own (.watch) and Facer can only handle it's own
  2. WatchMaker has many more customisation options than Facer
  3. WatchMaker has Tasker integration (that's a whole other post in itself!)
  4. WatchMaker has support for animated gif images
I'm sure there are more, but those are the main points for me at the moment.

There are lots of ways to get watch faces, included buying them from the Play store, but one of the best free repositories I've found is FaceRepo.  The site can filter on round/square faces and Facer or WatchMaker files, making it easy to find ones suitable for your watch.  It also allows you to create an account and upload your own watch faces.  

I love downloading watch faces, importing them into my WatchMaker app, and then customising them to suit my own needs.  Maybe I want the date formatted differently, or 24 hour time instead of 12 hour time, or whatever - easy!  

You can either view the site and download the files directly, or you can browse on your computer and then use a QR reader on your phone to quickly and easily download.  You can also get the .watch files from other sites and import them, as well as exporting your own creations as .watch files to upload and share.

Here are the top 3 watch faces that I've uploaded...



 

I've done 16 so far, including a range of Ron Swanson ones, and some Andy Fairhurst ones as well... http://facerepo.com/app/faces/user/trixmoto/1 - I hope you like.  Feel free to provide feedback, either here or on the FaceRepo site (requires a Disqus account).

I've learned some interesting watching making tricks already, and I'm sure there's more to learn as well, so keep a look out for some future posts on this subject!

Saturday 14 February 2015

Hello and welcome

I'm pretty new to the world of Android Wear, having been given a Moto 360 (which I'd been lusting after since it was first announced!) as a gift.  Here's an instagram picture of me getting it, about 3 weeks ago...



And yes, that is my hand :)

So I'm learning the joys of Android Wear, with a Moto 360 slant.  I wanted to share what I'm learning, some of the awesome apps I've found, and possibly writing my own apps (if I get that far!).  I'm not much of a vlogger, so I thought I'd stick with blogging.  

There are some very good vlogs out there, including my friend's Video Gadgets Journal, which isn't specifically for Android Wear, but he also has a Moto 360, and loves showing what it can do.

So this is it from me for now, just wanted to say hello - more posts coming soon!