added setting for white background

master
Alina Marquardt 2015-11-24 19:39:10 +01:00
parent 916b316963
commit acb18eff4a
3 changed files with 73 additions and 47 deletions

View File

@ -1,11 +1,12 @@
{ {
"appKeys": { "appKeys": {
"colors": 0 "colors": 0,
"inverse": 1
}, },
"capabilities": [ "capabilities": [
"configurable" "configurable"
], ],
"companyName": "lastfuture@lastfuture.de", "companyName": "lastfuture",
"longName": "Arcangle", "longName": "Arcangle",
"projectType": "native", "projectType": "native",
"resources": { "resources": {
@ -17,7 +18,7 @@
"chalk" "chalk"
], ],
"uuid": "000fd62a-3f0a-4bdd-a118-b3caa48893a0", "uuid": "000fd62a-3f0a-4bdd-a118-b3caa48893a0",
"versionLabel": "1.0", "versionLabel": "1.1",
"watchapp": { "watchapp": {
"watchface": true "watchface": true
} }

View File

@ -3,7 +3,7 @@ Pebble.addEventListener('ready', function() {
}); });
Pebble.addEventListener('showConfiguration', function() { Pebble.addEventListener('showConfiguration', function() {
var url='http://pebble.lastfuture.de/config/arcangle10/'; var url='http://pebble.lastfuture.de/config/arcangle11/';
console.log('Showing configuration page: '+url); console.log('Showing configuration page: '+url);
Pebble.openURL(url); Pebble.openURL(url);
}); });
@ -13,7 +13,8 @@ Pebble.addEventListener('webviewclosed', function(e) {
console.log('Configuration page returned: '+JSON.stringify(configData)); console.log('Configuration page returned: '+JSON.stringify(configData));
if (configData.colors) { if (configData.colors) {
Pebble.sendAppMessage({ Pebble.sendAppMessage({
colors: configData.colors colors: configData.colors,
inverse: configData.inverse === true
}, function() { }, function() {
console.log('Send successful!'); console.log('Send successful!');
}, function() { }, function() {

View File

@ -1,8 +1,10 @@
#include <pebble.h> #include <pebble.h>
#define KEY_COLORS 0 #define KEY_COLORS 0
#define KEY_INVERSE 0
#define ANTIALIASING true #define ANTIALIASING true
#define INVERSE true
#define FINAL_RADIUS 90 #define FINAL_RADIUS 90
#define HAND_WIDTH 6 #define HAND_WIDTH 6
@ -24,8 +26,8 @@ static Layer *s_canvas_layer;
static GPoint s_center; static GPoint s_center;
static Time s_last_time; static Time s_last_time;
static int s_radius = 0, colors = 1; static int colors = 1;
static bool s_animating = false, debug = false; static bool s_animating = false, debug = false, inverse = false;
static GColor gcolorbg, gcolorh, gcolort; static GColor gcolorbg, gcolorh, gcolort;
@ -54,16 +56,49 @@ static void handle_colorchange() {
default: default:
break; break;
} }
if (inverse) {
GColor tempcolor = gcolorh;
gcolorh = gcolort;
gcolort = tempcolor;
switch(colors) {
case 1: // greens
gcolorh = GColorDarkGreen;
gcolort = GColorMediumAquamarine;
break;
case 3: // blues
gcolort = GColorPictonBlue;
break;
case 2: // reds
gcolort = GColorMelon;
break;
case 4: // greys
gcolort = GColorLightGray;
break;
default:
break;
}
}
} }
static void inbox_received_handler(DictionaryIterator *iter, void *context) { static void inbox_received_handler(DictionaryIterator *iter, void *context) {
Tuple *colors_t = dict_find(iter, KEY_COLORS); Tuple *colors_t = dict_find(iter, KEY_COLORS);
Tuple *inverse_t = dict_find(iter, KEY_INVERSE);
if(colors_t) { if(colors_t) {
colors = colors_t->value->uint8; colors = colors_t->value->uint8;
persist_write_int(KEY_COLORS, colors); persist_write_int(KEY_COLORS, colors);
handle_colorchange(); handle_colorchange();
} }
if(inverse_t && inverse_t->value->int32 > 0) {
persist_write_bool(KEY_INVERSE, true);
inverse = true;
} else {
persist_write_bool(KEY_INVERSE, false);
inverse = false;
}
if(s_canvas_layer) { if(s_canvas_layer) {
layer_mark_dirty(s_canvas_layer); layer_mark_dirty(s_canvas_layer);
} }
@ -164,27 +199,22 @@ static void update_proc(Layer *layer, GContext *ctx) {
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, HAND_WIDTH);
if((s_radius - HAND_MARGIN_OUTER) > HAND_MARGIN_INNER) { graphics_draw_line(ctx, hour_hand_inner, hour_hand_outer);
if(s_radius > 2 * HAND_MARGIN_OUTER) { graphics_draw_line(ctx, minute_hand_inner, minute_hand_outer);
graphics_draw_line(ctx, hour_hand_inner, hour_hand_outer); if (minute_deg > hour_deg && minute_deg-hour_deg > 180) {
} hour_deg += 360;
if(s_radius > HAND_MARGIN_OUTER) { } else if (minute_deg < hour_deg && hour_deg-minute_deg > 180) {
graphics_draw_line(ctx, minute_hand_inner, minute_hand_outer); minute_deg += 360;
} }
if (minute_deg > hour_deg && minute_deg-hour_deg > 180) { graphics_context_set_stroke_width(ctx, HAND_WIDTH+1);
hour_deg += 360; if (minute_deg < hour_deg) {
} else if (minute_deg < hour_deg && hour_deg-minute_deg > 180) { graphics_draw_arc(ctx, bounds_m, GOvalScaleModeFitCircle,
minute_deg += 360; DEG_TO_TRIGANGLE(minute_deg),
} DEG_TO_TRIGANGLE(hour_deg));
if (minute_deg < hour_deg) { } else {
graphics_draw_arc(ctx, bounds_m, GOvalScaleModeFitCircle, graphics_draw_arc(ctx, bounds_m, GOvalScaleModeFitCircle,
DEG_TO_TRIGANGLE(minute_deg), DEG_TO_TRIGANGLE(hour_deg),
DEG_TO_TRIGANGLE(hour_deg)); DEG_TO_TRIGANGLE(minute_deg));
} else {
graphics_draw_arc(ctx, bounds_m, GOvalScaleModeFitCircle,
DEG_TO_TRIGANGLE(hour_deg),
DEG_TO_TRIGANGLE(minute_deg));
}
} }
} }
@ -193,13 +223,19 @@ static void window_load(Window *window) {
GRect window_bounds = layer_get_bounds(window_layer); GRect window_bounds = layer_get_bounds(window_layer);
s_center = grect_center_point(&window_bounds); s_center = grect_center_point(&window_bounds);
s_center.x -= 1;
s_center.y -= 1;
if (persist_exists(KEY_COLORS)) { if (persist_exists(KEY_COLORS)) {
colors = persist_read_int(KEY_COLORS); colors = persist_read_int(KEY_COLORS);
} else { } else {
colors = 1; colors = 1;
} }
if (persist_exists(KEY_INVERSE)) {
inverse = persist_read_bool(KEY_INVERSE);
} else {
inverse = false;
}
s_canvas_layer = layer_create(window_bounds); s_canvas_layer = layer_create(window_bounds);
@ -213,15 +249,6 @@ static void window_unload(Window *window) {
/*********************************** App **************************************/ /*********************************** App **************************************/
static int anim_percentage(AnimationProgress dist_normalized, int max) {
return (int)(float)(((float)dist_normalized / (float)ANIMATION_NORMALIZED_MAX) * (float)max);
}
static void radius_update(Animation *anim, AnimationProgress dist_normalized) {
s_radius = anim_percentage(dist_normalized, FINAL_RADIUS);
layer_mark_dirty(s_canvas_layer);
}
static void init() { static void init() {
srand(time(NULL)); srand(time(NULL));
@ -244,7 +271,12 @@ static void init() {
}); });
window_stack_push(s_main_window, true); window_stack_push(s_main_window, true);
gcolorbg = GColorBlack; if (inverse) {
gcolorbg = GColorWhite;
} else {
gcolorbg = GColorBlack;
}
gcolorh = GColorMediumSpringGreen; gcolorh = GColorMediumSpringGreen;
gcolort = GColorMidnightGreen; gcolort = GColorMidnightGreen;
@ -262,14 +294,6 @@ static void init() {
app_message_register_inbox_received(inbox_received_handler); app_message_register_inbox_received(inbox_received_handler);
app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum()); app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum());
// Prepare animations
AnimationImplementation radius_impl = {
.update = radius_update
};
animate(ANIMATION_DURATION, ANIMATION_DELAY, &radius_impl, false);
} }
static void deinit() { static void deinit() {