static void window_load(Window *window)
{
    // Check for saved settings
    mInvertColors = persist_exists(KEY_INVERT) ? persist_read_bool(KEY_INVERT) : false;
    mBackColor = (mInvertColors) ? GColorWhite : GColorBlack;
    mForeColor = (mInvertColors) ? GColorBlack : GColorWhite;

    mStarSpeed = STAR_SPEED_SLOW;//persist_exists(KEY_STAR_SPEED) ? persist_read_int(KEY_STAR_SPEED) : STAR_SPEED_FAST;
    mFramerate = FRAMERATE_SMOOTH;//persist_exists(KEY_FRAMERATE) ? persist_read_int(KEY_FRAMERATE) : FRAMERATE_POWER;

	window_set_background_color(window, mBackColor);
	canvas = layer_create(GRect(0, 0, SCREEN_WIDTH , SCREEN_HEIGHT));
	layer_set_update_proc(canvas, (LayerUpdateProc) render);
	layer_add_child(window_get_root_layer(window), canvas);
    
    mFont = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_TETRIS_24));
	
	// Set initial time so display isn't blank
    mTimeText = NULL;
	struct tm *t;
	time_t temp;
	temp = time(NULL);
	t = localtime(&temp);
	set_time_display(t);

	start();
}
Beispiel #2
0
static void window_load(Window *window)
{
	window_set_background_color(window, GColorBlack);
	canvas = layer_create(GRect(0, 0, SCREEN_WIDTH , SCREEN_HEIGHT));
	layer_set_update_proc(canvas, (LayerUpdateProc) render);
	layer_add_child(window_get_root_layer(window), canvas);
    
    mTimeFont = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_TREBUCHET_40));
    mTimeFontBold = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_TREBUCHET_BOLD_40));
    mSmallFont = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_TREBUCHET_BOLD_24));
    mTinyFont = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_TREBUCHET_16));

	// Init all text fields
    const int mTwoDigitTextSize = sizeof("00:00 ");
    mDayText = malloc(mTwoDigitTextSize);
    mMonthText = malloc(mTwoDigitTextSize);
    mYearText = malloc(mTwoDigitTextSize);
    mHourText = malloc(mTwoDigitTextSize);
    mMinuteText = malloc(mTwoDigitTextSize);
    mSecondText = malloc(mTwoDigitTextSize);
    
	// Set initial time so display isn't blank
    struct tm* t;
	time_t temp;
	temp = time(NULL);
	t = localtime(&temp);
	set_time_display(t);
    
    battery_handler(battery_state_service_peek());
}
Beispiel #3
0
static void window_load(Window *window)
{
	//Setup window
	window_set_background_color(window, GColorBlack);
	
	//Get Font
	f_handle = resource_get_handle(RESOURCE_ID_FONT_IMAGINE_38);

	//Setup canvas
	canvas = layer_create(GRect(0, 0, 144, 168));
	layer_set_update_proc(canvas, (LayerUpdateProc) render);
	layer_add_child(window_get_root_layer(window), canvas);
	
	//Set initial time so display isn't blank
	struct tm *t;
	time_t temp;	
	temp = time(NULL);	
	t = localtime(&temp);
	
	//Works to here
	set_time_display(t);
	
	//Start rendering
	start();
}
Beispiel #4
0
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());
}
Beispiel #5
0
static void tick_handler(struct tm* t, TimeUnits units_changed)
{
    APP_LOG(APP_LOG_LEVEL_DEBUG, "tick_handler");
	set_time_display(t);
    
    layer_mark_dirty(bgLayer);
    layer_mark_dirty(timeLayer);    
}
Beispiel #6
0
static void in_received_handler(DictionaryIterator *iter, void *context) {
	// Get our time display property
	Tuple *time_tuple = dict_find(iter, KEY_TIME_DISPLAY);
	
	// If exists, write the property to persistent storage
	time_tuple ? persist_write_int(KEY_TIME_DISPLAY, time_tuple->value->uint8) : false;
	
	// Handle showing or hiding the time display
	set_time_display();
}
Beispiel #7
0
static void init() {
	app_message_register_inbox_received(in_received_handler);
	app_message_register_inbox_dropped(in_dropped_handler);
	app_message_open(128, 0);
	
	window = window_create();
	window_set_background_color(window, GColorBlack);
	window_stack_push(window, true);
	
	Layer *window_layer = window_get_root_layer(window);
	
	// Add time layer
	label_layer_time = text_layer_create(GRect(0, 65, 144, 30));
	text_layer_set_text_color(label_layer_time, GColorWhite);
	text_layer_set_background_color(label_layer_time, GColorClear);
	text_layer_set_text_alignment(label_layer_time, GTextAlignmentCenter);
	text_layer_set_font(label_layer_time, fonts_get_system_font(FONT_KEY_GOTHIC_28));
	layer_set_hidden(text_layer_get_layer(label_layer_time), true);
	layer_add_child(window_layer, text_layer_get_layer(label_layer_time));
	
	tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick);
	
	set_time_display();
}
static void tick_handler(struct tm *t, TimeUnits units_changed)
{
	set_time_display(t);
}
Beispiel #9
0
static void window_load(Window* window)
{
    // Handle the settings.
#ifdef PBL_COLOR
    // Set default colors.
    mLightColor = GColorCeleste;
    mMediumColor = GColorJaegerGreen;
    mDarkColor = GColorDarkGreen;
    mBackgroundColor = GColorBlack;

    // Try to get saved colors.
    // Colors are auto mapped to the nearest color out of 64 available.
    APP_LOG(APP_LOG_LEVEL_DEBUG, "KEY_COLOR_ 1");
    if (persist_exists(KEY_COLOR_RED1) && persist_exists(KEY_COLOR_GREEN1) && persist_exists(KEY_COLOR_BLUE1))
    {
        int red = persist_read_int(KEY_COLOR_RED1);
        int green = persist_read_int(KEY_COLOR_GREEN1);
        int blue = persist_read_int(KEY_COLOR_BLUE1);
        mDarkColor = GColorFromRGB(red, green, blue);
    }

    APP_LOG(APP_LOG_LEVEL_DEBUG, "KEY_COLOR_ 2");
    if (persist_exists(KEY_COLOR_RED2) && persist_exists(KEY_COLOR_GREEN2) && persist_exists(KEY_COLOR_BLUE2))
    {
        int red = persist_read_int(KEY_COLOR_RED2);
        int green = persist_read_int(KEY_COLOR_GREEN2);
        int blue = persist_read_int(KEY_COLOR_BLUE2);
        mLightColor = GColorFromRGB(red, green, blue);
    }
#else
    /*APP_LOG(APP_LOG_LEVEL_DEBUG, "KEY_INVERT");
    if (persist_exists(KEY_INVERT))
    {
        mIsInverted = persist_read_bool(KEY_INVERT);
        APP_LOG(APP_LOG_LEVEL_DEBUG, "KEY_INVERT: %d", mIsInverted);
    }
    
    if (mIsInverted)
    {
        mBackgroundColor = GColorWhite;
        mTextColor = GColorBlack;
    }
    else*/
    {
        mBackgroundColor = GColorBlack;
        mTextColor = GColorWhite;
    }
#endif // PBL_COLOR

    mIs24HourStyle = clock_is_24h_style();
    APP_LOG(APP_LOG_LEVEL_DEBUG, "mIs24HourStyle: %d", mIs24HourStyle);

    APP_LOG(APP_LOG_LEVEL_DEBUG, "window_load: set_background");
	window_set_background_color(window, mBackgroundColor);
    
    APP_LOG(APP_LOG_LEVEL_DEBUG, "window_load: add layers");
    sBgLayer = layer_create(GRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT));
	layer_set_update_proc(sBgLayer, (LayerUpdateProc)render_bg);
	layer_add_child(window_get_root_layer(window), sBgLayer);
    
	sTimeLayer = layer_create(GRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT));
	layer_set_update_proc(sTimeLayer, (LayerUpdateProc)render_time);
	layer_add_child(window_get_root_layer(window), sTimeLayer);

    APP_LOG(APP_LOG_LEVEL_DEBUG, "window_load: setup fonts");
    mDayFont = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_CONSOLAB_14));
	mTimeFont = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_DSEG_BOLD_30));
    mTimeFontSmall = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_DSEG_BOLD_16));
    mDateFont = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_DSEG_NORMAL_14));
    //mDateFontSmall = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_DSEG_NORMAL_10));

    mDayText = malloc(9+1); // WEDNESDAY
    mTimeText = malloc(5+1); // HH:MM
    mTopText = malloc(5+1); // P T T
    mDateText = malloc(5+1); // MM.DD

    APP_LOG(APP_LOG_LEVEL_DEBUG, "window_load: set time");
    struct tm* t;
	time_t temp;
	temp = time(NULL);
	t = localtime(&temp);
	set_time_display(t);
    
    //  Init the BT and battery indicators.
    APP_LOG(APP_LOG_LEVEL_DEBUG, "window_load: setup bt and battery");
    bt_handler(bluetooth_connection_service_peek());
    battery_handler(battery_state_service_peek());
}