ui: toolbar fixes, disable elements on run

master
Clyne 4 years ago
parent ae99ff5967
commit ab0f6acf4d

@ -10,13 +10,12 @@ CXX = g++-10
CXXFLAGS = --std=c++20 -ggdb -O0 \ CXXFLAGS = --std=c++20 -ggdb -O0 \
-Wall -Wextra -pedantic \ -Wall -Wextra -pedantic \
-Wno-deprecated-copy \ -Wno-deprecated-copy \
-Iserial/include -IMETL/include -IMETL/dependencies/PEGTL/include \ -Iserial/include -IMETL/include -IMETL/dependencies/PEGTL/include
-Wa,-mbig-obj
ifeq ($(UNAME), Linux) ifeq ($(UNAME), Linux)
CXXFLAGS += $(shell wx-config --cxxflags) CXXFLAGS += $(shell wx-config --cxxflags)
else else
CXXFLAGS += -IC:\wx\include -DSTMDSP_WIN32 CXXFLAGS += -IC:\wx\include -DSTMDSP_WIN32 -Wa,-mbig-obj
endif endif
ifeq ($(UNAME), Linux) ifeq ($(UNAME), Linux)

@ -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; constexpr unsigned int D = 2000;
static adcsample_t output[SIZE]; float alpha = readalt() / 4095.;
static adcsample_t prev[D]; // prev[0] = output[0 - D]
static Sample output[size];
static Sample prev[D]; // prev[0] = output[0 - D]
// Do calculations with previous output // Do calculations with previous output
for (unsigned int i = 0; i < D; i++) for (unsigned int i = 0; i < D; i++)

@ -88,7 +88,7 @@ MainFrame::MainFrame() :
wxTE_READONLY | wxTE_MULTILINE | wxHSCROLL | wxTE_RICH2); wxTE_READONLY | wxTE_MULTILINE | wxHSCROLL | wxTE_RICH2);
m_measure_timer = new wxTimer(this, Id::MeasureTimer); m_measure_timer = new wxTimer(this, Id::MeasureTimer);
m_menu_bar = new wxMenuBar; m_menu_bar = new wxMenuBar;
m_rate_select = new wxComboBox(panelToolbar, wxID_ANY, m_rate_select = new wxComboBox(this, wxID_ANY,
wxEmptyString, wxEmptyString,
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
srateValues.size(), srateValues.data(), srateValues.size(), srateValues.data(),
@ -111,14 +111,14 @@ MainFrame::MainFrame() :
SetMenuBar(m_menu_bar); SetMenuBar(m_menu_bar);
// Toolbar initialization // Toolbar initialization
auto comp = new wxButton(this, wxID_ANY, "Compile", {10, 10}); auto comp = new wxButton(this, wxID_ANY, "Compile");
sizerToolbar->Add(comp, 0, wxLEFT, 4); sizerToolbar->Add(comp, 0, wxLEFT | wxTOP, 4);
sizerToolbar->Add(m_rate_select, 0, wxLEFT, 12); sizerToolbar->Add(m_rate_select, 0, wxLEFT | wxTOP, 4);
panelToolbar->SetSizer(sizerToolbar); panelToolbar->SetSizer(sizerToolbar);
// Code panel init. // Code panel init.
prepareEditor(); prepareEditor();
sizerCode->Add(panelToolbar, 0, wxTOP | wxBOTTOM, 4); sizerCode->Add(panelToolbar, 0, wxBOTTOM, 4);
sizerCode->Add(m_text_editor, 1, wxEXPAND, 0); sizerCode->Add(m_text_editor, 1, wxEXPAND, 0);
panelCode->SetSizer(sizerCode); panelCode->SetSizer(sizerCode);
@ -446,11 +446,16 @@ void MainFrame::updateMenuOptions()
{ {
bool connected = m_device != nullptr; bool connected = m_device != nullptr;
m_menu_bar->Enable(MRunStart, connected); 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(MRunGenUpload, connected);
m_menu_bar->Enable(MRunGenStart, 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);
} }

@ -76,6 +76,8 @@ void MainFrame::onRunStart(wxCommandEvent& ce)
if (m_run_draw_samples->IsChecked()) if (m_run_draw_samples->IsChecked())
m_compile_output->Refresh(); m_compile_output->Refresh();
} }
updateMenuOptions();
} }
void MainFrame::onRunLogResults(wxCommandEvent& ce) void MainFrame::onRunLogResults(wxCommandEvent& ce)

Loading…
Cancel
Save