Browse Source

WIP Add 6 Tactilo Motors

master
Igor Beloschapkin 4 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

<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!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> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>
</valuelist> </valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value> <value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> <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="QString" key="RunConfiguration.Arguments"></value>
<value type="bool" key="RunConfiguration.Arguments.multi">false</value> <value type="bool" key="RunConfiguration.Arguments.multi">false</value>
<value type="QString" key="RunConfiguration.OverrideDebuggerStartup"></value> <value type="QString" key="RunConfiguration.OverrideDebuggerStartup"></value>

+ 106
- 52
mainwindow.cpp View File

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


logBCIData = true; logBCIData = true;
leftON = false;
rightON = false;
forwardON = false;
backON = false;
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_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_allLOW, SIGNAL(clicked()), this, SLOT(allLOW()));
connect(ui->push_allHIGH, SIGNAL(clicked()), this, SLOT(allHIGH())); connect(ui->push_allHIGH, SIGNAL(clicked()), this, SLOT(allHIGH()));
} }


switch (i_direction) { switch (i_direction) {
case 0: //nothing 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; 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; 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; 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; 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; break;
} }
} }
ui->plain_Log->clear(); 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(); pushDirection();

} }


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


} }


void MainWindow::pushForward(const bool state)
void MainWindow::pushTac4(const bool state)
{ {
forwardON = state;
tac4ON = state;
pushDirection(); 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(); pushDirection();
} }


//first switch off all //first switch off all
udpSocket_Feather->writeDatagram(QByteArray::number(0), FeatherIP_full, FeatherPort); udpSocket_Feather->writeDatagram(QByteArray::number(0), FeatherIP_full, FeatherPort);


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


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


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


if(backON)
if(tac4ON)
udpSocket_Feather->writeDatagram(QByteArray::number(4), FeatherIP_full, FeatherPort); 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() void MainWindow::allLOW()
{ {
udpSocket_Feather->writeDatagram(QByteArray::number(0), FeatherIP_full, FeatherPort); 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() void MainWindow::allHIGH()
udpSocket_Feather->writeDatagram(QByteArray::number(2), FeatherIP_full, FeatherPort); udpSocket_Feather->writeDatagram(QByteArray::number(2), FeatherIP_full, FeatherPort);
udpSocket_Feather->writeDatagram(QByteArray::number(3), FeatherIP_full, FeatherPort); udpSocket_Feather->writeDatagram(QByteArray::number(3), FeatherIP_full, FeatherPort);
udpSocket_Feather->writeDatagram(QByteArray::number(4), 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

void readPCSocketData(); void readPCSocketData();
void setLogBCIData(const bool log); void setLogBCIData(const bool log);
void clearLog(); 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 allLOW();
void allHIGH(); void allHIGH();
private: private:


bool logBCIData; bool logBCIData;


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

+ 74
- 30
mainwindow.ui View File

<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>515</width> <width>515</width>
<height>486</height>
<height>532</height>
</rect> </rect>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<property name="bottomMargin"> <property name="bottomMargin">
<number>5</number> <number>5</number>
</property> </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"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<enum>QFrame::Box</enum> <enum>QFrame::Box</enum>
</property> </property>
<property name="text"> <property name="text">
<string>LINKS</string>
<string>Motor 2</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
</widget> </widget>
</item> </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"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<enum>QFrame::Box</enum> <enum>QFrame::Box</enum>
</property> </property>
<property name="text"> <property name="text">
<string>RECHTS</string>
<string>Motor 4</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label_Forward">
<widget class="QLabel" name="label_Tac3">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<enum>QFrame::Box</enum> <enum>QFrame::Box</enum>
</property> </property>
<property name="text"> <property name="text">
<string>VOR</string>
<string>Motor 3</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
</widget> </widget>
</item> </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"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<enum>QFrame::Box</enum> <enum>QFrame::Box</enum>
</property> </property>
<property name="text"> <property name="text">
<string>ZURÜCK</string>
<string>Motor 1</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
<layout class="QGridLayout" name="gridLayout_4"> <layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0"> <item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_3"> <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"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>40</height> <height>40</height>
</size> </size>
</property> </property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text"> <property name="text">
<string>All LOW</string>
<string>Motor 1</string>
</property>
<property name="checkable">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </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"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
</font> </font>
</property> </property>
<property name="text"> <property name="text">
<string>VOR</string>
<string>Motor 2</string>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </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"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string>All HIGH</string>
<string>All LOW</string>
</property> </property>
</widget> </widget>
</item> </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"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
</font> </font>
</property> </property>
<property name="text"> <property name="text">
<string>LINKS</string>
<string>Motor 4</string>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </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"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
</font> </font>
</property> </property>
<property name="text"> <property name="text">
<string>ZURÜCK</string>
<string>Motor 3</string>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </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"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
</font> </font>
</property> </property>
<property name="text"> <property name="text">
<string>RECHTS</string>
<string>Motor 5</string>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>

Loading…
Cancel
Save