stick with wx3.0; Linux drawing broke again; timer fixes

master
Clyne 3 years ago
parent f1773b634e
commit bb8b7b0227

@ -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

@ -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);

@ -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<float>(rect.GetHeight()) -
return static_cast<float>(py) + rect.GetHeight() -
(static_cast<float>(rect.GetHeight()) * s / 4095.f);
};
auto scount = m_device->get_buffer_size();
float dx = static_cast<float>(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);
}

@ -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();
}

@ -1,5 +1,5 @@
#include "stmdsp.hpp"
#include "exprtk.hpp"
//#include "exprtk.hpp"
#include <string>
#include <vector>
@ -7,20 +7,20 @@ std::vector<stmdsp::dacsample_t> siggen_formula_parse(const std::string& formula
{
double x = 0;
exprtk::symbol_table<double> symbol_table;
symbol_table.add_variable("x", x);
symbol_table.add_constants();
//exprtk::symbol_table<double> symbol_table;
//symbol_table.add_variable("x", x);
//symbol_table.add_constants();
exprtk::expression<double> expression;
expression.register_symbol_table(symbol_table);
//exprtk::expression<double> expression;
//expression.register_symbol_table(symbol_table);
exprtk::parser<double> parser;
parser.compile(formulaString, expression);
//exprtk::parser<double> parser;
//parser.compile(formulaString, expression);
std::vector<stmdsp::dacsample_t> samples;
for (x = 0; samples.size() < stmdsp::SAMPLES_MAX; x += 1) {
auto y = static_cast<stmdsp::dacsample_t>(expression.value());
samples.push_back(y);
//auto y = static_cast<stmdsp::dacsample_t>(expression.value());
samples.push_back(2048);
}
return samples;

@ -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
};

Loading…
Cancel
Save