My wife turns the house into the home of all homes, I get to see my all (or at least most of) my friends and ... I get to work on special projects :).
My first special project was to extend the standard Pebble Tutorial a little bit and show how to build a simple companion app that exchanges data with the watch.
As a first step I added some text to the standard Pebble Tutorial. The second step was to implement a companion app that can change the text.
This is not really a tutorial. Instead I will share the code and will highlight the changes and extension I made.
The main value is in showing what can be done and also in the configuration of the build systems.
To start I suggest you just follow the standard Pebble Tutorial and use CloudPebble to build it.
You can then take a look at my Pebble code to see how to add the text at the top and the bottom. In my case I also decided I want to use a real geek font. The code is also waiting for an app to send a new text to display, but initially works without the Android app and will just display "World" as a default.
Note: Right now the tick handler updates the time and the text to display. To save battery the tick handler gets only called when the minute changes, means when you send a new text to the phone you need to wait until the minute elapses before you can see the new text. Changing this to get updated every second (and make the colon flash every second) is an exercise for the reader :).
You can then clone the Android app. I am assuming you are familiar with developing Scala apps on Android. The app is very simple and it should be very easy to make it work with your Pebble app.
As a matter of fact you probably only need to go to CloudPebble and need to get the UUID of your Pebble app and need to update the Android code with it. Afterwards you should be able to compile and install the Android app on your phone.
A couple of things that worthwhile pointing out are:
- In the build.sbt file I had to add PebbleKit to the ProGuard configuration to make sure ProGuard is not removing the PebbleKit from the class files
- For the GUI I am using Macroid and to center the widgets I implemented a Tweak that sets the gravity. Not sure, if this is the right or best way to go about it
That's it. As I said, this is not a tutorial. Please do not expect that all of this will just work. Instead you have to learn how to build a Pebble app and how to build a Scala/Macroid app on Android and you can then use my code to make a simple companion app work.