diff --git a/examples/respira/.svn/all-wcprops b/examples/respira/.svn/all-wcprops deleted file mode 100644 index 74e6bd7..0000000 --- a/examples/respira/.svn/all-wcprops +++ /dev/null @@ -1,41 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/913/trunk/arduino/sketches/respira -END -product.h -K 25 -svn:wc:ra_dav:version-url -V 58 -/svn/!svn/ver/913/trunk/arduino/sketches/respira/product.h -END -regtable.ino -K 25 -svn:wc:ra_dav:version-url -V 61 -/svn/!svn/ver/913/trunk/arduino/sketches/respira/regtable.ino -END -respira.ino -K 25 -svn:wc:ra_dav:version-url -V 60 -/svn/!svn/ver/913/trunk/arduino/sketches/respira/respira.ino -END -regtable.h -K 25 -svn:wc:ra_dav:version-url -V 59 -/svn/!svn/ver/913/trunk/arduino/sketches/respira/regtable.h -END -sensor.ino -K 25 -svn:wc:ra_dav:version-url -V 59 -/svn/!svn/ver/913/trunk/arduino/sketches/respira/sensor.ino -END -sensor.h -K 25 -svn:wc:ra_dav:version-url -V 57 -/svn/!svn/ver/913/trunk/arduino/sketches/respira/sensor.h -END diff --git a/examples/respira/.svn/entries b/examples/respira/.svn/entries deleted file mode 100644 index 9f49fc6..0000000 --- a/examples/respira/.svn/entries +++ /dev/null @@ -1,232 +0,0 @@ -10 - -dir -913 -https://panstamp.googlecode.com/svn/trunk/arduino/sketches/respira -https://panstamp.googlecode.com/svn - - - -2013-04-30T18:18:21.025856Z -913 -dberenguer@usapiens.com - - - - - - - - - - - - - - -d77f469f-0316-7e13-d0a9-da7f422f7f4c - -sensor.h -file - - - - -2013-02-08T14:47:52.891174Z -b0438262aaa360ec389cfebe2a39434c -2013-04-30T18:18:21.025856Z -913 -dberenguer@usapiens.com - - - - - - - - - - - - - - - - - - - - - -2231 - -product.h -file - - - - -2013-02-08T10:15:43.431095Z -5c72394458ac69d58097a0a6638c98ab -2013-04-30T18:18:21.025856Z -913 -dberenguer@usapiens.com - - - - - - - - - - - - - - - - - - - - - -1233 - -respira.ino -file - - - - -2013-02-26T20:23:37.182544Z -332da8c5cb19e8a4f94299a02fd55950 -2013-04-30T18:18:21.025856Z -913 -dberenguer@usapiens.com - - - - - - - - - - - - - - - - - - - - - -2596 - -regtable.ino -file - - - - -2013-02-21T18:33:52.188248Z -7560f90b9b7941edd6eacfd3e9602974 -2013-04-30T18:18:21.025856Z -913 -dberenguer@usapiens.com - - - - - - - - - - - - - - - - - - - - - -3311 - -regtable.h -file - - - - -2013-02-08T11:19:10.455113Z -24527101c79a1eca9bc1d8f6d8f59430 -2013-04-30T18:18:21.025856Z -913 -dberenguer@usapiens.com - - - - - - - - - - - - - - - - - - - - - -1141 - -sensor.ino -file - - - - -2013-02-26T20:22:59.166543Z -d701628f618b001192d631998f86abfc -2013-04-30T18:18:21.025856Z -913 -dberenguer@usapiens.com - - - - - - - - - - - - - - - - - - - - - -4717 - diff --git a/examples/respira/.svn/text-base/product.h.svn-base b/examples/respira/.svn/text-base/product.h.svn-base deleted file mode 100644 index 188b492..0000000 --- a/examples/respira/.svn/text-base/product.h.svn-base +++ /dev/null @@ -1,51 +0,0 @@ -/** - * product.h - * - * Copyright (c) 2011 Daniel Berenguer - * - * This file is part of the panStamp project. - * - * panStamp is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * panStamp is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with panStamp; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * Author: Daniel Berenguer - * Creation date: 03/31/2011 - */ - -#ifndef _PRODUCT_H -#define _PRODUCT_H - -/** - * Hardware version - */ -#define HARDWARE_VERSION 0x00000100 - -/** - * Firmware version - */ -#define FIRMWARE_VERSION 0x00000100 - -/** - * Manufacturer SWAP ID - */ -#define SWAP_MANUFACT_ID 0x00000001 - -/** - * Product SWAP ID - */ -#define SWAP_PRODUCT_ID 0x0000000D - -#endif - diff --git a/examples/respira/.svn/text-base/regtable.h.svn-base b/examples/respira/.svn/text-base/regtable.h.svn-base deleted file mode 100644 index e1c9da0..0000000 --- a/examples/respira/.svn/text-base/regtable.h.svn-base +++ /dev/null @@ -1,44 +0,0 @@ -/** - * regtable.h - * - * Copyright (c) 2011 Daniel Berenguer - * - * This file is part of the panStamp project. - * - * panStamp is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * panStamp is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with panStamp; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * Author: Daniel Berenguer - * Creation date: 03/31/2011 - */ - -#ifndef _REGTABLE_H -#define _REGTABLE_H - -#include "Arduino.h" -#include "register.h" -#include "commonregs.h" - -/** - * Register indexes - */ -DEFINE_REGINDEX_START() - REGI_VOLTSUPPLY, - REGI_HTSENSOR, - REGI_AIRSENSOR -DEFINE_REGINDEX_END() - -#endif - diff --git a/examples/respira/.svn/text-base/regtable.ino.svn-base b/examples/respira/.svn/text-base/regtable.ino.svn-base deleted file mode 100644 index b670f28..0000000 --- a/examples/respira/.svn/text-base/regtable.ino.svn-base +++ /dev/null @@ -1,138 +0,0 @@ -/** - * regtable - * - * Copyright (c) 2011 Daniel Berenguer - * - * This file is part of the panStamp project. - * - * panStamp is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * panStamp is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with panStamp; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * Author: Daniel Berenguer - * Creation date: 03/31/2011 - */ - -#include -#include "product.h" -#include "panstamp.h" -#include "regtable.h" -#include "sensor.h" - -/** - * Declaration of common callback functions - */ -DECLARE_COMMON_CALLBACKS() - -/** - * Definition of common registers - */ -DEFINE_COMMON_REGISTERS() - -/* - * Definition of custom registers - */ -// Voltage supply -static unsigned long voltageSupply = 3300; -static byte dtVoltSupply[2]; -REGISTER regVoltSupply(dtVoltSupply, sizeof(dtVoltSupply), &updtVoltSupply, NULL); -// Humidity + temperature sensor register -REGISTER regHtSensor(dtHtSensor, sizeof(dtHtSensor), &updtHtSensor, NULL); -// CO + NO2 sensor register -REGISTER regAirSensor(dtAirSensor, sizeof(dtAirSensor), &updtAirSensor, NULL); - -/** - * Initialize table of registers - */ -DECLARE_REGISTERS_START() - ®VoltSupply, - ®HtSensor, - ®AirSensor -DECLARE_REGISTERS_END() - -/** - * Definition of common getter/setter callback functions - */ -DEFINE_COMMON_CALLBACKS() - -/** - * Definition of custom getter/setter callback functions - */ - -/** - * updtVoltSupply - * - * Measure voltage supply and update register - * - * 'rId' Register ID - */ -const void updtVoltSupply(byte rId) -{ - unsigned long result; - - // Read 1.1V reference against AVcc - ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1); - delay(2); // Wait for Vref to settle - ADCSRA |= _BV(ADSC); // Convert - while (bit_is_set(ADCSRA,ADSC)); - result = ADCL; - result |= ADCH << 8; - result = 1126400L / result; // Back-calculate AVcc in mV - voltageSupply = result; // Update global variable Vcc - - #ifdef VOLT_SUPPLY_A7 - - // Read voltage supply from A7 - unsigned short ref = voltageSupply; - result = analogRead(7); - result *= ref; - result /= 1024; - #endif - - /** - * register[eId]->member can be replaced by regVoltSupply in this case since - * no other register is going to use "updtVoltSupply" as "updater" function - */ - - // Update register value - regTable[rId]->value[0] = (result >> 8) & 0xFF; - regTable[rId]->value[1] = result & 0xFF; -} - -/** - * updtHtSensor - * - * Read humidity + temperature sensor and update register - * - * 'rId' Register ID - */ -const void updtHtSensor(byte rId) -{ - // Read temperature and humidity from sensor - sensor_ReadTempHum(); -} - -/** - * updtAirSensor - * - * Read Co + NO2 sensor and update register - * - * 'rId' Register ID - */ -const void updtAirSensor(byte rId) -{ - // Read temperature and humidity from sensor - sensor_ReadMics4514(); -} - diff --git a/examples/respira/.svn/text-base/respira.ino.svn-base b/examples/respira/.svn/text-base/respira.ino.svn-base deleted file mode 100644 index 2aed2cf..0000000 --- a/examples/respira/.svn/text-base/respira.ino.svn-base +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2011 Daniel Berenguer - * - * This file is part of the panStamp project. - * - * panStamp is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * panStamp is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with panStamp; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * Author: Daniel Berenguer - * Creation date: 02/08/2013 - * - * Device: - * Respira sensor for CO and NO2 - * - * Description: - * This sketch can runs on panStamp's respira sensor. This sensor measures - * humidity, temperature, CO and NO2 levels. - * - * Associated Device Definition Files, defining registers, endpoints and - * configuration parameters: - * respira.xml - */ - -#include "regtable.h" -#include "panstamp.h" - -/** - * Uncomment if you are reading Vcc from A7. All battery-boards do this - */ -//#define VOLT_SUPPLY_A7 - -/** - * LED pin - */ -#define LEDPIN 4 - -/** - * Wireless transmission interval (seconds) - */ -unsigned int txInterval; - -unsigned int loopCnt; - -/** - * setup - * - * Arduino setup function - */ -void setup() -{ - int i; - - pinMode(LEDPIN, OUTPUT); - digitalWrite(LEDPIN, LOW); - - // Init panStamp - panstamp.init(); - - /* - Serial.begin(38400); - Serial.println("Respira sensor ready!"); - */ - - // Wireless transmission interval - txInterval = panstamp.txInterval[0]; - txInterval = txInterval << 8 | panstamp.txInterval[1]; - //txInterval = 10; - - // Transmit product code - getRegister(REGI_PRODUCTCODE)->getData(); - - // Enter Rx ON state - panstamp.enterSystemState(SYSTATE_RXON); - - // Transmit periodic Tx interval - getRegister(REGI_TXINTERVAL)->getData(); - // Transmit power voltage - getRegister(REGI_VOLTSUPPLY)->getData(); - - // Initialize sensors - initSensor(); - -} - -/** - * loop - * - * Arduino main loop - */ -void loop() -{ - digitalWrite(LEDPIN, HIGH); - - // Transmit Humidity + temperaturesensor data - getRegister(REGI_HTSENSOR)->getData(); - - delay(100); - - // Transmit CO + NO2 sensor level - getRegister(REGI_AIRSENSOR)->getData(); - - digitalWrite(LEDPIN, LOW); - - for (loopCnt=0 ; loopCnt < txInterval ; loopCnt++) - delay(1000); -} - diff --git a/examples/respira/.svn/text-base/sensor.h.svn-base b/examples/respira/.svn/text-base/sensor.h.svn-base deleted file mode 100644 index 6373ef5..0000000 --- a/examples/respira/.svn/text-base/sensor.h.svn-base +++ /dev/null @@ -1,68 +0,0 @@ -/** - * sensor.h - * - * Copyright (c) 2011 Daniel Berenguer - * - * This file is part of the panStamp project. - * - * panStamp is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * panStamp is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with panStamp; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * Author: Daniel Berenguer - * Creation date: 09/01/2012 - */ - -#ifndef _SENSOR_H -#define _SENSOR_H - -/** - * Sensor values - */ -byte dtHtSensor[4]; // Humidity + temperature sensor -byte dtAirSensor[4]; // Air quality (CO + NO2) sensor - -/** - * Pin definitions - */ -// Temperature + Humidity (DHT22 sensor) -#define PORTW_DHT_DATA PORTD -#define PORTR_DHT_DATA PIND -#define PORTD_DHT_DATA DDRD -#define BIT_DHT_DATA 6 -#define PIN_DHT_DATA 6 - -#define setDataPin() bitSet(PORTW_DHT_DATA, BIT_DHT_DATA) -#define clearDataPin() bitClear(PORTW_DHT_DATA, BIT_DHT_DATA) -#define getDataPin() bitRead(PORTR_DHT_DATA, BIT_DHT_DATA) -#define setDataInput() bitClear(PORTD_DHT_DATA, BIT_DHT_DATA) -#define setDataOutput() bitSet(PORTD_DHT_DATA, BIT_DHT_DATA) - -#define PIN_PWRDHT 5 -#define dhtSensorON() digitalWrite(PIN_PWRDHT, HIGH); -#define dhtSensorOFF() digitalWrite(PIN_PWRDHT, LOW); - -// CO + NO2 (MiCS-4514 sensor) -#define ANALOG_NO2 3 // Arduino analog pin -#define ANALOG_CO 4 // Arduino analog pin -#define PIN_HEATING_NO2 19 // Arduino digital pin - -#define preHeaterON() digitalWrite(PIN_HEATING_NO2, HIGH); -#define preHeaterOFF() digitalWrite(PIN_HEATING_NO2, LOW); - -#define CALIB_R0_NO2 2200 // R0 calibration value for the NO2 sensor -#define CALIB_R0_CO 750000 // R0 calibration value for the CO sensor - -#endif - diff --git a/examples/respira/.svn/text-base/sensor.ino.svn-base b/examples/respira/.svn/text-base/sensor.ino.svn-base deleted file mode 100644 index 70ec1c4..0000000 --- a/examples/respira/.svn/text-base/sensor.ino.svn-base +++ /dev/null @@ -1,234 +0,0 @@ -/** - * sensor - * - * Copyright (c) 2011 Daniel Berenguer - * - * This file is part of the panStamp project. - * - * panStamp is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * panStamp is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with panStamp; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * Author: Daniel Berenguer - * Creation date: 03/31/2011 - */ - -#include "Arduino.h" -#include "sensor.h" - -/** - * Local functions - */ -int sensor_ReadByte(void); - -/** - * sensor_ReadByte - * - * Read data byte from DHT11 sensor - */ -int sensor_ReadByte(void) -{ - byte i, result = 0; - unsigned int count = 20000; - - for(i=0; i< 8; i++) - { - while(!getDataPin()) - { - if (--count == 0) - return -1; - } - delayMicroseconds(30); - - if (getDataPin()) - result |=(1<<(7-i)); - - count = 20000; - - while(getDataPin()) - { - if (--count == 0) - return -1; - } - } - return result; -} - -/** - * sensor_ReadTempHum - * - * Read temperature and humidity values from DHT11 sensor - * - * Return -1 in case of error. Return 0 otherwise - */ -int sensor_ReadTempHum(void) -{ - int temperature, humidity, chk; - - byte dhtData[5]; - byte i, dhtCrc; - boolean success = false; - - // Power ON sensor - dhtSensorON(); - delay(1500); - - setDataOutput(); - setDataPin(); - - // Start condition - clearDataPin(); - delay(18); - setDataPin(); - delayMicroseconds(40); - setDataInput(); - delayMicroseconds(40); - - if (!getDataPin()) - { - // Start condition met - delayMicroseconds(80); - if (getDataPin()) - { - // Start condition met - delayMicroseconds(80); - - // Now ready for data reception - for (i=0; i<5; i++) - { - if ((chk = sensor_ReadByte()) < 0) - return -1; - - dhtData[i] = (byte)chk; - } - success = true; - } - } - - setDataOutput(); - clearDataPin(); - - // Power OFF sensor - dhtSensorOFF(); - - if (!success) - return -1; - - dhtCrc = dhtData[0] + dhtData[1] + dhtData[2] + dhtData[3]; - - // check check_sum - if(dhtData[4]!= dhtCrc) - return -1; // CRC error - - // Prepare values for 2-decimal format: - int sign = 1; - if (dhtData[2] & 0x80) - { - sign = -1; - dhtData[2] &= 0x7F; - } - temperature = sign * word(dhtData[2], dhtData[3]) + 500; // 50.0 ÂșC offset in order to accept negative temperatures - humidity = word(dhtData[0], dhtData[1]); - - dtHtSensor[0] = (temperature >> 8) & 0xFF; - dtHtSensor[1] = temperature & 0xFF; - dtHtSensor[2] = (humidity >> 8) & 0xFF; - dtHtSensor[3] = humidity & 0xFF; - - return 0; -} - -/** - * sensor_ReadMics4514 - * - * Read CO and NO2 levels from MiCS-4514 sensor - * - * Return -1 in case of error. Return 0 otherwise - */ -int sensor_ReadMics4514(void) -{ - unsigned int reading; - unsigned long calib; - float fVolt, fRes, fConc; - - /** - * Read CO sensor - */ - reading = analogRead(ANALOG_CO); - // Convert reading to voltage (Volts) - fVolt = (reading * 3.3) / 1024.0; - // Get Rs/R0 value - calib = CALIB_R0_CO; - fRes = (5000.0/fVolt - 1000) / calib; - - // Convert to ppm - if (fRes > 0.7) - fRes = 0.7; - if (fRes > 0.6) - fConc = (0.711 - fRes) / 0.011; - else if (fRes > 0.3) - fConc = (0.7 - fRes) / 0.01; - else - fConc = (0.3233 - fRes) / 0.00058; - - reading = fConc; - dtAirSensor[0] = (reading >> 8) & 0xFF; - dtAirSensor[1] = reading & 0xFF; - - /** - * Read NO2 sensor - */ - - reading = analogRead(ANALOG_NO2); - // Convert reading to voltage (Volts) - fVolt = 3.3; - fVolt *= reading; - fVolt /= 1024.0; - - // Get Rs/R0 value - calib = CALIB_R0_NO2; - - fRes = (5000.0/fVolt - 1000) / calib; - - // Convert to ppm - if (fRes < 3.0) - fRes = 3.0; - if (fRes >= 3.0 && fRes < 8.0) - fConc = (fRes - 0.5) / 0.25; - else - fConc = (fRes + 129.655) / 4.589; - - reading = fConc; - dtAirSensor[2] = (reading >> 8) & 0xFF; - dtAirSensor[3] = reading & 0xFF; -} - -/** - * initSensor - * - * Initialize sensor pins - */ -void initSensor(void) -{ - // DHT22 sensor - pinMode(PIN_PWRDHT, OUTPUT); // Configure Power pin as output - dhtSensorOFF(); - - // MiCS-4514 sensor - pinMode(PIN_HEATING_NO2, OUTPUT); // Configure pre-heating pin as output - preHeaterON(); - delay(30000); - preHeaterOFF(); -} - diff --git a/examples/rgbdriver/.svn/all-wcprops b/examples/rgbdriver/.svn/all-wcprops deleted file mode 100644 index 74d5445..0000000 --- a/examples/rgbdriver/.svn/all-wcprops +++ /dev/null @@ -1,41 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 50 -/svn/!svn/ver/637/trunk/arduino/sketches/rgbdriver -END -rgbled.cpp -K 25 -svn:wc:ra_dav:version-url -V 61 -/svn/!svn/ver/915/trunk/arduino/sketches/rgbdriver/rgbled.cpp -END -rgbled.h -K 25 -svn:wc:ra_dav:version-url -V 59 -/svn/!svn/ver/637/trunk/arduino/sketches/rgbdriver/rgbled.h -END -product.h -K 25 -svn:wc:ra_dav:version-url -V 60 -/svn/!svn/ver/637/trunk/arduino/sketches/rgbdriver/product.h -END -regtable.ino -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/637/trunk/arduino/sketches/rgbdriver/regtable.ino -END -rgbdriver.ino -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/915/trunk/arduino/sketches/rgbdriver/rgbdriver.ino -END -regtable.h -K 25 -svn:wc:ra_dav:version-url -V 61 -/svn/!svn/ver/637/trunk/arduino/sketches/rgbdriver/regtable.h -END diff --git a/examples/rgbdriver/.svn/entries b/examples/rgbdriver/.svn/entries deleted file mode 100644 index eb11b6e..0000000 --- a/examples/rgbdriver/.svn/entries +++ /dev/null @@ -1,232 +0,0 @@ -10 - -dir -770 -https://panstamp.googlecode.com/svn/trunk/arduino/sketches/rgbdriver -https://panstamp.googlecode.com/svn - - - -2012-07-24T14:28:42.926043Z -637 -dberenguer@usapiens.com - - - - - - - - - - - - - - -d77f469f-0316-7e13-d0a9-da7f422f7f4c - -rgbled.cpp -file -915 - - - -2013-02-23T18:16:51.867933Z -23c16fcc7ffaab7cb59d36ac4495b3a7 -2013-04-30T18:25:13.020037Z -915 -dberenguer@usapiens.com - - - - - - - - - - - - - - - - - - - - - -1647 - -rgbled.h -file - - - - -2012-07-26T09:30:27.000000Z -264771f0a4573d8011dd978401f66c4a -2012-07-24T14:28:42.926043Z -637 -dberenguer@usapiens.com - - - - - - - - - - - - - - - - - - - - - -1838 - -product.h -file - - - - -2012-07-26T09:30:27.000000Z -3a58a0876f3e75e2ed7ee8f3a5e76d30 -2012-07-24T14:28:42.926043Z -637 -dberenguer@usapiens.com - - - - - - - - - - - - - - - - - - - - - -1235 - -regtable.ino -file - - - - -2012-07-26T09:30:27.000000Z -31066f6243854e2e577f56f1292bb30c -2012-07-24T14:28:42.926043Z -637 -dberenguer@usapiens.com - - - - - - - - - - - - - - - - - - - - - -1867 - -rgbdriver.ino -file -915 - - - -2013-02-23T18:16:51.843933Z -bff8ead6d71762795460b54c2f807735 -2013-04-30T18:25:13.020037Z -915 -dberenguer@usapiens.com - - - - - - - - - - - - - - - - - - - - - -2924 - -regtable.h -file - - - - -2012-07-26T09:30:27.000000Z -a970a48380ae75eb340b29dc9d921f5b -2012-07-24T14:28:42.926043Z -637 -dberenguer@usapiens.com - - - - - - - - - - - - - - - - - - - - - -1120 - diff --git a/examples/rgbdriver/.svn/text-base/product.h.svn-base b/examples/rgbdriver/.svn/text-base/product.h.svn-base deleted file mode 100644 index 03fcccc..0000000 --- a/examples/rgbdriver/.svn/text-base/product.h.svn-base +++ /dev/null @@ -1,51 +0,0 @@ -/** - * product.h - * - * Copyright (c) 2011 Daniel Berenguer - * - * This file is part of the panStamp project. - * - * panStamp is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * panStamp is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with panStamp; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * Author: Daniel Berenguer - * Creation date: 03/31/2011 - */ - -#ifndef _PRODUCT_H -#define _PRODUCT_H - -/** - * Hardware version - */ -#define HARDWARE_VERSION 0x00000100 - -/** - * Firmware version - */ -#define FIRMWARE_VERSION 0x00000100 - -/** - * Manufacturer SWAP ID - */ -#define SWAP_MANUFACT_ID 0x00000001 - -/** - * Product SWAP ID - */ -#define SWAP_PRODUCT_ID 0x00000003 - -#endif - diff --git a/examples/rgbdriver/.svn/text-base/regtable.h.svn-base b/examples/rgbdriver/.svn/text-base/regtable.h.svn-base deleted file mode 100644 index ef87cf8..0000000 --- a/examples/rgbdriver/.svn/text-base/regtable.h.svn-base +++ /dev/null @@ -1,43 +0,0 @@ -/** - * regtable.h - * - * Copyright (c) 2011 Daniel Berenguer - * - * This file is part of the panStamp project. - * - * panStamp is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * panStamp is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with panStamp; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * Author: Daniel Berenguer - * Creation date: 03/31/2011 - */ - -#ifndef _REGTABLE_H -#define _REGTABLE_H - -#include "Arduino.h" -#include "register.h" -#include "commonregs.h" - -/** - * Register indexes - */ - -DEFINE_COMMON_REGINDEX_START() - REGI_RGBLEVELS -DEFINE_COMMON_REGINDEX_END() - -#endif - diff --git a/examples/rgbdriver/.svn/text-base/regtable.ino.svn-base b/examples/rgbdriver/.svn/text-base/regtable.ino.svn-base deleted file mode 100644 index 9cf5e94..0000000 --- a/examples/rgbdriver/.svn/text-base/regtable.ino.svn-base +++ /dev/null @@ -1,81 +0,0 @@ -/** - * regtable.pde - * - * Copyright (c) 2011 Daniel Berenguer - * - * This file is part of the panStamp project. - * - * panStamp is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * panStamp is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with panStamp; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * Author: Daniel Berenguer - * Creation date: 03/31/2011 - */ - -#include -#include "product.h" -#include "panstamp.h" -#include "regtable.h" - -/** - * Declaration of common callback functions - */ -DECLARE_COMMON_CALLBACKS() - -/** - * Definition of common registers - */ -DEFINE_COMMON_REGISTERS(); - -/* - * Definition of custom registers - */ -// RGB levels -static byte dtRGBlevel[3]; -REGISTER regRGBlevels(dtRGBlevel, sizeof(dtRGBlevel), NULL, &setRGBlevel); - -/** - * Initialize table of registers - */ -DECLARE_REGISTERS_START() - ®RGBlevels -DECLARE_REGISTERS_END() - -/** - * Definition of common getter/setter callback functions - */ -DEFINE_COMMON_CALLBACKS() - -/** - * Definition of custom getter/setter callback functions - */ - -/** - * setRGBlevel - * - * Set RGB color levels - * - * 'rId' Register ID - * 'levels' New RGB levels - */ -const void setRGBlevel(byte rId, byte *levels) -{ - // Update register - memcpy(dtRGBlevel, levels, sizeof(dtRGBlevel)); - - // Control RGB LED - rgbLed.setColor(levels[0], levels[1], levels[2]); -} - diff --git a/examples/rgbdriver/.svn/text-base/rgbdriver.ino.svn-base b/examples/rgbdriver/.svn/text-base/rgbdriver.ino.svn-base deleted file mode 100644 index e4d15c1..0000000 --- a/examples/rgbdriver/.svn/text-base/rgbdriver.ino.svn-base +++ /dev/null @@ -1,110 +0,0 @@ -/** - * Copyright (c) 2011 Daniel Berenguer - * - * This file is part of the panStamp project. - * - * panStamp is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * panStamp is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with panStamp; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * Author: Daniel Berenguer - * Creation date: 06/22/2011 - * - * Device: - * RGB LED driver - * - * Description: - * This device controls a RGB LED or a RGB LED strip using three PWM - * outputs. RGB levels can be controlled via the RGBlevel register - * (see Device Definition File for details). At the same time, this device - * listens for the first Chronos watch appearing in the network and - * synchronizes the RGB levels with the Chronos XYZ acceleration samples. - * - * Associated Device Definition File: rgbdriver.xml - */ - -#include "panstamp.h" -#include "regtable.h" -#include "rgbled.h" - -#define CHRONOS_PRODUCT_CODE {0,0,0,1,0,0,0,2} -#define CHRONOS_REGID_ACC 14 - -// Global RGBLED object. Define your own PWM outputs here: -RGBLED rgbLed = RGBLED(9, 6, 5); - -// Address of the associated Chronos watch -byte chronosDevAddr = 0; - -/** - * swapStatusReceived - * - * Function automatically called by the panStamp API whenever a SWAP status - * packet is received - * - * 'status' SWAP status packet received - */ - void swapStatusReceived(SWPACKET *status) - { - byte chronos_pCode[] = CHRONOS_PRODUCT_CODE; - - // Still without an associated Chronos watch? - if (chronosDevAddr == 0) - { - // Product code received? - if (status->regId == REGI_PRODUCTCODE) - { - // Is this a Chronos watch? - if (!memcmp(status->value.data, chronos_pCode, sizeof(chronos_pCode))) - chronosDevAddr = status->srcAddr; // Save its device address - } - } - // We already have an associated Chronos watch - else - { - // Acceleration data received? - if (status->regId == CHRONOS_REGID_ACC) - { - // Update RGB levels - getRegister(REGI_RGBLEVELS)->setData(status->value.data); - } - } - } - -/** - * setup - * - * One-time setup function - */ -void setup() -{ - // Init panStamp - panstamp.init(); - - // Declare callback function for dispatching the incoming SWAP status packets - panstamp.setSwapStatusCallBack(swapStatusReceived); - - // Broadcast product status - getRegister(REGI_PRODUCTCODE)->getData(); -} - -/** - * loop - * - * Main loop - */ -void loop() -{ - delay(100); -} diff --git a/examples/rgbdriver/.svn/text-base/rgbled.cpp.svn-base b/examples/rgbdriver/.svn/text-base/rgbled.cpp.svn-base deleted file mode 100644 index d66b1d7..0000000 --- a/examples/rgbdriver/.svn/text-base/rgbled.cpp.svn-base +++ /dev/null @@ -1,62 +0,0 @@ -/** - * rgbled.pde - * - * Copyright (c) 2011 Daniel Berenguer - * - * This file is part of the panStamp project. - * - * panStamp is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * panStamp is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with panStamp; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * Author: Daniel Berenguer - * Creation date: 06/22/2011 - */ - -#include "rgbled.h" - -/** - * Class constructor - * - * 'redPin' Arduino pin connected to the red LED - * 'greenPin' Arduino pin connected to the green LED - * 'bluePin' Arduino pin connected to the blue LED -*/ -RGBLED::RGBLED(int redPin, int greenPin, int bluePin) -{ - pRed = redPin; - pGreen = greenPin; - pBlue = bluePin; - - pinMode(pRed, OUTPUT); - pinMode(pGreen, OUTPUT); - pinMode(pBlue, OUTPUT); -} - -/** - * setColor - * - * Set color levels on the RGB LED - * - * 'red' Bright level of the red LED - * 'green' Bright level of the green LED - * 'blue' Bright level of the blue LED - */ -void RGBLED::setColor(byte red, byte green, byte blue) -{ - analogWrite(pRed, red); - analogWrite(pGreen, green); - analogWrite(pBlue, blue); -} - diff --git a/examples/rgbdriver/.svn/text-base/rgbled.h.svn-base b/examples/rgbdriver/.svn/text-base/rgbled.h.svn-base deleted file mode 100644 index 15b5e38..0000000 --- a/examples/rgbdriver/.svn/text-base/rgbled.h.svn-base +++ /dev/null @@ -1,77 +0,0 @@ -/** - * rgbled.h - * - * Copyright (c) 2011 Daniel Berenguer - * - * This file is part of the panStamp project. - * - * panStamp is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * panStamp is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with panStamp; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * Author: Daniel Berenguer - * Creation date: 06/22/2011 - */ - -#ifndef _RGBLED_H -#define _RGBLED_H - -#include "Arduino.h" - -/** - * Macros - */ -#define turnOff() setColor(0, 0, 0) - -class RGBLED -{ - private: - /** - * Arduino pin connected to the red LED - */ - int pRed; - - /** - * Arduino pin connected to the green LED - */ - int pGreen; - - /** - * Arduino pin connected to the blue LED - */ - int pBlue; - - public: - /** - * Class constructor - * - * 'redPin' Arduino pin connected to the red LED - * 'greenPin' Arduino pin connected to the green LED - * 'bluePin' Arduino pin connected to the blue LED - */ - RGBLED(int redPin, int greenPin, int bluePin); - - /** - * setColor - * - * Set color levels on the RGB LED - * - * 'red' Bright level of the red LED - * 'green' Bright level of the green LED - * 'blue' Bright level of the blue LED - */ - void setColor(byte red, byte green, byte blue); -}; - -#endif diff --git a/examples/soilmoisture/.svn/all-wcprops b/examples/soilmoisture/.svn/all-wcprops deleted file mode 100644 index c2c27e4..0000000 --- a/examples/soilmoisture/.svn/all-wcprops +++ /dev/null @@ -1,29 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 53 -/svn/!svn/ver/911/trunk/arduino/sketches/soilmoisture -END -product.h -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/911/trunk/arduino/sketches/soilmoisture/product.h -END -regtable.ino -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/911/trunk/arduino/sketches/soilmoisture/regtable.ino -END -regtable.h -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/911/trunk/arduino/sketches/soilmoisture/regtable.h -END -soilmoisture.ino -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/911/trunk/arduino/sketches/soilmoisture/soilmoisture.ino -END diff --git a/examples/soilmoisture/.svn/entries b/examples/soilmoisture/.svn/entries deleted file mode 100644 index bf0e2ea..0000000 --- a/examples/soilmoisture/.svn/entries +++ /dev/null @@ -1,164 +0,0 @@ -10 - -dir -911 -https://panstamp.googlecode.com/svn/trunk/arduino/sketches/soilmoisture -https://panstamp.googlecode.com/svn - - - -2013-04-30T18:13:43.004908Z -911 -dberenguer@usapiens.com - - - - - - - - - - - - - - -d77f469f-0316-7e13-d0a9-da7f422f7f4c - -product.h -file - - - - -2013-04-29T15:43:41.474588Z -3f03b073a78ce18ac552608ab9e9d21a -2013-04-30T18:13:43.004908Z -911 -dberenguer@usapiens.com - - - - - - - - - - - - - - - - - - - - - -1233 - -regtable.ino -file - - - - -2013-04-30T17:49:06.286847Z -4b4268158c0936839bcfe2d29aeeecad -2013-04-30T18:13:43.004908Z -911 -dberenguer@usapiens.com - - - - - - - - - - - - - - - - - - - - - -3384 - -regtable.h -file - - - - -2013-04-30T15:35:41.170872Z -1723fd148ac89f45332e08e43b432773 -2013-04-30T18:13:43.004908Z -911 -dberenguer@usapiens.com - - - - - - - - - - - - - - - - - - - - - -1139 - -soilmoisture.ino -file - - - - -2013-04-30T18:12:58.434843Z -d14bcf31021c107617eb65b18ec7dafc -2013-04-30T18:13:43.004908Z -911 -dberenguer@usapiens.com - - - - - - - - - - - - - - - - - - - - - -2924 - diff --git a/examples/soilmoisture/.svn/text-base/product.h.svn-base b/examples/soilmoisture/.svn/text-base/product.h.svn-base deleted file mode 100644 index b7fb778..0000000 --- a/examples/soilmoisture/.svn/text-base/product.h.svn-base +++ /dev/null @@ -1,51 +0,0 @@ -/** - * product.h - * - * Copyright (c) 2011 Daniel Berenguer - * - * This file is part of the panStamp project. - * - * panStamp is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * panStamp is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with panStamp; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * Author: Daniel Berenguer - * Creation date: 04/29/2013 - */ - -#ifndef _PRODUCT_H -#define _PRODUCT_H - -/** - * Hardware version - */ -#define HARDWARE_VERSION 0x00000100 - -/** - * Firmware version - */ -#define FIRMWARE_VERSION 0x00000100 - -/** - * Manufacturer SWAP ID - */ -#define SWAP_MANUFACT_ID 0x00000001 - -/** - * Product SWAP ID - */ -#define SWAP_PRODUCT_ID 0x0000000E - -#endif - diff --git a/examples/soilmoisture/.svn/text-base/regtable.h.svn-base b/examples/soilmoisture/.svn/text-base/regtable.h.svn-base deleted file mode 100644 index edbb8fc..0000000 --- a/examples/soilmoisture/.svn/text-base/regtable.h.svn-base +++ /dev/null @@ -1,44 +0,0 @@ -/** - * regtable.h - * - * Copyright (c) 2011 Daniel Berenguer - * - * This file is part of the panStamp project. - * - * panStamp is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * panStamp is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with panStamp; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * Author: Daniel Berenguer - * Creation date: 04/29/2013 - */ - -#ifndef _REGTABLE_H -#define _REGTABLE_H - -#include "Arduino.h" -#include "register.h" -#include "commonregs.h" - -/** - * Register indexes - */ -DEFINE_REGINDEX_START() - REGI_VOLTSUPPLY, - REGI_SENSOR0, - REGI_SENSOR1, -DEFINE_REGINDEX_END() - -#endif - diff --git a/examples/soilmoisture/.svn/text-base/regtable.ino.svn-base b/examples/soilmoisture/.svn/text-base/regtable.ino.svn-base deleted file mode 100644 index 4d2df92..0000000 --- a/examples/soilmoisture/.svn/text-base/regtable.ino.svn-base +++ /dev/null @@ -1,137 +0,0 @@ -/** - * regtable - * - * Copyright (c) 2011 Daniel Berenguer - * - * This file is part of the panStamp project. - * - * panStamp is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * panStamp is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with panStamp; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * Author: Daniel Berenguer - * Creation date: 03/31/2011 - */ - -#include -#include "product.h" -#include "panstamp.h" -#include "regtable.h" - -/** - * Declaration of common callback functions - */ -DECLARE_COMMON_CALLBACKS() - -/** - * Definition of common registers - */ -DEFINE_COMMON_REGISTERS() - -/* - * Definition of custom registers - */ -// Voltage supply -static unsigned long voltageSupply = 3300; -static byte dtVoltSupply[2]; -REGISTER regVoltSupply(dtVoltSupply, sizeof(dtVoltSupply), &updtVoltSupply, NULL); -// Sensor value register (dual sensor) -static byte dtSensor[4]; -REGISTER regSensor(dtSensor, sizeof(dtSensor), &updtSensor, NULL); - -/** - * Initialize table of registers - */ -DECLARE_REGISTERS_START() - ®VoltSupply, - ®Sensor -DECLARE_REGISTERS_END() - -/** - * Definition of common getter/setter callback functions - */ -DEFINE_COMMON_CALLBACKS() - -/** - * Definition of custom getter/setter callback functions - */ - -/** - * updtVoltSupply - * - * Measure voltage supply and update register - * - * 'rId' Register ID - */ -const void updtVoltSupply(byte rId) -{ - unsigned long result; - - // Read 1.1V reference against AVcc - ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1); - delay(2); // Wait for Vref to settle - ADCSRA |= _BV(ADSC); // Convert - while (bit_is_set(ADCSRA,ADSC)); - result = ADCL; - result |= ADCH << 8; - result = 1126400L / result; // Back-calculate AVcc in mV - voltageSupply = result; // Update global variable Vcc - - #ifdef VOLT_SUPPLY_A7 - - // Read voltage supply from A7 - unsigned short ref = voltageSupply; - result = analogRead(7); - result *= ref; - result /= 1024; - #endif - - /** - * register[eId]->member can be replaced by regVoltSupply in this case since - * no other register is going to use "updtVoltSupply" as "updater" function - */ - - // Update register value - regTable[rId]->value[0] = (result >> 8) & 0xFF; - regTable[rId]->value[1] = result & 0xFF; -} - -/** - * updtSensor - * - * Measure sensor data and update register - * - * 'rId' Register ID - */ -const void updtSensor(byte rId) -{ - // Power sensors - digitalWrite(POWER_0_PIN, HIGH); - digitalWrite(POWER_1_PIN, HIGH); - delay(10); - // Read analog values - unsigned int adcValue0 = analogRead(SENSOR_0_PIN); - unsigned int adcValue1 = analogRead(SENSOR_1_PIN); - // Unpower sensors - digitalWrite(POWER_0_PIN, LOW); - digitalWrite(POWER_1_PIN, LOW); - - // Update register value - dtSensor[0] = (adcValue0 >> 8) & 0xFF; - dtSensor[1] = adcValue0 & 0xFF; - dtSensor[2] = (adcValue1 >> 8) & 0xFF; - dtSensor[3] = adcValue1 & 0xFF; -} - - diff --git a/examples/soilmoisture/.svn/text-base/soilmoisture.ino.svn-base b/examples/soilmoisture/.svn/text-base/soilmoisture.ino.svn-base deleted file mode 100644 index b427570..0000000 --- a/examples/soilmoisture/.svn/text-base/soilmoisture.ino.svn-base +++ /dev/null @@ -1,122 +0,0 @@ -/* - * soilmoisture - * - * Copyright (c) 2011 Daniel Berenguer - * - * This file is part of the panStamp project. - * - * panStamp is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * panStamp is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with panStamp; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * Author: Daniel Berenguer - * Creation date: 04/29/2013 - * - * Device: - * Soil Moisture sensor - * - * Description: - * This application measures soil moisture from any two sensor providing an - * analog signal - * - * These devices are low-power enabled so they will enter low-power mode - * just after reading the sensor values and transmitting them over the - * SWAP network. - * - * Associated Device Definition File, defining registers, endpoints and - * configuration parameters: - * soilmoisture.xml - */ - -#include "regtable.h" -#include "panstamp.h" - -/** - * Uncomment if you are reading Vcc from A7. All battery-boards do this - */ -#define VOLT_SUPPLY_A7 - -/** - * LED pin - */ -#define LEDPIN 4 - -/** - * Sensor pins - */ -#define SENSOR_0_PIN 3 // Analog pin - sensor 0 -#define POWER_0_PIN 16 // Digital pin used to powwer sensor 0 -#define SENSOR_1_PIN 5 // Analog pin - sensor 1 -#define POWER_1_PIN 18 // Digital pin used to powwer sensor 1 - -/** - * setup - * - * Arduino setup function - */ -void setup() -{ - int i; - - pinMode(LEDPIN, OUTPUT); - digitalWrite(LEDPIN, LOW); - - // Initialize power pins - pinMode(POWER_0_PIN, OUTPUT); - digitalWrite(POWER_0_PIN, LOW); - pinMode(POWER_1_PIN, OUTPUT); - digitalWrite(POWER_1_PIN, LOW); - - // Init panStamp - panstamp.init(); - - // Transmit product code - getRegister(REGI_PRODUCTCODE)->getData(); - - // Enter SYNC state - panstamp.enterSystemState(SYSTATE_SYNC); - - // During 3 seconds, listen the network for possible commands whilst the LED blinks - for(i=0 ; i<6 ; i++) - { - digitalWrite(LEDPIN, HIGH); - delay(100); - digitalWrite(LEDPIN, LOW); - delay(400); - } - - // Transmit periodic Tx interval - getRegister(REGI_TXINTERVAL)->getData(); - // Transmit power voltage - getRegister(REGI_VOLTSUPPLY)->getData(); - // Switch to Rx OFF state - panstamp.enterSystemState(SYSTATE_RXOFF); -} - -/** - * loop - * - * Arduino main loop - */ -void loop() -{ - // Transmit sensor data - getRegister(REGI_SENSOR)->getData(); - // Transmit power voltage - getRegister(REGI_VOLTSUPPLY)->getData(); - - // Sleep - panstamp.goToSleep(); -} - diff --git a/examples/template/.svn/all-wcprops b/examples/template/.svn/all-wcprops deleted file mode 100644 index 6c13ddb..0000000 --- a/examples/template/.svn/all-wcprops +++ /dev/null @@ -1,29 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/351/trunk/arduino/sketches/template -END -template.ino -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/351/trunk/arduino/sketches/template/template.ino -END -product.h -K 25 -svn:wc:ra_dav:version-url -V 59 -/svn/!svn/ver/351/trunk/arduino/sketches/template/product.h -END -regtable.ino -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/351/trunk/arduino/sketches/template/regtable.ino -END -regtable.h -K 25 -svn:wc:ra_dav:version-url -V 60 -/svn/!svn/ver/351/trunk/arduino/sketches/template/regtable.h -END diff --git a/examples/template/.svn/entries b/examples/template/.svn/entries deleted file mode 100644 index 07d8228..0000000 --- a/examples/template/.svn/entries +++ /dev/null @@ -1,164 +0,0 @@ -10 - -dir -770 -https://panstamp.googlecode.com/svn/trunk/arduino/sketches/template -https://panstamp.googlecode.com/svn - - - -2012-01-02T18:09:17.986421Z -351 -dberenguer@usapiens.com - - - - - - - - - - - - - - -d77f469f-0316-7e13-d0a9-da7f422f7f4c - -product.h -file - - - - -2012-07-26T09:30:28.000000Z -beb8634d55fe7ee4c08aaf9e2441bbe1 -2012-01-02T18:09:17.986421Z -351 -dberenguer@usapiens.com - - - - - - - - - - - - - - - - - - - - - -1235 - -regtable.ino -file - - - - -2012-07-26T09:30:28.000000Z -0ccc5051fd17a89016d211b82d0902d1 -2012-01-02T18:09:17.986421Z -351 -dberenguer@usapiens.com - - - - - - - - - - - - - - - - - - - - - -1506 - -regtable.h -file - - - - -2012-07-26T09:30:28.000000Z -f92083137e9b15be3287be3aac5c13f0 -2012-01-02T18:09:17.986421Z -351 -dberenguer@usapiens.com - - - - - - - - - - - - - - - - - - - - - -1117 - -template.ino -file - - - - -2012-07-26T09:30:28.000000Z -20477803c4197d163bbd0769da9d3296 -2012-01-02T18:09:17.986421Z -351 -dberenguer@usapiens.com - - - - - - - - - - - - - - - - - - - - - -1172 - diff --git a/examples/template/.svn/text-base/product.h.svn-base b/examples/template/.svn/text-base/product.h.svn-base deleted file mode 100644 index 2405b91..0000000 --- a/examples/template/.svn/text-base/product.h.svn-base +++ /dev/null @@ -1,51 +0,0 @@ -/** - * product.h - * - * Copyright (c) 2011 Daniel Berenguer - * - * This file is part of the panStamp project. - * - * panStamp is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * panLoader is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with panLoader; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * Author: Daniel Berenguer - * Creation date: 12/28/2011 - */ - -#ifndef _PRODUCT_H -#define _PRODUCT_H - -/** - * Hardware version - */ -#define HARDWARE_VERSION 0x00000000 - -/** - * Firmware version - */ -#define FIRMWARE_VERSION 0x00000000 - -/** - * Manufacturer SWAP ID - */ -#define SWAP_MANUFACT_ID 0x00000000 - -/** - * Product SWAP ID - */ -#define SWAP_PRODUCT_ID 0x00000000 - -#endif - diff --git a/examples/template/.svn/text-base/regtable.h.svn-base b/examples/template/.svn/text-base/regtable.h.svn-base deleted file mode 100644 index f9d6a84..0000000 --- a/examples/template/.svn/text-base/regtable.h.svn-base +++ /dev/null @@ -1,42 +0,0 @@ -/** - * regtable.h - * - * Copyright (c) 2011 Daniel Berenguer - * - * This file is part of the panStamp project. - * - * panStamp is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * panLoader is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with panLoader; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * Author: Daniel Berenguer - * Creation date: 12/28/2011 - */ - -#ifndef _REGTABLE_H -#define _REGTABLE_H - -#include "Arduino.h" -#include "register.h" -#include "commonregs.h" - -/** - * Register indexes - */ -DEFINE_REGINDEX_START() - // First index here = 11 -DEFINE_REGINDEX_END() - -#endif - diff --git a/examples/template/.svn/text-base/regtable.ino.svn-base b/examples/template/.svn/text-base/regtable.ino.svn-base deleted file mode 100644 index 9b19a62..0000000 --- a/examples/template/.svn/text-base/regtable.ino.svn-base +++ /dev/null @@ -1,62 +0,0 @@ -/** - * regtable - * - * Copyright (c) 2011 Daniel Berenguer - * - * This file is part of the panStamp project. - * - * panStamp is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * panLoader is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with panLoader; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * Author: Daniel Berenguer - * Creation date: 12/28/2011 - */ - -#include -#include "product.h" -#include "panstamp.h" -#include "regtable.h" - -/** - * Declaration of common callback functions - */ -DECLARE_COMMON_CALLBACKS() - -/** - * Definition of common registers - */ -DEFINE_COMMON_REGISTERS() - -/* - * Definition of custom registers - */ -// Your custom registers come here - -/** - * Initialize table of registers - */ -DECLARE_REGISTERS_START() - // Put here pointers to your custom registers -DECLARE_REGISTERS_END() - -/** - * Definition of common getter/setter callback functions - */ -DEFINE_COMMON_CALLBACKS() - -/** - * Definition of custom getter/setter callback functions - */ - diff --git a/examples/template/.svn/text-base/template.ino.svn-base b/examples/template/.svn/text-base/template.ino.svn-base deleted file mode 100644 index 535db02..0000000 --- a/examples/template/.svn/text-base/template.ino.svn-base +++ /dev/null @@ -1,52 +0,0 @@ -/* - * template - * - * Copyright (c) 2011 Daniel Berenguer - * - * This file is part of the panStamp project. - * - * panLoader is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * panLoader is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with panLoader; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * Author: Daniel Berenguer - * Creation date: 12/28/2011 - */ - -#include "regtable.h" -#include "panstamp.h" - -/** - * setup - * - * Arduino setup function - */ -void setup() -{ - // Init panStamp - panstamp.init(); - - // Transmit product code - getRegister(REGI_PRODUCTCODE)->getData(); -} - -/** - * loop - * - * Arduino main loop - */ -void loop() -{ -} - diff --git a/swvalue.h b/swvalue.h deleted file mode 100755 index 88b24be..0000000 --- a/swvalue.h +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Copyright (c) 2011 panStamp - * - * This file is part of the panStamp project. - * - * panStamp is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * any later version. - * - * panStamp is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with panStamp; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * Author: Daniel Berenguer - * Creation date: 06/03/2013 - */ - -#ifndef _SWVALUE_H -#define _SWVALUE_H - -#include "datatypes.h" - -/** - * Class: SWAPVALUE - * - * Description: - * SWAP value class - */ -template< typename T > class SWVALUE -{ - private: - /** - * Byte position in register - */ - uint8_t position; - - /** - * Number of bytes - */ - uint8_t length; - - /** - * value in byte-array format - */ - uint8_t *data; - - public: - /** - * Class constructor - * - * @param pos byte-position in register - * @param size byte-length of the value - */ - SWVALUE(uint8_t pos, uint8_t size) - { - position = pos; - length = size; - data = new uint8_t[size]; - } - - /** - * get - * - * @param val Value in unsigned integer format - */ - void get(T val) - { - int i; - - for(i=length-1 ; i>=0 ; i--) - { - data[i] = val & 0xFF; - val >>= 8; - } - } - -// constructor with user pre-defined size - array (int s) { - size = s; - myarray = new T [size]; - } - - template void setRegValue(T val, uint8_t size=0 , uint8_t offset=0) - { - int i, len; - - size > 0 ? len = size : len = length; - - for(i=len+offset-1 ; i<=offset ; i--) - { - value[i] = val & 0xFF; - val >>= 8; - } - } -}; - -#endif -