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); }
static void init(void) { app_message_init(); window = window_create(); window_set_click_config_provider(window, click_config_provider); window_set_window_handlers(window, (WindowHandlers) { .load = window_load, .unload = window_unload, });
static void init(void) { app_message_init(); bitmaps_init(); create_main_window(); show_main_window(true); }
static void init(void) { app_message_init(); data_image = malloc(sizeof(uint8_t) * (5 * 4) * 168 + 12); window = window_create(); window_set_click_config_provider(window, click_config_provider); window_set_window_handlers(window, (WindowHandlers) { .load = window_load, .unload = window_unload, });
static void init(void) { window = window_create(); app_message_init(); window_set_background_color(window, GColorWhite); window_set_window_handlers(window, (WindowHandlers) { .load = window_load, .unload = window_unload, });
int main(void) { handle_init(); app_message_init(); //get_events_handler(); //time(&start); app_event_loop(); handle_deinit(); }
void init() { app_message_init(); //Initialize the app elements here! window = window_create(); window_set_window_handlers(window, (WindowHandlers) { .load = window_load, .unload = window_unload, });
void handle_init(void) { quick_journey_init(); choose_station_init(); app_message_init(); my_window = window_create(); window_set_window_handlers(my_window, (WindowHandlers) { .load = window_load, .unload = window_unload });
static void init(void) { app_message_init(); window = window_create(); window_set_background_color(window, GColorClear); window_set_fullscreen(window, true); window_set_window_handlers(window, (WindowHandlers) { .load = window_load, .unload = window_unload });
/*! * Main function */ int main() { window = window_create(); window_set_fullscreen(window, true); app_message_init(); window_set_window_handlers(window, (WindowHandlers) { .load = window_load, .unload = window_unload, });
void handle_init() { int i; srand(time(NULL)); initColors(); readConfig(); swapDigitShapes(); app_message_init(); initSplash(); window = window_create(); if (invertStatus) { window_set_background_color(window, GColorWhite); } else { window_set_background_color(window, GColorBlack); } window_stack_push(window, true); rootLayer = window_get_root_layer(window); mainLayer = layer_create(layer_get_bounds(rootLayer)); layer_add_child(rootLayer, mainLayer); layer_set_update_proc(mainLayer, updateMainLayer); for (i=0; i<NUMSLOTS; i++) { initSlot(i, mainLayer); } initDigitCorners(); animImpl.setup = NULL; animImpl.update = animateDigits; #ifdef PBL_PLATFORM_APLITE animImpl.teardown = destroyAnim; #else animImpl.teardown = NULL; #endif createAnim(); timer = 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); }
static void init(void) { time_t t; struct tm *tm; initRadiuses(); readConfig(); app_message_init(); window = window_create(); window_set_background_color(window, GColorBlack); window_stack_push(window, false); rootLayer = window_get_root_layer(window); t = time(NULL); tm = localtime(&t); layer = layer_create(GRect(0, 0, 144, 168)); layer_set_update_proc(layer, updateScreen); layer_add_child(rootLayer, layer); font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_TIMEBURNER_20)); textFrame = GRect(72-innerCircleInnerRadius, 60, 2*innerCircleInnerRadius, 60); textLayer = text_layer_create(textFrame); text_layer_set_text_alignment(textLayer, GTextAlignmentCenter); text_layer_set_overflow_mode(textLayer, GTextOverflowModeWordWrap); text_layer_set_background_color(textLayer, GColorClear); text_layer_set_text_color(textLayer, GColorWhite); text_layer_set_font(textLayer, font); layer_set_hidden(text_layer_get_layer(textLayer), true); layer_add_child(rootLayer, text_layer_get_layer(textLayer)); setDate(tm); calcAngles(tm); tick_timer_service_subscribe(MINUTE_UNIT, handleTick); accel_tap_service_subscribe(tapHandler); bluetooth_connection_service_subscribe(&handle_bluetooth); }
static void init(void) { upgrade(); app_message_init(); error_window_init(); stats_layer_global_init(); refresh_layer_global_init(); window = window_create(); window_set_background_color(window, GColorBlack); window_set_click_config_provider(window, window_click_config_provider); window_set_fullscreen(window, true); static const WindowHandlers window_handlers = { .load = window_load, .unload = window_unload, }; window_set_window_handlers(window, window_handlers); window_stack_push(window, true); }
void init() { time_buffer[TEXT_BUFFER_SIZE] = date_buffer[TEXT_BUFFER_SIZE] = weekday_buffer[TEXT_BUFFER_SIZE] = status_buffer[TEXT_BUFFER_SIZE] = '\0'; window = window_create(); WindowHandlers handlers = { .load = window_load, .unload = window_unload }; window_set_window_handlers(window, handlers); window_stack_push(window, true); app_message_init(); ping_app_message(); battery_state_service_subscribe(handle_battery); BatteryChargeState charge_state = battery_state_service_peek(); handle_battery(charge_state); app_log(APP_LOG_LEVEL_DEBUG, "pebblemonface.c", __LINE__, "Done Initializing"); }
void handle_init(void) { // WINDOW // mWindow = window_create(); if (mWindow == NULL) { return; } window_stack_push(mWindow, true /* Animated */); mWindowLayer = window_get_root_layer(mWindow); window_set_background_color(mWindow, GColorWhite); // BACKGROUND // mBackgroundLayer = layer_create(layer_get_frame(mWindowLayer)); layer_add_child(mWindowLayer, mBackgroundLayer); layer_set_update_proc(mBackgroundLayer, update_background_callback); //BATTERY_ICONS battery_image = gbitmap_create_with_resource(RESOURCE_ID_BATTERY_100); GRect frame4 = (GRect) { .origin = { .x = 50, .y = 82 }, .size = battery_image->bounds.size }; battery_image_layer = bitmap_layer_create(frame4); bitmap_layer_set_bitmap(battery_image_layer, battery_image); layer_add_child(mWindowLayer, bitmap_layer_get_layer(battery_image_layer)); // FONTS // //ResHandle res_d = resource_get_handle(RESOURCE_ID_SMALL_26); ResHandle res_t = resource_get_handle(RESOURCE_ID_BIG_52); ResHandle res_temp = resource_get_handle(RESOURCE_ID_MEDIUM_34); //ResHandle res_hl = resource_get_handle(RESOURCE_ID_SMALL_22); //mDateFont = fonts_load_custom_font(res_d); mTimeFont = fonts_load_custom_font(res_t); mTemperatureFont = fonts_load_custom_font(res_temp); //mHighLowFont = fonts_load_custom_font(res_hl); // TIME LAYER // mTimeLayer = layer_create(layer_get_frame(mWindowLayer)); layer_add_child(mWindowLayer, mTimeLayer); // TIME HOUR LAYER // mTimeHourLayer = text_layer_create(TIME_HOUR_FRAME); text_layer_set_background_color(mTimeHourLayer, GColorClear); text_layer_set_text_color(mTimeHourLayer, GColorBlack); text_layer_set_font(mTimeHourLayer, mTimeFont); text_layer_set_text_alignment(mTimeHourLayer, GTextAlignmentRight); layer_add_child(mTimeLayer, text_layer_get_layer(mTimeHourLayer)); // TIME SEPARATOR LAYER // mTimeSeparatorLayer = text_layer_create(TIME_SEP_FRAME); text_layer_set_background_color(mTimeSeparatorLayer, GColorClear); text_layer_set_text_color(mTimeSeparatorLayer, GColorBlack); text_layer_set_font(mTimeSeparatorLayer, mTimeFont); text_layer_set_text_alignment(mTimeSeparatorLayer, GTextAlignmentCenter); text_layer_set_text(mTimeSeparatorLayer, ":"); layer_add_child(mTimeLayer, text_layer_get_layer(mTimeSeparatorLayer)); // TIME MINUTES LAYER // mTimeMinutesLayer = text_layer_create(TIME_MIN_FRAME); text_layer_set_background_color(mTimeMinutesLayer, GColorClear); text_layer_set_text_color(mTimeMinutesLayer, GColorBlack); text_layer_set_font(mTimeMinutesLayer, mTimeFont); text_layer_set_text_alignment(mTimeMinutesLayer, GTextAlignmentLeft); layer_add_child(mTimeLayer, text_layer_get_layer(mTimeMinutesLayer)); // DATE LAYER // mDateLayer = text_layer_create(DATE_FRAME); text_layer_set_background_color(mDateLayer, GColorClear); text_layer_set_text_color(mDateLayer, GColorBlack); text_layer_set_font(mDateLayer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));//mDateFont); text_layer_set_text_alignment(mDateLayer, GTextAlignmentCenter); layer_add_child(mWindowLayer, text_layer_get_layer(mDateLayer)); // WEATHER ICON // mWeatherIconLayer = bitmap_layer_create(WEATHER_ICON_FRAME); layer_add_child(mWindowLayer, bitmap_layer_get_layer(mWeatherIconLayer)); // TEMPERATURE // mTemperatureLayer = text_layer_create(WEATHER_TEMP_FRAME); text_layer_set_background_color(mTemperatureLayer, GColorClear); text_layer_set_text_color(mTemperatureLayer, GColorBlack); text_layer_set_font(mTemperatureLayer, mTemperatureFont); //fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD)); // text_layer_set_text_alignment(mTemperatureLayer, GTextAlignmentCenter); layer_add_child(mWindowLayer, text_layer_get_layer(mTemperatureLayer)); // HIGHLOW // mHighLowLayer = text_layer_create(WEATHER_HL_FRAME); text_layer_set_background_color(mHighLowLayer, GColorClear); text_layer_set_text_color(mHighLowLayer, GColorBlack); text_layer_set_font(mHighLowLayer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); //mHighLowFont); text_layer_set_text_alignment(mHighLowLayer, GTextAlignmentCenter); layer_add_child(mWindowLayer, text_layer_get_layer(mHighLowLayer)); weather_set_loading(); app_message_init(); time_t now = time(NULL); struct tm *tick_time = localtime(&now); mInitialMinute = (tick_time->tm_min % FREQUENCY_MINUTES); handle_tick(tick_time, DAY_UNIT + HOUR_UNIT + MINUTE_UNIT + SECOND_UNIT); tick_timer_service_subscribe(SECOND_UNIT, handle_tick); bluetooth_connection_service_subscribe(bluetooth_connection_callback); update_battery(battery_state_service_peek()); battery_state_service_subscribe(&update_battery); }
// Watchface initialization static void window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); // Set Background color to Black (For testing only) window_set_background_color(window, GColorBlack); // Initialize Globals mincount = 0; use_uq_weather = true; batt_img = gbitmap_create_with_resource(RESOURCE_ID_BATT_100); cond_img = gbitmap_create_with_resource(RESOURCE_ID_COND_LOADING); GRect bounds = layer_get_bounds(window_layer); // For debugging static char boundtext[20]; snprintf(boundtext, 20, "w=%d, h=%d\ntest", bounds.size.w, bounds.size.h); // Build the time layer time_layer = text_layer_create(GRect(0, -10, 122, 50)); text_layer_set_text(time_layer, "TIME"); //text_layer_set_font(time_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD)); text_layer_set_font(time_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MYRIADB_44))); text_layer_set_text_alignment(time_layer, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(time_layer)); // Build the ampm layer ampm_layer = text_layer_create(GRect(122, -4, 22, 44)); text_layer_set_font(ampm_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MYRIADB_20))); text_layer_set_text(ampm_layer, "A\nM"); text_layer_set_text_alignment(ampm_layer, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(ampm_layer)); // Build the date layer date_layer = text_layer_create(GRect(0, 42, 144, 27)); text_layer_set_font(date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MYRIAD_20))); text_layer_set_text(date_layer, "Date"); text_layer_set_text_alignment(date_layer, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(date_layer)); // Build the weather icon layer icon_layer = bitmap_layer_create(GRect(0, 73, 40, 40)); bitmap_layer_set_background_color(icon_layer, GColorBlack); layer_add_child(window_layer, bitmap_layer_get_layer(icon_layer)); // Build the temp layer temp_layer = text_layer_create(GRect(42, 71, 76, 43)); text_layer_set_background_color(temp_layer, GColorClear); text_layer_set_text_color(temp_layer, GColorWhite); text_layer_set_font(temp_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MYRIADB_32))); text_layer_set_text(temp_layer, "..."); text_layer_set_text_alignment(temp_layer, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(temp_layer)); // Build the battery layer batt_layer = bitmap_layer_create(GRect(120, 73, 24, 40)); bitmap_layer_set_background_color(batt_layer, GColorBlack); layer_add_child(window_layer, bitmap_layer_get_layer(batt_layer)); // Build the bitcoin price layer btc_layer = text_layer_create(GRect(0, 118, 144, 24)); text_layer_set_font(btc_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MYRIAD_18))); text_layer_set_text(btc_layer, "Loading..."); text_layer_set_text_alignment(btc_layer, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(btc_layer)); // Build the fitbit layer fitbit_layer = text_layer_create(GRect(0, 144, 144, 24)); text_layer_set_font(fitbit_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MYRIAD_16))); text_layer_set_text(fitbit_layer, "Loading..."); text_layer_set_text_alignment(fitbit_layer, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(fitbit_layer)); // Verify persistent storage for BTC daily value is setup check_bitcoin_persist(); // Setup AppMessage app_message_init(); // Subscribe to the minute tick tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick); // Force initial tick to inialize values time_t then = time(NULL); struct tm *now = localtime(&then); handle_minute_tick(now, SECOND_UNIT | MINUTE_UNIT | HOUR_UNIT | DAY_UNIT | MONTH_UNIT | YEAR_UNIT); // Subscribed to battery change events battery_state_service_subscribe(handle_battery); // Force initial battery check handle_battery(battery_state_service_peek()); // Subscribe to bluetooth change events bluetooth_connection_service_subscribe(handle_bluetooth); // Force initial bluetooth state check handle_bluetooth(bluetooth_connection_service_peek()); /* // Build the debugging text layer text_layer = text_layer_create(GRect(2, 54, 140, 80)); text_layer_set_background_color(text_layer, GColorBlack); text_layer_set_text_color(text_layer, GColorWhite); text_layer_set_text(text_layer, boundtext); text_layer_set_text_alignment(text_layer, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(text_layer)); */ }