As I mentioned in my previous blogpost, I am now the proud owner of a Pebble Time. This week I took the plunge and decided to make my own watchface in honour of xkcd #247 (“Factoring the time”). Pebble watchfaces have historically been written in the programming language C, although (given the relative unpopularity of C) the team there have also built a JavaScipt API, PebbleJS. I mean, I’ve never written any C before, but there’s no time like the present eh?
C turns out to be a particularly intensive language to work in, especially without the benefit of large utility libraries. For example, its array handling is poor, lacking push/pop functions, an accurate count function or indeed join/implode. The other thing I struggled with was performance enhancement. The major challenge when developing a watchface is battery conservation. Although Pebble provides some guidance covering this aspect, it remains vague (and difficult to even deduce through trial and error. For example, my initial design factorises the time afresh every minute using a blunt force recursive technique (given the maximum target is 2359, this is not too inefficient). But equally, I could store the pre-computed factorisations in a file. Would this be better or worse for battery conservation? Who knows.
The full code to the Factorise watchface is available from Github under the MIT licence.