dual wf display

master
Sebastien Bourdeauducq 2023-09-13 11:14:14 +08:00
parent 9bee53ab49
commit bd85526290
1 changed files with 34 additions and 21 deletions

View File

@ -125,7 +125,7 @@ int main(int argc, char* argv[])
std::atexit(glfwTerminate);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
static GLFWwindow* window = glfwCreateWindow(1280, 2200, "fastsa", nullptr, nullptr);
static GLFWwindow* window = glfwCreateWindow(1500, 2200, "fastsa", nullptr, nullptr);
if(window == nullptr) {
std::cerr << "failed to create GLFW window" << std::endl;
return 1;
@ -151,13 +151,15 @@ int main(int argc, char* argv[])
ImGui_ImplOpenGL3_Init("#version 130");
std::atexit(ImGui_ImplOpenGL3_Shutdown);
GLuint waterfall;
glGenTextures(1, &waterfall);
glBindTexture(GL_TEXTURE_2D, waterfall);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
GLuint wftex[2];
for(size_t i=0;i<2;i++) {
glGenTextures(1, &wftex[i]);
glBindTexture(GL_TEXTURE_2D, wftex[i]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
int status;
struct bladerf_devinfo dev_info;
@ -212,7 +214,7 @@ int main(int argc, char* argv[])
std::atexit(TerminateDSP);
bool exit = false;
bool update = true;
bool update_wf = true;
float freq_setpoint_local = 0.0f;
float tec_bias_local = 0.02f;
float tec_p_local = 0.001f;
@ -221,13 +223,20 @@ int main(int argc, char* argv[])
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glBindTexture(GL_TEXTURE_2D, waterfall);
#if defined(GL_UNPACK_ROW_LENGTH) && !defined(__EMSCRIPTEN__)
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
#endif
if(update) {
std::lock_guard<std::mutex> guard(wf_data_mutex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, wf_width, wf_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, wf_data);
if(update_wf) {
#if defined(GL_UNPACK_ROW_LENGTH) && !defined(__EMSCRIPTEN__)
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
#endif
glBindTexture(GL_TEXTURE_2D, wftex[0]);
{
std::lock_guard<std::mutex> guard(wf_data_mutex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, wf_width, wf_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, wf_data);
}
glBindTexture(GL_TEXTURE_2D, wftex[1]);
{
std::lock_guard<std::mutex> guard(wf_data_mutex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, wf_width, wf_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, wf_data);
}
}
ImGui_ImplOpenGL3_NewFrame();
@ -239,11 +248,13 @@ int main(int argc, char* argv[])
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::Begin("fastsa", nullptr, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoResize);
ImGui::BeginTable("fastsa", 2, ImGuiTableFlags_SizingStretchSame | ImGuiTableFlags_Resizable);
ImGui::TableSetupColumn("", 0, 280.0f);
ImGui::TableSetupColumn("", 0, 1000.0f);
ImGui::BeginTable("fastsa", 3, ImGuiTableFlags_SizingStretchSame | ImGuiTableFlags_Resizable);
ImGui::TableSetupColumn("SBS laser control", 0, 280.0f);
ImGui::TableSetupColumn("Pump/output heterodyne", 0, 1000.0f);
ImGui::TableSetupColumn("Linewidth", 0, 1000.0f);
ImGui::TableHeadersRow();
ImGui::TableNextColumn();
ImGui::Checkbox("Update waterfall", &update);
ImGui::Checkbox("Update waterfall plots", &update_wf);
ImGui::Text("Baseband peak: %.3f MHz", (float)freq_peak);
ImGui::Text("TEC current: %.6f mA", (float)tec_current);
ImGui::SliderFloat("Setpoint", &freq_setpoint_local, 0.0f, 40.0f);
@ -256,7 +267,9 @@ int main(int argc, char* argv[])
exit = true;
ImGui::Text("FPS: %d", (int)fps);
ImGui::TableNextColumn();
ImGui::Image((void*)(intptr_t)waterfall, ImVec2(wf_width, wf_height));
ImGui::Image((void*)(intptr_t)wftex[0], ImVec2(wf_width, wf_height));
ImGui::TableNextColumn();
ImGui::Image((void*)(intptr_t)wftex[1], ImVec2(wf_width, wf_height));
ImGui::EndTable();
ImGui::End();