/* Times out for bt->interval seconds. */ void bt_pause(struct backoff_timer *bt) { sleep(bt->interval); bt_update(bt); }
static void bt_handler(bool connected) { // Vibrate on disconnect if (bluetoothConnected == true && connected == false) { vibes_short_pulse(); } bluetoothConnected = connected; bt_update(); }
static void inbox_received_callback(DictionaryIterator *iter, void *context) { #if PBL_SDK_3 int red, green, blue; Tuple *color_red_t, *color_green_t, *color_blue_t; // Background color? color_red_t = dict_find(iter, KEY_BGCOLOR_R); color_green_t = dict_find(iter, KEY_BGCOLOR_G); color_blue_t = dict_find(iter, KEY_BGCOLOR_B); if(color_red_t && color_green_t && color_blue_t) { // Apply the color if available red = color_red_t->value->int32; green = color_green_t->value->int32; blue = color_blue_t->value->int32; // Persist values persist_write_int(KEY_BGCOLOR_R, red); persist_write_int(KEY_BGCOLOR_G, green); persist_write_int(KEY_BGCOLOR_B, blue); GColor bg_color = GColorFromRGB(red, green, blue); window_set_background_color(s_main_window, bg_color); } // Time color? color_red_t = dict_find(iter, KEY_TIME_COLOR_R); color_green_t = dict_find(iter, KEY_TIME_COLOR_G); color_blue_t = dict_find(iter, KEY_TIME_COLOR_B); if(color_red_t && color_green_t && color_blue_t) { // Apply the color if available red = color_red_t->value->int32; green = color_green_t->value->int32; blue = color_blue_t->value->int32; // Persist values persist_write_int(KEY_TIME_COLOR_R, red); persist_write_int(KEY_TIME_COLOR_G, green); persist_write_int(KEY_TIME_COLOR_B, blue); GColor time_color = GColorFromRGB(red, green, blue); text_layer_set_text_color(s_time_layer, time_color); } // Secondary color? color_red_t = dict_find(iter, KEY_SECONDARY_COLOR_R); color_green_t = dict_find(iter, KEY_SECONDARY_COLOR_G); color_blue_t = dict_find(iter, KEY_SECONDARY_COLOR_B); if(color_red_t && color_green_t && color_blue_t) { // Apply the color if available red = color_red_t->value->int32; green = color_green_t->value->int32; blue = color_blue_t->value->int32; // Persist values persist_write_int(KEY_SECONDARY_COLOR_R, red); persist_write_int(KEY_SECONDARY_COLOR_G, green); persist_write_int(KEY_SECONDARY_COLOR_B, blue); secondary_color = GColorFromRGB(red, green, blue); text_layer_set_text_color(s_date_layer, secondary_color); text_layer_set_text_color(s_day_layer, secondary_color); text_layer_set_text_color(s_ampm_layer, secondary_color); } #endif // Get bluetooth enabled Tuple *bluetooth_icon_enabled_t; bluetooth_icon_enabled_t = dict_find(iter, KEY_BLUETOOTH_ICON_ENABLED); if (bluetooth_icon_enabled_t) { int enabled = bluetooth_icon_enabled_t->value->uint8; bluetoothIconEnabled = enabled != 0; bt_update(); persist_write_int(KEY_BLUETOOTH_ICON_ENABLED, enabled); } }