Click here to Skip to main content
15,881,630 members
Articles / Mobile Apps / Smartwatch
Tip/Trick

Getting Started with Smart Watch Development with Pebble

Rate me:
Please Sign up or sign in to vote.
4.83/5 (3 votes)
15 Oct 2015CPOL2 min read 6.3K   27   2  
Smartwatch Development with pebble

Introduction

It's been so fascinating that Smart watches have evolved so much with different flavours and different types. It is now one of the essential things you have when you want to stay connected with the digital world. Hence the curiosity to learn a bit and share.

Background

This tip will cover the basic app structure of Pebble, what are the essential functions needed and getting started with Cloud Pebble with C Language.

Let's Start

Developing for Pebble is fun as we can use our age old language C to code it.

There are 2 different ways to develop for Pebble:

  1. One being direct SDK based development for Linux and Mac OS.
  2. For Windows users and also for Mac and Linux users, it can also be done with Cloud Pebble.

We will start with Cloud Pebble and will develop a simple Hello CP app and cover the app architecture.

We will modify a watch interface with our CodeProject Bob icon.

Let's get a feel of Cloud Pebble:

  1. First of all, you need to create an account at Cloud pebble: https://cloudpebble.net
  2. I found out lot of examples to tweek from http://developer.getpebble.com/tutorials

A look at Cloud Pebble:

Get going with Hello CodeProject:

Open a new account, go to the project Tab. Click on create.

Project Name: "Project Name" and Template as Blank and leave everything as it is. Click on create.

As everything will be blank and there is nothing to start with, we need to click source files, add new with file type as .C target would be app/watchface.

How the Pebble Development Environment Works

Everything happens in the main function.

Within Main function for declaration, we have init function for initialization and denit function for de-initialization.

You need to declare pointers.

You need to allocate the pointers and finally deallocate it.

An overview of the architecture is shown below:

First, you need to declare pointers first for the Window Size of the Watch and then to show text we need to declare the pointer. After declaration, we need to allocate the pointers as shown below:

C
//
// Window *window;
//window = window_create();
//
C
//
// TextLayer *text_layer;
//text_layer = text_layer_create(GRect(0, 0, 144, 40));
//

In the final step, we need to deallocate the pointers that too in deinit function:

C
TextLayer *text_layer;
text_layer_destroy(text_layer);
  window_destroy(window);
//

The whole code for the Watch is as follows:

C
#include <pebble.h><pebble.h>
Window *window;
TextLayer *text_layer;

void init() {
  window = window_create();
  text_layer = text_layer_create(GRect(0, 0, 144, 40));
  text_layer_set_text(text_layer, "Hello, CodeProject!");
  layer_add_child(window_get_root_layer(window), 
                    text_layer_get_layer(text_layer));
  window_stack_push(window, true);
}

void deinit() {
  text_layer_destroy(text_layer);
  window_destroy(window);
}

int main() {
  init();
  app_event_loop();
  deinit();
  return 0;
}

Save the project and run it in emulator. It will look like this:

References

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
India India
I am into software Development for less than a year and i have participated in 2 contests here at Codeproject:-Intel App Innovation Contest 2012 and Windows Azure Developer Challenge and been finalist at App Innovation contest App Submission award winner as well won two spot prizes for Azure Developer Challenge.I am also a finalist at Intel Perceptual Challenge Stage 2 with 6 entries nominated.I also won 2nd prize for Ultrabook article contest from CodeProject
Link:-
http://www.codeproject.com/Articles/523105/Ultrabook-Development-My-Way

Microsoft MVA Fast Track Challenge Global Winner.
Ocutag App Challenge 2013 Finalist.

My work at Intel AppUp Store:-

UltraSensors:-
http://www.appup.com/app-details/ultrasensors
UltraKnowHow:-
http://www.appup.com/app-details/ultraknowhow

Comments and Discussions

 
-- There are no messages in this forum --