Compare commits
No commits in common. "master" and "1.2" have entirely different histories.
|
@ -1,6 +1,5 @@
|
||||||
{
|
{
|
||||||
"appKeys": {
|
"appKeys": {
|
||||||
"btvibe": 2,
|
|
||||||
"colors": 0,
|
"colors": 0,
|
||||||
"inverse": 1
|
"inverse": 1
|
||||||
},
|
},
|
||||||
|
@ -19,7 +18,7 @@
|
||||||
"chalk"
|
"chalk"
|
||||||
],
|
],
|
||||||
"uuid": "000fd62a-3f0a-4bdd-a118-b3caa48893a0",
|
"uuid": "000fd62a-3f0a-4bdd-a118-b3caa48893a0",
|
||||||
"versionLabel": "1.3",
|
"versionLabel": "1.2",
|
||||||
"watchapp": {
|
"watchapp": {
|
||||||
"watchface": true
|
"watchface": true
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ Pebble.addEventListener('ready', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
Pebble.addEventListener('showConfiguration', function() {
|
Pebble.addEventListener('showConfiguration', function() {
|
||||||
var url='http://pebble.lastfuture.de/config/arcangle13/';
|
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);
|
||||||
});
|
});
|
||||||
|
@ -14,8 +14,7 @@ Pebble.addEventListener('webviewclosed', function(e) {
|
||||||
if (configData.colors) {
|
if (configData.colors) {
|
||||||
Pebble.sendAppMessage({
|
Pebble.sendAppMessage({
|
||||||
colors: configData.colors,
|
colors: configData.colors,
|
||||||
inverse: 0+(configData.inverse === true),
|
inverse: 0+(configData.inverse === true)
|
||||||
btvibe: 0+(configData.btvibe === true)
|
|
||||||
}, function() {
|
}, function() {
|
||||||
console.log('Send successful!');
|
console.log('Send successful!');
|
||||||
}, function() {
|
}, function() {
|
||||||
|
|
83
src/main.c
83
src/main.c
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#define KEY_COLORS 0
|
#define KEY_COLORS 0
|
||||||
#define KEY_INVERSE 1
|
#define KEY_INVERSE 1
|
||||||
#define KEY_BT_VIBE 2
|
|
||||||
|
|
||||||
#define ANTIALIASING true
|
#define ANTIALIASING true
|
||||||
#define INVERSE true
|
#define INVERSE true
|
||||||
|
@ -23,12 +22,12 @@ typedef struct {
|
||||||
} Time;
|
} Time;
|
||||||
|
|
||||||
static Window *s_main_window;
|
static Window *s_main_window;
|
||||||
static Layer *bg_canvas_layer, *s_canvas_layer;
|
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 colors = 1;
|
static int colors = 1;
|
||||||
static bool s_animating = false, debug = false, inverse = false, btvibe = false;
|
static bool s_animating = false, debug = false, inverse = false;
|
||||||
|
|
||||||
static GColor gcolorbg, gcolorh, gcolort;
|
static GColor gcolorbg, gcolorh, gcolort;
|
||||||
|
|
||||||
|
@ -92,7 +91,6 @@ static void handle_colorchange() {
|
||||||
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);
|
Tuple *inverse_t = dict_find(iter, KEY_INVERSE);
|
||||||
Tuple *btvibe_t = dict_find(iter, KEY_BT_VIBE);
|
|
||||||
|
|
||||||
if(colors_t) {
|
if(colors_t) {
|
||||||
colors = colors_t->value->uint8;
|
colors = colors_t->value->uint8;
|
||||||
|
@ -105,21 +103,10 @@ static void inbox_received_handler(DictionaryIterator *iter, void *context) {
|
||||||
persist_write_bool(KEY_INVERSE, false);
|
persist_write_bool(KEY_INVERSE, false);
|
||||||
inverse = false;
|
inverse = 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;
|
|
||||||
}
|
|
||||||
handle_colorchange();
|
handle_colorchange();
|
||||||
if(bg_canvas_layer) {
|
|
||||||
layer_mark_dirty(bg_canvas_layer);
|
|
||||||
}
|
|
||||||
if(s_canvas_layer) {
|
if(s_canvas_layer) {
|
||||||
layer_mark_dirty(s_canvas_layer);
|
layer_mark_dirty(s_canvas_layer);
|
||||||
}
|
}
|
||||||
vibes_short_pulse();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************** AnimationImplementation **************************/
|
/*************************** AnimationImplementation **************************/
|
||||||
|
@ -167,17 +154,6 @@ 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) {
|
static int32_t get_angle_for_minute(int minute) {
|
||||||
// Progress through 60 minutes, out of 360 degrees
|
// Progress through 60 minutes, out of 360 degrees
|
||||||
return (minute * 360) / 60;
|
return (minute * 360) / 60;
|
||||||
|
@ -188,25 +164,6 @@ static int32_t get_angle_for_hour(int hour, int minute) {
|
||||||
return ((hour * 360) / 12)+(get_angle_for_minute(minute)/12);
|
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, gcolorbg);
|
|
||||||
graphics_fill_rect(ctx, bounds, 0, GCornerNone);
|
|
||||||
graphics_context_set_antialiased(ctx, ANTIALIASING);
|
|
||||||
graphics_context_set_stroke_color(ctx, gcolort);
|
|
||||||
graphics_context_set_stroke_width(ctx, 1);
|
|
||||||
for (int gx=0; gx<bounds.size.h; gx += GRID_SPACING) {
|
|
||||||
GPoint gxtop = (GPoint) { .x = gx, .y = 0 };
|
|
||||||
GPoint gxbot = (GPoint) { .x = gx, .y = bounds.size.h };
|
|
||||||
graphics_draw_line(ctx, gxtop, gxbot);
|
|
||||||
}
|
|
||||||
for (int gy=0; gy<bounds.size.w; gy += GRID_SPACING) {
|
|
||||||
GPoint gxtop = (GPoint) { .y = gy, .x = 0 };
|
|
||||||
GPoint gxbot = (GPoint) { .y = gy, .x = bounds.size.w };
|
|
||||||
graphics_draw_line(ctx, gxtop, gxbot);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void update_proc(Layer *layer, GContext *ctx) {
|
static void update_proc(Layer *layer, GContext *ctx) {
|
||||||
GRect bounds = layer_get_bounds(layer);
|
GRect bounds = layer_get_bounds(layer);
|
||||||
GRect bounds_mo = grect_inset(bounds, GEdgeInsets(HAND_MARGIN_OUTER));
|
GRect bounds_mo = grect_inset(bounds, GEdgeInsets(HAND_MARGIN_OUTER));
|
||||||
|
@ -214,6 +171,9 @@ static void update_proc(Layer *layer, GContext *ctx) {
|
||||||
GRect bounds_m = grect_inset(bounds, GEdgeInsets(HAND_MARGIN_MIDDLE));
|
GRect bounds_m = grect_inset(bounds, GEdgeInsets(HAND_MARGIN_MIDDLE));
|
||||||
GRect bounds_ho = grect_inset(bounds, GEdgeInsets(HAND_MARGIN_MIDDLE+1));
|
GRect bounds_ho = grect_inset(bounds, GEdgeInsets(HAND_MARGIN_MIDDLE+1));
|
||||||
GRect bounds_hi = grect_inset(bounds, GEdgeInsets(HAND_MARGIN_INNER));
|
GRect bounds_hi = grect_inset(bounds, GEdgeInsets(HAND_MARGIN_INNER));
|
||||||
|
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
|
// Use current time while animating
|
||||||
Time mode_time = s_last_time;
|
Time mode_time = s_last_time;
|
||||||
|
@ -227,6 +187,21 @@ static void update_proc(Layer *layer, GContext *ctx) {
|
||||||
GPoint hour_hand_outer = gpoint_from_polar(bounds_ho, GOvalScaleModeFitCircle, DEG_TO_TRIGANGLE(hour_deg));
|
GPoint hour_hand_outer = gpoint_from_polar(bounds_ho, GOvalScaleModeFitCircle, DEG_TO_TRIGANGLE(hour_deg));
|
||||||
GPoint hour_hand_inner = gpoint_from_polar(bounds_hi, GOvalScaleModeFitCircle, DEG_TO_TRIGANGLE(hour_deg));
|
GPoint hour_hand_inner = gpoint_from_polar(bounds_hi, GOvalScaleModeFitCircle, DEG_TO_TRIGANGLE(hour_deg));
|
||||||
|
|
||||||
|
graphics_context_set_stroke_color(ctx, gcolort);
|
||||||
|
graphics_context_set_stroke_width(ctx, 1);
|
||||||
|
for (int gx=0; gx<bounds.size.h; gx += GRID_SPACING) {
|
||||||
|
GPoint gxtop = (GPoint) { .x = gx, .y = 0 };
|
||||||
|
GPoint gxbot = (GPoint) { .x = gx, .y = bounds.size.h };
|
||||||
|
graphics_draw_line(ctx, gxtop, gxbot);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int gy=0; gy<bounds.size.w; gy += GRID_SPACING) {
|
||||||
|
GPoint gxtop = (GPoint) { .y = gy, .x = 0 };
|
||||||
|
GPoint gxbot = (GPoint) { .y = gy, .x = bounds.size.w };
|
||||||
|
graphics_draw_line(ctx, gxtop, gxbot);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
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);
|
||||||
graphics_draw_line(ctx, hour_hand_inner, hour_hand_outer);
|
graphics_draw_line(ctx, hour_hand_inner, hour_hand_outer);
|
||||||
|
@ -266,22 +241,14 @@ static void window_load(Window *window) {
|
||||||
} else {
|
} else {
|
||||||
inverse = false;
|
inverse = false;
|
||||||
}
|
}
|
||||||
if (persist_exists(KEY_BT_VIBE)) {
|
|
||||||
btvibe = persist_read_bool(KEY_BT_VIBE);
|
|
||||||
} else {
|
|
||||||
btvibe = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bg_canvas_layer = layer_create(window_bounds);
|
|
||||||
s_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_set_update_proc(s_canvas_layer, update_proc);
|
||||||
layer_add_child(window_layer, bg_canvas_layer);
|
layer_add_child(window_layer, s_canvas_layer);
|
||||||
layer_add_child(bg_canvas_layer, s_canvas_layer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void window_unload(Window *window) {
|
static void window_unload(Window *window) {
|
||||||
layer_destroy(bg_canvas_layer);
|
|
||||||
layer_destroy(s_canvas_layer);
|
layer_destroy(s_canvas_layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,12 +297,6 @@ static void init() {
|
||||||
light_enable(true);
|
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_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());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue