Compare commits

...

2 Commits

Author SHA1 Message Date
Michael Mehari 674f29fa05
Merge 752b488caf into a0f0193fca 2024-03-26 05:34:39 +00:00
mmehari 752b488caf Backup/restore legacy waveform when enabling/disabling txUart 2024-03-26 06:34:19 +01:00
3 changed files with 37 additions and 3 deletions

View File

@ -10,6 +10,7 @@ ChannelData const& SingleChannelController::getData() const {
void SingleChannelController::waveformName(QString newName) void SingleChannelController::waveformName(QString newName)
{ {
qDebug() << "newName = " << newName; qDebug() << "newName = " << newName;
m_data.waveform = newName;
newName.append(".tlw"); newName.append(".tlw");
int length; int length;
@ -139,12 +140,22 @@ void SingleChannelController::txuartUpdate(int baudRate, std::vector<uint8_t> sa
m_data.samples.resize(length); m_data.samples.resize(length);
m_data.samples = samples; m_data.samples = samples;
m_data.freq = baudRate/length; m_data.freq = baudRate/length;
m_data.divisibility = 1;
m_data.repeat_forever = false; m_data.repeat_forever = false;
notifyUpdate(this); notifyUpdate(this);
} }
void SingleChannelController::backup_waveform()
{
m_data.freq2 = m_data.freq;
}
void SingleChannelController::restore_waveform()
{
m_data.freq = m_data.freq2;
waveformName(m_data.waveform);
}
DualChannelController::DualChannelController(QWidget *parent) : QLabel(parent) DualChannelController::DualChannelController(QWidget *parent) : QLabel(parent)
{ {
@ -208,6 +219,16 @@ void DualChannelController::txuartUpdate(ChannelID channelID, int baudRate, std:
getChannelController(channelID)->txuartUpdate(baudRate, samples); getChannelController(channelID)->txuartUpdate(baudRate, samples);
} }
void DualChannelController::backup_waveform(ChannelID channelID)
{
getChannelController(channelID)->backup_waveform();
}
void DualChannelController::restore_waveform(ChannelID channelID)
{
getChannelController(channelID)->restore_waveform();
}
void DualChannelController::waveformName_CH1(QString newName) void DualChannelController::waveformName_CH1(QString newName)
{ {

View File

@ -24,9 +24,10 @@ enum class ChannelID
struct ChannelData struct ChannelData
{ {
std::vector<uint8_t> samples; std::vector<uint8_t> samples;
QString waveform;
bool repeat_forever; bool repeat_forever;
int divisibility; int divisibility;
double freq = 1000.0; double freq = 1000.0, freq2 = 1000.0;
double amplitude = 0.0; double amplitude = 0.0;
double offset = 0.0; double offset = 0.0;
}; };
@ -49,6 +50,8 @@ public slots:
void amplitudeUpdate(double newAmplitude); void amplitudeUpdate(double newAmplitude);
void offsetUpdate(double newOffset); void offsetUpdate(double newOffset);
void txuartUpdate(int baudRate, std::vector<uint8_t> samples); void txuartUpdate(int baudRate, std::vector<uint8_t> samples);
void backup_waveform();
void restore_waveform();
private: private:
ChannelData m_data; ChannelData m_data;
@ -63,6 +66,8 @@ public:
public: public:
SingleChannelController* getChannelController(ChannelID channelID); SingleChannelController* getChannelController(ChannelID channelID);
void txuartUpdate(ChannelID channelID, int baudRate, std::vector<uint8_t> samples); void txuartUpdate(ChannelID channelID, int baudRate, std::vector<uint8_t> samples);
void backup_waveform(ChannelID channelID);
void restore_waveform(ChannelID channelID);
signals: signals:
void functionGenToUpdate(ChannelID channel, SingleChannelController* fGenControl); void functionGenToUpdate(ChannelID channel, SingleChannelController* fGenControl);

View File

@ -2639,8 +2639,12 @@ void MainWindow::on_serialEncodingCheck_CH1_toggled(bool checked)
std::vector<uint8_t> data; std::vector<uint8_t> data;
// If uart encoding is enabled // If uart encoding is enabled
using functionGen::ChannelID;
if(checked) if(checked)
{ {
// Backup waveform on CH1
ui->controller_fg->backup_waveform(ChannelID::CH1);
// Enable uart decoding // Enable uart decoding
ui->serialDecodingCheck_CH1->setChecked(true); ui->serialDecodingCheck_CH1->setChecked(true);
@ -2653,9 +2657,13 @@ void MainWindow::on_serialEncodingCheck_CH1_toggled(bool checked)
data = uartEncode("\r\n", parity_CH1); data = uartEncode("\r\n", parity_CH1);
// Transmit txuart data // Transmit txuart data
using functionGen::ChannelID;
ui->controller_fg->txuartUpdate(ChannelID::CH1, baudRate_CH1, data); ui->controller_fg->txuartUpdate(ChannelID::CH1, baudRate_CH1, data);
} }
else
{
// Restore waveform on CH1
ui->controller_fg->restore_waveform(ChannelID::CH1);
}
} }
void MainWindow::on_txuart_textChanged() void MainWindow::on_txuart_textChanged()