diff --git a/README.md b/README.md
index 154c007..93547c7 100644
--- a/README.md
+++ b/README.md
@@ -8,3 +8,15 @@ Alerts have been removed except for the falling rate-of-change alerts.
This watch face is meant for patients to use with xDrip, not for parents/carers.
All notifications/alerts are generated within xDrip (except for falling rate-of-change).
Ensure you enable notifications from xDrip in the Pebble App, and enable Third Party notifications, otherwise these will NOT come through on the pebble.
+
+
+
+
+Choose "Standard Watchface (old)" in xDrip and activate "xdrip Statusline (watch)" in your ConfigBuilder of AAPS.
+Then install this watchface manually over the existing one:
+Activate the developer option in your pebble app and have a look at the given IP adress.
+Switch to the main directory from terminal and execute:
+
+export PEBBLE_PHONE="192.168.xxx.xxx"
+
+pebble install
diff --git a/build/xDrip-pebble-master.pbw b/build/xDrip-pebble-master.pbw
new file mode 100644
index 0000000..e78c449
Binary files /dev/null and b/build/xDrip-pebble-master.pbw differ
diff --git a/build/xDrip-pebble.pbw b/build/xDrip-pebble.pbw
deleted file mode 100644
index 573f069..0000000
Binary files a/build/xDrip-pebble.pbw and /dev/null differ
diff --git a/src/xdrip.c b/src/xdrip.c
index d491b4f..6708ff5 100644
--- a/src/xdrip.c
+++ b/src/xdrip.c
@@ -16,9 +16,9 @@ TextLayer *watch_battlevel_layer = NULL;
TextLayer *time_watch_layer = NULL;
TextLayer *time_app_layer = NULL;
TextLayer *date_app_layer = NULL;
+TextLayer *appicon_layer = NULL;
BitmapLayer *icon_layer = NULL;
-BitmapLayer *appicon_layer = NULL;
GBitmap *icon_bitmap = NULL;
GBitmap *appicon_bitmap = NULL;
@@ -55,6 +55,8 @@ static uint32_t current_cgm_time = 0;
static uint32_t current_app_time = 0;
static char current_bg_delta[10];
static int converted_bgDelta = 0;
+static char insulinOnBoard[6];
+static char tempBasalRate[4];
// global BG snooze timer
static uint8_t lastAlertTime = 0;
@@ -75,7 +77,7 @@ static bool AppMsgInDropAlert = false;
static bool AppMsgOutFailAlert = false;
static bool BluetoothAlert = false;
static bool BT_timer_pop = false;
-//static bool CGMOffAlert = false;
+static bool CGMOffAlert = false;
static bool PhoneOffAlert = false;
static bool LowBatteryAlert = false;
@@ -174,7 +176,10 @@ enum CgmKey {
CGM_TAPP_KEY = 0x3, // TUPLE_INT, 4 BYTES (APP / PHONE TIME)
CGM_DLTA_KEY = 0x4, // TUPLE_CSTRING, MAX 5 BYTES (BG DELTA, -100 or -10.0)
CGM_UBAT_KEY = 0x5, // TUPLE_CSTRING, MAX 3 BYTES (UPLOADER BATTERY, 100)
- CGM_NAME_KEY = 0x6 // TUPLE_CSTRING, MAX 9 BYTES (Christine)
+ CGM_NAME_KEY = 0x6, // TUPLE_CSTRING, MAX 9 BYTES (Christine)
+ LOOP_TBR_KEY = 0xc, // Loop Data - Temp. Basal Rate
+ LOOP_IOB_KEY = 0xd // Loop Data - Insulin on Board
+
};
// TOTAL MESSAGE DATA 4x3+2+5+3+9 = 31 BYTES
// TOTAL KEY HEADER DATA (STRINGS) 4x6+2 = 26 BYTES
@@ -394,7 +399,7 @@ static void battery_handler(BatteryChargeState charge_state) {
if(charge_state.is_charging) {
#ifdef PBL_COLOR
//APP_LOG(APP_LOG_LEVEL_INFO, "COLOR DETECTED");
- text_layer_set_text_color(watch_battlevel_layer, GColorDukeBlue);
+ text_layer_set_text_color(watch_battlevel_layer, GColorBlack);
text_layer_set_background_color(watch_battlevel_layer, GColorGreen);
#else
//APP_LOG(APP_LOG_LEVEL_INFO, "BW DETECTED");
@@ -404,17 +409,17 @@ static void battery_handler(BatteryChargeState charge_state) {
} else {
#ifdef PBL_COLOR
//APP_LOG(APP_LOG_LEVEL_INFO, "COLOR DETECTED");
- if(charge_state.charge_percent > 40) {
+ if(charge_state.charge_percent > 30) {
//APP_LOG(APP_LOG_LEVEL_INFO, "BATTERY > 40");
text_layer_set_text_color(watch_battlevel_layer, GColorGreen);
- } else if (charge_state.charge_percent > 20) {
+ } else if (charge_state.charge_percent > 10) {
//APP_LOG(APP_LOG_LEVEL_INFO, "BATTERY > 20");
text_layer_set_text_color(watch_battlevel_layer, GColorYellow);
} else {
//APP_LOG(APP_LOG_LEVEL_INFO, "BATTERY <= 20");
text_layer_set_text_color(watch_battlevel_layer, GColorRed);
}
- text_layer_set_background_color(watch_battlevel_layer, GColorDukeBlue);
+ text_layer_set_background_color(watch_battlevel_layer, GColorBlack);
#else
//APP_LOG(APP_LOG_LEVEL_INFO, "BW DETECTED");
text_layer_set_text_color(watch_battlevel_layer, GColorWhite);
@@ -560,7 +565,7 @@ void handle_bluetooth_cgm(bool bt_connected) {
// erase cgm icon
//create_update_bitmap(&cgmicon_bitmap,cgmicon_layer,TIMEAGO_ICONS[NONE_TIMEAGO_ICON_INDX]);
// turn phone icon off
- create_update_bitmap(&appicon_bitmap,appicon_layer,TIMEAGO_ICONS[PHONEOFF_ICON_INDX]);
+ //create_update_bitmap(&appicon_bitmap,appicon_layer,TIMEAGO_ICONS[PHONEOFF_ICON_INDX]);
}
else {
@@ -687,12 +692,13 @@ void sync_error_callback_cgm(DictionaryResult appsync_dict_error, AppMessageResu
// erase cgm and app ago times
text_layer_set_text(cgmtime_layer, "");
text_layer_set_text(time_app_layer, "");
+ text_layer_set_text(appicon_layer, "");
// erase cgm icon
//create_update_bitmap(&cgmicon_bitmap,cgmicon_layer,TIMEAGO_ICONS[NONE_TIMEAGO_ICON_INDX]);
// turn phone icon off
- create_update_bitmap(&appicon_bitmap,appicon_layer,TIMEAGO_ICONS[PHONEOFF_ICON_INDX]);
+ //create_update_bitmap(&appicon_bitmap,appicon_layer,TIMEAGO_ICONS[PHONEOFF_ICON_INDX]);
// check if need to vibrate
if (!AppSyncErrAlert) {
@@ -764,12 +770,13 @@ void inbox_dropped_handler_cgm(AppMessageResult appmsg_indrop_error, void *conte
// erase cgm and app ago times
text_layer_set_text(cgmtime_layer, "");
text_layer_set_text(time_app_layer, "");
+ text_layer_set_text(appicon_layer, "");
// erase cgm icon
//create_update_bitmap(&cgmicon_bitmap,cgmicon_layer,TIMEAGO_ICONS[NONE_TIMEAGO_ICON_INDX]);
// turn phone icon off
- create_update_bitmap(&appicon_bitmap,appicon_layer,TIMEAGO_ICONS[PHONEOFF_ICON_INDX]);
+ //create_update_bitmap(&appicon_bitmap,appicon_layer,TIMEAGO_ICONS[PHONEOFF_ICON_INDX]);
// check if need to vibrate
if (!AppMsgInDropAlert) {
@@ -848,7 +855,7 @@ void outbox_failed_handler_cgm(DictionaryIterator *failed, AppMessageResult appm
//create_update_bitmap(&cgmicon_bitmap,cgmicon_layer,TIMEAGO_ICONS[NONE_TIMEAGO_ICON_INDX]);
// turn phone icon off
- create_update_bitmap(&appicon_bitmap,appicon_layer,TIMEAGO_ICONS[PHONEOFF_ICON_INDX]);
+ //create_update_bitmap(&appicon_bitmap,appicon_layer,TIMEAGO_ICONS[PHONEOFF_ICON_INDX]);
// check if need to vibrate
if (!AppMsgOutFailAlert) {
@@ -1363,11 +1370,12 @@ static void load_apptime(){
// check for init or error code
if (current_app_time == 0) {
text_layer_set_text(time_app_layer, "");
- create_update_bitmap(&appicon_bitmap,appicon_layer,TIMEAGO_ICONS[NONE_TIMEAGO_ICON_INDX]);
+ text_layer_set_text(appicon_layer, "");
+ //create_update_bitmap(&appicon_bitmap,appicon_layer,TIMEAGO_ICONS[NONE_TIMEAGO_ICON_INDX]);
}
else {
// set phone on icon
- create_update_bitmap(&appicon_bitmap,appicon_layer,TIMEAGO_ICONS[PHONEON_ICON_INDX]);
+ //create_update_bitmap(&appicon_bitmap,appicon_layer,TIMEAGO_ICONS[PHONEON_ICON_INDX]);
//time_now = time(NULL);
time_now = time(NULL);
@@ -1405,21 +1413,22 @@ static void load_apptime(){
strcat(formatted_app_timeago, app_label_buffer);
}
else {
- strncpy (formatted_app_timeago, "ERR", TIMEAGO_BUFFER_SIZE);
- create_update_bitmap(&appicon_bitmap,appicon_layer,TIMEAGO_ICONS[NONE_TIMEAGO_ICON_INDX]);
+ //strncpy (formatted_app_timeago, "ERR", TIMEAGO_BUFFER_SIZE);
+ ;;//create_update_bitmap(&appicon_bitmap,appicon_layer,TIMEAGO_ICONS[NONE_TIMEAGO_ICON_INDX]);
}
#if DEBUG_LEVEL > 0
APP_LOG(APP_LOG_LEVEL_DEBUG, "LOAD APPTIME, FORMATTED APP TIMEAGO STRING: %s", formatted_app_timeago);
#endif
- text_layer_set_text(time_app_layer, formatted_app_timeago);
-
+ //text_layer_set_text(time_app_layer, formatted_app_timeago);
+ text_layer_set_text(time_app_layer, tempBasalRate);
+ text_layer_set_text(appicon_layer, insulinOnBoard);
//APP_LOG(APP_LOG_LEVEL_INFO, "LOAD APPTIME, CHECK FOR PHONE OFF ICON");
// check to see if we need to set phone off icon
//APP_LOG(APP_LOG_LEVEL_DEBUG, "LOAD APPTIME, app_timeago_diff: %d, PHONEOUT_WAIT_MIN: %d, app_label_buffer: %s", app_timeago_diff, PHONEOUT_WAIT_MIN, app_label_buffer);
if ( (app_timeago_diff >= PHONEOUT_WAIT_MIN) || ( (strcmp(app_label_buffer, "") != 0) && (strcmp(app_label_buffer, "m") != 0) ) ) {
// set phone off icon
- create_update_bitmap(&appicon_bitmap,appicon_layer,TIMEAGO_ICONS[PHONEOFF_ICON_INDX]);
+ //create_update_bitmap(&appicon_bitmap,appicon_layer,TIMEAGO_ICONS[PHONEOFF_ICON_INDX]);
// erase cgm ago times and cgm icon
text_layer_set_text(cgmtime_layer, "");
@@ -1590,7 +1599,7 @@ static void load_bg_delta() {
if((currentBG_isMMOL && current_bg == 55) || (!currentBG_isMMOL && (current_bg == 100 || current_bg == 99))) {
text_layer_set_text(message_layer, "BAZINGA!");
#ifdef PBL_COLOR
- text_layer_set_text_color(message_layer, GColorDukeBlue);
+ text_layer_set_text_color(message_layer, GColorBlack);
#endif
} else {
@@ -1706,6 +1715,7 @@ void sync_tuple_changed_callback_cgm(const uint32_t key, const Tuple* new_tuple,
// CODE START
switch (key) {
+
case CGM_ICON_KEY:;
#if DEBUG_LEVEL > 0
@@ -1767,6 +1777,18 @@ void sync_tuple_changed_callback_cgm(const uint32_t key, const Tuple* new_tuple,
//APP_LOG(APP_LOG_LEVEL_INFO, "SYNC TUPLE: T1D NAME");
//text_layer_set_text(t1dname_layer, new_tuple->value->cstring);
break; // break for CGM_NAME_KEY
+
+ case LOOP_IOB_KEY:;
+ //APP_LOG(APP_LOG_LEVEL_INFO, "SYNC TUPLE: IOB CURRENT");
+ strncpy(insulinOnBoard, new_tuple->value->cstring, BG_MSGSTR_SIZE);
+ load_apptime();
+ break; // break for LOOP_IOB_KEY
+
+ case LOOP_TBR_KEY:;
+ //APP_LOG(APP_LOG_LEVEL_INFO, "SYNC TUPLE: TBR CURRENT");
+ strncpy(tempBasalRate, new_tuple->value->cstring, BG_MSGSTR_SIZE);
+ load_apptime();
+ break; // break for LOOP_TBR_KEY
} // end switch(key)
} // end sync_tuple_changed_callback_cgm()
@@ -1886,27 +1908,27 @@ void window_load_cgm(Window *window_cgm) {
// DELTA BG
#ifdef PBL_COLOR
- message_layer = text_layer_create(GRect(0, 33, 144, 50));
- text_layer_set_text_color(message_layer, GColorDukeBlue);
+ message_layer = text_layer_create(GRect(0,30, 144, 55));
+ text_layer_set_text_color(message_layer, GColorBlack);
text_layer_set_background_color(message_layer, GColorWhite);
text_layer_set_font(message_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
#else
message_layer = text_layer_create(GRect(0, 33, 144, 55));
text_layer_set_text_color(message_layer, GColorBlack);
text_layer_set_background_color(message_layer, GColorWhite);
- text_layer_set_font(message_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
+ text_layer_set_font(message_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
#endif
text_layer_set_text_alignment(message_layer, GTextAlignmentCenter);
layer_add_child(window_layer_cgm, text_layer_get_layer(message_layer));
// ARROW OR SPECIAL VALUE
- icon_layer = bitmap_layer_create(GRect(85, -7, 78, 50));
+ icon_layer = bitmap_layer_create(GRect(85, -9, 78, 50));
bitmap_layer_set_alignment(icon_layer, GAlignTopLeft);
bitmap_layer_set_background_color(icon_layer, GColorWhite);
layer_add_child(window_layer_cgm, bitmap_layer_get_layer(icon_layer));
// APP TIME AGO ICON
- #ifdef PBL_COLOR
+ /*#ifdef PBL_COLOR
appicon_layer = bitmap_layer_create(GRect(118, 63, 40, 24));
#else
appicon_layer = bitmap_layer_create(GRect(118, 63, 40, 24));
@@ -1914,25 +1936,40 @@ void window_load_cgm(Window *window_cgm) {
bitmap_layer_set_alignment(appicon_layer, GAlignLeft);
bitmap_layer_set_background_color(appicon_layer, GColorWhite);
layer_add_child(window_layer_cgm, bitmap_layer_get_layer(appicon_layer));
-
- // APP TIME AGO READING
+ */
+
+ // APP TIME AGO READING (CHANGED TO TBR FOR LOOPING)
#ifdef PBL_COLOR
- time_app_layer = text_layer_create(GRect(77, 58, 40, 24));
- text_layer_set_text_color(time_app_layer, GColorDukeBlue);
+ appicon_layer = text_layer_create(GRect(80, 54, 60, 28));
+ text_layer_set_text_color(appicon_layer, GColorBlack);
+ text_layer_set_background_color(appicon_layer, GColorWhite);
+ #else
+ appicon_layer = text_layer_create(GRect(80, 54, 60, 28));
+ text_layer_set_text_color(appicon_layer, GColorBlack);
+ text_layer_set_background_color(appicon_layer, GColorClear);
+ #endif
+ text_layer_set_font(appicon_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
+ text_layer_set_text_alignment(appicon_layer, GTextAlignmentRight);
+ layer_add_child(window_layer_cgm, text_layer_get_layer(appicon_layer));
+
+ // APP TIME AGO READING (CHANGED TO IOB FOR LOOPING)
+ #ifdef PBL_COLOR
+ time_app_layer = text_layer_create(GRect(43, 54, 60, 28));
+ text_layer_set_text_color(time_app_layer, GColorBlack);
text_layer_set_background_color(time_app_layer, GColorWhite);
#else
- time_app_layer = text_layer_create(GRect(77, 58, 40, 24));
+ time_app_layer = text_layer_create(GRect(43, 54, 60, 28));
text_layer_set_text_color(time_app_layer, GColorBlack);
text_layer_set_background_color(time_app_layer, GColorClear);
#endif
- text_layer_set_font(time_app_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
- text_layer_set_text_alignment(time_app_layer, GTextAlignmentRight);
+ text_layer_set_font(time_app_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
+ text_layer_set_text_alignment(time_app_layer, GTextAlignmentLeft);
layer_add_child(window_layer_cgm, text_layer_get_layer(time_app_layer));
// BG
#ifdef PBL_COLOR
- bg_layer = text_layer_create(GRect(0, -5, 95, 47));
- text_layer_set_text_color(bg_layer, GColorDukeBlue);
+ bg_layer = text_layer_create(GRect(0, -7, 95, 47));
+ text_layer_set_text_color(bg_layer, GColorBlack);
text_layer_set_background_color(bg_layer, GColorWhite);
#else
bg_layer = text_layer_create(GRect(0, -5, 95, 47));
@@ -1946,15 +1983,15 @@ void window_load_cgm(Window *window_cgm) {
// CGM TIME AGO READING
#ifdef PBL_COLOR
- cgmtime_layer = text_layer_create(GRect(5, 58, 40, 24));
- text_layer_set_text_color(cgmtime_layer, GColorDukeBlue);
+ cgmtime_layer = text_layer_create(GRect(5, 54, 40, 28));
+ text_layer_set_text_color(cgmtime_layer, GColorBlack);
text_layer_set_background_color(cgmtime_layer, GColorWhite);
#else
- cgmtime_layer = text_layer_create(GRect(5, 58, 40, 24));
+ cgmtime_layer = text_layer_create(GRect(5, 54, 40, 28));
text_layer_set_text_color(cgmtime_layer, GColorBlack);
text_layer_set_background_color(cgmtime_layer, GColorClear);
#endif
- text_layer_set_font(cgmtime_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
+ text_layer_set_font(cgmtime_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
text_layer_set_text_alignment(cgmtime_layer, GTextAlignmentLeft);
layer_add_child(window_layer_cgm, text_layer_get_layer(cgmtime_layer));
@@ -1962,7 +1999,7 @@ void window_load_cgm(Window *window_cgm) {
#ifdef PBL_COLOR
battlevel_layer = text_layer_create(GRect(0, 150, 80, 18));
text_layer_set_text_color(battlevel_layer, GColorGreen);
- text_layer_set_background_color(battlevel_layer, GColorDukeBlue);
+ text_layer_set_background_color(battlevel_layer, GColorBlack);
#else
battlevel_layer = text_layer_create(GRect(0, 148, 59, 18));
text_layer_set_text_color(battlevel_layer, GColorWhite);
@@ -1992,7 +2029,7 @@ void window_load_cgm(Window *window_cgm) {
#ifdef PBL_COLOR
time_watch_layer = text_layer_create(GRect(0, 82, 144, 44));
text_layer_set_text_color(time_watch_layer, GColorWhite);
- text_layer_set_background_color(time_watch_layer, GColorDukeBlue);
+ text_layer_set_background_color(time_watch_layer, GColorBlack);
#else
time_watch_layer = text_layer_create(GRect(0, 82, 144, 44));
text_layer_set_text_color(time_watch_layer, GColorWhite);
@@ -2006,9 +2043,9 @@ void window_load_cgm(Window *window_cgm) {
#ifdef PBL_COLOR
date_app_layer = text_layer_create(GRect(0, 124, 144, 26));
text_layer_set_text_color(date_app_layer, GColorWhite);
- text_layer_set_background_color(date_app_layer, GColorDukeBlue);
+ text_layer_set_background_color(date_app_layer, GColorBlack);
#else
- date_app_layer = text_layer_create(GRect(0, 120, 144, 29));
+ date_app_layer = text_layer_create(GRect(0, 120, 144, 25));
text_layer_set_text_color(date_app_layer, GColorWhite);
text_layer_set_background_color(date_app_layer, GColorClear);
#endif
@@ -2027,7 +2064,9 @@ void window_load_cgm(Window *window_cgm) {
TupletInteger(CGM_TAPP_KEY, 0),
TupletCString(CGM_DLTA_KEY, "LOAD"),
TupletCString(CGM_UBAT_KEY, " "),
- TupletCString(CGM_NAME_KEY, " ")
+ TupletCString(CGM_NAME_KEY, " "),
+ TupletCString(LOOP_IOB_KEY, " "),
+ TupletCString(LOOP_TBR_KEY, " ")
};
//APP_LOG(APP_LOG_LEVEL_INFO, "WINDOW LOAD, ABOUT TO CALL APP SYNC INIT");
@@ -2059,7 +2098,7 @@ void window_unload_cgm(Window *window_cgm) {
//APP_LOG(APP_LOG_LEVEL_INFO, "WINDOW UNLOAD, DESTROY BITMAPS IF EXIST");
destroy_null_BitmapLayer(&icon_layer);
//destroy_null_BitmapLayer(&cgmicon_layer);
- destroy_null_BitmapLayer(&appicon_layer);
+ destroy_null_TextLayer(&appicon_layer);
//destroy_null_BitmapLayer(&batticon_layer);
//APP_LOG(APP_LOG_LEVEL_INFO, "WINDOW UNLOAD, DESTROY TEXT LAYERS IF EXIST");
@@ -2072,6 +2111,8 @@ void window_unload_cgm(Window *window_cgm) {
destroy_null_TextLayer(&time_watch_layer);
destroy_null_TextLayer(&time_app_layer);
destroy_null_TextLayer(&date_app_layer);
+ destroy_null_TextLayer(&appicon_layer);
+
//APP_LOG(APP_LOG_LEVEL_INFO, "WINDOW UNLOAD, DESTROY INVERTER LAYERS IF EXIST");
//destroy_null_InverterLayer(&inv_battlevel_layer);