From b7822f7c82295c3e2f08594fdb4c8cf411d45b94 Mon Sep 17 00:00:00 2001 From: Thomas Pietrzak Date: Mon, 30 Jul 2012 15:46:20 +0000 Subject: [PATCH] Circle illusion demo git-svn-id: svn+ssh://thomaspietrzak.com/var/svn/rep@81 47cf9a05-e0a8-4ed5-9e9b-101a649bc004 --- Arduino/wristbandTactons/wristbandTactons.ino | 1 + TactonDebug/MagicCircle/MagicCircle.vcxproj | 144 ++++++++++++++++ TactonDebug/MagicCircle/magiccircle.cpp | 109 +++++++++++++ TactonDebug/MagicCircle/magiccircle.h | 42 +++++ TactonDebug/MagicCircle/magiccircle.qrc | 4 + TactonDebug/MagicCircle/magiccircle.ui | 154 ++++++++++++++++++ TactonDebug/MagicCircle/main.cpp | 10 ++ TactonDebug/TactonDebug.sln | 6 + TactonDebug/TactonDebug.suo | Bin 10752 -> 35328 bytes TactonDebug/TactonDebug/TactonDebug.vcxproj | 10 +- TactonDebug/TactonDebug/main.cpp | 1 + TactonDebug/TactonDebug/tactondebug.cpp | 5 +- TactonLibrary.suo | Bin 26112 -> 27648 bytes TactonPlayer/Tacton.hpp | 50 +++--- TactonPlayer/TactonPlayer.cpp | 24 +++ TactonPlayer/TactonPlayer.hpp | 32 ++-- TactonPlayer/TactonPlayer.vcxproj | 1 + 17 files changed, 555 insertions(+), 38 deletions(-) create mode 100644 TactonDebug/MagicCircle/MagicCircle.vcxproj create mode 100644 TactonDebug/MagicCircle/magiccircle.cpp create mode 100644 TactonDebug/MagicCircle/magiccircle.h create mode 100644 TactonDebug/MagicCircle/magiccircle.qrc create mode 100644 TactonDebug/MagicCircle/magiccircle.ui create mode 100644 TactonDebug/MagicCircle/main.cpp diff --git a/Arduino/wristbandTactons/wristbandTactons.ino b/Arduino/wristbandTactons/wristbandTactons.ino index 96bbff9..883d53a 100644 --- a/Arduino/wristbandTactons/wristbandTactons.ino +++ b/Arduino/wristbandTactons/wristbandTactons.ino @@ -153,6 +153,7 @@ void loop() //stop any vibration case 'A': manager.stop(); + command = 0; break; //unknown command: do nothing default: diff --git a/TactonDebug/MagicCircle/MagicCircle.vcxproj b/TactonDebug/MagicCircle/MagicCircle.vcxproj new file mode 100644 index 0000000..29f1bb3 --- /dev/null +++ b/TactonDebug/MagicCircle/MagicCircle.vcxproj @@ -0,0 +1,144 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {E39CA6E9-BA0B-4C12-8090-D5CE66CADF94} + Qt4VSv1.0 + + + + Application + + + Application + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + + + + _USE_MATH_DEFINES;UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_DLL;QT_CORE_LIB;QT_GUI_LIB;%(PreprocessorDefinitions) + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;%(AdditionalIncludeDirectories) + Disabled + ProgramDatabase + MultiThreadedDebugDLL + false + + + Windows + $(OutDir)\$(ProjectName).exe + $(QTDIR)\lib;%(AdditionalLibraryDirectories) + true + TactonPlayerd.lib;qtmaind.lib;QtCored4.lib;QtGuid4.lib;%(AdditionalDependencies) + + + + + _USE_MATH_DEFINES;UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_DLL;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_GUI_LIB;%(PreprocessorDefinitions) + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;%(AdditionalIncludeDirectories) + + + MultiThreadedDLL + false + + + Windows + $(OutDir)\$(ProjectName).exe + $(QTDIR)\lib;%(AdditionalLibraryDirectories) + false + TactonPlayer.lib;qtmain.lib;QtCore4.lib;QtGui4.lib;%(AdditionalDependencies) + + + + + true + + + + + + + + + true + + + + + + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing magiccircle.h... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -D_USE_MATH_DEFINES -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_CORE_LIB -DQT_GUI_LIB "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing magiccircle.h... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -D_USE_MATH_DEFINES -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" + + + + + 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/MagicCircle/magiccircle.cpp b/TactonDebug/MagicCircle/magiccircle.cpp new file mode 100644 index 0000000..306cd3d --- /dev/null +++ b/TactonDebug/MagicCircle/magiccircle.cpp @@ -0,0 +1,109 @@ +#include "magiccircle.h" + +#include + +MagicCircle::MagicCircle(QWidget *parent, Qt::WFlags flags) + : QMainWindow(parent, flags), _timer(this), _angle(0), _clockwise(true) +{ + try + { + _tactonPlayer = new TactonPlayer("COM4"); + } + catch(...) + { + _tactonPlayer = NULL; + } + + setupUi(this); + + layout()->setSizeConstraint(QLayout::SetFixedSize); + + //set initial parameters + setDirection(_direction->currentText()); + setResolution(_resolution->value()); + setSpeed(_speed->value()); + + connect(_play, SIGNAL(clicked(bool)), this, SLOT(play(bool))); + connect(_stop, SIGNAL(clicked(bool)), this, SLOT(stop(bool))); + + connect(_direction, SIGNAL(editTextChanged(const QString &)), this, SLOT(setDirection(const QString &))); + connect(_speed, SIGNAL(valueChanged(int)), this, SLOT(setSpeed(int))); + connect(_resolution, SIGNAL(valueChanged(int)), this, SLOT(setResolution(int))); + + connect(this, SIGNAL(setAngle(float)), SLOT(tactileFeedback(float))); + connect(this, SIGNAL(setAngle(float)), SLOT(visualFeedback(float))); + + connect(&_timer, SIGNAL(timeout()), this, SLOT(update())); +} + +MagicCircle::~MagicCircle() +{ + stop(true); +} + +void MagicCircle::play(bool) +{ + _timer.start(); +} + +void MagicCircle::stop(bool) +{ + _timer.stop(); + _tactonPlayer->stopBuzz(); +} + +void MagicCircle::update() +{ + if (_clockwise) + _angle -= _stepsize; + else + _angle += _stepsize; + + while (_angle < 0) + _angle += 360; + + while (_angle >= 360) + _angle -= 360; + + emit setAngle(_angle); +} + +void MagicCircle::setDirection(const QString &direction) +{ + _clockwise = (direction == "Clockwise"); +} + +void MagicCircle::setSpeed(int speed) +{ + _timer.setInterval(_stepsize / speed * 1000); +} + +void MagicCircle::setResolution(int res) +{ + _stepsize = 360.0 / res; + setSpeed(_speed->value()); +} + +void MagicCircle::tactileFeedback(float angle) +{ + unsigned char amplitudes[4]; + memset(amplitudes, 0, 4); + + //vertical + if (angle < 180) + amplitudes[1] = 255 * sin(angle * M_PI / 180); + else + amplitudes[3] = - 255 * sin(angle * M_PI / 180); + + //horizontal + if (angle < 90 ||angle > 270) + amplitudes[0] = 255 * cos(angle * M_PI / 180); + else + amplitudes[2] = - 255 * cos(angle * M_PI / 180); + + _tactonPlayer->buzz(_frequency->value(), 4, amplitudes); +} + +void MagicCircle::visualFeedback(float) +{ +} diff --git a/TactonDebug/MagicCircle/magiccircle.h b/TactonDebug/MagicCircle/magiccircle.h new file mode 100644 index 0000000..a8be0b5 --- /dev/null +++ b/TactonDebug/MagicCircle/magiccircle.h @@ -0,0 +1,42 @@ +#ifndef MAGICCIRCLE_H +#define MAGICCIRCLE_H + +#include +#include "ui_magiccircle.h" + +#include + +#include + +class MagicCircle : public QMainWindow, Ui::MagicCircleClass +{ + Q_OBJECT + + public: + MagicCircle(QWidget *parent = 0, Qt::WFlags flags = 0); + ~MagicCircle(); + + public slots: + void play(bool); + void stop(bool); + void update(); + + void setDirection(const QString &); + void setSpeed(int); + void setResolution(int); + + void tactileFeedback(float); + void visualFeedback(float); + + signals: + void setAngle(float a); + + private: + float _angle, _stepsize; + bool _clockwise; + + TactonPlayer *_tactonPlayer; + QTimer _timer; +}; + +#endif // MAGICCIRCLE_H diff --git a/TactonDebug/MagicCircle/magiccircle.qrc b/TactonDebug/MagicCircle/magiccircle.qrc new file mode 100644 index 0000000..57f6489 --- /dev/null +++ b/TactonDebug/MagicCircle/magiccircle.qrc @@ -0,0 +1,4 @@ + + + + diff --git a/TactonDebug/MagicCircle/magiccircle.ui b/TactonDebug/MagicCircle/magiccircle.ui new file mode 100644 index 0000000..cc56a5d --- /dev/null +++ b/TactonDebug/MagicCircle/magiccircle.ui @@ -0,0 +1,154 @@ + + + MagicCircleClass + + + + 0 + 0 + 268 + 448 + + + + MagicCircle + + + + + + + + 250 + 250 + + + + + 250 + 250 + + + + + + + + + + Speed (degrees/s) + + + + + + + 1 + + + 720 + + + 30 + + + + + + + Resolution (steps/360°) + + + + + + + + Clockwise + + + + + Counterclockwise + + + + + + + + Direction + + + + + + + 4 + + + 360 + + + 16 + + + + + + + Frequency + + + + + + + 1 + + + 400 + + + 250 + + + + + + + + + + + Stop + + + + + + + Play + + + + + + + + + + + _frequency + _direction + _speed + _resolution + _play + _stop + _canvas + + + + + + diff --git a/TactonDebug/MagicCircle/main.cpp b/TactonDebug/MagicCircle/main.cpp new file mode 100644 index 0000000..288aa7c --- /dev/null +++ b/TactonDebug/MagicCircle/main.cpp @@ -0,0 +1,10 @@ +#include "magiccircle.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MagicCircle w; + w.show(); + return a.exec(); +} diff --git a/TactonDebug/TactonDebug.sln b/TactonDebug/TactonDebug.sln index 0ab897a..972e2a2 100644 --- a/TactonDebug/TactonDebug.sln +++ b/TactonDebug/TactonDebug.sln @@ -3,6 +3,8 @@ 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 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MagicCircle", "MagicCircle\MagicCircle.vcxproj", "{E39CA6E9-BA0B-4C12-8090-D5CE66CADF94}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -13,6 +15,10 @@ Global {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 + {E39CA6E9-BA0B-4C12-8090-D5CE66CADF94}.Debug|Win32.ActiveCfg = Debug|Win32 + {E39CA6E9-BA0B-4C12-8090-D5CE66CADF94}.Debug|Win32.Build.0 = Debug|Win32 + {E39CA6E9-BA0B-4C12-8090-D5CE66CADF94}.Release|Win32.ActiveCfg = Release|Win32 + {E39CA6E9-BA0B-4C12-8090-D5CE66CADF94}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/TactonDebug/TactonDebug.suo b/TactonDebug/TactonDebug.suo index d47ffd0d457c61956a5b19f2d5ed811b9e69fdfe..1f131fa54fbafb1a1acf1e3a5440e4abd5524ce0 100644 GIT binary patch literal 35328 zcmeHQ4U|;Hm41Vu2q+30B`P=|G5k!oJ<~mZ@}o1|Gx!5>V1}Qpt=M$;3=ev`hwh$% zks+WGH?sJ%F~=lEW1@uQa1ug1th(gvE+;>$XcSDM>l%%5b2dg26Vz+Tt5W~Jubu6kAV-mR*4@2y+6ZoN5j_}t%o^9L8auH=M;%4y0+$InzwH{_Qg zP0+$QiZTib!biuC9~YU5g5;?%f=1wf(bmy;c^3i30QkPo0E`8k2^a?$4>$`j0f5)8 zoDG-=m;^W%Fd6U(z~2DQ155{;510b@B;W$Tg@CC5(#kZ%7X!)xGXOIImjFHmm;<;J z@M*v-z-+)=fD2Foa0C2+%K#n#pI3$03-AG|0X2YHKpmhSa5;eW<|AGJSO~ZRa3!Dt z&nBaNdBjcp$stc|8!ha29W;)0N!Kd|7(%A z96%YcQZHwn&mv9!uLO|)nP=pGUgzU~mS2hca{0drdCh=DfU5vk1FiwE{$j*S0G|O|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HA^iSAeL zg^Bvwit}G|n0K13z`N$)Ygd@T2KPyAST+F3h8Xl4{W*6(m#Gh0d^>_!NV=nf?qw~} zvVuUy4Z2gT6Rvp%X|3!C{PGM+tdW9>XKchXy70?QOmTc<7_Hn>W)e+!5_b>$ZkjXy zd^+jy&BP1M<{#?rcmEcL>0obOJ@}THuPolQf4cYh;*GIy5Pi6?qD5CvUTwL}V4ZhK iL6qCUxuOuhyN0_6<2wKgbzyLi9D_M;1VYzUwDdoC2QZNU diff --git a/TactonDebug/TactonDebug/TactonDebug.vcxproj b/TactonDebug/TactonDebug/TactonDebug.vcxproj index 857dc95..2ae6513 100644 --- a/TactonDebug/TactonDebug/TactonDebug.vcxproj +++ b/TactonDebug/TactonDebug/TactonDebug.vcxproj @@ -44,7 +44,7 @@ - UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_CORE_LIB;QT_GUI_LIB;%(PreprocessorDefinitions) + UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_CORE_LIB;QT_GUI_LIB;QT_DLL;%(PreprocessorDefinitions) .\GeneratedFiles;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\qtmain;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;.\;..;%(AdditionalIncludeDirectories) Disabled ProgramDatabase @@ -61,7 +61,7 @@ - UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_GUI_LIB;%(PreprocessorDefinitions) + UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_GUI_LIB;QT_DLL;%(PreprocessorDefinitions) .\GeneratedFiles;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\qtmain;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;.\;..;%(AdditionalIncludeDirectories) @@ -97,11 +97,11 @@ $(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)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_CORE_LIB -DQT_GUI_LIB -DQT_DLL "-I.\GeneratedFiles" "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\qtmain" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I." "-I.\.." $(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" + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_DLL "-I.\GeneratedFiles" "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\qtmain" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I." "-I.\.." @@ -138,7 +138,7 @@ - + \ No newline at end of file diff --git a/TactonDebug/TactonDebug/main.cpp b/TactonDebug/TactonDebug/main.cpp index 3ebd253..5fcd7b9 100644 --- a/TactonDebug/TactonDebug/main.cpp +++ b/TactonDebug/TactonDebug/main.cpp @@ -6,5 +6,6 @@ int main(int argc, char *argv[]) QApplication a(argc, argv); TactonDebug w; w.show(); + w.raise(); return a.exec(); } diff --git a/TactonDebug/TactonDebug/tactondebug.cpp b/TactonDebug/TactonDebug/tactondebug.cpp index 70442ad..ebad3a9 100644 --- a/TactonDebug/TactonDebug/tactondebug.cpp +++ b/TactonDebug/TactonDebug/tactondebug.cpp @@ -9,7 +9,7 @@ TactonDebug::TactonDebug(QWidget *parent, Qt::WFlags flags) { try { - _tactonPlayer = new TactonPlayer("COM5"); + _tactonPlayer = new TactonPlayer("COM4"); } catch(...) { @@ -17,6 +17,9 @@ TactonDebug::TactonDebug(QWidget *parent, Qt::WFlags flags) } setupUi(this); + + layout()->setSizeConstraint(QLayout::SetFixedSize); + 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 &))); diff --git a/TactonLibrary.suo b/TactonLibrary.suo index 6134b9ff7d21aa4f600c1f195dbbfdfed24fab4e..fc693ea9da458169cd32dd130bb656e193ca8ac3 100644 GIT binary patch delta 1597 zcmaJ>ZA_b06u!58-Ma5Klmt6ECpM($lOLp zmPsNG{)5<-d*MTkE)Ha7G~bupgFn+p~ts`yGYR3WOxOOh%&%lVQkQu<4V z{8y-8~nsGWLj%Q8K3?EAv zR}g~+@arZnGD29^Y*QYDvTd{I}{_qmS(Pw$v_ z#Lv7r)C746a`CLSib#KvNd*286Fmy6&FV<4Yc$<>jy^08E6hmjTwc;md@$3Rp?qJQ zDSppheQ|Bos9XN%;LieRbJO6QD;L5A1sK7wrvtt!%AsFl&AU+EUpGKm{kxKf-PV!b zL&F~bSkN5|oDb{cAWv5YGlg+*thg@fbUy$mCD!{f^kS%TLE8KxCj0_o8o}o6G}4(E z&*WL;Att|ybPjPQCclpK4aA#FUUI%oA)&4oQVRD%PK#R2qc*yV!U@Qz5!OiFk(3U= zRf7pCI3A|0CFLn*Yhw8lyoY>Og)@c>#{kPwB4Vl@IPi!qTz zVuU&9O+^oK!Qx&#Vju>IMoc&m4L zc$Z{TeY&@rl$#jJj3T;m`>SnTa7EgyDv~TnB}k?qaEJta;jQXgY8{obkP&vWF(Xg8 zc@g^4=EPZ%5T4Aykx;p+m})tV9yeV{KZwH|<IvsAi-ETi( z$C2;2OpwhRjq(hYD{S}-IAw?5Y4_WT951HxM2OUw;8sl~3*zKmL$VP(@X#fgwwl=Z zu&dG`Hs_!*Rk6R+=$SkoAUlFspQ?Y2I?RVXE+^eMKGuhcNpah>xJX0nE@=eCt$@X| z4Dm)D>gpxcP?<`{y#iSL$Q6em6j*vA2dEBp@K;9=tNIKxdhhuIS(wBo0 zng)xMHFjPGb4x@WZ~HB3qj*DkDsAo*;BMFjb*&O8UHM?Hv%-^T6WnWfrW)E;b>M6E LLb$;K;fmQm@60Vx diff --git a/TactonPlayer/Tacton.hpp b/TactonPlayer/Tacton.hpp index 60f3ee0..d71859a 100644 --- a/TactonPlayer/Tacton.hpp +++ b/TactonPlayer/Tacton.hpp @@ -11,6 +11,12 @@ #define POS2_LEFT 0x04 #define POS2_DOWN 0x08 +#ifdef __MACOSX__ +#define EXPORTED +#else +#define EXPORTED __declspec(dllexport) +#endif + class Tacton { public: @@ -20,46 +26,46 @@ class Tacton //2 for the duration //2 for the frequency //1 for the amplitude - __declspec(dllexport) Tacton(unsigned int nbframes, unsigned char *desc); + EXPORTED Tacton(unsigned int nbframes, unsigned char *desc); //creates a tacton using the CSV format //1 field for the number of frames, then 4 fields per frame //1 for the pattern //1 for the duration //1 for the frequency //1 for the amplitude - __declspec(dllexport) Tacton(char *desc); - __declspec(dllexport) Tacton(unsigned int nbframes, unsigned char *patterns, unsigned int *durations, unsigned int *frequencies, unsigned char *amplitudes); + EXPORTED Tacton(char *desc); + EXPORTED Tacton(unsigned int nbframes, unsigned char *patterns, unsigned int *durations, unsigned int *frequencies, unsigned char *amplitudes); //create a simple vibration - __declspec(dllexport) Tacton(char *pattern, unsigned int duration, unsigned int frequency, unsigned char amplitude); - __declspec(dllexport) Tacton(const char *pattern, unsigned int duration, unsigned int frequency, unsigned char amplitude); - __declspec(dllexport) Tacton(unsigned char pattern, unsigned int duration, unsigned int frequency, unsigned char amplitude); - __declspec(dllexport) Tacton(const Tacton &t); - __declspec(dllexport) ~Tacton(); + EXPORTED Tacton(char *pattern, unsigned int duration, unsigned int frequency, unsigned char amplitude); + EXPORTED Tacton(const char *pattern, unsigned int duration, unsigned int frequency, unsigned char amplitude); + EXPORTED Tacton(unsigned char pattern, unsigned int duration, unsigned int frequency, unsigned char amplitude); + EXPORTED Tacton(const Tacton &t); + EXPORTED ~Tacton(); //changes the pattern using raw format - __declspec(dllexport) void setPattern(char pattern); - __declspec(dllexport) void setPattern(unsigned int frame, char pattern); + EXPORTED void setPattern(char pattern); + EXPORTED void setPattern(unsigned int frame, char pattern); //changes the pattern using string format - __declspec(dllexport) void setPattern(char *pattern); - __declspec(dllexport) void setPattern(const char *pattern); - __declspec(dllexport) void setPattern(unsigned int frame, char *pattern); - __declspec(dllexport) void setPattern(unsigned int frame, const char *pattern); + EXPORTED void setPattern(char *pattern); + EXPORTED void setPattern(const char *pattern); + EXPORTED void setPattern(unsigned int frame, char *pattern); + EXPORTED void setPattern(unsigned int frame, const char *pattern); //changes the duration - __declspec(dllexport) void setDuration(unsigned int duration); - __declspec(dllexport) void setDuration(unsigned int frame, unsigned int duration); + EXPORTED void setDuration(unsigned int duration); + EXPORTED void setDuration(unsigned int frame, unsigned int duration); //changes the frequency - __declspec(dllexport) void setFrequency(unsigned int frequency); - __declspec(dllexport) void setFrequency(unsigned int frame, unsigned int frequency); + EXPORTED void setFrequency(unsigned int frequency); + EXPORTED void setFrequency(unsigned int frame, unsigned int frequency); //changes the amplitude - __declspec(dllexport) void setAmplitude(unsigned int amplitude); - __declspec(dllexport) void setAmplitude(unsigned int frame, unsigned int amplitude); + EXPORTED void setAmplitude(unsigned int amplitude); + EXPORTED void setAmplitude(unsigned int frame, unsigned int amplitude); //returns the number of frames - __declspec(dllexport) const unsigned int getNbFrames() const; + EXPORTED const unsigned int getNbFrames() const; //returns the raw code (useful to send to the serial port) - __declspec(dllexport) void *rawCode() const; + EXPORTED void *rawCode() const; private: unsigned int _nbframes; diff --git a/TactonPlayer/TactonPlayer.cpp b/TactonPlayer/TactonPlayer.cpp index d2f3be0..23f716e 100644 --- a/TactonPlayer/TactonPlayer.cpp +++ b/TactonPlayer/TactonPlayer.cpp @@ -43,6 +43,7 @@ void TactonPlayer::regist(const Tacton &t) buffer[0] = 'N'; buffer[1] = (nbframes & 0xff00) >> 8; buffer[2] = nbframes & 0xff; + memcpy(buffer + 3, t.rawCode(), 6 * nbframes); _comport->WriteData(buffer, 3 + 6 * nbframes); delete []buffer; @@ -118,6 +119,29 @@ void TactonPlayer::schedule(unsigned char index, unsigned long timestamp) _comport->WriteData(buffer, 6); } +void TactonPlayer::buzz(unsigned int frequency, unsigned int nbtactors, unsigned char *amplitudes) +{ + if (!_comport) + return; + + unsigned char *buffer = new unsigned char[4 + nbtactors]; + buffer[0] = 'B'; + buffer[1] = nbtactors; + buffer[2] = (unsigned char)((frequency & 0x0000ff00) >> 8); + buffer[3] = (unsigned char)(frequency & 0x000000ff); + memcpy(buffer + 4, amplitudes, nbtactors); + _comport->WriteData(buffer, 4 + nbtactors); + delete[] buffer; +} + +void TactonPlayer::stopBuzz() +{ + if (!_comport) + return; + + _comport->WriteData("A", 1); +} + void TactonPlayer::debugRead(char *res, int nb) const { if (_comport) diff --git a/TactonPlayer/TactonPlayer.hpp b/TactonPlayer/TactonPlayer.hpp index 3671db2..8e520c3 100644 --- a/TactonPlayer/TactonPlayer.hpp +++ b/TactonPlayer/TactonPlayer.hpp @@ -1,32 +1,44 @@ #include "Tacton.hpp" +#ifdef __MACOSX__ +#include +#define EXPORTED +#else #include +#define EXPORTED __declspec(dllexport) +#endif class TactonPlayer { public: - __declspec(dllexport) TactonPlayer(const char *port = "COM5"); - __declspec(dllexport) ~TactonPlayer(); + EXPORTED TactonPlayer(const char *port = "COM5"); + EXPORTED ~TactonPlayer(); //set the timestamp to 0, and watch for scheduled tactons - void __declspec(dllexport) start(); + EXPORTED void start(); //stop watching scheduled tactons, and erase registered tactons - void __declspec(dllexport) stop(); + EXPORTED void stop(); //register a tacton - __declspec(dllexport) void regist(const Tacton &t); + EXPORTED void regist(const Tacton &t); //register a list of tactons in a file, returns the number of tactons loaded - __declspec(dllexport) unsigned int registFile(char *filename); + EXPORTED unsigned int registFile(char *filename); //play a registered tacton - __declspec(dllexport) void play(unsigned char index); + EXPORTED void play(unsigned char index); //play a specified tacton - __declspec(dllexport) void play(const Tacton &t); + EXPORTED void play(const Tacton &t); //schedule the play of a registered tacton - __declspec(dllexport) void schedule(unsigned char index, unsigned long timestamp); + EXPORTED void schedule(unsigned char index, unsigned long timestamp); + + //sets a given frequency for all vibrators, and an amplitude for each vibrator + //vibrates until explicitely stop + EXPORTED void buzz(unsigned int frequency, unsigned int nbtactors, unsigned char *amplitudes); + //stop any vibration + EXPORTED void stopBuzz(); //read on the serial port - __declspec(dllexport) void debugRead(char *res, int nb) const; + EXPORTED void debugRead(char *res, int nb) const; private: Serial *_comport; diff --git a/TactonPlayer/TactonPlayer.vcxproj b/TactonPlayer/TactonPlayer.vcxproj index 86019d3..6a08bb8 100644 --- a/TactonPlayer/TactonPlayer.vcxproj +++ b/TactonPlayer/TactonPlayer.vcxproj @@ -39,6 +39,7 @@ true + $(ProjectName)d false -- 2.30.2