debug buzz
authorThomas Pietrzak <thomas.pietrzak@gmail.com>
Mon, 30 Jul 2012 14:45:44 +0000 (14:45 +0000)
committerThomas Pietrzak <thomas.pietrzak@gmail.com>
Mon, 30 Jul 2012 14:45:44 +0000 (14:45 +0000)
git-svn-id: svn+ssh://thomaspietrzak.com/var/svn/rep@80 47cf9a05-e0a8-4ed5-9e9b-101a649bc004

Arduino/TactonPlayer/TactonManager.cpp
Arduino/TactonPlayer/TactonPlayerPreciseNew.cpp
Arduino/wristbandTactons/wristbandTactons.ino

index 6103e4e0d50ff28e85c3380a4341c90d1d983d82..05a2dd4b053fd8050694c0a19de613e0ffd716fd 100644 (file)
@@ -125,9 +125,8 @@ void TactonManager::buzz(unsigned int nbf, byte *desc)
        for (unsigned int i = 0 ; i < nbf ; i++)\r
                amplitudes[i] = desc[i + 2];\r
 \r
-       _player->buzz((((unsigned int)(desc[1])) << 8) | ((unsigned int)(desc[0])), \r
-               nbf, \r
-               amplitudes);\r
+       unsigned int frequency = (((unsigned int)(desc[1])) << 8) | ((unsigned int)(desc[0]));\r
+       _player->buzz(frequency, nbf, amplitudes);\r
        free(amplitudes);\r
 }\r
 \r
index 55550cda963da59b6ed01e019b2eaf8758a61cf6..b06183f658fb7f0c583c8a16e95b6ec227022215 100644 (file)
@@ -69,6 +69,8 @@ void TactonPlayerPreciseNew::buzz(unsigned int frequency, byte nbtactors, byte *
        //set the amplitudes\r
        for (int i = 0 ; i < _nbtactors ; i++)\r
                analogWrite(_pins[i], amplitudes[i]);\r
+\r
+       setFrequency(frequency);\r
 }\r
 \r
 //Stop any vibration\r
index 014691a935cf3a47543a7c031c30b3a04333783a..96bbff9088b86efddf7ff48bd9f68ddd78f6d78a 100644 (file)
@@ -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;