grove: add documentation for grove module

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Brendan Le Foll 2014-08-11 14:12:23 +01:00
parent c99821ad26
commit 00114f69d2
3 changed files with 45 additions and 2 deletions

View File

@ -29,7 +29,7 @@
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
// Use i2c device 0 all the time //! [Interesting]
upm::GroveLed* led = new upm::GroveLed(2); upm::GroveLed* led = new upm::GroveLed(2);
std::cout << led->name() << std::endl; std::cout << led->name() << std::endl;
for (int i=0; i < 10; i++) { for (int i=0; i < 10; i++) {
@ -38,6 +38,7 @@ main(int argc, char **argv)
led->off(); led->off();
sleep(1); sleep(1);
} }
//! [Interesting]
return 0; return 0;
} }

View File

@ -29,13 +29,14 @@
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
// Use i2c device 0 all the time //! [Interesting]
upm::GroveTemp* s = new upm::GroveTemp(0); upm::GroveTemp* s = new upm::GroveTemp(0);
std::cout << s->name() << std::endl; std::cout << s->name() << std::endl;
for (int i=0; i < 10; i++) { for (int i=0; i < 10; i++) {
std::cout << s->value() << std::endl; std::cout << s->value() << std::endl;
sleep(1); sleep(1);
} }
//! [Interesting]
return 0; return 0;
} }

View File

@ -40,6 +40,13 @@ class Grove {
std::string m_name; std::string m_name;
}; };
/**
* @brief C++ API for Grove LED
*
* Very basic UPM module for grove LED, or any LED for that matter
*
* @snippet groveled.cxx Interesting
*/
class GroveLed: public Grove { class GroveLed: public Grove {
public: public:
GroveLed(int pin); GroveLed(int pin);
@ -51,21 +58,55 @@ class GroveLed: public Grove {
mraa_gpio_context m_gpio; mraa_gpio_context m_gpio;
}; };
/**
* @brief C++ API for Grove Temperature sensor
*
* Very basic UPM module for grove temperature sensor on analog
*
* @snippet grovetemp.cxx Interesting
*/
class GroveTemp: public Grove { class GroveTemp: public Grove {
public: public:
GroveTemp(unsigned int pin); GroveTemp(unsigned int pin);
~GroveTemp(); ~GroveTemp();
/**
* Get raw value from AIO pin
*
* @return the raw value from the ADC
*/
float raw_value(); float raw_value();
/**
* Get the temperature from the sensor
*
* @return the normalised temperature
*/
int value(); int value();
private: private:
mraa_aio_context m_aio; mraa_aio_context m_aio;
}; };
/**
* @brief C++ API for Grove light sensor
*
* Very basic UPM module for grove Light sensor on analog
*
* @snippet grovelight.cxx Interesting
*/
class GroveLight: public Grove { class GroveLight: public Grove {
public: public:
GroveLight(unsigned int pin); GroveLight(unsigned int pin);
~GroveLight(); ~GroveLight();
/**
* Get raw value from AIO pin
*
* @return the raw value from the ADC
*/
float raw_value(); float raw_value();
/**
* Get the light value from the sensor
*
* @return the normalised light reading
*/
int value(); int value();
private: private:
mraa_aio_context m_aio; mraa_aio_context m_aio;