I'm not a C programmer by any stretch of the imagination, but it was surprisingly simple to take the example code and work it into something. There's also a screen designer as part of the CloudPebble service which does a lot of the fiddly work for you. I was able to knock up a pretty reasonable app in a fairly short time. The example code shows how to send the buttons. Use the CloudPebble designer to create some text on the screen of the watch; pick your type size and font, and the position, and it will do all the code behind that for you.
Then, to keep the coding in C to a minimum, you use the sample to send commands to your B4A app, based on the buttons. You use a SELECT to choose what to do with the incoming commands, like stop or start the clock.
Then, you obviously need something that sends info back to the Pebble, which your C app there will put on the display. That's quite easy too. Information is sent as a Pebble Dictionary, which has keys in it, indicating which elements are there, and you add them as ints, or strings. Here's a bit of my code for that
Code:
Sub updatePebbleDisplay()
If pk.isWatchConnected = True Then
Dim pStatus As PebbleDictionary
pStatus.Initialize
pStatus.addInt8(P_LEVELA,levelA)
pStatus.addString(P_MODE,"some string")
pk.sendDataToPebble(APP_UID,pStatus)
Log("Data sent to pebble, size " & pStatus.size)
Log(pStatus.toJsonString)
End If
End Sub
P_LEVELA and P_MODE are Ints, defined earlier in the code; you add matching values as #defines at the top of the C code in the .h file that's created for you by the designer on CloudPebble. Then you use the inbox_received_callback to update the display, like this, assuming you have a string from the app, "some string" that you want to appear in the text box on the Pebble that you called s_modeinfo:
Code:
static void inbox_received_callback(DictionaryIterator *iterator, void *context) {
APP_LOG(APP_LOG_LEVEL_INFO, "Message received!");
// update the display, based on info from the app
Tuple *stimmode = dict_find(iterator, P_MODE) ;
static char modeinfo[32] ;
if (stimmode) {
// update mode info
snprintf(modeinfo,sizeof(modeinfo), "%s", stimmode->value->cstring) ;
text_layer_set_text(s_modeinfo,modeinfo) ;
}
}
That may look fairly gibberish if you've not done C, but it's pretty straightforward, and if you can do all the hard work in the app on the phone, and merely use the buttons and display on the watch, then this sort of approach won't be too hard - you just need to think about what messages you'll send to the Pebble and how often.