From: Thomas Pietrzak Date: Tue, 3 Apr 2012 19:30:36 +0000 (+0000) Subject: Import Tacton debugger X-Git-Url: https://git.thomaspietrzak.com/?a=commitdiff_plain;h=2df65b694918159b8aa5b0ab9b13e086468cdc14;p=tactonlibrary.git Import Tacton debugger git-svn-id: svn+ssh://thomaspietrzak.com/var/svn/rep@74 47cf9a05-e0a8-4ed5-9e9b-101a649bc004 --- diff --git a/TactonDebug/TactonDebug.sln b/TactonDebug/TactonDebug.sln new file mode 100644 index 0000000..0ab897a --- /dev/null +++ b/TactonDebug/TactonDebug.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TactonDebug", "TactonDebug\TactonDebug.vcxproj", "{245FF8C0-7CC0-4A37-9F07-6B3C8E29D089}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {245FF8C0-7CC0-4A37-9F07-6B3C8E29D089}.Debug|Win32.ActiveCfg = Debug|Win32 + {245FF8C0-7CC0-4A37-9F07-6B3C8E29D089}.Debug|Win32.Build.0 = Debug|Win32 + {245FF8C0-7CC0-4A37-9F07-6B3C8E29D089}.Release|Win32.ActiveCfg = Release|Win32 + {245FF8C0-7CC0-4A37-9F07-6B3C8E29D089}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/TactonDebug/TactonDebug.suo b/TactonDebug/TactonDebug.suo new file mode 100644 index 0000000..d47ffd0 Binary files /dev/null and b/TactonDebug/TactonDebug.suo differ diff --git a/TactonDebug/TactonDebug/TactonDebug.vcxproj b/TactonDebug/TactonDebug/TactonDebug.vcxproj new file mode 100644 index 0000000..857dc95 --- /dev/null +++ b/TactonDebug/TactonDebug/TactonDebug.vcxproj @@ -0,0 +1,144 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {245FF8C0-7CC0-4A37-9F07-6B3C8E29D089} + Qt4VSv1.0 + + + + Application + + + Application + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + AllRules.ruleset + + + AllRules.ruleset + + + $(SolutionDir)$(ConfigurationName) + $(SolutionDir)$(ConfigurationName) + + + + UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_CORE_LIB;QT_GUI_LIB;%(PreprocessorDefinitions) + .\GeneratedFiles;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\qtmain;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;.\;..;%(AdditionalIncludeDirectories) + Disabled + ProgramDatabase + MultiThreadedDebugDLL + false + + + Windows + $(OutDir)\$(ProjectName).exe + $(QTDIR)\lib;%(AdditionalLibraryDirectories) + true + qtmaind.lib;QtCored4.lib;QtGuid4.lib;%(AdditionalDependencies);tactonplayer.lib + + + + + UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_GUI_LIB;%(PreprocessorDefinitions) + .\GeneratedFiles;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\qtmain;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;.\;..;%(AdditionalIncludeDirectories) + + + MultiThreadedDLL + false + + + Windows + $(OutDir)\$(ProjectName).exe + $(QTDIR)\lib;%(AdditionalLibraryDirectories) + false + qtmain.lib;QtCore4.lib;QtGui4.lib;%(AdditionalDependencies);tactonplayer.lib + + + + + true + + + + + + + + + true + + + + + + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_CORE_LIB -DQT_GUI_LIB "-I." "-I.\GeneratedFiles" "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\qtmain" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I." "-I.\.." "-I." "-I." "-I." "tactondebug.h" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB "-I." "-I.\GeneratedFiles" "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\qtmain" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I." "-I.\.." "-I." "-I." "-I." "tactondebug.h" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" + + + + + Document + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + + + + + + + + Document + %(FullPath);%(AdditionalInputs) + Rcc%27ing %(Identity)... + .\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs) + "$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp + %(FullPath);%(AdditionalInputs) + Rcc%27ing %(Identity)... + .\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs) + "$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp + + + + + + + + + + + \ No newline at end of file diff --git a/TactonDebug/TactonDebug/main.cpp b/TactonDebug/TactonDebug/main.cpp new file mode 100644 index 0000000..3ebd253 --- /dev/null +++ b/TactonDebug/TactonDebug/main.cpp @@ -0,0 +1,10 @@ +#include "tactondebug.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + TactonDebug w; + w.show(); + return a.exec(); +} diff --git a/TactonDebug/TactonDebug/tactondebug.cpp b/TactonDebug/TactonDebug/tactondebug.cpp new file mode 100644 index 0000000..70442ad --- /dev/null +++ b/TactonDebug/TactonDebug/tactondebug.cpp @@ -0,0 +1,90 @@ +#include "tactondebug.h" + +int TactonDebug::MaxFrequency = 400; +int TactonDebug::MaxAmplitude = 255; +int TactonDebug::MaxDuration = 2000; + +TactonDebug::TactonDebug(QWidget *parent, Qt::WFlags flags) + : QMainWindow(parent, flags) +{ + try + { + _tactonPlayer = new TactonPlayer("COM5"); + } + catch(...) + { + _tactonPlayer = NULL; + } + + setupUi(this); + QObject::connect(frequencebox, SIGNAL(textChanged(const QString &)), this, SLOT(setFrequency(const QString &))); + QObject::connect(frequenceslider, SIGNAL(valueChanged(int)), this, SLOT(setFrequency(int))); + QObject::connect(amplitudebox, SIGNAL(textChanged(const QString &)), this, SLOT(setAmplitude(const QString &))); + QObject::connect(amplitudeslider, SIGNAL(valueChanged(int)), this, SLOT(setAmplitude(int))); + QObject::connect(durationbox, SIGNAL(textChanged(const QString &)), this, SLOT(setDuration(const QString &))); + QObject::connect(durationslider, SIGNAL(valueChanged(int)), this, SLOT(setDuration(int))); + + QObject::connect(playbutton, SIGNAL(clicked(bool)), this, SLOT(play(bool))); +} + +TactonDebug::~TactonDebug() +{ + +} + +void TactonDebug::setFrequency(int f) +{ + if (f > MaxFrequency) + f = MaxFrequency; + frequencebox->setText(QString::number(f)); +} + +void TactonDebug::setFrequency(const QString &text) +{ + int f = text.toInt(); + if (f > MaxFrequency) + f = MaxFrequency; + frequenceslider->setValue(f); +} + +void TactonDebug::setAmplitude(int a) +{ + if (a > MaxAmplitude) + a = MaxAmplitude; + amplitudebox->setText(QString::number(a)); +} + +void TactonDebug::setAmplitude(const QString &text) +{ + int a = text.toInt(); + if (a > MaxAmplitude) + a = MaxAmplitude; + amplitudeslider->setValue(a); +} + +void TactonDebug::setDuration(int d) +{ + if (d > MaxDuration) + d = MaxDuration; + durationbox->setText(QString::number(d)); +} + +void TactonDebug::setDuration(const QString &text) +{ + int d = text.toInt(); + if (d > MaxDuration) + d = MaxDuration; + durationslider->setValue(d); +} + +void TactonDebug::play(bool) +{ + if (!_tactonPlayer) + return; + unsigned char pattern = up->isChecked() * POS2_UP | + right->isChecked() * POS2_RIGHT | + left->isChecked() * POS2_LEFT | + down->isChecked() * POS2_DOWN; + + _tactonPlayer->play(Tacton(pattern, durationslider->value(), frequenceslider->value(), amplitudeslider->value())); +} diff --git a/TactonDebug/TactonDebug/tactondebug.h b/TactonDebug/TactonDebug/tactondebug.h new file mode 100644 index 0000000..ca468af --- /dev/null +++ b/TactonDebug/TactonDebug/tactondebug.h @@ -0,0 +1,35 @@ +#ifndef TACTONDEBUG_H +#define TACTONDEBUG_H + +#include +#include "ui_tactondebug.h" + +#include + +class TactonDebug : public QMainWindow, Ui::TactonDebugClass +{ + Q_OBJECT + + public: + TactonDebug(QWidget *parent = 0, Qt::WFlags flags = 0); + ~TactonDebug(); + + public slots: + void setFrequency(int f); + void setFrequency(const QString &text); + void setAmplitude(int a); + void setAmplitude(const QString &text); + void setDuration(int d); + void setDuration(const QString &text); + + void play(bool); + + private: + static int MaxFrequency; + static int MaxAmplitude; + static int MaxDuration; + + TactonPlayer *_tactonPlayer; +}; + +#endif // TACTONDEBUG_H diff --git a/TactonDebug/TactonDebug/tactondebug.qrc b/TactonDebug/TactonDebug/tactondebug.qrc new file mode 100644 index 0000000..0dc7b88 --- /dev/null +++ b/TactonDebug/TactonDebug/tactondebug.qrc @@ -0,0 +1,4 @@ + + + + diff --git a/TactonDebug/TactonDebug/tactondebug.ui b/TactonDebug/TactonDebug/tactondebug.ui new file mode 100644 index 0000000..c6deb50 --- /dev/null +++ b/TactonDebug/TactonDebug/tactondebug.ui @@ -0,0 +1,291 @@ + + + TactonDebugClass + + + + 0 + 0 + 231 + 371 + + + + TactonDebug + + + + + + 10 + 10 + 211 + 349 + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + false + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Fréquence + + + + + + + 250 + + + 3 + + + + + + + 400 + + + 250 + + + Qt::Horizontal + + + QSlider::TicksBothSides + + + 50 + + + + + + + Amplitude + + + + + + + 255 + + + 3 + + + + + + + 255 + + + 255 + + + Qt::Horizontal + + + QSlider::TicksBothSides + + + 32 + + + + + + + Duration + + + + + + + 200 + + + 4 + + + + + + + 2000 + + + 10 + + + 100 + + + 200 + + + Qt::Horizontal + + + QSlider::TicksBothSides + + + 100 + + + + + + + Play + + + + + + + + + + + + + diff --git a/TactonLibrary.suo b/TactonLibrary.suo index 5078e9b..6134b9f 100644 Binary files a/TactonLibrary.suo and b/TactonLibrary.suo differ diff --git a/TactonPlayer/Tacton.hpp b/TactonPlayer/Tacton.hpp index 0dfa37d..60f3ee0 100644 --- a/TactonPlayer/Tacton.hpp +++ b/TactonPlayer/Tacton.hpp @@ -1,9 +1,9 @@ #ifndef _TACTON_ #define _TACTON_ -#define POS1_UP_FOREWARD 0x01 +#define POS1_UP_FORWARD 0x01 #define POS1_UP_BACKWARD 0x02 -#define POS1_DOWN_FOREWARD 0x08 +#define POS1_DOWN_FORWARD 0x08 #define POS1_DOWN_BACKWARD 0x04 #define POS2_RIGHT 0x01 diff --git a/TactonPlayer/TactonPlayer.cpp b/TactonPlayer/TactonPlayer.cpp index e57595c..d2f3be0 100644 --- a/TactonPlayer/TactonPlayer.cpp +++ b/TactonPlayer/TactonPlayer.cpp @@ -12,6 +12,7 @@ TactonPlayer::TactonPlayer(const char *port) } catch(...) { + _comport = NULL; } }