prepared for aplite and added hand width option

master
Alina Marquardt 2015-12-20 21:10:16 +01:00
parent 34722e9f62
commit 9d4f553f7f
3 changed files with 141 additions and 84 deletions

View File

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

View File

@ -7,9 +7,11 @@ Pebble.addEventListener('showConfiguration', function() {
if(Pebble.getActiveWatchInfo) { if(Pebble.getActiveWatchInfo) {
watch = Pebble.getActiveWatchInfo(); watch = Pebble.getActiveWatchInfo();
} }
var url='http://pebble.lastfuture.de/config/supersimple17/'; var url='http://pebble.lastfuture.de/config/supersimple18/';
if (watch.platform != "chalk") { if (watch.platform == "basalt") {
url += "?rect=true"; url += "?rect=true";
} else if (watch.platform == "aplite") {
url += "?rect=true&bw=true";
} }
console.log('Showing configuration page: '+url); console.log('Showing configuration page: '+url);
Pebble.openURL(url); Pebble.openURL(url);
@ -28,7 +30,9 @@ Pebble.addEventListener('webviewclosed', function(e) {
ticks: configData.ticks, ticks: configData.ticks,
colort: parseInt(configData.colort, 16), colort: parseInt(configData.colort, 16),
rectticks: 0+(configData.rectticks === 'true'), rectticks: 0+(configData.rectticks === 'true'),
btvibe: 0+(configData.btvibe === 'true') btvibe: 0+(configData.btvibe === 'true'),
invert: 0+(configData.invert === 'true'),
whwidth: configData.whwidth,
}, function() { }, function() {
console.log('Send successful!'); console.log('Send successful!');
}, function() { }, function() {

View File

@ -9,12 +9,12 @@
#define KEY_TICK_COLOR 6 #define KEY_TICK_COLOR 6
#define KEY_RECT_TICKS 7 #define KEY_RECT_TICKS 7
#define KEY_BT_VIBE 8 #define KEY_BT_VIBE 8
#define KEY_INVERT 9
#define KEY_HAND_WIDTH 10
#define ANTIALIASING true #define ANTIALIASING true
#define HAND_WIDTH 7
#define TICK_RADIUS 3 #define TICK_RADIUS 3
#define DOT_RADIUS HAND_WIDTH/4
#define HAND_MARGIN_M 16 #define HAND_MARGIN_M 16
#define HAND_MARGIN_H 42 #define HAND_MARGIN_H 42
#define SHADOW_OFFSET 2 #define SHADOW_OFFSET 2
@ -52,11 +52,29 @@ static Layer *bg_canvas_layer, *s_canvas_layer;
static GPoint s_center; static GPoint s_center;
static Time s_last_time; static Time s_last_time;
static int animpercent = 0, ticks; static int animpercent = 0, ticks = 0, whwidth = 7;
static bool s_animating = false, shadows = true, debug = false, rectticks = true, btvibe = false; static bool s_animating = false, shadows = true, debug = false, rectticks = true, btvibe = false, invert = false;
static GColor gcolorbg, gcolorm, gcolorh, gcolorp, gcolorshadow, gcolort; 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) { static void inbox_received_handler(DictionaryIterator *iter, void *context) {
Tuple *colorbg_t = dict_find(iter, KEY_BG_COLOR); Tuple *colorbg_t = dict_find(iter, KEY_BG_COLOR);
Tuple *colorm_t = dict_find(iter, KEY_MINUTE_COLOR); Tuple *colorm_t = dict_find(iter, KEY_MINUTE_COLOR);
@ -67,44 +85,57 @@ static void inbox_received_handler(DictionaryIterator *iter, void *context) {
Tuple *colort_t = dict_find(iter, KEY_TICK_COLOR); Tuple *colort_t = dict_find(iter, KEY_TICK_COLOR);
Tuple *rectticks_t = dict_find(iter, KEY_RECT_TICKS); Tuple *rectticks_t = dict_find(iter, KEY_RECT_TICKS);
Tuple *btvibe_t = dict_find(iter, KEY_BT_VIBE); Tuple *btvibe_t = dict_find(iter, KEY_BT_VIBE);
Tuple *invert_t = dict_find(iter, KEY_INVERT);
if(colorbg_t) { Tuple *whwidth_t = dict_find(iter, KEY_HAND_WIDTH);
int colorbg = colorbg_t->value->int32;
persist_write_int(KEY_BG_COLOR, colorbg); #if defined(PBL_COLOR)
gcolorbg = GColorFromHEX(colorbg); if(colorbg_t) {
gcolorshadow = (GColor8) shadowtable[alpha & gcolorbg.argb]; int colorbg = colorbg_t->value->int32;
} persist_write_int(KEY_BG_COLOR, colorbg);
if(colorm_t) { gcolorbg = GColorFromHEX(colorbg);
int colorm = colorm_t->value->int32; gcolorshadow = (GColor8) shadowtable[alpha & gcolorbg.argb];
persist_write_int(KEY_MINUTE_COLOR, colorm); }
gcolorm = GColorFromHEX(colorm); if(colorm_t) {
} int colorm = colorm_t->value->int32;
if(colorh_t) { persist_write_int(KEY_MINUTE_COLOR, colorm);
int colorh = colorh_t->value->int32; gcolorm = GColorFromHEX(colorm);
persist_write_int(KEY_HOUR_COLOR, colorh); }
gcolorh = GColorFromHEX(colorh); if(colorh_t) {
} int colorh = colorh_t->value->int32;
if(colorp_t) { persist_write_int(KEY_HOUR_COLOR, colorh);
int colorp = colorp_t->value->int32; gcolorh = GColorFromHEX(colorh);
persist_write_int(KEY_PEG_COLOR, colorp); }
gcolorp = GColorFromHEX(colorp); if(colorp_t) {
} int colorp = colorp_t->value->int32;
if(shadows_t && shadows_t->value->int8 > 0) { persist_write_int(KEY_PEG_COLOR, colorp);
persist_write_bool(KEY_SHADOWS, true); gcolorp = GColorFromHEX(colorp);
shadows = true; }
} else { if(colort_t) {
persist_write_bool(KEY_SHADOWS, false); int colort = colort_t->value->int32;
shadows = false; 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) { if(ticknum_t) {
ticks = ticknum_t->value->uint8; ticks = ticknum_t->value->uint8;
persist_write_int(KEY_TICKS, ticks); 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) { if(rectticks_t && rectticks_t->value->int8 > 0) {
persist_write_bool(KEY_RECT_TICKS, true); persist_write_bool(KEY_RECT_TICKS, true);
rectticks = true; rectticks = true;
@ -119,6 +150,11 @@ static void inbox_received_handler(DictionaryIterator *iter, void *context) {
persist_write_bool(KEY_BT_VIBE, false); persist_write_bool(KEY_BT_VIBE, false);
btvibe = false; btvibe = false;
} }
if(whwidth_t) {
whwidth = whwidth_t->value->uint8;
persist_write_int(KEY_HAND_WIDTH, whwidth);
}
if(bg_canvas_layer) { if(bg_canvas_layer) {
layer_mark_dirty(bg_canvas_layer); layer_mark_dirty(bg_canvas_layer);
} }
@ -291,7 +327,7 @@ static void update_proc(Layer *layer, GContext *ctx) {
if(shadows) { if(shadows) {
graphics_context_set_stroke_color(ctx, gcolorshadow); 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; hour_hand_outer.y += SHADOW_OFFSET;
s_center.y += SHADOW_OFFSET; s_center.y += SHADOW_OFFSET;
graphics_draw_line(ctx, s_center, hour_hand_outer); graphics_draw_line(ctx, s_center, hour_hand_outer);
@ -303,13 +339,13 @@ static void update_proc(Layer *layer, GContext *ctx) {
s_center.y -= SHADOW_OFFSET+1; s_center.y -= SHADOW_OFFSET+1;
} }
graphics_context_set_stroke_color(ctx, gcolorh); 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_draw_line(ctx, s_center, hour_hand_outer);
graphics_context_set_stroke_color(ctx, gcolorm); 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_draw_line(ctx, s_center, minute_hand_outer);
graphics_context_set_fill_color(ctx, gcolorp); graphics_context_set_fill_color(ctx, gcolorp);
graphics_fill_circle(ctx, s_center, DOT_RADIUS); graphics_fill_circle(ctx, s_center, whwidth/4);
} }
@ -320,48 +356,57 @@ static void window_load(Window *window) {
s_center = grect_center_point(&window_bounds); s_center = grect_center_point(&window_bounds);
s_center.x -= 1; s_center.x -= 1;
s_center.y -= 1; s_center.y -= 1;
if (persist_exists(KEY_BG_COLOR)) { #if defined(PBL_COLOR)
int colorbg = persist_read_int(KEY_BG_COLOR); if (persist_exists(KEY_BG_COLOR)) {
gcolorbg = GColorFromHEX(colorbg); int colorbg = persist_read_int(KEY_BG_COLOR);
} else { gcolorbg = GColorFromHEX(colorbg);
gcolorbg = GColorBlack; } else {
} gcolorbg = GColorBlack;
gcolorshadow = (GColor8) shadowtable[alpha & gcolorbg.argb]; }
if (persist_exists(KEY_MINUTE_COLOR)) { gcolorshadow = (GColor8) shadowtable[alpha & gcolorbg.argb];
int colorm = persist_read_int(KEY_MINUTE_COLOR); if (persist_exists(KEY_MINUTE_COLOR)) {
gcolorm = GColorFromHEX(colorm); int colorm = persist_read_int(KEY_MINUTE_COLOR);
} else { gcolorm = GColorFromHEX(colorm);
gcolorm = GColorWhite; } else {
} gcolorm = GColorWhite;
if (persist_exists(KEY_HOUR_COLOR)) { }
int colorh = persist_read_int(KEY_HOUR_COLOR); if (persist_exists(KEY_HOUR_COLOR)) {
gcolorh = GColorFromHEX(colorh); int colorh = persist_read_int(KEY_HOUR_COLOR);
} else { gcolorh = GColorFromHEX(colorh);
gcolorh = GColorRed; } else {
} gcolorh = GColorRed;
if (persist_exists(KEY_PEG_COLOR)) { }
int colorp = persist_read_int(KEY_PEG_COLOR); if (persist_exists(KEY_PEG_COLOR)) {
gcolorp = GColorFromHEX(colorp); int colorp = persist_read_int(KEY_PEG_COLOR);
} else { gcolorp = GColorFromHEX(colorp);
gcolorp = GColorDarkGray; } else {
} gcolorp = GColorDarkGray;
if (persist_exists(KEY_SHADOWS)) { }
shadows = persist_read_bool(KEY_SHADOWS); if (persist_exists(KEY_TICK_COLOR)) {
} else { int colort = persist_read_int(KEY_TICK_COLOR);
shadows = false; 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)) { if (persist_exists(KEY_TICKS)) {
ticks = persist_read_int(KEY_TICKS); ticks = persist_read_int(KEY_TICKS);
} else { } else {
ticks = 0; 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)) { if (persist_exists(KEY_RECT_TICKS)) {
rectticks = persist_read_bool(KEY_RECT_TICKS); rectticks = persist_read_bool(KEY_RECT_TICKS);
} else { } else {
@ -372,6 +417,11 @@ static void window_load(Window *window) {
} else { } else {
btvibe = false; 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); bg_canvas_layer = layer_create(window_bounds);
s_canvas_layer = layer_create(window_bounds); s_canvas_layer = layer_create(window_bounds);