diff options
author | Dan Long <dan@dansl.net> | 2013-04-16 07:37:48 +0400 |
---|---|---|
committer | Dan Long <dan@dansl.net> | 2013-04-16 07:37:48 +0400 |
commit | b8e0d2458fa493e263a79d56a4b5b8fcbe0953eb (patch) | |
tree | 348cd29443dda821855ca531daa6ebc61591b5b2 | |
parent | bf27d0c22cc7c5613381a55c6aab5511c483fffd (diff) |
Initial Commit
-rw-r--r-- | psd/background.psd | bin | 0 -> 1199901 bytes | |||
-rw-r--r-- | psd/hour_hand.psd | bin | 0 -> 32950 bytes | |||
-rw-r--r-- | psd/icon.psd | bin | 0 -> 28589 bytes | |||
-rw-r--r-- | psd/minute_hand.psd | bin | 0 -> 36279 bytes | |||
-rw-r--r-- | psd/seconds_hand.psd | bin | 0 -> 31484 bytes | |||
-rw-r--r-- | reference.png | bin | 0 -> 2515 bytes | |||
-rw-r--r-- | silly_walk/resources/src/images/background.png | bin | 0 -> 1941 bytes | |||
-rw-r--r-- | silly_walk/resources/src/images/hour_hand.png | bin | 0 -> 1214 bytes | |||
-rw-r--r-- | silly_walk/resources/src/images/icon.png | bin | 0 -> 1089 bytes | |||
-rw-r--r-- | silly_walk/resources/src/images/minute_hand.png | bin | 0 -> 1212 bytes | |||
-rw-r--r-- | silly_walk/resources/src/images/seconds_hand.png | bin | 0 -> 1116 bytes | |||
-rw-r--r-- | silly_walk/resources/src/resource_map.json | 39 | ||||
-rw-r--r-- | silly_walk/src/silly_walk.c | 119 |
13 files changed, 158 insertions, 0 deletions
diff --git a/psd/background.psd b/psd/background.psd Binary files differnew file mode 100644 index 0000000..aa0b7a0 --- /dev/null +++ b/psd/background.psd diff --git a/psd/hour_hand.psd b/psd/hour_hand.psd Binary files differnew file mode 100644 index 0000000..cfc7fb3 --- /dev/null +++ b/psd/hour_hand.psd diff --git a/psd/icon.psd b/psd/icon.psd Binary files differnew file mode 100644 index 0000000..a8f0f81 --- /dev/null +++ b/psd/icon.psd diff --git a/psd/minute_hand.psd b/psd/minute_hand.psd Binary files differnew file mode 100644 index 0000000..2ebc1f6 --- /dev/null +++ b/psd/minute_hand.psd diff --git a/psd/seconds_hand.psd b/psd/seconds_hand.psd Binary files differnew file mode 100644 index 0000000..a405194 --- /dev/null +++ b/psd/seconds_hand.psd diff --git a/reference.png b/reference.png Binary files differnew file mode 100644 index 0000000..4ac5ef7 --- /dev/null +++ b/reference.png diff --git a/silly_walk/resources/src/images/background.png b/silly_walk/resources/src/images/background.png Binary files differnew file mode 100644 index 0000000..1219eff --- /dev/null +++ b/silly_walk/resources/src/images/background.png diff --git a/silly_walk/resources/src/images/hour_hand.png b/silly_walk/resources/src/images/hour_hand.png Binary files differnew file mode 100644 index 0000000..342889a --- /dev/null +++ b/silly_walk/resources/src/images/hour_hand.png diff --git a/silly_walk/resources/src/images/icon.png b/silly_walk/resources/src/images/icon.png Binary files differnew file mode 100644 index 0000000..a34703d --- /dev/null +++ b/silly_walk/resources/src/images/icon.png diff --git a/silly_walk/resources/src/images/minute_hand.png b/silly_walk/resources/src/images/minute_hand.png Binary files differnew file mode 100644 index 0000000..6a35022 --- /dev/null +++ b/silly_walk/resources/src/images/minute_hand.png diff --git a/silly_walk/resources/src/images/seconds_hand.png b/silly_walk/resources/src/images/seconds_hand.png Binary files differnew file mode 100644 index 0000000..2c66619 --- /dev/null +++ b/silly_walk/resources/src/images/seconds_hand.png 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 |