grove: remove deprecated classes and examples

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Mihai Tudor Panu
2019-05-07 18:00:34 -07:00
parent 7d0600df1c
commit 33d0aee280
217 changed files with 11 additions and 12042 deletions

View File

@ -1,6 +0,0 @@
set (libname "grove")
set (libdescription "Grove Starter Kit Sensor Library")
set (module_src grovebutton.cxx groveled.cxx grovelight.cxx groverelay.cxx groverotary.cxx groveslide.cxx grovetemp.cxx)
set (module_hpp grovebutton.hpp groveled.hpp grovelight.hpp groverelay.hpp groverotary.hpp groveslide.hpp grovetemp.hpp grovebase.hpp grove.hpp)
set (module_iface iLight.hpp)
upm_module_init(mraa)

View File

@ -1 +0,0 @@

View File

@ -1,34 +0,0 @@
/*
* Authors: Brendan Le Foll <brendan.le.foll@intel.com>
* Mihai Tudor Panu <mihai.tudor.panu@intel.com>
* Sarah Knepper <sarah.knepper@intel.com>
* Copyright (c) 2014 - 2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <grovebutton.hpp>
#include <groveled.hpp>
#include <grovelight.hpp>
#include <groverelay.hpp>
#include <groverotary.hpp>
#include <groveslide.hpp>
#include <grovetemp.hpp>

View File

@ -1,43 +0,0 @@
#ifdef SWIGPYTHON
%module (package="upm") htu21d
#endif
%import "interfaces/interfaces.i"
%include "../common_top.i"
/* BEGIN Java syntax ------------------------------------------------------- */
#ifdef SWIGJAVA
%typemap(javaimports) SWIGTYPE %{
import upm_interfaces.*;
%}
%apply int {mraa::Edge}
JAVA_ADD_INSTALLISR_EDGE(upm::GroveButton)
JAVA_JNI_LOADLIBRARY(javaupm_grove)
#endif
/* END Java syntax */
/* BEGIN Common SWIG syntax ------------------------------------------------- */
%{
#include "grovebase.hpp"
#include "grove.hpp"
#include "grovebutton.hpp"
#include "groveled.hpp"
#include "grovelight.hpp"
#include "groverelay.hpp"
#include "groverotary.hpp"
#include "groveslide.hpp"
#include "grovetemp.hpp"
%}
%include "grovebase.hpp"
%include "grove.hpp"
%include "grovebutton.hpp"
%include "groveled.hpp"
%include "grovelight.hpp"
%include "groverelay.hpp"
%include "groverotary.hpp"
%include "groveslide.hpp"
%include "grovetemp.hpp"
/* END Common SWIG syntax */

View File

@ -1,381 +0,0 @@
{
"Library": "grove",
"Description": "Generic library for basic Grove sensors",
"Sensor Class": {
"Grove": {
"Name": "Generic library for basic Grove sensors",
"Description": "This is the Generic UPM Module for basic Grove sensors. This library is now deprecated and replaced by individual libraries for every sensor.",
"Aliases": ["grove", "libupm-grove"],
"Categories": ["LED", "light", "relay", "temperature", "touch"],
"Connections": ["i2c", "gpio", "pwm", "ainput"],
"Project Type": ["prototyping", "commercial"],
"Manufacturers": ["Seeed"],
"Kits": ["gsk", "eak", "hak"],
"Examples": {
"C++": ["grove-grovebutton.cxx"]
},
"Urls": {
"Product Pages": ["https://github.com/intel-iot-devkit/upm/tree/master/src/grove"]
}
},
"GroveButton": {
"Name": "API for the Grove Button",
"Description": "This is the UPM Module for the Grove button. This class is being replaced by the upm-button library and the Button class.",
"Aliases": ["Grove Touch Sensor", "Grove button"],
"Categories": ["touch"],
"Connections": ["gpio"],
"Project Type": ["prototyping"],
"Manufacturers": ["Seeed"],
"Kits": ["gsk"],
"Image": "grovebutton.jpg",
"Examples": {
"Java": ["GroveButton_Example.java", "GroveButton_intr_Example.java"],
"Python": ["grovebutton.py"],
"Node.js": ["grovebutton.js"],
"C++": ["grove-grovebutton.cxx"]
},
"Specifications": {
"Vsource": {
"unit": "V",
"min": 3.3,
"max": 12.0
},
"Supply Current Digital": {
"unit": "mA",
"min" : 5,
"max" : 25
},
"Operating Temperature": {
"unit": "°C",
"min": -40,
"max": 85
}
},
"Platforms": {
"Intel Edison": {
"Notes": ["Might need Grove base shield"]
},
"Arduino 101": {
"Notes": ["Might need Grove base shield"]
}
},
"Urls": {
"Product Pages": ["https://www.seeedstudio.com/Grove-Button-p-766.html", "http://wiki.seeed.cc/Grove-Button/"],
"Schematics": ["https://github.com/SeeedDocument/Grove_Button/raw/master/resources/Grove_-_Button_v1.0_Source_File.zip"]
}
},
"GroveLed": {
"Name": "API for the Grove LED",
"Description": "This is the UPM Module for the Grove LED. This class is being replaced by the upm-led library and the Led class.",
"Aliases": ["Grove LED", "Grove Chainable RGB Led V2.0"],
"Categories": ["LED"],
"Connections": ["gpio"],
"Project Type": ["prototyping"],
"Manufacturers": ["Seeed"],
"Kits": ["gsk"],
"Image": "groveled.jpg",
"Examples": {
"Java": ["GroveLED_Example.java", "GroveLed_multi_Example.java"],
"Python": ["groveled.py"],
"Node.js": ["groveled.js"],
"C++": ["grove-groveled.cxx", "grove-groveled-multi.cxx"]
},
"Specifications": {
"Vsource": {
"unit": "V",
"min": 4.5,
"max": 7.5
},
"Supply Current": {
"unit": "mA",
"min" : 20,
"max" : 60
},
"Operating Temperature": {
"unit": "°C",
"min": -40,
"max": 85
}
},
"Platforms": {
"Intel Edison": {
"Notes": ["Might need Grove base shield"]
},
"Arduino 101": {
"Notes": ["Might need Grove base shield"]
}
},
"Urls": {
"Product Pages": ["https://www.seeedstudio.com/Grove-%E2%80%93-Chainable-RGB-Led-V2.0-p-2903.html", "http://wiki.seeed.cc/Grove-Chainable_RGB_LED/"],
"Datasheets": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Chainable_RGB_LED/master/res/P9813_datasheet.pdf"],
"Schematics": ["https://github.com/SeeedDocument/Grove-Chainable_RGB_LED/raw/master/res/Grove%20-%20Chainable%20RGB%20LED%20v2.0.zip"]
}
},
"GroveLight": {
"Name": "API for the Grove Light Sensor",
"Description": "This is the UPM Module for the Grove Light Sensor. This class is being replaced by the upm-light library and the Light class.",
"Aliases": ["grovelight", "Grove - Light Sensor(P)"],
"Categories": ["light"],
"Connections": ["analog"],
"Project Type": ["prototyping"],
"Manufacturers": ["Seeed"],
"Kits": ["gsk"],
"Image": "grovelight.jpg",
"Examples": {
"Java": ["GroveLight_Example.java"],
"Python": ["grovelight.py"],
"Node.js": ["grovelight.js"],
"C++": ["grove-grovelight.cxx"]
},
"Specifications": {
"Vsource": {
"unit": "V",
"min": 3,
"max": 5
},
"Supply Current": {
"unit": "mA",
"min" : 0.5,
"max" : 3.0
},
"Operating Temperature": {
"unit": "°C",
"min": -40,
"max": 85
},
"Response Time": {
"unit": "ms",
"min" : 20,
"max" : 30
}
},
"Platforms": {
"Intel Edison": {
"Notes": ["Might need Grove base shield"]
},
"Arduino 101": {
"Notes": ["Might need Grove base shield"]
}
},
"Urls": {
"Product Pages": ["https://www.seeedstudio.com/Grove-Light-Sensor(P)-p-1253.html", "http://wiki.seeed.cc/Grove-Light_Sensor/"],
"Datasheets": ["https://github.com/SeeedDocument/Grove_Light_Sensor/raw/master/res/LM358.pdf"],
"Schematics": ["https://github.com/SeeedDocument/Grove_Light_Sensor/raw/master/resources/Grove%20-%20Light%20Sensor%28P%29%20v1.1.zip"]
}
},
"GroveRelay": {
"Name": "API for the Grove Relay",
"Description": "This is the UPM Module for the Grove relay switch. This class is being replaced by the upm-relay library and the Relay class.",
"Aliases": ["groverelay", "Grove - Relay"],
"Categories": ["relay"],
"Connections": ["gpio"],
"Project Type": ["prototyping"],
"Manufacturers": ["Seeed"],
"Kits": ["gsk", "eak", "hak"],
"Image": "groverelay.jpg",
"Examples": {
"Java": ["GroveRelay_Example.java"],
"Python": ["groverelay.py"],
"Node.js": ["groverelay.js"],
"C++": ["grove-groverelay.cxx"]
},
"Specifications": {
"Vsource": {
"unit": "V",
"min": 3.3,
"max": 5.0
},
"Supply Current": {
"unit": "mA",
"typ" : 100
},
"Operating Temperature": {
"unit": "°C",
"min": -40,
"max": 85
},
"Relay Life": {
"unit": "Cycle",
"cycles": 100000
},
"Max Switching Voltage":{
"AC": {
"unit" : "V",
"max" : 250
},
"DC": {
"unit": "V",
"max" : 30
}
},
"Max Switching Current": {
"unit": "A",
"max" : 5
}
},
"Platforms": {
"Intel Edison": {
"Notes": ["Might need Grove base shield"]
},
"Arduino 101": {
"Notes": ["Might need Grove base shield"]
}
},
"Urls": {
"Product Pages": ["https://www.seeedstudio.com/Grove-Relay-p-769.html", "http://wiki.seeed.cc/Grove-Relay/"],
"Datasheets": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Relay/master/res/Relay_Datasheet.pdf"],
"Schematics": ["https://github.com/SeeedDocument/Grove-Relay/raw/master/res/Grove%20-%20Relay%20Schematic.pdf", "https://github.com/SeeedDocument/Grove-Relay/raw/master/res/Grove%20-%20Relay%20PCB.pdf", "https://raw.githubusercontent.com/SeeedDocument/Grove-Relay/master/res/Grove-Relay_Eagle_Files.zip"]
}
},
"GroveRotary": {
"Name": "API for the Grove Rotary Angle Sensor (Knob)",
"Description": "This is the UPM Module for the Grove Rotary Angle Sensor (Knob). This class is being replaced by the upm-rotary library and the Rotary class.",
"Aliases": ["groverotary", "Grove - Rotary Angle Sensor"],
"Categories": ["ainput"],
"Connections": ["analog"],
"Project Type": ["prototyping"],
"Manufacturers": ["Seeed"],
"Kits": ["gsk"],
"Image": "groverotary.jpg",
"Examples": {
"Java": ["GroveRotary_Example.java"],
"Python": ["groverotary.py"],
"Node.js": ["groverotary.js"],
"C++": ["grove-groverotary.cxx"]
},
"Specifications": {
"Vsource": {
"unit": "V",
"min": 4.75,
"max": 5.25
},
"Supply Current": {
"unit": "mA",
"typ" : 20
},
"Operating Temperature": {
"unit": "°C",
"min": -40,
"max": 85
},
"Rotary Angle":{
"unit": "°",
"min" : 0,
"max" : 300
}
},
"Platforms": {
"Intel Edison": {
"Notes": ["Might need Grove base shield"]
},
"Arduino 101": {
"Notes": ["Might need Grove base shield"]
}
},
"Urls": {
"Product Pages": ["https://www.seeedstudio.com/Grove-Rotary-Angle-Sensor-p-770.html", "http://wiki.seeed.cc/Grove-Rotary_Angle_Sensor/"],
"Schematics": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Rotary_Angle_Sensor/master/res/Grove-Rotary_Angle_Sensor_Eagle_File.zip", "https://raw.githubusercontent.com/SeeedDocument/Grove-Rotary_Angle_Sensor/master/res/Grove-Rotary_Angle_Sensor_v1.2.zip"]
}
},
"GroveSlide": {
"Name": "API for the Grove Slide Potentiometer",
"Description": "This is the UPM Module for the Grove Slide Potentiometer. This class is being replaced by the upm-slide library and the Slide class.",
"Aliases": ["groveslide", "Grove - Slide Potentiometer"],
"Categories": ["ainput"],
"Connections": ["analog"],
"Project Type": ["prototyping"],
"Manufacturers": ["Seeed"],
"Images": "slide.jpg",
"Examples": {
"Java": ["GroveSlide_Example.java"],
"Python": ["groveslide.py"],
"Node.js": ["groveslide.js"],
"C++": ["grove-groveslide.cxx"]
},
"Specifications": {
"Vsource": {
"unit": "V",
"min": 3.3,
"max": 30
},
"Supply Current": {
"unit": "mA",
"max" : 30
},
"Operating Temperature": {
"unit": "°C",
"min": -40,
"max": 85
},
"Sroke Length": {
"unit": "mm",
"min" : 0,
"max" : 30
}
},
"Platforms": {
"Intel Edison": {
"Notes": ["Might need Grove base shield"]
},
"Arduino 101": {
"Notes": ["Might need Grove base shield"]
}
},
"Urls": {
"Product Pages": ["https://www.seeedstudio.com/Grove-Slide-Potentiometer-p-1196.html?gclid=Cj0KCQjw5arMBRDzARIsAAqmJexy5Nrps6rpUqNFk4iIL6mVfHQt7EYfly4NbdhC7wBl4p3AxQZNkjIaAuN2EALw_wcB", "http://wiki.seeed.cc/Grove-Slide_Potentiometer/"],
"Datasheets": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Slide_Potentiometer/master/res/Sliding_potentiometer_datasheet.pdf"],
"Schematics": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Slide_Potentiometer/master/res/Sliding_Potentiometer.rar"]
}
},
"GroveTemp": {
"Name": "API for the Grove Temperature Sensor",
"Description": "This is the UPM Module for the Grove Temperature Sensor. This class is being replaced by the upm-temperature library and the Temperature class.",
"Aliases": ["groverelay", "Grove - Temperature Sensor"],
"Categories": ["temperature"],
"Connections": ["analog"],
"Project Type": ["prototyping"],
"Manufacturers": ["Seeed"],
"Kits": ["gsk"],
"Image": "grovetemp.jpg",
"Examples": {
"Java": ["GroveTemp_Example.java"],
"Python": ["grovetemp.py"],
"Node.js": ["grovetemp.js"],
"C++": ["grove-grovetemp.cxx"]
},
"Specifications": {
"Vsource": {
"unit": "V",
"min": 3.3,
"max": 5.0
},
"Supply Current": {
"unit": "mA",
"typ" : 50
},
"Operating Temperature": {
"unit": "°C",
"min": -40,
"max": 125
},
"Accuracy": {
"unit": "+/- °C",
"accuracy": 1.5
}
},
"Platforms": {
"Intel Edison": {
"Notes": ["Might need Grove base shield"]
},
"Arduino 101": {
"Notes": ["Might need Grove base shield"]
}
},
"Urls": {
"Product Pages": ["https://www.seeedstudio.com/Grove-Temperature-Sensor-p-774.html?gclid=Cj0KCQjw5arMBRDzARIsAAqmJexygEDSrIieYoG1C37j3HmOOx7PHjXlPsWxnQo7g1sCctC_VErW2IAaAvIHEALw_wcB", "http://wiki.seeed.cc/Grove-Temperature_Sensor_V1.2/"],
"Datasheets": ["https://github.com/SeeedDocument/Grove-Temperature_Sensor_V1.2/raw/master/res/NCP18WF104F03RC.pdf"],
"Schematics": ["https://github.com/SeeedDocument/Grove-Temperature_Sensor_V1.2/raw/master/res/Grove_-_Temperature_sensor_v1.1.zip"]
}
}
}
}

View File

@ -1,49 +0,0 @@
/*
* Authors: Brendan Le Foll <brendan.le.foll@intel.com>
* Mihai Tudor Panu <mihai.tudor.panu@intel.com>
* Sarah Knepper <sarah.knepper@intel.com>
* Copyright (c) 2014 - 2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <string>
namespace upm {
/**
* @deprecated This library is now deprecated and replaced by individual
* libraries for every sensor.
* @brief Generic Library for Basic Grove Sensors
* @defgroup grove libupm-grove
* @ingroup seeed gpio pwm ainput button led light relay temp touch gsk eak hak
*/
class Grove {
public:
virtual ~Grove() {}
std::string name()
{
return m_name;
}
protected:
std::string m_name;
};
}

View File

@ -1,80 +0,0 @@
/*
* Authors: Brendan Le Foll <brendan.le.foll@intel.com>
* Mihai Tudor Panu <mihai.tudor.panu@intel.com>
* Sarah Knepper <sarah.knepper@intel.com>
* Copyright (c) 2014 - 2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <iostream>
#include <string>
#include <stdexcept>
#include "grovebutton.hpp"
using namespace upm;
GroveButton::GroveButton(unsigned int pin)
{
if ( !(m_gpio = mraa_gpio_init(pin)) ) {
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_gpio_init() failed, invalid pin?");
return;
}
mraa_gpio_dir(m_gpio, MRAA_GPIO_IN);
m_name = "Button Sensor";
}
GroveButton::~GroveButton()
{
mraa_gpio_close(m_gpio);
}
std::string GroveButton::name()
{
return m_name;
}
int GroveButton::value()
{
return mraa_gpio_read(m_gpio);
}
bool GroveButton::isPressed()
{
return (bool) GroveButton::value();
}
void GroveButton::installISR(mraa::Edge level, void (*isr)(void *), void *arg)
{
if (m_isrInstalled)
uninstallISR();
// install our interrupt handler
mraa_gpio_isr(m_gpio, (mraa_gpio_edge_t) level, isr, arg);
m_isrInstalled = true;
}
void GroveButton::uninstallISR()
{
mraa_gpio_isr_exit(m_gpio);
m_isrInstalled = false;
}

View File

@ -1,108 +0,0 @@
/*
* Authors: Brendan Le Foll <brendan.le.foll@intel.com>
* Mihai Tudor Panu <mihai.tudor.panu@intel.com>
* Sarah Knepper <sarah.knepper@intel.com>
* Copyright (c) 2014 - 2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <string>
#include <mraa/gpio.hpp>
#include "grovebase.hpp"
#include <interfaces/iButton.hpp>
namespace upm {
/**
* @deprecated This class is being replaced by the upm-button library and the
* Button class.
* @library grove
* @sensor grovebutton
* @comname Button
* @altname Grove Touch Sensor
* @type button touch
* @man seeed
* @con gpio
* @kit gsk
*
* @brief API for the Grove Button
*
* Basic UPM module for the Grove button
*
* @image html grovebutton.jpg
* @snippet grove-grovebutton.cxx Interesting
*/
class GroveButton: public Grove, virtual public iButton {
public:
/**
* Grove button constructor
*
* @param pin Pin to use
*/
GroveButton(unsigned int pin);
/**
* Grove button destructor
*/
~GroveButton();
/**
* Gets the name of the sensor
*
* @return Name of this sensor
*/
std::string name();
/**
* Gets the value from the GPIO pin
*
* @return Value from the GPIO pin
*/
int value();
/**
* Gets the current button press state.
*
* @returns Button state
*/
virtual bool isPressed();
/**
* Installs an interrupt service routine (ISR) to be called when
* the button is activated or deactivated.
*
* @param fptr Pointer to a function to be called on interrupt
* @param arg Pointer to an object to be supplied as an
* argument to the ISR.
*/
void installISR(mraa::Edge level, void (*isr)(void *), void *arg);
/**
* Uninstalls the previously installed ISR
*
*/
void uninstallISR();
private:
bool m_isrInstalled;
std::string m_name;
mraa_gpio_context m_gpio;
};
}

View File

@ -1,67 +0,0 @@
/*
* Authors: Brendan Le Foll <brendan.le.foll@intel.com>
* Mihai Tudor Panu <mihai.tudor.panu@intel.com>
* Sarah Knepper <sarah.knepper@intel.com>
* Copyright (c) 2014 - 2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <iostream>
#include <string>
#include <stdexcept>
#include "groveled.hpp"
using namespace upm;
GroveLed::GroveLed(int pin)
{
if ( !(m_gpio = mraa_gpio_init(pin)) ) {
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_gpio_init() failed, invalid pin?");
return;
}
mraa_gpio_dir(m_gpio, MRAA_GPIO_OUT);
m_name = "LED Socket";
}
GroveLed::~GroveLed()
{
mraa_gpio_close(m_gpio);
}
mraa_result_t GroveLed::write(int value)
{
if (value >= 1) {
return mraa_gpio_write(m_gpio, 1);
}
return mraa_gpio_write(m_gpio, 0);
}
mraa_result_t GroveLed::on()
{
return write(1);
}
mraa_result_t GroveLed::off()
{
return write(0);
}

View File

@ -1,98 +0,0 @@
/*
* Authors: Brendan Le Foll <brendan.le.foll@intel.com>
* Mihai Tudor Panu <mihai.tudor.panu@intel.com>
* Sarah Knepper <sarah.knepper@intel.com>
* Copyright (c) 2014 - 2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <string>
#include <mraa/gpio.hpp>
#include "grovebase.hpp"
namespace upm {
/**
* @deprecated This class is being replaced by the upm-led library and the
* Led class.
* @library grove
* @sensor groveled
* @comname LED
* @type led
* @man seeed
* @con gpio
* @kit gsk
*
* @brief API for the Grove LED
*
* UPM module for the Grove LED (or other similar light-emitting diodes).
* An LED is a small lightbulb that emits light in
* response to a small current. The longer wire of an LED connects
* to the positive seat (anode); the shorter wire connects to the
* negative seat (cathode). The flat side of the bulb corresponds
* to the cathode, while the rounded side corresponds to the anode.
*
* @image html groveled.jpg
* @snippet grove-groveled.cxx Interesting
* @snippet grove-groveled-multi.cxx Interesting
*/
class GroveLed: public Grove {
public:
/**
* Grove LED constructor
*
* @param pin Pin to use
*/
GroveLed(int pin);
/**
* Grove LED destructor
*/
~GroveLed();
/**
* Turns the LED on or off, depending on the value.
* If the value is positive (greater than or equal
* to 1), the LED is turned on. Otherwise, for 0
* or negative values, the LED is turned off.
*
* @param value Tells the LED to turn on (for values >=1)
* or off (for values <1)
*
* @return 0 if successful, non-zero otherwise
*/
mraa_result_t write(int value);
/**
* Turns the LED off
*
* @return 0 if successful, non-zero otherwise
*/
mraa_result_t off();
/**
* Turns the LED on
*
* @return 0 if successful, non-zero otherwise
*/
mraa_result_t on();
private:
mraa_gpio_context m_gpio;
};
}

View File

@ -1,68 +0,0 @@
/*
* Authors: Brendan Le Foll <brendan.le.foll@intel.com>
* Mihai Tudor Panu <mihai.tudor.panu@intel.com>
* Sarah Knepper <sarah.knepper@intel.com>
* Copyright (c) 2014 - 2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <iostream>
#include <string>
#include <stdexcept>
#include "grovelight.hpp"
#include "math.h"
using namespace upm;
GroveLight::GroveLight(unsigned int pin)
{
if ( !(m_aio = mraa_aio_init(pin)) ) {
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_aio_init() failed, invalid pin?");
return;
}
m_name = "Light Sensor";
}
GroveLight::~GroveLight()
{
mraa_aio_close(m_aio);
}
int GroveLight::value()
{
// rough conversion to lux, using formula from Grove Starter Kit booklet
float a = (float) mraa_aio_read(m_aio);
if (a == -1.0) return -1;
a = 10000.0/pow(((1023.0-a)*10.0/a)*15.0,4.0/3.0);
return (int) round(a);
}
float GroveLight::getLuminance()
{
return value();
}
float GroveLight::raw_value()
{
return (float) mraa_aio_read(m_aio);
}

View File

@ -1,92 +0,0 @@
/*
* Authors: Brendan Le Foll <brendan.le.foll@intel.com>
* Mihai Tudor Panu <mihai.tudor.panu@intel.com>
* Sarah Knepper <sarah.knepper@intel.com>
* Copyright (c) 2014 - 2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <string>
#include <mraa/aio.hpp>
#include <interfaces/iLight.hpp>
#include "grovebase.hpp"
namespace upm {
/**
* @deprecated This class is being replaced by the upm-light library and the
* Light class.
* @library grove
* @sensor grovelight
* @comname Light Sensor
* @type light
* @man seeed
* @con analog
* @kit gsk
*
* @brief API for the Grove Light Sensor
*
* The Grove light sensor detects the intensity of the ambient light.
* As the light intensity of the environment increases, the resistance
* of the sensor decreases. This means the raw value from the
* analog pin is larger in bright light and smaller in the dark.
* An approximate lux value can also be returned.
*
* @image html grovelight.jpg
* @snippet grove-grovelight.cxx Interesting
*/
class GroveLight: public Grove, virtual public iLight {
public:
/**
* Grove analog light sensor constructor
*
* @param pin Analog pin to use
*/
GroveLight(unsigned int pin);
/**
* GroveLight destructor
*/
~GroveLight();
/**
* Gets the raw value from the AIO pin
*
* @return Raw value from the ADC
*/
float raw_value();
/**
* Gets an approximate light value, in lux, from the sensor
*
* @return Normalized light reading in lux
*/
int value();
/**
* Gets an approximate light value, in lux, from the sensor
*
* @return Normalized light reading in lux
*/
virtual float getLuminance();
private:
mraa_aio_context m_aio;
};
}

View File

@ -1,69 +0,0 @@
/*
* Authors: Brendan Le Foll <brendan.le.foll@intel.com>
* Mihai Tudor Panu <mihai.tudor.panu@intel.com>
* Sarah Knepper <sarah.knepper@intel.com>
* Copyright (c) 2014 - 2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <iostream>
#include <string>
#include <stdexcept>
#include "groverelay.hpp"
using namespace upm;
GroveRelay::GroveRelay(unsigned int pin)
{
if ( !(m_gpio = mraa_gpio_init(pin)) ) {
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_gpio_init() failed, invalid pin?");
return;
}
mraa_gpio_dir(m_gpio, MRAA_GPIO_OUT);
m_name = "Relay Switch";
}
GroveRelay::~GroveRelay()
{
mraa_gpio_close(m_gpio);
}
mraa_result_t GroveRelay::on()
{
return mraa_gpio_write(m_gpio, 1);
}
mraa_result_t GroveRelay::off()
{
return mraa_gpio_write(m_gpio, 0);
}
bool GroveRelay::isOn()
{
return mraa_gpio_read(m_gpio) == 1;
}
bool GroveRelay::isOff()
{
return mraa_gpio_read(m_gpio) == 0;
}

View File

@ -1,97 +0,0 @@
/*
* Authors: Brendan Le Foll <brendan.le.foll@intel.com>
* Mihai Tudor Panu <mihai.tudor.panu@intel.com>
* Sarah Knepper <sarah.knepper@intel.com>
* Copyright (c) 2014 - 2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <string>
#include <mraa/gpio.hpp>
#include "grovebase.hpp"
namespace upm {
/**
* @deprecated This class is being replaced by the upm-relay library and the
* Relay class.
* @library grove
* @sensor groverelay
* @comname Relay
* @type relay
* @man seeed
* @con gpio
* @kit gsk eak hak
*
* @brief API for the Grove Relay
*
* UPM module for the Grove relay switch. The Grove relay is a
* digital normally-open switch that uses low voltage or current to
* control a higher voltage and/or higher current. When closed,
* the indicator LED lights up and current is allowed to flow.
*
* @image html groverelay.jpg
* @snippet grove-groverelay.cxx Interesting
*/
class GroveRelay: public Grove {
public:
/**
* Grove relay constructor
*
* @param pin Pin to use
*/
GroveRelay(unsigned int pin);
/**
* Grove relay destructor
*/
~GroveRelay();
/**
* Sets the relay switch to on (closed). This allows current
* to flow and lights up the indicator LED.
*
* @return 0 if successful, non-zero otherwise
*/
mraa_result_t on();
/**
* Sets the relay switch to off (open). This stops current
* from flowing and the indicator LED is not lit.
*
* @return 0 if successful, non-zero otherwise
*/
mraa_result_t off();
/**
* Defines whether the relay switch is closed.
*
* @return True if the switch is on (closed), false otherwise
*/
bool isOn();
/**
* Defines whether the relay switch is open.
*
* @return True if the switch is off (open), false otherwise
*/
bool isOff();
private:
mraa_gpio_context m_gpio;
};
}

View File

@ -1,84 +0,0 @@
/*
* Authors: Brendan Le Foll <brendan.le.foll@intel.com>
* Mihai Tudor Panu <mihai.tudor.panu@intel.com>
* Sarah Knepper <sarah.knepper@intel.com>
* Copyright (c) 2014 - 2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <iostream>
#include <string>
#include <stdexcept>
#include "groverotary.hpp"
#include "math.h"
using namespace upm;
GroveRotary::GroveRotary(unsigned int pin)
{
if ( !(m_aio = mraa_aio_init(pin)) ) {
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_aio_init() failed, invalid pin?");
return;
}
m_name = "Rotary Angle Sensor";
}
GroveRotary::~GroveRotary()
{
mraa_aio_close(m_aio);
}
float GroveRotary::abs_value()
{
return (float) mraa_aio_read(m_aio);
}
float GroveRotary::abs_deg()
{
return GroveRotary::abs_value() * (float) m_max_angle / 1023.0;
}
float GroveRotary::abs_rad()
{
return GroveRotary::abs_deg() * M_PI / 180.0;
}
float GroveRotary::rel_value()
{
return GroveRotary::abs_value() - 512.0;
}
float GroveRotary::rel_deg()
{
return GroveRotary::rel_value() * (float) m_max_angle / 1023.0;
}
float GroveRotary::rel_rad()
{
return GroveRotary::rel_deg() * M_PI / 180.0;
}
float GroveRotary::getAngle()
{
return GroveRotary::abs_deg();
}

View File

@ -1,117 +0,0 @@
/*
* Authors: Brendan Le Foll <brendan.le.foll@intel.com>
* Mihai Tudor Panu <mihai.tudor.panu@intel.com>
* Sarah Knepper <sarah.knepper@intel.com>
* Copyright (c) 2014 - 2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <string>
#include <mraa/aio.hpp>
#include "grovebase.hpp"
#include <interfaces/iAngle.hpp>
namespace upm {
/**
* @deprecated This class is being replaced by the upm-rotary library and the
* Rotary class.
* @library grove
* @sensor groverotary
* @comname Rotary Angle Sensor
* @altname Rotary Potentiometer
* @type ainput
* @man seeed
* @con analog
* @kit gsk
*
* @brief API for the Grove Rotary Angle Sensor (Knob)
*
* Basic UPM module for the Grove rotary angle sensor (knob) on analog. Provides
* a set of functions to read the absolute pin value, degrees or radians, and another set
* to do the same relative to the center of the knob's range.
*
* @image html rotaryencoder.jpg
* @snippet grove-groverotary.cxx Interesting
*/
class GroveRotary: public Grove, virtual public iAngle {
public:
/**
* Grove rotary angle sensor constructor
*
* @param pin Number of the analog pin to use
*/
GroveRotary(unsigned int pin);
/**
* GroveRotary destructor
*/
~GroveRotary();
/**
* Gets the absolute raw value from the AIO pin
*
* @return Unsigned value from the ADC
*/
float abs_value();
/**
* Gets absolute raw degrees from the AIO pin
*
* @return Unsigned degrees from the ADC
*/
float abs_deg();
/**
* Gets absolute raw radians from the AIO pin
*
* @return Unsigned radians from the ADC
*/
float abs_rad();
/**
* Gets the relative value from the AIO pin
*
* @return Signed value from the ADC
*/
float rel_value();
/**
* Gets relative degrees from the AIO pin
*
* @return Signed degrees from the ADC
*/
float rel_deg();
/**
* Gets relative radians from the AIO pin
*
* @return Signed radians from the ADC
*/
float rel_rad();
/**
* Get rotation value as raw degrees from the AIO pin.
*
* @return rotation value.
*/
virtual float getAngle();
private:
mraa_aio_context m_aio;
static const int m_max_angle = 300;
};
}

View File

@ -1,68 +0,0 @@
/*
* Authors: Brendan Le Foll <brendan.le.foll@intel.com>
* Mihai Tudor Panu <mihai.tudor.panu@intel.com>
* Sarah Knepper <sarah.knepper@intel.com>
* Copyright (c) 2014 - 2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <iostream>
#include <string>
#include <stdexcept>
#include "groveslide.hpp"
#include "math.h"
using namespace upm;
GroveSlide::GroveSlide(unsigned int pin, float ref_voltage)
{
if ( !(m_aio = mraa_aio_init(pin)) ) {
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_aio_init() failed, invalid pin?");
return;
}
m_ref_voltage = ref_voltage;
m_name = "Slide Potentiometer";
}
GroveSlide::~GroveSlide()
{
mraa_aio_close(m_aio);
}
float GroveSlide::raw_value()
{
return (float) mraa_aio_read(m_aio);
}
float GroveSlide::voltage_value()
{
// conversion to Volts
float a = GroveSlide::raw_value();
a = m_ref_voltage * a / 1023.0 ;
return a;
}
float GroveSlide::ref_voltage()
{
return m_ref_voltage;
}

View File

@ -1,89 +0,0 @@
/*
* Authors: Brendan Le Foll <brendan.le.foll@intel.com>
* Mihai Tudor Panu <mihai.tudor.panu@intel.com>
* Sarah Knepper <sarah.knepper@intel.com>
* Copyright (c) 2014 - 2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <string>
#include <mraa/aio.hpp>
#include "grovebase.hpp"
namespace upm {
/**
* @deprecated This class is being replaced by the upm-slide library and the
* Slide class.
* @library grove
* @sensor groveslide
* @comname Slide Potentiometer
* @type ainput
* @man seeed
* @con analog
*
* @brief API for the Grove Slide Potentiometer
*
* Basic UPM module for the Grove slide potentiometer on analog that
* returns either a raw value or a scaled voltage value.
*
* @image html slide.jpg
* @snippet grove-groveslide.cxx Interesting
*/
class GroveSlide: public Grove {
public:
/**
* Grove analog slide potentiometer constructor
*
* @param pin Number of the analog pin to use
*
* @param ref_voltage Reference voltage the board is set to, as a floating-point value; default is 5.0V
*/
GroveSlide(unsigned int pin, float ref_voltage = 5.0);
/**
* GroveSlide destructor
*/
~GroveSlide();
/**
* Gets the raw value from the AIO pin
*
* @return Raw value from the ADC
*/
float raw_value();
/**
* Gets the voltage value from the pin
*
* @return Voltage reading based on the reference voltage
*/
float voltage_value();
/**
* Gets the board's reference voltage passed on object initialization
*
* @return Reference voltage the class was set for
*/
float ref_voltage();
private:
mraa_aio_context m_aio;
float m_ref_voltage;
};
}

View File

@ -1,73 +0,0 @@
/*
* Authors: Brendan Le Foll <brendan.le.foll@intel.com>
* Mihai Tudor Panu <mihai.tudor.panu@intel.com>
* Sarah Knepper <sarah.knepper@intel.com>
* Copyright (c) 2014 - 2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <iostream>
#include <string>
#include <stdexcept>
#include "grovetemp.hpp"
#include "math.h"
using namespace upm;
GroveTemp::GroveTemp(unsigned int pin, float scale, int r0, int b)
{
if ( !(m_aio = mraa_aio_init(pin)) ) {
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_aio_init() failed, invalid pin?");
return;
}
m_name = "Temperature Sensor";
m_scale = scale;
m_r0 = r0;
m_b = b;
}
GroveTemp::~GroveTemp()
{
mraa_aio_close(m_aio);
}
int GroveTemp::value ()
{
float a = (float) mraa_aio_read(m_aio);
if (a == -1.0) return -1;
// Apply scale factor after error check
a *= m_scale;
float r = (float)(1023.0-a)*(float)m_r0/a;
float t = 1.0/(log(r/(float)m_r0)/(float)m_b + 1.0/298.15)-273.15;
return (int) round(t);
}
float GroveTemp::getTemperature ()
{
return value();
}
float GroveTemp::raw_value()
{
return (float) mraa_aio_read(m_aio);
}

View File

@ -1,97 +0,0 @@
/*
* Authors: Brendan Le Foll <brendan.le.foll@intel.com>
* Mihai Tudor Panu <mihai.tudor.panu@intel.com>
* Sarah Knepper <sarah.knepper@intel.com>
* Copyright (c) 2014 - 2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <string>
#include <mraa/aio.hpp>
#include "grovebase.hpp"
#include <interfaces/iTemperature.hpp>
namespace upm {
/**
* @deprecated This class is being replaced by the upm-temperature library and
* the Temperature class.
* @library grove
* @sensor grovetemp
* @comname Temperature Sensor
* @type temp
* @man seeed
* @con analog
* @kit gsk
*
* @brief API for the Grove Temperature Sensor
*
* Basic UPM module for the Grove temperature sensor on analog. This sensor
* uses a thermistor to measure ambient temperature. The conversion formula has
* been updated to work with versions 1.1 and 1.2 of the sensor. For the older
* v1.0 sensor you will have to specify R0 and B values when initializing the
* device. The range of this sensor is -40 to 125 C and accuracy is +/- 1.5 C.
*
* @image html grovetemp.jpg
* @snippet grove-grovetemp.cxx Interesting
*/
class GroveTemp: public Grove, virtual public iTemperature {
public:
/**
* Grove analog temperature sensor constructor
*
* @param pin Analog pin to use
* @param scale Scaling factor for raw analog value from the ADC,
* useful for mixed 3.3V/5V boards, default 1.0
* @param r0 zero power resistance, this is 100K (default) for
* v1.1-v1.2 and 10K for v1.0 of the sensor
* @param b thermistor nominal B constant, this is 4275 (default) for
* v1.1-v1.2 and 3975 for v1.0 of the sensor
*/
GroveTemp(unsigned int pin, float scale = 1.0, int r0 = 100000, int b = 4275);
/**
* GroveTemp destructor
*/
~GroveTemp();
/**
* Gets the raw value from the AIO pin
*
* @return Raw value from the ADC
*/
float raw_value();
/**
* Gets the temperature in Celsius from the sensor
*
* @return Normalized temperature in Celsius
*/
int value();
virtual float getTemperature();
private:
mraa_aio_context m_aio;
float m_scale;
int m_r0;
int m_b;
};
}

View File

@ -1,6 +0,0 @@
set (libname "grovecollision")
set (libdescription "Collision Sensor")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
set (module_iface iCollision.hpp)
upm_module_init(mraa)

View File

@ -1,53 +0,0 @@
/*
* Author: Zion Orent <sorent@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string>
#include <stdexcept>
#include "grovecollision.hpp"
using namespace upm;
GroveCollision::GroveCollision(int pin)
{
if ( !(m_gpio = mraa_gpio_init(pin)) )
{
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_gpio_init() failed, invalid pin?");
return;
}
mraa_gpio_dir(m_gpio, MRAA_GPIO_IN);
}
GroveCollision::~GroveCollision()
{
mraa_gpio_close(m_gpio);
}
bool GroveCollision::isColliding()
{
// Collisions cause 0; no collision is 1
return (!(bool)mraa_gpio_read(m_gpio));
}

View File

@ -1,75 +0,0 @@
/*
* Author: Zion Orent <sorent@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <mraa/gpio.h>
#include <interfaces/iCollision.hpp>
namespace upm {
/**
* @deprecated This library is being replaced by libupm-collision
* @brief Grove Collision Sensor
* @defgroup grovecollision libupm-grovecollision
* @ingroup seeed gpio accelerometer
*/
/**
* @deprecated This class is being replaced by Collision
* @library grovecollision
* @sensor grovecollision
* @comname Collision Sensor
* @type accelerometer
* @man seeed
* @con gpio
*
* @brief API for the Grove Collision Sensor
*
* The Grove Collision Sensor can detect whether any
* collision movement or vibration happens.
* It outputs a low pulse signal when vibration is detected.
*
* @image html grovecollision.jpg
* @snippet grovecollision.cxx Interesting
*/
class GroveCollision : virtual public iCollision {
public:
/**
* Grove collision sensor constructor
*
* @param pin Digital pin to use
*/
GroveCollision(int pin);
/**
* GroveCollision destructor
*/
~GroveCollision();
/**
* @return boolean value defining whether something is colliding with sensor
*/
virtual bool isColliding();
private:
mraa_gpio_context m_gpio;
};
}

View File

@ -1,41 +0,0 @@
{
"Library": "grovecollision",
"Description": "API for the Grove Collision Sensor",
"Sensor Class":
{
"GroveCollision":
{
"Name": "Grove Collision Sensor",
"Description": "The Grove Collision Sensor can detect whether any collision movement or vibration happens. It outputs a low pulse signal when vibration is detected.",
"Aliases": ["grovecollision"],
"Categories": ["collision", "deprecated"],
"Connections": ["gpio"],
"Project Type": ["prototyping", "robotics"],
"Manufacturers": ["seeed"],
"Kits": [],
"Image": "grovecollision.jpg",
"Examples":
{
"Java": ["GroveCollision_Example.java"],
"Python": ["grovecollision.py"],
"Node.js": ["grovecollision.js"],
"C++": ["grovecollision.cxx"],
"C": []
},
"Specifications":
{
"Operating Voltage": {"unit": "V", "low": 3.3, "high": 5},
"Operating Current": {"unit": "mA", "max": 2},
"Reaction Point": {"unit": "mg", "typ": 50},
"Off Resistance": {"unit": "MOhms", "min": 30},
"On Resistance": {"unit": "Ohms", "max": 100}
},
"Urls" :
{
"Product Pages": ["https://www.seeedstudio.com/Grove-Collision-Sensor-p-1132.html"],
"Datasheets": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Collision_Sensor/master/res/DataSheet-MVS0608_02-v2_1.pdf", "http://wiki.seeed.cc/Grove-Collision_Sensor/"],
"Schematics": []
}
}
}
}

View File

@ -1,6 +0,0 @@
set (libname "groveehr")
set (libdescription "Ear-clip Heart Rate Sensor")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
set (module_iface iHeartRate.hpp)
upm_module_init(mraa)

View File

@ -1,135 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <iostream>
#include <string>
#include <stdexcept>
#include "groveehr.hpp"
using namespace upm;
using namespace std;
GroveEHR::GroveEHR(int pin)
{
if ( !(m_gpio = mraa_gpio_init(pin)) )
{
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_aio_init() failed, invalid pin?");
return;
}
mraa_gpio_dir(m_gpio, MRAA_GPIO_IN);
initClock();
m_beatCounter = 0;
}
GroveEHR::~GroveEHR()
{
mraa_gpio_close(m_gpio);
}
void GroveEHR::initClock()
{
gettimeofday(&m_startTime, NULL);
}
uint32_t GroveEHR::getMillis()
{
struct timeval elapsed, now;
uint32_t elapse;
// get current time
gettimeofday(&now, NULL);
// compute the delta since m_startTime
if( (elapsed.tv_usec = now.tv_usec - m_startTime.tv_usec) < 0 )
{
elapsed.tv_usec += 1000000;
elapsed.tv_sec = now.tv_sec - m_startTime.tv_sec - 1;
}
else
{
elapsed.tv_sec = now.tv_sec - m_startTime.tv_sec;
}
elapse = (uint32_t)((elapsed.tv_sec * 1000) + (elapsed.tv_usec / 1000));
// never return 0
if (elapse == 0)
elapse = 1;
return elapse;
}
void GroveEHR::clearBeatCounter()
{
m_beatCounter = 0;
}
void GroveEHR::startBeatCounter()
{
// install our interrupt handler
mraa_gpio_isr(m_gpio, MRAA_GPIO_EDGE_RISING,
&beatISR, this);
}
void GroveEHR::stopBeatCounter()
{
// remove the interrupt handler
mraa_gpio_isr_exit(m_gpio);
}
uint32_t GroveEHR::beatCounter()
{
return m_beatCounter;
}
void GroveEHR::beatISR(void *ctx)
{
upm::GroveEHR *This = (upm::GroveEHR *)ctx;
This->m_beatCounter++;
}
int GroveEHR::heartRate()
{
uint32_t millis = getMillis();
uint32_t beats = beatCounter();
float heartRate = 0;
// wait at least 5 seconds before attempting to compute the
// heart rate
if (millis > 5000)
{
heartRate = (float(beats) / (float(millis) / 1000.0)) * 60.0;
}
return int(heartRate);
}
int GroveEHR::getHeartRate()
{
return GroveEHR::heartRate();
}

View File

@ -1,134 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <string>
#include <stdint.h>
#include <sys/time.h>
#include <mraa/gpio.h>
#include <interfaces/iHeartRate.hpp>
namespace upm {
/**
* @deprecated This library is being replaced by libupm-ehr
* @brief Grove Ear-clip Heart Rate Sensor
* @defgroup groveehr libupm-groveehr
* @ingroup seeed gpio medical
*/
/**
* @deprecated This class is being replaced by EHR
* @library groveehr
* @sensor groveehr
* @comname Ear-clip Heart Rate Sensor
* @type medical
* @man seeed
* @con gpio
*
* @brief API for the Grove Ear-clip Heart Rate Sensor
*
* UPM module for the Grove ear-clip heart rate sensor. It is used to measure your
* heart rate.
*
* @image html groveehr.jpg
* @snippet groveehr.cxx Interesting
*/
class GroveEHR : virtual public iHeartRate {
public:
/**
* GroveEHR constructor
*
* @param pin Digital pin to use
*/
GroveEHR(int pin);
/**
* GroveEHR destructor
*/
~GroveEHR();
/**
* Returns the time of milliseconds elapsed since initClock()
* was last called.
*
* @return Elapsed milliseconds
*/
uint32_t getMillis();
/**
* Resets the clock
*
*/
void initClock();
/**
* Resets the beat counter to 0. The beat counter should be
* stopped via stopBeatCounter() prior to calling this function.
*
*/
void clearBeatCounter();
/**
* Starts the beat counter
*
*/
void startBeatCounter();
/**
* Stops the beat counter
*
*/
void stopBeatCounter();
/**
* Gets the beat Counter
*
* @return Beat counter
*/
uint32_t beatCounter();
/**
* Computes the heart rate
*
* @return Computed heart rate
*/
int heartRate();
/**
* Retrieve the computed heart rate
*
* @return Computed heart rate
*/
virtual int getHeartRate();
private:
/**
* Beat interrupt service routine (ISR)
*
*/
static void beatISR(void *ctx);
volatile uint32_t m_beatCounter;
struct timeval m_startTime;
mraa_gpio_context m_gpio;
};
}

View File

@ -1,26 +0,0 @@
#ifdef SWIGPYTHON
%module (package="upm") ehr
#endif
%import "interfaces/interfaces.i"
%include "../common_top.i"
/* BEGIN Java syntax ------------------------------------------------------- */
#ifdef SWIGJAVA
%typemap(javaimports) SWIGTYPE %{
import upm_interfaces.*;
%}
%ignore beatISR;
JAVA_JNI_LOADLIBRARY(javaupm_groveehr)
#endif
/* END Java syntax */
/* BEGIN Common SWIG syntax ------------------------------------------------- */
%{
#include "groveehr.hpp"
%}
%include "groveehr.hpp"
/* END Common SWIG syntax */

View File

@ -1,40 +0,0 @@
{
"Library": "groveehr",
"Description": "API for the Ear-clip Heart Rate Sensor",
"Sensor Class":
{
"GroveEHR":
{
"Name": "Ear-clip Heart Rate Sensor",
"Description": "UPM module for the ear-clip heart rate sensor. It is used to measure your heart rate.",
"Aliases": ["groveehr"],
"Categories": ["heartrate", "deprecated"],
"Connections": ["gpio"],
"Project Type": ["medical", "wearables", "prototyping"],
"Manufacturers": ["seeed"],
"Kits": [],
"Image": "groveehr.jpg",
"Examples":
{
"Java": ["GroveEHR_Example.java"],
"Python": ["groveehr.py"],
"Node.js": ["groveehr.js"],
"C++": ["groveehr.cxx"],
"C": []
},
"Specifications":
{
"Operating Voltage": {"unit": "V", "low": 3, "high": 5},
"Operating Current": {"unit": "mA", "typ": 6.5},
"Measurement Range": {"unit": "bpm", "min": 30}
},
"Urls" :
{
"Product Pages": ["https://www.seeedstudio.com/Grove-Ear-clip-Heart-Rate-Sensor-p-1116.html"],
"Datasheets": ["http://wiki.seeedstudio.com/wiki/Grove_-_Heart_rate_ear_clip_kit"],
"Schematics": []
}
}
}
}

View File

@ -1,5 +0,0 @@
set (libname "groveeldriver")
set (libdescription "Electroluminescent (EL) Driver")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
upm_module_init(mraa)

View File

@ -1,62 +0,0 @@
/*
* Author: Zion Orent <sorent@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string>
#include <stdexcept>
#include "groveeldriver.hpp"
using namespace upm;
GroveElDriver::GroveElDriver(int pin)
{
if ( !(m_gpio = mraa_gpio_init(pin)) )
{
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_gpio_init() failed, invalid pin?");
return;
}
mraa_gpio_dir(m_gpio, MRAA_GPIO_OUT);
}
GroveElDriver::~GroveElDriver()
{
mraa_gpio_close(m_gpio);
}
void GroveElDriver::on()
{
mraa_result_t error = MRAA_SUCCESS;
error = mraa_gpio_write (m_gpio, HIGH);
if (error != MRAA_SUCCESS)
mraa_result_print(error);
}
void GroveElDriver::off()
{
mraa_result_t error = MRAA_SUCCESS;
error = mraa_gpio_write (m_gpio, LOW);
if (error != MRAA_SUCCESS)
mraa_result_print(error);
}

View File

@ -1,80 +0,0 @@
/*
* Author: Zion Orent <sorent@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <mraa/gpio.h>
#define HIGH 1
#define LOW 0
namespace upm {
/**
* @deprecated This library is being replaced by libupm-eldriver
* @brief Grove EL Driver Module
* @defgroup groveeldriver libupm-groveeldriver
* @ingroup seeed gpio electric
*/
/**
* @deprecated This class is being replaced by ElDriver
* @library groveeldriver
* @sensor groveeldriver
* @comname Electroluminescent (EL) Driver
* @type electric
* @man seeed
* @con gpio
*
* @brief API for the Grove EL Driver Module
*
* The Grove EL Driver allows you to easily light up an
* EL wire with just one single Grove cable.
*
* @image html groveeldriver.jpg
* @snippet groveeldriver.cxx Interesting
*/
class GroveElDriver {
public:
/**
* Grove EL Driver constructor
*
* @param pin Digital pin to use
*/
GroveElDriver(int pin);
/**
* Grove EL Driver destructor
*/
~GroveElDriver();
/**
* Turns the EL wire on
*/
void on();
/**
* Turns the EL wire off
*/
void off();
private:
mraa_gpio_context m_gpio;
};
}

View File

@ -1,40 +0,0 @@
{
"Library": "groveeldriver",
"Description": "API for the Grove EL Driver Module",
"Sensor Class":
{
"GroveElDriver":
{
"Name": "Grove Electroluminescent Wire (EL) Driver",
"Description": "The Grove EL Driver allows you to easily light up an EL wire with just one single cable.",
"Aliases": ["groveeldriver"],
"Categories": ["lighting", "deprecated"],
"Connections": ["gpio"],
"Project Type": ["prototyping", "commercial", "wearables"],
"Manufacturers": ["seeed"],
"Kits": [],
"Image": "groveeldriver.jpg",
"Examples":
{
"Java": [],
"Python": ["groveeldriver.py"],
"Node.js": ["groveeldriver.js"],
"C++": ["groveeldriver.cxx"],
"C": []
},
"Specifications":
{
"Operating Voltage": {"unit": "V", "low": 3.3, "high": 5},
"Operating Current": {"unit": "mA", "max": 300},
"Supported EL Capacitance": {"unit": "nF", "max": 15}
},
"Urls" :
{
"Product Pages": ["https://www.seeedstudio.com/Grove-EL-Driver-p-2269.html"],
"Datasheets": ["http://wiki.seeed.cc/Grove-EL_Driver/"],
"Schematics": ["https://raw.githubusercontent.com/SeeedDocument/Grove-EL_Driver/master/res/Grove-EL_Driver_v1.0.pdf"]
}
}
}
}

View File

@ -1,6 +0,0 @@
set (libname "groveelectromagnet")
set (libdescription "Electromagnet")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
set (module_iface iElectromagnet.hpp)
upm_module_init(mraa)

View File

@ -1,62 +0,0 @@
/*
* Author: Zion Orent <sorent@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string>
#include <stdexcept>
#include "groveelectromagnet.hpp"
using namespace upm;
GroveElectromagnet::GroveElectromagnet(int pin)
{
if ( !(m_gpio = mraa_gpio_init(pin)) )
{
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_gpio_init() failed, invalid pin?");
return;
}
mraa_gpio_dir(m_gpio, MRAA_GPIO_OUT);
}
GroveElectromagnet::~GroveElectromagnet()
{
mraa_gpio_close(m_gpio);
}
void GroveElectromagnet::on()
{
mraa_result_t error = MRAA_SUCCESS;
error = mraa_gpio_write (m_gpio, HIGH);
if (error != MRAA_SUCCESS)
mraa_result_print(error);
}
void GroveElectromagnet::off()
{
mraa_result_t error = MRAA_SUCCESS;
error = mraa_gpio_write (m_gpio, LOW);
if (error != MRAA_SUCCESS)
mraa_result_print(error);
}

View File

@ -1,80 +0,0 @@
/*
* Author: Zion Orent <sorent@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <mraa/gpio.h>
#include <interfaces/iElectromagnet.hpp>
#define HIGH 1
#define LOW 0
namespace upm {
/**
* @deprecated This library is being replaced by libupm-electromagnet
* @brief Grove Electromagnet Library
* @defgroup groveelectromagnet libupm-groveelectromagnet
* @ingroup seeed gpio electric
*/
/**
* @deprecated This class is being replaced by Electromagnet
* @library groveelectromagnet
* @sensor groveelectromagnet
* @comname Electromagnet
* @type electric
* @man seeed
* @con gpio
*
* @brief API for the Grove Electromagnet
*
* The Grove Electromagnet can hold up to 1 kg (approximately 2.2 lbs)
*
* @image html groveelectromagnet.jpg
* @snippet groveelectromagnet.cxx Interesting
*/
class GroveElectromagnet : virtual public iElectromagnet {
public:
/**
* Grove Electromagnet constructor
*
* @param pin Digital pin to use
*/
GroveElectromagnet(int pin);
/**
* Grove Electromagnet destructor
*/
~GroveElectromagnet();
/**
* Turns the magnet on
*/
virtual void on();
/**
* Turns the magnet off
*/
virtual void off();
private:
mraa_gpio_context m_gpio;
};
}

View File

@ -1,41 +0,0 @@
{
"Library": "groveelectromagnet",
"Description": "Grove Electromagnet Library",
"Sensor Class":
{
"GroveElectromagnet":
{
"Name": "API for the Grove Electromagnet",
"Description": "The Grove Electromagnet can hold up to 1 kg (approximately 2.2 lbs)",
"Aliases": ["groveelectromagnet"],
"Categories": ["electric", "magnetic", "deprecated"],
"Connections": ["gpio"],
"Project Type": ["prototyping"],
"Manufacturers": ["seeed"],
"Kits": [],
"Image": "groveelectromagnet.jpg",
"Examples":
{
"Java": [],
"Python": ["groveelectromagnet.py"],
"Node.js": ["groveelectromagnet.js"],
"C++": ["groveelectromagnet.cxx"],
"C": []
},
"Specifications":
{
"Operating Voltage": {"unit": "V", "typ": 5},
"Operating Current": {"unit": "mA", "typ": 400},
"Standby Current": {"unit": "uA", "typ": 200},
"Max Load Weight": {"unit": "kgs", "typ": 1}
},
"Urls" :
{
"Product Pages": ["https://www.seeedstudio.com/Grove-Electromagnet-p-1820.html"],
"Datasheets": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Electromagnet/master/res/ZYE1-P20-15.pdf", "http://wiki.seeed.cc/Grove-Electromagnet/"],
"Schematics": []
}
}
}
}

View File

@ -1,6 +0,0 @@
set (libname "groveemg")
set (libdescription "Electromyography (EMG) Sensor")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
set (module_iface iEmg.hpp)
upm_module_init(mraa)

View File

@ -1,88 +0,0 @@
/*
* Author: Zion Orent <zorent@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <iostream>
#include <stdexcept>
#include <string>
#include "groveemg.hpp"
using namespace upm;
using namespace std;
GroveEMG::GroveEMG(int pin)
{
if (!(m_aio = mraa_aio_init(pin))) {
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_aio_init() failed, invalid pin?");
return;
}
}
GroveEMG::~GroveEMG()
{
mraa_aio_close(m_aio);
}
void
GroveEMG::calibrate()
{
int val, sum = 0;
for (int i = 0; i < 1100; i++) {
val = mraa_aio_read(m_aio);
if (val != -1)
throw std::runtime_error(std::string(__FUNCTION__) + ": Failed to do an aio read.");
sum += val;
usleep(1000);
}
sum /= 1100;
cout << "Static analog data = " << sum << endl;
}
int
GroveEMG::value()
{
int val = mraa_aio_read(m_aio);
return val;
}
float
GroveEMG::getVolts()
{
float val = mraa_aio_read_float(m_aio);
if (val < 0)
return val;
/* Apply raw scale */
val *= this->m_scale;
/* Scale to aRef */
val *= this->m_aRef;
/* Apply the offset in volts */
val += this->m_offset;
return val;
}

View File

@ -1,91 +0,0 @@
/*
* Author: Zion Orent <zorent@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <string>
#include <mraa/aio.h>
#include "interfaces/iEmg.hpp"
namespace upm {
/**
* @deprecated This library is being replaced by libupm-emg
* @brief Grove EMG Muscle Signal Reader
* @defgroup groveemg libupm-groveemg
* @ingroup seeed analog electric
*/
/**
* @deprecated This class is being replaced by EMG
* @library groveemg
* @sensor groveemg
* @comname Electromyography (EMG) Sensor
* @type electric
* @man seeed
* @con analog
*
* @brief API for the Grove EMG Muscle Signal Reader
*
* Grove EMG muscle signal reader gathers small muscle signals,
* then processes them, and returns the result
*
* @image html emg.jpg
* @snippet groveemg.cxx Interesting
*/
class GroveEMG : virtual public iEmg {
public:
/**
* Grove EMG reader constructor
*
* @param pin Analog pin to use
*/
GroveEMG(int pin);
/**
* GroveEMG destructor
*/
~GroveEMG();
/**
* Calibrates the Grove EMG reader
*/
virtual void calibrate();
/**
* Measures muscle signals from the reader
*
* @return Muscle output as analog voltage
*/
virtual int value();
virtual float getVolts();
private:
mraa_aio_context m_aio;
/* Analog voltage reference */
float m_aRef = 5.0;
/* Scale */
float m_scale = 1.0;
/* Offset in sensor units */
float m_offset = 0.0;
};
}

View File

@ -1,37 +0,0 @@
{
"Library": "groveemg",
"Description": "Grove EMG Muscle Signal Reader Library",
"Sensor Class":
{
"GroveEMG":
{
"Name": "Grove Electromyography (EMG) Sensor",
"Description": "Grove EMG muscle signal reader gathers small muscle signals, then processes them, and returns the result.",
"Aliases": ["groveemg"],
"Categories": ["electromyography", "medical", "deprecated"],
"Connections": ["analog"],
"Project Type": ["wearables", "computer interfacing", "prototyping"],
"Manufacturers": ["seeed"],
"Kits": [],
"Examples":
{
"Java": ["GroveEmg_Example.java"],
"Python": ["groveemg.py"],
"Node.js": ["groveemg.js"],
"C++": ["groveemg.cxx"],
"C": []
},
"Specifications":
{
"Operating Voltage": {"unit": "V", "low": 3.3, "high": 5}
},
"Urls" :
{
"Product Pages": ["https://www.seeedstudio.com/Grove-EMG-Detector-p-1737.html"],
"Datasheets": ["http://wiki.seeed.cc/Grove-EMG_Detector/"],
"Schematics": ["https://raw.githubusercontent.com/SeeedDocument/Grove-EMG_Detector/master/res/Grove-EMG_Sensor_v1.1_SCH.pdf"]
}
}
}
}

View File

@ -1,5 +0,0 @@
set (libname "grovegprs")
set (libdescription "GPRS Module")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
upm_module_init(mraa)

View File

@ -1,78 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <iostream>
#include "grovegprs.hpp"
using namespace upm;
using namespace std;
GroveGPRS::GroveGPRS(int uart) :
m_uart(uart)
{
}
GroveGPRS::~GroveGPRS()
{
}
bool GroveGPRS::dataAvailable(unsigned int millis)
{
return m_uart.dataAvailable(millis);
}
int GroveGPRS::readData(char *buffer, unsigned int len)
{
return m_uart.read(buffer, len);
}
std::string GroveGPRS::readDataStr(int len)
{
return m_uart.readStr(len);
}
int GroveGPRS::writeData(char *buffer, unsigned int len)
{
m_uart.flush();
return m_uart.write(buffer, len);
}
int GroveGPRS::writeDataStr(std::string data)
{
m_uart.flush();
return m_uart.writeStr(data);
}
int GroveGPRS::setBaudRate(int baud)
{
int ret_code = m_uart.setBaudRate(baud);
if (ret_code != mraa::SUCCESS) {
return ret_code;
} else {
return 0;
}
//return m_uart.setBaudRate(baud);
}

View File

@ -1,156 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Thanks to Adafruit for supplying a google translated version of the
* Chinese datasheet and some clues in their code.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <string>
#include <iostream>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <mraa/common.hpp>
#include <mraa/uart.hpp>
#define GROVEGPRS_DEFAULT_UART 0
namespace upm {
/**
* @deprecated This library is being replaced by libupm-gprs
* @brief Grove GPRS Module
* @defgroup grovegprs libupm-grovegprs
* @ingroup seeed uart wifi
*/
/**
* @deprecated This class is being replaced by GPRS
* @library grovegprs
* @sensor grovegprs
* @comname GPRS Module
* @type wifi
* @man seeed
* @con uart
* @web http://www.seeedstudio.com/wiki/GPRS_Shield_V2.0
*
* @brief API for the Grove GPRS Module
*
* The driver was tested with the Grove GPRS Module, V2. It's a
* GSM GPRS module based on the SIM900. This module uses a
* standard 'AT' command set. See the datasheet for a full list
* of available commands and their possible responses:
*
* http://www.seeedstudio.com/wiki/images/7/72/AT_Commands_v1.11.pdf
*
* It is connected via a UART at 19200 baud.
*
* @image html gprs.jpg
* @snippet grovegprs.cxx Interesting
*/
class GroveGPRS {
public:
/**
* GroveGPRS object constructor
*
* @param uart Default UART to use (0 or 1). Default is 0.
*/
GroveGPRS(int uart=GROVEGPRS_DEFAULT_UART);
/**
* GroveGPRS object destructor
*/
~GroveGPRS();
/**
* Checks to see if there is data available for reading
*
* @param millis Number of milliseconds to wait; 0 means no waiting
* @return true if there is data available for reading
*/
bool dataAvailable(unsigned int millis);
/**
* Reads any available data into a user-supplied buffer. Note: the
* call blocks until data is available for reading. Use
* dataAvailable() to determine whether there is data available
* beforehand, to avoid blocking.
*
* @param buffer Buffer to hold the data read
* @param len Length of the buffer
* @return Number of bytes read
*/
int readData(char *buffer, unsigned int len);
/**
* Reads any available data and returns it in a std::string. Note:
* the call blocks until data is available for reading. Use
* dataAvailable() to determine whether there is data available
* beforehand, to avoid blocking.
*
* @param len Maximum length of the data to be returned
* @return Number of bytes read
*/
std::string readDataStr(int len);
/**
* Writes the data in the buffer to the device. If you are
* writing a command, be sure to terminate it with a carriage
* return (\r)
*
* @param buffer Buffer to hold the data to write
* @param len Length of the buffer
* @return Number of bytes written
*/
int writeData(char *buffer, unsigned len);
/**
* Writes the std:string data to the device. If you are writing a
* command, be sure to terminate it with a carriage return (\r)
*
* @param data Buffer to write to the device
* @return Number of bytes written
*/
int writeDataStr(std::string data);
/**
* Sets the baud rate for the device. The default is 19200.
*
* @param baud Desired baud rate.
* @return true if successful
*/
int setBaudRate(int baud=19200);
protected:
mraa::Uart m_uart;
private:
};
}

View File

@ -1,16 +0,0 @@
%include "../common_top.i"
/* BEGIN Java syntax ------------------------------------------------------- */
#ifdef SWIGJAVA
JAVA_JNI_LOADLIBRARY(javaupm_grovegprs)
#endif
/* END Java syntax */
/* BEGIN Common SWIG syntax ------------------------------------------------- */
%include "carrays.i"
%{
#include "grovegprs.hpp"
%}
%include "grovegprs.hpp"
%array_class(char, charArray);
/* END Common SWIG syntax */

View File

@ -1,40 +0,0 @@
{
"Library": "grovegprs",
"Description": "API for the Grove GPRS Module",
"Sensor Class":
{
"GroveGPRS":
{
"Name": "Grove General Packet Radio Service (GPRS) Module",
"Description": "The driver was tested with the Grove GPRS Module, V2. It's a GSM GPRS module based on the SIM900. This module uses a standard 'AT' command set. See the datasheet for a full list of available commands and their possible responses.",
"Aliases": ["grovegprs"],
"Categories": ["wireless"],
"Connections": ["uart"],
"Project Type": ["prototyping", "wireless"],
"Manufacturers": ["seeed"],
"Kits": [],
"Image": "grovegprs.jpg",
"Examples":
{
"Java": [],
"Python": ["grovegprs.py"],
"Node.js": ["grovegprs.js"],
"C++": ["grovegprs.cxx"],
"C": []
},
"Specifications":
{
"Input Voltage (5v Pin)": {"unit": "V", "Typ": 5},
"Input Voltage (Vin Pin)": {"unit": "V", "low": 6.5, "high": 12},
"Power Consumption": {"unit": "mA", "low": 1.5},
"Operating Temperature": {"unit": "degC", "low": -40, "high": 85}
},
"Urls" :
{
"Product Pages": ["https://www.seeedstudio.com/GPRS-Shield-V3.0-p-2333.html"],
"Datasheets": ["http://www.seeedstudio.com/document/SIM900datasheeet.zip", "http://wiki.seeedstudio.com/wiki/GPRS_Shield_V3.0", "http://www.seeedstudio.com/wiki/images/7/72/AT_Commands_v1.11.pdf", "http://garden.seeedstudio.com/images/a/a8/SIM900_AT_Command_Manual_V1.03.pdf", "http://garden.seeedstudio.com/images/a/a0/SIM900_ATC_V1_00.pdf"],
"Schematics": ["http://www.seeedstudio.com/wiki/File:GPRS_Shield_v3.0.pdf"]
}
}
}
}

View File

@ -1,6 +0,0 @@
set (libname "grovegsr")
set (libdescription "Galvanic Skin Response (GSR) Sensor")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
set (module_iface iEC.hpp)
upm_module_init(mraa)

View File

@ -1,75 +0,0 @@
/*
* Author: Zion Orent <zorent@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <iostream>
#include <string>
#include <stdexcept>
#include "grovegsr.hpp"
using namespace upm;
using namespace std;
GroveGSR::GroveGSR(int pin)
{
if ( !(m_aio = mraa_aio_init(pin)) )
{
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_aio_init() failed, invalid pin?");
return;
}
}
GroveGSR::~GroveGSR()
{
mraa_aio_close(m_aio);
}
void GroveGSR::calibrate()
{
sleep(1);
int val, threshold, sum = 0;
for(int i=0; i<500; i++)
{
val = mraa_aio_read(m_aio);
if (val != -1) throw std::runtime_error(std::string(__FUNCTION__) +
": Failed to do an aio read.");
sum += val;
usleep(5000);
}
threshold = sum / 500;
cout << "Threshold = " << threshold << endl;
}
int GroveGSR::value()
{
int val = mraa_aio_read(m_aio);
return val;
}
float GroveGSR::getECValue()
{
return (float) GroveGSR::value();
}

View File

@ -1,92 +0,0 @@
/*
* Author: Zion Orent <zorent@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <string>
#include <mraa/aio.h>
#include <interfaces/iEC.hpp>
namespace upm {
/**
* @deprecated This library is being replaced by libupm-gsr
* @brief Grove GSR Galvanic Skin Response Sensor
* @defgroup grovegsr libupm-grovegsr
* @ingroup seeed analog electric
*/
/**
* @deprecated This class is being replaced by GSR
* @library grovegsr
* @sensor grovegsr
* @comname Galvanic Skin Response (GSR) Sensor
* @type electric
* @man seeed
* @con analog
*
* @brief API for the Grove GSR Galvanic Skin Response Sensor
*
* Measures the electrical conductance of skin
* to measure strong emotional reactions.
* In other words, it measures sweat on your fingers
* as an indicator of strong emotional reactions.
*
* @image html gsr.jpg
* @snippet grovegsr.cxx Interesting
*/
class GroveGSR : virtual public iEC {
public:
/**
* Grove GSR sensor constructor
*
* @param pin Analog pin to use
*/
GroveGSR(int pin);
/**
* GroveGSR destructor
*/
~GroveGSR();
/**
* Calibrates the Grove GSR sensor
*/
void calibrate();
/**
* Gets the electrical conductance of the skin from the sensor
*
* @return Electrical conductance of the skin
*/
int value();
/**
* Gets the electrical conductance of the skin from the sensor
*
* @return Electrical conductance of the skin
*/
virtual float getECValue();
private:
mraa_aio_context m_aio;
};
}

View File

@ -1,38 +0,0 @@
{
"Library": "grovegsr",
"Description": "API for the Grove GSR Galvanic Skin Response Sensor",
"Sensor Class":
{
"GroveGSR":
{
"Name": "Galvanic Skin Response (GSR) Sensor",
"Description": "Measures the electrical conductance of skin to measure strong emotional reactions. In other words, it measures sweat on your fingers as an indicator of strong emotional reactions.",
"Aliases": ["grovegsr"],
"Categories": ["skinresponse"],
"Connections": ["analog"],
"Project Type": ["medical", "interface", "wearables", "prototyping"],
"Manufacturers": ["seeed"],
"Kits": [],
"Examples":
{
"Java": ["GroveGsr_Example.java"],
"Python": ["grovegsr.py"],
"Node.js": ["grovegsr.js"],
"C++": ["grovegsr.cxx"],
"C": []
},
"Specifications":
{
"Operating Voltage": {"unit": "V", "low": 3.3, "high": 5},
"Operating Current": {"unit": "mA", "low": 0.7, "high": 3},
"Operating Temperature": {"unit": "degC", "min": 0, "max": 70}
},
"Urls" :
{
"Product Pages": ["https://www.seeedstudio.com/Grove-GSR-sensor-p-1614.html"],
"Datasheets": ["http://wiki.seeed.cc/Grove-GSR_Sensor/", "file:///C:/Users/Malachai/Downloads/Lm324.pdf"],
"Schematics": ["https://github.com/SeeedDocument/Grove-GSR_Sensor/raw/master/res/Grove%20-%20GSR_v1.2_SCH.pdf", "https://github.com/SeeedDocument/Grove-GSR_Sensor/raw/master/res/Grove%20-%20GSR%20v1.0%20SCH.pdf"]
}
}
}
}

View File

@ -1,6 +0,0 @@
set (libname "grovelinefinder")
set (libdescription "Line Finder")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
set (module_iface iLineFinder.hpp)
upm_module_init(mraa)

View File

@ -1,59 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <iostream>
#include <string>
#include <stdexcept>
#include "grovelinefinder.hpp"
using namespace upm;
using namespace std;
GroveLineFinder::GroveLineFinder(int pin)
{
if ( !(m_gpio = mraa_gpio_init(pin)) )
{
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_gpio_init() failed, invalid pin?");
return;
}
mraa_gpio_dir(m_gpio, MRAA_GPIO_IN);
}
GroveLineFinder::~GroveLineFinder()
{
mraa_gpio_close(m_gpio);
}
bool GroveLineFinder::whiteDetected()
{
return (!mraa_gpio_read(m_gpio) ? true : false);
}
bool GroveLineFinder::blackDetected()
{
return (mraa_gpio_read(m_gpio) ? true : false);
}

View File

@ -1,85 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <string>
#include <mraa/gpio.h>
#include <interfaces/iLineFinder.hpp>
namespace upm {
/**
* @deprecated This library is being replaced by libupm-linefinder
* @brief Grove Line Finder Sensor
* @defgroup grovelinefinder libupm-grovelinefinder
* @ingroup seeed gpio color robok
*/
/**
* @deprecated This class is being replaced by LineFinder
* @library grovelinefinder
* @sensor grovelinefinder
* @comname Line Finder
* @type color
* @man seeed
* @con gpio
* @kit robok
*
* @brief API for the Grove Line Finder Sensor
*
* UPM module for the Grove Line Finder sensor. It outputs a
* digital signal indicating whether it is detecting black on a
* white background, or white on a black background.
*
* @image html grovelinefinder.jpg
* @snippet grovelinefinder.cxx Interesting
*/
class GroveLineFinder : virtual public iLineFinder {
public:
/**
* Grove Line Finder digital sensor constructor
*
* @param pin Digital pin to use
*/
GroveLineFinder(int pin);
/**
* GroveLineFinder destructor
*/
~GroveLineFinder();
/**
* Determines whether white has been detected
*
* @return True if white is detected
*/
virtual bool whiteDetected();
/**
* Determines whether black has been detected
*
* @return True if black is detected
*/
virtual bool blackDetected();
private:
mraa_gpio_context m_gpio;
};
}

View File

@ -1,40 +0,0 @@
{
"Library": "grovelinefinder",
"Description": "Grove Line Finder Sensor Library",
"Sensor Class":
{
"GroveLineFinder":
{
"Name": "Infrared (IR) Based Line Finder",
"Description": "UPM module for the Line Finder sensor. It outputs a digital signal indicating whether it is detecting black on a white background, or white on a black background.",
"Aliases": ["grovelinefinder"],
"Categories": ["grovelinefinder"],
"Connections": ["gpio"],
"Project Type": ["robotics", "prototyping"],
"Manufacturers": ["seeed", "dfrobot"],
"Kits": ["robok"],
"Image": "grovelinefinder.jpg",
"Examples":
{
"Java": ["GroveLineFinder_Example.java"],
"Python": ["grovelinefinder.py"],
"Node.js": ["grovelinefinder.js"],
"C++": ["grovelinefinder.cxx"],
"C": []
},
"Specifications":
{
"Operating Voltage": {"unit": "V", "low": 2.7, "high": 5.5},
"Operating Current": {"unit": "uA", "typ": 210},
"Operating Temperature": {"unit": "degC", "low": -40, "high": 125}
},
"Urls" :
{
"Product Pages": ["https://www.seeedstudio.com/Grove-Line-Finder-v1.1-p-2712.html"],
"Datasheets": ["file:///C:/Users/Malachai/Downloads/Lmv358.pdf", "http://wiki.seeed.cc/Grove-Line_Finder/"],
"Schematics": ["https://easyeda.com/Seeed/Grove_Line_Finder_v1_1-dfc99c72325e41ff93a451882fd2e143"]
}
}
}
}

View File

@ -1,5 +0,0 @@
set (libname "grovemd")
set (libdescription "I2C Motor Driver")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
upm_module_init(mraa)

View File

@ -1,244 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <unistd.h>
#include <iostream>
#include <string>
#include <stdexcept>
#include "grovemd.hpp"
using namespace upm;
using namespace std;
GroveMD::GroveMD(int bus, uint8_t address) :
m_i2c(bus)
{
m_addr = address;
// this board *requires* 100Khz i2c bus only
mraa::Result rv;
if ( (rv = m_i2c.frequency(mraa::I2C_STD)) != mraa::SUCCESS )
{
throw std::invalid_argument(std::string(__FUNCTION__) +
": I2c.frequency(I2C_STD) failed");
return;
}
if (m_i2c.address(m_addr))
{
throw std::runtime_error(std::string(__FUNCTION__) +
": I2c.address() failed");
return;
}
initClock();
// default to mode1 stepper operation, 200 steps per rev.
configStepper(200, STEP_MODE1);
}
GroveMD::~GroveMD()
{
setMotorSpeeds(0, 0);
writePacket(SET_DIRECTION, 0, GROVEMD_NOOP);
}
bool GroveMD::writePacket(REG_T reg, uint8_t data1, uint8_t data2)
{
uint8_t buf[3];
buf[0] = reg;
buf[1] = data1;
buf[2] = data2;
if ( m_i2c.write(buf, 3) != mraa::SUCCESS )
{
throw std::runtime_error(std::string(__FUNCTION__) +
": I2c.write() failed");
return false;
}
// This sleep appears to be required. Without it, writes randomly
// fail (no ACK received). This happens most often on the SET_SPEED
// packet. I am guessing that there is a timing problem and/or bug
// in the motor driver's firmware.
usleep(100);
return true;
}
bool GroveMD::setMotorSpeeds(uint8_t speedA, uint8_t speedB)
{
return writePacket(SET_SPEED, speedA, speedB);
}
bool GroveMD::setPWMFrequencyPrescale(uint8_t freq)
{
return writePacket(SET_PWM_FREQ, freq, GROVEMD_NOOP);
}
bool GroveMD::setMotorDirections(DC_DIRECTION_T dirA, DC_DIRECTION_T dirB)
{
uint8_t dir = ((dirB & 0x03) << 2) | (dirA & 0x03);
return writePacket(SET_DIRECTION, dir, GROVEMD_NOOP);
}
bool GroveMD::enableStepper(STEP_DIRECTION_T dir, uint8_t speed)
{
// If mode 2, send the command and return immediately
if (m_stepMode == STEP_MODE2)
return writePacket(STEPPER_ENABLE, dir, speed);
// otherwise, mode 1, setup the basics and start stepping.
m_stepDelay = 60 * 1000 / m_stepsPerRev / speed;
m_stepDirection = ((dir == STEP_DIR_CW) ? 1 : -1);
// seeed says speed should always be 255,255 for stepper operation
setMotorSpeeds(255, 255);
while (m_totalSteps > 0)
{
if (getMillis() >= m_stepDelay)
{
// reset the clock
initClock();
m_currentStep += m_stepDirection;
if (m_stepDirection == 1)
{
if (m_currentStep >= m_stepsPerRev)
m_currentStep = 0;
}
else
{
if (m_currentStep <= 0)
m_currentStep = m_stepsPerRev;
}
m_totalSteps--;
stepperStep();
}
}
// and... we're done
return true;
}
bool GroveMD::disableStepper()
{
if (m_stepMode == STEP_MODE2)
return writePacket(STEPPER_DISABLE, GROVEMD_NOOP, GROVEMD_NOOP);
// else, mode 1
writePacket(SET_DIRECTION, 0, GROVEMD_NOOP);
return setMotorSpeeds(0, 0);
}
bool GroveMD::setStepperSteps(unsigned int steps)
{
if (m_stepMode == STEP_MODE2)
{
if (steps == 0)
{
// invalid
throw std::out_of_range(std::string(__FUNCTION__) +
": invalid number of steps. " +
"Valid values are between 1 and 255.");
return false;
}
return writePacket(STEPPER_NUM_STEPS, steps, GROVEMD_NOOP);
}
// for mode one, just store it for future use by enableStepper()
m_totalSteps = steps;
return true;
}
void GroveMD::initClock()
{
gettimeofday(&m_startTime, NULL);
}
uint32_t GroveMD::getMillis()
{
struct timeval elapsed, now;
uint32_t elapse;
// get current time
gettimeofday(&now, NULL);
// compute the delta since m_startTime
if( (elapsed.tv_usec = now.tv_usec - m_startTime.tv_usec) < 0 )
{
elapsed.tv_usec += 1000000;
elapsed.tv_sec = now.tv_sec - m_startTime.tv_sec - 1;
}
else
{
elapsed.tv_sec = now.tv_sec - m_startTime.tv_sec;
}
elapse = (uint32_t)((elapsed.tv_sec * 1000) + (elapsed.tv_usec / 1000));
// never return 0
if (elapse == 0)
elapse = 1;
return elapse;
}
void GroveMD::configStepper(unsigned int stepsPerRev, STEP_MODE_T mode)
{
m_stepsPerRev = stepsPerRev;
m_stepMode = mode;
m_currentStep = 0;
m_stepDelay = 0;
m_stepDirection = 1;
m_totalSteps = 0;
}
void GroveMD::stepperStep()
{
int step = m_currentStep % 4;
switch (step)
{
case 0:
writePacket(SET_DIRECTION, 0b0101, GROVEMD_NOOP);
break;
case 1:
writePacket(SET_DIRECTION, 0b0110, GROVEMD_NOOP);
break;
case 2:
writePacket(SET_DIRECTION, 0b1010, GROVEMD_NOOP);
break;
case 3:
writePacket(SET_DIRECTION, 0b1001, GROVEMD_NOOP);
break;
}
}

View File

@ -1,257 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <stdint.h>
#include <sys/time.h>
#include <string>
#include <mraa/types.hpp>
#include <mraa/i2c.hpp>
#define GROVEMD_I2C_BUS 0
#define GROVEMD_DEFAULT_I2C_ADDR 0x0f
namespace upm {
/**
* @deprecated This library is being replaced by libupm-md
* @brief Grove I2C Motor Driver
* @defgroup grovemd libupm-grovemd
* @ingroup seeed i2c motor robok
*/
/**
* @deprecated This class is being replaced by MD
* @library grovemd
* @sensor grovemd
* @comname I2C Motor Driver
* @type motor
* @man seeed
* @con i2c
* @kit robok
*
* @brief API for the Grove I2C Motor Driver
*
* This class implements support for the Grove I2C Motor Driver.
* This device can support a single 4-wire stepper motor, or two
* 2-wire DC motors. The device contains an Atmel* ATmega8L
* microcontroller that manages an L298N H-bridge driver chip.
*
* This device supports an I2C bus speed of 100Khz only.
*
* The module does not provide any telemetry or status - it only
* accepts I2C commands for its various operations.
*
* This module was tested with version 1.3 of the Grove I2C Motor
* Driver.
*
* For stepper operation, this driver can run in one of two modes -
* Mode 1, where this driver handles the stepping operation, and
* Mode 2, where this driver simply sends commands to the Grove
* Motor Driver, and it handles the stepping operation. Mode2
* requires updated (and working) firmware to be loaded onto the
* device.
*
* The default stepper operation mode is Mode1, which is generally
* more flexible and is supported on all firmware revisions.
*
* @image html grovemd.jpg
* An example showing the use of a DC motor
* @snippet grovemd.cxx Interesting
* An example showing the use of a 4-wire stepper
* @snippet grovemd-stepper.cxx Interesting
*/
class GroveMD {
public:
// GroveMD registers
typedef enum { SET_SPEED = 0x82,
SET_PWM_FREQ = 0x84,
SET_DIRECTION = 0xaa,
SET_MOTOR_A = 0xa1, // not documented
SET_MOTOR_B = 0xa5, // not documented
STEPPER_ENABLE = 0x1a,
STEPPER_DISABLE = 0x1b,
STEPPER_NUM_STEPS = 0x1c
} REG_T;
// legal directions for the stepper
typedef enum { STEP_DIR_CCW = 0x01,
STEP_DIR_CW = 0x00
} STEP_DIRECTION_T;
// legal directions for individual DC motors
typedef enum { DIR_CCW = 0x02,
DIR_CW = 0x01
} DC_DIRECTION_T;
// stepper modes
typedef enum { STEP_MODE1 = 0x00,
STEP_MODE2 = 0x01
} STEP_MODE_T;
/**
* GroveMD constructor
*
* @param bus I2C bus to use
* @param address I2C address to use
*/
GroveMD(int bus=GROVEMD_I2C_BUS,
uint8_t address=GROVEMD_DEFAULT_I2C_ADDR);
/**
* GroveMD destructor
*/
~GroveMD();
/**
* Composes and writes a 3-byte packet to the controller
*
* @param reg Register location
* @param data1 First byte of data
* @param data2 Second byte of data
* @return True if successful
*/
bool writePacket(REG_T reg, uint8_t data1, uint8_t data2);
/**
* To control DC motors, sets the speed of motors A & B.
* Valid values are 0-255.
*
* @param speedA Speed of motor A
* @param speedB Speed of motor B
* @return True if successful
*/
bool setMotorSpeeds(uint8_t speedA, uint8_t speedB);
/**
* To control DC motors, sets the PWM frequency prescale
* factor. Note: this register is not ducumented other than to say
* the default value is 0x03. Presumably, this is the timer
* prescale factor used on the ATMega MCU timer driving the PWM.
*
* @param freq PWM prescale frequency; default is 0x03
* @return True if successful
*/
bool setPWMFrequencyPrescale(uint8_t freq=0x03);
/**
* To control DC motors, sets the directions of motors A & B
*
* @param dirA Direction for motor A, DIR_CW or DIR_CCW
* @param dirB Direction for motor B, DIR_CW or DIR_CCW
* @return True if successful
*/
bool setMotorDirections(DC_DIRECTION_T dirA, DC_DIRECTION_T dirB);
/**
* To control a stepper motor, sets its direction and speed, and
* then starts operation. For Mode2, this method will return
* immediately. For Mode1 (the default) this method returns when
* the number of steps specified by setStepperSteps() has
* completed.
*
* @param dir Direction, STEP_DIR_CW or STEP_DIR_CCW
* @param speed Motor speed. Valid range is 1-255. For Mode 1
* (default), this specifies the speed in RPM's. For Mode 2,
* speed is multiplied by 4ms by the board, so higher numbers
* will mean a slower speed.
* @return True if successful
*/
bool enableStepper(STEP_DIRECTION_T dir, uint8_t speed);
/**
* To control a stepper motor, stops the stepper motor.
*
* @return True if successful
*/
bool disableStepper();
/**
* To control a stepper motor, specifies the number of steps to
* execute. For Mode2, valid values are between 1-255, 255 means
* continuous rotation.
*
* For Mode1 (the default) steps can be any positive integer.
*
* @param steps Number of steps to execute. 255 (only in Mode2)
* means continuous rotation.
* @return True if successful
*/
bool setStepperSteps(unsigned int steps);
/**
* Configure the initial Stepper parameters. This should be
* called before any other stepper method.
*
* @param stepsPerRev The number of steps required to complete one
* full revolution.
* @param mode The stepper operating mode, default STEP_MODE1
* @return Elapsed milliseconds
*/
void configStepper(unsigned int stepsPerRev, STEP_MODE_T mode=STEP_MODE1);
protected:
mraa::I2c m_i2c;
uint8_t m_addr;
private:
// steps per revolution
int m_stepsPerRev;
int m_currentStep;
uint32_t m_stepDelay;
uint32_t m_totalSteps;
STEP_MODE_T m_stepMode;
/**
* Steps the motor one tick
*
*/
void stepperStep();
// step direction: - 1 = forward, -1 = backward
int m_stepDirection;
// This is a NOOP value used to pad packets
static const uint8_t GROVEMD_NOOP = 0x01;
// our timer
struct timeval m_startTime;
/**
* Returns the number of milliseconds elapsed since initClock()
* was last called.
*
* @return Elapsed milliseconds
*/
uint32_t getMillis();
/**
* Resets the clock
*
*/
void initClock();
};
}

View File

@ -1,6 +0,0 @@
set (libname "grovemoisture")
set (libdescription "Moisture Sensor")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
set (module_iface iMoisture.hpp)
upm_module_init(mraa)

View File

@ -1,53 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <iostream>
#include <string>
#include <stdexcept>
#include "grovemoisture.hpp"
using namespace upm;
GroveMoisture::GroveMoisture(int pin)
{
if ( !(m_aio = mraa_aio_init(pin)) )
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_aio_init() failed, invalid pin?");
}
GroveMoisture::~GroveMoisture()
{
mraa_aio_close(m_aio);
}
int GroveMoisture::value()
{
return mraa_aio_read(m_aio);
}
int GroveMoisture::getMoisture()
{
return value();
}

View File

@ -1,91 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <string>
#include <mraa/aio.h>
#include <interfaces/iMoisture.hpp>
namespace upm {
/**
* @deprecated This library is being replaced by libupm-moisture
* @brief Grove Moisture Sensor
* @defgroup grovemoisture libupm-grovemoisture
* @ingroup seeed analog liquid eak hak
*/
/**
* @deprecated This class is being replaced by Moisture
* @library grovemoisture
* @sensor grovemoisture
* @comname Moisture Sensor
* @type liquid
* @man seeed
* @con analog
* @kit eak hak
*
* @brief API for the Grove Moisture Sensor
*
* UPM module for the Grove Moisture Sensor.
* This sensor can be used to detect the moisture content
* of soil or whether there is water around the sensor.
* As the moisture content increases, so does the value that is read.
* Note: this sensor is not designed to be left in soil
* nor to be used outdoors.
*
* @image html grovemoisture.jpg
* @snippet grovemoisture.cxx Interesting
*/
class GroveMoisture : virtual public iMoisture {
public:
/**
* Grove analog moisture sensor constructor
*
* @param pin Analog pin to use
*/
GroveMoisture(int pin);
/**
* GroveMoisture destructor
*/
~GroveMoisture();
/**
* Gets the moisture value from the sensor
*
* @return Moisture reading
*/
int value();
/**
* Gets the moisture value from the sensor
*
* @return Moisture reading
*/
virtual int getMoisture();
private:
mraa_aio_context m_aio;
};
}

View File

@ -1,38 +0,0 @@
{
"Library": "grovemoisture",
"Description": "API for the Grove Moisture Sensor",
"Sensor Class":
{
"GroveMoisture":
{
"Name": "Grove Moisture Sensor",
"Description": "UPM module for the Grove Moisture Sensor. This sensor can be used to detect the moisture content of soil or whether there is water around the sensor. As the moisture content increases, so does the value that is read. Note: this sensor is not designed to be left in soil nor to be used outdoors.",
"Aliases": ["grovemoisture"],
"Categories": ["moisture"],
"Connections": ["analog"],
"Project Type": ["liquid", "prototyping"],
"Manufacturers": ["seeed"],
"Kits": ["eak", "hak"],
"Image": "grovemoisture.jpg",
"Examples":
{
"Java": ["GroveMoisture_Example.java"],
"Python": ["grovemoisture.py"],
"Node.js": ["grovemoisture.js"],
"C++": ["grovemoisture.cxx"],
"C": []
},
"Specifications": {
"Vsource": {"unit": "V", "min": 3.3, "max": 5 },
"Operating Temperature": {"unit": "°C", "min": -40, "max": 85 },
"Supply Current": {"unit": "mA", "min" : 0, "max" : 35 }
},
"Urls" :
{
"Product Pages": ["https://www.seeedstudio.com/Grove-Moisture-Sensor-p-955.html"],
"Datasheets": ["http://wiki.seeed.cc/Grove-Moisture_Sensor/"],
"Schematics": []
}
}
}
}

View File

@ -1,6 +0,0 @@
set (libname "groveo2")
set (libdescription "Oxygen (O2) Concentration Sensor")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
set (module_iface iGas.hpp)
upm_module_init(mraa)

View File

@ -1,76 +0,0 @@
/*
* Author: Zion Orent <zorent@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <iostream>
#include <string>
#include <stdexcept>
#include "groveo2.hpp"
using namespace upm;
using namespace std;
GroveO2::GroveO2(int pin)
{
if ( !(m_aio = mraa_aio_init(pin)) )
{
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_aio_init() failed, invalid pin?");
return;
}
}
GroveO2::~GroveO2()
{
mraa_aio_close(m_aio);
}
float GroveO2::voltageValue()
{
int val = mraa_aio_read(m_aio);
if (val == -1) return -1.0f;
float sensorVoltage = (val/1024.0) * 5.0;
sensorVoltage = (sensorVoltage/201.0) * 10000.0;
return sensorVoltage;
}
float GroveO2::getConcentration()
{
float value;
/* Read normalized value */
value = mraa_aio_read_float(m_aio);
if (value < 0.0)
return -1;
/* Convert to %oxygen
Datasheet for grove o2 shows a linear response for the sensor. Assuming
20.5% oxygen @ 25 celsius, with an gain = 1 + 12k/100 = 121, a
dynamic range of 0->25% oxygen, and opamp rails of 0->3.3v (the grove o2
sensor uses a high-accuracy 3.3v regulator),
*/
value *= 25 * 5 / 3.3;
return value;
}

View File

@ -1,83 +0,0 @@
/*
* Author: Zion Orent <zorent@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <string>
#include <mraa/aio.h>
#include <interfaces/iGas.hpp>
namespace upm {
/**
* @deprecated This library is being replaced by libupm-o2
* @brief Grove O2 Oxygen Gas Sensor
* @defgroup groveo2 libupm-groveo2
* @ingroup seeed analog gaseous
*/
/**
* @deprecated This class is being replaced by O2
* @library groveo2
* @sensor groveo2
* @comname Oxygen (O2) Concentration Sensor
* @type gaseous
* @man seeed
* @con analog
*
* @brief API for the Grove O2 Oxygen Gas Sensor
*
* The Grove O2 Oxygen Gas sensor measures the oxygen concentration in the air
*
* @image html groveo2.jpg
* @snippet groveo2.cxx Interesting
*/
class GroveO2: virtual public iGas {
public:
/**
* Grove O2 Oxygen Gas sensor constructor
*
* @param pin Analog pin to use
*/
GroveO2(int pin);
/**
* GroveO2 destructor
*/
~GroveO2();
/**
* Measures O2 from the sensor
*
* @return Oxygen concentration as voltage
*/
float voltageValue();
/**
* Measures O2 from the sensor
*
* @return Oxygen concentration as PPM
*/
float getConcentration();
private:
mraa_aio_context m_aio;
};
}

View File

@ -1,39 +0,0 @@
{
"Library": "groveo2",
"Description": "Grove O2 Oxygen Gas Sensor Library",
"Sensor Class":
{
"GroveO2":
{
"Name": "Grove Oxygen (O2) Concentration Sensor",
"Description": "The Grove O2 Oxygen Gas sensor measures the oxygen concentration in the air.",
"Aliases": ["groveo2"],
"Categories": ["gas", "oxygen", "deprecated"],
"Connections": ["analog"],
"Project Type": ["environmental", "prototyping"],
"Manufacturers": ["seeed"],
"Kits": [],
"Image": "groveo2.jpg",
"Examples":
{
"Java": ["GroveO2_Example.java"],
"Python": ["groveo2.py"],
"Node.js": ["groveo2.js"],
"C++": ["groveo2.cxx"],
"C": []
},
"Specifications":
{
"Measurement Range": {"unit": "% Vol", "low": 0, "high": 25},
"Sensitivity": {"unit": "mA (in air)", "low": 0.1, "high": 0.3},
"Operating Temperature": {"unit": "degC", "low": -20, "high": 50}
},
"Urls" :
{
"Product Pages": ["https://www.seeedstudio.com/grove-gas-sensoro2-p-1541.html"],
"Datasheets": ["http://wiki.seeed.cc/Grove-Gas_Sensor-O2/"],
"Schematics": ["https://github.com/SeeedDocument/Grove_Gas_Sensor_O2/raw/master/resources/Schematics_O2.zip"]
}
}
}
}

View File

@ -1,5 +0,0 @@
set (libname "grovescam")
set (libdescription "Serial Camera Module")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
upm_module_init(mraa)

View File

@ -1,490 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Thanks to Seeed Studio for a working arduino sketch
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <iostream>
#include <string>
#include <stdexcept>
#include <errno.h>
#include "grovescam.hpp"
using namespace upm;
using namespace std;
static const int maxRetries = 100;
GROVESCAM::GROVESCAM(int uart, uint8_t camAddr)
{
m_ttyFd = -1;
// save our shifted camera address, we'll need it a lot
m_camAddr = (camAddr << 5);
m_picTotalLen = 0;
if ( !(m_uart = mraa_uart_init(uart)) )
{
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_uart_init() failed");
return;
}
// This requires a recent MRAA (1/2015)
const char *devPath = mraa_uart_get_dev_path(m_uart);
if (!devPath)
{
throw std::runtime_error(std::string(__FUNCTION__) +
": mraa_uart_get_dev_path() failed");
return;
}
// now open the tty
if ( (m_ttyFd = open(devPath, O_RDWR)) == -1)
{
throw std::runtime_error(std::string(__FUNCTION__) +
": open of " +
string(devPath) + " failed:" +
string(strerror(errno)));
return;
}
}
GROVESCAM::~GROVESCAM()
{
if (m_ttyFd != -1)
close(m_ttyFd);
}
bool GROVESCAM::dataAvailable(unsigned int millis)
{
if (m_ttyFd == -1)
return false;
struct timeval timeout;
if (millis == 0)
{
// no waiting
timeout.tv_sec = 0;
timeout.tv_usec = 0;
}
else
{
timeout.tv_sec = millis / 1000;
timeout.tv_usec = (millis % 1000) * 1000;
}
fd_set readfds;
FD_ZERO(&readfds);
FD_SET(m_ttyFd, &readfds);
if (select(m_ttyFd + 1, &readfds, NULL, NULL, &timeout) > 0)
return true; // data is ready
else
return false;
}
int GROVESCAM::readData(uint8_t *buffer, int len)
{
if (m_ttyFd == -1)
return(-1);
int rv = read(m_ttyFd, (char *)buffer, len);
if (rv < 0)
{
throw std::runtime_error(std::string(__FUNCTION__) +
": read() failed: " +
string(strerror(errno)));
return rv;
}
return rv;
}
int GROVESCAM::writeData(uint8_t *buffer, int len)
{
if (m_ttyFd == -1)
return(-1);
// first, flush any pending but unread input
tcflush(m_ttyFd, TCIFLUSH);
int rv = write(m_ttyFd, (char *)buffer, len);
if (rv < 0)
{
throw std::runtime_error(std::string(__FUNCTION__) +
": write() failed: " +
string(strerror(errno)));
return rv;
}
tcdrain(m_ttyFd);
return rv;
}
bool GROVESCAM::setupTty(speed_t baud)
{
if (m_ttyFd == -1)
return(false);
struct termios termio;
// get current modes
tcgetattr(m_ttyFd, &termio);
// setup for a 'raw' mode. 81N, no echo or special character
// handling, such as flow control.
cfmakeraw(&termio);
// set our baud rates
cfsetispeed(&termio, baud);
cfsetospeed(&termio, baud);
// make it so
if (tcsetattr(m_ttyFd, TCSAFLUSH, &termio) < 0)
{
throw std::runtime_error(std::string(__FUNCTION__) +
": tcsetattr() failed: " +
string(strerror(errno)));
return false;
}
return true;
}
void GROVESCAM::drainInput()
{
uint8_t ch;
while (dataAvailable(0))
readData(&ch, 1);
}
bool GROVESCAM::init()
{
const unsigned int pktLen = 6;
uint8_t cmd[pktLen] = {0xaa, static_cast<uint8_t>(0x0d|m_camAddr), 0x00,
0x00, 0x00, 0x00};
uint8_t resp[pktLen];
int retries = 0;
while (true)
{
if (retries++ > maxRetries)
{
throw std::runtime_error(std::string(__FUNCTION__) +
": maximum retries exceeded");
return false;
}
writeData(cmd, pktLen);
if (!dataAvailable(500))
continue;
if (readData(resp, pktLen) != pktLen)
continue;
if (resp[0] == 0xaa
&& resp[1] == (0x0e | m_camAddr)
&& resp[2] == 0x0d
&& resp[4] == 0
&& resp[5] == 0)
{
if (readData(resp, pktLen) != pktLen)
continue;
else
{
if (resp[0] == 0xaa
&& resp[1] == (0x0d | m_camAddr)
&& resp[2] == 0
&& resp[3] == 0
&& resp[4] == 0
&& resp[5] == 0)
break;
}
}
}
cmd[1] = 0x0e | m_camAddr;
cmd[2] = 0x0d;
writeData(cmd, pktLen);
return true;
}
bool GROVESCAM::preCapture(PIC_FORMATS_T fmt)
{
const unsigned int pktLen = 6;
uint8_t cmd[pktLen] = { 0xaa, static_cast<uint8_t>(0x01 | m_camAddr), 0x00,
0x07, 0x00, static_cast<uint8_t>(fmt) };
uint8_t resp[pktLen];
int retries = 0;
while (true)
{
if (retries++ > maxRetries)
{
throw std::runtime_error(std::string(__FUNCTION__) +
": maximum retries exceeded");
return false;
}
drainInput();
writeData(cmd, pktLen);
if (!dataAvailable(100))
continue;
if (readData(resp, pktLen) != pktLen)
continue;
if (resp[0] == 0xaa
&& resp[1] == (0x0e | m_camAddr)
&& resp[2] == 0x01
&& resp[4] == 0
&& resp[5] == 0) break;
}
return true;
}
bool GROVESCAM::doCapture()
{
const unsigned int pktLen = 6;
uint8_t cmd[pktLen] = { 0xaa, static_cast<uint8_t>(0x06 | m_camAddr), 0x08,
static_cast<uint8_t>(MAX_PKT_LEN & 0xff),
static_cast<uint8_t>((MAX_PKT_LEN >> 8)) & 0xff, 0};
uint8_t resp[pktLen];
int retries = 0;
m_picTotalLen = 0;
while (true)
{
if (retries++ > maxRetries)
{
throw std::runtime_error(std::string(__FUNCTION__) +
": maximum retries exceeded");
return false;
}
drainInput();
writeData(cmd, pktLen);
usleep(100000);
if (!dataAvailable(100))
continue;
if (readData(resp, pktLen) != pktLen)
continue;
if (resp[0] == 0xaa
&& resp[1] == (0x0e | m_camAddr)
&& resp[2] == 0x06
&& resp[4] == 0
&& resp[5] == 0)
break;
}
cmd[1] = 0x05 | m_camAddr;
cmd[2] = 0;
cmd[3] = 0;
cmd[4] = 0;
cmd[5] = 0;
retries = 0;
while (true)
{
if (retries++ > maxRetries)
{
throw std::runtime_error(std::string(__FUNCTION__) +
": maximum retries exceeded");
return false;
}
drainInput();
writeData(cmd, pktLen);
if (readData(resp, pktLen) != pktLen)
continue;
if (resp[0] == 0xaa
&& resp[1] == (0x0e | m_camAddr)
&& resp[2] == 0x05
&& resp[4] == 0
&& resp[5] == 0)
break;
}
cmd[1] = 0x04 | m_camAddr;
cmd[2] = 0x01;
retries = 0;
while (true)
{
if (retries++ > maxRetries)
{
throw std::runtime_error(std::string(__FUNCTION__) +
": maximum retries exceeded");
return false;
}
drainInput();
writeData(cmd, 6);
if (readData(resp, pktLen) != pktLen)
continue;
if (resp[0] == 0xaa
&& resp[1] == (0x0e | m_camAddr)
&& resp[2] == 0x04
&& resp[4] == 0
&& resp[5] == 0)
{
if (!dataAvailable(1000))
continue;
if (readData(resp, pktLen) != pktLen)
continue;
if (resp[0] == 0xaa
&& resp[1] == (0x0a | m_camAddr)
&& resp[2] == 0x01)
{
m_picTotalLen = (resp[3]) | (resp[4] << 8) | (resp[5] << 16);
break;
}
}
}
return true;
}
bool GROVESCAM::storeImage(const char *fname)
{
if (!fname)
{
throw std::invalid_argument(std::string(__FUNCTION__) +
": filename is NULL");
return false;
}
if (!m_picTotalLen)
{
throw std::runtime_error(std::string(__FUNCTION__) +
": Picture length is zero, you need to capture first.");
return false;
}
FILE *file = fopen(fname, "wb");
if (!file)
{
throw std::runtime_error(std::string(__FUNCTION__) +
": fopen() failed: " +
string(strerror(errno)));
return false;
}
/// let the games begin...
const unsigned int pktLen = 6;
unsigned int pktCnt = (m_picTotalLen) / (MAX_PKT_LEN - 6);
if ((m_picTotalLen % (MAX_PKT_LEN-6)) != 0)
pktCnt += 1;
uint8_t cmd[pktLen] = { 0xaa, static_cast<uint8_t>(0x0e | m_camAddr), 0x00,
0x00, 0x00, 0x00 };
uint8_t pkt[MAX_PKT_LEN];
int retries = 0;
for (unsigned int i = 0; i < pktCnt; i++)
{
cmd[4] = i & 0xff;
cmd[5] = (i >> 8) & 0xff;
retries = 0;
retry:
usleep(10000);
drainInput();
writeData(cmd, pktLen);
if (!dataAvailable(1000))
{
if (retries++ > maxRetries)
{
throw std::runtime_error(std::string(__FUNCTION__) +
": timeout, maximum retries exceeded");
return false;
}
goto retry;
}
uint16_t cnt = readData(pkt, MAX_PKT_LEN);
unsigned char sum = 0;
for (int y = 0; y < cnt - 2; y++)
{
sum += pkt[y];
}
if (sum != pkt[cnt-2])
{
if (retries++ <= maxRetries)
goto retry;
else
{
fclose(file);
throw std::runtime_error(std::string(__FUNCTION__) +
": cksum error, maximum retries exceeded");
return false;
}
}
fwrite((const uint8_t *)&pkt[4], cnt - 6, 1, file);
}
cmd[4] = 0xf0;
cmd[5] = 0xf0;
writeData(cmd, pktLen);
fclose(file);
// reset the pic length to 0 for another run.
m_picTotalLen = 0;
return true;
}

View File

@ -1,196 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Thanks to Seeed Studio for a working arduino sketch
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <string>
#include <iostream>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>
#include <sys/time.h>
#include <sys/select.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <mraa/uart.h>
#define GROVESCAM_DEFAULT_UART 0
#define GROVESCAM_DEFAULT_CAMERA_ADDR 0
namespace upm {
/**
* @deprecated This library is being replaced by libupm-scam
* @brief Grove Serial Camera
* @defgroup grovescam libupm-grovescam
* @ingroup seeed uart other
*/
/**
* @deprecated This class is being replaced by SCAM
* @library grovescam
* @sensor grovescam
* @comname Serial Camera Module
* @type other
* @man seeed
* @con uart
* @web http://www.seeedstudio.com/wiki/Grove_-_Serial_Camera_Kit
*
* @brief API for the Grove Serial Camera
*
* The driver was tested with the Grove Serial Camera. There is
* no protocol documentation currently available, so this module
* was developed based completely on the Seeed Studio* Arduino*
* sketch.
*
* It is connected via a UART at 115,200 baud.
*
* @image html grovescam.jpg
* @snippet grovescam.cxx Interesting
*/
class GROVESCAM {
public:
static const unsigned int MAX_PKT_LEN = 128;
typedef enum {
FORMAT_VGA = 7, // 640x480
FORMAT_CIF = 5, // 352*288
FORMAT_OCIF = 3 // ??? (maybe they meant QCIF?)
} PIC_FORMATS_T;
/**
* Grove Serial Camera constructor
*
* @param uart Default UART to use (0 or 1)
* @param camAddr 3-bit address identifier of the camera; default is 0
*/
GROVESCAM(int uart, uint8_t camAddr=GROVESCAM_DEFAULT_CAMERA_ADDR);
/**
* GROVESCAM destructor
*/
~GROVESCAM();
/**
* Checks to see if there is data available for reading
*
* @param millis Number of milliseconds to wait; 0 means no waiting.
* @return True if there is data available for reading
*/
bool dataAvailable(unsigned int millis);
/**
* Reads any available data into a user-supplied buffer. Note: the
* call blocks until data is available to be read. Use
* dataAvailable() to determine whether there is data available
* beforehand, to avoid blocking.
*
* @param buffer Buffer to hold the data read
* @param len Length of the buffer
* @return Number of bytes read
*/
int readData(uint8_t *buffer, int len);
/**
* Writes the data in the buffer to the device
*
* @param buffer Buffer to hold the data read
* @param len Length of the buffer
* @return Number of bytes written
*/
int writeData(uint8_t *buffer, int len);
/**
* Sets up proper tty I/O modes and the baud rate. For this device, the default
* baud rate is 9,600 (B9600).
*
* @param baud Desired baud rate
* @return True if successful
*/
bool setupTty(speed_t baud=B115200);
/**
* Reads serial input and discards until no more characters are available
*
*/
void drainInput();
/**
* Initializes the camera
*
*/
bool init();
/**
* Tells the camera to prepare for a capture
*
* @param fmt One of the PIC_FORMATS_T values
*/
bool preCapture(PIC_FORMATS_T fmt=FORMAT_VGA);
/**
* Starts the capture
*
* @return True if successful
*/
bool doCapture();
/**
* Stores the captured image in a file
*
* @param fname Name of the file to write
* @return True if successful
*/
bool storeImage(const char *fname);
/**
* Returns the picture length. Note: this is only valid after
* doCapture() has run successfully.
*
* @return Image length
*/
int getImageSize() { return m_picTotalLen; };
protected:
int ttyFd() { return m_ttyFd; };
private:
mraa_uart_context m_uart;
int m_ttyFd;
uint8_t m_camAddr;
int m_picTotalLen;
};
}

View File

@ -1,16 +0,0 @@
%include "../common_top.i"
/* BEGIN Java syntax ------------------------------------------------------- */
#ifdef SWIGJAVA
%include "../java_buffer.i"
JAVA_JNI_LOADLIBRARY(javaupm_grovescam)
#endif
/* END Java syntax */
/* BEGIN Common SWIG syntax ------------------------------------------------- */
%{
#include "grovescam.hpp"
%}
%include "grovescam.hpp"
/* END Common SWIG syntax */

View File

@ -1,39 +0,0 @@
{
"Library": "grovescam",
"Description": "Grove Serial Camera Library",
"Sensor Class":
{
"GROVESCAM":
{
"Name": "Serial Camera Module",
"Description": "UPM module for the ear-clip heart rate sensor. It is used to measure your heart rate.",
"Aliases": ["grovescam"],
"Categories": ["imaging", "deprecated"],
"Connections": ["uart"],
"Project Type": ["prototyping", "access control", "security"],
"Manufacturers": ["seeed"],
"Kits": [],
"Image": "grovescam.jpg",
"Examples":
{
"Java": ["GROVESCAM_Example.java"],
"Python": ["grovescam.py"],
"Node.js": ["grovescam.js"],
"C++": ["grovescam.cxx"],
"C": []
},
"Specifications":
{
"Operating Voltage": {"unit": "V", "typ": 5},
"Resolution": {"unit": "", "max": "640x480"}
},
"Urls" :
{
"Product Pages": ["https://www.seeedstudio.com/Grove-Serial-Camera-Kit-p-1608.html"],
"Datasheets": ["http://www.seeedstudio.com/wiki/Grove_-_Serial_Camera_Kit"],
"Schematics": []
}
}
}
}

View File

@ -1,5 +0,0 @@
set (libname "grovespeaker")
set (libdescription "Speaker Module")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
upm_module_init(mraa)

View File

@ -1,150 +0,0 @@
/*
* Author: Zion Orent <sorent@ics.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <iostream>
#include <string>
#include <stdexcept>
#include "grovespeaker.hpp"
using namespace upm;
GroveSpeaker::GroveSpeaker(int pin)
{
if ( !(m_gpio = mraa_gpio_init(pin)) )
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_gpio_init() failed, invalid pin?");
mraa_gpio_dir(m_gpio, MRAA_GPIO_OUT);
m_note_list['a'] = storeNote(1136, 1073, 568, 536, 284, 268);
m_note_list['b'] = storeNote(1012, 0, 506, 0, 253, 0);
m_note_list['c'] = storeNote(1911, 1804, 956, 902, 478, 451);
m_note_list['d'] = storeNote(1703, 1607, 851, 804, 426, 402);
m_note_list['e'] = storeNote(1517, 0, 758, 0, 379, 0);
m_note_list['f'] = storeNote(1432, 1351, 716, 676, 358, 338);
m_note_list['g'] = storeNote(1276, 1204, 638, 602, 319, 301);
}
GroveSpeaker::~GroveSpeaker()
{
mraa_gpio_close(m_gpio);
}
NoteData GroveSpeaker::storeNote(int noteDelayLow, int noteDelayLowSharp,
int noteDelayMed, int noteDelayMedSharp,
int noteDelayHigh, int noteDelayHighSharp)
{
NoteData note;
note.delayTimeLow = noteDelayLow;
note.delayTimeLowSharp = noteDelayLowSharp;
note.delayTimeMed = noteDelayMed;
note.delayTimeMedSharp = noteDelayMedSharp;
note.delayTimeHigh = noteDelayHigh;
note.delayTimeHighSharp = noteDelayHighSharp;
return note;
}
void GroveSpeaker::playAll()
{
playSound('c', false, "low");
usleep(200000);
playSound('d', false, "low");
usleep(200000);
playSound('e', false, "low");
usleep(200000);
playSound('f', false, "low");
usleep(200000);
playSound('g', false, "low");
usleep(500000);
playSound('a', false, "low");
usleep(500000);
playSound('b', false, "low");
usleep(500000);
}
void GroveSpeaker::playSound(char letter, bool sharp, std::string vocalWeight)
{
std::map<char, NoteData>::iterator it = m_note_list.find(letter);
if(it == m_note_list.end())
{
std::cout << "The key " << letter << " doesn't exist." << std::endl;
return;
}
NoteData nd = it->second;
int delayTime;
if (sharp)
{
if (vocalWeight.compare("low") == 0)
delayTime = nd.delayTimeLowSharp;
else if (vocalWeight.compare("med") == 0)
delayTime = nd.delayTimeMedSharp;
else if (vocalWeight.compare("high") == 0)
delayTime = nd.delayTimeHighSharp;
else
{
std::cout << "Correct voice weight values are low, med, or high"
<< std::endl;
return;
}
}
else
{
if (vocalWeight.compare("low") == 0)
delayTime = nd.delayTimeLow;
else if (vocalWeight.compare("med") == 0)
delayTime = nd.delayTimeMed;
else if (vocalWeight.compare("high") == 0)
delayTime = nd.delayTimeHigh;
else
{
std::cout << "Correct voice weight values are low, med, or high"
<< std::endl;
return;
}
}
// If delayTime is zero, that means you tried to choose a sharp note
// for a note that has no sharp
if (sharp && !delayTime)
{
std::cout << "The key " << letter << " doesn't have a sharp note."
<< std::endl;
return;
}
sound(delayTime);
}
void GroveSpeaker::sound(int note_delay)
{
mraa_result_t error = MRAA_SUCCESS;
for (int i = 0; i < 100; i++)
{
error = mraa_gpio_write (m_gpio, HIGH);
usleep(note_delay);
error = mraa_gpio_write (m_gpio, LOW);
usleep(note_delay);
}
if (error != MRAA_SUCCESS)
mraa_result_print(error);
}

View File

@ -1,105 +0,0 @@
/*
* Author: Zion Orent <sorent@ics.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <string>
#include <map>
#include <unistd.h>
#include <mraa/gpio.h>
#define HIGH 1
#define LOW 0
namespace upm {
/**
* @deprecated This library is being replaced by libupm-speaker
* @brief Grove Speaker
* @defgroup grovespeaker libupm-grovespeaker
* @ingroup seeed gpio sound hak
*/
typedef struct
{
int delayTimeLow;
int delayTimeLowSharp;
int delayTimeMed;
int delayTimeMedSharp;
int delayTimeHigh;
int delayTimeHighSharp;
} NoteData;
/**
* @deprecated This class is being replaced by Speaker
* @library grovespeaker
* @sensor grovespeaker
* @comname Speaker Module
* @type sound
* @man seeed
* @con gpio
* @kit hak
*
* @brief API for the Grove Speaker
*
* UPM module for the Grove Speaker.
* This sensor can generate different tones and sounds depending on the
* frequency of the input signal.
*
* @image html grovespeaker.jpg
* @snippet grovespeaker.cxx Interesting
*/
class GroveSpeaker {
public:
/**
* Grove Speaker constructor
*
* @param pin Digital pin to use
*/
GroveSpeaker(int pin);
/**
* GroveSpeaker destructor
*/
~GroveSpeaker();
/**
* Plays all alto notes (lowest notes)
*
*/
void playAll();
/**
* Plays a sound and a note whether it's sharp or not
*
* @param letter Character name of the note
* ('a', 'b', 'c', 'd', 'e', 'f', or 'g')
* @param sharp If true, plays a sharp version of the note; otherwise, does not play the note
* @param vocalWeight String to determine whether to play a low ("low"),
* a medium ("med"), or a high ("high") note
*/
void playSound(char letter, bool sharp, std::string vocalWeight);
private:
mraa_gpio_context m_gpio;
std::map <char, NoteData> m_note_list;
void sound(int note_delay);
NoteData storeNote(int noteDelayLow, int noteDelayLowSharp,
int noteDelayMed, int noteDelayMedSharp,
int noteDelayHigh, int noteDelayHighSharp);
};
}

View File

@ -1,40 +0,0 @@
{
"Library": "grovespeaker",
"Description": "API for the Grove Speaker",
"Sensor Class":
{
"GroveSpeaker":
{
"Name": "Grove Speaker Module",
"Description": "UPM module for the Grove Speaker. This sensor can generate different tones and sounds depending on the frequency of the input signal.",
"Aliases": ["grovespeaker"],
"Categories": ["sound", "deprecated"],
"Connections": ["gpio"],
"Project Type": ["sound", "prototyping"],
"Manufacturers": ["seeed"],
"Kits": ["hak"],
"Image": "grovespeaker.jpg",
"Examples":
{
"Java": ["GroveSpeaker_Example.java"],
"Python": ["grovespeaker.py"],
"Node.js": ["grovespeaker.js"],
"C++": ["grovespeaker.cxx"],
"C": []
},
"Specifications":
{
"Operating Voltage": {"unit": "V", "low": 4, "high": 5.5},
"Voltage Gain": {"unit": "dB", "typ": 46},
"Bandwidth": {"unit": "KHz", "min": 20}
},
"Urls" :
{
"Product Pages": ["https://www.seeedstudio.com/Grove-Speaker-p-1445.html"],
"Datasheets": ["http://wiki.seeed.cc/Grove-Speaker/", "https://raw.githubusercontent.com/SeeedDocument/Grove-Speaker/master/res/LM386_Low_Voltage_Audio_Power_Amplifier_Datasheet.pdf"],
"Schematics": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Speaker/master/res/Grove-Speaker_v1.0_sch.pdf"]
}
}
}
}

View File

@ -1,5 +0,0 @@
set (libname "groveultrasonic")
set (libdescription "Ultrasonic Proximity Sensor")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
upm_module_init(mraa)

View File

@ -1,105 +0,0 @@
/*
* Author: Jun Kato <i@junkato.jp>
* Copyright (c) 2015 Jun Kato.
*
* Thanks to Seeed Studio for a working arduino sketch
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <functional>
#include <iostream>
#include <stdlib.h>
#include <unistd.h>
#include "groveultrasonic.hpp"
using namespace upm;
GroveUltraSonic::GroveUltraSonic(int pin)
{
m_name = "GroveUltraSonic";
mraa_init();
// setup pin
m_pinCtx = mraa_gpio_init(pin);
if (m_pinCtx == NULL) {
fprintf(stderr, "Are you sure that pin%d you requested is valid on your platform?", pin);
exit(1);
}
mraa_gpio_isr (m_pinCtx, MRAA_GPIO_EDGE_BOTH,
&signalISR, this);
}
GroveUltraSonic::~GroveUltraSonic()
{
// close pin
mraa_gpio_isr_exit(m_pinCtx);
mraa_gpio_close(m_pinCtx);
}
float
GroveUltraSonic::getDistance()
{
// output trigger signal
mraa_gpio_dir(m_pinCtx, MRAA_GPIO_OUT);
mraa_gpio_write(m_pinCtx, LOW);
usleep(2);
mraa_gpio_write(m_pinCtx, HIGH);
usleep(5);
mraa_gpio_write(m_pinCtx, LOW);
// wait for the pulse,
m_doWork = true;
m_InterruptCounter = 0;
mraa_gpio_dir(m_pinCtx, MRAA_GPIO_IN);
// though do not wait over 25 [ms].
int timer = 0;
while (m_doWork && timer++ < 5) {
// in 25 [ms], sound travels 25000 / 29 / 2 = 431 [cm],
// which is more than 400 [cm], the max distance measurable with this sensor.
usleep(5 * 1000); // 5 [ms]
}
// calc diff
long diff = m_FallingTimeStamp.tv_usec - m_RisingTimeStamp.tv_usec;
diff += (m_FallingTimeStamp.tv_sec - m_RisingTimeStamp.tv_sec) * 1000000;
return timer >= 5 ? 0 : diff;
}
void
GroveUltraSonic::signalISR(void* ctx)
{
upm::GroveUltraSonic* This = (upm::GroveUltraSonic*) ctx;
This->ackEdgeDetected();
}
void
GroveUltraSonic::ackEdgeDetected()
{
if (++m_InterruptCounter % 2 == 0) {
gettimeofday(&m_FallingTimeStamp, NULL);
m_doWork = false;
} else {
gettimeofday(&m_RisingTimeStamp, NULL);
}
}

View File

@ -1,123 +0,0 @@
/*
* Author: Jun Kato <i@junkato.jp>
* Copyright (c) 2015 Jun Kato.
*
* Thanks to Seeed Studio for a working arduino sketch
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <string>
#include <mraa/aio.h>
#include <mraa/gpio.h>
#include <sys/time.h>
#define HIGH 1
#define LOW 0
namespace upm {
/**
* @deprecated This library is being replaced by libupm-ultrasonic
* @brief Grove Ultrasonic Sensor
* @defgroup groveultrasonic libupm-groveultrasonic
* @ingroup seeed gpio sound
*/
/**
* @deprecated This class is being replaced by UltraSonic
* @library groveultrasonic
* @sensor groveultrasonic
* @comname Ultrasonic Proximity Sensor
* @type sound
* @man seeed
* @con gpio
*
* @brief API for Grove Ultrasonic Ranger
*
* This Grove Ultrasonic sensor is a non-contact distance measurement module
* which is compatible with the Grove system. It is designed for easy modular
* project usage with industrial performance. Detection ranges from 3 cm (1.2")
* to 4 m (13'1.5") and works best when the object is within a 30 degree angle
* relative to the sensor.
*
* @image html groveultrasonic.jpg
* @snippet groveultrasonic.cxx Interesting
*/
class GroveUltraSonic {
public:
/**
* Instantiates a GroveUltraSonic object
*
* @param pin pin for triggering the sensor for distance and for receiving pulse response
*/
GroveUltraSonic (int pin);
/**
* GroveUltraSonic object destructor.
*/
~GroveUltraSonic ();
/**
* Returns the echo's pulse width from the sensor in microseconds.
* Divide by 58 to convert distance to centimetres.
* Divide by 148 to convert distance to inches.
*/
float getDistance ();
/**
* Return name of the component
*/
std::string name()
{
return m_name;
}
/**
* Returns true while the sensor is busy waiting for the echo pulse
*/
bool working()
{
return m_doWork;
}
private:
bool m_doWork; /* Flag to control blocking function while waiting for falling edge interrupt */
mraa_gpio_context m_pinCtx;
uint8_t m_InterruptCounter;
struct timeval m_RisingTimeStamp;
struct timeval m_FallingTimeStamp;
std::string m_name;
/**
* ISR for the pulse signal
*/
static void signalISR(void *ctx);
/**
* On each interrupt this function will detect if the interrupt
* was falling edge or rising.
* Should be called from the interrupt handler.
*/
void ackEdgeDetected ();
};
}

View File

@ -1,16 +0,0 @@
%include "../common_top.i"
/* BEGIN Java syntax ------------------------------------------------------- */
#ifdef SWIGJAVA
%ignore signalISR;
JAVA_JNI_LOADLIBRARY(javaupm_groveultrasonic)
#endif
/* END Java syntax */
/* BEGIN Common SWIG syntax ------------------------------------------------- */
%{
#include "groveultrasonic.hpp"
%}
%include "groveultrasonic.hpp"
/* END Common SWIG syntax */

View File

@ -1,40 +0,0 @@
{
"Library": "groveultrasonic",
"Description": "Grove Ultrasonic Sensor Library",
"Sensor Class":
{
"GroveUltraSonic":
{
"Name": "Ultrasonic Proximity Sensor",
"Description": "This Grove Ultrasonic sensor is a non-contact distance measurement module which is compatible with the Grove system. It is designed for easy modular project usage with industrial performance. Detection ranges from 3 cm (1.2\") to 4 m (13'1.5\") and works best when the object is within a 30 degree angle relative to the sensor.",
"Aliases": ["groveultrasonic"],
"Categories": ["proximity", "deprecated"],
"Connections": ["gpio"],
"Project Type": ["robotics", "prototyping"],
"Manufacturers": ["seeed"],
"Kits": [],
"Image": "groveultrasonic.jpg",
"Examples":
{
"Java": [],
"Python": [],
"Node.js": ["groveultrasonic.js"],
"C++": ["groveultrasonic.cxx"],
"C": []
},
"Specifications":
{
"Operating Voltage": {"unit": "V", "low": 3.2, "high": 5.2},
"Operating Current": {"unit": "mA", "typ": 8},
"Measurement Range": {"unit": "cm", "low": 2, "high": 350}
},
"Urls" :
{
"Product Pages": ["https://www.seeedstudio.com/Grove-Ultrasonic-Ranger-p-960.html"],
"Datasheets": ["http://wiki.seeed.cc/Grove-Ultrasonic_Ranger/"],
"Schematics": []
}
}
}
}

View File

@ -1,6 +0,0 @@
set (libname "grovevdiv")
set (libdescription "Voltage Divider")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
set (module_iface iVDiv.hpp)
upm_module_init(mraa)

View File

@ -1,72 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <iostream>
#include <string>
#include <stdexcept>
#include "grovevdiv.hpp"
using namespace upm;
using namespace std;
GroveVDiv::GroveVDiv(int pin)
{
if ( !(m_aio = mraa_aio_init(pin)) )
{
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_aio_init() failed, invalid pin?");
return;
}
}
GroveVDiv::~GroveVDiv()
{
mraa_aio_close(m_aio);
}
unsigned int GroveVDiv::value(unsigned int samples)
{
int sum = 0;
for (unsigned int i=0; i<samples; i++)
{
sum += mraa_aio_read(m_aio);
if (sum == -1) return 0;
usleep(2000);
}
return (sum / samples);
}
unsigned int GroveVDiv::getValue()
{
return GroveVDiv::value(1);
}
float GroveVDiv::computedValue(uint8_t gain, unsigned int val, int vref, int res)
{
return ((float(gain) * float(val) * float(vref) / float(res)) / 1000.0);
}

View File

@ -1,108 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <string>
#include <iostream>
#include <stdint.h>
#include <mraa/aio.h>
#include <interfaces/iVDiv.hpp>
// reference voltage in millivolts
#define GROVEVDIV_VREF 4980
// default ADC resolution
#define GROVEVDIV_ADC_RES 1024
namespace upm {
/**
* @deprecated This library is being replaced by libupm-vdiv
* @brief Grove Voltage Divider Sensor
* @defgroup grovevdiv libupm-grovevdiv
* @ingroup seeed analog electric robok
*/
/**
* @deprecated This class is being replaced by VDiv
* @library grovevdiv
* @sensor grovevdiv
* @comname Voltage Divider
* @type electric
* @man seeed
* @con analog
* @kit robok
*
* @brief API for the Grove Voltage Divider Sensor
*
* UPM module for the Grove Voltage Divider sensor
*
* @image html grovevdiv.jpg
* @snippet grovevdiv.cxx Interesting
*/
class GroveVDiv : virtual public iVDiv {
public:
/**
* Grove Voltage Divider sensor constructor
*
* @param pin Analog pin to use
*/
GroveVDiv(int pin);
/**
* Grove Voltage Divider destructor
*/
~GroveVDiv();
/**
* Gets the conversion value from the sensor
*
* @param samples Specifies how many samples to average over
* @return Average ADC conversion value
*/
unsigned int value(unsigned int samples);
/**
* Gets the conversion value from the sensor
*
* @return ADC conversion value
*/
virtual unsigned int getValue();
/**
* Computes the measured voltage
*
* @param gain Gain switch, either 3 or 10 for Grove
* @param val Measured voltage (from value())
* @param vref Reference voltage in millivolts
* @param res ADC resolution
*
* @return Measured voltage
*/
float computedValue(uint8_t gain, unsigned int val, int vref=GROVEVDIV_VREF,
int res=GROVEVDIV_ADC_RES);
private:
mraa_aio_context m_aio;
};
}

View File

@ -1,37 +0,0 @@
{
"Library": "grovevdiv",
"Description": "API for the Grove Voltage Divider Sensor",
"Sensor Class":
{
"GroveVDiv":
{
"Name": "Grove Voltage Divider Sensor",
"Description": "UPM module for the Grove Voltage Divider sensor.",
"Aliases": ["grovevdiv"],
"Categories": ["electric", "deprecated"],
"Connections": ["gpio"],
"Project Type": ["robotics", "prototyping"],
"Manufacturers": ["seeed"],
"Kits": ["robok"],
"Image": "grovevdiv.jpg",
"Examples":
{
"Java": ["GroveVDiv_Example.java"],
"Python": ["grovevdiv.py"],
"Node.js": ["grovevdiv.js"],
"C++": ["grovevdiv.cxx"],
"C": []
},
"Specifications":
{
"Operating Voltage": {"unit": "V", "typ": 5}
},
"Urls" :
{
"Product Pages": ["https://www.seeedstudio.com/Grove-Voltage-Divider-p-1472.html"],
"Datasheets": ["http://wiki.seeed.cc/Grove-Voltage_Divider/"],
"Schematics": ["https://github.com/SeeedDocument/Grove-Voltage_Divider/raw/master/res/LMV358ID_Datasheet.pdf"]
}
}
}
}

View File

@ -1,5 +0,0 @@
set (libname "grovewater")
set (libdescription "Water Sensor")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
upm_module_init(mraa)

View File

@ -1,54 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <iostream>
#include <string>
#include <stdexcept>
#include "grovewater.hpp"
using namespace upm;
using namespace std;
GroveWater::GroveWater(int pin)
{
if ( !(m_gpio = mraa_gpio_init(pin)) )
{
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_gpio_init() failed, invalid pin?");
return;
}
mraa_gpio_dir(m_gpio, MRAA_GPIO_IN);
}
GroveWater::~GroveWater()
{
mraa_gpio_close(m_gpio);
}
bool GroveWater::isWet()
{
return (!mraa_gpio_read(m_gpio) ? true : false);
}

View File

@ -1,76 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <string>
#include <mraa/gpio.h>
namespace upm {
/**
* @deprecated This library is being replaced by libupm-water
* @brief Grove Water Sensor
* @defgroup grovewater libupm-grovewater
* @ingroup seeed gpio liquid eak
*/
/**
* @deprecated This class is being replaced by Water
* @library grovewater
* @sensor grovewater
* @comname Water Sensor
* @type liquid
* @man seeed
* @con gpio
* @kit eak
*
* @brief API for the Grove Water Sensor
*
* UPM module for the Grove Water sensor
*
* @image html water.jpg
* @snippet grovewater.cxx Interesting
*/
class GroveWater {
public:
/**
* Grove digital water sensor constructor
*
* @param pin Digital pin to use
*/
GroveWater(int pin);
/**
* GroveWater destructor
*/
~GroveWater();
/**
* Gets the water (wet/not wet) value from the sensor
*
* @return True if the sensor is wet, false otherwise
*/
bool isWet();
private:
mraa_gpio_context m_gpio;
};
}

View File

@ -1,39 +0,0 @@
{
"Library": "grovewater",
"Description": "Grove Water Sensor Library",
"Sensor Class":
{
"GroveWater":
{
"Name": "Grove Water Sensor",
"Description": "UPM module for the Grove Water sensor.",
"Aliases": ["grovewater"],
"Categories": ["liquid", "deprecated"],
"Connections": ["gpio"],
"Project Type": ["agriculture", "environmental", "prototyping"],
"Manufacturers": ["seeed"],
"Kits": ["eak"],
"Examples":
{
"Java": ["GroveWater_Example.java"],
"Python": ["grovewater.py"],
"Node.js": ["grovewater.js"],
"C++": ["grovewater.cxx"],
"C": []
},
"Specifications":
{
"Operating Voltage": {"unit": "V", "low": 4.7, "high": 5.25},
"Operating Current": {"unit": "mA", "max": 20},
"Working Temperature": {"unit": "degC", "low": 10, "high": 30}
},
"Urls" :
{
"Product Pages": ["https://www.seeedstudio.com/Grove-Water-Sensor-p-748.html"],
"Datasheets": ["http://wiki.seeed.cc/Grove-Water_Sensor/"],
"Schematics": []
}
}
}
}

View File

@ -1,5 +0,0 @@
set (libname "grovewfs")
set (libdescription "Water Flow Sensor")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
upm_module_init(mraa)

View File

@ -1,124 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <iostream>
#include <string>
#include <stdexcept>
#include "grovewfs.hpp"
using namespace upm;
using namespace std;
GroveWFS::GroveWFS(int pin)
{
if ( !(m_gpio = mraa_gpio_init(pin)) )
{
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_gpio_init() failed, invalid pin?");
return;
}
mraa_gpio_dir(m_gpio, MRAA_GPIO_IN);
initClock();
m_flowCounter = 0;
m_isrInstalled = false;
}
GroveWFS::~GroveWFS()
{
if (m_isrInstalled)
stopFlowCounter();
mraa_gpio_close(m_gpio);
}
void GroveWFS::initClock()
{
gettimeofday(&m_startTime, NULL);
}
uint32_t GroveWFS::getMillis()
{
struct timeval elapsed, now;
uint32_t elapse;
// get current time
gettimeofday(&now, NULL);
// compute the delta since m_startTime
if( (elapsed.tv_usec = now.tv_usec - m_startTime.tv_usec) < 0 )
{
elapsed.tv_usec += 1000000;
elapsed.tv_sec = now.tv_sec - m_startTime.tv_sec - 1;
}
else
{
elapsed.tv_sec = now.tv_sec - m_startTime.tv_sec;
}
elapse = (uint32_t)((elapsed.tv_sec * 1000) + (elapsed.tv_usec / 1000));
// never return 0
if (elapse == 0)
elapse = 1;
return elapse;
}
void GroveWFS::startFlowCounter()
{
initClock();
// install our interrupt handler
mraa_gpio_isr(m_gpio, MRAA_GPIO_EDGE_RISING,
&flowISR, this);
m_isrInstalled = true;
}
void GroveWFS::stopFlowCounter()
{
// remove the interrupt handler
mraa_gpio_isr_exit(m_gpio);
m_isrInstalled = false;
}
void GroveWFS::flowISR(void *ctx)
{
upm::GroveWFS *This = (upm::GroveWFS *)ctx;
This->m_flowCounter++;
}
float GroveWFS::flowRate()
{
uint32_t millis = getMillis();
uint32_t flow = flowCounter();
// 7.5 comes from the seeedstudio page, see the confusing datasheet :)
float flowRate = (float(flow) * 7.5) / ((float(millis) / 1000.0) * 60.0);
return flowRate;
}

View File

@ -1,142 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <string>
#include <stdint.h>
#include <sys/time.h>
#include <mraa/gpio.h>
namespace upm {
/**
* @deprecated This library is being replaced by libupm-wfs
* @brief Grove Water Flow Sensor
* @defgroup grovewfs libupm-grovewfs
* @ingroup seeed gpio liquid eak
*/
/**
* @deprecated This class is being replaced by WFS
* @library grovewfs
* @sensor grovewfs
* @comname Water Flow Sensor
* @type liquid
* @man seeed
* @web http://wiki.seeedstudio.com/wiki/G1/2_Water_Flow_sensor
* @con gpio
* @kit eak
*
* @brief API for the Grove Water Flow Sensor
*
* This sensor is used to measure water flow in liters per
* minute (LPM). It incorporates a Hall Effect sensor. The UPM module
* defines an interrupt routine to be triggered on each low pulse,
* keeping count. This device requires a 10K pull-up resistor for
* the signal line (yellow wire). There is a schematic diagram on
* the SeeedStudio site (3/2015):
* http://www.seeedstudio.com/wiki/index.php?title=G1/2_Water_Flow_sensor
*
* However, be careful when wiring this up - the schematic appears to
* have a bug in it: the lower left connection of the signal line
* (yellow) to Vcc (red) should not be there. The sensor can work
* with this connection, but probably not for very long.
*
* @image html grovewfs.jpg
* @snippet grovewfs.cxx Interesting
*/
class GroveWFS {
public:
/**
* Grove Water Flow sensor constructor
*
* @param pin Digital pin to use
*/
GroveWFS(int pin);
/**
* GroveWFS destructor
*/
~GroveWFS();
/**
* Returns the number of milliseconds elapsed since initClock()
* was last called.
*
* @return Elapsed milliseconds
*/
uint32_t getMillis();
/**
* Resets the clock
*
*/
void initClock();
/**
* Resets the flow counter to 0. The flow counter should be
* stopped via stopFlowCounter() prior to calling this function.
*
*/
void clearFlowCounter() { m_flowCounter = 0; };
/**
* Starts the flow counter
*
*/
void startFlowCounter();
/**
* Stops the flow counter
*
*/
void stopFlowCounter();
/**
* Gets the flow counter
*
* @return Flow counter
*/
uint32_t flowCounter() { return m_flowCounter; };
/**
* Computes the flow rate in liters per minute (LPM)
*
* @return Computed flow rate
*/
float flowRate();
private:
/**
* Flow interrupt service routine (ISR)
*
*/
static void flowISR(void *ctx);
volatile uint32_t m_flowCounter;
struct timeval m_startTime;
mraa_gpio_context m_gpio;
bool m_isrInstalled;
};
}

View File

@ -1,16 +0,0 @@
%include "../common_top.i"
/* BEGIN Java syntax ------------------------------------------------------- */
#ifdef SWIGJAVA
%ignore flowISR;
JAVA_JNI_LOADLIBRARY(javaupm_grovewfs)
#endif
/* END Java syntax */
/* BEGIN Common SWIG syntax ------------------------------------------------- */
%{
#include "grovewfs.hpp"
%}
%include "grovewfs.hpp"
/* END Common SWIG syntax */

View File

@ -1,40 +0,0 @@
{
"Library": "grovewfs",
"Description": "API for the Grove Water Flow Sensor",
"Sensor Class":
{
"GroveWFS":
{
"Name": "Water Flow Sensor",
"Description": "This sensor is used to measure water flow in liters per minute (LPM). It incorporates a Hall Effect sensor. The UPM module defines an interrupt routine to be triggered on each low pulse, keeping count. This device requires a 10K pull-up resistor for the signal line (yellow wire). There is a schematic diagram on the SeeedStudio site (3/2015): http://www.seeedstudio.com/wiki/index.php?title=G1/2_Water_Flow_sensor However, be careful when wiring this up - the schematic appears to have a bug in it: the lower left connection of the signal line (yellow) to Vcc (red) should not be there. The sensor can work with this connection, but probably not for very long.",
"Aliases": ["grovewfs"],
"Categories": ["liquid", "deprecated"],
"Connections": ["gpio"],
"Project Type": ["agriculture", "monitoring", "prototyping"],
"Manufacturers": ["seeed"],
"Kits": ["eak"],
"Image": "grovewfs.jpg",
"Examples":
{
"Java": ["GroveWFS_Example.java"],
"Python": ["grovewfs.py"],
"Node.js": ["grovewfs.js"],
"C++": ["grovewfs.cxx"],
"C": []
},
"Specifications":
{
"Operating Voltage": {"unit": "V", "low": 5, "high": 24},
"Operating Current": {"unit": "mA", "typ": 15},
"Water Pressure": {"unit": "MPa", "max": 2},
"Water Temperature": {"unit": "degC", "max": 120}
},
"Urls" :
{
"Product Pages": ["https://www.seeedstudio.com/G1%26amp%3B2%26quot%3B-Water-Flow-Sensor-p-635.html"],
"Datasheets": ["http://wiki.seeedstudio.com/wiki/G1/2_Water_Flow_sensor", "http://www.seeedstudio.com/wiki/images/b/b7/Water_flow_sensor_datasheet.pdf"],
"Schematics": []
}
}
}
}