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

stylesheet_tac_unmarked = "QLabel {background-color: white;}"; stylesheet_tac_unmarked = "QLabel {background-color: white;}";


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


lastBufferStr = "0"; lastBufferStr = "0";


connect(ui->check_LogBCI, SIGNAL(toggled(bool)), this, SLOT(setLogBCIData(bool))); connect(ui->check_LogBCI, SIGNAL(toggled(bool)), this, SLOT(setLogBCIData(bool)));
connect(ui->push_ClearLog, SIGNAL(clicked()), this, SLOT(clearLog())); 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) void MainWindow::log(QString logtext)
} }


if(bufferStr != lastBufferStr){ if(bufferStr != lastBufferStr){
//TODO Buffer nur von 1-6 weiterschicken, andere hier schon rausfiltern!
QByteArray data = bufferStr.toUtf8(); QByteArray data = bufferStr.toUtf8();
udpSocket_Feather->writeDatagram(data, FeatherIP_full, FeatherPort); udpSocket_Feather->writeDatagram(data, FeatherIP_full, FeatherPort);
lastBufferStr = bufferStr; lastBufferStr = bufferStr;
//qDebug() << i_direction; //qDebug() << i_direction;


switch (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 case 1: //Tac1
ui->label_Tac1->setStyleSheet(stylesheet_tac_marked); ui->label_Tac1->setStyleSheet(stylesheet_tac_marked);
ui->label_Tac2->setStyleSheet(stylesheet_tac_unmarked); ui->label_Tac2->setStyleSheet(stylesheet_tac_unmarked);
ui->plain_Log->clear(); 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

void readPCSocketData(); void readPCSocketData();
void setLogBCIData(const bool log); void setLogBCIData(const bool log);
void clearLog(); 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: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;




bool logBCIData; bool logBCIData;


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



+ 6
- 6
mainwindow.ui View File

<string>Motor 4</string> <string>Motor 4</string>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>true</bool>
<bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
<string>Motor 3</string> <string>Motor 3</string>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>true</bool>
<bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
<string>Motor 5</string> <string>Motor 5</string>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>true</bool>
<bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
<string>Motor 1</string> <string>Motor 1</string>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>true</bool>
<bool>false</bool>
</property> </property>
<property name="flat"> <property name="flat">
<bool>false</bool> <bool>false</bool>
<string>Motor 6</string> <string>Motor 6</string>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>true</bool>
<bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
<string>Motor 2</string> <string>Motor 2</string>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>true</bool>
<bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>

+ 6
- 6
ui_mainwindow.h View File

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


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


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


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


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


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


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


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


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


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


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



Loading…
Cancel
Save