Exemple #1
0
void draw_line (ESContext *esContext, int16_t px1, int16_t py1, int16_t px2, int16_t py2, uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
#ifdef CONSOLE_ONLY
	return;
#endif
	GLfloat x1 = (float)px1 / (float)esContext->width * 2.0 * aspect - 1.0 * aspect;
	GLfloat y1 = (float)py1 / (float)esContext->height * 2.0 - 1.0;
	GLfloat x2 = (float)px2 / (float)esContext->width * 2.0 * aspect - 1.0 * aspect;
	GLfloat y2 = (float)py2 / (float)esContext->height * 2.0 - 1.0;
	draw_line_f3(esContext, x1, y1, 0.0, x2, y2, 0.0, r, g, b, a);
}
Exemple #2
0
void draw_pulldown (ESContext *esContext, float x1, float y1, float w, float z, char *name, EntryList *list, uint8_t open, uint8_t select, uint8_t (*callback) (char *, float, float, int8_t, float, uint8_t)) {
#ifdef CONSOLE_ONLY
	return;
#endif
	uint8_t n = 0;
	float x2 = x1 + w;
	float h = 0.07;
	float y2 = y1 + h;
	char tmp_str[1024];
#ifdef SDLGL
#ifndef ANDROID
	draw_box_rounded_f3(esContext, x1, y1, z, x2, y2, z, h / 3, 255, 255, 255, 55);
	draw_rect_rounded_f3(esContext, x1, y1, z, x2, y2, z, h / 3, 255, 255, 255, 255);
#else
	draw_box_f3(esContext, x1, y1, z, x2, y2, z, 255, 255, 255, 55);
	draw_rect_f3(esContext, x1, y1, z, x2, y2, z, 255, 255, 255, 255);
#endif
#endif
	if (open == 1) {
//		y1 -= select * h;
//		y2 -= select * h;
		while (list[n].name != NULL) {
			if (n == select) {
				draw_box_f3(esContext, x1 + 0.01, y1 + n * h, z, x2 - 0.01, y2 + n * h, z + 0.05, 200, 200, 200, 200);
			} else {
				draw_box_f3(esContext, x1 + 0.01, y1 + n * h, z, x2 - 0.01, y2 + n * h, z + 0.05, 255, 255, 255, 200);
			}
			draw_text_f3(esContext, x1 + 0.001 + 0.005, y1 + n * h + 0.005, z + 0.1, h - 0.01, h - 0.01, FONT_GREEN, list[n].name);
			sprintf(tmp_str, "%s_%i", name, n);
			set_button(tmp_str, setup.view_mode, x1 + 0.01, y1 + n * h, x2 + 0.01, y2 + n * h, callback, (float)(n + 1), 0);
			n++;
		}
		gui_ov_lock = 1;
	} else {
		draw_line_f3(esContext, x2 - h + 0.02, y1 + h / 2 - 0.01, z, x2 - 0.02, y1 + h / 2 - 0.01, z, 255, 255, 255, 255);
		draw_line_f3(esContext, x2 - h + 0.02, y1 + h / 2 - 0.01, z, x2 - h / 2, y1 + h / 2 + 0.01, z, 255, 255, 255, 255);
		draw_line_f3(esContext, x2 - h / 2, y1 + h / 2 + 0.01, z, x2 - 0.02, y1 + h / 2 - 0.01, z, 255, 255, 255, 255);
		draw_text_f3(esContext, x1 + 0.005, y1 + 0.005, z + 0.001, h - 0.01, h - 0.01, FONT_GREEN, list[select].name);
		sprintf(tmp_str, "%s", name);
		set_button(tmp_str, setup.view_mode, x1, y1, x2, y2, callback, 0.0, 0);
	}
}
Exemple #3
0
void draw_spinbox (ESContext *esContext, float x1, float y1, float w, float z, char *name, char *format, float value, uint8_t (*callback) (char *, float, float, int8_t, float, uint8_t)) {
#ifdef CONSOLE_ONLY
	return;
#endif
	float x2 = x1 + w;
	float h = 0.07;
	float y2 = y1 + h;
	char tmp_str[1024];
	sprintf(tmp_str, format, value);
#ifdef SDLGL
#ifndef ANDROID
	draw_box_rounded_f3(esContext, x1, y1, z, x2, y2, z, h / 3, 255, 255, 255, 55);
	draw_rect_rounded_f3(esContext, x1, y1, z, x2, y2, z, h / 3, 255, 255, 255, 255);
#else
	draw_box_f3(esContext, x1, y1, z, x2, y2, z, 255, 255, 255, 55);
	draw_rect_f3(esContext, x1, y1, z, x2, y2, z, 255, 255, 255, 255);
#endif
#endif
	draw_line_f3(esContext, x2 - h + 0.02, y1 + h / 2 + 0.005, z, x2 - 0.02, y1 + h / 2 + 0.005, z, 255, 255, 255, 255);
	draw_line_f3(esContext, x2 - h + 0.02, y1 + h / 2 + 0.005, z, x2 - h / 2, y1 + h / 2 + 0.02, z, 255, 255, 255, 255);
	draw_line_f3(esContext, x2 - h / 2, y1 + h / 2 + 0.02, z, x2 - 0.02, y1 + h / 2 + 0.005, z, 255, 255, 255, 255);
	draw_line_f3(esContext, x2 - h + 0.02, y1 + h / 2 - 0.005, z, x2 - 0.02, y1 + h / 2 - 0.005, z, 255, 255, 255, 255);
	draw_line_f3(esContext, x2 - h + 0.02, y1 + h / 2 - 0.005, z, x2 - h / 2, y1 + h / 2 - 0.02, z, 255, 255, 255, 255);
	draw_line_f3(esContext, x2 - h / 2, y1 + h / 2 - 0.02, z, x2 - 0.02, y1 + h / 2 - 0.005, z, 255, 255, 255, 255);
	draw_text_f3(esContext, x1 + 0.005, y1 + 0.005, z + 0.001, h - 0.01, h - 0.01, FONT_GREEN, tmp_str);
	set_button(name, setup.view_mode, x1, y1, x2, y2, callback, 0.0, 0);
}
Exemple #4
0
void draw_checkbox (ESContext *esContext, float x1, float y1, float z, char *name, uint8_t check, uint8_t (*callback) (char *, float, float, int8_t, float, uint8_t)) {
#ifdef CONSOLE_ONLY
	return;
#endif
	float w = 0.07;
	float h = 0.07;
	float x2 = x1 + w;
	float y2 = y1 + h;
#ifdef SDLGL
#ifndef ANDROID
	draw_box_rounded_f3(esContext, x1, y1, z, x2, y2, z, h / 3, 255, 255, 255, 55);
	draw_rect_rounded_f3(esContext, x1, y1, z, x2, y2, z, h / 3, 255, 255, 255, 255);
#else
	draw_box_f3(esContext, x1, y1, z, x2, y2, z, 255, 255, 255, 55);
	draw_rect_f3(esContext, x1, y1, z, x2, y2, z, 255, 255, 255, 255);
#endif
#endif
	if (check == 1) {
		draw_line_f3(esContext, x1 + 0.02, y1 + 0.02, z, x2 - 0.02, y2 - 0.02, z, 255, 255, 255, 255);
		draw_line_f3(esContext, x1 + 0.02, y2 - 0.02, z, x2 - 0.02, y1 + 0.02, z, 255, 255, 255, 255);
	}
	set_button(name, setup.view_mode, x1, y1, x2, y2, callback, 0.0, 0);
}
Exemple #5
0
void draw_window (ESContext *esContext, float x1, float y1, float x2, float y2, float z, char *name, char *title, EntryList *list, uint8_t select, uint8_t (*callback) (char *, float, float, int8_t, float, uint8_t)) {
#ifdef CONSOLE_ONLY
	return;
#endif
	uint8_t n = 0;
	uint8_t m = 0;
	float tw = 0.6;
	float step = 0.4;
	char tmp_str[1024];
	while (list[m].name != NULL) {
		m++;
	}
#ifdef SDLGL
#ifndef ANDROID
	draw_box_rounded_f3(esContext, x1, y1, z, x2, y2, z, 0.04, 55, 55, 255, 100);
	draw_rect_rounded_f3(esContext, x1, y1, z, x2, y2, z, 0.04, 255, 255, 255, 255);
#else
	draw_box_f3(esContext, x1, y1, z, x2, y2, z, 55, 55, 255, 100);
	draw_rect_f3(esContext, x1, y1, z, x2, y2, z, 255, 255, 255, 255);
#endif
#endif
	draw_line_f3(esContext, x1, y1 + 0.08, z, x1 + tw, y1 + 0.08, z, 255, 255, 255, 255);
	draw_line_f3(esContext, x1 + tw, y1 + 0.08, z, x1 + tw + 0.1, y1, z, 255, 255, 255, 255);
	draw_text_f3(esContext, x1 + 0.05, y1 + 0.01, z + 0.001, 0.07, 0.07, FONT_PINK, title);
	while (list[n].name != NULL) {
		sprintf(tmp_str, "%s%i", name, n);
		if (n == select) {
			draw_line_f3(esContext, x1 + tw + step * n, y1 + 0.08, z, x1 + tw + step * n + step, y1 + 0.08, z, 255, 255, 255, 100);
		} else {
			draw_line_f3(esContext, x1 + tw + step * n, y1 + 0.08, z, x1 + tw + step * n + step, y1 + 0.08, z, 255, 255, 255, 255);
		}
		draw_line_f3(esContext, x1 + tw + step * n + step, y1 + 0.08, z, x1 + tw + step * n + step + 0.1, y1, z, 255, 255, 255, 255);
		draw_text_f3(esContext, x1 + tw + step * n + 0.07, y1 + 0.02, z + 0.001, 0.06, 0.06, FONT_WHITE, list[n].name);
		set_button(tmp_str, setup.view_mode, x1 + tw + step * n, y1, x1 + tw + step * n + step, y1 + 0.08, callback, (float)n, 0);
		n++;
	}
	draw_line_f3(esContext, x1 + tw + step * n, y1 + 0.08, z, x2, y1 + 0.08, z, 255, 255, 255, 255);
}
Exemple #6
0
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);
}
Exemple #7
0
void draw_line_f (ESContext *esContext, float x1, float y1, float x2, float y2, uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
#ifdef CONSOLE_ONLY
	return;
#endif
	draw_line_f3(esContext, x1, y1, 0.0, x2, y2, 0.0, r, g, b, a);
}
Exemple #8
0
void swarm_draw_setup(ESContext *esContext) {
	int n = 0;
	int ny = 1;
	int gx = 0;
	int gy = 0;
	char tmp_str[128];
	char tmp_str2[128];
	float px1 = -0.8;
	float py1 = -0.9;
	float px2 = 0.9;
	float py2 = 0.1;
	float sy = 0.08;
	reset_buttons();
	EntryList list[3];
	list[0].name = "ROLE";
	list[1].name = "OFFSET";
	list[2].name = NULL;
	draw_window(esContext, px1, py1, px2, py2, 0.002, "SwarmSetup.options", "Swarm-Setup", list, SwarmSetup.options, swarm_set);
	if (SwarmSetup.options == 0) {
		draw_text_button(esContext, "master_title", setup.view_mode, "Master:", FONT_WHITE, px1, py1 + (float)ny * sy, 0.005, 0.06, ALIGN_LEFT, ALIGN_TOP, swarm_set, 0.0);
		ny++;
		uint8_t n2 = 0;
		EntryList list[MODELS_MAX + 2];
		list[0].name = "GCS";
		for (n2 = 0; n2 < MODELS_MAX; n2++) {
			list[n2 + 1].name = ModelData[n2].name;
		}
		list[n2 + 1].name = NULL;
		draw_pulldown(esContext, px1 + 0.1, py1 + (float)ny * sy, 0.45, 0.01, "SwarmSetup.master", list, pd_openm, SwarmSetup.master + 1, swarm_set);
		ny++;
		draw_text_button(esContext, "sclave_title", setup.view_mode, "Slaves:", FONT_WHITE, px1, py1 + (float)ny * sy, 0.005, 0.06, ALIGN_LEFT, ALIGN_TOP, swarm_set, 0.0);
		ny++;
		for (n = 0; n < 4; n++) {
			sprintf(tmp_str2, "SwarmSetup.slave%i", n);
			draw_pulldown(esContext, px1 + 0.1, py1 + (float)ny * sy, 0.44, 0.01, tmp_str2, list, pd_open[n], SwarmSetup.slave[n] + 1, swarm_set);
			sprintf(tmp_str, "X=%im", SwarmSetup.offset_x[n]);
			sprintf(tmp_str2, "SwarmSetup.offx%i", n);
			draw_spinbox(esContext, px1 + 0.55, py1 + (float)ny * sy, 0.34, 0.01, tmp_str2, "X=%0.0fm", SwarmSetup.offset_x[n], swarm_set);
			sprintf(tmp_str, "Y=%im", SwarmSetup.offset_y[n]);
			sprintf(tmp_str2, "SwarmSetup.offy%i", n);
			draw_spinbox(esContext, px1 + 0.9, py1 + (float)ny * sy, 0.34, 0.01, tmp_str2, "Y=%0.0fm", SwarmSetup.offset_y[n], swarm_set);
			sprintf(tmp_str, "Z=%im", SwarmSetup.offset_z[n]);
			sprintf(tmp_str2, "SwarmSetup.offz%i", n);
			draw_spinbox(esContext, px1 + 1.25, py1 + (float)ny * sy, 0.34, 0.01, tmp_str2, "Z=%0.0fm", SwarmSetup.offset_z[n], swarm_set);
			ny++;
		}
		ny++;
		draw_text_button(esContext, "swarm_yawmode_", setup.view_mode, "Yaw-Rotate", FONT_GREEN, px1 + 0.1, py1 + (float)ny * sy, 0.005, 0.06, ALIGN_LEFT, ALIGN_TOP, swarm_set, 0.0);
		draw_checkbox(esContext, px1 + 0.7, py1 + (float)ny * sy, 0.005, "swarm_yawmode", SwarmSetup.yaw_mode, swarm_set);
		ny++;
		draw_text_button(esContext, "swarm_rotate_", setup.view_mode, "Pattern-Rotate", FONT_GREEN, px1 + 0.1, py1 + (float)ny * sy, 0.005, 0.06, ALIGN_LEFT, ALIGN_TOP, swarm_set, 0.0);
		draw_checkbox(esContext, px1 + 0.7, py1 + (float)ny * sy, 0.005, "swarm_rotate", SwarmSetup.rotate, swarm_set);
		ny++;
	} else {
		float gx1 = px1 + 0.5;
		float gx2 = px2 - 0.1;
		float gy1 = py1 + 0.15;
		float gy2 = py2 - 0.15;
		int gxn = 80;
		int gyn = 40;
		ny++;
		ny++;
		sprintf(tmp_str, "SLAVE=%i", SwarmSetup.selected);
		draw_text_button(esContext, "SwarmSetup.selected", setup.view_mode, tmp_str, FONT_GREEN, px1 + 0.01, py1 + (float)ny * sy, 0.005, 0.06, ALIGN_LEFT, ALIGN_TOP, swarm_set, 0.0);
		ny++;
		sprintf(tmp_str, "%s", ModelData[SwarmSetup.slave[SwarmSetup.selected]].name);
		draw_text_button(esContext, "SwarmSetup.offn", setup.view_mode, tmp_str, FONT_GREEN, px1 + 0.01, py1 + (float)ny * sy, 0.005, 0.06, ALIGN_LEFT, ALIGN_TOP, swarm_set, (float)SwarmSetup.selected);
		ny++;
		sprintf(tmp_str, "X=%im", SwarmSetup.offset_x[SwarmSetup.selected]);
		draw_text_button(esContext, "SwarmSetup.offx", setup.view_mode, tmp_str, FONT_GREEN, px1 + 0.01, py1 + (float)ny * sy, 0.005, 0.06, ALIGN_LEFT, ALIGN_TOP, swarm_set, (float)SwarmSetup.selected);
		ny++;
		sprintf(tmp_str, "Y=%im", SwarmSetup.offset_y[SwarmSetup.selected]);
		draw_text_button(esContext, "SwarmSetup.offy", setup.view_mode, tmp_str, FONT_GREEN, px1 + 0.01, py1 + (float)ny * sy, 0.005, 0.06, ALIGN_LEFT, ALIGN_TOP, swarm_set, (float)SwarmSetup.selected);
		ny++;
		sprintf(tmp_str, "Z=%im", SwarmSetup.offset_z[SwarmSetup.selected]);
		draw_text_button(esContext, "SwarmSetup.offz", setup.view_mode, tmp_str, FONT_GREEN, px1 + 0.01, py1 + (float)ny * sy, 0.005, 0.06, ALIGN_LEFT, ALIGN_TOP, swarm_set, (float)SwarmSetup.selected);
		ny++;
		for (gx = 0; gx <= gxn; gx++) {
			draw_line_f3(esContext, gx1 + (float)gx * ((gx2 - gx1) / (float)gxn), gy1, 0.006, gx1 + (float)gx * ((gx2 - gx1) / (float)gxn), gy2, 0.006, 255, 255, 255, 90);
		}
		for (gy = 0; gy <= gyn; gy++) {
			draw_line_f3(esContext, gx1, gy1 + (float)gy * ((gy2 - gy1) / (float)gyn), 0.006, gx2, gy1 + (float)gy * ((gy2 - gy1) / (float)gyn), 0.006, 255, 255, 255, 90);
		}
		draw_circleFilled_f3(esContext, gx1 + (gx2 - gx1) / 2.0, gy1 + (gy2 - gy1) / 2.0, 0.007, 0.01, 255, 0, 0, 255);
		for (n = 0; n < 4; n++) {
			if (SwarmSetup.slave[n] == -1) {
				continue;
			}
			float offx = SwarmSetup.offset_x[n] / 50.0;
			float offy = SwarmSetup.offset_y[n] / 50.0;
			draw_circleFilled_f3(esContext, gx1 + (gx2 - gx1) / 2.0 + offx, gy1 + (gy2 - gy1) / 2.0 + offy, 0.007, 0.01, 255, 255, 0, 255);
			if (n == SwarmSetup.selected) {
				draw_circle_f3(esContext, gx1 + (gx2 - gx1) / 2.0 + offx, gy1 + (gy2 - gy1) / 2.0 + offy, 0.007, 0.02, 255, 0, 255, 255);
			}
		}
	}
	draw_buttonbox(esContext, "swarm_setup_done", setup.view_mode, "CLOSE", px2 - 0.33, py2 - 0.1, 0.3, 0.005, swarm_set, 0.0);
}