From: Thomas Pietrzak Date: Mon, 30 Jul 2012 14:45:44 +0000 (+0000) Subject: debug buzz X-Git-Url: https://git.thomaspietrzak.com/?a=commitdiff_plain;h=abfe63ce751e6d1a6b3574238b0734d0c029ca6b;p=tactonlibrary.git debug buzz git-svn-id: svn+ssh://thomaspietrzak.com/var/svn/rep@80 47cf9a05-e0a8-4ed5-9e9b-101a649bc004 --- diff --git a/Arduino/TactonPlayer/TactonManager.cpp b/Arduino/TactonPlayer/TactonManager.cpp index 6103e4e..05a2dd4 100644 --- a/Arduino/TactonPlayer/TactonManager.cpp +++ b/Arduino/TactonPlayer/TactonManager.cpp @@ -125,9 +125,8 @@ void TactonManager::buzz(unsigned int nbf, byte *desc) for (unsigned int i = 0 ; i < nbf ; i++) amplitudes[i] = desc[i + 2]; - _player->buzz((((unsigned int)(desc[1])) << 8) | ((unsigned int)(desc[0])), - nbf, - amplitudes); + unsigned int frequency = (((unsigned int)(desc[1])) << 8) | ((unsigned int)(desc[0])); + _player->buzz(frequency, nbf, amplitudes); free(amplitudes); } diff --git a/Arduino/TactonPlayer/TactonPlayerPreciseNew.cpp b/Arduino/TactonPlayer/TactonPlayerPreciseNew.cpp index 55550cd..b06183f 100644 --- a/Arduino/TactonPlayer/TactonPlayerPreciseNew.cpp +++ b/Arduino/TactonPlayer/TactonPlayerPreciseNew.cpp @@ -69,6 +69,8 @@ void TactonPlayerPreciseNew::buzz(unsigned int frequency, byte nbtactors, byte * //set the amplitudes for (int i = 0 ; i < _nbtactors ; i++) analogWrite(_pins[i], amplitudes[i]); + + setFrequency(frequency); } //Stop any vibration diff --git a/Arduino/wristbandTactons/wristbandTactons.ino b/Arduino/wristbandTactons/wristbandTactons.ino index 014691a..96bbff9 100644 --- a/Arduino/wristbandTactons/wristbandTactons.ino +++ b/Arduino/wristbandTactons/wristbandTactons.ino @@ -126,22 +126,22 @@ void loop() } break; //sets a frequency for all the vibrators and an amplitude for each one - // BnFa1a2...an - // n = nb tactors - // F = frequency - // A1, A2, ..., an : amplitudes + // BnFFa1a2...an + // n = nb tactors (1 byte) + // FF = frequency (2 bytes) + // A1, A2, ..., an : amplitudes (1 byte per tactor) case 'B': - if (nbf == 0 && Serial.available() >= 2) - nbf = (((unsigned int) Serial.read()) << 8) | ((unsigned int) Serial.read()); + if (nbf == 0 && Serial.available() >= 1) + nbf = (unsigned int) Serial.read(); if (nbf > 0) { //DO NOT OVERFLOW max(nbf): 60 - while (posbuf < nbf + 1 && Serial.available() > 0) + while (posbuf < nbf + 2 && Serial.available() > 0) { buffer[posbuf] = Serial.read(); posbuf++; } - if (posbuf >= nbf + 1) + if (posbuf >= nbf + 2) { manager.buzz(nbf, buffer); posbuf = 0;