Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

add example

  • Loading branch information...
commit fec05c3c510ef770c40cff8e4e435032e6f70d40 1 parent 26bfbce
James Bloomer authored May 28, 2013
32  README.md
Source Rendered
@@ -17,28 +17,38 @@ Tadaa defaults to 'aplay' (available for Linux systems) but the player can be co
17 17
 
18 18
 Tada can play a sound, depending the value you are monitoring.
19 19
 
20  
-    var tadaa = require('tadaa');
21  
-    var audioPlayer = 'mplayer' // player used to play sounds, defaults to aplay
22  
-    var interval = 60000;       // time in ms for which the value function is called
  20
+    var tadaa = require('../lib/tadaa');
  21
+
  22
+    var audioPlayer = 'aplay'   // player used to play sounds, defaults to aplay
  23
+    var interval = 10000;       // time in ms for which the value function is called
23 24
     var up = 'up.wav';          // sound to play when value goes up
24 25
     var down = 'down.wav';      // sound to play when value goes down
25  
-    
  26
+        
26 27
     var fnup = function(currentValue, newValue) {
27 28
         return newValue > currentValue;  
28 29
     };
29  
-    
  30
+
30 31
     var fndown = function(currentValue, newValue) {
31 32
         return newValue < currentValue;  
32 33
     };
33 34
 
34 35
     // Function to call to get the value
35  
-    var getValue = function(callback){
36  
-        // ...my clever value logic...
37  
-        callback(null, Math.random() * 100); } 
  36
+    var getValue = function(options, callback){
  37
+        // ...insert your clever value logic...
  38
+        var number = Math.random() * 100;
  39
+        console.log(number);
  40
+        callback(null, number); 
  41
+    } 
38 42
         
39  
-    var getValueOptions = { a : 1, b : 2 }; // Data to pass to the function.
40  
-    
41  
-    tadaa.start(interval, [{fn: fnup, sound:up}, {fn: fndown, sound:down}], getValue, getValueOptions, audioPlayer};
  43
+    // Data to pass to the function.
  44
+    var getValueOptions = { a : 1, b : 2 }; 
  45
+
  46
+    tadaa.start(
  47
+        interval, 
  48
+        [{fn: fnup, sound:up}, {fn: fndown, sound:down}], 
  49
+        getValue, 
  50
+        getValueOptions, 
  51
+        audioPlayer);
42 52
     
43 53
 ## Tadaa logic functions included in the box
44 54
 - up
BIN  example/down.wav
Binary file not shown
32  example/random_number.js
... ...
@@ -0,0 +1,32 @@
  1
+var tadaa = require('../lib/tadaa');
  2
+
  3
+var audioPlayer = 'aplay' 	// player used to play sounds, defaults to aplay
  4
+var interval = 10000;       // time in ms for which the value function is called
  5
+var up = 'up.wav';          // sound to play when value goes up
  6
+var down = 'down.wav';      // sound to play when value goes down
  7
+    
  8
+var fnup = function(currentValue, newValue) {
  9
+    return newValue > currentValue;  
  10
+};
  11
+
  12
+var fndown = function(currentValue, newValue) {
  13
+    return newValue < currentValue;  
  14
+};
  15
+
  16
+// Function to call to get the value
  17
+var getValue = function(options, callback){
  18
+    // ...insert your clever value logic...
  19
+    var number = Math.random() * 100;
  20
+    console.log(number);
  21
+    callback(null, number); 
  22
+} 
  23
+    
  24
+// Data to pass to the function.
  25
+var getValueOptions = { a : 1, b : 2 }; 
  26
+
  27
+tadaa.start(
  28
+    interval, 
  29
+    [{fn: fnup, sound:up}, {fn: fndown, sound:down}], 
  30
+    getValue, 
  31
+    getValueOptions, 
  32
+    audioPlayer);
BIN  example/up.wav
Binary file not shown
6  package.json
@@ -16,9 +16,7 @@
16 16
 	"dependencies": {
17 17
     "buddha": "1.0.x", 
18 18
     "commander": "0.5.x",
19  
-    "pivotal": "0.1.x"
20  
-  },
21  
-  "dependencies" : {
  19
+    "pivotal": "0.1.x",
22 20
     "async" : "x.x.x"
23 21
   },
24 22
   "devDependencies" : {
@@ -30,5 +28,5 @@
30 28
   "main": "./lib/tadaa",
31 29
   "bin": { "tadaa": "./bin/tadaa" },
32 30
   "scripts": { "test": "mocha test/*_test.js --reporter spec" },
33  
-  "engines": { "node": ">= 0.4.12 < 0.9.0" }
  31
+  "engines": { "node": ">= 0.4.12 < 0.11.0" }
34 32
 }

0 notes on commit fec05c3

Please sign in to comment.
Something went wrong with that request. Please try again.