[#PEBBLE] Working with buttons (II) and a bit of #debug mode using #CloudPebble


After the yesterday’s post, I have been able today to update the Pebble smartwatch and the SDK to the version 2.1. That means that I have everything ready for a demo. So, I’ll start with a video of a very simple app. For every button pressed, it sends a debug message to the cloud development environment.

We can see in the video is how an app to the Pebble is displayed using CloudPebble. And then as it is connected and can capture debug events. In the video you can see

00: 00 the development environment CloudPebble with the source code of an app and the feed from a camera with the Pebble

00: 46 Build option, in this case, compiles and deploys the app to the Pebble (through an iPod)

00: 22 now it is possible to see the app deployed and running on the Pebble

00: 25 selection from the view of debug output in the development environment

00: 34 Click on the Button Up and debug message!

Those who are not developers won’t know to enjoy of the divine moment of emotion that can be reached when a smartwatch sends a message by TCP to a browse that is where is the development environment .

That said, just sharing the code and tomorrow an example of a more interesting app with buttons

#include <pebble.h>
Window *window;
TextLayer *text_layer;
/* Buttons Handlers */
void up_click_handler(ClickRecognizerRef recognizer, void *context)
void down_click_handler(ClickRecognizerRef recognizer, void *context)
void select_click_handler(ClickRecognizerRef recognizer, void *context)
APP_LOG(APP_LOG_LEVEL_DEBUG, "Button Select !");
void click_config_provider(void *context)
window_single_click_subscribe(BUTTON_ID_UP, up_click_handler);
window_single_click_subscribe(BUTTON_ID_DOWN, down_click_handler);
window_single_click_subscribe(BUTTON_ID_SELECT, select_click_handler);
void handle_init(void) {
// Create a window and text layer
window = window_create();
text_layer = text_layer_create(GRect(0, 0, 144, 154));
// Set the text, font, and text alignment
text_layer_set_text(text_layer, "El Bruno, buttons sample!");
text_layer_set_font(text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
text_layer_set_text_alignment(text_layer, GTextAlignmentCenter);
// Add the text layer to the window
layer_add_child(window_get_root_layer(window), text_layer_get_layer(text_layer));
// buttons handlers
window_set_click_config_provider(window, click_config_provider);
// Push the window
window_stack_push(window, true);
// App Logging!
APP_LOG(APP_LOG_LEVEL_DEBUG, "Just pushed a window!");
void handle_deinit(void) {
// Destroy the text layer
// Destroy the window
int main(void) {

Saludos @ Home

El Bruno

image image image Google

1 comment

Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: