mirror of https://github.com/nealey/Twatch
Vibrate + icon if we lose the phone
This commit is contained in:
parent
7eee8dc814
commit
5ff7f42c42
12
appinfo.json
12
appinfo.json
|
@ -4,7 +4,7 @@
|
|||
""
|
||||
],
|
||||
"companyName": "dartcatcher@gmail.com",
|
||||
"longName": "Twatch",
|
||||
"longName": "Neale's Watch",
|
||||
"projectType": "native",
|
||||
"resources": {
|
||||
"media": [
|
||||
|
@ -13,16 +13,22 @@
|
|||
"file": "fonts/AveriaSerifLibre-Regular.ttf",
|
||||
"name": "FONT_48",
|
||||
"type": "font"
|
||||
},
|
||||
{
|
||||
"characterRegex": "[]",
|
||||
"file": "fonts/fontawesome-webfont.ttf",
|
||||
"name": "SYMBOLS_52",
|
||||
"type": "font"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sdkVersion": "3",
|
||||
"shortName": "Twatch",
|
||||
"shortName": "Natch",
|
||||
"targetPlatforms": [
|
||||
"aplite",
|
||||
"basalt"
|
||||
],
|
||||
"uuid": "3b2a3db6-1699-4826-8a2d-dbbc843cc28c",
|
||||
"uuid": "901f4c61-772a-4591-8fbc-2f807e3fd6ba",
|
||||
"versionLabel": "1.0",
|
||||
"watchapp": {
|
||||
"watchface": true
|
||||
|
|
Binary file not shown.
Binary file not shown.
30
src/main.c
30
src/main.c
|
@ -19,12 +19,13 @@
|
|||
|
||||
static Window *window;
|
||||
static Layer *s_simple_bg_layer, *s_date_layer, *s_hands_layer;
|
||||
static TextLayer *s_day_label, *s_mon_label;
|
||||
static TextLayer *s_bt_label, *s_day_label, *s_mon_label;
|
||||
|
||||
static GPath *s_tick_paths[NUM_CLOCK_TICKS];
|
||||
static GPath *s_minute_arrow, *s_hour_arrow;
|
||||
static char s_mon_buffer[4], s_day_buffer[6];
|
||||
|
||||
static bool bt_connected = true;
|
||||
static TextLayer *s_hour_label[4];
|
||||
static char s_hour[4][4];
|
||||
|
||||
|
@ -100,6 +101,12 @@ static void date_update_proc(Layer *layer, GContext *ctx) {
|
|||
struct tm *t = localtime(&now);
|
||||
char *b = s_day_buffer;
|
||||
|
||||
if (bt_connected) {
|
||||
text_layer_set_text(s_bt_label, "");
|
||||
} else {
|
||||
text_layer_set_text(s_bt_label, "");
|
||||
}
|
||||
|
||||
strftime(s_mon_buffer, sizeof(s_mon_buffer), "%b", t);
|
||||
text_layer_set_text(s_mon_label, s_mon_buffer);
|
||||
|
||||
|
@ -163,13 +170,20 @@ static void window_load(Window *window) {
|
|||
layer_set_update_proc(s_date_layer, date_update_proc);
|
||||
layer_add_child(window_layer, s_date_layer);
|
||||
|
||||
s_bt_label = text_layer_create(GRect(15, 90, 52, 52));
|
||||
text_layer_set_text_alignment(s_bt_label, GTextAlignmentLeft);
|
||||
text_layer_set_text(s_bt_label, "");
|
||||
text_layer_set_background_color(s_bt_label, GColorClear);
|
||||
text_layer_set_text_color(s_bt_label, FG);
|
||||
text_layer_set_font(s_bt_label, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_SYMBOLS_52)));
|
||||
layer_add_child(s_date_layer, text_layer_get_layer(s_bt_label));
|
||||
|
||||
s_mon_label = text_layer_create(GRect(114, 140, 27, 24));
|
||||
text_layer_set_text_alignment(s_mon_label, GTextAlignmentRight);
|
||||
text_layer_set_text(s_mon_label, s_day_buffer);
|
||||
text_layer_set_background_color(s_mon_label, BG);
|
||||
text_layer_set_text_color(s_mon_label, FG);
|
||||
text_layer_set_font(s_mon_label, fonts_get_system_font(FONT_KEY_GOTHIC_24));
|
||||
|
||||
layer_add_child(s_date_layer, text_layer_get_layer(s_mon_label));
|
||||
|
||||
s_day_label = text_layer_create(GRect(121, 122, 20, 24));
|
||||
|
@ -178,7 +192,6 @@ static void window_load(Window *window) {
|
|||
text_layer_set_background_color(s_day_label, GColorClear);
|
||||
text_layer_set_text_color(s_day_label, FG);
|
||||
text_layer_set_font(s_day_label, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
|
||||
|
||||
layer_add_child(s_date_layer, text_layer_get_layer(s_day_label));
|
||||
|
||||
s_hands_layer = layer_create(bounds);
|
||||
|
@ -196,6 +209,14 @@ static void window_unload(Window *window) {
|
|||
layer_destroy(s_hands_layer);
|
||||
}
|
||||
|
||||
static void bt_handler(bool connected) {
|
||||
bt_connected = connected;
|
||||
if (! connected) {
|
||||
vibes_long_pulse();
|
||||
}
|
||||
layer_mark_dirty(s_date_layer);
|
||||
}
|
||||
|
||||
static void init() {
|
||||
window = window_create();
|
||||
window_set_window_handlers(window, (WindowHandlers) {
|
||||
|
@ -221,6 +242,9 @@ static void init() {
|
|||
s_tick_paths[i] = gpath_create(&ANALOG_BG_POINTS[i]);
|
||||
}
|
||||
|
||||
bluetooth_connection_service_subscribe(bt_handler);
|
||||
bt_connected = bluetooth_connection_service_peek();
|
||||
|
||||
#ifdef SECONDS
|
||||
tick_timer_service_subscribe(SECOND_UNIT, handle_second_tick);
|
||||
#else
|
||||
|
|
Loading…
Reference in New Issue