void screen_number(ESContext *esContext) { if (show_number != setup.view_mode) { return; } screen_keyboard(esContext); }
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); }