2015-03-12 13:11:22 -04:00
|
|
|
/*
|
|
|
|
* 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>
|
|
|
|
|
|
|
|
namespace upm {
|
|
|
|
|
|
|
|
/**
|
2015-08-09 22:51:25 +03:00
|
|
|
* @brief Spectra Symbol Flex Sensor library
|
2015-03-12 13:11:22 -04:00
|
|
|
* @defgroup flex libupm-flex
|
2015-04-16 16:59:41 -07:00
|
|
|
* @ingroup sparkfun analog flexfor
|
2015-03-12 13:11:22 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @library flex
|
2015-04-09 12:56:09 -07:00
|
|
|
* @sensor flex
|
2015-06-01 15:44:07 -07:00
|
|
|
* @comname Flex Sensor
|
2015-04-16 16:59:41 -07:00
|
|
|
* @type flexfor
|
2015-04-09 12:56:09 -07:00
|
|
|
* @man sparkfun
|
2015-06-04 16:51:07 -07:00
|
|
|
* @web https://www.sparkfun.com/products/8606
|
2015-04-09 12:56:09 -07:00
|
|
|
* @con analog
|
2015-03-12 13:11:22 -04:00
|
|
|
*
|
2015-08-09 22:51:25 +03:00
|
|
|
* @brief API for the Spectra Symbol Flex Sensor
|
2015-03-12 13:11:22 -04:00
|
|
|
*
|
2015-08-09 22:51:25 +03:00
|
|
|
* A simple flex sensor. The resistance across the sensor increases when
|
|
|
|
* flexed. Patented technology by Spectra Symbol, these sensors were used in
|
|
|
|
* the original Nintendo* Power Glove.
|
2015-04-09 12:56:09 -07:00
|
|
|
*
|
2015-05-22 01:31:14 -07:00
|
|
|
* @image html flex.jpg
|
2015-08-09 22:51:25 +03:00
|
|
|
* <br><em>Flex Sensor image provided by SparkFun* under
|
2015-06-04 16:51:07 -07:00
|
|
|
* <a href=https://creativecommons.org/licenses/by-nc-sa/3.0/>
|
|
|
|
* CC BY-NC-SA-3.0</a>.</em>
|
|
|
|
*
|
2015-03-12 13:11:22 -04:00
|
|
|
* @snippet flex.cxx Interesting
|
|
|
|
*/
|
|
|
|
class Flex {
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Flex sensor constructor
|
|
|
|
*
|
2015-08-09 22:51:25 +03:00
|
|
|
* @param pin Analog pin to use
|
2015-03-12 13:11:22 -04:00
|
|
|
*/
|
|
|
|
Flex(int pin);
|
|
|
|
/**
|
2015-08-09 22:51:25 +03:00
|
|
|
* Flex sensor destructor
|
2015-03-12 13:11:22 -04:00
|
|
|
*/
|
|
|
|
~Flex();
|
|
|
|
/**
|
2015-08-09 22:51:25 +03:00
|
|
|
* @return Analog flex value
|
2015-03-12 13:11:22 -04:00
|
|
|
*/
|
|
|
|
int value();
|
|
|
|
|
|
|
|
private:
|
|
|
|
mraa_aio_context m_aio;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|