+) spi初始化的界面逻辑
This commit is contained in:
parent
8dc807662a
commit
f96b1eb169
@ -106,6 +106,7 @@ void MainWindow::on_pushButton_5_clicked()
|
||||
ui->lineEdit->setEnabled(false);
|
||||
ui->pushButton_5->setEnabled(false);
|
||||
ui->pushButton_7->setEnabled(true);
|
||||
ui->btnSpiSaveSetting->setEnabled(false);
|
||||
onLogPrint("Close device success");
|
||||
}else{
|
||||
onLogPrint("Close device failed");
|
||||
@ -134,15 +135,17 @@ void MainWindow::on_pushButton_2_clicked()
|
||||
|
||||
// 判断打开串口设备是否成功
|
||||
if(status == TRUE){
|
||||
ui->comboBox_3->setEnabled(true);
|
||||
ui->comboBox_4->setEnabled(true);
|
||||
ui->comboBox_5->setEnabled(true);
|
||||
ui->comboBox_6->setEnabled(true);
|
||||
ui->comboBox_16->setEnabled(true);
|
||||
ui->comboBox_17->setEnabled(true);
|
||||
ui->comboSpiMode->setEnabled(true);
|
||||
ui->comboSpiClock->setEnabled(true);
|
||||
ui->comboSpiByteOrder->setEnabled(true);
|
||||
ui->comboSpiDataBits->setEnabled(true);
|
||||
ui->comboSpiCS1Pol->setEnabled(true);
|
||||
ui->comboSpiCS2Pol->setEnabled(true);
|
||||
ui->pushButton_3->setEnabled(true);
|
||||
ui->pushButton_2->setEnabled(false);
|
||||
ui->btnSpiSaveSetting->setEnabled(true);
|
||||
onLogPrint("Open device success");
|
||||
on_btnSpiSaveSetting_clicked(); // 初始化SPI参数
|
||||
}else{
|
||||
onLogPrint("Open device failed");
|
||||
}
|
||||
@ -157,12 +160,12 @@ void MainWindow::on_pushButton_3_clicked()
|
||||
|
||||
// 判断打开串口设备是否成功
|
||||
if(status == TRUE){
|
||||
ui->comboBox_3->setEnabled(false);
|
||||
ui->comboBox_4->setEnabled(false);
|
||||
ui->comboBox_5->setEnabled(false);
|
||||
ui->comboBox_6->setEnabled(false);
|
||||
ui->comboBox_16->setEnabled(false);
|
||||
ui->comboBox_17->setEnabled(false);
|
||||
ui->comboSpiMode->setEnabled(false);
|
||||
ui->comboSpiClock->setEnabled(false);
|
||||
ui->comboSpiByteOrder->setEnabled(false);
|
||||
ui->comboSpiDataBits->setEnabled(false);
|
||||
ui->comboSpiCS1Pol->setEnabled(false);
|
||||
ui->comboSpiCS2Pol->setEnabled(false);
|
||||
ui->pushButton_3->setEnabled(false);
|
||||
ui->pushButton_2->setEnabled(true);
|
||||
|
||||
@ -172,3 +175,44 @@ void MainWindow::on_pushButton_3_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_btnSpiSaveSetting_clicked() {
|
||||
drvSPI->spi_Init(
|
||||
ui->comboBox_2->currentIndex(),
|
||||
ui->comboSpiMode->currentIndex(),
|
||||
ui->comboSpiClock->currentIndex(),
|
||||
ui->comboSpiByteOrder->currentIndex(),
|
||||
ui->comboSpiDataBits->currentIndex(),
|
||||
ui->comboSpiCS1Pol->currentIndex(),
|
||||
ui->comboSpiCS2Pol->currentIndex()
|
||||
);
|
||||
}
|
||||
|
||||
void MainWindow::onWriteRegButtonClicked() {
|
||||
QByteArray ba;
|
||||
ba.append(0x9F);
|
||||
ba.append(0xE4);
|
||||
ba.append(0x05);
|
||||
ba.append(0x0B);
|
||||
for (int i = 0; i < 11; ++i) {
|
||||
ba.append((char)0x00);
|
||||
}
|
||||
ba.append(0x93);
|
||||
|
||||
drvSPI->spi_Write(ba);
|
||||
qDebug() << __FUNCTION__ << ba;
|
||||
}
|
||||
|
||||
void MainWindow::onReadRegButtonClicked() {
|
||||
qDebug() << __FUNCTION__;
|
||||
}
|
||||
|
||||
void MainWindow::on_comboBox_currentTextChanged(const QString& text) {
|
||||
if (text.toLower() == "spi") {
|
||||
connect(ui->pushButton_4, &QPushButton::clicked, this, &MainWindow::onWriteRegButtonClicked);
|
||||
connect(ui->pushButton_10, &QPushButton::clicked, this, &MainWindow::onReadRegButtonClicked);
|
||||
} else {
|
||||
disconnect(ui->pushButton_4, &QPushButton::clicked, this, &MainWindow::onWriteRegButtonClicked);
|
||||
disconnect(ui->pushButton_10, &QPushButton::clicked, this, &MainWindow::onReadRegButtonClicked);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -49,11 +49,16 @@ private slots:
|
||||
|
||||
void on_pushButton_3_clicked();
|
||||
|
||||
void on_btnSpiSaveSetting_clicked();
|
||||
void onWriteRegButtonClicked();
|
||||
void onReadRegButtonClicked();
|
||||
|
||||
void on_comboBox_currentTextChanged(const QString& text);
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
DialogCalibrate *dc;
|
||||
DRV_Uart *drvUart;
|
||||
DRV_Spi *drvSPI;
|
||||
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
||||
|
||||
@ -90,7 +90,7 @@
|
||||
<string>Timeout(ms):</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -149,7 +149,7 @@
|
||||
<string>Data Bits:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -159,7 +159,7 @@
|
||||
<string>Stop Bits:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -258,7 +258,7 @@
|
||||
<string>Baud Rate:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -268,7 +268,7 @@
|
||||
<string>Parity Bits:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -288,7 +288,7 @@
|
||||
<string>UART Device List:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -311,15 +311,18 @@
|
||||
<string>SPI Device List:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="comboBox_4">
|
||||
<widget class="QComboBox" name="comboSpiByteOrder">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>LSB</string>
|
||||
@ -333,7 +336,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QComboBox" name="comboBox_6">
|
||||
<widget class="QComboBox" name="comboSpiDataBits">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
@ -355,12 +358,15 @@
|
||||
<string>SPI Mode:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="5" rowspan="2">
|
||||
<widget class="QPushButton" name="pushButton_4">
|
||||
<widget class="QPushButton" name="btnSpiSaveSetting">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
@ -383,10 +389,13 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QComboBox" name="comboBox_5">
|
||||
<widget class="QComboBox" name="comboSpiClock">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>60MHz</string>
|
||||
@ -435,7 +444,7 @@
|
||||
<string>Clock:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -445,12 +454,12 @@
|
||||
<string>LSB/MSB</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="comboBox_3">
|
||||
<widget class="QComboBox" name="comboSpiMode">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
@ -482,12 +491,12 @@
|
||||
<string>DataBits:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="QComboBox" name="comboBox_16">
|
||||
<widget class="QComboBox" name="comboSpiCS1Pol">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
@ -504,7 +513,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="4">
|
||||
<widget class="QComboBox" name="comboBox_17">
|
||||
<widget class="QComboBox" name="comboSpiCS2Pol">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
@ -632,10 +641,10 @@
|
||||
<item row="0" column="6">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||
<enum>QSizePolicy::Policy::MinimumExpanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@ -1057,7 +1066,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="pushButton_9">
|
||||
<widget class="QPushButton" name="pushButton_4">
|
||||
<property name="text">
|
||||
<string>Write Reg</string>
|
||||
</property>
|
||||
@ -1091,7 +1100,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>839</width>
|
||||
<height>21</height>
|
||||
<height>33</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user