Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/pebble-silly-walk.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Long <dan@dansl.net>2013-04-16 07:37:48 +0400
committerDan Long <dan@dansl.net>2013-04-16 07:37:48 +0400
commitb8e0d2458fa493e263a79d56a4b5b8fcbe0953eb (patch)
tree348cd29443dda821855ca531daa6ebc61591b5b2
parentbf27d0c22cc7c5613381a55c6aab5511c483fffd (diff)
Initial Commit
-rw-r--r--psd/background.psdbin0 -> 1199901 bytes
-rw-r--r--psd/hour_hand.psdbin0 -> 32950 bytes
-rw-r--r--psd/icon.psdbin0 -> 28589 bytes
-rw-r--r--psd/minute_hand.psdbin0 -> 36279 bytes
-rw-r--r--psd/seconds_hand.psdbin0 -> 31484 bytes
-rw-r--r--reference.pngbin0 -> 2515 bytes
-rw-r--r--silly_walk/resources/src/images/background.pngbin0 -> 1941 bytes
-rw-r--r--silly_walk/resources/src/images/hour_hand.pngbin0 -> 1214 bytes
-rw-r--r--silly_walk/resources/src/images/icon.pngbin0 -> 1089 bytes
-rw-r--r--silly_walk/resources/src/images/minute_hand.pngbin0 -> 1212 bytes
-rw-r--r--silly_walk/resources/src/images/seconds_hand.pngbin0 -> 1116 bytes
-rw-r--r--silly_walk/resources/src/resource_map.json39
-rw-r--r--silly_walk/src/silly_walk.c119
13 files changed, 158 insertions, 0 deletions
diff --git a/psd/background.psd b/psd/background.psd
new file mode 100644
index 0000000..aa0b7a0
--- /dev/null
+++ b/psd/background.psd
Binary files differ
diff --git a/psd/hour_hand.psd b/psd/hour_hand.psd
new file mode 100644
index 0000000..cfc7fb3
--- /dev/null
+++ b/psd/hour_hand.psd
Binary files differ
diff --git a/psd/icon.psd b/psd/icon.psd
new file mode 100644
index 0000000..a8f0f81
--- /dev/null
+++ b/psd/icon.psd
Binary files differ
diff --git a/psd/minute_hand.psd b/psd/minute_hand.psd
new file mode 100644
index 0000000..2ebc1f6
--- /dev/null
+++ b/psd/minute_hand.psd
Binary files differ
diff --git a/psd/seconds_hand.psd b/psd/seconds_hand.psd
new file mode 100644
index 0000000..a405194
--- /dev/null
+++ b/psd/seconds_hand.psd
Binary files differ
diff --git a/reference.png b/reference.png
new file mode 100644
index 0000000..4ac5ef7
--- /dev/null
+++ b/reference.png
Binary files differ
diff --git a/silly_walk/resources/src/images/background.png b/silly_walk/resources/src/images/background.png
new file mode 100644
index 0000000..1219eff
--- /dev/null
+++ b/silly_walk/resources/src/images/background.png
Binary files differ
diff --git a/silly_walk/resources/src/images/hour_hand.png b/silly_walk/resources/src/images/hour_hand.png
new file mode 100644
index 0000000..342889a
--- /dev/null
+++ b/silly_walk/resources/src/images/hour_hand.png
Binary files differ
diff --git a/silly_walk/resources/src/images/icon.png b/silly_walk/resources/src/images/icon.png
new file mode 100644
index 0000000..a34703d
--- /dev/null
+++ b/silly_walk/resources/src/images/icon.png
Binary files differ
diff --git a/silly_walk/resources/src/images/minute_hand.png b/silly_walk/resources/src/images/minute_hand.png
new file mode 100644
index 0000000..6a35022
--- /dev/null
+++ b/silly_walk/resources/src/images/minute_hand.png
Binary files differ
diff --git a/silly_walk/resources/src/images/seconds_hand.png b/silly_walk/resources/src/images/seconds_hand.png
new file mode 100644
index 0000000..2c66619
--- /dev/null
+++ b/silly_walk/resources/src/images/seconds_hand.png
Binary files differ
diff --git a/silly_walk/resources/src/resource_map.json b/silly_walk/resources/src/resource_map.json
new file mode 100644
index 0000000..4e9fe55
--- /dev/null
+++ b/silly_walk/resources/src/resource_map.json
@@ -0,0 +1,39 @@
+{
+ "friendlyVersion": "dev_0.0",
+ "versionDefName": "APP_RESOURCES",
+
+ "media": [
+
+ {
+ "type": "png",
+ "defName": "IMAGE_MENU_ICON",
+ "file": "images/icon.png"
+ },
+
+ {
+ "type": "png",
+ "defName": "IMAGE_BACKGROUND",
+ "file": "images/background.png"
+ },
+
+ {
+ "type": "png-trans",
+ "defName": "IMAGE_HOUR_HAND",
+ "file": "images/hour_hand.png"
+ },
+
+ {
+ "type": "png-trans",
+ "defName": "IMAGE_MINUTE_HAND",
+ "file": "images/minute_hand.png"
+ },
+
+ {
+ "type": "png-trans",
+ "defName": "IMAGE_SECOND_HAND",
+ "file": "images/seconds_hand.png"
+ }
+
+ ]
+}
+
diff --git a/silly_walk/src/silly_walk.c b/silly_walk/src/silly_walk.c
new file mode 100644
index 0000000..2093b7f
--- /dev/null
+++ b/silly_walk/src/silly_walk.c
@@ -0,0 +1,119 @@
+#include "pebble_os.h"
+#include "pebble_app.h"
+#include "pebble_fonts.h"
+
+
+#define MY_UUID { 0xAE, 0xF7, 0x20, 0xA0, 0x74, 0x8F, 0x49, 0x01, 0xB2, 0xF5, 0xD4, 0x0B, 0xF9, 0xF6, 0xA5, 0x96 }
+PBL_APP_INFO(MY_UUID,
+ "Silly Walk", "Dansl",
+ 1, 0, /* App version */
+ RESOURCE_ID_IMAGE_MENU_ICON,
+ APP_INFO_WATCH_FACE);
+
+Window window;
+
+BmpContainer background_image_container;
+
+RotBmpPairContainer hour_hand_image_container;
+RotBmpPairContainer minute_hand_image_container;
+RotBmpPairContainer second_hand_image_container;
+
+void update_watch(PblTm* t){
+ // Watch = 144x168 half = 72x84
+ // Hour GFX = 70x70 half = 35x35
+ // Min GFX = 30x70 half = 15x35
+ // Sec GFX = 14x50 half = 7x25
+
+ //rotbmp_pair_layer_set_angle(&hour_hand_image_container.layer, ((t->tm_hour % 12) * 30) + (t->tm_min/2));
+ hour_hand_image_container.layer.white_layer.rotation = TRIG_MAX_ANGLE * (((t->tm_hour % 12) * 30) + (t->tm_min/2)) / 360;
+ hour_hand_image_container.layer.black_layer.rotation = TRIG_MAX_ANGLE * (((t->tm_hour % 12) * 30) + (t->tm_min/2)) / 360;
+ hour_hand_image_container.layer.layer.frame.origin.x = (144/2) - (hour_hand_image_container.layer.layer.frame.size.w/2);
+ hour_hand_image_container.layer.layer.frame.origin.y = (168/2) - (hour_hand_image_container.layer.layer.frame.size.h/2);
+ layer_mark_dirty(&hour_hand_image_container.layer.layer);
+
+ //rotbmp_pair_layer_set_angle(&minute_hand_image_container.layer, t->tm_min * 6);
+ minute_hand_image_container.layer.white_layer.rotation = TRIG_MAX_ANGLE * (t->tm_min * 6) / 360;
+ minute_hand_image_container.layer.black_layer.rotation = TRIG_MAX_ANGLE * (t->tm_min * 6) / 360;
+ minute_hand_image_container.layer.layer.frame.origin.x = (144/2) - (minute_hand_image_container.layer.layer.frame.size.w/2);
+ minute_hand_image_container.layer.layer.frame.origin.y = (168/2) - (minute_hand_image_container.layer.layer.frame.size.h/2);
+ layer_mark_dirty(&minute_hand_image_container.layer.layer);
+
+ //rotbmp_pair_layer_set_angle(&second_hand_image_container.layer, t->tm_sec * 6);
+ second_hand_image_container.layer.white_layer.rotation = TRIG_MAX_ANGLE * (t->tm_sec * 6) / 360;
+ second_hand_image_container.layer.black_layer.rotation = TRIG_MAX_ANGLE * (t->tm_sec * 6) / 360;
+ second_hand_image_container.layer.layer.frame.origin.x = (144/2) - (second_hand_image_container.layer.layer.frame.size.w/2);
+ second_hand_image_container.layer.layer.frame.origin.y = (168/2) - (second_hand_image_container.layer.layer.frame.size.h/2);
+ layer_mark_dirty(&second_hand_image_container.layer.layer);
+}
+
+// Called once per second
+void handle_second_tick(AppContextRef ctx, PebbleTickEvent *t) {
+ update_watch(t->tick_time);
+}
+
+
+// Handle the start-up of the app
+void handle_init(AppContextRef app_ctx) {
+
+ // Create our app's base window
+ window_init(&window, "Silly Walk");
+ window_stack_push(&window, true);
+ window_set_background_color(&window, GColorBlack);
+
+ resource_init_current_app(&APP_RESOURCES);
+
+ // Set up a layer for the static watch face background
+ bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND, &background_image_container);
+ layer_add_child(&window.layer, &background_image_container.layer.layer);
+
+
+ // Set up a layer for the hour hand
+ //rotbmp_init_container(RESOURCE_ID_IMAGE_HOUR_HAND, &hour_hand_image_container);
+ rotbmp_pair_init_container(RESOURCE_ID_IMAGE_HOUR_HAND_WHITE, RESOURCE_ID_IMAGE_HOUR_HAND_BLACK, &hour_hand_image_container);
+ rotbmp_pair_layer_set_src_ic(&hour_hand_image_container.layer, GPoint(33, 40));
+ layer_add_child(&window.layer, &hour_hand_image_container.layer.layer);
+
+
+ // Set up a layer for the minute hand
+ rotbmp_pair_init_container(RESOURCE_ID_IMAGE_MINUTE_HAND_WHITE, RESOURCE_ID_IMAGE_MINUTE_HAND_BLACK, &minute_hand_image_container);
+ rotbmp_pair_layer_set_src_ic(&minute_hand_image_container.layer, GPoint(16, 60));
+ layer_add_child(&window.layer, &minute_hand_image_container.layer.layer);
+
+
+ // Set up a layer for the second hand
+ rotbmp_pair_init_container(RESOURCE_ID_IMAGE_SECOND_HAND_WHITE, RESOURCE_ID_IMAGE_SECOND_HAND_BLACK, &second_hand_image_container);
+ rotbmp_pair_layer_set_src_ic(&second_hand_image_container.layer, GPoint(7, 44));
+ layer_add_child(&window.layer, &second_hand_image_container.layer.layer);
+
+ PblTm t;
+ get_time(&t);
+ update_watch(&t);
+
+}
+
+void handle_deinit(AppContextRef ctx) {
+
+ bmp_deinit_container(&background_image_container);
+ rotbmp_pair_deinit_container(&hour_hand_image_container);
+ rotbmp_pair_deinit_container(&minute_hand_image_container);
+ rotbmp_pair_deinit_container(&second_hand_image_container);
+}
+
+
+// The main event/run loop for our app
+void pbl_main(void *params) {
+ PebbleAppHandlers handlers = {
+
+ // Handle app start
+ .init_handler = &handle_init,
+ .deinit_handler = &handle_deinit,
+
+ // Handle time updates
+ .tick_info = {
+ .tick_handler = &handle_second_tick,
+ .tick_units = SECOND_UNIT
+ }
+
+ };
+ app_event_loop(params, &handlers);
+} \ No newline at end of file