Compare commits

...

34 Commits
0.9 ... master

Author SHA1 Message Date
Alina Marquardt b53e699bcf added demo time of 8 past 10 2015-12-20 21:39:46 +01:00
Alina Marquardt 9d4f553f7f prepared for aplite and added hand width option 2015-12-20 21:10:16 +01:00
Alina Marquardt 34722e9f62 sync with cloudpebble 2015-12-20 19:54:05 +01:00
Alina Marquardt eebb13b2de added option for vibration alert on bt disconnect 2015-11-25 23:05:47 +01:00
Alina Marquardt 626d922c57 layer handling fixes 2015-11-25 21:47:20 +01:00
Alina Marquardt adfcf45283 separated background/ticks and hands into layers 2015-11-25 21:29:31 +01:00
Alina Marquardt 18223442d0 made changes release ready 2015-11-25 20:18:30 +01:00
Alina Marquardt 9d7b3a945a fixed boolean in AppMessage bug, moved ticks 2015-11-25 20:02:53 +01:00
Alina Marquardt 4e298171ef fixed a bug on Android keeping ticks rectangular 2015-11-24 23:23:27 +01:00
Alina Marquardt 4b254e6a42 added configuration for ticks fitting to rectangle 2015-11-24 21:14:50 +01:00
Alina Marquardt e92a88932c refactored all of the hands drawing 2015-11-24 00:21:26 +01:00
Alina Marquardt 6aeb9601c0 set dummy time for emulator 2015-11-20 03:35:16 +01:00
Alina Marquardt 404536c3b7 release 2015-11-20 01:27:50 +01:00
Alina Marquardt b48313dba4 added setting for tick marks 2015-11-20 00:33:31 +01:00
Alina Marquardt b8508ce0fd made watchface always light up in emulator 2015-11-18 22:50:23 +01:00
Alina Marquardt f6d3c9c3f5 excluded binaries from repo 2015-11-18 22:28:21 +01:00
Alina Marquardt e7c01919d4 added shadow-toggle to the settings page 2015-11-18 22:25:45 +01:00
Alina Marquardt e3216b3352 removed config page from repo 2015-11-18 21:05:31 +01:00
Alina Marquardt 2604a8d3ae added drop shadows to the hands 2015-11-18 21:01:57 +01:00
Alina Marquardt d0fa7bc990 Merge branch 'master' of https://github.com/lastfuture/Pebble-Time-Watchface---Super-Simple 2015-11-18 19:21:24 +01:00
Alina Marquardt f032dc6488 removed assets 2015-11-18 19:20:40 +01:00
Alina Marquardt a27ed69547 added shadowtable
added shadowtable from https://github.com/robisodd/transparency/blob/master/src/transparency.c
2015-11-16 22:38:40 +01:00
Alina Marquardt ff15d72028 added banner for chalk 2015-11-15 20:44:59 +01:00
Alina Marquardt 5296df4453 added more screenshots and animated screens to the assets 2015-11-14 23:39:45 +01:00
Alina Marquardt e1511925f8 bugfix when loading colors configured as black 2015-11-14 21:47:34 +01:00
Alina Marquardt d93e38187a Merge branch 'master' of https://github.com/lastfuture/Pebble-Time-Watchface---Super-Simple 2015-11-14 20:56:31 +01:00
Alina Marquardt 55d64b8f9c created new assets for color configurations 2015-11-14 20:56:21 +01:00
Alina Marquardt c34c5e9b4c added color configuration to the C part 2015-11-14 20:38:08 +01:00
Alina Marquardt c9d52de376 added pebble-js-app.js 2015-11-14 19:44:20 +01:00
Alina Marquardt 6d69c296d9 turned divs into labels to make color pickers work 2015-11-14 19:43:39 +01:00
Alina Marquardt f616ae6dd2 corrected colors to reflect default colors in watchface 2015-11-14 19:31:07 +01:00
Alina Marquardt 99e43e6502 added HTML/JS/CSS for config page (but not the integration into the watchface yet) 2015-11-14 19:28:49 +01:00
Alina Marquardt 99b0cdeee6 added assets for basalt as well 2015-11-14 18:00:10 +01:00
Alina Marquardt aff6eaa6c0 added assets for pebble watch app store 2015-11-14 17:55:26 +01:00
5 changed files with 482 additions and 69 deletions

32
.gitignore vendored Normal file
View File

@ -0,0 +1,32 @@
assets
config
bin
# Created by https://www.gitignore.io/api/osx
### OSX ###
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

View File

@ -1 +1 @@
# Pebble-Time-Watchface---Super-Simple
# “Super Simple” watchface for Pebble Time Round and Pebble Time

View File

@ -1,5 +1,17 @@
{
"appKeys": {},
"appKeys": {
"btvibe": 8,
"colorbg": 0,
"colorh": 2,
"colorm": 1,
"colorp": 3,
"colort": 6,
"invert": 9,
"rectticks": 7,
"shadows": 4,
"ticks": 5,
"whwidth": 10
},
"capabilities": [
"configurable"
],
@ -12,11 +24,12 @@
"sdkVersion": "3",
"shortName": "Super Simple",
"targetPlatforms": [
"aplite",
"basalt",
"chalk"
],
"uuid": "ceeae81b-6b50-43b6-8bbb-6d6f6eb62b69",
"versionLabel": "0.9",
"versionLabel": "1.8",
"watchapp": {
"watchface": true
}

42
src/js/pebble-js-app.js Normal file
View File

@ -0,0 +1,42 @@
Pebble.addEventListener('ready', function() {
console.log('PebbleKit JS ready!');
});
Pebble.addEventListener('showConfiguration', function() {
var watch;
if(Pebble.getActiveWatchInfo) {
watch = Pebble.getActiveWatchInfo();
}
var url='http://pebble.lastfuture.de/config/supersimple18/';
if (watch.platform == "basalt") {
url += "?rect=true";
} else if (watch.platform == "aplite") {
url += "?rect=true&bw=true";
}
console.log('Showing configuration page: '+url);
Pebble.openURL(url);
});
Pebble.addEventListener('webviewclosed', function(e) {
var configData = JSON.parse(decodeURIComponent(e.response));
console.log('Configuration page returned: '+JSON.stringify(configData));
if (configData.colorbg) {
Pebble.sendAppMessage({
colorbg: parseInt(configData.colorbg, 16),
colorm: parseInt(configData.colorm, 16),
colorh: parseInt(configData.colorh, 16),
colorp: parseInt(configData.colorp, 16),
shadows: 0+(configData.shadows === 'true'),
ticks: configData.ticks,
colort: parseInt(configData.colort, 16),
rectticks: 0+(configData.rectticks === 'true'),
btvibe: 0+(configData.btvibe === 'true'),
invert: 0+(configData.invert === 'true'),
whwidth: configData.whwidth,
}, function() {
console.log('Send successful!');
}, function() {
console.log('Send failed!');
});
}
});

View File

@ -1,21 +1,46 @@
#include <pebble.h>
#define MINUTE_COLOR GColorWhite
#define HOUR_COLOR GColorRed
#define PEG_COLOR GColorDarkGray
#define BG_COLOR GColorBlack
#define KEY_BG_COLOR 0
#define KEY_MINUTE_COLOR 1
#define KEY_HOUR_COLOR 2
#define KEY_PEG_COLOR 3
#define KEY_SHADOWS 4
#define KEY_TICKS 5
#define KEY_TICK_COLOR 6
#define KEY_RECT_TICKS 7
#define KEY_BT_VIBE 8
#define KEY_INVERT 9
#define KEY_HAND_WIDTH 10
#define ANTIALIASING true
#define FINAL_RADIUS 88
#define HAND_WIDTH 7
#define DOT_RADIUS HAND_WIDTH/4
#define HAND_MARGIN_OUTER 10-(HAND_WIDTH/2)
#define HAND_MARGIN_INNER 0
#define TICK_RADIUS 3
#define HAND_MARGIN_M 16
#define HAND_MARGIN_H 42
#define SHADOW_OFFSET 2
#define ANIMATION_DURATION 600
#define ANIMATION_DELAY 150
#define ANIMATION_DURATION 750
#define ANIMATION_DELAY 0
static uint8_t shadowtable[] = {192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, \
192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, \
192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, \
192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, \
192,192,192,193,192,192,192,193,192,192,192,193,196,196,196,197, \
192,192,192,193,192,192,192,193,192,192,192,193,196,196,196,197, \
192,192,192,193,192,192,192,193,192,192,192,193,196,196,196,197, \
208,208,208,209,208,208,208,209,208,208,208,209,212,212,212,213, \
192,192,193,194,192,192,193,194,196,196,197,198,200,200,201,202, \
192,192,193,194,192,192,193,194,196,196,197,198,200,200,201,202, \
208,208,209,210,208,208,209,210,212,212,213,214,216,216,217,218, \
224,224,225,226,224,224,225,226,228,228,229,230,232,232,233,234, \
192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207, \
208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223, \
224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239, \
240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255};
// alpha should only be 0b??111111 where ?? = 00 (full shade), 01 (much shade), 10 (some shade), 11 (none shade)
static uint8_t alpha = 0b10111111;
typedef struct {
int hours;
@ -23,13 +48,121 @@ typedef struct {
} Time;
static Window *s_main_window;
static Layer *s_canvas_layer;
static Layer *bg_canvas_layer, *s_canvas_layer;
static GPoint s_center;
static Time s_last_time;
static int s_radius = 0;
static bool s_animating = false;
static float anim_offset;
static int animpercent = 0, ticks = 0, whwidth = 7;
static bool s_animating = false, shadows = true, debug = false, rectticks = true, btvibe = false, invert = false;
static GColor gcolorbg, gcolorm, gcolorh, gcolorp, gcolorshadow, gcolort;
static void handle_bw_colors() {
if (!invert) {
gcolorbg = GColorBlack;
gcolorm = GColorWhite;
gcolorh = GColorWhite;
gcolorp = GColorBlack;
gcolort = GColorWhite;
shadows = false;
} else {
gcolorbg = GColorWhite;
gcolorm = GColorBlack;
gcolorh = GColorBlack;
gcolorp = GColorWhite;
gcolort = GColorBlack;
shadows = false;
}
}
static void inbox_received_handler(DictionaryIterator *iter, void *context) {
Tuple *colorbg_t = dict_find(iter, KEY_BG_COLOR);
Tuple *colorm_t = dict_find(iter, KEY_MINUTE_COLOR);
Tuple *colorh_t = dict_find(iter, KEY_HOUR_COLOR);
Tuple *colorp_t = dict_find(iter, KEY_PEG_COLOR);
Tuple *shadows_t = dict_find(iter, KEY_SHADOWS);
Tuple *ticknum_t = dict_find(iter, KEY_TICKS);
Tuple *colort_t = dict_find(iter, KEY_TICK_COLOR);
Tuple *rectticks_t = dict_find(iter, KEY_RECT_TICKS);
Tuple *btvibe_t = dict_find(iter, KEY_BT_VIBE);
Tuple *invert_t = dict_find(iter, KEY_INVERT);
Tuple *whwidth_t = dict_find(iter, KEY_HAND_WIDTH);
#if defined(PBL_COLOR)
if(colorbg_t) {
int colorbg = colorbg_t->value->int32;
persist_write_int(KEY_BG_COLOR, colorbg);
gcolorbg = GColorFromHEX(colorbg);
gcolorshadow = (GColor8) shadowtable[alpha & gcolorbg.argb];
}
if(colorm_t) {
int colorm = colorm_t->value->int32;
persist_write_int(KEY_MINUTE_COLOR, colorm);
gcolorm = GColorFromHEX(colorm);
}
if(colorh_t) {
int colorh = colorh_t->value->int32;
persist_write_int(KEY_HOUR_COLOR, colorh);
gcolorh = GColorFromHEX(colorh);
}
if(colorp_t) {
int colorp = colorp_t->value->int32;
persist_write_int(KEY_PEG_COLOR, colorp);
gcolorp = GColorFromHEX(colorp);
}
if(colort_t) {
int colort = colort_t->value->int32;
persist_write_int(KEY_TICK_COLOR, colort);
gcolort = GColorFromHEX(colort);
}
if(shadows_t && shadows_t->value->int8 > 0) {
persist_write_bool(KEY_SHADOWS, true);
shadows = true;
} else {
persist_write_bool(KEY_SHADOWS, false);
shadows = false;
}
#elif defined(PBL_BW)
if(invert_t && invert_t->value->int8 > 0) {
persist_write_bool(KEY_INVERT, true);
invert = true;
} else {
persist_write_bool(KEY_INVERT, false);
invert = false;
}
handle_bw_colors();
#endif
if(ticknum_t) {
ticks = ticknum_t->value->uint8;
persist_write_int(KEY_TICKS, ticks);
}
if(rectticks_t && rectticks_t->value->int8 > 0) {
persist_write_bool(KEY_RECT_TICKS, true);
rectticks = true;
} else {
persist_write_bool(KEY_RECT_TICKS, false);
rectticks = false;
}
if(btvibe_t && btvibe_t->value->int8 > 0) {
persist_write_bool(KEY_BT_VIBE, true);
btvibe = true;
} else {
persist_write_bool(KEY_BT_VIBE, false);
btvibe = false;
}
if(whwidth_t) {
whwidth = whwidth_t->value->uint8;
persist_write_int(KEY_HAND_WIDTH, whwidth);
}
if(bg_canvas_layer) {
layer_mark_dirty(bg_canvas_layer);
}
if(s_canvas_layer) {
layer_mark_dirty(s_canvas_layer);
}
vibes_short_pulse();
}
/*************************** AnimationImplementation **************************/
@ -60,9 +193,19 @@ static void animate(int duration, int delay, AnimationImplementation *implementa
static void tick_handler(struct tm *tick_time, TimeUnits changed) {
// Store time
s_last_time.hours = tick_time->tm_hour;
s_last_time.hours -= (s_last_time.hours > 12) ? 12 : 0;
s_last_time.minutes = tick_time->tm_min;
// dummy time in emulator
if (debug) {
/*
s_last_time.hours = 0;
s_last_time.minutes = tick_time->tm_sec;
*/
s_last_time.hours = 10;
s_last_time.minutes = 8;
} else {
s_last_time.hours = tick_time->tm_hour;
s_last_time.hours -= (s_last_time.hours > 12) ? 12 : 0;
s_last_time.minutes = tick_time->tm_min;
}
// Redraw
if(s_canvas_layer) {
@ -70,57 +213,143 @@ static void tick_handler(struct tm *tick_time, TimeUnits changed) {
}
}
static void update_proc(Layer *layer, GContext *ctx) {
// Color background?
static void handle_bluetooth(bool connected) {
if (btvibe && !connected) {
static uint32_t const segments[] = { 200, 200, 50, 150, 200 };
VibePattern pat = {
.durations = segments,
.num_segments = ARRAY_LENGTH(segments),
};
vibes_enqueue_custom_pattern(pat);
}
}
static int32_t get_angle_for_minute(int minute) {
// Progress through 60 minutes, out of 360 degrees
return ((minute * 360) / 60);
}
static int32_t get_angle_for_hour(int hour, int minute) {
// Progress through 12 hours, out of 360 degrees
return (((hour * 360) / 12)+(get_angle_for_minute(minute)/12));
}
static void bg_update_proc(Layer *layer, GContext *ctx) {
GRect bounds = layer_get_bounds(layer);
graphics_context_set_fill_color(ctx, BG_COLOR);
graphics_context_set_fill_color(ctx, gcolorbg);
graphics_fill_rect(ctx, bounds, 0, GCornerNone);
graphics_context_set_antialiased(ctx, ANTIALIASING);
if (ticks > 0) {
graphics_context_set_fill_color(ctx, gcolort);
#if defined(PBL_RECT)
if (rectticks) {
int dist_v = 39;
int dist_h = 46;
int halfwidth = (bounds.size.w/2)-1;
int halfheight = (bounds.size.h/2)-1;
switch (ticks) {
case 12:
graphics_fill_circle(ctx, GPoint(halfwidth+dist_h, 4), TICK_RADIUS/2); // 1
graphics_fill_circle(ctx, GPoint(halfwidth-dist_h, 4), TICK_RADIUS/2); // 11
graphics_fill_circle(ctx, GPoint(halfwidth+dist_h, (bounds.size.h-5)), TICK_RADIUS/2); // 5
graphics_fill_circle(ctx, GPoint(halfwidth-dist_h, (bounds.size.h-5)), TICK_RADIUS/2); // 7
graphics_fill_circle(ctx, GPoint((bounds.size.w-5), halfheight-dist_v), TICK_RADIUS/2); // 2
graphics_fill_circle(ctx, GPoint((bounds.size.w-5), halfheight+dist_v), TICK_RADIUS/2); // 4
graphics_fill_circle(ctx, GPoint(4, halfheight-dist_v), TICK_RADIUS/2); // 10
graphics_fill_circle(ctx, GPoint(4, halfheight+dist_v), TICK_RADIUS/2); // 8
case 4:
graphics_fill_circle(ctx, GPoint(halfwidth, (bounds.size.h-3)), TICK_RADIUS); // 6
graphics_fill_circle(ctx, GPoint((bounds.size.w-3), halfheight), TICK_RADIUS); // 3
graphics_fill_circle(ctx, GPoint(2, halfheight), TICK_RADIUS); // 9
case 1:
default:
graphics_fill_circle(ctx, GPoint(halfwidth, 2), TICK_RADIUS); // 12
break;
}
} else {
#endif
GRect insetbounds = grect_inset(bounds, GEdgeInsets(2));
GRect insetbounds12 = grect_inset(bounds, GEdgeInsets(4));
for(int i = 0; i < ticks; i++) {
int hour_angle = (i * 360) / ticks;
if (ticks == 12 && i%3!=0) {
GPoint pos = gpoint_from_polar(insetbounds12, GOvalScaleModeFitCircle , DEG_TO_TRIGANGLE(hour_angle));
graphics_fill_circle(ctx, pos, TICK_RADIUS/2);
} else {
GPoint pos = gpoint_from_polar(insetbounds, GOvalScaleModeFitCircle , DEG_TO_TRIGANGLE(hour_angle));
graphics_fill_circle(ctx, pos, TICK_RADIUS);
}
}
#if defined(PBL_RECT)
}
#endif
}
}
// Don't use current time while animating
static void update_proc(Layer *layer, GContext *ctx) {
GRect bounds = layer_get_bounds(layer);
GRect bounds_h = bounds;
bounds_h.size.w = bounds_h.size.h;
bounds_h.origin.x -= (bounds_h.size.w-bounds.size.w)/2;
int maxradius = bounds_h.size.w;
if (bounds_h.size.h < maxradius) { maxradius = bounds_h.size.h; }
maxradius /= 2;
int animradius = maxradius-((maxradius*animpercent)/100);
#if defined(PBL_RECT)
int platform_margin_m = (HAND_MARGIN_M/1.5);
#elif defined(PBL_ROUND)
int platform_margin_m = HAND_MARGIN_M;
#endif
int outer_m = animradius+platform_margin_m;
int outer_h = animradius+HAND_MARGIN_H;
if (outer_m < platform_margin_m) {
outer_m = platform_margin_m;
}
if (outer_h < HAND_MARGIN_H) {
outer_h = HAND_MARGIN_H;
}
if (outer_m > maxradius) {
outer_m = maxradius;
}
if (outer_h > maxradius) {
outer_h = maxradius;
}
GRect bounds_mo = grect_inset(bounds_h, GEdgeInsets(outer_m));
GRect bounds_ho = grect_inset(bounds_h, GEdgeInsets(outer_h));
graphics_context_set_antialiased(ctx, ANTIALIASING);
// Use current time while animating
Time mode_time = s_last_time;
// Adjust for minutes through the hour
float hour_angle = TRIG_MAX_ANGLE * mode_time.hours / 12;
float minute_angle = TRIG_MAX_ANGLE * mode_time.minutes / 60;
hour_angle += (minute_angle / TRIG_MAX_ANGLE) * (TRIG_MAX_ANGLE / 12);
if (s_animating) {
hour_angle += anim_offset;
minute_angle -= anim_offset;
}
float hour_deg = get_angle_for_hour(mode_time.hours, mode_time.minutes);
float minute_deg = get_angle_for_minute(mode_time.minutes);
// Plot hands
GPoint minute_hand_outer = (GPoint) {
.x = (int16_t)(sin_lookup(TRIG_MAX_ANGLE * mode_time.minutes / 60) * (int32_t)(s_radius - HAND_MARGIN_OUTER) / TRIG_MAX_RATIO) + s_center.x,
.y = (int16_t)(-cos_lookup(TRIG_MAX_ANGLE * mode_time.minutes / 60) * (int32_t)(s_radius - HAND_MARGIN_OUTER) / TRIG_MAX_RATIO) + s_center.y,
};
GPoint minute_hand_inner = (GPoint) {
.x = (int16_t)(sin_lookup(TRIG_MAX_ANGLE * mode_time.minutes / 60) * (int32_t)HAND_MARGIN_INNER / TRIG_MAX_RATIO) + s_center.x,
.y = (int16_t)(-cos_lookup(TRIG_MAX_ANGLE * mode_time.minutes / 60) * (int32_t)HAND_MARGIN_INNER / TRIG_MAX_RATIO) + s_center.y,
};
GPoint hour_hand_outer = (GPoint) {
.x = (int16_t)(sin_lookup(hour_angle) * (int32_t)(s_radius - HAND_MARGIN_OUTER - (0.3 * s_radius)) / TRIG_MAX_RATIO) + s_center.x,
.y = (int16_t)(-cos_lookup(hour_angle) * (int32_t)(s_radius - HAND_MARGIN_OUTER - (0.3 * s_radius)) / TRIG_MAX_RATIO) + s_center.y,
};
GPoint hour_hand_inner = (GPoint) {
.x = (int16_t)(sin_lookup(hour_angle) * (int32_t)HAND_MARGIN_INNER / TRIG_MAX_RATIO) + s_center.x,
.y = (int16_t)(-cos_lookup(hour_angle) * (int32_t)HAND_MARGIN_INNER / TRIG_MAX_RATIO) + s_center.y,
};
// Draw hands with positive length only
if((s_radius - HAND_MARGIN_OUTER) > HAND_MARGIN_INNER) {
if(s_radius > 2 * HAND_MARGIN_OUTER) {
graphics_context_set_stroke_color(ctx, HOUR_COLOR);
graphics_context_set_stroke_width(ctx, HAND_WIDTH);
graphics_draw_line(ctx, hour_hand_inner, hour_hand_outer);
}
if(s_radius > HAND_MARGIN_OUTER) {
graphics_context_set_stroke_color(ctx, MINUTE_COLOR);
graphics_context_set_stroke_width(ctx, HAND_WIDTH);
graphics_draw_line(ctx, minute_hand_inner, minute_hand_outer);
}
GPoint minute_hand_outer = gpoint_from_polar(bounds_mo, GOvalScaleModeFillCircle, DEG_TO_TRIGANGLE(minute_deg));
GPoint hour_hand_outer = gpoint_from_polar(bounds_ho, GOvalScaleModeFillCircle, DEG_TO_TRIGANGLE(hour_deg));
if(shadows) {
graphics_context_set_stroke_color(ctx, gcolorshadow);
graphics_context_set_stroke_width(ctx, whwidth);
hour_hand_outer.y += SHADOW_OFFSET;
s_center.y += SHADOW_OFFSET;
graphics_draw_line(ctx, s_center, hour_hand_outer);
minute_hand_outer.y += SHADOW_OFFSET+1;
s_center.y += 1;
graphics_draw_line(ctx, s_center, minute_hand_outer);
hour_hand_outer.y -= SHADOW_OFFSET;
minute_hand_outer.y -= SHADOW_OFFSET+1;
s_center.y -= SHADOW_OFFSET+1;
}
graphics_context_set_fill_color(ctx, PEG_COLOR);
graphics_fill_circle(ctx, s_center, DOT_RADIUS);
graphics_context_set_stroke_color(ctx, gcolorh);
graphics_context_set_stroke_width(ctx, whwidth);
graphics_draw_line(ctx, s_center, hour_hand_outer);
graphics_context_set_stroke_color(ctx, gcolorm);
graphics_context_set_stroke_width(ctx, whwidth);
graphics_draw_line(ctx, s_center, minute_hand_outer);
graphics_context_set_fill_color(ctx, gcolorp);
graphics_fill_circle(ctx, s_center, whwidth/4);
}
@ -129,13 +358,85 @@ static void window_load(Window *window) {
GRect window_bounds = layer_get_bounds(window_layer);
s_center = grect_center_point(&window_bounds);
s_center.x -= 1;
s_center.y -= 1;
#if defined(PBL_COLOR)
if (persist_exists(KEY_BG_COLOR)) {
int colorbg = persist_read_int(KEY_BG_COLOR);
gcolorbg = GColorFromHEX(colorbg);
} else {
gcolorbg = GColorBlack;
}
gcolorshadow = (GColor8) shadowtable[alpha & gcolorbg.argb];
if (persist_exists(KEY_MINUTE_COLOR)) {
int colorm = persist_read_int(KEY_MINUTE_COLOR);
gcolorm = GColorFromHEX(colorm);
} else {
gcolorm = GColorWhite;
}
if (persist_exists(KEY_HOUR_COLOR)) {
int colorh = persist_read_int(KEY_HOUR_COLOR);
gcolorh = GColorFromHEX(colorh);
} else {
gcolorh = GColorRed;
}
if (persist_exists(KEY_PEG_COLOR)) {
int colorp = persist_read_int(KEY_PEG_COLOR);
gcolorp = GColorFromHEX(colorp);
} else {
gcolorp = GColorDarkGray;
}
if (persist_exists(KEY_TICK_COLOR)) {
int colort = persist_read_int(KEY_TICK_COLOR);
gcolort = GColorFromHEX(colort);
} else {
gcolort = GColorWhite;
}
if (persist_exists(KEY_SHADOWS)) {
shadows = persist_read_bool(KEY_SHADOWS);
} else {
shadows = false;
}
#elif defined(PBL_BW)
if (persist_exists(KEY_INVERT)) {
invert = persist_read_bool(KEY_INVERT);
} else {
invert = false;
}
handle_bw_colors();
#endif
if (persist_exists(KEY_TICKS)) {
ticks = persist_read_int(KEY_TICKS);
} else {
ticks = 0;
}
if (persist_exists(KEY_RECT_TICKS)) {
rectticks = persist_read_bool(KEY_RECT_TICKS);
} else {
rectticks = false;
}
if (persist_exists(KEY_BT_VIBE)) {
btvibe = persist_read_bool(KEY_BT_VIBE);
} else {
btvibe = false;
}
if (persist_exists(KEY_HAND_WIDTH)) {
whwidth = persist_read_int(KEY_HAND_WIDTH);
} else {
whwidth = 7;
}
bg_canvas_layer = layer_create(window_bounds);
s_canvas_layer = layer_create(window_bounds);
layer_set_update_proc(bg_canvas_layer, bg_update_proc);
layer_set_update_proc(s_canvas_layer, update_proc);
layer_add_child(window_layer, s_canvas_layer);
layer_add_child(window_layer, bg_canvas_layer);
layer_add_child(bg_canvas_layer, s_canvas_layer);
}
static void window_unload(Window *window) {
layer_destroy(bg_canvas_layer);
layer_destroy(s_canvas_layer);
}
@ -146,16 +447,25 @@ static int anim_percentage(AnimationProgress dist_normalized, int max) {
}
static void radius_update(Animation *anim, AnimationProgress dist_normalized) {
s_radius = anim_percentage(dist_normalized, FINAL_RADIUS);
animpercent = anim_percentage(dist_normalized, 100);
layer_mark_dirty(s_canvas_layer);
}
static void init() {
srand(time(NULL));
// keep lit only in emulator
if (watch_info_get_model()==WATCH_INFO_MODEL_UNKNOWN) {
debug = true;
}
time_t t = time(NULL);
struct tm *time_now = localtime(&t);
tick_handler(time_now, MINUTE_UNIT);
if (debug) {
tick_handler(time_now, SECOND_UNIT);
} else {
tick_handler(time_now, MINUTE_UNIT);
}
s_main_window = window_create();
window_set_window_handlers(s_main_window, (WindowHandlers) {
@ -164,7 +474,24 @@ static void init() {
});
window_stack_push(s_main_window, true);
tick_timer_service_subscribe(MINUTE_UNIT, tick_handler);
if (debug) {
tick_timer_service_subscribe(SECOND_UNIT, tick_handler);
} else {
tick_timer_service_subscribe(MINUTE_UNIT, tick_handler);
}
if (debug) {
light_enable(true);
}
handle_bluetooth(connection_service_peek_pebble_app_connection());
connection_service_subscribe((ConnectionHandlers) {
.pebble_app_connection_handler = handle_bluetooth
});
app_message_register_inbox_received(inbox_received_handler);
app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum());
// Prepare animations
AnimationImplementation radius_impl = {
@ -183,4 +510,3 @@ int main() {
deinit();
}