diff --git a/gui/wxmain.cpp b/gui/wxmain.cpp index 64f36e4..13d7586 100644 --- a/gui/wxmain.cpp +++ b/gui/wxmain.cpp @@ -258,8 +258,6 @@ void MainFrame::onPaint(wxPaintEvent&) dc->SetBrush(*wxBLACK_BRUSH); dc->SetPen(*wxBLACK_PEN); dc->DrawRectangle(rect); - dc->SetBrush(*wxRED_BRUSH); - dc->SetPen(*wxRED_PEN); auto stoy = [&](stmdsp::adcsample_t s) { return static_cast(py) + rect.GetHeight() - (static_cast(rect.GetHeight()) * s / 4095.f); @@ -268,15 +266,17 @@ void MainFrame::onPaint(wxPaintEvent&) 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))); for (decltype(scount) i = 0; i < scount; i++) { auto y = stoy(m_device_samples[i]); dc->DrawLine(x, lasty, x + dx, y); x += dx, lasty = y; } - dc->SetBrush(*wxBLUE_BRUSH); - dc->SetPen(*wxBLUE_PEN); x = 0; lasty = stoy(2048); + 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); diff --git a/gui/wxmain_mrun.h b/gui/wxmain_mrun.h index b00898a..919b17d 100644 --- a/gui/wxmain_mrun.h +++ b/gui/wxmain_mrun.h @@ -103,6 +103,8 @@ void MainFrame::onRunEditBSize(wxCommandEvent&) if (wxString value = dialog.GetValue(); !value.IsEmpty()) { if (unsigned long n; value.ToULong(&n)) { if (n >= 100 && n <= stmdsp::SAMPLES_MAX) { + if (n & 1 == 1) + ++n; m_device->continuous_set_buffer_size(n); } else { m_status_bar->SetStatusText("Error: Invalid buffer size."); @@ -156,6 +158,9 @@ void MainFrame::onRunGenUpload(wxCommandEvent&) } if (samples.size() <= stmdsp::SAMPLES_MAX * 2) { + // DAC buffer must be of even size + if (samples.size() & 1 == 1) + samples.push_back(0); m_device->siggen_upload(&samples[0], samples.size()); m_status_bar->SetStatusText("Generator ready."); } else { diff --git a/source/dac.cpp b/source/dac.cpp index 2116dcb..ce9c465 100644 --- a/source/dac.cpp +++ b/source/dac.cpp @@ -26,13 +26,17 @@ const DACConversionGroup DAC::m_group_config = { .num_channels = 1, .end_cb = nullptr, .error_cb = nullptr, +#if defined(TARGET_PLATFORM_H7) .trigger = 5 // TIM6_TRGO +#elif defined(TARGET_PLATFORM_L4) + .trigger = 0 // TIM6_TRGO +#endif }; void DAC::begin() { - palSetPadMode(GPIOA, 4, PAL_MODE_INPUT_ANALOG); - palSetPadMode(GPIOA, 5, PAL_MODE_INPUT_ANALOG); + palSetPadMode(GPIOA, 4, PAL_STM32_MODE_ANALOG); + palSetPadMode(GPIOA, 5, PAL_STM32_MODE_ANALOG); dacStart(m_driver[0], &m_config); dacStart(m_driver[1], &m_config);