Permalink
Browse files

merges.

  • Loading branch information...
2 parents c589924 + 059f4f4 commit 4eddaf45bebab58c22cb5b33a494c5172653ece0 @voodootikigod committed Jan 24, 2014
Showing with 310 additions and 714 deletions.
  1. +6 −0 .travis.yml
  2. +2 −0 eg/.gitignore
  3. +2 −2 eg/blink.js
  4. +5 −4 eg/read.js
  5. +9 −57 firmware/{firmware.cpp → voodoospark.cpp}
  6. +94 −71 lib/spark.js
  7. +0 −348 lib/spark.local.js
  8. +9 −6 package.json
  9. +14 −1 readme.md
  10. +169 −225 test/spark.js
View
@@ -0,0 +1,6 @@
+language: node_js
+node_js:
+ - "0.10"
+before_script:
+ - npm install -g grunt-cli
+compiler: clang
View
@@ -1 +1,3 @@
blink.local.js
+write.local.js
+read.local.js
View
@@ -1,7 +1,7 @@
var Spark = require("../lib/spark");
var board = new Spark({
- token: "608fd30995205529ffc186d4018a651d253af9a9",
- deviceId: "53ff6f065067544840551187"
+ token: "{{ YOUR TOKEN }}",
+ deviceId: "{{ YOUR DEVICE ID }}"
});
board.on("ready", function() {
View
@@ -1,13 +1,14 @@
var Spark = require("../lib/spark");
var board = new Spark({
- token: "608fd30995205529ffc186d4018a651d253af9a9",
- deviceId: "53ff6f065067544840551187"
+ token: "{{ YOUR TOKEN }}",
+ deviceId: "{{ YOUR DEVICE ID }}"
});
board.on("ready", function() {
console.log("CONNECTED");
- this.digitalRead("D7", function(data) {
- console.log( data );
+ this.analogRead("A0", function(data) {
+ console.log( "A0", data );
});
+
});
@@ -30,6 +30,9 @@ int connectToMyServer(String params) {
ipArrayFromString(serverAddress, ip);
int serverPort = port.toInt();
if (client.connect(serverAddress, serverPort)) {
+
+ reset();
+
if (DEBUG)
Serial.println("Connected to server: "+ip+":"+port);
return 1; // successfully connected
@@ -48,6 +51,12 @@ void setup() {
}
+void reset() {
+ for (int i = 0; i < 20; i++) {
+ reading[i] = 0;
+ previous[i] = 0;
+ }
+}
void send(int action, int pin, int value) {
if (previous[pin] != value) {
@@ -87,55 +96,6 @@ void loop() {
if(DEBUG)
Serial.println("Action received: "+('0'+action));
int pin, mode, val, type, speed, address, stop, len, i;
- switch (action) {
- case 0x00: // pinMode
- pin = client.read();
- mode = client.read();
- //mode is modeled after Standard Firmata
- if (mode == 0x00) {
- pinMode(pin, INPUT);
- } else if (mode == 0x02) {
- pinMode(pin, INPUT_PULLUP);
- } else if (mode == 0x03) {
- pinMode(pin, INPUT_PULLDOWN);
- } else if (mode == 0x01) {
- pinMode(pin, OUTPUT);
- }
- break;
- case 0x01: // digitalWrite
- pin = client.read();
- val = client.read();
- digitalWrite(pin, val);
- break;
- case 0x02: // analogWrite
- pin = client.read();
- val = client.read();
- analogWrite(pin, val);
- break;
- case 0x03: // digitalRead
- pin = client.read();
- val = digitalRead(pin);
- client.write(0x03);
- client.write(pin);
- client.write(val);
- break;
- case 0x04: // analogRead
- pin = client.read();
- val = analogRead(pin);
- client.write(0x04);
- client.write(pin);
- client.write(val);
- break;
- case 0x05: // set always send bit
- pin = client.read();
- val = client.read();
- reading[pin] = val;
- break;
-
- if(DEBUG)
- Serial.println("Action received: "+('0'+action));
-
- int pin, mode, val;
// These are used in the commented code below there are warnings there that need to be resolved
// otherwise spark.io will not compile and flash
@@ -358,16 +318,8 @@ void loop() {
client.write(val);
break;
-
-
-
-
-
-
-
default: // noop
break;
- }
}
}
}
Oops, something went wrong.

0 comments on commit 4eddaf4

Please sign in to comment.