コード例 #1
0
ファイル: screen_model.c プロジェクト: auuuux/multigcs
void screen_model (ESContext *esContext) {
#ifndef SDLGL
	ESMatrix modelview;
	UserData *userData = esContext->userData;
#endif
	draw_title(esContext, "Model");

	char tmp_str[100];
	int n = 0;

#ifndef SDLGL
	esMatrixLoadIdentity(&modelview);
	esMatrixMultiply(&userData->mvpMatrix, &modelview, &userData->perspective);
	esMatrixMultiply(&userData->mvpMatrix2, &modelview, &userData->perspective);
#endif

	if (clientmode == 1) {

		draw_text_button(esContext, "clientmode", VIEW_MODE_MODEL, "Client-Mode / No Config", FONT_PINK, 0.0, 0.0, 0.002, 0.1, ALIGN_CENTER, ALIGN_TOP, model_null, (float)n);

		return;
	}

	if (select_teletype == 1) {
		for (n = 0; n < TELETYPE_LAST; n++) {
			draw_text_button(esContext, teletypes[n], VIEW_MODE_MODEL, teletypes[n], FONT_WHITE, -1.25, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_teletype_set, (float)n);
		}
		return;
	}

	draw_text_button(esContext, "Model", VIEW_MODE_MODEL, "Model", FONT_WHITE, -1.25, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_null, (float)n);
	draw_line_f3(esContext, -1.3, -0.8 + n * 0.12 + 0.1, 0.002, 1.25, -0.8 + n * 0.12 + 0.1, 0.002, 255, 255, 0, 128);
	n++;

	draw_text_button(esContext, "model_load", VIEW_MODE_MODEL, "[LOAD]", FONT_WHITE, 1.1, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_RIGHT, ALIGN_TOP, model_load, 0);

	draw_text_button(esContext, "model_load2", VIEW_MODE_MODEL, "NAME:", FONT_WHITE, -1.1, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_name_edit, 0);
	if (ModelData[ModelActive].name[0] == 0) {
		strcpy(ModelData[ModelActive].name, "model1");
	}
	sprintf(tmp_str, "%s", ModelData[ModelActive].name);
	draw_text_button(esContext, "model_name_edit", VIEW_MODE_MODEL, tmp_str, FONT_WHITE, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_name_edit, 0);
	n++;
	draw_text_button(esContext, "model_type", VIEW_MODE_MODEL, "TYPE:", FONT_WHITE, -1.1, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_dronetype_change, 0);

	if (ModelData[ModelActive].dronetype > 26) {
		sprintf(tmp_str, "UNKNOWN: %i", ModelData[ModelActive].dronetype);
		draw_text_button(esContext, "dronetype_change", VIEW_MODE_MODEL, tmp_str, FONT_WHITE, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_dronetype_change, 0);
	} else {
		draw_text_button(esContext, "dronetype_change", VIEW_MODE_MODEL, dronetypes[ModelData[ModelActive].dronetype], FONT_WHITE, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_dronetype_change, 0);
	}


#ifdef SDLGL
//	get_background_model(ModelActive, tmp_str);

if (ModelData[ModelActive].dronetype > 26) {
	sprintf(tmp_str, "%s/obj3d/_.obj", BASE_DIR);
} else {
	sprintf(tmp_str, "%s/obj3d/%s.obj", BASE_DIR, dronetypes[ModelData[ModelActive].dronetype]);
}
	if (file_exists(tmp_str) != 0) {
		static uint8_t startup = 0;
		static float rotate = 0.0;
		rotate += 0.5;
		if (startup == 0 || strcmp(obj3d_dronetype.name, tmp_str) != 0) {
			startup = 1;
			if (obj3d_dronetype.faces_num != 0) {
				object3d_free(&obj3d_dronetype);
			}
			object3d_load(&obj3d_dronetype, tmp_str);
		}
		glPushMatrix();
		glTranslatef(0.5, (-0.8 + n * 0.12 + 0.2) * -1.0, -2.0);
		if (ModelData[ModelActive].heartbeat == 0) {
			glRotatef(rotate, 0.2, 1.0, 0.3);
		} else {
			glRotatef(-90.0, 1.0, 0.0, 0.0);
//			glRotatef(ModelData[ModelActive].yaw, 0.0, 0.0, -1.0);
			glRotatef(ModelData[ModelActive].pitch, 1.0, 0.0, 0.0);
			glRotatef(ModelData[ModelActive].roll, 0.0, 1.0, 0.0);
		}
		glScalef(0.25, 0.25, 0.25);
		object3d_draw(&obj3d_dronetype, 255, 255, 255, 100);
		glPopMatrix();
	} else {
		sprintf(tmp_str, "%s/textures/%s.png", BASE_DIR, dronetypes[ModelData[ModelActive].dronetype]);
		draw_image_f3(esContext, -1.1 + 1.0, -0.8 + n * 0.12 - 0.02, -1.1 + 1.0 + 0.1, -0.8 + n * 0.12 + 0.1 - 0.02, 0.002, tmp_str);
	}
#else
	sprintf(tmp_str, "%s/textures/%s.png", BASE_DIR, dronetypes[ModelData[ModelActive].dronetype]);
	draw_image_f3(esContext, -1.1 + 1.0, -0.8 + n * 0.12 - 0.02, -1.1 + 1.0 + 0.1, -0.8 + n * 0.12 + 0.1 - 0.02, 0.002, tmp_str);
#endif


	n++;

	draw_text_button(esContext, "model_image_change", VIEW_MODE_MODEL, "IMAGE:", FONT_WHITE, -1.1, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_image_change, 0);
	draw_image_f3(esContext, -1.1 + 0.3, -0.8 + n * 0.12 - 0.02, -1.2 + 0.3 + 0.4, -0.8 + n * 0.12 + 0.3 - 0.02, 0.002, ModelData[ModelActive].image);
	n++;

	n++;
	draw_text_button(esContext, "Telemetry", VIEW_MODE_MODEL, "Telemetry", FONT_WHITE, -1.25, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_null, (float)n);
	draw_line_f3(esContext, -1.3, -0.8 + n * 0.12 + 0.1, 0.002, 1.25, -0.8 + n * 0.12 + 0.1, 0.002, 255, 255, 0, 128);
	n++;

	draw_text_button(esContext, "model_load3", VIEW_MODE_MODEL, "TYPE:", FONT_WHITE, -1.1, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_teletype_change, 0);
	draw_text_button(esContext, "model_teletype_change", VIEW_MODE_MODEL, teletypes[ModelData[ModelActive].teletype], FONT_WHITE, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_teletype_change, 0);
	n++;


#ifdef SDLGL
	if (ModelData[ModelActive].pilottype == MAV_AUTOPILOT_PIXHAWK) {
		sprintf(tmp_str, "%s/obj3d/%s.obj", BASE_DIR, "PIXHAWK");
	} else {
		sprintf(tmp_str, "%s/obj3d/%s.obj", BASE_DIR, teletypes[ModelData[ModelActive].teletype]);
	}
	if (file_exists(tmp_str) != 0) {
		static uint8_t startup = 0;
		static float rotate = 0.0;
		rotate += 0.4;
		if (startup == 0 || strcmp(obj3d_teletype.name, tmp_str) != 0) {
			startup = 1;
			if (obj3d_teletype.faces_num != 0) {
				object3d_free(&obj3d_teletype);
			}
			object3d_load(&obj3d_teletype, tmp_str);
		}
		glTranslatef(0.5, -0.15, -2.0);
		glRotatef(rotate, -1.0, -1.0, 0.2);
		glScalef(0.25, 0.25, 0.25);
		object3d_draw(&obj3d_teletype, 255, 255, 255, 100);
		glMatrixMode( GL_MODELVIEW );
		glLoadIdentity();
	}
#endif


	draw_text_f3(esContext, -1.1, -0.8 + n * 0.12, 0.002, 0.06, 0.06, FONT_WHITE, "DEVICE:");
	if (ModelData[ModelActive].telemetry_port[0] == 0) {
//		strcpy(ModelData[ModelActive].telemetry_port, "/dev/rfcomm0");
	}
	sprintf(tmp_str, "%s [SELECT]", ModelData[ModelActive].telemetry_port);
	draw_text_button(esContext, "device_select", VIEW_MODE_MODEL, tmp_str, FONT_WHITE, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_device_change, 0);
	n++;

	if (strcmp(ModelData[ModelActive].telemetry_port, "TCP") == 0) {
		draw_text_f3(esContext, -1.1, -0.8 + n * 0.12, 0.002, 0.06, 0.06, FONT_WHITE, "IP:");
		sprintf(tmp_str, "%s [CHANGE]", ModelData[ModelActive].netip);
		draw_text_button(esContext, "model_ip_edit", VIEW_MODE_MODEL, tmp_str, FONT_WHITE, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_ip_edit, n);
		n++;
		draw_text_f3(esContext, -1.1, -0.8 + n * 0.12, 0.002, 0.06, 0.06, FONT_WHITE, "PORT:");
		sprintf(tmp_str, "%i [CHANGE]", ModelData[ModelActive].netport);
		draw_text_button(esContext, "model_port_edit", VIEW_MODE_MODEL, tmp_str, FONT_WHITE, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_port_edit, n);
		n++;
	} else if (strcmp(ModelData[ModelActive].telemetry_port, "UDP") == 0) {
		if (ModelData[ModelActive].teletype == TELETYPE_ARDUPILOT) {
			draw_text_f3(esContext, -1.1, -0.8 + n * 0.12, 0.002, 0.06, 0.06, FONT_WHITE, "USEID:");
			sprintf(tmp_str, "%i [CHANGE]", ModelData[ModelActive].use_deviceid);
			if (ModelData[ModelActive].use_deviceid == 1) {
				draw_text_button(esContext, "rc_useid", VIEW_MODE_MODEL, tmp_str, FONT_GREEN, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_use_deviceid_change, n);
				n++;
				draw_text_f3(esContext, -1.1, -0.8 + n * 0.12, 0.002, 0.06, 0.06, FONT_WHITE, "SysID:");
				sprintf(tmp_str, "%i [CHANGE]", ModelData[ModelActive].mavlink_sysid);
				draw_text_button(esContext, "rc_mavlink_sysid", VIEW_MODE_MODEL, tmp_str, FONT_WHITE, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_mavlink_sysid_change, n);
			} else {
				draw_text_button(esContext, "rc_useid", VIEW_MODE_MODEL, tmp_str, FONT_WHITE, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_use_deviceid_change, n);
			}
		}
		n++;
	} else {
		draw_text_f3(esContext, -1.1, -0.8 + n * 0.12, 0.002, 0.06, 0.06, FONT_WHITE, "BAUD:");
		sprintf(tmp_str, "%i [CHANGE]", ModelData[ModelActive].telemetry_baud);
		draw_text_button(esContext, "rc_baud", VIEW_MODE_MODEL, tmp_str, FONT_WHITE, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_baud_change, n);
		n++;

		draw_text_f3(esContext, -1.1, -0.8 + n * 0.12, 0.002, 0.06, 0.06, FONT_WHITE, "USEID:");
		sprintf(tmp_str, "%i [CHANGE]", ModelData[ModelActive].use_deviceid);
		if (ModelData[ModelActive].use_deviceid == 1) {
			draw_text_button(esContext, "rc_useid", VIEW_MODE_MODEL, tmp_str, FONT_GREEN, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_use_deviceid_change, n);
			n++;
			draw_text_f3(esContext, -1.1, -0.8 + n * 0.12, 0.002, 0.06, 0.06, FONT_WHITE, "ID:");
			draw_text_button(esContext, "rc_deviceid", VIEW_MODE_MODEL, ModelData[ModelActive].deviceid, FONT_WHITE, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_null, n);
		} else {
			draw_text_button(esContext, "rc_useid", VIEW_MODE_MODEL, tmp_str, FONT_WHITE, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_use_deviceid_change, n);
		}
		n++;
	}

	draw_text_f3(esContext, -1.1, -0.8 + n * 0.12, 0.002, 0.06, 0.06, FONT_WHITE, "FORWARD:");
	if (ModelData[ModelActive].mavlink_forward == 0) {
		sprintf(tmp_str, "NO [CHANGE]");
	} else if (ModelData[ModelActive].mavlink_forward == 1) {
		sprintf(tmp_str, "READ/WRITE [CHANGE]");
	} else if (ModelData[ModelActive].mavlink_forward == 2) {
		sprintf(tmp_str, "WRITE PROTECT [CHANGE]");
	}

	draw_text_button(esContext, "mavlink_forward_change", VIEW_MODE_MODEL, tmp_str, FONT_WHITE, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_mavlink_forward_change, n);
	n++;

	if (strstr(ModelData[ModelActive].telemetry_port, "rfcomm") > 0) {
		n++;
		draw_text_f3(esContext, -1.1 + 0.1, -0.8 + n * 0.12, 0.002, 0.06, 0.06, FONT_WHITE, "BLUETOOTH_DEVICE:");
		if (ModelData[ModelActive].telebtaddr[0] == 0) {
			strcpy(ModelData[ModelActive].telebtaddr, "00:00:00:00:00:00");
		}
		sprintf(tmp_str, "%s [RESCAN]", ModelData[ModelActive].telebtaddr);
		draw_text_button(esContext, "bt_scan", VIEW_MODE_MODEL, tmp_str, FONT_WHITE, -1.1 + 0.8, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_null, n);

		n++;
		draw_text_f3(esContext, -1.1 + 0.1, -0.8 + n * 0.12, 0.002, 0.06, 0.06, FONT_WHITE, "BLUETOOTH_PIN:");
		if (ModelData[ModelActive].telebtpin[0] == 0) {
			strcpy(ModelData[ModelActive].telebtpin, "1234");
		}
		sprintf(tmp_str, "%s [CHANGE]", ModelData[ModelActive].telebtpin);
		draw_text_button(esContext, "bt_pin", VIEW_MODE_MODEL, tmp_str, FONT_WHITE, -1.1 + 0.8, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_null, n);
	} else {
		n++;
		n++;
	}

	n = 13;
	draw_text_button(esContext, "model_reconnect", VIEW_MODE_MODEL, "[RECONNECT]", FONT_WHITE, 0.0, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_CENTER, ALIGN_TOP, model_reconnect, n);
	n++;
	draw_text_button(esContext, "model_save", VIEW_MODE_MODEL, "[SAVE]", FONT_WHITE, 0.0, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_CENTER, ALIGN_TOP, model_save, n);

	screen_keyboard(esContext);
	screen_filesystem(esContext);
	screen_device(esContext);
	screen_baud(esContext);
}
コード例 #2
0
ファイル: screen_system.c プロジェクト: OpenGelo/multigcs
void screen_system(ESContext *esContext) {
#ifndef SDLGL
	ESMatrix modelview;
	UserData *userData = esContext->userData;
#endif
#ifndef WINDOWS
	FILE *cmd = NULL;
#endif
	char buffer[1025];
	static char ip[30];
	static char bcast[30];
	static char mask[30];
	static char hostname[30];
	static char dnsserver[30];
	static char gateway[30];
	uint32_t now_time = time(0);
	static uint32_t last_time = 0;
#ifndef SDLGL
	esMatrixLoadIdentity(&modelview);
	esMatrixMultiply(&userData->mvpMatrix, &modelview, &userData->perspective);
#endif
	draw_title(esContext, "System");
	if (last_time != now_time) {
		strcpy(ip, "---.---.---.---");
		strcpy(bcast, "---.---.---.---");
		strcpy(mask, "---.---.---.---");
		strcpy(dnsserver, "---.---.---.---");
		strcpy(gateway, "---.---.---.---");
#ifndef WINDOWS
#ifndef ANDROID
#ifdef OSX
		if ((cmd = popen("LANG=C ifconfig en0 | grep \"inet \" | sed \"s|[a-zA-Z:]||g\"", "r")) != NULL) {
			while (!feof(cmd)) {
				if (fgets(buffer, 1024, cmd) != NULL) {
					sscanf(buffer, "%s %s %s", (char *)&ip, (char *)&bcast, (char *)&mask);
					//			SDL_Log("## %s, %s, %s ##\n", ip, bcast, mask);
				}
			}
			pclose(cmd);
		}
#else
		if ((cmd = popen("LANG=C ifconfig eth0 | grep \"inet addr:\" | sed \"s|[a-zA-Z:]||g\"", "r")) != NULL) {
			while (!feof(cmd)) {
				if (fgets(buffer, 1024, cmd) != NULL) {
					sscanf(buffer, "%s %s %s", (char *)&ip, (char *)&bcast, (char *)&mask);
					//			SDL_Log("## %s, %s, %s ##\n", ip, bcast, mask);
				}
			}
			pclose(cmd);
		}
		if ((cmd = popen("grep \"^nameserver \" /etc/resolv.conf | cut -d\" \" -f2", "r")) != NULL) {
			while (!feof(cmd)) {
				if (fgets(dnsserver, 1024, cmd) != NULL) {
				}
			}
		}
		pclose(cmd);
		if ((cmd = popen("route -n | grep \" 0.0.0.0.*255.255.255.0 \" | cut -d\" \" -f1", "r")) != NULL) {
			while (!feof(cmd)) {
				if (fgets(gateway, 1024, cmd) != NULL) {
				}
			}
		}
		pclose(cmd);
#endif
		if ((cmd = popen("hostname", "r")) != NULL) {
			while (!feof(cmd)) {
				if (fgets(hostname, 1024, cmd) != NULL) {
				}
			}
		}
		pclose(cmd);
#endif
#endif
		last_time = now_time;
	}
	sprintf(buffer, "Name  : %s", hostname);
	draw_text_f(esContext, -0.5, -0.8 + 1 * 0.1, 0.06, 0.06, FONT_GREEN, buffer);
	sprintf(buffer, "IP    : %s", ip);
	draw_text_f(esContext, -0.5, -0.8 + 3 * 0.1, 0.06, 0.06, FONT_GREEN, buffer);
	sprintf(buffer, "BCAST : %s", bcast);
	draw_text_f(esContext, -0.5, -0.8 + 4 * 0.1, 0.06, 0.06, FONT_GREEN, buffer);
	sprintf(buffer, "MASK  : %s", mask);
	draw_text_f(esContext, -0.5, -0.8 + 5 * 0.1, 0.06, 0.06, FONT_GREEN, buffer);
	sprintf(buffer, "DNS   : %s", dnsserver);
	draw_text_f(esContext, -0.5, -0.8 + 6 * 0.1, 0.06, 0.06, FONT_GREEN, buffer);
	sprintf(buffer, "GATE  : %s", gateway);
	draw_text_f(esContext, -0.5, -0.8 + 7 * 0.1, 0.06, 0.06, FONT_GREEN, buffer);
	draw_text_button(esContext, "system_dhclient", VIEW_MODE_SYSTEM, "<GET IP OVER DHCP>", FONT_GREEN, 0.0, -0.8 + 9 * 0.1, 0.002, 0.06, ALIGN_CENTER, ALIGN_TOP, system_dhclient, 0.0);
	//	draw_text_button(esContext, "system_gcs", VIEW_MODE_SYSTEM, "<UPDATE GCS>", FONT_GREEN, 0.0, -0.8 + 10 * 0.1, 0.002, 0.06, ALIGN_CENTER, ALIGN_TOP, system_update, 0.0);
	// Connections-Status
	char tmp_str[100];
	uint8_t n = 0;
	if (ModelData[ModelActive].teletype == TELETYPE_AUTOQUAD || ModelData[ModelActive].teletype == TELETYPE_ARDUPILOT || ModelData[ModelActive].teletype == TELETYPE_MEGAPIRATE_NG) {
		if (mavlink_connection_status(ModelActive) != 0) {
			sprintf(tmp_str, "MAVLINK %s (%i / %i)", ModelData[ModelActive].telemetry_port, ModelData[ModelActive].telemetry_baud, (uint8_t)(time(0)) - mavlink_connection_status(ModelActive));
			draw_text_button(esContext, "mavlink_connection_status", VIEW_MODE_SYSTEM, tmp_str, FONT_GREEN, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0);
		} else {
			sprintf(tmp_str, "MAVLINK %s (%i)", ModelData[ModelActive].telemetry_port, ModelData[ModelActive].telemetry_baud);
			draw_text_button(esContext, "mavlink_connection_status", VIEW_MODE_SYSTEM, tmp_str, FONT_WHITE, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0);
		}
	} else {
		draw_text_button(esContext, "mavlink_connection_status", VIEW_MODE_SYSTEM, "MAVLINK", FONT_TRANS, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0);
	}
	if (ModelData[ModelActive].teletype == TELETYPE_MULTIWII_21 || ModelData[ModelActive].teletype == TELETYPE_BASEFLIGHT) {
		if (mwi21_connection_status(ModelActive) != 0) {
			sprintf(tmp_str, "MULTIWII21 %s (%i / %i)", ModelData[ModelActive].telemetry_port, ModelData[ModelActive].telemetry_baud, (uint8_t)(time(0)) - mwi21_connection_status(ModelActive));
			draw_text_button(esContext, "mwi21_connection_status", VIEW_MODE_SYSTEM, tmp_str, FONT_GREEN, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0);
		} else {
			sprintf(tmp_str, "MULTIWII21 %s (%i)", ModelData[ModelActive].telemetry_port, ModelData[ModelActive].telemetry_baud);
			draw_text_button(esContext, "mwi21_connection_status", VIEW_MODE_SYSTEM, tmp_str, FONT_WHITE, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0);
		}
	} else {
		draw_text_button(esContext, "mwi21_connection_status", VIEW_MODE_SYSTEM, "MULTIWII21", FONT_TRANS, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0);
	}
	if (ModelData[ModelActive].teletype == TELETYPE_BASEFLIGHT) {
		if (mwi21_connection_status(ModelActive) != 0) {
			sprintf(tmp_str, "BASEFLIGHT %s (%i / %i)", ModelData[ModelActive].telemetry_port, ModelData[ModelActive].telemetry_baud, (uint8_t)(time(0)) - mwi21_connection_status(ModelActive));
			draw_text_button(esContext, "mwi21_connection_status", VIEW_MODE_SYSTEM, tmp_str, FONT_GREEN, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0);
		} else {
			sprintf(tmp_str, "BASEFLIGHT %s (%i)", ModelData[ModelActive].telemetry_port, ModelData[ModelActive].telemetry_baud);
			draw_text_button(esContext, "mwi21_connection_status", VIEW_MODE_SYSTEM, tmp_str, FONT_WHITE, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0);
		}
	} else {
		draw_text_button(esContext, "mwi21_connection_status", VIEW_MODE_SYSTEM, "BASEFLIGHT", FONT_TRANS, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0);
	}
	if (ModelData[ModelActive].teletype == TELETYPE_OPENPILOT) {
		if (openpilot_connection_status(ModelActive) != 0) {
			sprintf(tmp_str, "OPENPILOT %s (%i / %i)", ModelData[ModelActive].telemetry_port, ModelData[ModelActive].telemetry_baud, (uint8_t)(time(0)) - openpilot_connection_status(ModelActive));
			draw_text_button(esContext, "openpilot_connection_status", VIEW_MODE_SYSTEM, tmp_str, FONT_GREEN, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0);
		} else {
			sprintf(tmp_str, "OPENPILOT %s (%i)", ModelData[ModelActive].telemetry_port, ModelData[ModelActive].telemetry_baud);
			draw_text_button(esContext, "openpilot_connection_status", VIEW_MODE_SYSTEM, tmp_str, FONT_WHITE, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0);
		}
	} else {
		draw_text_button(esContext, "openpilot_connection_status", VIEW_MODE_SYSTEM, "OPENPILOT", FONT_TRANS, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0);
	}
	if (ModelData[ModelActive].teletype == TELETYPE_GPS_NMEA) {
		if (gps_connection_status(ModelActive) != 0) {
			sprintf(tmp_str, "NMEA-GPS %s (%i / %i)", ModelData[ModelActive].telemetry_port, ModelData[ModelActive].telemetry_baud, (uint8_t)(time(0)) - gps_connection_status(ModelActive));
			draw_text_button(esContext, "gps_connection_status", VIEW_MODE_SYSTEM, tmp_str, FONT_GREEN, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0);
		} else {
			sprintf(tmp_str, "NMEA-GPS %s (%i)", ModelData[ModelActive].telemetry_port, ModelData[ModelActive].telemetry_baud);
			draw_text_button(esContext, "gps_connection_status", VIEW_MODE_SYSTEM, tmp_str, FONT_WHITE, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0);
		}
	} else {
		draw_text_button(esContext, "gps_connection_status", VIEW_MODE_SYSTEM, "NMEA-GPS", FONT_TRANS, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0);
	}
	if (frsky_connection_status() != 0) {
		sprintf(tmp_str, "FRSKY %s (%i / %i)", setup.frsky_port, setup.frsky_baud, (uint8_t)(time(0)) - frsky_connection_status());
		draw_text_button(esContext, "frsky", VIEW_MODE_SYSTEM, tmp_str, FONT_GREEN, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_device_change, 0.0);
	} else {
		sprintf(tmp_str, "FRSKY %s (%i)", setup.frsky_port, setup.frsky_baud);
		draw_text_button(esContext, "frsky", VIEW_MODE_SYSTEM, tmp_str, FONT_WHITE, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_device_change, 0.0);
	}
	if (jeti_connection_status() != 0) {
		sprintf(tmp_str, "JETI %s (%i / %i)", setup.jeti_port, setup.jeti_baud, (uint8_t)(time(0)) - jeti_connection_status());
		draw_text_button(esContext, "jeti", VIEW_MODE_SYSTEM, tmp_str, FONT_GREEN, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_device_change, 0.0);
	} else {
		sprintf(tmp_str, "JETI %s (%i)", setup.jeti_port, setup.jeti_baud);
		draw_text_button(esContext, "jeti", VIEW_MODE_SYSTEM, tmp_str, FONT_WHITE, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_device_change, 0.0);
	}
	if (gcsgps_connection_status() != 0) {
		sprintf(tmp_str, "GCS-GPS %s (%i / %i)", setup.gcs_gps_port, setup.gcs_gps_baud, (uint8_t)(time(0)) - gcsgps_connection_status());
		draw_text_button(esContext, "gcs_gps", VIEW_MODE_SYSTEM, tmp_str, FONT_GREEN, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_device_change, 0.0);
	} else {
		sprintf(tmp_str, "GCS-GPS %s (%i)", setup.gcs_gps_port, setup.gcs_gps_baud);
		draw_text_button(esContext, "gcs_gps", VIEW_MODE_SYSTEM, tmp_str, FONT_WHITE, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_device_change, 0.0);
	}
	if (rcflow_connection_status() != 0) {
		sprintf(tmp_str, "RCFLOW %s (%i / %i)", setup.rcflow_port, setup.rcflow_baud, (uint8_t)(time(0)) - rcflow_connection_status());
		draw_text_button(esContext, "rcflow", VIEW_MODE_SYSTEM, tmp_str, FONT_GREEN, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_device_change, 0.0);
	} else {
		sprintf(tmp_str, "RCFLOW %s (%i)", setup.rcflow_port, setup.rcflow_baud);
		draw_text_button(esContext, "rcflow", VIEW_MODE_SYSTEM, tmp_str, FONT_WHITE, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_device_change, 0.0);
	}
	if (tracker_connection_status() != 0) {
		sprintf(tmp_str, "TRACKER %s (%i / %i)", setup.tracker_port, setup.tracker_baud, (uint8_t)(time(0)) - tracker_connection_status());
		draw_text_button(esContext, "tracker", VIEW_MODE_SYSTEM, tmp_str, FONT_GREEN, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_device_change, 0.0);
	} else {
		sprintf(tmp_str, "TRACKER %s (%i)", setup.tracker_port, setup.tracker_baud);
		draw_text_button(esContext, "tracker", VIEW_MODE_SYSTEM, tmp_str, FONT_WHITE, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_device_change, 0.0);
	}

	sprintf(tmp_str, "Font: %s (%i/%i)", fontnames[(int)setup.font], setup.font + 1, FONT_MAX);
	draw_text_button(esContext, "_font", VIEW_MODE_SYSTEM, tmp_str, FONT_GREEN, 0.55, 0.2, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_font, 0.0);

	sprintf(tmp_str, "Resolution: %ix%i", esContext->width, esContext->height);
	draw_text_button(esContext, "_res", VIEW_MODE_SYSTEM, tmp_str, FONT_GREEN, 0.55, 0.3, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_fps, 0.0);

	draw_text_button(esContext, "_border_x", VIEW_MODE_SYSTEM, "X-Border", FONT_GREEN, 0.55, 0.4, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_border_x, 0.0);
	draw_text_button(esContext, "_border_x--", VIEW_MODE_SYSTEM, "[-]", FONT_GREEN, 0.85, 0.4, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_border_x, -2.0);
	draw_text_button(esContext, "_border_x++", VIEW_MODE_SYSTEM, "[+]", FONT_GREEN, 0.95, 0.4, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_border_x, 2.0);
	draw_text_button(esContext, "_border_y", VIEW_MODE_SYSTEM, "Y-Border", FONT_GREEN, 0.55, 0.5, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_border_y, 0.0);
	draw_text_button(esContext, "_border_y--", VIEW_MODE_SYSTEM, "[-]", FONT_GREEN, 0.85, 0.5, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_border_y, -2.0);
	draw_text_button(esContext, "_border_y++", VIEW_MODE_SYSTEM, "[+]", FONT_GREEN, 0.95, 0.5, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_border_y, 2.0);
	sprintf(tmp_str, "Ratio(%0.1f)", setup.keep_ratio);
	draw_text_button(esContext, "ratio", VIEW_MODE_SYSTEM, tmp_str, FONT_GREEN, 0.55, 0.6, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_ratio, 0.0);
	draw_text_button(esContext, "ratio--", VIEW_MODE_SYSTEM, "[-]", FONT_GREEN, 0.85, 0.6, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_ratio, -0.1);
	draw_text_button(esContext, "ratio++", VIEW_MODE_SYSTEM, "[+]", FONT_GREEN, 0.95, 0.6, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_ratio, 0.1);
	if (setup.side_by_side == 1) {
		draw_text_button(esContext, "side_by_side", VIEW_MODE_SYSTEM, "SideBySide", FONT_PINK, 0.55, 0.7, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_side_by_side, 0.1);
	} else {
		draw_text_button(esContext, "side_by_side", VIEW_MODE_SYSTEM, "SideBySide", FONT_GREEN, 0.55, 0.7, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_side_by_side, 0.1);
	}
#ifndef ANDROID
#ifdef SDL2
	if (setup.fullscreen == 0) {
		draw_text_button(esContext, "fullscreen", VIEW_MODE_SYSTEM, "TOGGLE FULLSCREEN", FONT_WHITE, 0.55, 0.7, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_fullscreen, 0.0);
	} else {
		draw_text_button(esContext, "fullscreen", VIEW_MODE_SYSTEM, "TOGGLE FULLSCREEN", FONT_GREEN, 0.55, 0.7, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_fullscreen, 0.0);
	}
#endif
#endif
	if (setup.weather_enable == 1) {
		draw_text_button(esContext, "copyright", VIEW_MODE_SYSTEM, "Weather-Data copyright by http://www.openweathermap.org", FONT_PINK, 0.0, 0.88, 0.002, 0.04, ALIGN_CENTER, ALIGN_TOP, system_null, 0.0);
	}
	draw_text_button(esContext, "copyright", VIEW_MODE_SYSTEM, "Copyright by Oliver Dippel ([email protected])", FONT_PINK, 0.0, 0.93, 0.002, 0.04, ALIGN_CENTER, ALIGN_TOP, system_null, 0.0);
	screen_device(esContext);
	screen_baud(esContext);
	if (resize != 0) {
		resize = 0;
#ifdef SDL2
		glResize(esContext, setup.screen_w, setup.screen_h);
#endif
	}
}