From: Thomas Pietrzak Date: Thu, 29 Mar 2012 12:55:14 +0000 (+0000) Subject: Wristband v3 X-Git-Url: https://git.thomaspietrzak.com/?a=commitdiff_plain;h=e5ddebd2fd26bf1a7b8bd0f3841239b1f5a8f087;p=tactonlibrary.git Wristband v3 git-svn-id: svn+ssh://thomaspietrzak.com/var/svn/rep@71 47cf9a05-e0a8-4ed5-9e9b-101a649bc004 --- diff --git a/Arduino/wristbandTactons/wristbandTactons.pde b/Arduino/wristbandTactons/wristbandTactons.pde deleted file mode 100644 index cc8b724..0000000 --- a/Arduino/wristbandTactons/wristbandTactons.pde +++ /dev/null @@ -1,132 +0,0 @@ -#include -#include -#include -byte pins[] = { - 3, 11, 5, 9}; -TactonPlayerWithAmplitude player(4, pins); -TactonManager manager(&player); - -byte command = 0; -byte posbuf = 0; -unsigned int nbf = 0; -byte buffer[60]; -//unsigned long start = 0; -boolean active = false; - -void setup() -{ - Serial.begin(57600); -// player.init(); -/* player.debug1(); - player.debug2(); - player.debug3(); - player.debug4();*/ -} - -void loop() -{ - byte index; - unsigned long timestamp; - - if (Serial.available() > 0) - { - if (command == 0) - command = Serial.read(); - switch(command) - { - //set the timestamp to 0, and watch for scheduled tactons - case 'S': -// start = millis(); - manager.setOffset(millis()); - command = 0; - active = true; - break; - //stop watching scheduled tactons, and erase registered tactons - case 'Q': - command = 0; - manager.clear(); - active = false; - break; - //register a tacton - case 'N': - if (nbf == 0 && Serial.available() >= 2) - nbf = (((unsigned int) Serial.read()) << 8) | ((unsigned int) Serial.read()); - if (nbf > 0) - { - //DO NOT OVERFLOW max(nbf): 10 - while (posbuf < nbf * 6 && Serial.available() > 0) - { - buffer[posbuf] = Serial.read(); - posbuf++; - } - if (posbuf >= nbf*6) - { - manager.add(nbf, buffer); - posbuf = 0; - command = 0; - nbf = 0; - } - } - break; - //play a specified tacton - case 'V': - if (nbf == 0 && Serial.available() >= 2) - nbf = (((unsigned int) Serial.read()) << 8) | ((unsigned int) Serial.read()); - if (nbf > 0) - { - //DO NOT OVERFLOW max(nbf): 10 - while (posbuf < nbf * 6 && Serial.available() > 0) - { - buffer[posbuf] = Serial.read(); - posbuf++; - } - if (posbuf >= nbf*6) - { - manager.play(nbf, buffer); - posbuf = 0; - command = 0; - nbf = 0; - } - } - break; - //play a registered tacton - case 'T': - if (Serial.available() >= 1) - { - index = Serial.read(); - manager.play(index); - command = 0; - /* Serial.print("Play"); - Serial.println(index, DEC);*/ - } - break; - //schedule the play of a registered tacton - case 'P': - if (Serial.available() >= 5) - { - index = Serial.read(); - timestamp = (((unsigned long)Serial.read()) << 24) | \ - (((unsigned long)Serial.read()) << 16) | \ - (((unsigned long)Serial.read()) << 8) | \ - (((unsigned long)Serial.read())); -/* Serial.print("Plan "); - Serial.println(timestamp, DEC); - Serial.print(" played at "); - Serial.print(timestamp + start, DEC); - Serial.print(" shift="); - Serial.println(start, DEC);*/ - manager.addPlay(index, timestamp); - command = 0; - } - break; - //unknown command: do nothing - default: - command = 0; - break; - } - } - - if (active) - manager.checkPlay(); -} -