After more than a year of waiting since I put my money into that famous Kickstarter, the package has finally arrived. I have a black Pebble on my wrist. After a few hours playing with it, I'm amazed by the e-paper display. It looks perfect in broad daylight and promises to last a week without charging.

But let's be honest: the charm of having a "smartwatch" isn't seeing phone notifications, but being able to get your hands dirty with the code. The default watchfaces are boring, so this weekend I dusted off my C skills to make my own.

The Pebble SDK: A trip back to the days of limited memory

Programming for Pebble is like going back to the 90s. You don't have gigabytes of RAM or a magical garbage collector to save you from your mistakes. You have a minuscule amount of memory (a few kilobytes for your app) and you have to program in pure C using its native SDK.

The paradigm is event-based. You define a window (Window), stick text layers (TextLayer) or graphic layers (InverterLayer) on it, and subscribe to a system service (like tick_timer_service) so the watch's operating system wakes up your code every time the minute changes.

#include "pebble_os.h"
#include "pebble_app.h"
#include "pebble_fonts.h"

// Global variables for the window and the text layer
Window window;
TextLayer text_layer;

// Function executed every minute
void handle_minute_tick(AppContextRef ctx, PebbleTickEvent *t) {
    static char time_text[] = "00:00";

    // We format the current time
    string_format_time(time_text, sizeof(time_text), "%H:%M", t->tick_time);

    // We update the text on the screen
    text_layer_set_text(&text_layer, time_text);
}

// Main initialization function
void handle_init(AppContextRef ctx) {
    window_init(&window, "Mi Watchface");
    window_stack_push(&window, true /* animated */);

    // We initialize the text layer in the center of the screen
    text_layer_init(&text_layer, GRect(0, 50, 144, 168));
    text_layer_set_text_alignment(&text_layer, GTextAlignmentCenter);
    text_layer_set_font(&text_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD));

    layer_add_child(&window.layer, &text_layer.layer);
}

It's like when we fought with pointers in college, but now the error isn't a "Segmentation Fault" in the terminal, but the watch rebooting with a sad screen.

Reflection: The future of the wrist

The Pebble is the most "hacker" device I've seen in a long time, but I doubt its long-term commercial future. There are strong rumors that giants like Apple and Google are preparing their own watches.

I'm afraid the average consumer will prefer full-color OLED screens, fluid animations, and heavy applications, even if that means having to charge the watch every night (an aberration for a watch, in my humble opinion). For now, I'll enjoy my little e-paper device while I compile my own tools in C.