Skip to content

Commit 9f6170d

Browse files
committed
First commit
0 parents  commit 9f6170d

File tree

6 files changed

+109
-0
lines changed

6 files changed

+109
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
# Ignore build generated files
3+
build

README.md

Whitespace-only changes.

appinfo.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"uuid": "ad4d6d24-c0f3-4bfb-95bc-902b66356176",
3+
"shortName": "uptimerobot-pebble",
4+
"longName": "uptimerobot-pebble",
5+
"companyName": "MakeAwesomeHappen",
6+
"versionCode": 1,
7+
"versionLabel": "1.0.0",
8+
"watchapp": {
9+
"watchface": false
10+
},
11+
"appKeys": {
12+
"dummy": 0
13+
},
14+
"resources": {
15+
"media": []
16+
}
17+
}

src/js/pebble-js-app.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Pebble.addEventListener("ready",
2+
function(e) {
3+
console.log("Hello world! - Sent from your javascript application.");
4+
}
5+
);

src/uptimerobot-pebble.c

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#include <pebble.h>
2+
3+
static Window *window;
4+
static TextLayer *text_layer;
5+
6+
static void select_click_handler(ClickRecognizerRef recognizer, void *context) {
7+
text_layer_set_text(text_layer, "Select");
8+
}
9+
10+
static void up_click_handler(ClickRecognizerRef recognizer, void *context) {
11+
text_layer_set_text(text_layer, "Up");
12+
}
13+
14+
static void down_click_handler(ClickRecognizerRef recognizer, void *context) {
15+
text_layer_set_text(text_layer, "Down");
16+
}
17+
18+
static void click_config_provider(void *context) {
19+
window_single_click_subscribe(BUTTON_ID_SELECT, select_click_handler);
20+
window_single_click_subscribe(BUTTON_ID_UP, up_click_handler);
21+
window_single_click_subscribe(BUTTON_ID_DOWN, down_click_handler);
22+
}
23+
24+
static void window_load(Window *window) {
25+
Layer *window_layer = window_get_root_layer(window);
26+
GRect bounds = layer_get_bounds(window_layer);
27+
28+
text_layer = text_layer_create((GRect) { .origin = { 0, 72 }, .size = { bounds.size.w, 20 } });
29+
text_layer_set_text(text_layer, "Press a button");
30+
text_layer_set_text_alignment(text_layer, GTextAlignmentCenter);
31+
layer_add_child(window_layer, text_layer_get_layer(text_layer));
32+
}
33+
34+
static void window_unload(Window *window) {
35+
text_layer_destroy(text_layer);
36+
}
37+
38+
static void init(void) {
39+
window = window_create();
40+
window_set_click_config_provider(window, click_config_provider);
41+
window_set_window_handlers(window, (WindowHandlers) {
42+
.load = window_load,
43+
.unload = window_unload,
44+
});
45+
const bool animated = true;
46+
window_stack_push(window, animated);
47+
}
48+
49+
static void deinit(void) {
50+
window_destroy(window);
51+
}
52+
53+
int main(void) {
54+
init();
55+
56+
APP_LOG(APP_LOG_LEVEL_DEBUG, "Done initializing, pushed window: %p", window);
57+
58+
app_event_loop();
59+
deinit();
60+
}

wscript

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
#
3+
# This file is the default set of rules to compile a Pebble project.
4+
#
5+
# Feel free to customize this to your needs.
6+
#
7+
8+
top = '.'
9+
out = 'build'
10+
11+
def options(ctx):
12+
ctx.load('pebble_sdk')
13+
14+
def configure(ctx):
15+
ctx.load('pebble_sdk')
16+
17+
def build(ctx):
18+
ctx.load('pebble_sdk')
19+
20+
ctx.pbl_program(source=ctx.path.ant_glob('src/**/*.c'),
21+
target='pebble-app.elf')
22+
23+
ctx.pbl_bundle(elf='pebble-app.elf',
24+
js=ctx.path.ant_glob('src/js/**/*.js'))

0 commit comments

Comments
 (0)