Skip to content

Commit

Permalink
TestGUI: Raw sensor values, sensor display, red/green
Browse files Browse the repository at this point in the history
  • Loading branch information
thp committed Mar 24, 2011
1 parent d30bd50 commit 5ca9e72
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 30 deletions.
35 changes: 30 additions & 5 deletions testgui/psmovetestgui.cpp
Expand Up @@ -8,6 +8,7 @@
PSMoveTestGUI::PSMoveTestGUI(QWidget *parent) :
QMainWindow(parent),
psm(NULL),
scene(NULL),
colorLEDs(Qt::black),
_chosenIndex(-1),
_red(NULL),
Expand Down Expand Up @@ -55,8 +56,10 @@ void PSMoveTestGUI::on_checkboxEnable_toggled(bool checked)
} else {
ui->checkboxEnable->toggle();
_red = new PSMoveQt(0);
_red->setEnabled(true);
_red->setColor(Qt::red);
_green = new PSMoveQt(1);
_green->setEnabled(true);
_green->setColor(Qt::green);
_chosenIndex = -1;
(new DeviceChooserDialog(this))->show();
Expand All @@ -66,6 +69,8 @@ void PSMoveTestGUI::on_checkboxEnable_toggled(bool checked)
}

psm = new PSMoveQt(index);
scene = new PSMoveSensorScene(this, psm);
ui->viewSensors->setScene(scene);

switch (psm->connectionType()) {
case PSMoveQt::Bluetooth:
Expand All @@ -87,12 +92,23 @@ void PSMoveTestGUI::on_checkboxEnable_toggled(bool checked)
connect(psm, SIGNAL(buttonReleased(int)),
this, SLOT(onButtonReleased(int)));

connect(psm, SIGNAL(gyroChanged()),
this, SLOT(readAccelerometer()));

connect(psm, SIGNAL(accelerometerChanged()),
this, SLOT(readGyro()));

//ui->viewSensors->setScene(new PSMoveSensorScene(this, psm));

psm->setRumble(ui->sliderRumble->value());
psm->setColor(colorLEDs);
psm->setEnabled(true);
} else {
if (scene != NULL) {
ui->viewSensors->setScene(NULL);
delete scene;
}
scene = NULL;
if (psm != NULL) {
psm->setRumble(0);
psm->setColor(Qt::black);
Expand Down Expand Up @@ -124,11 +140,6 @@ void PSMoveTestGUI::on_buttonLEDs_clicked()
}
}

void PSMoveTestGUI::on_buttonQuit_clicked()
{
QApplication::quit();
}

void PSMoveTestGUI::setTrigger()
{
if (psm != NULL) {
Expand Down Expand Up @@ -225,3 +236,17 @@ void PSMoveTestGUI::reconnectByIndex(int index)
ui->checkboxEnable->toggle();
}
}

void PSMoveTestGUI::readAccelerometer()
{
ui->labelAx->setText("ax: "+QString::number(psm->ax()));
ui->labelAy->setText("ay: "+QString::number(psm->ay()));
ui->labelAz->setText("az: "+QString::number(psm->az()));
}

void PSMoveTestGUI::readGyro()
{
ui->labelGx->setText("gx: "+QString::number(psm->gx()));
ui->labelGy->setText("gy: "+QString::number(psm->gy()));
ui->labelGz->setText("gz: "+QString::number(psm->gz()));
}
8 changes: 5 additions & 3 deletions testgui/psmovetestgui.h
Expand Up @@ -5,6 +5,8 @@

#include "psmoveqt.hpp"

#include "psmovesensorscene.h"

namespace Ui {
class PSMoveTestGUI;
}
Expand All @@ -14,6 +16,7 @@ class PSMoveTestGUI : public QMainWindow
Q_OBJECT

PSMoveQt *psm;
PSMoveSensorScene *scene;
QColor colorLEDs;

int _chosenIndex;
Expand All @@ -34,13 +37,12 @@ public slots:
private slots:
void setColor(QColor color);
void setButton(int button, bool pressed);
void readAccelerometer();
void readGyro();

void on_checkboxEnable_toggled(bool checked);
void on_buttonLEDs_clicked();
void on_buttonQuit_clicked();

void on_sliderRumble_sliderMoved(int position);

void on_buttonBluetoothSet_clicked();

private:
Expand Down
86 changes: 64 additions & 22 deletions testgui/psmovetestgui.ui
Expand Up @@ -21,7 +21,7 @@
<string>Motion Sensors</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<item row="0" column="0" rowspan="7">
<widget class="QGraphicsView" name="viewSensors">
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
Expand All @@ -31,6 +31,55 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="labelAx">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="labelAy">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="labelAz">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="labelGx">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="labelGy">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLabel" name="labelGz">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="labelSensors">
<property name="text">
<string>&lt;b&gt;motion data&lt;/b&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -139,27 +188,6 @@
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="buttonQuit">
<property name="text">
<string>Quit</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p align=&quot;right&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:9pt;&quot;&gt;PSMoveAPI - http://thp.io/2010/psmove/&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QGroupBox" name="groupBluetooth">
<property name="title">
Expand Down Expand Up @@ -214,6 +242,20 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="label">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p align=&quot;right&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:9pt;&quot;&gt;PSMoveAPI - http://thp.io/2010/psmove/&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
<action name="actionQuit">
Expand Down

0 comments on commit 5ca9e72

Please sign in to comment.