diff --git a/gui/Makefile b/gui/Makefile index e06a740..e7e1a74 100644 --- a/gui/Makefile +++ b/gui/Makefile @@ -32,7 +32,7 @@ endif OFILES = $(patsubst %.cc, %.o, $(patsubst %.cpp, %.o, $(CXXFILES))) ifeq ($(UNAME), Linux) -LIBS = $(shell wx-config --libs) -lwx_gtk3u_stc-3.1 +LIBS = $(shell wx-config --libs) -lwx_gtk3u_stc-3.0 else LIBS = -lSetupAPI \ -LC:\wx\lib\gcc810_x64_dll -lwxbase31u -lwxmsw31u_core -lwxmsw31u_stc diff --git a/gui/wxapp.hpp b/gui/wxapp.hpp index 85bddc2..ef6a68c 100644 --- a/gui/wxapp.hpp +++ b/gui/wxapp.hpp @@ -21,7 +21,7 @@ class MainApp : public wxApp { public: virtual bool OnInit() final { - wxFont::AddPrivateFont("./Hack-Regular.ttf"); + //wxFont::AddPrivateFont("./Hack-Regular.ttf"); m_main_frame = new MainFrame; m_main_frame->Show(true); diff --git a/gui/wxmain.cpp b/gui/wxmain.cpp index 75eedb6..c526157 100644 --- a/gui/wxmain.cpp +++ b/gui/wxmain.cpp @@ -152,8 +152,9 @@ MainFrame::MainFrame() : Bind(wxEVT_TIMER, &MainFrame::onTimerRecord, this, Id::TimerRecord); Bind(wxEVT_TIMER, &MainFrame::onTimerWavClip, this, Id::TimerWavClip); Bind(wxEVT_CLOSE_WINDOW, &MainFrame::onCloseEvent, this, wxID_ANY); - m_compile_output-> - Bind(wxEVT_PAINT, &MainFrame::onPaint, this, Id::CompileOutput); +// m_compile_output-> +// Bind(wxEVT_PAINT, &MainFrame::onPaint, this, Id::CompileOutput); + Bind(wxEVT_PAINT, &MainFrame::onPaint, this, wxID_ANY); // Toolbar actions Bind(wxEVT_BUTTON, &MainFrame::onRunCompile, this, wxID_ANY, wxID_ANY, comp); @@ -234,7 +235,7 @@ void MainFrame::onTimerRecord(wxTimerEvent&) if (m_run_draw_samples->IsChecked()) { samples = m_device->continuous_read_input(); std::copy(samples.cbegin(), samples.cend(), m_device_samples_input); - m_compile_output->Refresh(); + /*m_compile_output->*/Refresh(); } } } @@ -253,42 +254,50 @@ void MainFrame::onTimerWavClip(wxTimerEvent&) void MainFrame::onPaint(wxPaintEvent&) { - if (!m_is_running || !m_run_draw_samples->IsChecked()) + if (!m_is_running || !m_run_draw_samples->IsChecked()) { + if (!m_compile_output->IsShown()) + m_compile_output->Show(); return; + } else if (m_compile_output->IsShown()) { + m_compile_output->Hide(); + } - const auto& dim = m_compile_output->GetSize(); + auto py = m_compile_output->GetScreenPosition().y - this->GetScreenPosition().y - 28; wxRect rect { - 0, 0, dim.GetWidth(), dim.GetHeight() + 0, py, + this->GetSize().GetWidth(), + this->GetSize().GetHeight() - py - 60 }; - wxBufferedPaintDC dc (m_compile_output); - dc.SetBrush(*wxBLACK_BRUSH); - dc.SetPen(*wxBLACK_PEN); - dc.DrawRectangle(rect); + auto *dc = new wxBufferedPaintDC(this); + dc->SetBrush(*wxBLACK_BRUSH); + dc->SetPen(*wxBLACK_PEN); + dc->DrawRectangle(rect); auto stoy = [&](stmdsp::adcsample_t s) { - return static_cast(rect.GetHeight()) - + return static_cast(py) + rect.GetHeight() - (static_cast(rect.GetHeight()) * s / 4095.f); }; auto scount = m_device->get_buffer_size(); float dx = static_cast(rect.GetWidth()) / scount; float x = 0; float lasty = stoy(2048); - dc.SetBrush(wxBrush(wxColour(0xFF, 0, 0, 0x80))); - dc.SetPen(wxPen(wxColour(0xFF, 0, 0, 0x80))); + dc->SetBrush(wxBrush(wxColour(0xFF, 0, 0, 0x80))); + dc->SetPen(wxPen(wxColour(0xFF, 0, 0, 0x80))); for (decltype(scount) i = 0; i < scount; i++) { auto y = stoy(m_device_samples[i]); - dc.DrawLine(x, lasty, x + dx, y); + dc->DrawLine(x, lasty, x + dx, y); x += dx, lasty = y; } x = 0; lasty = stoy(2048); - dc.SetBrush(wxBrush(wxColour(0, 0, 0xFF, 0x80))); - dc.SetPen(wxPen(wxColour(0, 0, 0xFF, 0x80))); + dc->SetBrush(wxBrush(wxColour(0, 0, 0xFF, 0x80))); + dc->SetPen(wxPen(wxColour(0, 0, 0xFF, 0x80))); for (decltype(scount) i = 0; i < scount; i++) { auto y = stoy(m_device_samples_input[i]); - dc.DrawLine(x, lasty, x + dx, y); + dc->DrawLine(x, lasty, x + dx, y); x += dx, lasty = y; } + delete dc; } void MainFrame::prepareEditor() @@ -452,6 +461,8 @@ void MainFrame::updateMenuOptions() m_menu_bar->Enable(MRunGenUpload, connected); m_menu_bar->Enable(MRunGenStart, connected); + m_menu_bar->Enable(MRunConnect, !m_is_running); + bool nrunning = connected && !m_is_running; m_menu_bar->Enable(MRunUpload, nrunning); m_menu_bar->Enable(MRunUnload, nrunning); @@ -459,6 +470,7 @@ void MainFrame::updateMenuOptions() m_menu_bar->Enable(MRunMeasure, nrunning); m_menu_bar->Enable(MRunDrawSamples, nrunning); m_menu_bar->Enable(MRunLogResults, nrunning); + m_menu_bar->Enable(MRunGenUpload, nrunning); m_rate_select->Enable(nrunning); } diff --git a/gui/wxmain_mrun.cpp b/gui/wxmain_mrun.cpp index e12d068..9fb307a 100644 --- a/gui/wxmain_mrun.cpp +++ b/gui/wxmain_mrun.cpp @@ -54,10 +54,13 @@ void MainFrame::onRunStart(wxCommandEvent& ce) * 1000.f * 0.5f; int reqSpeed = reqSpeedExact; - if (m_device->is_siggening() && m_wav_clip) + if (m_device->is_siggening() && m_wav_clip) { m_timer_wavclip->Start(reqSpeed); + // Cap refresh speed in case sample drawing runs too. + reqSpeed = std::max(reqSpeed, 500); + } if (m_conv_result_log || m_run_draw_samples->IsChecked()) - m_timer_record->Start(reqSpeed); + m_timer_record->Start(std::max(reqSpeed, 200)); m_device->continuous_start(); } diff --git a/gui/wxmain_mrun_genupload.cpp b/gui/wxmain_mrun_genupload.cpp index b720e3a..d1b82ef 100644 --- a/gui/wxmain_mrun_genupload.cpp +++ b/gui/wxmain_mrun_genupload.cpp @@ -1,5 +1,5 @@ #include "stmdsp.hpp" -#include "exprtk.hpp" +//#include "exprtk.hpp" #include #include @@ -7,20 +7,20 @@ std::vector siggen_formula_parse(const std::string& formula { double x = 0; - exprtk::symbol_table symbol_table; - symbol_table.add_variable("x", x); - symbol_table.add_constants(); + //exprtk::symbol_table symbol_table; + //symbol_table.add_variable("x", x); + //symbol_table.add_constants(); - exprtk::expression expression; - expression.register_symbol_table(symbol_table); + //exprtk::expression expression; + //expression.register_symbol_table(symbol_table); - exprtk::parser parser; - parser.compile(formulaString, expression); + //exprtk::parser parser; + //parser.compile(formulaString, expression); std::vector samples; for (x = 0; samples.size() < stmdsp::SAMPLES_MAX; x += 1) { - auto y = static_cast(expression.value()); - samples.push_back(y); + //auto y = static_cast(expression.value()); + samples.push_back(2048); } return samples; diff --git a/source/dac.cpp b/source/dac.cpp index 2772928..1ff8867 100644 --- a/source/dac.cpp +++ b/source/dac.cpp @@ -17,7 +17,7 @@ DACDriver *DAC::m_driver[2] = { }; const DACConfig DAC::m_config = { - .init = 0, + .init = 2048, .datamode = DAC_DHRM_12BIT_RIGHT, .cr = 0 };