void handle_appmessage_receive(DictionaryIterator *received, void *context) { Tuple *tuple = dict_read_first(received); while (tuple) { switch (tuple->key) { case SECONDS_MODE: seconds_mode = tuple->value->int32; break; case BATTERY_MODE: battery_mode = tuple->value->int32; break; case DATE_MODE: date_mode = tuple->value->int32; break; case BLUETOOTH_MODE: bluetooth_mode = tuple->value->int32; break; case GRAPHICS_MODE: graphics_mode = tuple->value->int32; break; case CONNLOST_MODE: connlost_mode = tuple->value->int32; break; } tuple = dict_read_next(received); } APP_LOG(APP_LOG_LEVEL_DEBUG, "Received config"); has_config = true; handle_battery(battery_state_service_peek()); handle_bluetooth(bluetooth_connection_service_peek()); handle_inverter(); }
void show_watchface(void) { initialise_ui(); s_res_charging = gbitmap_create_with_resource(RESOURCE_ID_CHARGING); s_res_battery_20 = gbitmap_create_with_resource(RESOURCE_ID_BATTERY_20); s_res_battery_40 = gbitmap_create_with_resource(RESOURCE_ID_BATTERY_40); s_res_battery_60 = gbitmap_create_with_resource(RESOURCE_ID_BATTERY_60); s_res_battery_80 = gbitmap_create_with_resource(RESOURCE_ID_BATTERY_80); s_res_battery_100 = gbitmap_create_with_resource(RESOURCE_ID_BATTERY_100); layer_set_update_proc(sCalendarLayer, calendar_layer_update_callback); tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick); battery_state_service_subscribe(handle_battery); bluetooth_connection_service_subscribe(handle_bluetooth); sTimer = NULL; btStatus = bluetooth_connection_service_peek(); handle_battery(battery_state_service_peek()); currentTime = get_time(); update_time_text(); update_date_text(); layer_mark_dirty(sCalendarLayer); window_set_window_handlers(s_window, (WindowHandlers) { .unload = handle_window_unload, });
bool owm_weather_fetch(OWMWeatherCallback *callback) { if(!s_info) { APP_LOG(APP_LOG_LEVEL_ERROR, "OWM Weather library is not initialized!"); return false; } if(!callback) { APP_LOG(APP_LOG_LEVEL_ERROR, "OWMWeatherCallback was NULL!"); return false; } s_callback = callback; if(!bluetooth_connection_service_peek()) { s_status = OWMWeatherStatusBluetoothDisconnected; s_callback(s_info, s_status); return false; } app_message_deregister_callbacks(); app_message_register_inbox_received(inbox_received_handler); app_message_open(2026, 656); return fetch(); }
void handle_init() { Layer *rootLayer; int i; window = window_create(); window_set_background_color(window, GColorWhite); window_stack_push(window, true); readConfig(); app_message_init(); rootLayer = window_get_root_layer(window); for (i=0; i<NUMSLOTS; i++) { initSlot(i, rootLayer); } animImpl.setup = NULL; animImpl.update = animateDigits; animImpl.teardown = NULL; anim = animation_create(); animation_set_delay(anim, 0); animation_set_duration(anim, DIGIT_CHANGE_ANIM_DURATION); animation_set_implementation(anim, &animImpl); app_timer_register(STARTDELAY, handle_timer, NULL); tick_timer_service_subscribe(MINUTE_UNIT, handle_tick); accel_tap_service_subscribe(handle_tap); lastBluetoothStatus = bluetooth_connection_service_peek(); bluetooth_connection_service_subscribe(handle_bluetooth); }
void request_weather(WeatherData *weather_data) { APP_LOG(APP_LOG_LEVEL_DEBUG, "Request weather, retry: %i", retry_count); if (retry_count > MAX_RETRY) { APP_LOG(APP_LOG_LEVEL_DEBUG, "Too many retries"); retry_count = 0; return; } if (!bluetooth_connection_service_peek()) { weather_data->error = WEATHER_E_DISCONNECTED; return; } DictionaryIterator *iter; app_message_outbox_begin(&iter); if (iter == NULL) { APP_LOG(APP_LOG_LEVEL_DEBUG, "Null iter"); return; } dict_write_cstring(iter, KEY_SERVICE, weather_data->service); dict_write_cstring(iter, KEY_SCALE, weather_data->scale); dict_write_uint8(iter, KEY_DEBUG, (uint8_t)weather_data->debug); dict_write_uint8(iter, KEY_BATTERY, (uint8_t)weather_data->battery); dict_write_end(iter); app_message_outbox_send(); }
static void main_window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_frame(window_layer); s_text_layer = text_layer_create(GRect(0, 1, bounds.size.w, bounds.size.h - 20)); text_layer_set_background_color(s_text_layer, GColorBlack); text_layer_set_text_color(s_text_layer, GColorWhite); text_layer_set_font(s_text_layer, fonts_get_system_font(FONT_KEY_DROID_SERIF_28_BOLD)); layer_add_child(window_layer, text_layer_get_layer(s_text_layer)); s_connection_layer = text_layer_create(GRect(0, 135, bounds.size.w, 34)); text_layer_set_text_color(s_connection_layer, GColorWhite); text_layer_set_background_color(s_connection_layer, GColorClear); text_layer_set_font(s_connection_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD)); text_layer_set_text_alignment(s_connection_layer, GTextAlignmentRight); handle_bluetooth(bluetooth_connection_service_peek()); s_battery_layer = text_layer_create(GRect(0, 150, bounds.size.w, 34)); text_layer_set_text_color(s_battery_layer, GColorWhite); text_layer_set_background_color(s_battery_layer, GColorClear); text_layer_set_font(s_battery_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD)); text_layer_set_text_alignment(s_battery_layer, GTextAlignmentRight); text_layer_set_text(s_battery_layer, "100% charged"); time_t now = time(NULL); struct tm *t = localtime(&now); update_time(t); tick_timer_service_subscribe(MINUTE_UNIT, &handle_minute_tick); battery_state_service_subscribe(handle_battery); bluetooth_connection_service_subscribe(handle_bluetooth); layer_add_child(window_layer, text_layer_get_layer(s_connection_layer)); layer_add_child(window_layer, text_layer_get_layer(s_battery_layer)); }
static void window_load(Window *window) { mBackgroundColor = GColorBlack; mTextColor = GColorWhite; #if PBL_COLOR lightColor = GColorMintGreen; darkColor = GColorDarkGreen; window_set_background_color(window, darkColor); #else window_set_background_color(window, mBackgroundColor); #endif // PBL_COLOR bgLayer = layer_create(GRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); layer_set_update_proc(bgLayer, (LayerUpdateProc)render_bg); layer_add_child(window_get_root_layer(window), bgLayer); timeLayer = layer_create(GRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); layer_set_update_proc(timeLayer, (LayerUpdateProc)render_time); layer_add_child(window_get_root_layer(window), timeLayer); mTimeFont = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_BITWISE_16)); mTimeText = malloc(5); // HH:MM mDateText = malloc(5); // MM-DD struct tm* t; time_t temp; temp = time(NULL); t = localtime(&temp); set_time_display(t); bt_handler(bluetooth_connection_service_peek()); battery_handler(battery_state_service_peek()); }
static void write_blk_buf_to_persist(){ /* the persist_read_int(I_BLK_PERSIST_KEY) is NOT a count, it is the current index * but 1-indexced, so 1 is the first block and zero is the empty state */ if(persist_read_int(I_BLK_PERSIST_KEY) < N_BLK_PERSIST){ // set the index of the current block persist_write_int(I_BLK_PERSIST_KEY,persist_read_int(I_BLK_PERSIST_KEY)+1); persist_write_data(persist_read_int(I_BLK_PERSIST_KEY), blk_buf,((SIZE_SUMM*N_SUMM_BLK)+SIZE_BLK_HEAD)); } if(bluetooth_connection_service_peek()){ persist_write_int(WORKER_START_FORE_APP_REASON_PERSIST_KEY, WFAWR_PUSH_ALL_DATA_TO_SERVER); summ_since_trans_server = 0; // once try to go to server, reset worker_launch_app(); } else if(persist_read_int(I_BLK_PERSIST_KEY) >= (N_BLK_PERSIST-1) ){ // if the I_BLK_PERSIST_KEY is greater than 90% of storage, then prompt // that need to connect the phone persist_write_int(WORKER_START_FORE_APP_REASON_PERSIST_KEY, WFAWR_MEMORY_LOW_REMINDER); worker_launch_app(); } // else if(){ // // reset the counter for consecutive summaries // persist_write_int(WORKER_START_FORE_APP_REASON_PERSIST_KEY, // WFAWR_WEAR_REMINDER); // worker_launch_app(); // } }
void handle_init() { // Configure window window = window_create(); window_stack_push(window, true /* Animated */); window_set_background_color(window, BKGD_COLOR); window_set_fullscreen(window, true); Layer *window_layer = window_get_root_layer(window); // Dynamic allocation of assets minuteFrame = GRect(53, 16, 40, 40); minuteLayer = text_layer_create(minuteFrame); hourLayer = bitmap_layer_create(GRect(0, 0, 144, 148)); batteryLogoLayer = bitmap_layer_create(GRect(65, 151, 10, 15)); batteryPercentLayer = text_layer_create(GRect(78, 150, 30, 167-150)); dateLayer = text_layer_create(GRect(3, 150, 38, 167-150)); dayLayer = text_layer_create(GRect(141-30, 150, 30, 167-150)); text_layer_set_text_alignment(dayLayer, GTextAlignmentRight); bottomBarLayer = layer_create(GRect(1, 149, 142, 18)); // Setup minute layer text_layer_set_text_color(minuteLayer, TEXT_COLOR); text_layer_set_background_color(minuteLayer, GColorClear); text_layer_set_font(minuteLayer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MINUTE_38))); // Setup date & day layer text_layer_set_text_color(dateLayer, TEXT_COLOR); text_layer_set_background_color(dateLayer, GColorClear); text_layer_set_text_color(dayLayer, TEXT_COLOR); text_layer_set_background_color(dayLayer, GColorClear); // Setup battery layers text_layer_set_text_color(batteryPercentLayer, TEXT_COLOR); text_layer_set_background_color(batteryPercentLayer, GColorClear); // Setup line layer layer_set_update_proc(bottomBarLayer, bottom_bar_layer_update_callback); // Add layers into hierachy layer_add_child(bitmap_layer_get_layer(hourLayer), text_layer_get_layer(minuteLayer)); layer_add_child(window_layer, bitmap_layer_get_layer(hourLayer)); layer_add_child(window_layer, bottomBarLayer); layer_add_child(window_layer, bitmap_layer_get_layer(batteryLogoLayer)); layer_add_child(window_layer, text_layer_get_layer(batteryPercentLayer)); layer_add_child(window_layer, text_layer_get_layer(dateLayer)); layer_add_child(window_layer, text_layer_get_layer(dayLayer)); // Avoids a blank screen on watch start. time_t tick_time = time(NULL); display_time(localtime(&tick_time)); handle_battery(battery_state_service_peek()); handle_bluetooth(bluetooth_connection_service_peek()); tick_timer_service_subscribe(MINUTE_UNIT, &handle_minute_tick); battery_state_service_subscribe(&handle_battery); bluetooth_connection_service_subscribe(&handle_bluetooth); initialized = true; }
static void sendDoGetMessageIfBluetoothConnected() { if (bluetooth_connection_service_peek()) { APP_LOG(APP_LOG_LEVEL_INFO, "Phone is connected!"); do_gets(ALL); } else { APP_LOG(APP_LOG_LEVEL_INFO, "Phone is not connected!"); } }
static void update_all(void) { update_minute(); update_daily(); update_weather(FORCE_WEATHER_UPDATE); battery_handler(battery_state_service_peek()); // force refresh bluetooth_handler(bluetooth_connection_service_peek()); }
void handle_init(void) { // Create a window and text layer window = window_create(); text_layer = text_layer_create(GRect(0, TIME_HEIGHT, 144, 168 - TIME_HEIGHT)); show_seconds = persist_read_bool(KEY_SHOW_SECONDS); invert_face = persist_read_bool(KEY_INVERT); metric_units = persist_read_bool(KEY_UNITS); latitude[0] = 0; longitude[0] = 0; location[0] = 0; weather[0] = 0; // Set the text, font, and text alignment //text_layer_set_text(text_layer, ""); // http://www.openweathermap.org/current // https://developer.getpebble.com/blog/2013/07/24/Using-Pebble-System-Fonts/ // https://github.com/JvetS/PebbleSimulator/blob/master/PebbleSimulator/pebble_fonts.h text_layer_set_font(text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); // https://developer.getpebble.com/2/api-reference/group___graphics_types.html text_layer_set_text_alignment(text_layer, GTextAlignmentLeft); // Add the text layer to the window layer_add_child(window_get_root_layer(window), text_layer_get_layer(text_layer)); // date_layer = text_layer_create(GRect(0, 112, 144, 56)); // text_layer_set_text_alignment(date_layer, GTextAlignmentCenter); // text_layer_set_font(date_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD)); // layer_add_child(window_get_root_layer(window), text_layer_get_layer(date_layer)); time_layer = text_layer_create(GRect(0, 0, 144, TIME_HEIGHT)); text_layer_set_text_alignment(time_layer, GTextAlignmentCenter); text_layer_set_font(time_layer, fonts_get_system_font(FONT_PRO_32)); layer_add_child(window_get_root_layer(window), text_layer_get_layer(time_layer)); inverter_layer = inverter_layer_create(GRect(0, 0, 144, 168)); layer_add_child(window_get_root_layer(window), inverter_layer_get_layer(inverter_layer)); layer_set_hidden(inverter_layer_get_layer(inverter_layer), invert_face); battery_state_service_subscribe(handle_battery_change); handle_battery_change(battery_state_service_peek()); bluetooth_connection_service_subscribe(handle_bluetooth_change); handle_bluetooth_change(bluetooth_connection_service_peek()); app_message_register_inbox_received(in_received_handler); app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum()); time_t current_time = time(0); handle_timechanges(localtime(¤t_time), SECOND_UNIT); tick_timer_service_subscribe(SECOND_UNIT, handle_timechanges); // Push the window window_stack_push(window, true); // App Logging! //APP_LOG(APP_LOG_LEVEL_DEBUG, "Hello World from the applogs!"); }
// WINDOW CREATION // static void main_window_load(Window *window) { // Create time TextLayer s_time_layer = text_layer_create(GRect(0, -3, 144, 171)); // Note the negative Y-axis value for better positioning. text_layer_set_background_color(s_time_layer, GColorClear); text_layer_set_text_color(s_time_layer, GColorBlack); text_layer_set_text(s_time_layer, "TIME: 00:00"); text_layer_set_font(s_time_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text_alignment(s_time_layer, GTextAlignmentLeft); // Create Bluetooth TextLayer s_bluetooth_layer = text_layer_create(GRect(0, 95, 144, 14)); // A single text line is 14px high text_layer_set_background_color(s_bluetooth_layer, GColorClear); text_layer_set_text_color(s_bluetooth_layer, GColorBlack); text_layer_set_text(s_bluetooth_layer, "CONNECTED (Y/N): N"); text_layer_set_font(s_bluetooth_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text_alignment(s_bluetooth_layer, GTextAlignmentLeft); // Create Battery TextLayer s_battery_layer = text_layer_create(GRect(0, 109, 144, 14)); text_layer_set_background_color(s_battery_layer, GColorClear); text_layer_set_text_color(s_battery_layer, GColorBlack); text_layer_set_text(s_battery_layer, "BATTERY LEVEL: N/A"); text_layer_set_font(s_battery_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text_alignment(s_battery_layer, GTextAlignmentLeft); // Create Battery TextLayer s_weather_layer = text_layer_create(GRect(0, 123, 144, 28)); text_layer_set_background_color(s_weather_layer, GColorClear); text_layer_set_text_color(s_weather_layer, GColorBlack); text_layer_set_text(s_weather_layer, "TEMPERATURE: Loading...\nWEATHER: Loading..."); text_layer_set_font(s_weather_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text_alignment(s_weather_layer, GTextAlignmentLeft); // Create uptime TextLayer s_uptime_layer = text_layer_create(GRect(0, 151, 144, 14)); text_layer_set_background_color(s_uptime_layer, GColorClear); text_layer_set_text_color(s_uptime_layer, GColorBlack); text_layer_set_text(s_uptime_layer, "LOG UPTIME: 0h 0m 0s"); text_layer_set_font(s_uptime_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text_alignment(s_uptime_layer, GTextAlignmentLeft); // Make sure the time is displayed from the start update_time(); // Show current connection state bt_handler(bluetooth_connection_service_peek()); // Get the current battery level battery_handler(battery_state_service_peek()); // Add child layers to the Window's root layer 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_uptime_layer)); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_bluetooth_layer)); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_battery_layer)); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_weather_layer)); }
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); s_time_layer = text_layer_create(GRect(0, 0, 24, 24)); text_layer_set_background_color(s_time_layer, GColorClear); text_layer_set_font(s_time_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24)); text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_time_layer)); if (persist_read_int(KEY_BACKGROUND_COLOR)) { background_color = GColorFromHEX(persist_read_int(KEY_BACKGROUND_COLOR)); window_set_background_color(window, GColorFromHEX(persist_read_int(KEY_BACKGROUND_COLOR))); } else { background_color = GColorWhite; } setup_blocks(); if (persist_read_int(KEY_DEGREEOPTION)) { degreeOption = persist_read_int(KEY_DEGREEOPTION); } else { degreeOption = 0; } s_weather_layer = text_layer_create(GRect(0,152, 144, 14)); text_layer_set_font(s_weather_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_background_color(s_weather_layer, GColorClear); text_layer_set_text_color(s_weather_layer, gcolor_legible_over(background_color)); text_layer_set_text_alignment(s_weather_layer, GTextAlignmentRight); text_layer_set_text(s_weather_layer, "Loading..."); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_weather_layer)); s_bluetooth_icon_layer = layer_create(GRect(0,0,30,30)); layer_set_update_proc(s_bluetooth_icon_layer, bluetooth_update_proc); bluetooth_path = gpath_create(&BLUETOOTH_INFO); layer_add_child(window_get_root_layer(window), s_bluetooth_icon_layer); //show the correct state of the bluetooth connection from the start #ifdef PBL_SDK_2 bluetooth_callback(bluetooth_connection_service_peek()); #elif PBL_SDK_3 bluetooth_callback(connection_service_peek_pebble_app_connection()); #endif s_date_layer = text_layer_create(GRect(0,0,144,14)); text_layer_set_font(s_date_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text_color(s_date_layer, gcolor_legible_over(background_color)); text_layer_set_background_color(s_date_layer, GColorClear); text_layer_set_text_alignment(s_date_layer, GTextAlignmentRight); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_date_layer)); }
/*----------------------------------------------------------------------------*/ int main(void) { APP_LOG(APP_LOG_LEVEL_INFO, "main: entry: %s %s", __TIME__, __DATE__); /* * Commission App */ window = window_create(); WindowHandlers handlers = {.load = window_load, .unload = window_unload }; window_set_window_handlers(window, handlers); const bool animated = true; window_stack_push(window, animated); Layer * window_layer = window_get_root_layer(window); GRect bounds = layer_get_frame(window_layer); /* Display the simple splash screen to indicate PebblePointer is running. */ image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_PEBBLEPOINTER); image_layer = bitmap_layer_create(bounds); bitmap_layer_set_bitmap(image_layer, image); bitmap_layer_set_alignment(image_layer, GAlignCenter); layer_add_child(window_layer, bitmap_layer_get_layer(image_layer)); /* Basic accelerometer initialization. Enable Tap-Tap functionality. */ accel_service_set_sampling_rate( SAMPLING_RATE ); accel_tap_service_subscribe( (AccelTapHandler) accel_tap_callback ); app_message_open(SYNC_BUFFER_SIZE, SYNC_BUFFER_SIZE); /* Request notfication on Bluetooth connectivity changes. */ bluetooth_connection_service_subscribe( bluetooth_connection_callback ); isConnected = bluetooth_connection_service_peek(); APP_LOG(APP_LOG_LEVEL_INFO, "initially %sonnected", (isConnected) ? "c" : "disc"); /* * Event Processing */ app_event_loop(); /* * Decommission App */ if (tapSwitchState == true) { accel_data_service_unsubscribe(); } /* Remove the Tap-Tap callback */ accel_tap_service_unsubscribe(); /* Release splash-screen resources */ gbitmap_destroy(image); bitmap_layer_destroy(image_layer); window_destroy(window); APP_LOG(APP_LOG_LEVEL_INFO, "main: exit"); }
static void do_init(void) { window = window_create(); window_stack_push(window, true); window_layer = window_get_root_layer(window); date_layer = text_layer_create(GRect(layers[0][0][0],layers[0][0][1],layers[0][1][0],layers[0][1][1])); text_layer_set_text_alignment(date_layer, GTextAlignmentCenter); text_layer_set_text(date_layer, ""); ampm_layer = text_layer_create(GRect(layers[3][0][0],layers[3][0][1],layers[3][1][0],layers[3][1][1])); text_layer_set_text_alignment(ampm_layer, GTextAlignmentCenter); text_layer_set_text(ampm_layer, ""); text_layer_set_text_color(date_layer, GColorBlack); text_layer_set_background_color(date_layer, GColorWhite); text_layer_set_font(date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_ROBOTO_BOLD_16))); conn_layer = bitmap_layer_create( GRect(layers[1][0][0],layers[1][0][1],layers[1][1][0],layers[1][1][1])); load_icon_into_layer(0, bitmap_layer_get_layer(conn_layer)); battery_layer = bitmap_layer_create( GRect(layers[2][0][0],layers[2][0][1],layers[2][1][0],layers[2][1][1])); load_icon_into_layer(0, bitmap_layer_get_layer(battery_layer)); int adj = 0; for (int slot_number = 0; slot_number < TOTAL_IMAGE_SLOTS; slot_number++) { digit_slot[slot_number] = bitmap_layer_create( GRect(position[slot_number][0][0], position[slot_number][0][1], position[slot_number][1][0], position[slot_number][1][1])); load_digit_image_into_slot(slot_number, slot_number); layer_add_child(window_layer, bitmap_layer_get_layer(digit_slot[slot_number])); } time_t now = time(NULL); struct tm *current_time = localtime(&now); handle_second_tick(current_time, SECOND_UNIT); handle_bluetooth(bluetooth_connection_service_peek()); handle_battery(battery_state_service_peek()); tick_timer_service_subscribe(SECOND_UNIT, &handle_second_tick); battery_state_service_subscribe(&handle_battery); bluetooth_connection_service_subscribe(&handle_bluetooth); layer_add_child(window_layer, text_layer_get_layer(date_layer)); window_set_background_color(window, GColorWhite); text_layer_set_text_color(date_layer, GColorBlack); text_layer_set_background_color(date_layer, GColorWhite); text_layer_set_font(date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_ROBOTO_BOLD_16))); layer_add_child(window_layer, bitmap_layer_get_layer(conn_layer)); layer_add_child(window_layer, bitmap_layer_get_layer(battery_layer)); layer_add_child(window_layer, text_layer_get_layer(ampm_layer)); }
static void main_window_load(Window *window) { // Create root layer Layer *window_layer = window_get_root_layer(window); GRect window_bounds = layer_get_bounds(window_layer); // Create time TextLayer s_time_layer = text_layer_create(GRect(0, 35, window_bounds.size.w, 44)); text_layer_set_background_color(s_time_layer, GColorClear); text_layer_set_text_color(s_time_layer, GColorWhite); text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter); // Create date TextLayer s_date_layer = text_layer_create(GRect(0, 82, window_bounds.size.w, 26)); text_layer_set_background_color(s_date_layer, GColorClear); text_layer_set_text_color(s_date_layer, GColorWhite); text_layer_set_text_alignment(s_date_layer, GTextAlignmentCenter); text_layer_set_font(s_date_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD)); // Create battery TextLayer s_battery_layer = text_layer_create(GRect(window_bounds.size.w / 2, 0, (window_bounds.size.w / 2) - 2, 18)); text_layer_set_background_color(s_battery_layer, GColorClear); text_layer_set_text_color(s_battery_layer, GColorWhite); text_layer_set_text_alignment(s_battery_layer, GTextAlignmentRight); text_layer_set_font(s_battery_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); // Create Pi time BitmapLayer s_pi_bitmap = gbitmap_create_with_resource(RESOURCE_ID_PI_BACKGROUND); s_pi_layer = bitmap_layer_create(GRect(0,17,144,150)); bitmap_layer_set_bitmap(s_pi_layer, s_pi_bitmap); layer_set_hidden(bitmap_layer_get_layer(s_pi_layer), true); // Create bluetooth BitmapLayer s_bt_connected_bitmap = gbitmap_create_with_resource(RESOURCE_ID_BT_CONNECTED); s_bt_disconnected_bitmap = gbitmap_create_with_resource(RESOURCE_ID_BT_DISCONNECTED); s_bt_layer = bitmap_layer_create(GRect(3,3,12,11)); // Create bluetooth connected InverterLayer s_inv_layer = inverter_layer_create(GRect(0,0,window_bounds.size.w,window_bounds.size.h)); // Initialize watch state s_show_seconds_bool = true; battery_handler(battery_state_service_peek()); bluetooth_handler(bluetooth_connection_service_peek()); format_time(); // Add all layers to the Window's root layer layer_add_child(window_layer, text_layer_get_layer(s_time_layer)); layer_add_child(window_layer, text_layer_get_layer(s_battery_layer)); layer_add_child(window_layer, text_layer_get_layer(s_date_layer)); layer_add_child(window_layer, bitmap_layer_get_layer(s_bt_layer)); layer_add_child(window_layer, bitmap_layer_get_layer(s_pi_layer)); layer_add_child(window_layer, inverter_layer_get_layer(s_inv_layer)); }
static void log_action(void* vpath) { char* path = (char*)vpath; if(vpath == NULL){ #ifdef DEBUG app_log(APP_LOG_LEVEL_INFO, "vpath", 0, "vpath is NULL"); #endif path = ""; } if(!bluetooth_connection_service_peek()) { #ifdef DEBUG app_log(APP_LOG_LEVEL_INFO, "btdropmsg", 0, (char*)vpath); #endif return; } #ifdef DEBUG app_log(APP_LOG_LEVEL_INFO, "action", 0, path); #endif DictionaryIterator *iter; AppMessageResult amr = app_message_outbox_begin(&iter); if(amr != APP_MSG_OK){ #ifdef DEBUG app_log(APP_LOG_LEVEL_INFO, "logdropmsg", 0, translate_error(amr)); app_log(APP_LOG_LEVEL_INFO, "logdropmsg", 0, path); #endif if(amr == APP_MSG_BUSY){ appendLog(path); #ifdef DEBUG app_log(APP_LOG_LEVEL_INFO, "appendLog", 0, path); plogs(); #endif } return; } #ifdef DEBUG app_log(APP_LOG_LEVEL_INFO, "wasokay", 0, path); #endif Tuplet t = TupletStaticCString(KEY_OFFSET + T_LOG, path, strlen(path)); if(dict_write_tuplet(iter, &t) == DICT_OK) { if(dict_write_end(iter) != 0){ app_message_outbox_send(); #ifdef DEBUG app_log(APP_LOG_LEVEL_INFO, "osend", 0, path); #endif } } else { #ifdef DEBUG app_log(APP_LOG_LEVEL_INFO, "dictbad", 0, path); #endif } }
void bt_handler(){ if(bluetooth_connection_service_peek()){ text_layer_set_text(bt_layer, ""); //vibes_short_pulse(); } else{ text_layer_set_text(bt_layer, "No Bluetooth Connection"); //vibes_short_pulse(); } }
void handle_init(void) { window = window_create(); window_stack_push(window, true /* Animated */); window_set_background_color(window, GColorBlack); fontRobotoCondensed19 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_19)); Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); triangle_overlay_layer = layer_create(bounds); layer_set_update_proc(triangle_overlay_layer, triangle_display_layer_update_callback); layer_add_child(window_layer, triangle_overlay_layer); triangle_overlay_path = gpath_create(&TRIANGLE_OVERLAY_POINTS); gpath_move_to(triangle_overlay_path, grect_center_point(&bounds)); // init hand paths minute_arrow_path = gpath_create(&MINUTE_HAND_POINTS); gpath_move_to(minute_arrow_path, grect_center_point(&bounds)); hour_arrow_path = gpath_create(&HOUR_HAND_POINTS); gpath_move_to(hour_arrow_path, grect_center_point(&bounds)); tick_timer_service_subscribe(MINUTE_UNIT, handle_tick); s_hands_layer = layer_create(bounds); layer_set_update_proc(s_hands_layer, hands_update_proc); layer_add_child(window_layer, s_hands_layer); // Battery Line Basalt #ifdef PBL_PLATFORM_BASALT GRect line_frame = GRect(22, 160, 104, 6); LineLayer = layer_create(line_frame); layer_set_update_proc(LineLayer, line_layer_update_callback); layer_add_child(window_layer, LineLayer); #else //Chalk GRect line_round_frame = GRect(1, 1, 180, 180); RoundBatteryLayer = layer_create(line_round_frame); layer_set_update_proc(RoundBatteryLayer, RoundBatteryLayer_update_callback); layer_add_child(window_layer,RoundBatteryLayer); #endif //Service subscribes: battery_state_service_subscribe(&handle_battery); handle_battery(battery_state_service_peek()); bluetooth_connection_service_subscribe(&handle_bluetooth); handle_bluetooth(bluetooth_connection_service_peek()); app_focus_service_subscribe(&handle_appfocus); }
static void do_init(void) { window = window_create(); window_stack_push(window, true); window_set_background_color(window, GColorBlack); window_layer = window_get_root_layer(window); GRect line_frame = GRect(8, 120, 139, 2); line_layer = layer_create(line_frame); layer_set_update_proc(line_layer, draw_line); layer_add_child(window_layer, line_layer); time_layer = text_layer_create(GRect(5, 66, 118, 70)); text_layer_set_text_color(time_layer, GColorWhite); text_layer_set_background_color(time_layer, GColorClear); text_layer_set_font(time_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_font_droid_44))); text_layer_set_text_alignment(time_layer,GTextAlignmentRight); layer_add_child(window_layer, text_layer_get_layer(time_layer)); date_layer = text_layer_create(GRect(65, 125, 79, 25)); text_layer_set_text_color(date_layer, GColorWhite); text_layer_set_background_color(date_layer, GColorClear); text_layer_set_font(date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_font_droid_18))); layer_add_child(window_layer, text_layer_get_layer(date_layer)); wday_layer = text_layer_create(GRect(60, 143, 50, 25)); text_layer_set_text_color(wday_layer, GColorWhite); text_layer_set_background_color(wday_layer, GColorClear); text_layer_set_font(wday_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_font_droid_18))); layer_add_child(window_layer, text_layer_get_layer(wday_layer)); //+時間のNULL回避?(わかってない→調べる time_t now = time(NULL); struct tm *current_time = localtime(&now); handle_time_tick(current_time, SECOND_UNIT); tick_timer_service_subscribe(SECOND_UNIT, &handle_time_tick); batt_layer = bitmap_layer_create(GRect(123, 151, 14, 10)); layer_add_child(window_layer, bitmap_layer_get_layer(batt_layer)); //親レイヤに載せる watchicon_layer = bitmap_layer_create(GRect(131, 151, 6, 10)); layer_add_child(window_layer, bitmap_layer_get_layer(watchicon_layer)); bitmap_layer_set_background_color(watchicon_layer, GColorClear); bt_layer = bitmap_layer_create(GRect(110, 151, 11, 10)); layer_add_child(window_layer, bitmap_layer_get_layer(bt_layer)); handle_battery(battery_state_service_peek()); battery_state_service_subscribe(&handle_battery); handle_bluetooth(bluetooth_connection_service_peek()); bluetooth_connection_service_subscribe(&handle_bluetooth); }
static void bluetooth_layer_update_callback(Layer *layer, GContext *ctx) { bool connected = bluetooth_connection_service_peek(); // Draw bluetooth icon graphics_context_set_compositing_mode(ctx, GCompOpSet); graphics_draw_bitmap_in_rect(ctx, s_bluetooth_image, gbitmap_get_bounds(s_bluetooth_image)); // Draw cross if not connected if (!connected) { graphics_draw_bitmap_in_rect(ctx, s_cross_image, gbitmap_get_bounds(s_cross_image)); } }
static void update_bluetooth(bool connected) { if (bluetooth_connection_service_peek()) { vibes_enqueue_custom_pattern(custom_pattern_connected); text_layer_set_text(bluetoothstatus_layer,"Phone is connected!"); APP_LOG(APP_LOG_LEVEL_INFO, "Phone is connected!"); } else { vibes_enqueue_custom_pattern(custom_pattern_notconnected); text_layer_set_text(bluetoothstatus_layer, "Phone is not connected!"); APP_LOG(APP_LOG_LEVEL_INFO, "Phone is not connected!"); } }
static void main_window_load(Window *window) { s_root_layer = window_get_root_layer(window); // Time s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_EMULOGIC_24)); s_time_layer = text_layer_create(POS_TIME); text_layer_set_background_color(s_time_layer, GColorClear); text_layer_set_font(s_time_layer, s_time_font); text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_time_layer)); // Date s_date_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_EMULOGIC_12)); s_date_layer = text_layer_create(POS_DATE); text_layer_set_background_color(s_date_layer, GColorClear); text_layer_set_font(s_date_layer, s_date_font); text_layer_set_text_alignment(s_date_layer, GTextAlignmentCenter); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_date_layer)); // Bluetooth s_bluetooth_layer = bitmap_layer_create(POS_BT); layer_add_child(s_root_layer, bitmap_layer_get_layer(s_bluetooth_layer)); // Battery s_battery_layer = bitmap_layer_create(POS_BATT); layer_add_child(s_root_layer, bitmap_layer_get_layer(s_battery_layer)); // Kirby s_kirby_layer = bitmap_layer_create(POS_KBY); layer_add_child(s_root_layer, bitmap_layer_get_layer(s_kirby_layer)); // === First update === // tick_handler time_t temp = time(NULL); struct tm *tick_time = localtime(&temp); srand(temp); cur_kirby = rand() % NUM_KIRBIES; tick_handler(tick_time, INTERVAL_UPDATE); // Go back one Kirby so the next update keeps it the same cur_kirby = (cur_kirby - 1 + NUM_KIRBIES) % NUM_KIRBIES; // bt_handler bt_handler(bluetooth_connection_service_peek()); // batt_handler batt_handler(battery_state_service_peek()); }
static void do_init(void) { window = window_create(); window_stack_push(window, true); window_set_background_color(window, GColorBlack); Layer *root_layer = window_get_root_layer(window); GRect frame = layer_get_frame(root_layer); /* Background */ Anonymous = gbitmap_create_with_resource(RESOURCE_ID_BG_ANONYMOUS); Anonymous_Layer = bitmap_layer_create(GRect(0, 0, WIDTH, HEIGHT)); bitmap_layer_set_background_color(Anonymous_Layer, GColorBlack); bitmap_layer_set_bitmap(Anonymous_Layer, Anonymous); layer_add_child(root_layer, bitmap_layer_get_layer(Anonymous_Layer)); /* Time block */ time_layer = text_layer_create(GRect(0, 52, frame.size.w, 34)); text_layer_set_text_color(time_layer, GColorBlack); text_layer_set_background_color(time_layer, GColorClear); text_layer_set_font(time_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD )); text_layer_set_text_alignment(time_layer, GTextAlignmentCenter); /* Bluetooth block */ bt_connected = gbitmap_create_with_resource(RESOURCE_ID_BT_DISCONNECTED); bt_connected_layer = bitmap_layer_create(GRect(WIDTH - ICON_WIDTH, 1, ICON_WIDTH, ICON_HEIGHT)); bitmap_layer_set_background_color(bt_connected_layer, GColorBlack); layer_add_child(root_layer, bitmap_layer_get_layer(bt_connected_layer)); /* Battery block */ battery_layer = text_layer_create(GRect(2, -2, frame.size.w, 16 )); text_layer_set_text_color(battery_layer, GColorWhite); text_layer_set_background_color(battery_layer, GColorClear); text_layer_set_font(battery_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text_alignment(battery_layer, GTextAlignmentLeft); text_layer_set_text(battery_layer, "100% charged"); /* Init blocks */ time_t now = time(NULL); struct tm *current_time = localtime(&now); handle_second_tick(current_time, SECOND_UNIT); tick_timer_service_subscribe(SECOND_UNIT, &handle_second_tick); battery_state_service_subscribe(&handle_battery); bool connected = bluetooth_connection_service_peek(); handle_bluetooth(connected); bluetooth_connection_service_subscribe(&handle_bluetooth); layer_add_child(root_layer, text_layer_get_layer(time_layer)); layer_add_child(root_layer, text_layer_get_layer(battery_layer)); }
static void main_window_load(Window *window) { time_layer = text_layer_create(GRect(0, 30, 144, 61)); text_layer_set_background_color(time_layer, GColorClear); text_layer_set_text_color(time_layer, GColorBlack); time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_LIBERATION_NARROW_BOLD_60)); text_layer_set_font(time_layer, time_font); text_layer_set_text_alignment(time_layer, GTextAlignmentCenter); layer_add_child(window_get_root_layer(main_window), text_layer_get_layer(time_layer)); seconds_layer = text_layer_create(GRect(0, 90, 144, 34)); text_layer_set_background_color(seconds_layer, GColorClear); text_layer_set_text_color(seconds_layer, GColorBlack); seconds_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_LIBERATION_NARROW_BOLD_30)); text_layer_set_font(seconds_layer, seconds_font); text_layer_set_text_alignment(seconds_layer, GTextAlignmentCenter); layer_add_child(window_get_root_layer(main_window), text_layer_get_layer(seconds_layer)); date_layer = text_layer_create(GRect(0, 125, 144, 34)); text_layer_set_background_color(date_layer, GColorClear); text_layer_set_text_color(date_layer, GColorBlack); date_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_LIBERATION_NARROW_BOLD_30)); text_layer_set_font(date_layer, date_font); text_layer_set_text_alignment(date_layer, GTextAlignmentCenter); layer_add_child(window_get_root_layer(main_window), text_layer_get_layer(date_layer)); battery_text_layer = text_layer_create(GRect(32, 0, 67, 34)); text_layer_set_background_color(battery_text_layer, GColorClear); text_layer_set_text_color(battery_text_layer, GColorBlack); battery_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_LIBERATION_NARROW_BOLD_30)); text_layer_set_font(battery_text_layer, battery_font); text_layer_set_text_alignment(battery_text_layer, GTextAlignmentLeft); layer_add_child(window_get_root_layer(main_window), text_layer_get_layer(battery_text_layer)); battery_0_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BATTERY_0); battery_1_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BATTERY_1); battery_2_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BATTERY_2); battery_3_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BATTERY_3); battery_4_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BATTERY_4); battery_5_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BATTERY_5); battery_loading_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BATTERY_LOADING); battery_icon_layer = bitmap_layer_create(GRect(10, 7, 15, 24)); bitmap_layer_set_bitmap(battery_icon_layer, battery_0_bitmap); layer_add_child(window_get_root_layer(main_window), bitmap_layer_get_layer(battery_icon_layer)); bt_icon_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BT_ICON); bt_icon_layer = bitmap_layer_create(GRect(116, 7, 18, 24)); bitmap_layer_set_bitmap(bt_icon_layer, bt_icon_bitmap); layer_add_child(window_get_root_layer(main_window), bitmap_layer_get_layer(bt_icon_layer)); bluetooth_callback(bluetooth_connection_service_peek()); }
void bg_update_proc(Layer* me, GContext* ctx) { graphics_context_set_fill_color(ctx, GColorBlack); graphics_fill_rect(ctx, layer_get_bounds(me), 0, GCornerNone); graphics_context_set_fill_color(ctx, GColorWhite); //APP_LOG(APP_LOG_LEVEL_DEBUG, "draw tick_paths"); for (int i = 0; i < NUM_CLOCK_TICKS; ++i) { gpath_draw_filled(ctx, s_data.tick_paths[i]); } if(BTDisp) { if(bluetooth_connection_service_peek()) { graphics_context_set_stroke_color(ctx, GColorWhite); graphics_context_set_fill_color(ctx, GColorWhite); for (int i = 0; i < NUM_BT_LINES; ++i) { gpath_draw_outline(ctx, s_data.bt_paths[i]); } } } if(batDisp) { graphics_context_set_stroke_color(ctx, GColorWhite); graphics_context_set_fill_color(ctx, GColorWhite); BatteryChargeState bat_stat = battery_state_service_peek(); uint8_t bat_level = bat_stat.charge_percent; //APP_LOG(APP_LOG_LEVEL_DEBUG, "bat : %d", bat_level); int BatNumToFill = 0; if( bat_level > 87.5 ) BatNumToFill = 10; else if( bat_level > 75 ) BatNumToFill = 9; else if( bat_level > 62.5 ) BatNumToFill = 8; else if( bat_level > 50 ) BatNumToFill = 7; else if( bat_level > 37.5 ) BatNumToFill = 6; else if( bat_level > 25 ) BatNumToFill = 5; else if( bat_level > 12.5 ) BatNumToFill = 4; else BatNumToFill = 3; //APP_LOG(APP_LOG_LEVEL_DEBUG, "batnumtofill : %d", BatNumToFill); //BatNumToFill = BatNumToFill + 1; for (int i = 0; i < BatNumToFill; ++i) { gpath_draw_outline(ctx, s_data.bat_paths[i]); } } }
static void do_post(char *url) { if (bluetooth_connection_service_peek()) { APP_LOG(APP_LOG_LEVEL_INFO, "Phone is connected!"); DictionaryIterator *iter; app_message_outbox_begin(&iter); dict_write_cstring(iter, READING_LIST, url); app_message_outbox_send(); } else { APP_LOG(APP_LOG_LEVEL_INFO, "Phone is not connected!"); hide_animation(); show_no_con_error(); } }
void lost_connection_warning(void *data) { int count = (int) data; bool on_off = count & 1; // blink icon bitmap_layer_set_bitmap(bluetooth_layer, bluetooth_images[on_off ? 1 : 0]); layer_set_hidden(bitmap_layer_get_layer(bluetooth_layer), false); // buzz 3 times if (count < 6 && !on_off) vibes_short_pulse(); if (count < 50) // blink for 15 seconds app_timer_register(300, lost_connection_warning, (void*) (count+1)); else // restore bluetooth icon handle_bluetooth(bluetooth_connection_service_peek()); }
static void do_init(void) { s_data.window = window_create(); const bool animated = true; window_stack_push(s_data.window, animated); window_set_background_color(s_data.window, GColorBlack); GFont font = fonts_get_system_font(FONT_KEY_DROID_SERIF_28_BOLD); Layer *root_layer = window_get_root_layer(s_data.window); GRect frame = layer_get_frame(root_layer); s_data.label = text_layer_create(GRect(0, 0, frame.size.w, frame.size.h)); text_layer_set_background_color(s_data.label, GColorBlack); text_layer_set_text_color(s_data.label, GColorWhite); text_layer_set_font(s_data.label, font); text_layer_set_text_alignment(s_data.label, GTextAlignmentLeft); layer_add_child(root_layer, text_layer_get_layer(s_data.label)); time_t now = time(NULL); struct tm *t = localtime(&now); update_time(t); tick_timer_service_subscribe(SECOND_UNIT, &handle_minute_tick); bluetoothstatus_layer = text_layer_create(GRect(0, 100, frame.size.w, frame.size.h)); text_layer_set_text_color(bluetoothstatus_layer, GColorWhite); text_layer_set_background_color(bluetoothstatus_layer, GColorBlack); text_layer_set_font(bluetoothstatus_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text_alignment(bluetoothstatus_layer, GTextAlignmentCenter); layer_add_child(root_layer, text_layer_get_layer(bluetoothstatus_layer)); bluetooth_connection_service_subscribe(bluetooth_connection_callback); update_bluetooth(bluetooth_connection_service_peek()); batterystatus_layer = text_layer_create(GRect(0, 120, frame.size.w, frame.size.h)); text_layer_set_text_color(batterystatus_layer, GColorWhite); text_layer_set_background_color(batterystatus_layer, GColorBlack); text_layer_set_font(batterystatus_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text_alignment(batterystatus_layer, GTextAlignmentCenter); layer_add_child(root_layer, text_layer_get_layer(batterystatus_layer)); BatteryChargeState pb_bat = battery_state_service_peek(); pebble_batteryPercent = pb_bat.charge_percent; battery_state_service_subscribe(pebble_battery_callback); update_pebble_battery(battery_state_service_peek()); icon_bt_on = gbitmap_create_with_resource( RESOURCE_ID_IMAGE_BT_ON_ICON ); }