void forecast_process_callback(DictionaryIterator *iterator, void *context) { Tuple *minute; for (int i = 0; i < NUM_WEDGES; i++) { minute = dict_find(iterator, i); //APP_LOG(APP_LOG_LEVEL_INFO, "value at %d: %d", i, (int)minute->value->int32); s_minutely[i] = GColorFromHEX((int)minute->value->int32); if (s_context) { fill_wedge(s_context, get_wedge(i), s_minutely[i]); } } if (s_canvas_layer) { layer_mark_dirty(s_canvas_layer); } }
static void window_load(Window *window) { application.layer = statium_watchface_layer_create(window); // Modify watchface screen if configuration previously set. if (persist_exists(PEBBLE_KEYS_MODE)) { statium_watchface_layer_set_mode(application.layer, (StatiumWatchFaceLayerMode)persist_read_int(PEBBLE_KEYS_MODE)); } #ifdef PBL_PLATFORM_BASALT if (persist_exists(PEBBLE_KEYS_BACKGROUND)) { statium_watchface_layer_set_background_color(application.layer, GColorFromHEX(persist_read_int(PEBBLE_KEYS_BACKGROUND))); } if (persist_exists(PEBBLE_KEYS_FOREGROUND)) { statium_watchface_layer_set_foreground_color(application.layer, GColorFromHEX(persist_read_int(PEBBLE_KEYS_BACKGROUND))); } #endif layer_add_child(window_get_root_layer(window), statium_watchface_layer_get_layer(application.layer)); // Initialize watch/phone communication. app_message_register_inbox_received(message_handlers); app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum()); // Check bluetooth connection. bluetooth_connection(bluetooth_connection_service_peek()); bluetooth_connection_service_subscribe(bluetooth_connection); }
static void inbox_received_callback(DictionaryIterator *iterator, void *context) { APP_LOG(APP_LOG_LEVEL_INFO, "message received"); Tuple *start_immediately = dict_find(iterator, KEY_START_IMMEDIATELY); if (start_immediately) { APP_LOG(APP_LOG_LEVEL_INFO, "remember KEY_START_IMMEDIATELY=%d", start_immediately->value->uint8); persist_write_bool(KEY_START_IMMEDIATELY, start_immediately->value->uint8); } Tuple *enable_confirmation_dialog = dict_find(iterator, KEY_ENABLE_CONFIRMATION_DIALOG); if (enable_confirmation_dialog) { APP_LOG(APP_LOG_LEVEL_INFO, "remember KEY_ENABLE_CONFIRMATION_DIALOG=%d", enable_confirmation_dialog->value->uint8); persist_write_bool(KEY_ENABLE_CONFIRMATION_DIALOG, enable_confirmation_dialog->value->uint8); dictation_session_enable_confirmation(s_dictation_session, persist_read_bool(KEY_ENABLE_CONFIRMATION_DIALOG)); } Tuple *enable_error_dialog = dict_find(iterator, KEY_ENABLE_ERROR_DIALOG); if (enable_error_dialog) { APP_LOG(APP_LOG_LEVEL_INFO, "remember KEY_ENABLE_ERROR_DIALOG=%d", enable_error_dialog->value->uint8); persist_write_bool(KEY_ENABLE_ERROR_DIALOG, enable_error_dialog->value->uint8); dictation_session_enable_error_dialogs(s_dictation_session, persist_read_bool(KEY_ENABLE_ERROR_DIALOG)); } Tuple *status = dict_find(iterator, KEY_STATUS); Tuple *text = dict_find(iterator, KEY_TEXT); if (status) { if (status->value->uint8 == 255) { // configuration was opened, disable auto exit auto_exit_enable = false; } else if (status->value->uint8 == 0) { if (text) { show_text(text->value->cstring, GColorFromHEX(0x000000), GColorFromHEX(0x00ff00)); } else { show_text("OK", GColorFromHEX(0x000000), GColorFromHEX(0x00ff00)); } } else { if (text) { show_text(text->value->cstring, GColorFromHEX(0xffffff), GColorFromHEX(0xff0000)); } else { show_text("ERROR", GColorFromHEX(0xffffff), GColorFromHEX(0xff0000)); } } timeout_timer = app_timer_register(EXIT_TIMEOUT, exit_timeout, NULL); } }
static void setColors(int color, bool invert){ GColor fgcolor = GColorWhite; GColor bgcolor = GColorBlack; GColor tmp; #ifdef PBL_COLOR fgcolor = GColorFromHEX(color); bgcolor = gcolor_legible_over(fgcolor); #endif if (invert){ tmp = bgcolor; bgcolor = fgcolor; fgcolor = tmp; } window_set_background_color(window_time, bgcolor); text_layer_set_background_color(time_layer, bgcolor); text_layer_set_text_color(time_layer, fgcolor); }
GColor get_color(int color) { #ifdef PBL_COLOR if (color == 1) { return GColorWhite; } else { return GColorFromHEX(color); } #else if (color == 0) { return GColorBlack; } else if (color == 2) { return GColorDarkGray; } else { return GColorWhite; } #endif }
static void update_time(int force) { // Get a tm structure time_t temp = time(NULL); struct tm *tick_time = localtime(&temp); // Create a long-lived buffer static char sbuffer[] = "00"; strftime(sbuffer, sizeof("00"), "%S", tick_time); // Get seconds as int int result = atoi(sbuffer); box_width = 144 * result / 60 + 2; layer_mark_dirty(s_canvas); // Did a minute pass, or was force == true? if (result <= 0 || force) { static char buffer[] = "00:00"; // Write the current hours and minutes into the buffer if (clock_is_24h_style() == true) { // Use 24 hour format strftime(buffer, sizeof("00:00"), "%H:%M", tick_time); } else { // Use 12 hour format strftime(buffer, sizeof("00:00"), "%I:%M", tick_time); } // Update date text. static char dbuffer[] = ""; strftime(dbuffer, 80, "%a. %d. %b. %Y", tick_time); text_layer_set_text(s_info_layer, dbuffer); // Set the minute texts. text_layer_set_text(s_time_layer, buffer); // Get new color theme. selected_color = rand() % MAX_COLORS; window_set_background_color(s_main_window, GColorFromHEX(background_colors[selected_color])); } }
static Line* parseLines(uint8_t* data, int* linesLen) { int len = parseArraySize(data); Line *ret = malloc(sizeof(Line) * len); *linesLen = len; for(int i = 0; i < len; i++) { int lineLen = parseArraySize(data); for(int j = 0; j < lineLen; j++) { if(j == 0) { ret[i].name = parseInt(data); } else if(j == 1) { int color = parseInt(data); ret[i].color = GColorFromHEX(color); } else if(j == 2) { ret[i].startFrom = parseInt(data); } else if(j == 3) { ret[i].stations = parseInt(data); } } } return ret; }
static void main_window_load(Window *window) { // Initialize variables. selected_color = 0; // Set background color. window_set_background_color(s_main_window, GColorFromHEX(background_colors[selected_color])); // Create background canvas. s_canvas = layer_create(GRect(0, 0, 144, 168)); // Create watch texts. s_time_layer = text_layer_create(GRect(0, 30, 144, 54)); s_info_layer = text_layer_create(GRect(10, 134, 124, 24)); // Setup watch text colors. text_layer_set_text_color(s_time_layer, GColorBlack); text_layer_set_background_color(s_time_layer, GColorClear); text_layer_set_text_color(s_info_layer, GColorBlack); text_layer_set_background_color(s_info_layer, GColorClear); // Setup font for watch. s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTICON_42)); text_layer_set_font(s_time_layer, s_time_font); text_layer_set_font(s_info_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); // Set text alignments. text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter); text_layer_set_text_alignment(s_info_layer, GTextAlignmentCenter); // Add it as a child layer to the Window's root layer layer_add_child(window_get_root_layer(window), s_canvas); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_time_layer)); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_info_layer)); // Get the current battery level battery_handler(battery_state_service_peek()); }
static void my_layer_draw(Layer *layer, GContext *ctx) { // Crea un nuevo rectangulo con los limites indicados por el "layer" GRect bounds = layer_get_bounds(layer); // Obtiene el centro del rectangulo (para indicar el inicio del segundo) GPoint center = grect_center_point(&bounds); // El tamanyo del rectangulo es la mitad del espacio de la "watchface" bounds.size.w /= 2; // Establece la segunda mitad de la ventana para el segundo rectangulo GRect bounds2 = GRect(center.x, 0, bounds.size.w, bounds.size.h); // Pinta la mitad del fondo de blanco graphics_context_set_fill_color(ctx, GColorWhite); graphics_fill_rect(ctx, bounds, 0, GCornerNone); // Pinta la otra mitad de azul graphics_context_set_fill_color(ctx, GColorFromHEX(0x007cb2)); graphics_fill_rect(ctx, bounds2 , 0, GCornerNone); }
static void set_top_text_color(int top_text_color){ GColor top_text = GColorFromHEX(top_text_color); text_layer_set_text_color(upper_text_layer, top_text); }
void set_colors(Window *window) { APP_LOG(APP_LOG_LEVEL_DEBUG, "Defining colors. %d%03d", (int)time(NULL), (int)time_ms(NULL, NULL)); base_color = persist_exists(KEY_HOURSCOLOR) ? GColorFromHEX(persist_read_int(KEY_HOURSCOLOR)) : GColorWhite; text_layer_set_text_color(hours, base_color); enable_advanced = is_advanced_colors_enabled(); APP_LOG(APP_LOG_LEVEL_DEBUG, "Advanced colors %d", enable_advanced); GColor min_color = enable_advanced ? GColorFromHEX(persist_read_int(KEY_MINCOLOR)) : base_color; GColor max_color = enable_advanced ? GColorFromHEX(persist_read_int(KEY_MAXCOLOR)) : base_color; #if defined(PBL_HEALTH) steps_color = enable_advanced ? GColorFromHEX(persist_read_int(KEY_STEPSCOLOR)) : base_color; steps_behind_color = enable_advanced ? GColorFromHEX(persist_read_int(KEY_STEPSBEHINDCOLOR)) : base_color; dist_color = enable_advanced ? GColorFromHEX(persist_read_int(KEY_DISTCOLOR)) : base_color; dist_behind_color = enable_advanced ? GColorFromHEX(persist_read_int(KEY_DISTBEHINDCOLOR)) : base_color; cal_color = enable_advanced ? GColorFromHEX(persist_read_int(KEY_CALCOLOR)) : base_color; cal_behind_color = enable_advanced ? GColorFromHEX(persist_read_int(KEY_CALBEHINDCOLOR)) : base_color; sleep_color = enable_advanced ? GColorFromHEX(persist_read_int(KEY_SLEEPCOLOR)) : base_color; sleep_behind_color = enable_advanced ? GColorFromHEX(persist_read_int(KEY_SLEEPBEHINDCOLOR)) : base_color; deep_color = enable_advanced ? GColorFromHEX(persist_read_int(KEY_DEEPCOLOR)) : base_color; deep_behind_color = enable_advanced ? GColorFromHEX(persist_read_int(KEY_DEEPBEHINDCOLOR)) : base_color; #endif text_layer_set_text_color(date, enable_advanced ? GColorFromHEX(persist_read_int(KEY_DATECOLOR)) : base_color); text_layer_set_text_color(alt_time, enable_advanced ? GColorFromHEX(persist_read_int(KEY_ALTHOURSCOLOR)) : base_color); text_layer_set_text_color(weather, enable_advanced ? GColorFromHEX(persist_read_int(KEY_WEATHERCOLOR)) : base_color); text_layer_set_text_color(temp_cur, enable_advanced ? GColorFromHEX(persist_read_int(KEY_TEMPCOLOR)) : base_color); text_layer_set_text_color(temp_min, min_color); text_layer_set_text_color(min_icon, min_color); text_layer_set_text_color(temp_max, max_color); text_layer_set_text_color(max_icon, max_color); text_layer_set_text_color(speed, enable_advanced ? GColorFromHEX(persist_read_int(KEY_WINDSPEEDCOLOR)) : base_color); text_layer_set_text_color(wind_unit, enable_advanced ? GColorFromHEX(persist_read_int(KEY_WINDSPEEDCOLOR)) : base_color); text_layer_set_text_color(direction, enable_advanced ? GColorFromHEX(persist_read_int(KEY_WINDDIRCOLOR)) : base_color); battery_color = enable_advanced ? GColorFromHEX(persist_read_int(KEY_BATTERYCOLOR)) : base_color; battery_low_color = enable_advanced ? GColorFromHEX(persist_read_int(KEY_BATTERYLOWCOLOR)) : base_color; window_set_background_color(window, persist_read_int(KEY_BGCOLOR) ? GColorFromHEX(persist_read_int(KEY_BGCOLOR)) : GColorBlack); APP_LOG(APP_LOG_LEVEL_DEBUG, "Defined colors. %d%03d", (int)time(NULL), (int)time_ms(NULL, NULL)); }
static void set_bottom_text_color(int bottom_text_color){ GColor bottom_text = GColorFromHEX(bottom_text_color); text_layer_set_text_color(lower_text_layer, bottom_text); }
static void draw_watchface(Layer *layer, GContext *ctx) { GRect bounds = layer_get_bounds(layer); uint16_t width = bounds.size.w - (2 * PADDING); uint16_t max_height = bounds.size.h - (2 * PADDING); //set the colour graphics_context_set_fill_color(ctx, COLOR_FALLBACK(GColorRed, GColorWhite)); //display the seconds graphics_fill_rect(ctx, GRect(((s_sec * width)/60) + PADDING, 84 - 10, 2, 19), 0 ,0); //display the hours //left hours------------------------------ int8_t cur_hours = s_hour % 12; if (cur_hours == 0) { cur_hours = 12; } int8_t left_hours = cur_hours; if (cur_hours > 6) { left_hours = 6; } GPathInfo HOURS_LEFT_PATH_INFO = { .num_points = 4, .points = (GPoint []) {{0,0},{(left_hours*width/12) + 2,0},{(left_hours*width/12) + 2,27},{0,27}} }; GPath *s_hours_path_left = gpath_create(&HOURS_LEFT_PATH_INFO); gpath_rotate_to(s_hours_path_left, DEG_TO_TRIGANGLE(-45)); gpath_move_to(s_hours_path_left, GPoint(3,32 + PADDING)); gpath_draw_filled(ctx, s_hours_path_left); //right hours------------------------------ int8_t right_hours = cur_hours; if (cur_hours < 6) { right_hours = 0; } else { right_hours = cur_hours - 6; } GPathInfo HOURS_RIGHT_PATH_INFO = { .num_points = 4, .points = (GPoint []) {{0,0},{(right_hours*width/12) + 2,0},{(right_hours*width/12) + 2,27},{0,27}} }; GPath *s_hours_path_right = gpath_create(&HOURS_RIGHT_PATH_INFO); gpath_rotate_to(s_hours_path_right, DEG_TO_TRIGANGLE(45)); gpath_move_to(s_hours_path_right, GPoint(width - 32 + 8, 1)); gpath_draw_filled(ctx, s_hours_path_right); //display the minutes //left minutes------------------------------ int8_t left_mins = s_min; if (s_min > 30) { left_mins = 30; } GPathInfo MINS_LEFT_PATH_INFO = { .num_points = 4, .points = (GPoint []) {{0,0},{(left_mins*width/60) + 1,0},{(left_mins*width/60) + 1, 27},{0,27}} }; GPath *s_mins_path_left = gpath_create(&MINS_LEFT_PATH_INFO); gpath_rotate_to(s_mins_path_left, DEG_TO_TRIGANGLE(45)); gpath_move_to(s_mins_path_left, GPoint(PADDING + 10, max_height - 32 - 11)); gpath_draw_filled(ctx, s_mins_path_left); //right minutes------------------------------ int8_t right_mins = s_min; if (s_min < 30) { right_mins = 0; } else { right_mins = s_min - 30; } GPathInfo MINS_RIGHT_PATH_INFO = { .num_points = 4, .points = (GPoint []) {{0,0},{(right_mins*width/60) + 1,0},{(right_mins*width/60) + 1, 27},{0,27}} }; GPath *s_mins_path_right = gpath_create(&MINS_RIGHT_PATH_INFO); gpath_rotate_to(s_mins_path_right, DEG_TO_TRIGANGLE(-45)); gpath_move_to(s_mins_path_right, GPoint(width - 32 - PADDING + 1, max_height)); gpath_draw_filled(ctx, s_mins_path_right); } static void set_background_color(int color) { GColor background_color = GColorFromHEX(color); window_set_background_color(window, background_color); } static void inbox_received_handler(DictionaryIterator *iter, void *context) { APP_LOG(APP_LOG_LEVEL_DEBUG, "inbox received handler"); Tuple *background_color_t = dict_find(iter, KEY_BACKGROUND_COLOR); if (background_color_t) { int background_color = background_color_t->value->int32; if (background_color == 0) { //quick fix so that black colour persists background_color++; } persist_write_int(KEY_BACKGROUND_COLOR, background_color); set_background_color(background_color); APP_LOG(APP_LOG_LEVEL_DEBUG, "background color: %d", background_color); } } static void window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); s_layer = layer_create(layer_get_bounds(window_get_root_layer(window))); layer_add_child(window_get_root_layer(window), s_layer); layer_set_update_proc(s_layer, draw_watchface); uint16_t width = bounds.size.w - (2 * PADDING); uint16_t max_height = bounds.size.h - (2 * PADDING); //create the ternary seconds image s_ternary_seconds_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_SECONDS_TERNARY_REFLECT); s_ternary_seconds_layer = bitmap_layer_create(GRect(PADDING, 0, width + 1, 168)); bitmap_layer_set_background_color(s_ternary_seconds_layer, GColorClear); bitmap_layer_set_bitmap(s_ternary_seconds_layer, s_ternary_seconds_bitmap); bitmap_layer_set_compositing_mode(s_ternary_seconds_layer, GCompOpSet); layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(s_ternary_seconds_layer)); //create the left hours image s_unary_hours_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_6_SINGLE_BLOCKS); s_unary_hours_layer_left = rot_bitmap_layer_create(s_unary_hours_bitmap); rot_bitmap_layer_set_corner_clip_color(s_unary_hours_layer_left, GColorClear); rot_bitmap_set_compositing_mode(s_unary_hours_layer_left, GCompOpSet); rot_bitmap_layer_set_angle(s_unary_hours_layer_left, DEG_TO_TRIGANGLE(-45)); //position the frame GRect r = layer_get_frame((Layer *) s_unary_hours_layer_left); r.origin.x = 2; layer_set_frame((Layer *) s_unary_hours_layer_left, r); layer_add_child(window_get_root_layer(window), (Layer *) s_unary_hours_layer_left); //create the right hours image s_unary_hours_layer_right = rot_bitmap_layer_create(s_unary_hours_bitmap); rot_bitmap_layer_set_corner_clip_color(s_unary_hours_layer_right, GColorClear); rot_bitmap_set_compositing_mode(s_unary_hours_layer_right, GCompOpSet); rot_bitmap_layer_set_angle(s_unary_hours_layer_right, DEG_TO_TRIGANGLE(45)); //position the frame r = layer_get_frame((Layer *) s_unary_hours_layer_right); r.origin.x = width - 32 - PADDING; layer_set_frame((Layer *) s_unary_hours_layer_right, r); layer_add_child(window_get_root_layer(window), (Layer *) s_unary_hours_layer_right); //create the left minutes image s_ternary_minutes_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_30_TERNARY); s_ternary_minutes_layer_left = rot_bitmap_layer_create(s_ternary_minutes_bitmap); rot_bitmap_layer_set_corner_clip_color(s_ternary_minutes_layer_left, GColorClear); rot_bitmap_set_compositing_mode(s_ternary_minutes_layer_left, GCompOpSet); rot_bitmap_layer_set_angle(s_ternary_minutes_layer_left, DEG_TO_TRIGANGLE(45)); //position the frame r = layer_get_frame((Layer *) s_ternary_minutes_layer_left); r.origin.x = 2; r.origin.y = max_height - 32 - PADDING; layer_set_frame((Layer *) s_ternary_minutes_layer_left, r); layer_add_child(window_get_root_layer(window), (Layer *) s_ternary_minutes_layer_left); //create the right minutes image s_ternary_minutes_layer_right = rot_bitmap_layer_create(s_ternary_minutes_bitmap); rot_bitmap_layer_set_corner_clip_color(s_ternary_minutes_layer_right, GColorClear); rot_bitmap_set_compositing_mode(s_ternary_minutes_layer_right, GCompOpSet); rot_bitmap_layer_set_angle(s_ternary_minutes_layer_right, DEG_TO_TRIGANGLE(-45)); //position the frame r = layer_get_frame((Layer *) s_ternary_minutes_layer_right); r.origin.x = width - 32 - PADDING; r.origin.y = max_height - 32 - PADDING; layer_set_frame((Layer *) s_ternary_minutes_layer_right, r); layer_add_child(window_get_root_layer(window), (Layer *) s_ternary_minutes_layer_right); if (persist_read_int(KEY_BACKGROUND_COLOR)) { set_background_color(persist_read_int(KEY_BACKGROUND_COLOR)); } } static void window_unload(Window *window) { gbitmap_destroy(s_ternary_seconds_bitmap); bitmap_layer_destroy(s_ternary_seconds_layer); gbitmap_destroy(s_unary_hours_bitmap); rot_bitmap_layer_destroy(s_unary_hours_layer_left); rot_bitmap_layer_destroy(s_unary_hours_layer_right); gbitmap_destroy(s_ternary_minutes_bitmap); rot_bitmap_layer_destroy(s_ternary_minutes_layer_left); rot_bitmap_layer_destroy(s_ternary_minutes_layer_right); }
static void set_battery_color(int battery_color_hex){ GColor battery_color_set = GColorFromHEX(battery_color_hex); text_layer_set_text_color(battery_text, battery_color_set); }
static void inbox_received_handler(DictionaryIterator *iterator, void *context) { // Store incoming information APP_LOG(APP_LOG_LEVEL_INFO, "inbox received"); static char temperature_buffer[8]; static char conditions_buffer[32]; static char weather_layer_buffer[38]; //static char location_layer_buffer[38]; //Tuple *invert_t = dict_find(iterator, KEY_INVERT); APP_LOG(APP_LOG_LEVEL_INFO, "Reading 24 hour Tuple"); Tuple *twenty_four_hour_format_t = dict_find(iterator, MESSAGE_KEY_Twenty_Four_Hour_Format); APP_LOG(APP_LOG_LEVEL_INFO, "Reading Celsius Tuple"); Tuple *celsius_t = dict_find(iterator, MESSAGE_KEY_Celsius); APP_LOG(APP_LOG_LEVEL_INFO, "Reading Background color Tuple"); Tuple *bg_color_t = dict_find(iterator, MESSAGE_KEY_BackgroundColor); if(bg_color_t) { //bg_color = GColorFromHEX(bg_color_t->value->int32); int background = bg_color_t->value->int32; persist_write_int(MESSAGE_KEY_BackgroundColor, background); } else if(!persist_exists(MESSAGE_KEY_BackgroundColor)) { persist_write_int(MESSAGE_KEY_BackgroundColor, 0xFFFFFF); } APP_LOG(APP_LOG_LEVEL_INFO, "Reading Text color Tuple"); Tuple *fg_color_t = dict_find(iterator, MESSAGE_KEY_TextColor); if(fg_color_t) { //text_color = GColorFromHEX(fg_color_t->value->int32); int textColor = fg_color_t->value->int32; persist_write_int(MESSAGE_KEY_TextColor, textColor); } else if(!persist_exists(MESSAGE_KEY_TextColor)) { persist_write_int(MESSAGE_KEY_TextColor, 0x000000); } APP_LOG(APP_LOG_LEVEL_INFO, "Reading Battery Tuple"); Tuple *battery_t = dict_find(iterator, MESSAGE_KEY_Battery); APP_LOG(APP_LOG_LEVEL_INFO, "Reading Bluetooth Tuple"); Tuple *bluetooth_t = dict_find(iterator, MESSAGE_KEY_Bluetooth); //Tuple *custom_location_t = dict_find(iterator, KEY_CUSTOM_LOCATION); APP_LOG(APP_LOG_LEVEL_INFO, "Reading Weather Fetch Tuple"); Tuple *weather_fetch_t = dict_find(iterator, MESSAGE_KEY_Weather_Fetch); APP_LOG(APP_LOG_LEVEL_INFO, "Reading Step Goal Tuple"); Tuple *step_goal_t = dict_find(iterator, MESSAGE_KEY_Step_Goal); APP_LOG(APP_LOG_LEVEL_INFO, "Reading Goal Color Tuple"); Tuple *goal_color_t = dict_find(iterator, MESSAGE_KEY_Goal_Color); GColor bg_color = GColorFromHEX(persist_read_int(MESSAGE_KEY_BackgroundColor)); window_set_background_color(s_main_window, bg_color); GColor text_color = GColorFromHEX(persist_read_int(MESSAGE_KEY_TextColor)); //text_layer_set_text_color(s_num_label, text_color); text_layer_set_text_color(s_date_layer, text_color); text_layer_set_text_color(s_weather_layer, text_color); text_layer_set_text_color(s_time_layer, text_color); if (twenty_four_hour_format_t) { persist_write_bool(MESSAGE_KEY_Twenty_Four_Hour_Format, twenty_four_hour_format_t->value->int8); update_time(); } if (celsius_t) { celsius = celsius_t->value->int8; APP_LOG(APP_LOG_LEVEL_INFO, "celsius: %d", celsius); persist_write_int(MESSAGE_KEY_Celsius, celsius); // Begin dictionary DictionaryIterator *iter; app_message_outbox_begin(&iter); // Add a key-value pair dict_write_uint8(iter, 0, 0); // Send the message! app_message_outbox_send(); } if (battery_t) { int battery_pref = battery_t->value->int8; persist_write_int(MESSAGE_KEY_Battery, battery_pref); layer_mark_dirty(s_battery_layer); } if (bluetooth_t) { int bt = bluetooth_t->value->int8; persist_write_int(MESSAGE_KEY_Bluetooth, bt); } if (weather_fetch_t) { int fetch = weather_fetch_t->value->int8; persist_write_int(MESSAGE_KEY_Weather_Fetch, fetch); } //STEP GOALS if (step_goal_t) { int step_goal = step_goal_t->value->int32; persist_write_int(MESSAGE_KEY_Step_Goal, step_goal); } if (goal_color_t) { int steps_color = goal_color_t->value->int32; persist_write_int(MESSAGE_KEY_Goal_Color, steps_color); int goal_num = persist_read_int(MESSAGE_KEY_Step_Goal); GColor goal_color = GColorFromHEX(steps_color); APP_LOG(APP_LOG_LEVEL_INFO, "Steps today: %d", (int)health_service_sum_today(HealthMetricStepCount)); APP_LOG(APP_LOG_LEVEL_INFO, "Goal Steps: %d", goal_num); if (goal_num == 0 || (int)health_service_sum_today(HealthMetricStepCount) < goal_num) { text_layer_set_text_color(s_num_label, text_color); } else { text_layer_set_text_color(s_num_label, goal_color); } } else if(!persist_exists(MESSAGE_KEY_Goal_Color)) { persist_write_int(MESSAGE_KEY_Goal_Color, 0x000000); } /* if (custom_location_t) { customLocation = custom_location_t->value->cstring; persist_write_string(KEY_CUSTOM_LOCATION, customLocation); // Begin dictionary DictionaryIterator *iter; app_message_outbox_begin(&iter); // Add a key-value pair dict_write_uint8(iter, 0, 0); // Send the message! app_message_outbox_send(); } */ APP_LOG(APP_LOG_LEVEL_INFO, "%d", celsius); // Read tuples for data Tuple *temp_tuple = dict_find(iterator, MESSAGE_KEY_KEY_TEMPERATURE); Tuple *conditions_tuple = dict_find(iterator, MESSAGE_KEY_KEY_CONDITIONS); //APP_LOG(APP_LOG_LEVEL_INFO, "initializing temp"); //temp = (int)temp_tuple->value->int32; //APP_LOG(APP_LOG_LEVEL_INFO, "temp initialized"); //if(celsius == false) { // temp = (int)(temp * 5.0/9.0 + 32); //} // If all data is available, use it if(temp_tuple && conditions_tuple && (celsius == 1)) { snprintf(temperature_buffer, sizeof(temperature_buffer), "%dº", (int)round((((float)temp_tuple->value->int32) - 32) * (5.0/9.0))); snprintf(conditions_buffer, sizeof(conditions_buffer), "%s", conditions_tuple->value->cstring); } else if(temp_tuple && conditions_tuple && (celsius == 0)) { snprintf(temperature_buffer, sizeof(temperature_buffer), "%dº", (int)(int)temp_tuple->value->int32); snprintf(conditions_buffer, sizeof(conditions_buffer), "%s", conditions_tuple->value->cstring); } // Assemble full string and display snprintf(weather_layer_buffer, sizeof(weather_layer_buffer), "%s, %s", temperature_buffer, conditions_buffer); //APP_LOG(APP_LOG_LEVEL_INFO, weather_layer_buffer); text_layer_set_text(s_weather_layer, weather_layer_buffer); }
static void update_proc(Layer *layer, GContext *ctx) { //resister wire graphics_context_set_fill_color(ctx, GColorFromHEX(mycolor[8])); graphics_fill_rect(ctx, GRect(0, 30, 144, 4), 0, 0); //resister body body_color = (clock_is_24h_style() == true) ? 0x66AAFF:0xAAAA00; graphics_context_set_fill_color(ctx, GColorFromHEX(body_color)); graphics_fill_circle(ctx, GPoint(36,32),24); graphics_fill_circle(ctx, GPoint(108,32),24); graphics_fill_rect(ctx, GRect(36, 8, 72, 50), 0, 0); //resister color bar int i = 1,j = 0,c = 0; for(c=0;c<4;c++) { sw_time = totall_time / i; if(sw_time == 0){ graphics_context_set_fill_color(ctx, GColorFromHEX(mycolor[0])); graphics_fill_rect(ctx, GRect(96 - j, 8, 15, 50), 0, 0); }else{ sw_time = sw_time % 10; graphics_context_set_fill_color(ctx, GColorFromHEX(mycolor[sw_time])); graphics_fill_rect(ctx, GRect(96 - j, 8, 15, 50), 0, 0); } i *= 10; j += 20; } //LED of display week graphics_context_set_fill_color(ctx, GColorCadetBlue); graphics_fill_rect(ctx, GRect(5, 151, 39, 7), 0, 0); graphics_fill_rect(ctx, GRect(7, 139, 35, 20), 0, 0); graphics_fill_circle(ctx, GPoint(24,139),17); graphics_context_set_fill_color(ctx, GColorFromHEX(leg_color)); graphics_fill_rect(ctx, GRect(12, 150, 4, 28), 0,0); graphics_fill_rect(ctx, GRect(16, 150, 4, 6), 0,0); graphics_fill_rect(ctx, GRect(32, 150, 4, 28), 0,0); graphics_fill_rect(ctx, GRect(28, 150, 4, 6), 0,0); //Capaciter of display month graphics_context_set_fill_color(ctx, GColorFromHEX(leg_color)); graphics_fill_rect(ctx, GRect(60, 140, 4, 28), 0,0); graphics_fill_rect(ctx, GRect(80, 140, 4, 28), 0,0); graphics_context_set_fill_color(ctx, GColorFromHEX(cap_color)); graphics_fill_rect(ctx, GRect(57, 128, 10, 30), 4,GCornersAll); graphics_fill_rect(ctx, GRect(77, 128, 10, 30), 4,GCornersAll); graphics_fill_circle(ctx, GPoint(72,139),18); //Capaciter of display date graphics_context_set_fill_color(ctx, GColorFromHEX(leg_color)); graphics_fill_rect(ctx, GRect(108, 140, 4, 28), 0,0); graphics_fill_rect(ctx, GRect(128, 140, 4, 28), 0,0); graphics_context_set_fill_color(ctx, GColorFromHEX(cap_color)); graphics_fill_rect(ctx, GRect(105, 128, 10, 30), 4,GCornersAll); graphics_fill_rect(ctx, GRect(125, 128, 10, 30), 4,GCornersAll); graphics_fill_circle(ctx, GPoint(120,139),18); //IC of temparature and weather int g = 0,a = 0; for(g=0;g<8;g++){ graphics_context_set_fill_color(ctx, GColorFromHEX(mycolor[8])); graphics_fill_rect(ctx, GRect(25 + a, 64, 4, 52), 0,0); a += 13; } graphics_context_set_fill_color(ctx, GColorDarkGray); graphics_fill_rect(ctx, GRect(12, 70, 120, 40), 0,0); graphics_context_set_fill_color(ctx, GColorWhite); graphics_fill_circle(ctx, GPoint(12,90),3); graphics_context_set_fill_color(ctx, GColorBlack); graphics_fill_circle(ctx, GPoint(18,100),2); }
void inbox_received_callback(DictionaryIterator *iterator, void *context) { // does this message contain weather information? Tuple *weatherTemp_tuple = dict_find(iterator, KEY_TEMPERATURE); Tuple *weatherConditions_tuple = dict_find(iterator, KEY_CONDITION_CODE); Tuple *weatherIsNight_tuple = dict_find(iterator, KEY_USE_NIGHT_ICON); // forecast info Tuple *weatherForecastCondition_tuple = dict_find(iterator, KEY_FORECAST_CONDITION); Tuple *weatherForecastHigh_tuple = dict_find(iterator, KEY_FORECAST_TEMP_HIGH); Tuple *weatherForecastLow_tuple = dict_find(iterator, KEY_FORECAST_TEMP_LOW); if(weatherTemp_tuple != NULL && weatherConditions_tuple != NULL && weatherIsNight_tuple != NULL) { bool isNight = (bool)weatherIsNight_tuple->value->int32; // now set the weather conditions properly Weather_weatherInfo.currentTemp = (int)weatherTemp_tuple->value->int32; Weather_weatherForecast.highTemp = (int)weatherForecastHigh_tuple->value->int32; Weather_weatherForecast.lowTemp = (int)weatherForecastLow_tuple->value->int32; Weather_setConditions(weatherConditions_tuple->value->int32, isNight, weatherForecastCondition_tuple->value->int32); Weather_saveData(); } // does this message contain new config information? Tuple *timeColor_tuple = dict_find(iterator, KEY_SETTING_COLOR_TIME); Tuple *bgColor_tuple = dict_find(iterator, KEY_SETTING_COLOR_BG); Tuple *sidebarColor_tuple = dict_find(iterator, KEY_SETTING_COLOR_SIDEBAR); Tuple *sidebarPos_tuple = dict_find(iterator, KEY_SETTING_SIDEBAR_LEFT); Tuple *sidebarTextColor_tuple = dict_find(iterator, KEY_SETTING_SIDEBAR_TEXT_COLOR); Tuple *useMetric_tuple = dict_find(iterator, KEY_SETTING_USE_METRIC); Tuple *btVibe_tuple = dict_find(iterator, KEY_SETTING_BT_VIBE); Tuple *language_tuple = dict_find(iterator, KEY_SETTING_LANGUAGE_ID); Tuple *leadingZero_tuple = dict_find(iterator, KEY_SETTING_SHOW_LEADING_ZERO); Tuple *batteryPct_tuple = dict_find(iterator, KEY_SETTING_SHOW_BATTERY_PCT); Tuple *disableWeather_tuple = dict_find(iterator, KEY_SETTING_DISABLE_WEATHER); Tuple *clockFont_tuple = dict_find(iterator, KEY_SETTING_CLOCK_FONT_ID); Tuple *hourlyVibe_tuple = dict_find(iterator, KEY_SETTING_HOURLY_VIBE); Tuple *onlyShowBatteryWhenLow_tuple = dict_find(iterator, KEY_SETTING_ONLY_SHOW_BATTERY_WHEN_LOW); Tuple *useLargeFonts_tuple = dict_find(iterator, KEY_SETTING_USE_LARGE_FONTS); Tuple *widget0Id_tuple = dict_find(iterator, KEY_WIDGET_0_ID); Tuple *widget1Id_tuple = dict_find(iterator, KEY_WIDGET_1_ID); Tuple *widget2Id_tuple = dict_find(iterator, KEY_WIDGET_2_ID); Tuple *altclockName_tuple = dict_find(iterator, KEY_SETTING_ALTCLOCK_NAME); Tuple *altclockOffset_tuple = dict_find(iterator, KEY_SETTING_ALTCLOCK_OFFSET); if(timeColor_tuple != NULL) { globalSettings.timeColor = GColorFromHEX(timeColor_tuple->value->int32); } if(bgColor_tuple != NULL) { globalSettings.timeBgColor = GColorFromHEX(bgColor_tuple->value->int32); } if(sidebarColor_tuple != NULL) { globalSettings.sidebarColor = GColorFromHEX(sidebarColor_tuple->value->int32); } if(sidebarTextColor_tuple != NULL) { // text can only be black or white, so we'll enforce that here globalSettings.sidebarTextColor = GColorFromHEX(sidebarTextColor_tuple->value->int32); } if(sidebarPos_tuple != NULL) { globalSettings.sidebarOnLeft = (bool)sidebarPos_tuple->value->int8; } if(useMetric_tuple != NULL) { globalSettings.useMetric = (bool)useMetric_tuple->value->int8; } if(btVibe_tuple != NULL) { globalSettings.btVibe = (bool)btVibe_tuple->value->int8; } if(leadingZero_tuple != NULL) { globalSettings.showLeadingZero = (bool)leadingZero_tuple->value->int8; } if(batteryPct_tuple != NULL) { globalSettings.showBatteryPct = (bool)batteryPct_tuple->value->int8; } if(onlyShowBatteryWhenLow_tuple != NULL) { globalSettings.onlyShowBatteryWhenLow = (bool)onlyShowBatteryWhenLow_tuple->value->int8; } if(disableWeather_tuple != NULL) { globalSettings.disableWeather = (bool)disableWeather_tuple->value->int8; } if(clockFont_tuple != NULL) { globalSettings.clockFontId = (bool)clockFont_tuple->value->int8; } if(useLargeFonts_tuple != NULL) { globalSettings.useLargeFonts = (bool)useLargeFonts_tuple->value->int8; } if(hourlyVibe_tuple != NULL) { globalSettings.hourlyVibe = hourlyVibe_tuple->value->int8; } if(language_tuple != NULL) { globalSettings.languageId = language_tuple->value->int8; } if(language_tuple != NULL) { globalSettings.languageId = language_tuple->value->int8; } if(widget0Id_tuple != NULL) { globalSettings.widgets[0] = widget0Id_tuple->value->int8; } if(widget1Id_tuple != NULL) { globalSettings.widgets[1] = widget1Id_tuple->value->int8; } if(widget2Id_tuple != NULL) { globalSettings.widgets[2] = widget2Id_tuple->value->int8; } if(altclockName_tuple != NULL) { strncpy(globalSettings.altclockName, altclockName_tuple->value->cstring, sizeof(globalSettings.altclockName)); } if(altclockOffset_tuple != NULL) { globalSettings.altclockOffset = altclockOffset_tuple->value->int8; } // save the new settings to persistent storage Settings_saveToStorage(); // notify the main screen, in case something changed message_processed_callback(); }
void inbox_received_callback(DictionaryIterator *iterator, void *context) { // does this message contain weather information? Tuple *weatherTemp_tuple = dict_find(iterator, KEY_TEMPERATURE); Tuple *weatherConditions_tuple = dict_find(iterator, KEY_CONDITION_CODE); Tuple *weatherIsNight_tuple = dict_find(iterator, KEY_USE_NIGHT_ICON); if(weatherTemp_tuple != NULL && weatherConditions_tuple != NULL && weatherIsNight_tuple != NULL) { bool isNight = (bool)weatherIsNight_tuple->value->int32; // now set the weather conditions properly Weather_weatherInfo.currentTemp = (int)weatherTemp_tuple->value->int32; Weather_setCondition((int)weatherConditions_tuple->value->int32, isNight); } // does this message contain new config information? Tuple *timeColor_tuple = dict_find(iterator, KEY_SETTING_COLOR_TIME); Tuple *bgColor_tuple = dict_find(iterator, KEY_SETTING_COLOR_BG); Tuple *sidebarColor_tuple = dict_find(iterator, KEY_SETTING_COLOR_SIDEBAR); Tuple *sidebarPos_tuple = dict_find(iterator, KEY_SETTING_SIDEBAR_RIGHT); Tuple *sidebarTextColor_tuple = dict_find(iterator, KEY_SETTING_SIDEBAR_TEXT_COLOR); Tuple *useMetric_tuple = dict_find(iterator, KEY_SETTING_USE_METRIC); Tuple *btVibe_tuple = dict_find(iterator, KEY_SETTING_BT_VIBE); Tuple *language_tuple = dict_find(iterator, KEY_SETTING_LANGUAGE_ID); Tuple *batteryMeter_tuple = dict_find(iterator, KEY_SETTING_SHOW_BATTERY_METER); Tuple *leadingZero_tuple = dict_find(iterator, KEY_SETTING_SHOW_LEADING_ZERO); if(timeColor_tuple != NULL) { #ifdef PBL_COLOR globalSettings.timeColor = GColorFromHEX(timeColor_tuple->value->int32); #else globalSettings.timeColor = (timeColor_tuple->value->int32 == 0) ? GColorBlack : GColorWhite; #endif } if(bgColor_tuple != NULL) { #ifdef PBL_COLOR globalSettings.timeBgColor = GColorFromHEX(bgColor_tuple->value->int32); #else globalSettings.timeBgColor = (bgColor_tuple->value->int32 == 0) ? GColorBlack : GColorWhite; #endif } if(sidebarColor_tuple != NULL) { #ifdef PBL_COLOR globalSettings.sidebarColor = GColorFromHEX(sidebarColor_tuple->value->int32); #else globalSettings.sidebarColor = (sidebarColor_tuple->value->int32 == 0) ? GColorBlack : GColorWhite; #endif } if(sidebarTextColor_tuple != NULL) { #ifdef PBL_COLOR globalSettings.sidebarTextColor = GColorFromHEX(sidebarTextColor_tuple->value->int32); #else globalSettings.sidebarTextColor = (sidebarTextColor_tuple->value->int32 == 0) ? GColorBlack : GColorWhite; #endif } if(sidebarPos_tuple != NULL) { globalSettings.sidebarOnRight = (bool)sidebarPos_tuple->value->int8; } if(useMetric_tuple != NULL) { globalSettings.useMetric = (bool)useMetric_tuple->value->int8; } if(btVibe_tuple != NULL) { globalSettings.btVibe = (bool)btVibe_tuple->value->int8; } if(batteryMeter_tuple != NULL) { globalSettings.showBatteryLevel = (bool)batteryMeter_tuple->value->int8; } if(leadingZero_tuple != NULL) { Settings_showLeadingZero = (bool)leadingZero_tuple->value->int8; } if(language_tuple != NULL) { globalSettings.languageId = language_tuple->value->int8; } // notify the main screen, in case something changed message_processed_callback(); }
static void set_weekday_color(int weekday_color_hex){ GColor weekday_color_set = GColorFromHEX(weekday_color_hex); text_layer_set_text_color(weekday_text, weekday_color_set); }
static void inbox_received_handler(DictionaryIterator *iter, void *context) { Tuple *temperature_t = dict_find(iter, KEY_TEMPERATURE); if(temperature_t) { snprintf(s_temp_buffer, 5, "%d°", temperature_t->value->int16); APP_LOG(APP_LOG_LEVEL_INFO, s_temp_buffer); } Tuple *show_numbers_t = dict_find(iter, KEY_SHOW_NUMBERS); if(show_numbers_t) { APP_LOG(APP_LOG_LEVEL_INFO, "Show numbers %d", show_numbers_t->value->uint8); b_show_numbers = show_numbers_t->value->uint8; persist_write_int(KEY_SHOW_NUMBERS, b_show_numbers); } Tuple *show_date_t = dict_find(iter, KEY_SHOW_DATE); if(show_date_t) { APP_LOG(APP_LOG_LEVEL_INFO, "Show date %d", show_date_t->value->uint8); b_show_date = show_date_t->value->uint8; persist_write_int(KEY_SHOW_DATE, show_date_t->value->uint8); } Tuple *show_temperature_t = dict_find(iter, KEY_SHOW_TEMPERATURE); if(show_temperature_t) { APP_LOG(APP_LOG_LEVEL_INFO, "Show temperature %d", show_temperature_t->value->uint8); b_show_temperature = show_temperature_t->value->uint8; persist_write_int(KEY_SHOW_TEMPERATURE, b_show_temperature); } Tuple *show_second_hand_t = dict_find(iter, KEY_SHOW_SECOND_HAND); if(show_second_hand_t) { APP_LOG(APP_LOG_LEVEL_INFO, "Show second hand %d", show_second_hand_t->value->uint8); b_show_second_hand = show_second_hand_t->value->uint8; persist_write_int(KEY_SHOW_SECOND_HAND, show_second_hand_t->value->uint8); } Tuple *color_background_t = dict_find(iter, KEY_COLOR_BACKGROUND); if(color_background_t) { APP_LOG(APP_LOG_LEVEL_INFO, "Background color %lu", color_background_t->value->int32); gcolor_background = GColorFromHEX(color_background_t->value->int32); window_set_background_color(window, gcolor_background); persist_write_int(KEY_COLOR_BACKGROUND, color_background_t->value->int32); } Tuple *color_label_t = dict_find(iter, KEY_COLOR_LABEL); if(color_label_t) { APP_LOG(APP_LOG_LEVEL_INFO, "Label color %lu", color_label_t->value->int32); gcolor_numbers = GColorFromHEX(color_label_t->value->int32); persist_write_int(KEY_COLOR_LABEL, color_label_t->value->int32); } Tuple *color_hour_marks_t = dict_find(iter, KEY_COLOR_HOUR_MARKS); if(color_hour_marks_t) { APP_LOG(APP_LOG_LEVEL_INFO, "Hour mark color %lu", color_hour_marks_t->value->int32); gcolor_hour_marks = GColorFromHEX(color_hour_marks_t->value->int32); persist_write_int(KEY_COLOR_HOUR_MARKS, color_hour_marks_t->value->int32); } Tuple *color_minute_marks_t = dict_find(iter, KEY_COLOR_MINUTE_MARKS); if(color_minute_marks_t) { APP_LOG(APP_LOG_LEVEL_INFO, "Minute mark color %lu", color_minute_marks_t->value->int32); gcolor_minute_marks = GColorFromHEX(color_minute_marks_t->value->int32); persist_write_int(KEY_COLOR_MINUTE_MARKS, color_minute_marks_t->value->int32); } Tuple *color_hour_hand_t = dict_find(iter, KEY_COLOR_HOUR_HAND); if(color_hour_hand_t) { APP_LOG(APP_LOG_LEVEL_INFO, "Hour hand color %lu", color_hour_hand_t->value->int32); gcolor_hour_hand = GColorFromHEX(color_hour_hand_t->value->int32); persist_write_int(KEY_COLOR_HOUR_HAND, color_hour_hand_t->value->int32); } Tuple *color_minute_hand_t = dict_find(iter, KEY_COLOR_MINUTE_HAND); if(color_minute_hand_t) { APP_LOG(APP_LOG_LEVEL_INFO, "Minute hand color %lu", color_minute_hand_t->value->int32); gcolor_minute_hand = GColorFromHEX(color_minute_hand_t->value->int32); persist_write_int(KEY_COLOR_MINUTE_HAND, color_minute_hand_t->value->int32); } Tuple *color_second_hand_t = dict_find(iter, KEY_COLOR_SECOND_HAND); if(color_second_hand_t) { APP_LOG(APP_LOG_LEVEL_INFO, "Second hand color %lu", color_second_hand_t->value->int32); gcolor_second_hand = GColorFromHEX(color_second_hand_t->value->int32); persist_write_int(KEY_COLOR_SECOND_HAND, color_second_hand_t->value->int32); } }
static void load_persisted_values() { // SHOW_NUMBERS if (persist_exists(KEY_SHOW_NUMBERS)) { b_show_numbers = persist_read_int(KEY_SHOW_NUMBERS); } // SHOW_SECOND_HAND if (persist_exists(KEY_SHOW_SECOND_HAND)) { b_show_second_hand = persist_read_int(KEY_SHOW_SECOND_HAND); } // SHOW_TEMPERATURE if (persist_exists(KEY_SHOW_TEMPERATURE)) { b_show_temperature = persist_read_int(KEY_SHOW_TEMPERATURE); } // SHOW_DATE if (persist_exists(KEY_SHOW_DATE)) { b_show_date = persist_read_int(KEY_SHOW_DATE); } // COLOR_BACKGROUND if (persist_exists(KEY_COLOR_BACKGROUND)) { int color_hex = persist_read_int(KEY_COLOR_BACKGROUND); gcolor_background = GColorFromHEX(color_hex); window_set_background_color(window, gcolor_background); } // COLOR_HOUR_MARKS if (persist_exists(KEY_COLOR_HOUR_MARKS)) { int color_hex = persist_read_int(KEY_COLOR_HOUR_MARKS); gcolor_hour_marks = GColorFromHEX(color_hex); } // COLOR_MINUTE_MARKS if (persist_exists(KEY_COLOR_MINUTE_MARKS)) { int color_hex = persist_read_int(KEY_COLOR_MINUTE_MARKS); gcolor_minute_marks = GColorFromHEX(color_hex); } // COLOR_LABEL if (persist_exists(KEY_COLOR_LABEL)) { int color_hex = persist_read_int(KEY_COLOR_LABEL); gcolor_numbers = GColorFromHEX(color_hex); } // COLOR_HOUR_HAND if (persist_exists(KEY_COLOR_HOUR_HAND)) { int color_hex = persist_read_int(KEY_COLOR_HOUR_HAND); gcolor_hour_hand = GColorFromHEX(color_hex); } // COLOR_MINUTE_HAND if (persist_exists(KEY_COLOR_MINUTE_HAND)) { int color_hex = persist_read_int(KEY_COLOR_MINUTE_HAND); gcolor_minute_hand = GColorFromHEX(color_hex); } // COLOR_SECOND_HAND if (persist_exists(KEY_COLOR_SECOND_HAND)) { int color_hex = persist_read_int(KEY_COLOR_SECOND_HAND); gcolor_second_hand = GColorFromHEX(color_hex); } }
static void request_timeout() { show_text("request timeout", GColorFromHEX(0xffffff), GColorFromHEX(0xff0000)); timeout_timer = app_timer_register(EXIT_TIMEOUT, exit_timeout, NULL); }
void set_bluetooth_color() { text_layer_set_text_color(bluetooth, enable_advanced && persist_exists(KEY_BLUETOOTHCOLOR) ? GColorFromHEX(persist_read_int(KEY_BLUETOOTHCOLOR)) : base_color); }
static void set_background_and_text_color(int color) { GColor background_color = GColorFromHEX(color); window_set_background_color(s_main_window, background_color); text_layer_set_text_color(s_text_layer, gcolor_legible_over(background_color)); }
void set_update_color() { text_layer_set_text_color(update, enable_advanced && persist_exists(KEY_UPDATECOLOR) ? GColorFromHEX(persist_read_int(KEY_UPDATECOLOR)) : base_color); }
static void main_window_load(Window *window) { // Get information about the Window Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); APP_LOG(APP_LOG_LEVEL_INFO, "Main window loading"); APP_LOG(APP_LOG_LEVEL_INFO, "battery time"); s_battery_layer = layer_create(GRect(PBL_IF_ROUND_ELSE(0, 20), PBL_IF_ROUND_ELSE(0, 154), PBL_IF_ROUND_ELSE(180, 104), PBL_IF_ROUND_ELSE(180, 2))); s_weather_layer = text_layer_create(GRect(0, PBL_IF_ROUND_ELSE(117, 120), bounds.size.w, 55)); s_time_layer = text_layer_create(GRect(0, PBL_IF_ROUND_ELSE(52, 46), bounds.size.w, 80)); s_date_layer = PBL_IF_BW_ELSE(text_layer_create(GRect(1, 2, bounds.size.w, 50)), text_layer_create(GRect(PBL_IF_ROUND_ELSE(42, 1), PBL_IF_ROUND_ELSE(15, 1), PBL_IF_ROUND_ELSE(97, 65), 55))); s_bt_icon_layer = PBL_IF_BW_ELSE(layer_create(GRect(60, 115, 30, 30)), layer_create(GRect(PBL_IF_ROUND_ELSE(75, 62), PBL_IF_ROUND_ELSE(135, 8), 30, 30))); int textcolor = persist_read_int(MESSAGE_KEY_TextColor); int background = persist_read_int(MESSAGE_KEY_BackgroundColor); GColor bg_color = GColorFromHEX(background); GColor text_color = GColorFromHEX(textcolor); window_set_background_color(s_main_window, bg_color); APP_LOG(APP_LOG_LEVEL_INFO, "Text Color is: %d", textcolor); APP_LOG(APP_LOG_LEVEL_INFO, "Background Color is: %d", background); // Battery Layer layer_set_update_proc(s_battery_layer, battery_update_proc); // Add Battery Layer to Window layer_add_child(window_get_root_layer(window), s_battery_layer); APP_LOG(APP_LOG_LEVEL_INFO, "reading key: celsius"); if (persist_read_bool(MESSAGE_KEY_Celsius)) { celsius = persist_read_int(MESSAGE_KEY_Celsius); } /* APP_LOG(APP_LOG_LEVEL_INFO, "reading key: customLocation"); if (persist_read_string(KEY_CUSTOM_LOCATION)) { customLocation = persist_read_string(KEY_CUSTOM_LOCATION); }*/ APP_LOG(APP_LOG_LEVEL_INFO, "weather time"); // Weather Layer text_layer_set_background_color(s_weather_layer, GColorClear); text_layer_set_text_color(s_weather_layer, text_color); //text_layer_set_text_color(s_weather_layer, GColorBlack); text_layer_set_text_alignment(s_weather_layer, GTextAlignmentCenter); PBL_IF_BW_ELSE(text_layer_set_text(s_weather_layer, ""), text_layer_set_text(s_weather_layer, "Loading...")); s_weather_font = PBL_IF_ROUND_ELSE(fonts_load_custom_font(resource_get_handle(RESOURCE_ID_SF_17)), fonts_load_custom_font(resource_get_handle(RESOURCE_ID_SF_20))); text_layer_set_font(s_weather_layer, s_weather_font); // Add Weather Layer to Window layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_weather_layer)); APP_LOG(APP_LOG_LEVEL_INFO, "time layer"); // Time Layer s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_SF_53)); text_layer_set_font(s_time_layer, s_time_font); text_layer_set_background_color(s_time_layer, GColorClear); text_layer_set_text_color(s_time_layer, text_color); APP_LOG(APP_LOG_LEVEL_INFO, "reading key: invert"); APP_LOG(APP_LOG_LEVEL_INFO, "reading key: 24h"); text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter); // Add Time Layer to Window layer_add_child(window_layer, text_layer_get_layer(s_time_layer)); APP_LOG(APP_LOG_LEVEL_INFO, "date time"); // Date Layer s_date_font = PBL_IF_BW_ELSE(fonts_load_custom_font(resource_get_handle(RESOURCE_ID_SF_20)), fonts_load_custom_font(resource_get_handle(RESOURCE_ID_SF_17))); text_layer_set_text_color(s_date_layer, text_color); //text_layer_set_text_color(s_date_layer, GColorBlack); text_layer_set_background_color(s_date_layer, GColorClear); text_layer_set_text_alignment(s_date_layer, GTextAlignmentCenter); text_layer_set_font(s_date_layer, s_date_font); APP_LOG(APP_LOG_LEVEL_INFO, "updating time"); // Add Date Layer to Window layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_date_layer)); // Create the Bluetooth icon GBitmap APP_LOG(APP_LOG_LEVEL_INFO, "Reading Bluetooth color: %d", persist_read_bool(MESSAGE_KEY_Bluetooth)); if (persist_read_int(MESSAGE_KEY_Bluetooth) == 102) { s_bt_icon_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BT_ICON); } else { s_bt_icon_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BT_ICON_BLACK); } // Create the BitmapLayer to display the GBitmap s_bt_icon_layer = PBL_IF_BW_ELSE(layer_create(GRect(60, 115, 30, 30)), layer_create(GRect(PBL_IF_ROUND_ELSE(75, 62), PBL_IF_ROUND_ELSE(135, 8), 30, 30))); layer_set_update_proc(s_bt_icon_layer, layer_update_proc); //bitmap_layer_set_bitmap(s_bt_icon_layer, s_bt_icon_bitmap); layer_add_child(window_layer, s_bt_icon_layer); APP_LOG(APP_LOG_LEVEL_INFO, "steps time"); // Steps Layer // subscribe to health events int goal_num = persist_read_int(MESSAGE_KEY_Step_Goal); int steps = persist_read_int(MESSAGE_KEY_Goal_Color); GColor steps_color = GColorFromHEX(steps); s_num_label = text_layer_create(GRect(PBL_IF_ROUND_ELSE(67, 90), PBL_IF_ROUND_ELSE(37, 1), 50, 45)); text_layer_set_background_color(s_num_label, GColorClear); text_layer_set_text_color(s_num_label, text_color); int s_step_count = (int)health_service_sum_today(HealthMetricStepCount); if (goal_num == 0 || s_step_count < goal_num) { int textcolor = persist_read_int(MESSAGE_KEY_TextColor); GColor text_color = GColorFromHEX(textcolor); text_layer_set_text_color(s_num_label, text_color); } else { text_layer_set_text_color(s_num_label, steps_color); } //text_layer_set_text_color(s_num_label, GColorBlack); text_layer_set_text_alignment(s_num_label, PBL_IF_ROUND_ELSE(GTextAlignmentCenter, GTextAlignmentRight)); text_layer_set_font(s_num_label, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_SF_17))); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_num_label)); if(health_service_events_subscribe(health_handler, NULL)) { // force initial steps display health_handler(HealthEventMovementUpdate, NULL); } else { APP_LOG(APP_LOG_LEVEL_ERROR, "Health not available!"); } // Show the correct state of the BT connection from the start bluetooth_callback(connection_service_peek_pebble_app_connection()); APP_LOG(APP_LOG_LEVEL_INFO, "Main window loaded"); update_time(); }
static void setup_blocks() { twelve = GRect(60, 16, 24, 24); one = GRect(80, 40, 24, 24); two = GRect(104, 48, 24, 24); three = GRect(112, 72, 24, 24); four = GRect(104, 96, 24, 24); five = GRect(80, 104, 24, 24); six = GRect(60, 128, 24, 24); seven = GRect(40, 104, 24, 24); eight = GRect(16, 96, 24, 24); nine = GRect(8, 72, 24, 24); ten = GRect(16, 48, 24, 24); eleven = GRect(40, 40, 24, 24); if (persist_read_int(KEY_BLOCK_ONE_COLOR)) { blockOneColor = GColorFromHEX(persist_read_int(KEY_BLOCK_ONE_COLOR)); } else { blockOneColor = GColorRed; } if (persist_read_int(KEY_BLOCK_TWO_COLOR)) { blockTwoColor = GColorFromHEX(persist_read_int(KEY_BLOCK_TWO_COLOR)); } else { blockTwoColor = GColorRed; } if (persist_read_int(KEY_BLOCK_THREE_COLOR)) { blockThreeColor = GColorFromHEX(persist_read_int(KEY_BLOCK_THREE_COLOR)); } else { blockThreeColor = GColorRed; } if (persist_read_int(KEY_BLOCK_FOUR_COLOR)) { blockFourColor = GColorFromHEX(persist_read_int(KEY_BLOCK_FOUR_COLOR)); } else { blockFourColor = GColorRed; } if (persist_read_int(KEY_BLOCK_FIVE_COLOR)) { blockFiveColor = GColorFromHEX(persist_read_int(KEY_BLOCK_FIVE_COLOR)); } else { blockFiveColor = GColorRed; } if (persist_read_int(KEY_BLOCK_SIX_COLOR)) { blockSixColor = GColorFromHEX(persist_read_int(KEY_BLOCK_SIX_COLOR)); } else { blockSixColor = GColorRed; } if (persist_read_int(KEY_BLOCK_SEVEN_COLOR)) { blockSevenColor = GColorFromHEX(persist_read_int(KEY_BLOCK_SEVEN_COLOR)); } else { blockSevenColor = GColorRed; } if (persist_read_int(KEY_BLOCK_EIGHT_COLOR)) { blockEightColor = GColorFromHEX(persist_read_int(KEY_BLOCK_EIGHT_COLOR)); } else { blockEightColor = GColorRed; } if (persist_read_int(KEY_BLOCK_NINE_COLOR)) { blockNineColor = GColorFromHEX(persist_read_int(KEY_BLOCK_NINE_COLOR)); } else { blockNineColor = GColorRed; } if (persist_read_int(KEY_BLOCK_TEN_COLOR)) { blockTenColor = GColorFromHEX(persist_read_int(KEY_BLOCK_TEN_COLOR)); } else { blockTenColor = GColorRed; } if (persist_read_int(KEY_BLOCK_ELEVEN_COLOR)) { blockElevenColor = GColorFromHEX(persist_read_int(KEY_BLOCK_ELEVEN_COLOR)); } else { blockElevenColor = GColorRed; } if (persist_read_int(KEY_BLOCK_TWELVE_COLOR)) { blockTwelveColor = GColorFromHEX(persist_read_int(KEY_BLOCK_TWELVE_COLOR)); } else { blockTwelveColor = GColorRed; } }
app_message_register_inbox_received(inbox_received_callback); app_message_register_inbox_dropped(inbox_dropped_callback); app_message_register_outbox_failed(outbox_failed_callback); app_message_register_outbox_sent(outbox_sent_callback); // open AppMessage with sensible buffer sizes app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum()); // main window s_main_window = window_create(); window_set_click_config_provider(s_main_window, click_config_provider); window_set_window_handlers(s_main_window, (WindowHandlers) { .load = window_load, .unload = window_unload, }); window_set_background_color(s_main_window, GColorFromHEX(0x000000)); window_stack_push(s_main_window, true); // dictation s_dictation_session = dictation_session_create(sizeof(s_last_text), dictation_session_callback, NULL); if (persist_exists(KEY_ENABLE_CONFIRMATION_DIALOG)) { dictation_session_enable_confirmation(s_dictation_session, persist_read_bool(KEY_ENABLE_CONFIRMATION_DIALOG)); } if (persist_exists(KEY_ENABLE_ERROR_DIALOG)) { dictation_session_enable_error_dialogs(s_dictation_session, persist_read_bool(KEY_ENABLE_ERROR_DIALOG)); } if (persist_exists(KEY_START_IMMEDIATELY) && persist_read_bool(KEY_START_IMMEDIATELY)) { dictation_session_start(s_dictation_session);
static void draw_row_callback(GContext *ctx, Layer *cell_layer, MenuIndex *idx, void *context) { GRect bounds = layer_get_bounds(cell_layer); #if defined(PBL_ROUND) // get info of pixel row in the middle of menu row GBitmap *fb = graphics_capture_frame_buffer(ctx); GPoint sc_coord = layer_convert_point_to_screen(cell_layer, GPoint(0, bounds.size.h/2)); GBitmapDataRowInfo info = gbitmap_get_data_row_info(fb, sc_coord.y); graphics_release_frame_buffer(ctx, fb); // adapt bounds for round displays bounds.origin.x = info.min_x + PADDING; bounds.size.w = info.max_x - info.min_x - PADDING; #endif GRect frame = GRect( bounds.origin.x + ICON_SIZE + 3*PADDING, 0, bounds.size.w - 2*ICON_SIZE - PADDING, bounds.size.h/2 ); // draw direction // expand frame width if countdown on the right is small if(deps_items[idx->row].countdown > 0 && deps_items[idx->row].countdown < 10) { frame.size.w += 10; } graphics_draw_text(ctx, deps_items[idx->row].direction, fonts_get_system_font(FONT_KEY_GOTHIC_14), frame, GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL); // draw time of scheduled departure plus delay frame.origin.y += 12; graphics_draw_text(ctx, deps_items[idx->row].time, fonts_get_system_font(FONT_KEY_GOTHIC_18), frame, GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL); // draw time until real time departure frame.origin.x = bounds.origin.x + bounds.size.w - ICON_SIZE - PADDING; frame.origin.y = 0; frame.size.w = ICON_SIZE; frame.size.h = ICON_SIZE; if(deps_items[idx->row].countdown == 0) { // draw icon if departure is imminent char* icon_number; if (strcmp(deps_items[idx->row].icon, "bus") == 0) { icon_number = "1"; } else if (strcmp(deps_items[idx->row].icon, "tram") == 0) { icon_number = "2"; } else if (strcmp(deps_items[idx->row].icon, "train") == 0) { icon_number = "3"; } else if (strcmp(deps_items[idx->row].icon, "boat") == 0) { icon_number = "4"; } else if (strcmp(deps_items[idx->row].icon, "funicular") == 0) { icon_number = "5"; } else if (strcmp(deps_items[idx->row].icon, "cable_car") == 0) { icon_number = "6"; } else { icon_number = ""; } frame.origin.x = bounds.origin.x + bounds.size.w - ICON_SIZE; frame.origin.y = 0; frame.size.w = ICON_SIZE+2; frame.size.h = ICON_SIZE; graphics_draw_text(ctx, icon_number, s_icons, frame, GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL); } else { static char s_buff[16]; if(deps_items[idx->row].countdown > 60) { strncpy(s_buff, ">1h", 16); } else if(deps_items[idx->row].countdown > 0) { snprintf(s_buff, sizeof(s_buff), "%d'", deps_items[idx->row].countdown); } graphics_draw_text(ctx, s_buff, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD), frame, GTextOverflowModeFill, GTextAlignmentRight, NULL); } // draw line icon with colors frame.origin.x = bounds.origin.x + PADDING; frame.origin.y = (bounds.size.h / 2) - (ICON_SIZE / 2); frame.size.w = ICON_SIZE; frame.size.h = ICON_SIZE; GColor color_bg; // correct some coloring switch(deps_items[idx->row].color_bg) { case 9090335 : color_bg = GColorSpringBud; break; case 12703135 : color_bg = GColorInchworm; break; default : color_bg = GColorFromHEX(deps_items[idx->row].color_bg); } GColor color_fg = GColorFromHEX(deps_items[idx->row].color_fg); graphics_context_set_fill_color(ctx, COLOR_FALLBACK(color_bg, GColorClear)); graphics_fill_rect(ctx, frame, 3, GCornersAll); if(!gcolor_equal(color_bg, GColorWhite) || menu_cell_layer_is_highlighted(cell_layer)) { graphics_context_set_stroke_color(ctx, COLOR_FALLBACK(GColorWhite, GColorClear)); } graphics_draw_round_rect(ctx, frame, 3); graphics_context_set_text_color(ctx, COLOR_FALLBACK(color_fg, GColorBlack)); char * name = deps_items[idx->row].name; GFont font; if(strlen(name) == 1) { frame.origin.x += 1; frame.origin.y += 3; /*font = fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD);*/ font = s_helvetic_bold; } else if(strlen(name) == 2) { // correct position if 2nd digit is "1" if (strstr(name+1, "1") != NULL) { frame.origin.x += 2; } frame.origin.y += 3; /*font = fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD);*/ font = s_helvetic_bold; /*if(strlen(name) == 1) { frame.origin.x += 1; }*/ } else if(strlen(name) == 3){ frame.origin.y += 3; font = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD); } else { frame.origin.y += 6; font = fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD); } graphics_draw_text(ctx, name, font, frame, GTextOverflowModeFill, GTextAlignmentCenter, NULL); }
static void inbox_received_handler(DictionaryIterator *iter, void *context) { APP_LOG(APP_LOG_LEVEL_DEBUG, "inbox received handler"); Tuple *background_color_t = dict_find(iter, KEY_BACKGROUND_COLOR); Tuple *one_t = dict_find(iter, KEY_BLOCK_ONE_COLOR); Tuple *two_t = dict_find(iter, KEY_BLOCK_TWO_COLOR); Tuple *three_t = dict_find(iter, KEY_BLOCK_THREE_COLOR); Tuple *four_t = dict_find(iter, KEY_BLOCK_FOUR_COLOR); Tuple *five_t = dict_find(iter, KEY_BLOCK_FIVE_COLOR); Tuple *six_t = dict_find(iter, KEY_BLOCK_SIX_COLOR); Tuple *seven_t = dict_find(iter, KEY_BLOCK_SEVEN_COLOR); Tuple *eight_t = dict_find(iter, KEY_BLOCK_EIGHT_COLOR); Tuple *nine_t = dict_find(iter, KEY_BLOCK_NINE_COLOR); Tuple *ten_t = dict_find(iter, KEY_BLOCK_TEN_COLOR); Tuple *eleven_t = dict_find(iter, KEY_BLOCK_ELEVEN_COLOR); Tuple *twelve_t = dict_find(iter, KEY_BLOCK_TWELVE_COLOR); Tuple *temp_t = dict_find(iter, KEY_TEMPERATURE); Tuple *conditions_t = dict_find(iter, KEY_CONDITIONS); Tuple *degreeOption_t = dict_find(iter, KEY_DEGREEOPTION); //Store incoming information static char temperature_buffer[8]; static char conditions_buffer[32]; static char weather_layer_buffer[42]; if (degreeOption_t) { degreeOption = degreeOption_t->value->uint32; APP_LOG(APP_LOG_LEVEL_DEBUG, "degree Option : %d", degreeOption); persist_write_int(KEY_DEGREEOPTION, degreeOption); } if (temp_t) { int kelvin = (int) temp_t->value->int32; if (degreeOption == 0) { //celsius int celsius = kelvin - 273.15; snprintf(temperature_buffer, sizeof(temperature_buffer), "%d\u00B0", (int) celsius); APP_LOG(APP_LOG_LEVEL_DEBUG, "Degree option is Celsius: %d", degreeOption); } else { //fahrenheit int fahrenheit = (kelvin - 273.15) * 1.8 + 32; snprintf(temperature_buffer, sizeof(temperature_buffer), "%d\u00B0", (int) fahrenheit); APP_LOG(APP_LOG_LEVEL_DEBUG, "Degree option is Fahrenheit: %d", degreeOption); } } if (conditions_t) { snprintf(conditions_buffer, sizeof(conditions_buffer), "%s", conditions_t->value->cstring); } if (conditions_t && temp_t) { snprintf(weather_layer_buffer, sizeof(weather_layer_buffer), "%s, %s", temperature_buffer, conditions_buffer); text_layer_set_text_color(s_weather_layer, gcolor_legible_over(background_color)); text_layer_set_text(s_weather_layer, weather_layer_buffer); } if (background_color_t) { int bc = background_color_t->value->int32; if (bc == 0) { //quick fix so that black colour persists bc++; } persist_write_int(KEY_BACKGROUND_COLOR, bc); background_color = GColorFromHEX(bc); window_set_background_color(window, background_color); APP_LOG(APP_LOG_LEVEL_DEBUG, "background color %d", bc); } if (one_t) { int c = one_t->value->int32; if (c == 0) { //quick fix so that black colour persists c++; } persist_write_int(KEY_BLOCK_ONE_COLOR, c); blockOneColor = GColorFromHEX(c); } if (two_t) { int c = two_t->value->int32; if (c == 0) { //quick fix so that black colour persists c++; } persist_write_int(KEY_BLOCK_TWO_COLOR, c); blockTwoColor = GColorFromHEX(c); } if (three_t) { int c = three_t->value->int32; if (c == 0) { //quick fix so that black colour persists c++; } persist_write_int(KEY_BLOCK_THREE_COLOR, c); blockThreeColor = GColorFromHEX(c); } if (four_t) { int c = four_t->value->int32; if (c == 0) { //quick fix so that black colour persists c++; } persist_write_int(KEY_BLOCK_FOUR_COLOR, c); blockFourColor = GColorFromHEX(c); } if (five_t) { int c = five_t->value->int32; if (c == 0) { //quick fix so that black colour persists c++; } persist_write_int(KEY_BLOCK_FIVE_COLOR, c); blockFiveColor = GColorFromHEX(c); } if (six_t) { int c = six_t->value->int32; if (c == 0) { //quick fix so that black colour persists c++; } persist_write_int(KEY_BLOCK_SIX_COLOR, c); blockSixColor = GColorFromHEX(c); } if (seven_t) { int c = seven_t->value->int32; if (c == 0) { //quick fix so that black colour persists c++; } persist_write_int(KEY_BLOCK_SEVEN_COLOR, c); blockSevenColor = GColorFromHEX(c); } if (eight_t) { int c = eight_t->value->int32; if (c == 0) { //quick fix so that black colour persists c++; } persist_write_int(KEY_BLOCK_EIGHT_COLOR, c); blockEightColor = GColorFromHEX(c); } if (nine_t) { int c = nine_t->value->int32; if (c == 0) { //quick fix so that black colour persists c++; } persist_write_int(KEY_BLOCK_NINE_COLOR, c); blockNineColor = GColorFromHEX(c); APP_LOG(APP_LOG_LEVEL_DEBUG, "nine color %d", c); } if (ten_t) { int c = ten_t->value->int32; if (c == 0) { //quick fix so that black colour persists c++; } persist_write_int(KEY_BLOCK_TEN_COLOR, c); blockTenColor = GColorFromHEX(c); APP_LOG(APP_LOG_LEVEL_DEBUG, "ten color %d", c); } if (eleven_t) { int c = eleven_t->value->int32; if (c == 0) { //quick fix so that black colour persists c++; } persist_write_int(KEY_BLOCK_ELEVEN_COLOR, c); blockElevenColor = GColorFromHEX(c); APP_LOG(APP_LOG_LEVEL_DEBUG, "eleven color %d", c); } if (twelve_t) { int c = twelve_t->value->int32; if (c == 0) { //quick fix so that black colour persists c++; } persist_write_int(KEY_BLOCK_TWELVE_COLOR, c); blockTwelveColor = GColorFromHEX(c); } time_t start_time = time(NULL); update_time(localtime(&start_time)); }