|
|
|
@ -8,12 +8,13 @@
|
|
|
|
|
#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 HAND_WIDTH 7
|
|
|
|
|
#define TICK_RADIUS 3
|
|
|
|
|
#define DOT_RADIUS HAND_WIDTH/4
|
|
|
|
|
#define HAND_MARGIN_M 16
|
|
|
|
|
#define HAND_MARGIN_H 42
|
|
|
|
|
#define SHADOW_OFFSET 2
|
|
|
|
@ -47,15 +48,33 @@ 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 animpercent = 0, ticks;
|
|
|
|
|
static bool s_animating = false, shadows = true, debug = false, rectticks = true;
|
|
|
|
|
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);
|
|
|
|
@ -65,44 +84,58 @@ static void inbox_received_handler(DictionaryIterator *iter, void *context) {
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
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(shadows_t && shadows_t->value->int8 > 0) {
|
|
|
|
|
persist_write_bool(KEY_SHADOWS, true);
|
|
|
|
|
shadows = true;
|
|
|
|
|
} else {
|
|
|
|
|
persist_write_bool(KEY_SHADOWS, false);
|
|
|
|
|
shadows = false;
|
|
|
|
|
}
|
|
|
|
|
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(colort_t) {
|
|
|
|
|
int colort = colort_t->value->int32;
|
|
|
|
|
persist_write_int(KEY_TICK_COLOR, colort);
|
|
|
|
|
gcolort = GColorFromHEX(colort);
|
|
|
|
|
}
|
|
|
|
|
if(rectticks_t && rectticks_t->value->int8 > 0) {
|
|
|
|
|
persist_write_bool(KEY_RECT_TICKS, true);
|
|
|
|
|
rectticks = true;
|
|
|
|
@ -110,9 +143,25 @@ static void inbox_received_handler(DictionaryIterator *iter, void *context) {
|
|
|
|
|
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 **************************/
|
|
|
|
@ -145,9 +194,13 @@ static void animate(int duration, int delay, AnimationImplementation *implementa
|
|
|
|
|
static void tick_handler(struct tm *tick_time, TimeUnits changed) {
|
|
|
|
|
// Store time
|
|
|
|
|
// dummy time in emulator
|
|
|
|
|
if (watch_info_get_model()==WATCH_INFO_MODEL_UNKNOWN) {
|
|
|
|
|
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;
|
|
|
|
@ -160,6 +213,17 @@ static void tick_handler(struct tm *tick_time, TimeUnits changed) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
@ -170,56 +234,16 @@ static int32_t get_angle_for_hour(int hour, int minute) {
|
|
|
|
|
return (((hour * 360) / 12)+(get_angle_for_minute(minute)/12));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void update_proc(Layer *layer, GContext *ctx) {
|
|
|
|
|
static void bg_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_fill_color(ctx, gcolorbg);
|
|
|
|
|
graphics_fill_rect(ctx, bounds, 0, GCornerNone);
|
|
|
|
|
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_deg = get_angle_for_hour(mode_time.hours, mode_time.minutes);
|
|
|
|
|
float minute_deg = get_angle_for_minute(mode_time.minutes);
|
|
|
|
|
|
|
|
|
|
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 (ticks > 0) {
|
|
|
|
|
graphics_context_set_fill_color(ctx, gcolort);
|
|
|
|
|
#if defined(PBL_RECT)
|
|
|
|
|
if (rectticks) {
|
|
|
|
|
int dist_v = 41;
|
|
|
|
|
int dist_v = 39;
|
|
|
|
|
int dist_h = 46;
|
|
|
|
|
int halfwidth = (bounds.size.w/2)-1;
|
|
|
|
|
int halfheight = (bounds.size.h/2)-1;
|
|
|
|
@ -260,10 +284,54 @@ static void update_proc(Layer *layer, GContext *ctx) {
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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_deg = get_angle_for_hour(mode_time.hours, mode_time.minutes);
|
|
|
|
|
float minute_deg = get_angle_for_minute(mode_time.minutes);
|
|
|
|
|
|
|
|
|
|
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, HAND_WIDTH);
|
|
|
|
|
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);
|
|
|
|
@ -275,13 +343,13 @@ static void update_proc(Layer *layer, GContext *ctx) {
|
|
|
|
|
s_center.y -= SHADOW_OFFSET+1;
|
|
|
|
|
}
|
|
|
|
|
graphics_context_set_stroke_color(ctx, gcolorh);
|
|
|
|
|
graphics_context_set_stroke_width(ctx, HAND_WIDTH);
|
|
|
|
|
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, HAND_WIDTH);
|
|
|
|
|
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, DOT_RADIUS);
|
|
|
|
|
graphics_fill_circle(ctx, s_center, whwidth/4);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -292,60 +360,83 @@ static void window_load(Window *window) {
|
|
|
|
|
s_center = grect_center_point(&window_bounds);
|
|
|
|
|
s_center.x -= 1;
|
|
|
|
|
s_center.y -= 1;
|
|
|
|
|
|
|
|
|
|
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_SHADOWS)) {
|
|
|
|
|
shadows = persist_read_bool(KEY_SHADOWS);
|
|
|
|
|
} else {
|
|
|
|
|
shadows = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#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_TICK_COLOR)) {
|
|
|
|
|
int colort = persist_read_int(KEY_TICK_COLOR);
|
|
|
|
|
gcolort = GColorFromHEX(colort);
|
|
|
|
|
} else {
|
|
|
|
|
gcolort = GColorWhite;
|
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -392,7 +483,13 @@ static void init() {
|
|
|
|
|
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());
|
|
|
|
|
|
|
|
|
|