void fill_weather_forecast_temperature(control_t *p_detail_cont, weather_detail_t *p_data)
{
  control_t *p_temp_cont = NULL;
  control_t *p_temp_item = NULL;
  u8 asc_str[64] = {0};
	//u16 tmpf[2] = {0x2109, 0};
  u16 uni_str[64] = {0};
	//u8 string_asc[8] = {0};
  int i;
  int low, high, t;
  char* fmt;
  fmt = sg_c_or_f ? "%dбуF - %dбуF" : "%dбуC - %dбуC";
  p_temp_cont = ctrl_get_child_by_id(p_detail_cont, IDC_WEATHER_TEMP_CONT);
  for(i = 0; i < 5; i++)
  {
    p_temp_item = ctrl_get_child_by_id(p_temp_cont, IDC_WEATHER_TEMP_ITEM + i);

		//u_itoa(p_data->forecast[i].low, string_asc, 10);
		//str_asc2uni(string_asc, low);

		//u_itoa(p_data->forecast[i].high, string_asc, 10);
		//str_asc2uni(string_asc, high);

    t = atoi(p_data->para.w_yahoo.forecast[i].low);
    sg_temperature[i].temp_cf[0].low = t;
    sg_temperature[i].temp_cf[1].low = celsius_to_fahr(t);
    t = atoi(p_data->para.w_yahoo.forecast[i].high);
    sg_temperature[i].temp_cf[0].high = t;
    sg_temperature[i].temp_cf[1].high = celsius_to_fahr(t);

    low = sg_temperature[i].temp_cf[sg_c_or_f].low;
    high = sg_temperature[i].temp_cf[sg_c_or_f].high;

    snprintf(asc_str, sizeof(asc_str), fmt, low, high);

    gb2312_2_utf16le(asc_str, strlen(asc_str), (char*)uni_str, sizeof(uni_str)-1);
    text_set_content_by_unistr(p_temp_item, uni_str);
  }
}
Exemplo n.º 2
0
int main() {
	float celsius;
	int lower, upper, step;
	
	lower = 0;
	upper = 300;
	step = 20;
	
	printf("Celsius-Fahrenheit table\n");
	
	celsius = lower;
	while (celsius <= upper) {
		printf("%3.0f %6.1f\n", celsius, celsius_to_fahr(celsius));
		celsius = celsius + step;
	}
	
	return 0;
}
void fill_weather_detail_city(control_t *p_detail_cont, weather_detail_t *p_data)
{
  control_t *p_city_cont = NULL;
  control_t *p_tmp_cont = NULL;
  u8 city[100] = {0};
  char* fmt;
  u8 asc_str[32];
  u16 uni_str[32];
  int t;
  p_city_cont = ctrl_get_child_by_id(p_detail_cont, IDC_WEATHER_CITY);
  sprintf(city, "%s/%s/%s", p_data->para.w_yahoo.location.city, p_data->para.w_yahoo.location.region, p_data->para.w_yahoo.location.country);
  text_set_content_by_ascstr(p_city_cont, city);
  p_tmp_cont = ctrl_get_child_by_id(p_detail_cont, IDC_WEATHER_CITY_TEMP1);
  fmt = sg_c_or_f ? "%dбуF" : "%dбуC";
  t = atoi(p_data->para.w_yahoo.wind.chill);
  sg_cur_temp[0] = t;
  sg_cur_temp[1] = celsius_to_fahr(t);
  
  snprintf(asc_str, sizeof(asc_str), fmt, sg_cur_temp[sg_c_or_f]);
  gb2312_2_utf16le(asc_str, strlen(asc_str), (char*)uni_str, sizeof(uni_str)-1);
  text_set_content_by_unistr(p_tmp_cont, uni_str);
  return;
}
Exemplo n.º 4
0
int main(){
	celsius_to_fahr();
	return 0;
}