Skip to content

Commit

Permalink
Support Arduino boards setting DTR to true
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmucde committed May 16, 2022
1 parent e1459ed commit ad58ee6
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ Github Sponsors:

v0.1.4:

* Support Arduino boards setting DTR to true
* Cleanup current output
* Support OWON XDM1041 Multimeter

Expand Down
1 change: 0 additions & 1 deletion dltmultimeter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ DLTMultimeter::DLTMultimeter(QObject *parent) : QObject(parent)
clearSettings();

value = 0;
type = 0;
powerName = "Power";
readVoltageOngoing = false;
}
Expand Down
25 changes: 22 additions & 3 deletions dltrelais.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

DLTRelais::DLTRelais(QObject *parent) : QObject(parent)
{
clearSettings();
clearSettings();
}

DLTRelais::~DLTRelais()
Expand Down Expand Up @@ -82,8 +82,11 @@ void DLTRelais::start()
{
// open with success

// prevent flash mode of Wemos D1 mini
serialPort.setDataTerminalReady(false);
// prevent flash mode of Wemos D1 mini and Wemos D1, not for Arduino boards
if(type==2) // Arduino Boards
serialPort.setDataTerminalReady(true);
else
serialPort.setDataTerminalReady(false);

// connect slot to receive data from serial port
connect(&serialPort, SIGNAL(readyRead()), this, SLOT(readyRead()));
Expand Down Expand Up @@ -212,9 +215,20 @@ void DLTRelais::timeout()
}
}

int DLTRelais::getType() const
{
return type;
}

void DLTRelais::setType(int newType)
{
type = newType;
}

void DLTRelais::clearSettings()
{
// clear settings
type = 0;
for(int num=0;num<4;num++)
relaisName[num] = QString("Relais%1").arg(num+1);

Expand All @@ -237,6 +251,7 @@ void DLTRelais::writeSettings(QXmlStreamWriter &xml,int num)
xml.writeTextElement("interfaceSerialNumber",QSerialPortInfo(interface).serialNumber());
xml.writeTextElement("interfaceProductIdentifier",QString("%1").arg(QSerialPortInfo(interface).productIdentifier()));
xml.writeTextElement("interfaceVendorIdentifier",QString("%1").arg(QSerialPortInfo(interface).vendorIdentifier()));
xml.writeTextElement("type",QString("%1").arg(type));
xml.writeTextElement("active",QString("%1").arg(active));
xml.writeEndElement(); // DLTRelais
}
Expand Down Expand Up @@ -293,6 +308,10 @@ void DLTRelais::readSettings(const QString &filename,int num)
{
interfaceVendorIdentifier = xml.readElementText().toUShort();
}
else if(xml.name() == QString("type"))
{
type = xml.readElementText().toInt();
}
else if(xml.name() == QString("active"))
{
active = xml.readElementText().toInt();
Expand Down
4 changes: 4 additions & 0 deletions dltrelais.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ class DLTRelais : public QObject
void writeSettings(QXmlStreamWriter &xml,int num);
void readSettings(const QString &filename,int num);

int getType() const;
void setType(int newType);

signals:

// Called when status changed
Expand All @@ -76,6 +79,7 @@ private slots:
unsigned int watchDogCounter,watchDogCounterLast;

// Settings
int type;
QString interface;
QString interfaceSerialNumber;
ushort interfaceProductIdentifier;
Expand Down
4 changes: 4 additions & 0 deletions settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ void SettingsDialog::restoreSettings(DLTRelais *dltRelais1, DLTRelais *dltRelais
ui->comboBoxSerialPort2->setCurrentText(dltRelais2->getInterface());
ui->checkBoxRelais1Active->setChecked(dltRelais1->getActive());
ui->checkBoxRelais2Active->setChecked(dltRelais2->getActive());
ui->comboBoxRelaisBoardType1->setCurrentIndex(dltRelais1->getType());
ui->comboBoxRelaisBoardType2->setCurrentIndex(dltRelais2->getType());

/* DLTMultimeter */
ui->comboBoxSerialPortMultimeter1->setCurrentText(dltMultimeter1->getInterface());
Expand Down Expand Up @@ -125,6 +127,8 @@ void SettingsDialog::backupSettings(DLTRelais *dltRelais1, DLTRelais *dltRelais2
dltRelais2->setRelaisName(4,ui->lineEditRelaisName8->text());
dltRelais1->setActive(ui->checkBoxRelais1Active->isChecked());
dltRelais2->setActive(ui->checkBoxRelais2Active->isChecked());
dltRelais1->setType(ui->comboBoxRelaisBoardType1->currentIndex());
dltRelais2->setType(ui->comboBoxRelaisBoardType2->currentIndex());

/* DLTMultimeter */
dltMultimeter1->setInterface(ui->comboBoxSerialPortMultimeter1->currentText());
Expand Down
52 changes: 52 additions & 0 deletions settingsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,32 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_22">
<property name="text">
<string>Type:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxRelaisBoardType1">
<item>
<property name="text">
<string>Wemos Mini D1 (3 Relais)</string>
</property>
</item>
<item>
<property name="text">
<string>Wemos D1 (4 Relais)</string>
</property>
</item>
<item>
<property name="text">
<string>Arduino Boards</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
Expand Down Expand Up @@ -175,6 +201,32 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_23">
<property name="text">
<string>Type:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxRelaisBoardType2">
<item>
<property name="text">
<string>Wemos Mini D1 (3 Relais)</string>
</property>
</item>
<item>
<property name="text">
<string>Wemos D1 (4 Relais)</string>
</property>
</item>
<item>
<property name="text">
<string>Arduino Boards</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="label_8">
<property name="text">
Expand Down

0 comments on commit ad58ee6

Please sign in to comment.