示例#1
0
static void inbox_received_handler(DictionaryIterator* iter, void* context)
{
    APP_LOG(APP_LOG_LEVEL_DEBUG, "inbox_received_handler");

#ifdef PBL_COLOR
    // Apply the colors if available.
    Tuple* color_red_t = dict_find(iter, KEY_COLOR_RED1);
    Tuple* color_green_t = dict_find(iter, KEY_COLOR_GREEN1);
    Tuple* color_blue_t = dict_find(iter, KEY_COLOR_BLUE1);
    Tuple* color_red_t2 = dict_find(iter, KEY_COLOR_RED2);
    Tuple* color_green_t2 = dict_find(iter, KEY_COLOR_GREEN2);
    Tuple* color_blue_t2 = dict_find(iter, KEY_COLOR_BLUE2);
    if ((color_red_t && color_green_t && color_blue_t) &&
        (color_red_t2 && color_green_t2 && color_blue_t2))
    {
        int red = color_red_t->value->int32;
        int green = color_green_t->value->int32;
        int blue = color_blue_t->value->int32;

        // Persist values
        persist_write_int(KEY_COLOR_RED1, red);
        persist_write_int(KEY_COLOR_GREEN1, green);
        persist_write_int(KEY_COLOR_BLUE1, blue);

        mDarkColor = GColorFromRGB(red, green, blue);
        APP_LOG(APP_LOG_LEVEL_DEBUG, "inbox_received_handler: mainColor: R:%d, G:%d, B:%d", red, green, blue);
     
        int red2 = color_red_t2->value->int32;
        int green2 = color_green_t2->value->int32;
        int blue2 = color_blue_t2->value->int32;

        // Persist values
        persist_write_int(KEY_COLOR_RED2, red2);
        persist_write_int(KEY_COLOR_GREEN2, green2);
        persist_write_int(KEY_COLOR_BLUE2, blue2);

        mLightColor = GColorFromRGB(red2, green2, blue2);
        APP_LOG(APP_LOG_LEVEL_DEBUG, "inbox_received_handler: secondaryColor: R:%d, G:%d, B:%d", red2, green2, blue2);
        
        // Prevent stupid user settings from ruining the watch.
        if (mLightColor.r == mDarkColor.r && mLightColor.g == mDarkColor.g && mLightColor.b == mDarkColor.b)
        {
            // Just use white.
            mLightColor = GColorWhite;
            mMediumColor = GColorLightGray;
        }
        else
        {
            // Medium color should be between the other colors.
            mMediumColor = GColorFromRGB((red + red2)     / 2,
                                         (green + green2) / 2,
                                         (blue + blue2)   / 2);
        }

        // Redraw the background.
        APP_LOG(APP_LOG_LEVEL_DEBUG, "inbox_received_handler. mark BG dirty");
        layer_mark_dirty(sBgLayer);
    }
#endif // PBL_COLOR
}
示例#2
0
// color bar drawing
static void layer_update_callback(Layer *me, GContext *ctx) {
  //APP_LOG(APP_LOG_LEVEL_DEBUG, "Getting chargeState = %d", chargeState);
  
  #ifdef PBL_COLOR
    //GColor color = GColorFromRGB(rand() % 255, rand() % 255, rand() % 255);
    GColor color = GColorFromRGB(255, 255, 255);
  
    if (chargeState >= 80) {
        color = GColorFromRGB(0, 255, 0);
    } else if (chargeState >= 50) {
        color = GColorFromRGB(0, 0, 255);
    } else if (chargeState >= 30) {
        color = GColorFromRGB(255, 255, 0);
    } else if (chargeState > -1) {
        color = GColorFromRGB(255, 0, 0);
    }    
    
    graphics_context_set_stroke_color(ctx, color);
    graphics_context_set_fill_color(ctx, color);
  #else
    graphics_context_set_stroke_color(ctx, GColorWhite);
    graphics_context_set_fill_color(ctx, GColorWhite);
  #endif
 
  graphics_fill_rect(ctx, GRect(x0 + 24, y0 + 88, 96, 4), 0, GCornersAll);
  
  // debug - force separator
  //time_sep = time_sep_square_bold;
  
  if (time_sep != time_sep_none) {
    int total_w = get_total_width(); // max is 0000 -> 4*31 + 20 = 144
    int x_min = ((144 - total_w) / 2) +  1 + get_width(h1) + 4 + get_width(h2) + 3;
    
    graphics_context_set_stroke_color(ctx, GColorWhite);
    graphics_context_set_fill_color(ctx, GColorWhite);

    if (time_sep == time_sep_square) {
      graphics_fill_rect(ctx, GRect(x0 + x_min, y0 + y0d + 37, 4, 4), 0, GCornersAll);
      graphics_fill_rect(ctx, GRect(x0 + x_min, y0 + y0d + 56, 4, 4), 0, GCornersAll);
    }
    else if (time_sep == time_sep_round) {
      graphics_fill_rect(ctx, GRect(x0 + x_min, y0 + y0d + 37, 4, 4), 1, GCornersAll);
      graphics_fill_rect(ctx, GRect(x0 + x_min, y0 + y0d + 56, 4, 4), 1, GCornersAll);
    }
    else if (time_sep == time_sep_square_bold) {
      graphics_fill_rect(ctx, GRect(x0 + x_min - 1, y0 + y0d + 36, 6, 6), 0, GCornersAll);
      graphics_fill_rect(ctx, GRect(x0 + x_min - 1, y0 + y0d + 55, 6, 6), 0, GCornersAll);
    }
    else if (time_sep == time_sep_round_bold) {
      graphics_fill_rect(ctx, GRect(x0 + x_min - 1, y0 + y0d + 36, 6, 6), 2, GCornersAll);
      graphics_fill_rect(ctx, GRect(x0 + x_min - 1, y0 + y0d + 55, 6, 6), 2, GCornersAll);
    }
  }
}
示例#3
0
static void inbox_received_handler(DictionaryIterator *iter, void *context) {
  
  APP_LOG(APP_LOG_LEVEL_DEBUG, "Inbox called!");
  // Color Scheme?
  Tuple *color_red_t = dict_find(iter, KEY_COLOR_RED);
  Tuple *color_green_t = dict_find(iter, KEY_COLOR_GREEN);
  Tuple *color_blue_t = dict_find(iter, KEY_COLOR_BLUE);
  if(color_red_t && color_green_t && color_blue_t) {
  APP_LOG(APP_LOG_LEVEL_DEBUG, "Got new Background RGB values!");
  // Apply the color, if available
  #if defined(PBL_BW)
    window_set_background_color(s_main_window, GColorWhite);
  #elif defined(PBL_COLOR)
    int red = color_red_t->value->int32;
    int green = color_green_t->value->int32;
    int blue = color_blue_t->value->int32;
  
    // Persist values
    persist_write_int(KEY_COLOR_RED, red);
    persist_write_int(KEY_COLOR_GREEN, green);
    persist_write_int(KEY_COLOR_BLUE, blue);
  
    GColor bg_color = GColorFromRGB(red, green, blue);
    window_set_background_color(s_main_window, bg_color);
    APP_LOG(APP_LOG_LEVEL_DEBUG, "Set new background color!");
  #endif
  }  
}
示例#4
0
static GColor GColorFromCMYK(int cyan, int magenta, int yellow, int black) {
  int red   = 255 - MIN(255, cyan    * (255 - black)) + black;
  int green = 255 - MIN(255, magenta * (255 - black)) + black;
  int blue  = 255 - MIN(255, yellow  * (255 - black)) + black;

  return GColorFromRGB(red, green, blue);
}
示例#5
0
static void DrawStepsBars(Layer *layer, GContext *ctx) 
{	
  graphics_context_set_compositing_mode(ctx, GCompOpSet);
	
	int MaxStepHis = GetMaxStepHistory();
	float BestSteps = 1;
	for(int index = MaxStepHis-1; index >= 0; --index)
	{
		int thisHis = GetStepHistory(index);
		
		if(thisHis > BestSteps)
			BestSteps = thisHis;
	}
	
	graphics_context_set_fill_color(ctx, GColorFromRGB(255,255,0));
	//APP_LOG(APP_LOG_LEVEL_DEBUG, "StepUpdate3");
	for(int index = 0; index < MaxStepHis; ++index)
	{
		float thisHis = (float)GetStepHistory(index);
		int zSize = (thisHis / BestSteps) * 18;
		if(zSize <= 0)
			zSize = 1;
		graphics_fill_rect(ctx, GRect(index * 3, 18 - zSize, 2, zSize), 0, GCornerNone);		
	}
}
示例#6
0
static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);

  s_text_layer = text_layer_create(GRect(0, 50, bounds.size.w, 100));
  text_layer_set_text(s_text_layer, "App configuration choices will be reflected here!");
  text_layer_set_font(s_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
  text_layer_set_text_alignment(s_text_layer, GTextAlignmentCenter);
  text_layer_set_background_color(s_text_layer, GColorClear);
  layer_add_child(window_layer, text_layer_get_layer(s_text_layer));

  // Read saved config 
  if(persist_read_bool(KEY_HIGH_CONTRAST)) {
    // Apply high contrast mode
    window_set_background_color(s_main_window, GColorBlack);
    text_layer_set_text_color(s_text_layer, GColorWhite);
  } else {
#ifdef PBL_SDK_2
    // Not available, use normal colors
#elif PBL_SDK_3
    // Use background color setting
    int red = persist_read_int(KEY_COLOR_RED);
    int green = persist_read_int(KEY_COLOR_GREEN);
    int blue = persist_read_int(KEY_COLOR_BLUE);

    GColor bg_color = GColorFromRGB(red, green, blue);
    window_set_background_color(s_main_window, bg_color);
    text_layer_set_text_color(s_text_layer, gcolor_is_dark(bg_color) ? GColorWhite : GColorBlack);    
#endif
  }
}
示例#7
0
文件: main.c 项目: RodgerLeblanc/H2WC
void set_color() {
//	APP_LOG(APP_LOG_LEVEL_DEBUG, "Top colors: %d %d %d", user_colors.top_color_red, user_colors.top_color_green, user_colors.top_color_blue);
//	APP_LOG(APP_LOG_LEVEL_DEBUG, "Bottom colors: %d %d %d", user_colors.bottom_color_red, user_colors.bottom_color_green, user_colors.bottom_color_blue);
//	APP_LOG(APP_LOG_LEVEL_DEBUG, "Time colors: %d %d %d", user_colors.time_color_red, user_colors.time_color_green, user_colors.time_color_blue);
	
  	if ((user_colors.top_color_red >= 0) && (user_colors.top_color_green >= 0) && (user_colors.top_color_blue >= 0)) {
    	// Apply the color if available
		#ifdef PBL_PLATFORM_APLITE
			if (window)
    			window_set_background_color(window, GColorBlack);
		#else
    		top_color = GColorFromRGB(user_colors.top_color_red, user_colors.top_color_green, user_colors.top_color_blue);
			if (window)
    			window_set_background_color(window, top_color);
		#endif
	}

  	if ((user_colors.bottom_color_red >= 0) && (user_colors.bottom_color_green >= 0) && (user_colors.bottom_color_blue >= 0)) {
		#ifdef PBL_PLATFORM_APLITE
			bottom_color = GColorWhite;
		#else
    		bottom_color = GColorFromRGB(user_colors.bottom_color_red, user_colors.bottom_color_green, user_colors.bottom_color_blue);
		#endif
		if (hub_layer)
			layer_mark_dirty(hub_layer);
  	}
	
  	if ((user_colors.time_color_red >= 0) && (user_colors.time_color_green >= 0) && (user_colors.time_color_blue >= 0)) {
    	// Apply the color if available
		#ifdef PBL_PLATFORM_APLITE
			if (time_layer)
    			text_layer_set_text_color(time_layer, GColorWhite);
			if (date_layer) 
    			text_layer_set_text_color(date_layer, GColorWhite);
		#else
    		time_color = GColorFromRGB(user_colors.time_color_red, user_colors.time_color_green, user_colors.time_color_blue);
			if (time_layer)
    			text_layer_set_text_color(time_layer, time_color);
			if (date_layer) {
    			text_layer_set_text_color(date_layer, time_color);
			}
		#endif
  	}
	
	savePersistentSettings();
}
示例#8
0
文件: config.c 项目: qanqan/TileTime
//GColorfromHEXSTR converts an hexstring to a GColor value.
GColor GColorFromHEXSTR(char const* hexstring) {
    unsigned int x;
    if (0 == htoi(hexstring,&x)) {
        unsigned int red = (x & 0xff0000) >> 16;
        unsigned int green = (x & 0x00ff00) >> 8;
        unsigned int blue = (x & 0x0000ff) >> 0;
        return GColorFromRGB(red,green,blue);
    }
示例#9
0
static void timewarp_update_proc(Layer *layer, GContext *ctx){
  // draw timewarp
  //APP_LOG(APP_LOG_LEVEL_INFO, "timewarp: GColorFromRGB(%d, %d, %d)", red, green, blue);

  GRect bounds = layer_get_bounds(layer);
  graphics_context_set_fill_color(ctx, GColorFromRGB(red, green, blue));
  graphics_fill_rect(ctx, bounds, battery_radius, GCornersAll);
}
示例#10
0
void Firework_Update(GBitmap *bitmap) {
  static int darken_count = 0;
  if (darken_count++ >= 4) {
    darken_count = 0;
    graphics_darken(bitmap);
  }
  // Draw fireworks
  for (int i = 0; i < FIREWORKS; i++) {
    FireworkStruct* firework = &prv_fireworks[i];
    GColor color;
    if (firework->hasExploded) {
      color = GColorFromRGB(
          sll2int(sllmul(int2sll(firework->red), firework->alpha)),
          sll2int(sllmul(int2sll(firework->green), firework->alpha)),
          sll2int(sllmul(int2sll(firework->blue), firework->alpha)));

      for (int p = 0; p < FIREWORK_PARTICLES; p++) {
        int xpos = sll2int(firework->x[p]);
        int ypos = sll2int(firework->y[p]);
        graphics_draw_pixel_color(bitmap, (GPoint){xpos, ypos}, color);
        graphics_draw_pixel_color(bitmap, (GPoint){xpos + 1, ypos}, color);
        graphics_draw_pixel_color(bitmap, (GPoint){xpos + 1, ypos + 1}, color);
        graphics_draw_pixel_color(bitmap, (GPoint){xpos, ypos + 1}, color);
      }

      Firework_Explode(&prv_fireworks[i]);
    } else {
      color = GColorFromRGB(255, 255, 0);
      int xpos = sll2int(firework->x[0]);
      int ypos = sll2int(firework->y[0]);
      graphics_draw_pixel_color(bitmap, (GPoint){xpos, ypos}, color);
      graphics_draw_pixel_color(bitmap, (GPoint){xpos + 1, ypos}, color);
      graphics_draw_pixel_color(bitmap, (GPoint){xpos + 1, ypos + 1}, color);
      graphics_draw_pixel_color(bitmap, (GPoint){xpos, ypos + 1}, color);

      Firework_Move(&prv_fireworks[i]);
    }
  }
}
示例#11
0
static void update_color(struct tm *tick_time) {
  
  char hex[] = "000000";
  
  if(clock_is_24h_style() == true) {
    //Use 2h hour format
    strftime(hex, sizeof("000000"), "%H%M%S", tick_time);
  } else {
    //Use 12 hour format
    strftime(hex, sizeof("000000"), "%I%M%S", tick_time);
  }
  
  r_val = (hex[0] - '0')*16+(hex[1] - '0');
  g_val = (hex[2] - '0')*16+(hex[3] - '0');
  b_val = (hex[4] - '0')*16+(hex[5] - '0');

  // Update main bg color
  window_set_background_color(windowMain, GColorFromRGB(r_val,g_val,b_val));
  
  // Update battery and date font colors to match main bg
  text_layer_set_text_color(s_date_layer, GColorFromRGB(r_val,g_val,b_val));
  text_layer_set_text_color(s_battery_layer, GColorFromRGB(r_val,g_val,b_val));
}
static void disc_init(Disc *disc) {
  static double next_radius = 3;

  GRect frame = window_frame;
  disc->pos.x = frame.size.w/2;
  disc->pos.y = frame.size.h/2;
  disc->vel.x = 0;
  disc->vel.y = 0;
  disc->radius = next_radius;
  disc->mass = disc_calc_mass(disc);
#ifdef PBL_COLOR
  disc->color = GColorFromRGB(rand() % 255, rand() % 255, rand() % 255);
#endif
  next_radius += 0.5;
}
示例#13
0
static void inbox_received_handler(DictionaryIterator *iter, void *context) {
  // High contrast selected?
  Tuple *high_contrast_t = dict_find(iter, KEY_HIGH_CONTRAST);
  if(high_contrast_t && high_contrast_t->value->int32 > 0) {
    // Change color scheme
    window_set_background_color(s_main_window, GColorBlack);
    text_layer_set_text_color(s_text_layer, GColorWhite);

    // Persist value
    persist_write_bool(KEY_HIGH_CONTRAST, true);
  } else {
    persist_write_bool(KEY_HIGH_CONTRAST, false);
  }

  // Color scheme?
  Tuple *color_red_t = dict_find(iter, KEY_COLOR_RED);
  Tuple *color_green_t = dict_find(iter, KEY_COLOR_GREEN);
  Tuple *color_blue_t = dict_find(iter, KEY_COLOR_BLUE);
  if(color_red_t && color_green_t && color_blue_t) {
    // Apply the color if available
#ifdef PBL_SDK_2
    window_set_background_color(s_main_window, GColorWhite);
    text_layer_set_text_color(s_text_layer, GColorBlack);
#elif PBL_SDK_3 
    int red = color_red_t->value->int32;
    int green = color_green_t->value->int32;
    int blue = color_blue_t->value->int32;

    // Persist values
    persist_write_int(KEY_COLOR_RED, red);
    persist_write_int(KEY_COLOR_GREEN, green);
    persist_write_int(KEY_COLOR_BLUE, blue);

    GColor bg_color = GColorFromRGB(red, green, blue);
    window_set_background_color(s_main_window, bg_color);
    text_layer_set_text_color(s_text_layer, gcolor_is_dark(bg_color) ? GColorWhite : GColorBlack);    
#endif
  }
}
示例#14
0
static void inbox_received_callback(DictionaryIterator *iter, void *context) {
  #if PBL_SDK_3 
  int red, green, blue;
  Tuple *color_red_t, *color_green_t, *color_blue_t;
  // Background color?
  color_red_t = dict_find(iter, KEY_BGCOLOR_R);
  color_green_t = dict_find(iter, KEY_BGCOLOR_G);
  color_blue_t = dict_find(iter, KEY_BGCOLOR_B);
  if(color_red_t && color_green_t && color_blue_t) {
    // Apply the color if available
      red = color_red_t->value->int32;
      green = color_green_t->value->int32;
      blue = color_blue_t->value->int32;
  
      // Persist values
      persist_write_int(KEY_BGCOLOR_R, red);
      persist_write_int(KEY_BGCOLOR_G, green);
      persist_write_int(KEY_BGCOLOR_B, blue);
  
      GColor bg_color = GColorFromRGB(red, green, blue);
      window_set_background_color(s_main_window, bg_color);
  }
  // Time color?
  color_red_t = dict_find(iter, KEY_TIME_COLOR_R);
  color_green_t = dict_find(iter, KEY_TIME_COLOR_G);
  color_blue_t = dict_find(iter, KEY_TIME_COLOR_B);
  if(color_red_t && color_green_t && color_blue_t) {
    // Apply the color if available
      red = color_red_t->value->int32;
      green = color_green_t->value->int32;
      blue = color_blue_t->value->int32;
  
      // Persist values
      persist_write_int(KEY_TIME_COLOR_R, red);
      persist_write_int(KEY_TIME_COLOR_G, green);
      persist_write_int(KEY_TIME_COLOR_B, blue);
  
      GColor time_color = GColorFromRGB(red, green, blue);
      text_layer_set_text_color(s_time_layer, time_color); 
  }
  // Secondary color?
  color_red_t = dict_find(iter, KEY_SECONDARY_COLOR_R);
  color_green_t = dict_find(iter, KEY_SECONDARY_COLOR_G);
  color_blue_t = dict_find(iter, KEY_SECONDARY_COLOR_B);
  if(color_red_t && color_green_t && color_blue_t) {
    // Apply the color if available
      red = color_red_t->value->int32;
      green = color_green_t->value->int32;
      blue = color_blue_t->value->int32;
  
      // Persist values
      persist_write_int(KEY_SECONDARY_COLOR_R, red);
      persist_write_int(KEY_SECONDARY_COLOR_G, green);
      persist_write_int(KEY_SECONDARY_COLOR_B, blue);
  
      secondary_color = GColorFromRGB(red, green, blue);
      text_layer_set_text_color(s_date_layer, secondary_color); 
      text_layer_set_text_color(s_day_layer, secondary_color); 
      text_layer_set_text_color(s_ampm_layer, secondary_color);
  }
  #endif
  // Get bluetooth enabled
  Tuple *bluetooth_icon_enabled_t;
  bluetooth_icon_enabled_t = dict_find(iter, KEY_BLUETOOTH_ICON_ENABLED);
  if (bluetooth_icon_enabled_t) {
    int enabled = bluetooth_icon_enabled_t->value->uint8;
    bluetoothIconEnabled = enabled != 0;
    bt_update();
    persist_write_int(KEY_BLUETOOTH_ICON_ENABLED, enabled);
  }
}
示例#15
0
static void main_window_load(Window *window) {
  // Create time TextLayer
  s_time_layer = text_layer_create(GRect(0, 51, 144, 100));
  s_date_layer = text_layer_create(GRect(0, 101, 144, 80));
  s_day_layer = text_layer_create(GRect(4, 3, 144, 80));
  s_ampm_layer = text_layer_create(GRect(127, 85, 30, 30));
  text_layer_set_background_color(s_time_layer, GColorClear);
  text_layer_set_background_color(s_date_layer, GColorClear);
  text_layer_set_background_color(s_day_layer, GColorClear);
  text_layer_set_background_color(s_ampm_layer, GColorClear);
  
  // Get stored colors
  #ifdef PBL_COLOR
    int red, green, blue;
    if (persist_exists(KEY_BGCOLOR_R)) {
      red = persist_read_int(KEY_BGCOLOR_R);
      green = persist_read_int(KEY_BGCOLOR_G);
      blue = persist_read_int(KEY_BGCOLOR_B);
      GColor bg_color = GColorFromRGB(red, green, blue);
      window_set_background_color(s_main_window, bg_color); 
    } 
    else {
      window_set_background_color(s_main_window, GColorBlack); 
    }
    if (persist_exists(KEY_TIME_COLOR_R)) {
      red = persist_read_int(KEY_TIME_COLOR_R);
      green = persist_read_int(KEY_TIME_COLOR_G);
      blue = persist_read_int(KEY_TIME_COLOR_B);  
      GColor time_color = GColorFromRGB(red, green, blue);
      text_layer_set_text_color(s_time_layer, time_color);  
    } 
    else {
      text_layer_set_text_color(s_time_layer, GColorWhite);  
    }
  if (persist_exists(KEY_SECONDARY_COLOR_R)) {
      red = persist_read_int(KEY_SECONDARY_COLOR_R);
      green = persist_read_int(KEY_SECONDARY_COLOR_G);
      blue = persist_read_int(KEY_SECONDARY_COLOR_B);     
      secondary_color = GColorFromRGB(red, green, blue);
      text_layer_set_text_color(s_date_layer, secondary_color); 
      text_layer_set_text_color(s_day_layer, secondary_color); 
      text_layer_set_text_color(s_ampm_layer, secondary_color);
    } 
    else {
        // Set secondary colors
        text_layer_set_text_color(s_date_layer, GColorVividCerulean);
        text_layer_set_text_color(s_day_layer, GColorVividCerulean);
        text_layer_set_text_color(s_ampm_layer, GColorVividCerulean);
    }
  #endif
    
  // Get stored BT var
  if (persist_exists(KEY_BLUETOOTH_ICON_ENABLED)) {
    int enabled = persist_read_int(KEY_BLUETOOTH_ICON_ENABLED);
    bluetoothIconEnabled = enabled != 0;
  }
  else {
    bluetoothIconEnabled = true;
  }
    
  // Create bluetooth icon layer and register it
  bluetooth_icon_layer = layer_create(GRect(129, 141, 144, 168));
  layer_set_update_proc(bluetooth_icon_layer, bluetooth_icon_update_proc);
  
  // Improve the layout to be more like a watchface
  text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);
  text_layer_set_text_alignment(s_date_layer, GTextAlignmentCenter);
  text_layer_set_text_alignment(s_day_layer, GTextAlignmentLeft);

  // 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_date_layer));
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_day_layer));
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_ampm_layer));
  layer_add_child(window_get_root_layer(window), bluetooth_icon_layer);
  
  // Make sure the time is displayed from the start
  update_time();
  
  // Show current connection state
  bt_handler(bluetooth_connection_service_peek());
  
  // Create GFont
  s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_TIME_46));
  s_date_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_DATE_20));
  s_ampm_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_AMPM_10));
  
  // Apply to TextLayer
  text_layer_set_font(s_time_layer, s_time_font);
  text_layer_set_font(s_date_layer, s_date_font);
  text_layer_set_font(s_day_layer, s_date_font);
  text_layer_set_font(s_ampm_layer, s_ampm_font);
}
示例#16
0
static void main_window_load(Window *window) {
	
#if defined(PBL_BW)
    window_set_background_color(s_main_window, GColorWhite);
#elif defined(PBLE_COLOR)
  int red = persist_read_int(KEY_COLOR_RED);
  int green = persist_read_int(KEY_COLOR_GREEN);
  int blue = persist_read_int(KEY_COLOR_BLUE);
  
  GColor bg_color = GColorFromRGB(red, green, blue);
  window_set_background_color(s_main_window, bg_color);
#endif
  
  // Get the Window's root layer and the bounds
  GRect bounds = layer_get_bounds(window_get_root_layer(window));
  
  // Load the image
  #ifdef PBL_COLOR
    logo_bitmap = gbitmap_create_with_resource(RESOURCE_ID_LOGO);
  #else
    logo_bitmap = gbitmap_create_with_resource(RESOURCE_ID_LOGO_BW);
  #endif

// Create a BitmapLayer
logo_layer = bitmap_layer_create(bounds);

// Set the bitmap and center it
bitmap_layer_set_bitmap(logo_layer, logo_bitmap);
bitmap_layer_set_alignment(logo_layer, GAlignCenter);
bitmap_layer_set_compositing_mode(logo_layer, GCompOpSet);

// Add to the Window
layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(logo_layer));
	
	// Set font hour TextLayer
	s_hour_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_SYNC_BOLD_50));
	// Set font minutes TextLayer
	s_minutes_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_SYNC_BOLD_50));
	
	//Hour Layer
  #if defined(PBL_RECT) 
	  s_hour_layer = text_layer_create(GRect (0, 30, 144, 54));
  #elif defined(PBL_ROUND)
    s_hour_layer = text_layer_create(GRect (0, 35, 180, 54));
  #endif
	text_layer_set_background_color(s_hour_layer, GColorClear);
  text_layer_set_text_color(s_hour_layer, GColorBlack);
	text_layer_set_text(s_hour_layer, "00");
	
	//Minute Layer
	#if defined(PBL_RECT) 
    s_minutes_layer = text_layer_create(GRect (0, 74, 144, 54));
  #elif defined(PBL_ROUND) 
    s_minutes_layer = text_layer_create(GRect (0, 79, 180, 54));
  #endif
	text_layer_set_background_color(s_minutes_layer, GColorClear);
	text_layer_set_text_color(s_minutes_layer, GColorBlack);
	text_layer_set_text(s_minutes_layer, "00");
  
	//Make it look more like a watch
	text_layer_set_font(s_hour_layer, s_hour_font);
	text_layer_set_font(s_minutes_layer, s_minutes_font);
	text_layer_set_text_alignment(s_hour_layer, GTextAlignmentCenter);
	text_layer_set_text_alignment(s_minutes_layer, GTextAlignmentCenter);
	
	//Add hour, miuntes, and weather layers as child windows to the Window's root layer
	layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_hour_layer));
	layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_minutes_layer));
}
示例#17
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());
}
示例#18
0
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);

	// Create Layers
	s_time_textLayer = text_layer_create(
	    GRect(0, PBL_IF_ROUND_ELSE(58, 52), bounds.size.w, 50));
	s_weather_textLayer = text_layer_create(
		GRect(PBL_IF_ROUND_ELSE(65, 5), PBL_IF_ROUND_ELSE(0, 2), PBL_IF_ROUND_ELSE(70, bounds.size.w), 50));
	s_dayOfWeek_textLayer = text_layer_create(
		GRect(PBL_IF_ROUND_ELSE(30, -5), PBL_IF_ROUND_ELSE(25, 2), bounds.size.w, 50));
	s_date_textLayer = text_layer_create(
		GRect(0, PBL_IF_ROUND_ELSE(105, 115), PBL_IF_ROUND_ELSE(bounds.size.w-31, bounds.size.w-3), 50));
	// UI Layers
	s_ui_top = text_layer_create(
		GRect(0,0,bounds.size.w,PBL_IF_ROUND_ELSE(70,52)));
	s_ui_bottom = text_layer_create(
		GRect(0,PBL_IF_ROUND_ELSE(110,117),bounds.size.w,100));

	// Setup Background colors
	text_layer_set_background_color(s_time_textLayer, 		GColorClear);
	text_layer_set_background_color(s_weather_textLayer, 	GColorClear);
	text_layer_set_background_color(s_dayOfWeek_textLayer,	GColorClear);
	text_layer_set_background_color(s_date_textLayer,		GColorClear);

	// Setup Text Colors
	text_layer_set_text_color(s_time_textLayer, 			GColorBlack);
	text_layer_set_text_color(s_weather_textLayer,			GColorWhite);
	text_layer_set_text_color(s_dayOfWeek_textLayer,		GColorWhite);
	text_layer_set_text_color(s_date_textLayer,				GColorWhite);

	// Setup Font Styles
	time_font = fonts_get_system_font(FONT_KEY_ROBOTO_BOLD_SUBSET_49);
	nonTime_font = fonts_get_system_font(FONT_KEY_BITHAM_42_LIGHT);
	text_layer_set_font(s_time_textLayer, time_font);
	// text_layer_set_font(s_time_textLayer, s_time_gfont);
	text_layer_set_font(s_weather_textLayer, nonTime_font);
	text_layer_set_font(s_dayOfWeek_textLayer, nonTime_font);
	text_layer_set_font(s_date_textLayer, nonTime_font);

	// Format Text alignments
	text_layer_set_text_alignment(s_time_textLayer, 		GTextAlignmentCenter);
	text_layer_set_text_alignment(s_weather_textLayer,		GTextAlignmentRight);
	text_layer_set_text_alignment(s_dayOfWeek_textLayer,	GTextAlignmentLeft);
	text_layer_set_text_alignment(s_date_textLayer,			GTextAlignmentRight);

	// Optionally, Add Text to the layer as a placeholder
	text_layer_set_text(s_weather_textLayer, "...");
		
	// Perform Color Changes!
	#if defined(PBL_BW)
		text_layer_set_background_color(s_ui_top,				GColorBlack);
		text_layer_set_background_color(s_ui_bottom,			GColorBlack);
  	#elif defined(PBL_COLOR)
	    // Accent Color Setting
	    int red_accent = persist_read_int(KEY_COLOR_RED_ACCENT);
	    int green_accent = persist_read_int(KEY_COLOR_GREEN_ACCENT);
	    int blue_accent = persist_read_int(KEY_COLOR_BLUE_ACCENT);

	    // APP_LOG(APP_LOG_LEVEL_INFO, "color is %d". bg_color_accent);
		// APP_LOG(APP_LOG_LEVEL_INFO, "accent color is rgb %d %d %d", red_accent, green_accent,blue_accent);
	    if(red_accent >= 0 && green_accent >= 0 && blue_accent >= 0) {
	    	GColor bg_color_accent = GColorFromRGB(red_accent, green_accent, blue_accent);
	    	
	    	text_layer_set_background_color(s_ui_top, bg_color_accent);
	    	text_layer_set_background_color(s_ui_bottom, bg_color_accent);
	    	text_layer_set_text_color(s_dayOfWeek_textLayer, gcolor_is_dark(bg_color_accent) ? GColorWhite : GColorBlack);
	    	text_layer_set_text_color(s_date_textLayer, gcolor_is_dark(bg_color_accent) ? GColorWhite : GColorBlack);
	    	text_layer_set_text_color(s_weather_textLayer, gcolor_is_dark(bg_color_accent) ? GColorWhite : GColorBlack);
	    }
	    // Time Color Setting
	    int red_time = persist_read_int(KEY_COLOR_RED_TIME);
	    int green_time = persist_read_int(KEY_COLOR_GREEN_TIME);
	    int blue_time = persist_read_int(KEY_COLOR_BLUE_TIME);

	    if(red_time >= 0 && green_time >= 0 && blue_time >= 0) {
	    	GColor bg_color_time = GColorFromRGB(red_time, green_time, blue_time);
	    	
	    	window_set_background_color(s_main_window, bg_color_time);
	    	text_layer_set_text_color(s_time_textLayer, gcolor_is_dark(bg_color_time) ? GColorWhite : GColorBlack);
	    }
    #endif

	// UI
	layer_add_child(window_layer, text_layer_get_layer(s_ui_top));
	layer_add_child(window_layer, text_layer_get_layer(s_ui_bottom));
	// Add Layers as Children to window.
	layer_add_child(window_layer, text_layer_get_layer(s_time_textLayer));
	layer_add_child(window_layer, text_layer_get_layer(s_weather_textLayer));
	layer_add_child(window_layer, text_layer_get_layer(s_dayOfWeek_textLayer));
	layer_add_child(window_layer, text_layer_get_layer(s_date_textLayer));
	// Don't forget to destroy all layers below.
}
示例#19
0
static void time_update_proc(Layer *layer, GContext *ctx)
{
    time_t now = time(NULL);
    struct tm *t = localtime(&now);

    bool saving = false;
    bool pm = t->tm_hour >= 12;
    if (s_ps_start_time-1 > s_ps_end_time)
    {
        if (t->tm_hour >= s_ps_start_time-1 || t->tm_hour <= s_ps_end_time)
            saving = true;
    }
    else
    {
        if (t->tm_hour >= s_ps_start_time-1 && t->tm_hour <= s_ps_end_time)
            saving = true;
    }

    int first = t->tm_sec - 30;
    if (first < -1) first = -1;
    int second = t->tm_sec;
    if (second > 30) second = 30;

    switch (s_second_bar)
    {
    case SETTING_SECOND_FILL_COLOR:
        first = 30;
        second = 30;
        break;
    case SETTING_SECOND_FILL_BLACK:
        first = -1;
        second = -1;
        break;
    case SETTING_SECOND_FILL_COLOR_WHEN_SAVING:
        if (saving)
        {
            first = 30;
            second = 30;
        }
        break;
    case SETTING_SECOND_FILL_BLACK_WHEN_SAVING:
        if (saving)
        {
            first = -1;
            second = -1;
        }
        break;
    case SETTING_SECOND_AS_AM_PM:
        second = pm ? -1 : 30;
        first = pm ? 30 : -1;
        break;
    }

    if (s_ps_start_time == 0) saving = false;

    // min
    char *buffer = malloc(3);

    for (int i = -2; i < 5; i++)
    {
        snprintf(buffer, 3, "%02d", (t->tm_min + i + 60)%60);
        if (i == 0) graphics_context_set_text_color(ctx, GColorFromRGB(s_minute_r, s_minute_g, s_minute_b));
        else graphics_context_set_text_color(ctx, GColorDarkGray);

        graphics_draw_text(ctx, buffer, fonts_get_system_font(FONT_KEY_LECO_32_BOLD_NUMBERS), GRect(75-i*39+(saving?0:(39*t->tm_sec/60)),74,40,38), GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
    }

    // sec
    if (s_second_rate > 0 && !saving)
    {
        for (int i = -2; i < 5; i++)
        {
            float progress = 0;
            if (s_second_rate > 1)
            {
                progress = s_msecond/1000.0;
            }
            if (t->tm_sec != s_last_second)
            {
                s_msecond = 0;
                s_last_second = t->tm_sec;
            }
            snprintf(buffer, 3, "%02d", (t->tm_sec + i + 60)%60);
            if (i == 0) graphics_context_set_text_color(ctx, GColorFromRGB(s_second_r, s_second_g, s_second_b));
            else graphics_context_set_text_color(ctx, GColorDarkGray);

            graphics_draw_text(ctx, buffer, fonts_get_system_font(FONT_KEY_LECO_20_BOLD_NUMBERS), GRect(75-i*26+(26*progress),120,40,20), GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
        }
        graphics_context_set_stroke_color(ctx, GColorDarkGray);
        graphics_draw_line(ctx, GPoint(0,121), GPoint(144,121));
        graphics_draw_line(ctx, GPoint(0,143), GPoint(144,143));
    }

    // hour
    graphics_context_set_fill_color(ctx, GColorBlack);
    graphics_fill_rect(ctx, GRect(23,12,46,142), 0, GCornerNone);

    graphics_context_set_fill_color(ctx, GColorBlack);
    graphics_fill_rect(ctx, GRect(23,12,46,142), 0, GCornerNone);

    for (int i = -4; i < 6; i++)
    {
        if (s_12hour)
            snprintf(buffer, 3, "%02d", (t->tm_hour + i == 12) ? 12 : (t->tm_hour + i + 12)%12);
        else
            snprintf(buffer, 3, "%02d", (t->tm_hour + i + 24)%24);
        if (i == 0) graphics_context_set_text_color(ctx, GColorFromRGB(s_hour_r, s_hour_g, s_hour_b));
        else graphics_context_set_text_color(ctx, GColorDarkGray);
        graphics_draw_text(ctx, buffer, fonts_get_system_font(FONT_KEY_LECO_36_BOLD_NUMBERS), GRect(21,65-i*27+(saving?0:(27*t->tm_min/60)),50,36), GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
    }

    if (s_second_bar != SETTING_SECOND_AS_AM_PM && s_12hour)
    {
        graphics_context_set_fill_color(ctx, GColorBlack);
        graphics_fill_rect(ctx, GRect(12,80,5,26), 0, GCornerNone);

        graphics_context_set_fill_color(ctx, GColorFromRGB(s_hour_r, s_hour_g, s_hour_b));
        if (pm)
            graphics_fill_rect(ctx, GRect(12,93,5,13), 0, GCornerNone);
        else
            graphics_fill_rect(ctx, GRect(12,80,5,13), 0, GCornerNone);
    }

    free(buffer);

    // SEC
    graphics_context_set_stroke_color(ctx, GColorFromRGB(s_second_bar_r, s_second_bar_g, s_second_bar_b));
    graphics_draw_line(ctx, GPoint(29,61), GPoint(29+second,61));
    graphics_draw_line(ctx, GPoint(34,116), GPoint(34+first,116));

    graphics_context_set_stroke_color(ctx, GColorBlack);
    graphics_draw_line(ctx, GPoint(30+second,61), GPoint(60,61));
    graphics_draw_line(ctx, GPoint(35+first,116), GPoint(65,116));
}
示例#20
0
文件: main.c 项目: NovaGL/simpleface
//////////////////////////////////////////////////// Main Visuals /////////////////////////////
static void main_window_load(Window *window) {
  
  window = window_create();
  window_stack_push(window, true);
	window_set_background_color(window, GColorBlack);
  time_color = GColorFromRGB(0, 170, 255);
  
	Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);
  
  // position battery and bluetooth icons depending on screen
  #ifdef PBL_ROUND
    int topright = bounds.size.w / 2;
  #else
    int topright = bounds.size.w - (bounds.size.w / 4);  
  #endif
    
  // Create GFonts
  s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_Font_Prototype_42));
  s_date_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_Font_Prototype_20));
   
    
 // Create TIME TextLayer and set colour
  s_time_layer = text_layer_create(GRect(0, 40, bounds.size.w, bounds.size.h));
  text_layer_set_background_color(s_time_layer, GColorClear);
  // Read saved config
  #if defined(PBL_BW)
    text_layer_set_text_color(s_time_layer, GColorWhite);
  #elif defined(PBL_COLOR)
    // Use background color setting
    red = persist_read_int(KEY_COLOR_RED);
    green = persist_read_int(KEY_COLOR_GREEN);
    blue = persist_read_int(KEY_COLOR_BLUE);
    time_color = GColorFromRGB(red, green, blue);    
    text_layer_set_text_color(s_time_layer, time_color);
  #endif
  text_layer_set_text(s_time_layer, "00:00");
  text_layer_set_font(s_time_layer, s_time_font);
  text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);
  layer_add_child(window_layer, text_layer_get_layer(s_time_layer));
  
  
  // Create DATE TextLayer
  s_date_layer = text_layer_create(GRect(0, 115, bounds.size.w, bounds.size.h));
  text_layer_set_text_color(s_date_layer, GColorFromHEX(0xFFFFFF));
  text_layer_set_background_color(s_date_layer, GColorClear);
  text_layer_set_text_alignment(s_date_layer, GTextAlignmentCenter);
  text_layer_set_text(s_date_layer, "Sept 23");
  text_layer_set_font(s_date_layer, s_date_font);
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_date_layer));

  // Create Divider
  GRect line_frame = GRect(20, 104, bounds.size.w -40, 2);
  line_layer = layer_create(line_frame);
  layer_set_update_proc(line_layer, draw_line);
	layer_add_child(window_layer, line_layer);
  
  
  // Create the BitmapLayer to display the Bluetooth icon
  s_bt_icon_layer = bitmap_layer_create(GRect(topright - 12, bounds.origin.x + 10, 11, 10));
  bitmap_layer_set_bitmap(s_bt_icon_layer, s_bt_icon_bitmap);
  layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(s_bt_icon_layer));
 
  
   // Create the BitmapLayer to display the Battery
  s_batt_icon_layer = bitmap_layer_create(GRect(topright + 5, bounds.origin.x + 10, 16, 10));
  bitmap_layer_set_bitmap(s_batt_icon_layer, s_batt_icon_bitmap);
  layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(s_batt_icon_layer));
  
  // Initialize the display
  update_time();
  
  battery_callback(battery_state_service_peek());

  bluetooth_callback(connection_service_peek_pebble_app_connection());
}
示例#21
0
static void inbox_received_callback(DictionaryIterator *iterator, void *context) {
	// Weather -------------------------------------------------------------------
	static char temperature_buffer[8];
	static char weather_layer_buffer[8];
	int temperature = 0;
	Tuple *temp_tuple = dict_find(iterator, KEY_TEMPERATURE);
	static int temp_in_c;
	if( temp_tuple ) {
		temp_in_c = (int)temp_tuple->value->int32;
		if( persist_read_bool(KEY_WEATHER_UNIT) == true ) {
			temperature = convert_to_fahrenheit(temp_in_c);
		} else {
			temperature = temp_in_c;
		}
	}
	Tuple *unit_tuple = dict_find(iterator, KEY_WEATHER_UNIT);
	if( unit_tuple && unit_tuple->value->int8 > 0 ) {
		// USE CELCIOUS UNITS
		persist_write_bool(KEY_WEATHER_UNIT, false);
		APP_LOG(APP_LOG_LEVEL_INFO, "Callback: Units are C\n");
		temperature = temp_in_c;
	} else if( unit_tuple && unit_tuple->value->int8 <= 0 ) {
		// USEFARIENHEIT
		persist_write_bool(KEY_WEATHER_UNIT, true);
		APP_LOG(APP_LOG_LEVEL_INFO, "Callback: Units are F\n");
		temperature = convert_to_fahrenheit(temp_in_c);
	}
	snprintf(temperature_buffer, sizeof(temperature_buffer), "%d", temperature);
	snprintf(weather_layer_buffer, sizeof(weather_layer_buffer), "%s°", temperature_buffer);
	text_layer_set_text(s_weather_textLayer, weather_layer_buffer);
	// End Weather ---------------------------------------------------------------

	// Configuration -------------------------------------------------------------
	// Color ===================
	#if defined(PBL_COLOR)
	  Tuple *color_red_accent = dict_find(iterator, KEY_COLOR_RED_ACCENT);
	  Tuple *color_green_accent = dict_find(iterator, KEY_COLOR_GREEN_ACCENT);
	  Tuple *color_blue_accent = dict_find(iterator, KEY_COLOR_BLUE_ACCENT);
	  Tuple *color_red_time = dict_find(iterator, KEY_COLOR_RED_TIME);
	  Tuple *color_green_time = dict_find(iterator, KEY_COLOR_GREEN_TIME);
	  Tuple *color_blue_time = dict_find(iterator, KEY_COLOR_BLUE_TIME);
	  if(color_red_accent && color_green_accent && color_blue_accent) {
	    // Apply the color if available
	  
	    int red_accent = color_red_accent->value->int32;
	    int green_accent = color_green_accent->value->int32;
	    int blue_accent = color_blue_accent->value->int32;

	    // Persist values
	    persist_write_int(KEY_COLOR_RED_ACCENT, red_accent);
	    persist_write_int(KEY_COLOR_GREEN_ACCENT, green_accent);
	    persist_write_int(KEY_COLOR_BLUE_ACCENT, blue_accent);

	    GColor bg_color_accent = GColorFromRGB(red_accent, green_accent, blue_accent);
	    text_layer_set_background_color(s_ui_top, bg_color_accent);
	    text_layer_set_background_color(s_ui_bottom, bg_color_accent);

	    text_layer_set_text_color(s_dayOfWeek_textLayer, gcolor_is_dark(bg_color_accent) ? GColorWhite : GColorBlack);
	    text_layer_set_text_color(s_date_textLayer, gcolor_is_dark(bg_color_accent) ? GColorWhite : GColorBlack);
	    text_layer_set_text_color(s_weather_textLayer, gcolor_is_dark(bg_color_accent) ? GColorWhite : GColorBlack);
	  }
	  
	  if(color_red_time && color_green_time && color_blue_time) {
	    // Apply the color if available
	    int red_time = color_red_time->value->int32;
	    int green_time = color_green_time->value->int32;
	    int blue_time = color_blue_time->value->int32;

	    // Persist values
	    persist_write_int(KEY_COLOR_RED_TIME, red_time);
	    persist_write_int(KEY_COLOR_GREEN_TIME, green_time);
	    persist_write_int(KEY_COLOR_BLUE_TIME, blue_time);

	    GColor bg_color_time = GColorFromRGB(red_time, green_time, blue_time);
	    window_set_background_color(s_main_window, bg_color_time);

	    text_layer_set_text_color(s_time_textLayer, gcolor_is_dark(bg_color_time) ? GColorWhite : GColorBlack);
	  }
	 #endif
	// End Color ===============

	// Date Format
	static char temporary_date_holder_callback[32];
	Tuple *date_format_tuple = dict_find(iterator, KEY_DATE_FORMAT);
	if( date_format_tuple ) {
		APP_LOG(APP_LOG_LEVEL_INFO, "Callback: Date Tuple Worked!\n");
		APP_LOG(APP_LOG_LEVEL_INFO, "Callback: Value Recieved from Date Tuple: %d\n", (int)date_format_tuple->value->int8);
	} else {
		APP_LOG(APP_LOG_LEVEL_INFO, "Callback: Date Tuple Failed\n");
	}
	if( date_format_tuple && date_format_tuple->value->int8 == 49 ) {
		snprintf(temporary_date_holder_callback, sizeof(temporary_date_holder_callback), "%s.%s", day_tickTime, month_tickTime);
		// snprintf(dateWithoutYear, sizeof(dateWithoutYear), "\0");
		snprintf(ddmm_dateWithoutYear, sizeof(ddmm_dateWithoutYear), "%s", temporary_date_holder_callback);
		persist_write_int(KEY_DATE_FORMAT, 1);
		text_layer_set_text(s_date_textLayer, temporary_date_holder_callback);
		APP_LOG(APP_LOG_LEVEL_INFO, "Callback: Date was updated as DD-MM 1\n");
	} else if( date_format_tuple && date_format_tuple->value->int8 == 48 ){
		snprintf(temporary_date_holder_callback, sizeof(temporary_date_holder_callback), "%s.%s", month_tickTime, day_tickTime);
		// snprintf(dateWithoutYear, sizeof(dateWithoutYear), "\0");
		snprintf(dateWithoutYear, sizeof(dateWithoutYear), "%s", temporary_date_holder_callback);
		persist_write_int(KEY_DATE_FORMAT, 0);
		text_layer_set_text(s_date_textLayer, temporary_date_holder_callback);
		APP_LOG(APP_LOG_LEVEL_INFO, "Callback: Date was updated as MM-DD 1\n");
	}

	// Add year or not
	static char temporary_dateWithoutYear_holder_update[32];
	Tuple *year_is_displayed_tuple = dict_find(iterator, KEY_DATE_ADD_YEAR);
	if( year_is_displayed_tuple && year_is_displayed_tuple->value->int8 > 0 ) {
		if( persist_read_int(KEY_DATE_FORMAT) == 1 ) {
			strcpy(temporary_dateWithoutYear_holder_update, ddmm_dateWithoutYear);
		}
		else if( persist_read_int(KEY_DATE_FORMAT) == 0 ) {
			strcpy(temporary_dateWithoutYear_holder_update, dateWithoutYear);
		}
		strcat(temporary_dateWithoutYear_holder_update, year_tickTime);
		persist_write_bool(KEY_DATE_ADD_YEAR, true);
		text_layer_set_text(s_date_textLayer, temporary_dateWithoutYear_holder_update);
	} else if( year_is_displayed_tuple && year_is_displayed_tuple->value->int8 <= 0 ) {
		persist_write_bool(KEY_DATE_ADD_YEAR, false);
		if( persist_read_int(KEY_DATE_FORMAT) == 1 )
			text_layer_set_text(s_date_textLayer, ddmm_dateWithoutYear);
		else
			text_layer_set_text(s_date_textLayer, dateWithoutYear);
	}

	// Language Handing On Callback			
	Tuple *lang_is_eng_tuple = dict_find(iterator, KEY_LANGUAGE);
	if( lang_is_eng_tuple ) {
		APP_LOG(APP_LOG_LEVEL_INFO, "Callback: lang Tuple Worked!\n");
		APP_LOG(APP_LOG_LEVEL_INFO, "Callback: Value Recieved from lang Tuple: %d\n", (int)lang_is_eng_tuple->value->int8);
	} else {
		APP_LOG(APP_LOG_LEVEL_INFO, "Callback: lang Tuple Failed\n");
	}
	if( lang_is_eng_tuple && lang_is_eng_tuple->value->int8 == 49 ) {
		// Time to convert this to spanish
		int dayOfWeekInt = atoi(dayOfWeekNumber_tickTime);
		static char temporary_day_of_week_holder_callback[8];
		switch(dayOfWeekInt) {
			case 0:
				snprintf(temporary_day_of_week_holder_callback, sizeof(temporary_day_of_week_holder_callback), "%s", "Dom");
			break;
			case 1:
				snprintf(temporary_day_of_week_holder_callback, sizeof(temporary_day_of_week_holder_callback), "%s", "Lun");
			break;
			case 2:
				snprintf(temporary_day_of_week_holder_callback, sizeof(temporary_day_of_week_holder_callback), "%s", "Mar");
			break;
			case 3:
				snprintf(temporary_day_of_week_holder_callback, sizeof(temporary_day_of_week_holder_callback), "%s", "Mie");
			break;
			case 4:
				snprintf(temporary_day_of_week_holder_callback, sizeof(temporary_day_of_week_holder_callback), "%s", "Jue");
			break;
			case 5:
				snprintf(temporary_day_of_week_holder_callback, sizeof(temporary_day_of_week_holder_callback), "%s", "Vie");
			break;
			case 6:
				snprintf(temporary_day_of_week_holder_callback, sizeof(temporary_day_of_week_holder_callback), "%s", "Sab");
			break;
			default:
				text_layer_set_text(s_dayOfWeek_textLayer, temporary_day_of_week_holder_callback);
			break;
		}
		persist_write_int(KEY_LANGUAGE, 1);
		text_layer_set_text(s_dayOfWeek_textLayer, temporary_day_of_week_holder_callback);
	} else if( lang_is_eng_tuple && lang_is_eng_tuple->value->int8 == 48 ) {
		persist_write_int(KEY_LANGUAGE, 0);
		// English
		text_layer_set_text(s_dayOfWeek_textLayer, engDayOfWeek_tickTime);
	}
	// End Configuration ---------------------------------------------------------
}