]> code.bitgloo.com Git - clyne/stmdsp.git/commitdiff
stick with wx3.0; Linux drawing broke again; timer fixes
authorClyne Sullivan <clyne@bitgloo.com>
Mon, 14 Jun 2021 10:23:23 +0000 (06:23 -0400)
committerClyne Sullivan <clyne@bitgloo.com>
Mon, 14 Jun 2021 10:23:23 +0000 (06:23 -0400)
gui/Makefile
gui/wxapp.hpp
gui/wxmain.cpp
gui/wxmain_mrun.cpp
gui/wxmain_mrun_genupload.cpp
source/dac.cpp

index e06a740fb957d630e13a2ce39626cdd13ac6d70e..e7e1a74f4b41e3a7ae63ef577a62ab91cb23f50c 100644 (file)
@@ -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
index 85bddc27fc77c18a10552be62a1cb48c19ef927a..ef6a68cdb6b35c34d708f30a15b690c40337868b 100644 (file)
@@ -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);
index 75eedb6c294715ff0af46d68bf49ebbf46ce57aa..c526157a6324d8fa24425e17e738373ac3f18d09 100644 (file)
@@ -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);
 }
 
index e12d068d5cb5c18a1a380a44ba8317433ca3b20b..9fb307adc6c78af7c38215c878929ccff135b49e 100644 (file)
@@ -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();
         }
index b720e3af89aaa762de8e2699aa8f152d324c636e..d1b82ef4fcbe9864834d2f5b2663ddd65e2830bb 100644 (file)
@@ -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;
index 2772928f48dd0d71eced9d6fe1163d73ca9040fd..1ff8867f7b3228a940d71587b604a79c5f122b62 100644 (file)
@@ -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
 };