Ejemplo n.º 1
0
void widget_gpos_draw(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t flags)
{
	uint8_t lh = widget_label_P(PSTR("GPos"), x, y);

	if (fc.gps_data.valid)
	{
		widget_value_txt2((char *)fc.gps_data.cache_gui_latitude,
				(char *)fc.gps_data.cache_gui_longtitude, x, y + lh, w, h - lh);
	}
	else
	{
		char tmp[4];
		sprintf_P(tmp, PSTR("---"));
		widget_value_int(tmp, x, y + lh, w, h - lh);
	}


}
Ejemplo n.º 2
0
void widget_gpos_draw(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t flags)
{
	uint8_t lh = widget_label_P(PSTR("GPos"), x, y);

	char tmp1[16];
	char tmp2[16];

	float decimal;
	float deg;
	float min;
	float sec;
	uint8_t c;

	if (fc.gps_data.valid)
	{
		switch (config.connectivity.gps_format_flags & GPS_FORMAT_MASK)
		{
			case(GPS_DDdddddd):
				sprintf_P(tmp1, PSTR("%+02.6f"), fc.gps_data.latitude);
				sprintf_P(tmp2, PSTR("%+03.6f"), fc.gps_data.longtitude);
			break;
			case(GPS_DDMMmmm):
				c = (fc.gps_data.latitude < 0) ? 'S' : 'N';
				decimal = abs(fc.gps_data.latitude);
				deg = floor(decimal);
				min = (decimal - deg) * 60;
				sprintf_P(tmp1, PSTR("%02.0f*%02.3f%c"), deg, min, c);

				c = (fc.gps_data.longtitude < 0) ? 'W' : 'E';
				decimal = abs(fc.gps_data.longtitude);
				deg = floor(decimal);
				min = (decimal - deg) * 60;
				sprintf_P(tmp2, PSTR("%03.0f*%02.3f%c"), deg, min, c);
			break;
			case(GPS_DDMMSS):
				c = (fc.gps_data.latitude < 0) ? 'S' : 'N';
				decimal = abs(fc.gps_data.latitude);
				deg = floor(decimal);
				min = floor((decimal - deg) * 60);
				sec = floor((decimal - deg - min / 60) * 3600);
				sprintf_P(tmp1, PSTR("%02.0f*%02.0f'%02.0f\"%c"), deg, min, sec, c);

				c = (fc.gps_data.longtitude < 0) ? 'W' : 'E';
				decimal = abs(fc.gps_data.longtitude);
				deg = floor(decimal);
				min = floor((decimal - deg) * 60);
				sec = floor((decimal - deg - min / 60) * 3600);
				sprintf_P(tmp2, PSTR("%03.0f*%02.0f'%02.0f\"%c"), deg, min, sec, c);

			break;
		}

		widget_value_txt2(tmp1, tmp2, x, y + lh, w, h - lh);
	}
	else
	{
		sprintf_P(tmp1, PSTR("---"));
		widget_value_int(tmp1, x, y + lh, w, h - lh);
	}


}