Esempio n. 1
0
void Weather_setConditions(int conditionCode, bool isNight, int forecastCondition) {

  uint32_t currentWeatherIcon = getConditionIcon(conditionCode);
  uint32_t forecastWeatherIcon = getConditionIcon(forecastCondition);

  // ok, now load the new icon:
  #ifdef PBL_COLOR
    GDrawCommandImage* oldImage = Weather_currentWeatherIcon;
    Weather_currentWeatherIcon = gdraw_command_image_create_with_resource(currentWeatherIcon);
    gdraw_command_image_destroy(oldImage);

    oldImage = Weather_forecastWeatherIcon;
    Weather_forecastWeatherIcon = gdraw_command_image_create_with_resource(forecastWeatherIcon);
    gdraw_command_image_destroy(oldImage);
  #else
    GBitmap* oldImage = Weather_currentWeatherIcon;
    Weather_currentWeatherIcon = gbitmap_create_with_resource(currentWeatherIcon);
    gbitmap_destroy(oldImage);

    oldImage = Weather_forecastWeatherIcon;
    Weather_forecastWeatherIcon = gbitmap_create_with_resource(forecastWeatherIcon);
    gbitmap_destroy(oldImage);
  #endif

  Weather_weatherInfo.currentIconResourceID = currentWeatherIcon;
  Weather_weatherForecast.forecastIconResourceID = forecastWeatherIcon;
}
Esempio n. 2
0
void Weather_deinit() {
  // save weather data to persistent storage
  Weather_saveData();

  // free memory
  #ifdef PBL_COLOR
    gdraw_command_image_destroy(Weather_currentWeatherIcon);
    gdraw_command_image_destroy(Weather_forecastWeatherIcon);
  #else
    gbitmap_destroy(Weather_currentWeatherIcon);
    gbitmap_destroy(Weather_forecastWeatherIcon);
  #endif
}
Esempio n. 3
0
void Weather_deinit() {
  // save weather data to persistent storage
  persist_write_data(WEATHERINFO_PERSIST_KEY, &Weather_weatherInfo, sizeof(WeatherInfo));
  
  // free memory
  gdraw_command_image_destroy(Weather_currentWeatherIcon);
}
Esempio n. 4
0
void render_calendar_background(Layer *layer, GContext *ctx)
{
    // Kill the old struct!
    GDrawCommandImage* oldImage = calendar_background;
    calendar_background = gdraw_command_image_create_with_resource(RESOURCE_ID_CALENDAR_BACKGROUND);
    gdraw_command_image_destroy(oldImage);
    gdraw_command_image_draw(ctx, calendar_background, GPoint(114, 4));
}
Esempio n. 5
0
static void main_window_unload(Window *window) {
  for(int i = 0; i < 4; i++) {
    ClockDigit_destruct(&clockDigits[i]);
  }

  layer_destroy(sidebarLayer);

  #ifdef PBL_COLOR
    gdraw_command_image_destroy(dateImage);
    gdraw_command_image_destroy(disconnectImage);
    gdraw_command_image_destroy(batteryImage);
  #else
    gbitmap_destroy(dateImage);
    gbitmap_destroy(disconnectImage);
    gbitmap_destroy(batteryImage);
  #endif
}
Esempio n. 6
0
void Weather_setCondition(int conditionCode, bool isNight) {
  int generalCondition = conditionCode / 100;
  
  uint32_t iconToLoad;
  
  switch(generalCondition) {
    case 2: //thunderstorm
      iconToLoad = RESOURCE_ID_WEATHER_THUNDERSTORM;
      break;
    case 3: //drizzle
      iconToLoad = RESOURCE_ID_WEATHER_LIGHT_RAIN;
      break;
    case 5: //rain
      if(conditionCode == 500) {
        iconToLoad = RESOURCE_ID_WEATHER_LIGHT_RAIN;
      } else if(conditionCode < 505) {
        iconToLoad = RESOURCE_ID_WEATHER_HEAVY_RAIN;
      } else if(conditionCode == 511) {
        iconToLoad = RESOURCE_ID_WEATHER_RAINING_AND_SNOWING;
      } else {
        iconToLoad = RESOURCE_ID_WEATHER_LIGHT_RAIN;
      }
      break;
    case 6: //snow
      if(conditionCode == 600 || conditionCode == 620) {
        iconToLoad = RESOURCE_ID_WEATHER_LIGHT_SNOW;
      } else if(conditionCode > 610 && conditionCode < 620) {
        iconToLoad = RESOURCE_ID_WEATHER_RAINING_AND_SNOWING;
      } else {
        iconToLoad = RESOURCE_ID_WEATHER_HEAVY_SNOW;
      }
      break;
    case 7: // fog, dust, etc
      iconToLoad = RESOURCE_ID_WEATHER_CLOUDY;
      break;
    case 8: // clouds
      if(conditionCode == 800) {
        iconToLoad = (!isNight) ? RESOURCE_ID_WEATHER_CLEAR_DAY : RESOURCE_ID_WEATHER_CLEAR_NIGHT;
      } else if(conditionCode < 803) {
        iconToLoad = (!isNight) ? RESOURCE_ID_WEATHER_PARTLY_CLOUDY : RESOURCE_ID_WEATHER_PARTLY_CLOUDY_NIGHT;
      } else {
        iconToLoad = RESOURCE_ID_WEATHER_CLOUDY;
      }
      break;
    default: // hack: let's just treat the rest as clear
      iconToLoad = (!isNight) ? RESOURCE_ID_WEATHER_CLEAR_DAY : RESOURCE_ID_WEATHER_CLEAR_NIGHT;
      break;
  }
   
  // ok, now load the new icon:
  GDrawCommandImage* oldImage = Weather_currentWeatherIcon;
  Weather_currentWeatherIcon = gdraw_command_image_create_with_resource(iconToLoad);
  gdraw_command_image_destroy(oldImage);
  Weather_weatherInfo.currentIconResourceID = iconToLoad;
}
Esempio n. 7
0
void unload_weather(Window *window) {
	text_layer_destroy(s_weather_layer);
	text_layer_destroy(s_weather_temp_min);
	text_layer_destroy(s_weather_temp_max);

	bitmap_layer_destroy(s_weather_icon_layer);
  gbitmap_destroy(s_weather_icon_bitmap);

	layer_destroy(s_weather_icon_draw_layer);
	gdraw_command_image_destroy(s_weather_cmd_img);
}
Esempio n. 8
0
void SidebarWidgets_deinit() {
  gdraw_command_image_destroy(dateImage);
  gdraw_command_image_destroy(disconnectImage);
  gdraw_command_image_destroy(batteryImage);
  gdraw_command_image_destroy(batteryChargeImage);

  #ifdef PBL_HEALTH
    gdraw_command_image_destroy(stepsImage);
    gdraw_command_image_destroy(sleepImage);
  #endif
}
Esempio n. 9
0
void SidebarWidgets_deinit() {
  gdraw_command_image_destroy(dateImage);
  gdraw_command_image_destroy(disconnectImage);
  gdraw_command_image_destroy(batteryImage);
  gdraw_command_image_destroy(batteryChargeImage);
}
Esempio n. 10
0
static void weather_display_refresh() {
	
	APP_LOG(APP_LOG_LEVEL_DEBUG_VERBOSE, "weather display refresh");
	
  // Store incoming information
  static char temperature_buffer[8];
	static char temperature_min_buffer[8];
	static char temperature_max_buffer[8];
  static char conditions_buffer[32];
  static char weather_layer_buffer[32];
	
	if (weather_data.fetch_time == 0) {
		text_layer_set_text(s_weather_layer, "Loading...");
		return;
	}
	
	snprintf(temperature_buffer, sizeof(temperature_buffer), "%d°", (int)weather_data.temperature);
	snprintf(temperature_min_buffer, sizeof(temperature_min_buffer), "%d°", (int)weather_data.temperature_min);
	snprintf(temperature_max_buffer, sizeof(temperature_max_buffer), "%d°", (int)weather_data.temperature_max);
	snprintf(conditions_buffer, sizeof(conditions_buffer), "%d", (int)weather_data.condition_id);
		
  // Assemble full string and display
  snprintf(weather_layer_buffer, sizeof(weather_layer_buffer), "%s, %s", temperature_buffer, conditions_buffer);
	text_layer_set_text(s_weather_layer, weather_layer_buffer);
	text_layer_set_text(s_weather_temp_min, temperature_min_buffer);
	text_layer_set_text(s_weather_temp_max, temperature_max_buffer);
	


	
	gdraw_command_image_destroy(s_weather_cmd_img);
	
	switch (weather_data.condition_id) {
		//Group 2xx: Thunderstorm
		case 200:
		case 201:
		case 202:
		case 210:
		case 211:
		case 212:
		case 221:
		case 230:
		case 231:
		case 232:
			s_weather_cmd_img = gdraw_command_image_create_with_resource(RESOURCE_ID_RAINING_AND_SNOWING);
			break;
				
		//Group 3xx: Drizzle
		case 300:
		case 301:
		case 302:
		case 310:
		case 311:
		case 312:
		case 313:
		case 314:
		case 321:
				s_weather_cmd_img = gdraw_command_image_create_with_resource(RESOURCE_ID_HEAVY_RAIN);
				break;
		
		//Group 5xx: Rain
		case 500:
				s_weather_cmd_img = gdraw_command_image_create_with_resource(RESOURCE_ID_LIGHT_RAIN);
				break;
		case 501:
		case 502:
		case 503:
		case 504:
				s_weather_cmd_img = gdraw_command_image_create_with_resource(RESOURCE_ID_HEAVY_RAIN);
				break;
		case 511:
				s_weather_cmd_img = gdraw_command_image_create_with_resource(RESOURCE_ID_HEAVY_SNOW);
				break;
		case 520:
		case 521:
		case 522:
		case 531:
				s_weather_cmd_img = gdraw_command_image_create_with_resource(RESOURCE_ID_HEAVY_RAIN);
				break;
		
		//Group 6xx: Snow
		case 600:
				s_weather_cmd_img = gdraw_command_image_create_with_resource(RESOURCE_ID_LIGHT_SNOW);
				break;
		case 601:
		case 602:
		case 611:
		case 612:
		case 615:
		case 616:
		case 620:
		case 621:
		case 622:
				s_weather_cmd_img = gdraw_command_image_create_with_resource(RESOURCE_ID_HEAVY_SNOW);
				break;
		
		//Group 7xx: Atmosphere
		case 701:
		case 711:
		case 721:
		case 731:
		case 741:
		case 751:
		case 761:
		case 762:
		case 771:
		case 781:
			break;
		
		//Group 800: Clear
		case 800:
				s_weather_cmd_img = gdraw_command_image_create_with_resource(RESOURCE_ID_TIMELINE_SUN);
				break;
		
		//Group 80x: Clouds
		case 801:
		case 802:
				s_weather_cmd_img = gdraw_command_image_create_with_resource(RESOURCE_ID_PARTLY_CLOUDY);
				break;
		case 803:
		case 804:
				s_weather_cmd_img = gdraw_command_image_create_with_resource(RESOURCE_ID_CLOUDY_DAY);
				break;
		
		//Group 90x: Extreme
		case 900:
		case 901:
		case 902:
		case 903:
		case 904:
		case 905:
		case 906:
			break;
				
		//Group 9xx: Additional
		case 951:
		case 952:
		case 953:
		case 954:
		case 955:
		case 956:
		case 957:
		case 958:
		case 959:
		case 960:
		case 961:
		case 962:
			break;
	
		default:
			break;
		
	}
	
	if (!s_weather_cmd_img) {
		s_weather_cmd_img = gdraw_command_image_create_with_resource(RESOURCE_ID_GENERIC_WARNING);	
	}
		
	
	layer_mark_dirty(s_weather_icon_draw_layer);
	
}