summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2014-06-22 20:59:40 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2014-06-22 20:59:40 +0100
commitf1f83bb07f7be22b3750314e467822d83c0b4b90 (patch)
treebc3db55ddb83885cff360b43137aa935e80f2fc0
parent73381e529ff3c1c25dc0d138fd1904cb83c652b1 (diff)
downloadaskel-ja-uni-f1f83bb07f7be22b3750314e467822d83c0b4b90.tar.bz2
Outline for watch app
-rw-r--r--watchapp/.gitignore3
-rw-r--r--watchapp/appinfo.json17
-rw-r--r--watchapp/src/watchapp.c60
-rw-r--r--watchapp/wscript24
4 files changed, 104 insertions, 0 deletions
diff --git a/watchapp/.gitignore b/watchapp/.gitignore
new file mode 100644
index 0000000..9ed9d4f
--- /dev/null
+++ b/watchapp/.gitignore
@@ -0,0 +1,3 @@
+
+# Ignore build generated files
+build
diff --git a/watchapp/appinfo.json b/watchapp/appinfo.json
new file mode 100644
index 0000000..3064eed
--- /dev/null
+++ b/watchapp/appinfo.json
@@ -0,0 +1,17 @@
+{
+ "uuid": "a265da09-4cf5-4470-a2a3-8a30af0a1eba",
+ "shortName": "Askel ja Uni",
+ "longName": "Askel ja Uni - Step and Sleep",
+ "companyName": "Daniel Silverstone",
+ "versionCode": 1,
+ "versionLabel": "1.0.0",
+ "watchapp": {
+ "watchface": false
+ },
+ "appKeys": {
+ "dummy": 0
+ },
+ "resources": {
+ "media": []
+ }
+}
diff --git a/watchapp/src/watchapp.c b/watchapp/src/watchapp.c
new file mode 100644
index 0000000..516f7c8
--- /dev/null
+++ b/watchapp/src/watchapp.c
@@ -0,0 +1,60 @@
+#include <pebble.h>
+
+static Window *window;
+static TextLayer *text_layer;
+
+static void select_click_handler(ClickRecognizerRef recognizer, void *context) {
+ text_layer_set_text(text_layer, "Select");
+}
+
+static void up_click_handler(ClickRecognizerRef recognizer, void *context) {
+ text_layer_set_text(text_layer, "Up");
+}
+
+static void down_click_handler(ClickRecognizerRef recognizer, void *context) {
+ text_layer_set_text(text_layer, "Down");
+}
+
+static void click_config_provider(void *context) {
+ window_single_click_subscribe(BUTTON_ID_SELECT, select_click_handler);
+ window_single_click_subscribe(BUTTON_ID_UP, up_click_handler);
+ window_single_click_subscribe(BUTTON_ID_DOWN, down_click_handler);
+}
+
+static void window_load(Window *window) {
+ Layer *window_layer = window_get_root_layer(window);
+ GRect bounds = layer_get_bounds(window_layer);
+
+ text_layer = text_layer_create((GRect) { .origin = { 0, 72 }, .size = { bounds.size.w, 20 } });
+ text_layer_set_text(text_layer, "Press a button");
+ text_layer_set_text_alignment(text_layer, GTextAlignmentCenter);
+ layer_add_child(window_layer, text_layer_get_layer(text_layer));
+}
+
+static void window_unload(Window *window) {
+ text_layer_destroy(text_layer);
+}
+
+static void init(void) {
+ window = window_create();
+ window_set_click_config_provider(window, click_config_provider);
+ window_set_window_handlers(window, (WindowHandlers) {
+ .load = window_load,
+ .unload = window_unload,
+ });
+ const bool animated = true;
+ window_stack_push(window, animated);
+}
+
+static void deinit(void) {
+ window_destroy(window);
+}
+
+int main(void) {
+ init();
+
+ APP_LOG(APP_LOG_LEVEL_DEBUG, "Done initializing, pushed window: %p", window);
+
+ app_event_loop();
+ deinit();
+}
diff --git a/watchapp/wscript b/watchapp/wscript
new file mode 100644
index 0000000..0554dc8
--- /dev/null
+++ b/watchapp/wscript
@@ -0,0 +1,24 @@
+
+#
+# This file is the default set of rules to compile a Pebble project.
+#
+# Feel free to customize this to your needs.
+#
+
+top = '.'
+out = 'build'
+
+def options(ctx):
+ ctx.load('pebble_sdk')
+
+def configure(ctx):
+ ctx.load('pebble_sdk')
+
+def build(ctx):
+ ctx.load('pebble_sdk')
+
+ ctx.pbl_program(source=ctx.path.ant_glob('src/**/*.c'),
+ target='pebble-app.elf')
+
+ ctx.pbl_bundle(elf='pebble-app.elf',
+ js=ctx.path.ant_glob('src/js/**/*.js'))