Browse Source

WIP Add 6 Tactilo Motors

master
Igor Beloschapkin 3 years ago
parent
commit
3d865528ec
4 changed files with 191 additions and 90 deletions
  1. 4
    3
      TactileBCIFilter.pro.user
  2. 106
    52
      mainwindow.cpp
  3. 7
    5
      mainwindow.h
  4. 74
    30
      mainwindow.ui

+ 4
- 3
TactileBCIFilter.pro.user View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.12.4, 2020-08-28T14:10:30. -->
<!-- Written by QtCreator 4.12.4, 2020-11-09T15:08:36. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
@@ -308,8 +308,9 @@
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:/Users/bci/Desktop/Qt Filter Program/TactileBCIFilter/TactileBCIFilter.pro</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">C:/Users/bci/Desktop/Qt Filter Program/TactileBCIFilter/TactileBCIFilter.pro</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">TactileBCIFilter2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:/Users/bci/Desktop/tactilebcifilter/TactileBCIFilter.pro</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">C:/Users/bci/Desktop/tactilebcifilter/TactileBCIFilter.pro</value>
<value type="QString" key="RunConfiguration.Arguments"></value>
<value type="bool" key="RunConfiguration.Arguments.multi">false</value>
<value type="QString" key="RunConfiguration.OverrideDebuggerStartup"></value>

+ 106
- 52
mainwindow.cpp View File

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

logBCIData = true;
leftON = false;
rightON = false;
forwardON = false;
backON = false;
tac1ON = false;
tac2ON = false;
tac3ON = false;
tac4ON = false;
tac5ON = false;
tac6ON = false;

lastBufferStr = "0";

@@ -51,10 +53,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_Left, SIGNAL(clicked(bool)), this, SLOT(pushLeft(bool)));
connect(ui->push_Right, SIGNAL(clicked(bool)), this, SLOT(pushRight(bool)));
connect(ui->push_Forward, SIGNAL(clicked(bool)), this, SLOT(pushForward(bool)));
connect(ui->push_Back, SIGNAL(clicked(bool)), this, SLOT(pushBack(bool)));
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_allLOW, SIGNAL(clicked()), this, SLOT(allLOW()));
connect(ui->push_allHIGH, SIGNAL(clicked()), this, SLOT(allHIGH()));
}
@@ -254,34 +258,60 @@ void MainWindow::markDirectionTactile(const QString direction)

switch (i_direction) {
case 0: //nothing
ui->label_Left->setStyleSheet(stylesheet_tac_unmarked);
ui->label_Right->setStyleSheet(stylesheet_tac_unmarked);
ui->label_Forward->setStyleSheet(stylesheet_tac_unmarked);
ui->label_Back->setStyleSheet(stylesheet_tac_unmarked);
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: //left
ui->label_Left->setStyleSheet(stylesheet_tac_marked);
ui->label_Right->setStyleSheet(stylesheet_tac_unmarked);
ui->label_Forward->setStyleSheet(stylesheet_tac_unmarked);
ui->label_Back->setStyleSheet(stylesheet_tac_unmarked);
case 1: //Tac1
ui->label_Tac1->setStyleSheet(stylesheet_tac_marked);
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 2: //right
ui->label_Left->setStyleSheet(stylesheet_tac_unmarked);
ui->label_Right->setStyleSheet(stylesheet_tac_marked);
ui->label_Forward->setStyleSheet(stylesheet_tac_unmarked);
ui->label_Back->setStyleSheet(stylesheet_tac_unmarked);
case 2: //Tac2
ui->label_Tac1->setStyleSheet(stylesheet_tac_unmarked);
ui->label_Tac2->setStyleSheet(stylesheet_tac_marked);
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 3: //forward
ui->label_Left->setStyleSheet(stylesheet_tac_unmarked);
ui->label_Right->setStyleSheet(stylesheet_tac_unmarked);
ui->label_Forward->setStyleSheet(stylesheet_tac_marked);
ui->label_Back->setStyleSheet(stylesheet_tac_unmarked);
case 3: //Tac3
ui->label_Tac1->setStyleSheet(stylesheet_tac_unmarked);
ui->label_Tac2->setStyleSheet(stylesheet_tac_unmarked);
ui->label_Tac3->setStyleSheet(stylesheet_tac_marked);
ui->label_Tac4->setStyleSheet(stylesheet_tac_unmarked);
ui->label_Tac5->setStyleSheet(stylesheet_tac_unmarked);
ui->label_Tac6->setStyleSheet(stylesheet_tac_unmarked);
break;
case 4: //back
ui->label_Left->setStyleSheet(stylesheet_tac_unmarked);
ui->label_Right->setStyleSheet(stylesheet_tac_unmarked);
ui->label_Forward->setStyleSheet(stylesheet_tac_unmarked);
ui->label_Back->setStyleSheet(stylesheet_tac_marked);
case 4: //Tac4
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_marked);
ui->label_Tac5->setStyleSheet(stylesheet_tac_unmarked);
ui->label_Tac6->setStyleSheet(stylesheet_tac_unmarked);
break;
case 5: //Tac5
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_marked);
ui->label_Tac6->setStyleSheet(stylesheet_tac_unmarked);
break;
case 6: //Tac6
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_marked);
break;
}
}
@@ -296,29 +326,41 @@ void MainWindow::clearLog()
ui->plain_Log->clear();
}

void MainWindow::pushLeft(const bool state)
void MainWindow::pushTac1(const bool state)
{
tac1ON = state;
pushDirection();
}

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

}

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

}

void MainWindow::pushForward(const bool state)
void MainWindow::pushTac4(const bool state)
{
forwardON = state;
tac4ON = state;
pushDirection();
}

void MainWindow::pushTac5(const bool state)
{
tac5ON = state;
pushDirection();
}

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

@@ -327,26 +369,34 @@ void MainWindow::pushDirection()
//first switch off all
udpSocket_Feather->writeDatagram(QByteArray::number(0), FeatherIP_full, FeatherPort);

if(leftON)
if(tac1ON)
udpSocket_Feather->writeDatagram(QByteArray::number(1), FeatherIP_full, FeatherPort);

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

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

if(backON)
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);
}

void MainWindow::allLOW()
{
udpSocket_Feather->writeDatagram(QByteArray::number(0), FeatherIP_full, FeatherPort);
ui->push_Left->setChecked(false);
ui->push_Right->setChecked(false);
ui->push_Forward->setChecked(false);
ui->push_Back->setChecked(false);
ui->push_Tac1->setChecked(false);
ui->push_Tac2->setChecked(false);
ui->push_Tac3->setChecked(false);
ui->push_Tac4->setChecked(false);
ui->push_Tac5->setChecked(false);
ui->push_Tac6->setChecked(false);
}

void MainWindow::allHIGH()
@@ -355,8 +405,12 @@ void MainWindow::allHIGH()
udpSocket_Feather->writeDatagram(QByteArray::number(2), FeatherIP_full, FeatherPort);
udpSocket_Feather->writeDatagram(QByteArray::number(3), FeatherIP_full, FeatherPort);
udpSocket_Feather->writeDatagram(QByteArray::number(4), FeatherIP_full, FeatherPort);
ui->push_Left->setChecked(true);
ui->push_Right->setChecked(true);
ui->push_Forward->setChecked(true);
ui->push_Back->setChecked(true);
udpSocket_Feather->writeDatagram(QByteArray::number(5), FeatherIP_full, FeatherPort);
udpSocket_Feather->writeDatagram(QByteArray::number(6), FeatherIP_full, FeatherPort);
ui->push_Tac1->setChecked(true);
ui->push_Tac2->setChecked(true);
ui->push_Tac3->setChecked(true);
ui->push_Tac4->setChecked(true);
ui->push_Tac5->setChecked(true);
ui->push_Tac6->setChecked(true);
}

+ 7
- 5
mainwindow.h View File

@@ -21,10 +21,12 @@ private slots:
void readPCSocketData();
void setLogBCIData(const bool log);
void clearLog();
void pushLeft(const bool checked);
void pushRight(const bool checked);
void pushForward(const bool state);
void pushBack(const bool state);
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 allLOW();
void allHIGH();
private:
@@ -52,7 +54,7 @@ private:

bool logBCIData;

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

+ 74
- 30
mainwindow.ui View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>515</width>
<height>486</height>
<height>532</height>
</rect>
</property>
<property name="maximumSize">
@@ -616,8 +616,8 @@
<property name="bottomMargin">
<number>5</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_Left">
<item row="1" column="0">
<widget class="QLabel" name="label_Tac2">
<property name="minimumSize">
<size>
<width>0</width>
@@ -638,15 +638,15 @@
<enum>QFrame::Box</enum>
</property>
<property name="text">
<string>LINKS</string>
<string>Motor 2</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_Right">
<item row="3" column="0">
<widget class="QLabel" name="label_Tac4">
<property name="minimumSize">
<size>
<width>0</width>
@@ -667,7 +667,7 @@
<enum>QFrame::Box</enum>
</property>
<property name="text">
<string>RECHTS</string>
<string>Motor 4</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
@@ -675,7 +675,7 @@
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_Forward">
<widget class="QLabel" name="label_Tac3">
<property name="minimumSize">
<size>
<width>0</width>
@@ -696,15 +696,15 @@
<enum>QFrame::Box</enum>
</property>
<property name="text">
<string>VOR</string>
<string>Motor 3</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_Back">
<item row="0" column="0">
<widget class="QLabel" name="label_Tac1">
<property name="minimumSize">
<size>
<width>0</width>
@@ -725,7 +725,7 @@
<enum>QFrame::Box</enum>
</property>
<property name="text">
<string>ZURÜCK</string>
<string>Motor 1</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
@@ -746,21 +746,30 @@
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_3">
<item row="2" column="1">
<widget class="QPushButton" name="push_allLOW">
<item row="0" column="0">
<widget class="QPushButton" name="push_Tac1">
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>All LOW</string>
<string>Motor 1</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="push_Forward">
<item row="0" column="1">
<widget class="QPushButton" name="push_Tac2">
<property name="minimumSize">
<size>
<width>0</width>
@@ -774,15 +783,15 @@
</font>
</property>
<property name="text">
<string>VOR</string>
<string>Motor 2</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="push_allHIGH">
<item row="3" column="1">
<widget class="QPushButton" name="push_allLOW">
<property name="minimumSize">
<size>
<width>0</width>
@@ -790,12 +799,12 @@
</size>
</property>
<property name="text">
<string>All HIGH</string>
<string>All LOW</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="push_Left">
<item row="1" column="1">
<widget class="QPushButton" name="push_Tac4">
<property name="minimumSize">
<size>
<width>0</width>
@@ -809,15 +818,15 @@
</font>
</property>
<property name="text">
<string>LINKS</string>
<string>Motor 4</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="push_Back">
<item row="1" column="0">
<widget class="QPushButton" name="push_Tac3">
<property name="minimumSize">
<size>
<width>0</width>
@@ -831,15 +840,50 @@
</font>
</property>
<property name="text">
<string>ZURÜCK</string>
<string>Motor 3</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="push_Right">
<item row="3" column="0">
<widget class="QPushButton" name="push_allHIGH">
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="text">
<string>All HIGH</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="push_Tac6">
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Motor 6</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="push_Tac5">
<property name="minimumSize">
<size>
<width>0</width>
@@ -853,7 +897,7 @@
</font>
</property>
<property name="text">
<string>RECHTS</string>
<string>Motor 5</string>
</property>
<property name="checkable">
<bool>true</bool>

Loading…
Cancel
Save