void load_holomesh(int craft_index) { g_current_craft = craft_index; #ifdef OVERDRAW_TEST int resource_id = RESOURCE_ID_HOLO_TIEFTR; #else int resource_id = c_craft_info[craft_index].resource_id; #endif ResHandle handle = resource_get_handle(resource_id); #ifdef PROFILE max_time = 0; min_time = 10000; total_time = 0; samples = 0; #endif // Allocate space for the resource // TODO: estimate this better if (g_holomesh == NULL) { g_holomesh = (holomesh_t*) malloc(MAX_MEMORY_SIZE); ASSERT(g_holomesh != NULL); } // Load it size_t size = resource_size(handle); size_t copied = resource_load(handle, (uint8_t*) g_holomesh, size); ASSERT(copied == g_holomesh->file_size); ASSERT(size >= g_holomesh->file_size); // Deserialize it holomesh_result hr = holomesh_deserialize(g_holomesh, size); ASSERT(hr == hmresult_ok); // Allocate renderer resources size_t scratch_size = g_holomesh->scratch_size; scratch_set(((uint8_t*)g_holomesh) + size, scratch_size); // Init the renderer render_init(); // Load the logo load_background_image(g_holomesh->info.affiliation); APP_LOG(APP_LOG_LEVEL_DEBUG, "HOLOMESH: %u bytes [0x%x-0x%x], %u mesh, %u scratch, %u hulls", (unsigned) MAX_MEMORY_SIZE, (unsigned) g_holomesh, (unsigned) g_holomesh + (unsigned) MAX_MEMORY_SIZE, (unsigned) size, (unsigned) scratch_size, (unsigned) g_holomesh->hulls.size); ASSERT(g_holomesh->hulls.size <= MAX_HULLS); }
static void window_load(Window *window) { Layer *window_layer = window_get_root_layer(s_window); GRect bounds = layer_get_bounds(window_layer); // Load Mondaine background image s_background_layer = bitmap_layer_create(GRect(0, 0, 144, 168)); load_background_image(); layer_add_child(window_layer, bitmap_layer_get_layer(s_background_layer)); // Initalize date layer time_t now = time(NULL); struct tm *t = localtime(&now); static char date[3]; strftime(date, 3, "%d", t); s_res_gothic_18_bold = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD); s_textlayer_date = text_layer_create(GRect(102, 72, 22, 20)); #ifdef PBL_COLOR if (strcmp(configs.dialcolor, "white") == 0 || strcmp(configs.dialcolor, "white_nl") == 0) { text_layer_set_text_color(s_textlayer_date, GColorDarkGray); } else if (strcmp(configs.dialcolor, "black") == 0 || strcmp(configs.dialcolor, "black_nl") == 0) { text_layer_set_text_color(s_textlayer_date, GColorWhite); }; #else if (strcmp(configs.dialcolor, "white") == 0 || strcmp(configs.dialcolor, "white_nl") == 0) { text_layer_set_text_color(s_textlayer_date, GColorBlack); } else if (strcmp(configs.dialcolor, "black") == 0 || strcmp(configs.dialcolor, "black_nl") == 0) { text_layer_set_text_color(s_textlayer_date, GColorWhite); } #endif text_layer_set_background_color(s_textlayer_date, GColorClear); text_layer_set_text(s_textlayer_date, date); text_layer_set_text_alignment(s_textlayer_date, GTextAlignmentCenter); text_layer_set_font(s_textlayer_date, s_res_gothic_18_bold); layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_date); if (strcmp(configs.dateoption, "nodate") == 0) { layer_set_hidden((Layer *)s_textlayer_date, true); } // Initalize hands layer s_hands_layer = layer_create(bounds); layer_set_update_proc(s_hands_layer, hands_update_proc); layer_add_child(window_layer, s_hands_layer); }
static void s_sync_tuple_changed_callback(const uint32_t key, const Tuple* new_tuple, const Tuple* old_tuple, void* context) { //APP_LOG(APP_LOG_LEVEL_DEBUG, "sync_tuple_changed_callback, key: %lu", key); //APP_LOG(APP_LOG_LEVEL_DEBUG, "sync_tuple_changed_callback, new_tuple->value->cstring: %s", new_tuple->value->cstring); switch (key) { case DialColor_KEY: strcpy(configs.dialcolor, new_tuple->value->cstring); load_background_image(); break; case SecondHandOption_KEY: strcpy(configs.secondhandoption, new_tuple->value->cstring); if (strcmp(configs.secondhandoption, "quartz") == 0) { tick_timer_service_unsubscribe(); tick_timer_service_subscribe(SECOND_UNIT, handle_tick); } else if (strcmp(configs.secondhandoption, "stop2go") == 0) { tick_timer_service_unsubscribe(); tick_timer_service_subscribe(SECOND_UNIT, handle_tick); } else if (strcmp(configs.secondhandoption, "off") == 0) { tick_timer_service_unsubscribe(); tick_timer_service_subscribe(MINUTE_UNIT, handle_tick); } break; case DateOption_KEY: strcpy(configs.dateoption, new_tuple->value->cstring); break; case HourlyVibration_KEY: strcpy(configs.hourlyvibration, new_tuple->value->cstring); break; case BluetoothStatusDetection_KEY: configs.bluetoothstatusdetection = new_tuple->value->uint8; break; } time_t now = time(NULL); struct tm *t = localtime(&now); handle_tick(t, HOUR_UNIT + MINUTE_UNIT + SECOND_UNIT); }