-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e8ec3d9
Showing
7 changed files
with
197 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# segment-six | ||
|
||
![screenshot](segment-six-screenshot.png) | ||
|
||
Example watchface showing the minutes and seconds as arc segments. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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')) |