From: Thomas Pietrzak Date: Wed, 15 Feb 2012 13:39:26 +0000 (+0000) Subject: First import Dwell buttons X-Git-Url: https://git.thomaspietrzak.com/?a=commitdiff_plain;h=648c47a3f600a843eaa6e4e0b9c3e77394333b4e;p=tactonlibrary.git First import Dwell buttons git-svn-id: svn+ssh://thomaspietrzak.com/var/svn/rep@45 47cf9a05-e0a8-4ed5-9e9b-101a649bc004 --- diff --git a/TactonLibrary.suo b/TactonLibrary.suo index 70e4b04..5927214 100644 Binary files a/TactonLibrary.suo and b/TactonLibrary.suo differ diff --git a/TactonPlayer/TactonPlayer.cpp b/TactonPlayer/TactonPlayer.cpp index 3e8fa2c..35eab85 100644 --- a/TactonPlayer/TactonPlayer.cpp +++ b/TactonPlayer/TactonPlayer.cpp @@ -5,8 +5,14 @@ #include TactonPlayer::TactonPlayer(const char *port) -:_comport(new SerialWindows(port)) { + try + { + _comport = new SerialWindows(port); + } + catch(...) + { + } } TactonPlayer::~TactonPlayer() @@ -16,16 +22,21 @@ TactonPlayer::~TactonPlayer() void TactonPlayer::start() { - _comport->WriteData("S", 1); + if (_comport) + _comport->WriteData("S", 1); } void TactonPlayer::stop() { - _comport->WriteData("Q", 1); + if (_comport) + _comport->WriteData("Q", 1); } void TactonPlayer::regist(const Tacton &t) { + if (!_comport) + return; + unsigned int nbframes = t.getNbFrames(); unsigned char *buffer = new unsigned char[3 + 6 * nbframes]; buffer[0] = 'N'; @@ -38,6 +49,8 @@ void TactonPlayer::regist(const Tacton &t) unsigned int TactonPlayer::registFile(char *filename) { + if (!_comport) + return -1; unsigned int nb = 0; //load icons @@ -66,6 +79,8 @@ unsigned int TactonPlayer::registFile(char *filename) void TactonPlayer::play(unsigned char index) { + if (!_comport) + return; unsigned char buffer[2]; buffer[0] = 'T'; buffer[1] = index; @@ -74,6 +89,9 @@ void TactonPlayer::play(unsigned char index) void TactonPlayer::play(const Tacton &t) { + if (!_comport) + return; + unsigned int nbframes = t.getNbFrames(); unsigned char *buffer = new unsigned char[3 + 6 * nbframes]; buffer[0] = 'V'; @@ -86,6 +104,9 @@ void TactonPlayer::play(const Tacton &t) void TactonPlayer::schedule(unsigned char index, unsigned long timestamp) { + if (!_comport) + return; + unsigned char buffer[6]; buffer[0] = 'P'; buffer[1] = index; @@ -98,5 +119,6 @@ void TactonPlayer::schedule(unsigned char index, unsigned long timestamp) void TactonPlayer::debugRead(char *res, int nb) const { - _comport->ReadData(res, nb); + if (_comport) + _comport->ReadData(res, nb); } diff --git a/TactonPlayer/TactonPlayer.vcxproj b/TactonPlayer/TactonPlayer.vcxproj index 770df4b..7902274 100644 --- a/TactonPlayer/TactonPlayer.vcxproj +++ b/TactonPlayer/TactonPlayer.vcxproj @@ -51,10 +51,12 @@ Disabled WIN32;_DEBUG;_WINDOWS;_USRDLL;TACTONPLAYER_EXPORTS;%(PreprocessorDefinitions) 4996 + ArduinoSerial Windows true + arduinoserial.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) copy /y $(CodeAnalysisInputAssembly) C:\Windows\system\ @@ -72,12 +74,14 @@ copy /y $(OutDir)$(ProjectName).lib $(VSInstallDir)VC\lib true WIN32;NDEBUG;_WINDOWS;_USRDLL;TACTONPLAYER_EXPORTS;%(PreprocessorDefinitions) 4996 + ArduinoSerial Windows true true true + arduinoserial.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) REM copy /y $(CodeAnalysisInputAssembly) C:\Windows\system\ @@ -86,14 +90,10 @@ REM copy /y $(OutDir)$(ProjectName).lib $(VSInstallDir)VC\lib - - - - diff --git a/TactonPlayer/TactonPlayer.vcxproj.filters b/TactonPlayer/TactonPlayer.vcxproj.filters index 8f2e3f7..13e88f8 100644 --- a/TactonPlayer/TactonPlayer.vcxproj.filters +++ b/TactonPlayer/TactonPlayer.vcxproj.filters @@ -15,12 +15,6 @@ - - Header Files - - - Header Files - Header Files @@ -32,12 +26,6 @@ Source Files - - Source Files - - - Source Files - Source Files