Browse Source

Implement uncheckable Buttons

master
Igor Beloschapkin 3 years ago
parent
commit
7a32f03feb
4 changed files with 45 additions and 73 deletions
  1. 27
    53
      mainwindow.cpp
  2. 6
    8
      mainwindow.h
  3. 6
    6
      mainwindow.ui
  4. 6
    6
      ui_mainwindow.h

+ 27
- 53
mainwindow.cpp View File

@@ -29,12 +29,6 @@ MainWindow::MainWindow(QWidget *parent) :
stylesheet_tac_unmarked = "QLabel {background-color: white;}";

logBCIData = true;
tac1ON = false;
tac2ON = false;
tac3ON = false;
tac4ON = false;
tac5ON = false;
tac6ON = false;

lastBufferStr = "0";

@@ -53,12 +47,12 @@ void MainWindow::setupSignalsAndSlots()
connect(ui->check_LogBCI, SIGNAL(toggled(bool)), this, SLOT(setLogBCIData(bool)));
connect(ui->push_ClearLog, SIGNAL(clicked()), this, SLOT(clearLog()));

connect(ui->push_Tac1, SIGNAL(clicked(bool)), this, SLOT(pushTac1(bool)));
connect(ui->push_Tac2, SIGNAL(clicked(bool)), this, SLOT(pushTac2(bool)));
connect(ui->push_Tac3, SIGNAL(clicked(bool)), this, SLOT(pushTac3(bool)));
connect(ui->push_Tac4, SIGNAL(clicked(bool)), this, SLOT(pushTac4(bool)));
connect(ui->push_Tac5, SIGNAL(clicked(bool)), this, SLOT(pushTac5(bool)));
connect(ui->push_Tac6, SIGNAL(clicked(bool)), this, SLOT(pushTac6(bool)));
connect(ui->push_Tac1, SIGNAL(clicked(bool)), this, SLOT(pushTac1()));
connect(ui->push_Tac2, SIGNAL(clicked(bool)), this, SLOT(pushTac2()));
connect(ui->push_Tac3, SIGNAL(clicked(bool)), this, SLOT(pushTac3()));
connect(ui->push_Tac4, SIGNAL(clicked(bool)), this, SLOT(pushTac4()));
connect(ui->push_Tac5, SIGNAL(clicked(bool)), this, SLOT(pushTac5()));
connect(ui->push_Tac6, SIGNAL(clicked(bool)), this, SLOT(pushTac6()));
}

void MainWindow::log(QString logtext)
@@ -241,6 +235,7 @@ void MainWindow::readPCSocketData()
}

if(bufferStr != lastBufferStr){
//TODO Buffer nur von 1-6 weiterschicken, andere hier schon rausfiltern!
QByteArray data = bufferStr.toUtf8();
udpSocket_Feather->writeDatagram(data, FeatherIP_full, FeatherPort);
lastBufferStr = bufferStr;
@@ -255,6 +250,14 @@ void MainWindow::markDirectionTactile(const QString direction)
//qDebug() << i_direction;

switch (i_direction) {
case 0: //all Low
ui->label_Tac1->setStyleSheet(stylesheet_tac_unmarked);
ui->label_Tac2->setStyleSheet(stylesheet_tac_unmarked);
ui->label_Tac3->setStyleSheet(stylesheet_tac_unmarked);
ui->label_Tac4->setStyleSheet(stylesheet_tac_unmarked);
ui->label_Tac5->setStyleSheet(stylesheet_tac_unmarked);
ui->label_Tac6->setStyleSheet(stylesheet_tac_unmarked);
break;
case 1: //Tac1
ui->label_Tac1->setStyleSheet(stylesheet_tac_marked);
ui->label_Tac2->setStyleSheet(stylesheet_tac_unmarked);
@@ -316,61 +319,32 @@ void MainWindow::clearLog()
ui->plain_Log->clear();
}

void MainWindow::pushTac1(const bool state)
void MainWindow::pushTac1()
{
tac1ON = state;
pushDirection();
udpSocket_Feather->writeDatagram(QByteArray::number(1), FeatherIP_full, FeatherPort);
}

void MainWindow::pushTac2(const bool state)
void MainWindow::pushTac2()
{
tac2ON = state;
pushDirection();

udpSocket_Feather->writeDatagram(QByteArray::number(2), FeatherIP_full, FeatherPort);
}

void MainWindow::pushTac3(const bool state)
void MainWindow::pushTac3()
{
tac3ON = state;
pushDirection();

udpSocket_Feather->writeDatagram(QByteArray::number(3), FeatherIP_full, FeatherPort);
}

void MainWindow::pushTac4(const bool state)
void MainWindow::pushTac4()
{
tac4ON = state;
pushDirection();
udpSocket_Feather->writeDatagram(QByteArray::number(4), FeatherIP_full, FeatherPort);
}

void MainWindow::pushTac5(const bool state)
void MainWindow::pushTac5()
{
tac5ON = state;
pushDirection();
udpSocket_Feather->writeDatagram(QByteArray::number(5), FeatherIP_full, FeatherPort);
}

void MainWindow::pushTac6(const bool state)
void MainWindow::pushTac6()
{
tac6ON = state;
pushDirection();
}

void MainWindow::pushDirection()
{
if(tac1ON)
udpSocket_Feather->writeDatagram(QByteArray::number(1), FeatherIP_full, FeatherPort);

if(tac2ON)
udpSocket_Feather->writeDatagram(QByteArray::number(2), FeatherIP_full, FeatherPort);

if(tac3ON)
udpSocket_Feather->writeDatagram(QByteArray::number(3), FeatherIP_full, FeatherPort);

if(tac4ON)
udpSocket_Feather->writeDatagram(QByteArray::number(4), FeatherIP_full, FeatherPort);

if(tac5ON)
udpSocket_Feather->writeDatagram(QByteArray::number(5), FeatherIP_full, FeatherPort);

if(tac6ON)
udpSocket_Feather->writeDatagram(QByteArray::number(6), FeatherIP_full, FeatherPort);
udpSocket_Feather->writeDatagram(QByteArray::number(6), FeatherIP_full, FeatherPort);
}

+ 6
- 8
mainwindow.h View File

@@ -21,12 +21,12 @@ private slots:
void readPCSocketData();
void setLogBCIData(const bool log);
void clearLog();
void pushTac1(const bool checked);
void pushTac2(const bool checked);
void pushTac3(const bool state);
void pushTac4(const bool state);
void pushTac5(const bool state);
void pushTac6(const bool state);
void pushTac1();
void pushTac2();
void pushTac3();
void pushTac4();
void pushTac5();
void pushTac6();
private:
Ui::MainWindow *ui;

@@ -52,8 +52,6 @@ private:

bool logBCIData;

bool tac1ON, tac2ON, tac3ON, tac4ON, tac5ON, tac6ON;
void pushDirection();
bool checkPort(const quint16 port);
};


+ 6
- 6
mainwindow.ui View File

@@ -822,7 +822,7 @@
<string>Motor 4</string>
</property>
<property name="checkable">
<bool>true</bool>
<bool>false</bool>
</property>
</widget>
</item>
@@ -844,7 +844,7 @@
<string>Motor 3</string>
</property>
<property name="checkable">
<bool>true</bool>
<bool>false</bool>
</property>
</widget>
</item>
@@ -866,7 +866,7 @@
<string>Motor 5</string>
</property>
<property name="checkable">
<bool>true</bool>
<bool>false</bool>
</property>
</widget>
</item>
@@ -888,7 +888,7 @@
<string>Motor 1</string>
</property>
<property name="checkable">
<bool>true</bool>
<bool>false</bool>
</property>
<property name="flat">
<bool>false</bool>
@@ -913,7 +913,7 @@
<string>Motor 6</string>
</property>
<property name="checkable">
<bool>true</bool>
<bool>false</bool>
</property>
</widget>
</item>
@@ -935,7 +935,7 @@
<string>Motor 2</string>
</property>
<property name="checkable">
<bool>true</bool>
<bool>false</bool>
</property>
</widget>
</item>

+ 6
- 6
ui_mainwindow.h View File

@@ -527,7 +527,7 @@ public:
push_Tac4->setObjectName(QString::fromUtf8("push_Tac4"));
push_Tac4->setMinimumSize(QSize(0, 40));
push_Tac4->setFont(font);
push_Tac4->setCheckable(true);
push_Tac4->setCheckable(false);

gridLayout_3->addWidget(push_Tac4, 1, 1, 1, 1);

@@ -535,7 +535,7 @@ public:
push_Tac3->setObjectName(QString::fromUtf8("push_Tac3"));
push_Tac3->setMinimumSize(QSize(0, 40));
push_Tac3->setFont(font);
push_Tac3->setCheckable(true);
push_Tac3->setCheckable(false);

gridLayout_3->addWidget(push_Tac3, 1, 0, 1, 1);

@@ -543,7 +543,7 @@ public:
push_Tac5->setObjectName(QString::fromUtf8("push_Tac5"));
push_Tac5->setMinimumSize(QSize(0, 40));
push_Tac5->setFont(font);
push_Tac5->setCheckable(true);
push_Tac5->setCheckable(false);

gridLayout_3->addWidget(push_Tac5, 2, 0, 1, 1);

@@ -551,7 +551,7 @@ public:
push_Tac1->setObjectName(QString::fromUtf8("push_Tac1"));
push_Tac1->setMinimumSize(QSize(0, 40));
push_Tac1->setFont(font);
push_Tac1->setCheckable(true);
push_Tac1->setCheckable(false);
push_Tac1->setFlat(false);

gridLayout_3->addWidget(push_Tac1, 0, 0, 1, 1);
@@ -560,7 +560,7 @@ public:
push_Tac6->setObjectName(QString::fromUtf8("push_Tac6"));
push_Tac6->setMinimumSize(QSize(0, 40));
push_Tac6->setFont(font);
push_Tac6->setCheckable(true);
push_Tac6->setCheckable(false);

gridLayout_3->addWidget(push_Tac6, 2, 1, 1, 1);

@@ -568,7 +568,7 @@ public:
push_Tac2->setObjectName(QString::fromUtf8("push_Tac2"));
push_Tac2->setMinimumSize(QSize(0, 40));
push_Tac2->setFont(font);
push_Tac2->setCheckable(true);
push_Tac2->setCheckable(false);

gridLayout_3->addWidget(push_Tac2, 0, 1, 1, 1);


Loading…
Cancel
Save