int compose_compound(F_compound *c) { c->ellipses = NULL; c->lines = NULL; c->texts = NULL; c->splines = NULL; c->arcs = NULL; c->comments = NULL; c->compounds = NULL; /* defer updating of layer buttons until we've composed the entire compound */ defer_update_layers = True; get_ellipse(&c->ellipses); get_line(&c->lines); get_spline(&c->splines); get_text(&c->texts); get_arc(&c->arcs); get_compound(&c->compounds); /* now update the layer buttons */ defer_update_layers = False; update_layers(); if (c->ellipses != NULL) return (1); if (c->splines != NULL) return (1); if (c->lines != NULL) return (1); if (c->texts != NULL) return (1); if (c->arcs != NULL) return (1); if (c->compounds != NULL) return (1); return (0); }
static void inbox_received_handler(DictionaryIterator *iter, void *context) { APP_LOG(APP_LOG_LEVEL_INFO, "Tuple read"); Tuple *invert_face_t = dict_find(iter, KEY_INVERT_FACE); Tuple *bluetooth_vibration_t = dict_find(iter, KEY_BLUETOOTH_VIBRATION); Tuple *show_date_t = dict_find(iter, KEY_SHOW_DATE); if(invert_face_t){ invert_face = invert_face_t->value->int8; persist_write_int(KEY_INVERT_FACE, invert_face); APP_LOG(APP_LOG_LEVEL_INFO, "Recevied invert info"); } if(bluetooth_vibration_t){ bluetooth_vibration = bluetooth_vibration_t->value->int8; persist_write_int(KEY_BLUETOOTH_VIBRATION, bluetooth_vibration); APP_LOG(APP_LOG_LEVEL_INFO, "Recevied bluetooth info"); } if(show_date_t){ show_date = show_date_t->value->int8; persist_write_int(KEY_SHOW_DATE, show_date); APP_LOG(APP_LOG_LEVEL_INFO, "Recevied date info"); } update_layers(); }
static void main_window_load(Window *window) { window_set_background_color(s_my_window, GColorBlack); tick_timer_service_subscribe(MINUTE_UNIT, tick_handler); bluetooth_connection_service_subscribe(bluetooth_handler); s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_LIGHT_72)); s_minute_layer = text_layer_create(GRect(15, 56, 144, 80)); text_layer_set_text(s_minute_layer, ""); text_layer_set_text_alignment(s_minute_layer, GTextAlignmentCenter); text_layer_set_font(s_minute_layer, s_time_font); text_layer_set_background_color(s_minute_layer, GColorClear); s_hour_layer = text_layer_create(GRect(-23, 19, 154, 61)); text_layer_set_font(s_hour_layer, s_time_font); text_layer_set_text(s_hour_layer, ""); text_layer_set_text_alignment(s_hour_layer, GTextAlignmentCenter); text_layer_set_background_color(s_hour_layer, GColorBlack); date_layer = text_layer_create(GRect(0, 0, 144, 20)); text_layer_set_font(date_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18)); text_layer_set_text_alignment(date_layer, GTextAlignmentCenter); text_layer_set_background_color(date_layer, GColorBlack); text_layer_set_text_color(date_layer, GColorWhite); s_line_layer = layer_create(GRect(0 , 0, 144, 168)); layer_set_update_proc(s_line_layer, s_layer_update_proc); #ifdef PBL_BW s_inv_layer = inverter_layer_create(GRect(0, 0, 144, 168)); text_layer_set_text_color(s_minute_layer , GColorWhite); text_layer_set_text_color(s_hour_layer , GColorWhite); #else text_layer_set_text_color(s_minute_layer , GColorSpringBud); text_layer_set_text_color(s_hour_layer , GColorGreen); #endif layer_add_child(window_get_root_layer(s_my_window), text_layer_get_layer(s_minute_layer)); layer_add_child(window_get_root_layer(s_my_window), text_layer_get_layer(s_hour_layer)); layer_add_child(window_get_root_layer(s_my_window), s_line_layer); layer_add_child(window_get_root_layer(s_my_window), text_layer_get_layer(date_layer)); #ifdef PBL_BW layer_add_child(window_get_root_layer(window), inverter_layer_get_layer(s_inv_layer)); #endif if(persist_exists(KEY_INVERT_FACE)){ invert_face = persist_read_int(KEY_INVERT_FACE); APP_LOG(APP_LOG_LEVEL_INFO, "Read Invert"); } if(persist_exists(KEY_BLUETOOTH_VIBRATION)){ bluetooth_vibration = persist_read_int(KEY_BLUETOOTH_VIBRATION); APP_LOG(APP_LOG_LEVEL_INFO,"Bluetooth read"); } if(persist_exists(KEY_SHOW_DATE)){ show_date = persist_read_int(KEY_SHOW_DATE); APP_LOG(APP_LOG_LEVEL_INFO, "Read Date"); } update_time(); update_layers(); struct tm *t; time_t temp; temp = time(NULL); t = localtime(&temp); tick_handler(t, MINUTE_UNIT); }
static void window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); battery_layer = layer_create(GRect(0, 0, 144, 30)); outline_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_LECO_16)); bluetooth_connection_service_subscribe(bluetooth_handler); upper_text_layer = text_layer_create(GRect(0, 36, 144, 44)); text_layer_set_font(upper_text_layer, fonts_get_system_font(FONT_KEY_LECO_42_NUMBERS)); text_layer_set_text_alignment(upper_text_layer, GTextAlignmentCenter); text_layer_set_background_color(upper_text_layer, GColorClear); outline_layer = text_layer_create(GRect(0, 36, 144, 168)); text_layer_set_font(outline_layer, outline_font); text_layer_set_text_alignment(outline_layer, GTextAlignmentCenter); text_layer_set_text_color(outline_layer, GColorWhite); text_layer_set_background_color(outline_layer, GColorClear); lower_text_layer = text_layer_create(GRect(0, 84, 144, 100)); text_layer_set_font(lower_text_layer, fonts_get_system_font(FONT_KEY_LECO_28_LIGHT_NUMBERS)); text_layer_set_text_alignment(lower_text_layer, GTextAlignmentCenter); text_layer_set_background_color(lower_text_layer, GColorClear); text_layer_set_text(lower_text_layer, ""); weekday_text = text_layer_create(GRect(0,144,144,25)); text_layer_set_text_alignment(weekday_text, GTextAlignmentCenter); text_layer_set_background_color(weekday_text, GColorClear); text_layer_set_text_color(weekday_text, GColorWhite); text_layer_set_font(weekday_text, outline_font); battery_text = text_layer_create(GRect(0,0,144,25)); text_layer_set_text_alignment(battery_text, GTextAlignmentCenter); text_layer_set_background_color(battery_text, GColorClear); text_layer_set_text_color(battery_text, GColorWhite); text_layer_set_font(battery_text, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); layer_add_child(window_layer, battery_layer); layer_add_child(window_layer, text_layer_get_layer(lower_text_layer)); layer_add_child(window_layer, text_layer_get_layer(upper_text_layer)); layer_add_child(window_layer, text_layer_get_layer(outline_layer)); layer_add_child(battery_layer, text_layer_get_layer(battery_text)); layer_add_child(window_layer, text_layer_get_layer(weekday_text)); if (persist_read_int(KEY_TOP_COLOR)) { int top_color = persist_read_int(KEY_TOP_COLOR); set_background_and_text_color(top_color); } if (persist_read_int(KEY_BOTTOM_COLOR)) { int bottom_color = persist_read_int(KEY_BOTTOM_COLOR); set_layer1_color_and_text(bottom_color); } if (persist_read_bool(KEY_TWENTY_FOUR_HOUR_FORMAT)) { twenty_four_hour_format = persist_read_bool(KEY_TWENTY_FOUR_HOUR_FORMAT); } if (persist_read_int(KEY_TOP_TEXT_COLOR)) { int top_text_color = persist_read_int(KEY_TOP_TEXT_COLOR); set_top_text_color(top_text_color); } if(persist_read_int(KEY_BOTTOM_TEXT_COLOR)) { int bottom_text_color = persist_read_int(KEY_BOTTOM_TEXT_COLOR); set_bottom_text_color(bottom_text_color); } if(persist_exists(KEY_BLUETOOTH_VIBRATION)){ bluetooth_vibration = persist_read_int(KEY_BLUETOOTH_VIBRATION); APP_LOG(APP_LOG_LEVEL_INFO,"Bluetooth read"); } if(persist_exists(KEY_SHOW_BATTERY)){ show_battery = persist_read_int(KEY_SHOW_BATTERY); } if(persist_exists(KEY_SHOW_WEEKDAY)){ show_weekday = persist_read_int(KEY_SHOW_WEEKDAY); APP_LOG(APP_LOG_LEVEL_INFO,"Weekday read"); } if(persist_exists(KEY_DATE_FORMAT)){ change_date_format = persist_read_int(KEY_DATE_FORMAT); APP_LOG(APP_LOG_LEVEL_INFO,"Date format read"); } if(persist_read_int(KEY_WEEKDAY_COLOR)) { int weekday_color = persist_read_int(KEY_WEEKDAY_COLOR); set_weekday_color(weekday_color); } if(persist_read_int(KEY_BATTERY_COLOR)) { int battery_color = persist_read_int(KEY_BATTERY_COLOR); set_battery_color(battery_color); } if(persist_read_bool(KEY_HOUR_VIBRATE)) { hour_vibrate = persist_read_bool(KEY_HOUR_VIBRATE); } update_time(); update_layers(); battery_handler(battery_state_service_peek()); }
static void inbox_received_handler(DictionaryIterator *iter, void *context) { Tuple *top_color_t = dict_find(iter, KEY_TOP_COLOR); Tuple *twenty_four_hour_format_t = dict_find(iter, KEY_TWENTY_FOUR_HOUR_FORMAT); Tuple *bottom_color_t = dict_find(iter, KEY_BOTTOM_COLOR); Tuple *top_text_color_t = dict_find(iter, KEY_TOP_TEXT_COLOR); Tuple *bottom_text_color_t = dict_find(iter, KEY_BOTTOM_TEXT_COLOR); Tuple *bluetooth_vibration_t = dict_find(iter, KEY_BLUETOOTH_VIBRATION); Tuple *show_battery_t = dict_find(iter, KEY_SHOW_BATTERY); Tuple *show_weekday_t = dict_find(iter, KEY_SHOW_WEEKDAY); Tuple *change_date_format_t = dict_find(iter, KEY_DATE_FORMAT); Tuple *weekday_color_t = dict_find(iter, KEY_WEEKDAY_COLOR); Tuple *battery_color_t = dict_find(iter, KEY_BATTERY_COLOR); Tuple *hour_vibrate_t = dict_find(iter, KEY_HOUR_VIBRATE); if (top_color_t) { int top_color = top_color_t->value->int32; persist_write_int(KEY_TOP_COLOR, top_color); set_background_and_text_color(top_color); } if (bottom_color_t) { int bottom_color = bottom_color_t->value->int32; persist_write_int(KEY_BOTTOM_COLOR, bottom_color); set_layer1_color_and_text(bottom_color); } if (twenty_four_hour_format_t) { twenty_four_hour_format = twenty_four_hour_format_t->value->int8; persist_write_int(KEY_TWENTY_FOUR_HOUR_FORMAT, twenty_four_hour_format); update_time(); } if(top_text_color_t) { int top_text = top_text_color_t->value->int32; persist_write_int(KEY_TOP_TEXT_COLOR, top_text); set_top_text_color(top_text); } if(bottom_text_color_t) { int bottom_text = bottom_text_color_t->value->int32; persist_write_int(KEY_BOTTOM_TEXT_COLOR, bottom_text); set_bottom_text_color(bottom_text); } if(bluetooth_vibration_t){ bluetooth_vibration = bluetooth_vibration_t->value->int8; persist_write_int(KEY_BLUETOOTH_VIBRATION, bluetooth_vibration); } if(show_battery_t){ show_battery = show_battery_t->value->int8; persist_write_int(KEY_SHOW_BATTERY, show_battery); } if(show_weekday_t){ show_weekday = show_weekday_t->value->int8; persist_write_int(KEY_SHOW_WEEKDAY, show_weekday); } if(change_date_format_t){ change_date_format = change_date_format_t->value->int8; persist_write_int(KEY_DATE_FORMAT, change_date_format); } if(weekday_color_t){ int weekday_color = weekday_color_t->value->int32; persist_write_int(KEY_WEEKDAY_COLOR, weekday_color); set_weekday_color(weekday_color); } if(battery_color_t){ int battery_color = battery_color_t->value->int32; persist_write_int(KEY_BATTERY_COLOR, battery_color); set_battery_color(battery_color); } if(hour_vibrate_t){ hour_vibrate = hour_vibrate_t->value->int8; persist_write_int(KEY_HOUR_VIBRATE, hour_vibrate); } update_layers(); update_time(); }