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); // Set background if(watch_info_get_model() != WATCH_INFO_MODEL_PEBBLE_ORIGINAL && watch_info_get_model() != WATCH_INFO_MODEL_PEBBLE_STEEL) { bg_grass = gbitmap_create_with_resource(RESOURCE_ID_BG_GRASS); background_image = bitmap_layer_create(bounds); bitmap_layer_set_bitmap(background_image, bg_grass); layer_add_child(window_layer, bitmap_layer_get_layer(background_image)); } // Create GBitmaps num0 = gbitmap_create_with_resource(RESOURCE_ID_NUM_0); num1left = gbitmap_create_with_resource(RESOURCE_ID_NUM_1_LEFT); num1right = gbitmap_create_with_resource(RESOURCE_ID_NUM_1_RIGHT); num2 = gbitmap_create_with_resource(RESOURCE_ID_NUM_2); num3 = gbitmap_create_with_resource(RESOURCE_ID_NUM_3); num4 = gbitmap_create_with_resource(RESOURCE_ID_NUM_4); num5 = gbitmap_create_with_resource(RESOURCE_ID_NUM_5); num6 = gbitmap_create_with_resource(RESOURCE_ID_NUM_6); num7 = gbitmap_create_with_resource(RESOURCE_ID_NUM_7); num8 = gbitmap_create_with_resource(RESOURCE_ID_NUM_8); num9 = gbitmap_create_with_resource(RESOURCE_ID_NUM_9); // Create BitmapLayers topleft_image = bitmap_layer_create(GRect(7, 5, 64, 76)); topright_image = bitmap_layer_create(GRect(71, 5, 64, 76)); bottomleft_image = bitmap_layer_create(GRect(7, 86, 64, 76)); bottomright_image = bitmap_layer_create(GRect(71, 86, 64, 76)); // Set transparency bitmap_layer_set_background_color(topleft_image, GColorClear); bitmap_layer_set_background_color(topright_image, GColorClear); bitmap_layer_set_background_color(bottomleft_image, GColorClear); bitmap_layer_set_background_color(bottomright_image, GColorClear); bitmap_layer_set_compositing_mode(topleft_image, GCompOpSet); bitmap_layer_set_compositing_mode(topright_image, GCompOpSet); bitmap_layer_set_compositing_mode(bottomleft_image, GCompOpSet); bitmap_layer_set_compositing_mode(bottomright_image, GCompOpSet); // Add BitmapLayers as child layers to the Window's root layer layer_add_child(window_layer, bitmap_layer_get_layer(topleft_image)); layer_add_child(window_layer, bitmap_layer_get_layer(topright_image)); layer_add_child(window_layer, bitmap_layer_get_layer(bottomleft_image)); layer_add_child(window_layer, bitmap_layer_get_layer(bottomright_image)); }
static bool get_color() { // is color supported? if (FORCE_COLOR) { return true; } else { switch(watch_info_get_model()) { case WATCH_INFO_MODEL_PEBBLE_ORIGINAL: return false; case WATCH_INFO_MODEL_PEBBLE_STEEL: return false; case WATCH_INFO_MODEL_UNKNOWN: return false; default: return true; } } }
layer_destroy(graphics_layer); } static void init(void) { // Set up and push main window main_window = window_create(); window_set_window_handlers(main_window, (WindowHandlers) { .load = main_window_load, .unload = main_window_unload }); window_set_click_config_provider(main_window, click_config_provider); window_set_background_color(main_window, GColorBlack); IF_SDK2(window_set_fullscreen(main_window, true)); // Detect Emulation emulator = watch_info_get_model()==WATCH_INFO_MODEL_UNKNOWN; if(emulator) { light_enable(true); // Good colors on emulator LOG("Emulator Detected: Turning Backlight On"); } //Set up other stuff cursor.x = 72; cursor.y = 44; // Cursor starting position srand(time(NULL)); // Seed randomizer (just for good measure) accel_raw_data_service_subscribe(5, accel_data_handler); // We will be using the accelerometer: 5 samples_per_update accel_service_set_sampling_rate(ACCEL_SAMPLING_100HZ); // 100 samples per second = 20 updates per second //Begin window_stack_push(main_window, true /* Animated */); // Display window. Callback will be called once layer is dirtied then written }