Permalink
Browse files

add example

  • Loading branch information...
1 parent 26bfbce commit fec05c3c510ef770c40cff8e4e435032e6f70d40 @jamesbloomer committed May 28, 2013
Showing with 55 additions and 15 deletions.
  1. +21 −11 README.md
  2. BIN example/down.wav
  3. +32 −0 example/random_number.js
  4. BIN example/up.wav
  5. +2 −4 package.json
View
@@ -17,28 +17,38 @@ Tadaa defaults to 'aplay' (available for Linux systems) but the player can be co
Tada can play a sound, depending the value you are monitoring.
- var tadaa = require('tadaa');
- var audioPlayer = 'mplayer' // player used to play sounds, defaults to aplay
- var interval = 60000; // time in ms for which the value function is called
+ var tadaa = require('../lib/tadaa');
+
+ var audioPlayer = 'aplay' // player used to play sounds, defaults to aplay
+ var interval = 10000; // time in ms for which the value function is called
var up = 'up.wav'; // sound to play when value goes up
var down = 'down.wav'; // sound to play when value goes down
-
+
var fnup = function(currentValue, newValue) {
return newValue > currentValue;
};
-
+
var fndown = function(currentValue, newValue) {
return newValue < currentValue;
};
// Function to call to get the value
- var getValue = function(callback){
- // ...my clever value logic...
- callback(null, Math.random() * 100); }
+ var getValue = function(options, callback){
+ // ...insert your clever value logic...
+ var number = Math.random() * 100;
+ console.log(number);
+ callback(null, number);
+ }
- var getValueOptions = { a : 1, b : 2 }; // Data to pass to the function.
-
- tadaa.start(interval, [{fn: fnup, sound:up}, {fn: fndown, sound:down}], getValue, getValueOptions, audioPlayer};
+ // Data to pass to the function.
+ var getValueOptions = { a : 1, b : 2 };
+
+ tadaa.start(
+ interval,
+ [{fn: fnup, sound:up}, {fn: fndown, sound:down}],
+ getValue,
+ getValueOptions,
+ audioPlayer);
## Tadaa logic functions included in the box
- up
View
Binary file not shown.
@@ -0,0 +1,32 @@
+var tadaa = require('../lib/tadaa');
+
+var audioPlayer = 'aplay' // player used to play sounds, defaults to aplay
+var interval = 10000; // time in ms for which the value function is called
+var up = 'up.wav'; // sound to play when value goes up
+var down = 'down.wav'; // sound to play when value goes down
+
+var fnup = function(currentValue, newValue) {
+ return newValue > currentValue;
+};
+
+var fndown = function(currentValue, newValue) {
+ return newValue < currentValue;
+};
+
+// Function to call to get the value
+var getValue = function(options, callback){
+ // ...insert your clever value logic...
+ var number = Math.random() * 100;
+ console.log(number);
+ callback(null, number);
+}
+
+// Data to pass to the function.
+var getValueOptions = { a : 1, b : 2 };
+
+tadaa.start(
+ interval,
+ [{fn: fnup, sound:up}, {fn: fndown, sound:down}],
+ getValue,
+ getValueOptions,
+ audioPlayer);
View
Binary file not shown.
View
@@ -16,9 +16,7 @@
"dependencies": {
"buddha": "1.0.x",
"commander": "0.5.x",
- "pivotal": "0.1.x"
- },
- "dependencies" : {
+ "pivotal": "0.1.x",
"async" : "x.x.x"
},
"devDependencies" : {
@@ -30,5 +28,5 @@
"main": "./lib/tadaa",
"bin": { "tadaa": "./bin/tadaa" },
"scripts": { "test": "mocha test/*_test.js --reporter spec" },
- "engines": { "node": ">= 0.4.12 < 0.9.0" }
+ "engines": { "node": ">= 0.4.12 < 0.11.0" }
}

0 comments on commit fec05c3

Please sign in to comment.