diff options
author | Dan Long <dan@dansl.net> | 2013-04-16 08:33:17 +0400 |
---|---|---|
committer | Dan Long <dan@dansl.net> | 2013-04-16 08:33:17 +0400 |
commit | 23c67a34bbecfe653f402c472b7572a5ff6dcbaa (patch) | |
tree | 04b6d1b74d9d67fc60be663a8aa144a6318f5fd5 | |
parent | 98c14aec89c8adbc894c2ede82898e8dfcbccac1 (diff) |
Silly Walk Simple
19 files changed, 154 insertions, 0 deletions
diff --git a/psd/background.psd b/psd/silly_walk/background.psd Binary files differindex aa0b7a0..aa0b7a0 100644 --- a/psd/background.psd +++ b/psd/silly_walk/background.psd diff --git a/psd/hour_hand.psd b/psd/silly_walk/hour_hand.psd Binary files differindex cfc7fb3..cfc7fb3 100644 --- a/psd/hour_hand.psd +++ b/psd/silly_walk/hour_hand.psd diff --git a/psd/icon.psd b/psd/silly_walk/icon.psd Binary files differindex a8f0f81..a8f0f81 100644 --- a/psd/icon.psd +++ b/psd/silly_walk/icon.psd diff --git a/psd/minute_hand.psd b/psd/silly_walk/minute_hand.psd Binary files differindex 2ebc1f6..2ebc1f6 100644 --- a/psd/minute_hand.psd +++ b/psd/silly_walk/minute_hand.psd diff --git a/psd/seconds_hand.psd b/psd/silly_walk/seconds_hand.psd Binary files differindex a405194..a405194 100644 --- a/psd/seconds_hand.psd +++ b/psd/silly_walk/seconds_hand.psd diff --git a/psd/silly_walk_simple/background.psd b/psd/silly_walk_simple/background.psd Binary files differnew file mode 100644 index 0000000..8b11a20 --- /dev/null +++ b/psd/silly_walk_simple/background.psd diff --git a/psd/silly_walk_simple/hour_hand.psd b/psd/silly_walk_simple/hour_hand.psd Binary files differnew file mode 100644 index 0000000..cfc7fb3 --- /dev/null +++ b/psd/silly_walk_simple/hour_hand.psd diff --git a/psd/silly_walk_simple/icon.psd b/psd/silly_walk_simple/icon.psd Binary files differnew file mode 100644 index 0000000..a8f0f81 --- /dev/null +++ b/psd/silly_walk_simple/icon.psd diff --git a/psd/silly_walk_simple/minute_hand.psd b/psd/silly_walk_simple/minute_hand.psd Binary files differnew file mode 100644 index 0000000..2ebc1f6 --- /dev/null +++ b/psd/silly_walk_simple/minute_hand.psd diff --git a/psd/silly_walk_simple/seconds_hand.psd b/psd/silly_walk_simple/seconds_hand.psd Binary files differnew file mode 100644 index 0000000..a405194 --- /dev/null +++ b/psd/silly_walk_simple/seconds_hand.psd diff --git a/reference2.png b/reference2.png Binary files differnew file mode 100644 index 0000000..330f30d --- /dev/null +++ b/reference2.png diff --git a/silly_walk_simple/resources/src/images/background.png b/silly_walk_simple/resources/src/images/background.png Binary files differnew file mode 100644 index 0000000..6e8025f --- /dev/null +++ b/silly_walk_simple/resources/src/images/background.png diff --git a/silly_walk_simple/resources/src/images/hour_hand.png b/silly_walk_simple/resources/src/images/hour_hand.png Binary files differnew file mode 100644 index 0000000..342889a --- /dev/null +++ b/silly_walk_simple/resources/src/images/hour_hand.png diff --git a/silly_walk_simple/resources/src/images/icon.png b/silly_walk_simple/resources/src/images/icon.png Binary files differnew file mode 100644 index 0000000..a34703d --- /dev/null +++ b/silly_walk_simple/resources/src/images/icon.png diff --git a/silly_walk_simple/resources/src/images/minute_hand.png b/silly_walk_simple/resources/src/images/minute_hand.png Binary files differnew file mode 100644 index 0000000..6a35022 --- /dev/null +++ b/silly_walk_simple/resources/src/images/minute_hand.png diff --git a/silly_walk_simple/resources/src/images/seconds_hand.png b/silly_walk_simple/resources/src/images/seconds_hand.png Binary files differnew file mode 100644 index 0000000..2c66619 --- /dev/null +++ b/silly_walk_simple/resources/src/images/seconds_hand.png diff --git a/silly_walk_simple/resources/src/resource_map.json b/silly_walk_simple/resources/src/resource_map.json new file mode 100644 index 0000000..4e9fe55 --- /dev/null +++ b/silly_walk_simple/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_simple/silly_walk_simple.pbw b/silly_walk_simple/silly_walk_simple.pbw Binary files differnew file mode 100644 index 0000000..49a1dad --- /dev/null +++ b/silly_walk_simple/silly_walk_simple.pbw diff --git a/silly_walk_simple/src/silly_walk_simple.c b/silly_walk_simple/src/silly_walk_simple.c new file mode 100644 index 0000000..dbddc22 --- /dev/null +++ b/silly_walk_simple/src/silly_walk_simple.c @@ -0,0 +1,115 @@ +#include "pebble_os.h" +#include "pebble_app.h" +#include "pebble_fonts.h" + + +#define MY_UUID { 0x08, 0x08, 0xBD, 0x57, 0x94, 0x61, 0x4D, 0xA5, 0x98, 0xF4, 0x61, 0x6D, 0xA2, 0x5E, 0x6B, 0xA8 } +PBL_APP_INFO(MY_UUID, + "Silly Walk Simple", "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){ + + //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 Simple"); + 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 |