App for the Pebble Smartwatch: Introduction – June 20, 2014

I am making an app for the pebble smartwatch which after the first week in the program is a concept, but by the end of these six weeks will be fully operational on the pebble smartwatch. At the time of this post, the pebble currently runs on Pebble 2.0 with apps being based on C programming language. In the first week, I am learning C in order to better comprehend the functions of each line of code in a Pebble app and how a person would get an app to perform different functions such as display the weather for a certain city or even play a game. In order to get the watch to get past the setup, you need to pair it to a smartphone. The Pebble app on either Google Play or the iTunes App Store will need to be downloaded and opened. Once opened the watch is paired with the phone over bluetooth. The watch may need to be updated and once set up, the app will show what’s on the Pebble. The Pebble App on the smartphone serves not only to set it up, but also to put and delete apps on the smartwatch. Since I will be developing an app for the smartwatch, I will need to write the code as well as send it to the watch using cloudpebble.com, a service from pebble that allows developers to write code and test it on the watch. The website also checks if the code works before sending it to the watch among other things like downloading the file and can give you suggestions in coding an app.

 

Reflection/Conclusion:

During my time at Bluestamp Engineering, I coded a Chess Clock app for the Pebble smartwatch. I took an existing timer app and built upon it to turn the app into a Chess Clock. The app in the end added another 200 lines of code and modified the existing code heavily with the duplication and adapting of sections of my code to be coded for two timers. This was done by creating two states, one for each timer with different states for both including counting down, paused, done, and setting. This was true for other parts of the code with one exception being the actual settings. This was ao that both timers would have the same amount of time. The timer will also be available on the Pebble App Store for people that are interested in downloading.

It was a tricky process, this is made especially harder for me because I didn’t know anything about programming. For me, I got a tutorial in C and I looked at the different templates in Cloudpebble including text layers, inverter layers, accelerometer,  and images just to get a sense of how coding worked with Pebble. I also looked a the timer code and saw what I needed to do in order to get the app to work. In the beginning, coding was very confusing, so I spent the first week learning how to code in C. This does a lot for beginners which was essential for me to get started. After that, I started coding the app which was easier especially because I could now say what some sections of the code did. Other sectons were understood after I worked with them which took some time. After all of the tinkering and multiple failiures with the build ofmmy code, I got the app to work partially. Then came fixing the bugs to get the code working more like I had envisioned. This process took a shorter time, but eventually got the app to work like I had wanted.

Pictures:

These are screenshots of the working app below:

 

photo 3

20140724-09402705620140724_09310320140724-09402705620140724-094027056

index(4)index(5)index(3)

 

Documentation:

Below are the documents for the project including the Bill Of Materials and links for the code in GitHub:

BOM-Omar Garcia – Sheet1

BOM-Omar Garcia

BuildPlan-OmarGarcia

Links:

https://github.com/31422/Hello-World

https://github.com/31422/Pebble-Timer

https://github.com/31422/Chess-Clock

Milestone 3- July 21, 2014

The video for my third and final milestone is here:

In this final video, I explain the working chess clock app. This app builds upon the Pebble-Timer app I showed in the last milestone. When you look at the code, you’ll see that most of the code has been duplicated in some sections and adapted for two timers.

When the app opens, it will already be in settings to set the amount of time each player has using the up and down buttons. Pressing the select button in settings allows the user to cycle through the hours, minutes, and seconds. Pressing and holding the button while in settings will start the clock with white counting down first since white goes first in chess. Switching timers is done by pressing the up or down buttons, and pressing the select button while the timers are counting down will bring the clock back to settings. When one of the timers count down to zero, the watch will vibrate. As usual the code for the app is below and github at: https://github.com/31422/Chess-Clock

 

Milestone 2- July 21, 2014

The video for my second milestone is here:

In it I explain the second app I worked on called Pebble Timer. I used an existing app, but it didn’t work when I put it on Cloudpebble. It took some tinkering, but I got it to work. The app runs like a normal timer and vibrates when time is up. The code for the timer app is below as well as github: https://github.com/31422/Pebble-Timer

Milestone 1- June 27, 2014

The video for my first milestone is here:

In it I explian the first app I made called Hello World which is based on C. The app contains the message “Hi, I’m a Pebble. This is the first milestone for this project!” with the first sentence later changed to say “Hello World”. The code for my message is below as well as github: https://github.com/31422/Hello-World

#include <pebble.h>
Window *window;
TextLayer *text_layer;
InverterLayer *inverter_layer;
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, "Hello World. This is the first milestone in this project!");
text_layer_set_font(text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28));
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));
inverter_layer = inverter_layer_create(GRect(0, 0, 144, 168));
layer_add_child(window_get_root_layer(window), inverter_layer_get_layer(inverter_layer));
// 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
text_layer_destroy(text_layer);
inverter_layer_destroy(inverter_layer);
// Destroy the window
window_destroy(window);
}
int main(void) {
handle_init();
app_event_loop();
handle_deinit();
}

Appendix

The Pebble Timer is was actually taken from another user on Github and was used as a template to begin programming and adapting it to be a chess clock.

Source: https://github.com/mwylde/pebble-timer

Start typing and press Enter to search