From ab0f6acf4d7a75f2d6573526acbc9948dbf2c110 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Sun, 18 Apr 2021 15:10:51 -0400 Subject: [PATCH] ui: toolbar fixes, disable elements on run --- gui/Makefile | 5 ++--- gui/demos/2_iir_echo.cpp | 10 ++++++---- gui/wxmain.cpp | 23 ++++++++++++++--------- gui/wxmain_mrun.cpp | 2 ++ 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/gui/Makefile b/gui/Makefile index 25b1872..e06a740 100644 --- a/gui/Makefile +++ b/gui/Makefile @@ -10,13 +10,12 @@ CXX = g++-10 CXXFLAGS = --std=c++20 -ggdb -O0 \ -Wall -Wextra -pedantic \ -Wno-deprecated-copy \ - -Iserial/include -IMETL/include -IMETL/dependencies/PEGTL/include \ - -Wa,-mbig-obj + -Iserial/include -IMETL/include -IMETL/dependencies/PEGTL/include ifeq ($(UNAME), Linux) CXXFLAGS += $(shell wx-config --cxxflags) else -CXXFLAGS += -IC:\wx\include -DSTMDSP_WIN32 +CXXFLAGS += -IC:\wx\include -DSTMDSP_WIN32 -Wa,-mbig-obj endif ifeq ($(UNAME), Linux) diff --git a/gui/demos/2_iir_echo.cpp b/gui/demos/2_iir_echo.cpp index 0bd7e9d..acb5c5d 100644 --- a/gui/demos/2_iir_echo.cpp +++ b/gui/demos/2_iir_echo.cpp @@ -1,10 +1,12 @@ -adcsample_t *process_data(adcsample_t *samples, unsigned int size) +Sample *process_data(Samples samples) { - constexpr float alpha = 0.7; + constexpr unsigned int size = samples.size(); constexpr unsigned int D = 2000; - static adcsample_t output[SIZE]; - static adcsample_t prev[D]; // prev[0] = output[0 - D] + float alpha = readalt() / 4095.; + + static Sample output[size]; + static Sample prev[D]; // prev[0] = output[0 - D] // Do calculations with previous output for (unsigned int i = 0; i < D; i++) diff --git a/gui/wxmain.cpp b/gui/wxmain.cpp index 98c08ff..ba352e4 100644 --- a/gui/wxmain.cpp +++ b/gui/wxmain.cpp @@ -88,7 +88,7 @@ MainFrame::MainFrame() : wxTE_READONLY | wxTE_MULTILINE | wxHSCROLL | wxTE_RICH2); m_measure_timer = new wxTimer(this, Id::MeasureTimer); m_menu_bar = new wxMenuBar; - m_rate_select = new wxComboBox(panelToolbar, wxID_ANY, + m_rate_select = new wxComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, srateValues.size(), srateValues.data(), @@ -111,14 +111,14 @@ MainFrame::MainFrame() : SetMenuBar(m_menu_bar); // Toolbar initialization - auto comp = new wxButton(this, wxID_ANY, "Compile", {10, 10}); - sizerToolbar->Add(comp, 0, wxLEFT, 4); - sizerToolbar->Add(m_rate_select, 0, wxLEFT, 12); + auto comp = new wxButton(this, wxID_ANY, "Compile"); + sizerToolbar->Add(comp, 0, wxLEFT | wxTOP, 4); + sizerToolbar->Add(m_rate_select, 0, wxLEFT | wxTOP, 4); panelToolbar->SetSizer(sizerToolbar); // Code panel init. prepareEditor(); - sizerCode->Add(panelToolbar, 0, wxTOP | wxBOTTOM, 4); + sizerCode->Add(panelToolbar, 0, wxBOTTOM, 4); sizerCode->Add(m_text_editor, 1, wxEXPAND, 0); panelCode->SetSizer(sizerCode); @@ -446,11 +446,16 @@ void MainFrame::updateMenuOptions() { bool connected = m_device != nullptr; m_menu_bar->Enable(MRunStart, connected); - m_menu_bar->Enable(MRunUpload, connected); - m_menu_bar->Enable(MRunUnload, connected); - m_menu_bar->Enable(MRunEditBSize, connected); m_menu_bar->Enable(MRunGenUpload, connected); m_menu_bar->Enable(MRunGenStart, connected); - m_rate_select->Enable(connected); + + bool nrunning = connected && !m_is_running; + m_menu_bar->Enable(MRunUpload, nrunning); + m_menu_bar->Enable(MRunUnload, nrunning); + m_menu_bar->Enable(MRunEditBSize, nrunning); + m_menu_bar->Enable(MRunMeasure, nrunning); + m_menu_bar->Enable(MRunDrawSamples, nrunning); + m_menu_bar->Enable(MRunLogResults, nrunning); + m_rate_select->Enable(nrunning); } diff --git a/gui/wxmain_mrun.cpp b/gui/wxmain_mrun.cpp index 7283657..5661832 100644 --- a/gui/wxmain_mrun.cpp +++ b/gui/wxmain_mrun.cpp @@ -76,6 +76,8 @@ void MainFrame::onRunStart(wxCommandEvent& ce) if (m_run_draw_samples->IsChecked()) m_compile_output->Refresh(); } + + updateMenuOptions(); } void MainFrame::onRunLogResults(wxCommandEvent& ce)