From e8ec3d958560699de0bc7bfd09fdba5662b9e071 Mon Sep 17 00:00:00 2001 From: C-D-Lewis Date: Wed, 11 Mar 2015 16:15:32 -0700 Subject: [PATCH] Initial commit --- .gitignore | 1 + README.md | 5 + appinfo.json | 27 +++++ resources/images/menu_icon_sector_watch.png | Bin 0 -> 357 bytes segment-six-screenshot.png | Bin 0 -> 2042 bytes src/segment_six.c | 125 ++++++++++++++++++++ wscript | 39 ++++++ 7 files changed, 197 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 appinfo.json create mode 100644 resources/images/menu_icon_sector_watch.png create mode 100644 segment-six-screenshot.png create mode 100644 src/segment_six.c create mode 100644 wscript diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..378eac2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build diff --git a/README.md b/README.md new file mode 100644 index 0000000..529f14f --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# segment-six + +![screenshot](segment-six-screenshot.png) + +Example watchface showing the minutes and seconds as arc segments. \ No newline at end of file diff --git a/appinfo.json b/appinfo.json new file mode 100644 index 0000000..2dc3fa9 --- /dev/null +++ b/appinfo.json @@ -0,0 +1,27 @@ +{ + "uuid": "1e8d28ef-e169-4924-a8b8-76c32faa7a66", + "shortName": "Segment Six", + "longName": "Segment Six", + "companyName": "Pebble Technology", + "versionCode": 2, + "versionLabel": "2.0", + "watchapp": { + "watchface": true + }, + "appKeys": {}, + "resources": { + "media": [ + { + "menuIcon": true, + "type": "png", + "name": "IMAGE_MENU_ICON", + "file": "images/menu_icon_sector_watch.png" + } + ] + }, + "targetPlatforms": [ + "aplite", + "basalt" + ], + "sdkVersion": "3" +} \ No newline at end of file diff --git a/resources/images/menu_icon_sector_watch.png b/resources/images/menu_icon_sector_watch.png new file mode 100644 index 0000000000000000000000000000000000000000..96b3f6685209cd988a6b12d91b7b7af3a4b298b9 GIT binary patch literal 357 zcmeAS@N?(olHy`uVBq!ia0vp^54uQv?#&cA*_N`YQM;K6Fbp0 zN7m1D{rmL8+W1F2YD)KYFR?GLSdx3|e^#}z;E`N8yCOIF&}sTI4gCN^}5F8a&s~Q tu9O&^j@+Wm_a`~`Gd@b9mFu&t8J)?l?U{RQ*{gQu&X%Q~loCIFJff`R}5 literal 0 HcmV?d00001 diff --git a/segment-six-screenshot.png b/segment-six-screenshot.png new file mode 100644 index 0000000000000000000000000000000000000000..4c12e292c76b90ce80429a3a86df89c62bb979cf GIT binary patch literal 2042 zcmV{Q+R+uPg6=U@F%0z(PB3(!z* zy6OJ}1V|KI2?&rYKHV%pGT=%;fL!tEW&x4`R|4Au`uOnw7UTW>5#yeJwg7}cGRk9h zTuTC)38n>YHBid{Vn%a^Y6VQC0aZk^8m4l9RzkA^rZRwbfO7>^VT+>%v?H2oU5OHq z;M~88>5*|CA<4OiZ(*X%iKOCmR_B23(9@sgr_bZ1R@upRq%Me7O{Hdk5x&?7MBaC(EVb{Efe%z2HThg^Wz5HX^u*qM5AbOT~Q z)U#ku2Z^|swJTXOg#em`$hydg!lTDzgk;GV2IvShD+tTt&_#|OFDpCiIxHE(0Y!Hs z%c86Sv0ldnsg-vKpeRJG#jt`HnO7A=VStc`c7k)o#scZC2BCluh<3)4eXe}fDW?JQ zAQGN`C1vPD&+2j8fgTe^7qBM;^s`6KA#C^bQ+Ks^&eKsrAUF^5;;@bmi+Q|Ri2eZbOvH=Bb@$eUG~TbRfhe1j$nl z-@S3gW2 z(-Q>=3+2^lnTXN=>3k$W?gZ3@+!2}w$m&9A9Y}c0wTE4pfk=R0<>DJ?89?ej^KeBY zO6foXBtXLn2+weIup1-0PB0%fbHf3c3loIpvhaBNo{)MRkO#*Zc zzA7RCN(S^Q@QR28hzQVQD%B8C1F9Hk%cCXmDu^s=Y2|VL9R78V6#+fgWC^|kBFj1i zs3!sAwbtO-5n0z^jO9%o$e2`5@XUyM)?tZ8fGjB)x3FJlgU|mF3FDstrbiE@{G378a|5jE4)Jo{|`Dg)H5RK0NRYYNcR@}xs1(=P% z=rXNKJ%yNw$TM#NYN_b>98riFkP!2J7E|aJrfuwAW+tL2JfUx4M|7D%bu^OUOOeIM z$_6>-YjEm71C)>j$v}jhZ#p1tV{M_4h$8W%Y+(Y_1{9gm5`ZEDvXuvWRa8;XohWLa z=QP95KsrqK;YA`^3Xr;x9TEaj2A;Gt(65$9`ZWi8dB3lWE|3RN^xURwVXJLr8ATdJ zlrguTdVc>fg?yvq_J?{jnBFcCeSJo5y;)_<=~oAu0ce%;P*$<5h_dGM2T;bIe(eU< zP@=ntXZ*~9S@O!9&(Q=PU)=rLzp@{`LKn);>=mNyxljNSqW=E(4ABfce*n$uLe&vv z7LN_jSM821Y$l+}h_V1N;W^jq7oeGlEQiGYh97@N2B5oaGM@b`!Sj4*0I3T-$Igc5 zTBkpNW_F>fh$1=x+Z)%x`#P_ufMz4A1_=#_vFqH`gceXGL`Xoac)9^GbfKLPv2Iy+ zTi4HjKflIbk8#MKEYJH;g*P-$R_u6Q{UG0NVMoC|!FbTLULVn8d&e8esREqVF3<$T zvX!-3sTY9v{vJTBj@mPpciyf0TXQu5VnfvWsc3}~_4%v9w+c};mscSjp{n*aUX!JU>MJs=e1bZ(FKSZ5fdZ}R;F{#b-q?SUzvaY?fybE^WvEg z+bia_ETEBgZ0Q`m*Hl2`$!Z7?`&Ra<$UW`37YqBjrnR1tY=!|<3+$Z=I{DNqBR5|vL=PU zE)q{l2T~`(qp*$`jVBe5AX&@qzb*q#>K1m5L|d94$=wK0>X$3UP17docTMf)L z+j56!?^YLqYjq^AGT$B$8su){3D9m82d`Ivz=7^IoB-`saqxNt2ps5c!wJxC6$h{P YKhc&+hVe>*7ytkO07*qoM6N<$f|F*Zn*aa+ literal 0 HcmV?d00001 diff --git a/src/segment_six.c b/src/segment_six.c new file mode 100644 index 0000000..e413a37 --- /dev/null +++ b/src/segment_six.c @@ -0,0 +1,125 @@ +#include "pebble.h" + +static const GPathInfo MINUTE_SEGMENT_PATH_POINTS = { + 3, + (GPoint[]) { + {0, 0}, + {-8, -80}, // 80 = radius + fudge; 8 = 80*tan(6 degrees); 6 degrees per minute; + {8, -80}, + } +}; + +static const GPathInfo HOUR_SEGMENT_PATH_POINTS = { + 3, + (GPoint[]) { + {0, 0}, + {-13, -50}, // 50 = radius + fudge; _ = 50*tan(15 degrees); 30 degrees per hour; + {13, -50}, + } +}; + +static Window *s_main_window; +static Layer *s_minute_display_layer, *s_hour_display_layer; + +static GPath *s_minute_segment_path, *s_hour_segment_path; + +static void minute_display_update_proc(Layer *layer, GContext* ctx) { + time_t now = time(NULL); + struct tm *t = localtime(&now); + + unsigned int angle = t->tm_min * 6; + gpath_rotate_to(s_minute_segment_path, (TRIG_MAX_ANGLE / 360) * angle); + + GRect bounds = layer_get_bounds(layer); + GPoint center = grect_center_point(&bounds); + graphics_context_set_fill_color(ctx, GColorWhite); + graphics_fill_circle(ctx, center, 77); + graphics_context_set_fill_color(ctx, GColorBlack); + gpath_draw_filled(ctx, s_minute_segment_path); + graphics_fill_circle(ctx, center, 52); +} + +static void hour_display_update_proc(Layer *layer, GContext* ctx) { + time_t now = time(NULL); + struct tm *t = localtime(&now); + + unsigned int angle = (t->tm_hour % 12) * 30; + GRect bounds = layer_get_bounds(layer); + GPoint center = grect_center_point(&bounds); + + graphics_context_set_fill_color(ctx, GColorWhite); + graphics_fill_circle(ctx, center, 48); + + for (unsigned int i = 0; i < 360; i += 15) { + if ((i != angle) && (i != (angle + 15)) && (i != ((angle - 15 + 360) % 360)) ) { + gpath_rotate_to(s_hour_segment_path, (TRIG_MAX_ANGLE / 360) * i); + graphics_context_set_fill_color(ctx, GColorBlack); + gpath_draw_filled(ctx, s_hour_segment_path); + } + } + + // Stray pixels + graphics_context_set_fill_color(ctx, GColorBlack); + graphics_fill_circle(ctx, center, 5); + graphics_context_set_stroke_color(ctx, GColorBlack); + if ((angle != 0) && (angle != 330)) { + graphics_draw_pixel(ctx, GPoint(71, 77)); + graphics_draw_pixel(ctx, GPoint(71, 78)); + } +} + +static void handle_minute_tick(struct tm *tick_time, TimeUnits units_changed) { + layer_mark_dirty(s_minute_display_layer); + layer_mark_dirty(s_hour_display_layer); +} + +static void main_window_load(Window *window) { + Layer *window_layer = window_get_root_layer(window); + GRect bounds = layer_get_bounds(window_layer); + + s_minute_display_layer = layer_create(bounds); + layer_set_update_proc(s_minute_display_layer, minute_display_update_proc); + layer_add_child(window_layer, s_minute_display_layer); + + s_minute_segment_path = gpath_create(&MINUTE_SEGMENT_PATH_POINTS); + gpath_move_to(s_minute_segment_path, grect_center_point(&bounds)); + + s_hour_display_layer = layer_create(bounds); + layer_set_update_proc(s_hour_display_layer, hour_display_update_proc); + layer_add_child(window_layer, s_hour_display_layer); + + s_hour_segment_path = gpath_create(&HOUR_SEGMENT_PATH_POINTS); + gpath_move_to(s_hour_segment_path, grect_center_point(&bounds)); +} + +static void main_window_unload(Window *window) { + gpath_destroy(s_minute_segment_path); + gpath_destroy(s_hour_segment_path); + + layer_destroy(s_minute_display_layer); + layer_destroy(s_hour_display_layer); +} + +static void init() { + s_main_window = window_create(); + window_set_background_color(s_main_window, GColorBlack); + window_set_window_handlers(s_main_window, (WindowHandlers) { + .load = main_window_load, + .unload = main_window_unload, + }); + window_stack_push(s_main_window, true); + + tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick); +} + +static void deinit() { + window_destroy(s_main_window); + + tick_timer_service_unsubscribe(); +} + +int main() { + init(); + app_event_loop(); + deinit(); +} diff --git a/wscript b/wscript new file mode 100644 index 0000000..e9657e5 --- /dev/null +++ b/wscript @@ -0,0 +1,39 @@ + +# +# This file is the default set of rules to compile a Pebble project. +# +# Feel free to customize this to your needs. +# + +import os.path + +top = '.' +out = 'build' + +def options(ctx): + ctx.load('pebble_sdk') + +def configure(ctx): + ctx.load('pebble_sdk') + +def build(ctx): + ctx.load('pebble_sdk') + + build_worker = os.path.exists('worker_src') + binaries = [] + + for p in ctx.env.TARGET_PLATFORMS: + ctx.set_env(ctx.all_envs[p]) + app_elf='{}/pebble-app.elf'.format(ctx.env.BUILD_DIR) + ctx.pbl_program(source=ctx.path.ant_glob('src/**/*.c'), + target=app_elf) + + if build_worker: + worker_elf='{}/pebble-worker.elf'.format(ctx.env.BUILD_DIR) + binaries.append({'platform': p, 'app_elf': app_elf, 'worker_elf': worker_elf}) + ctx.pbl_worker(source=ctx.path.ant_glob('worker_src/**/*.c'), + target=worker_elf) + else: + binaries.append({'platform': p, 'app_elf': app_elf}) + + ctx.pbl_bundle(binaries=binaries, js=ctx.path.ant_glob('src/js/**/*.js'))