upm  0.5.1
Sensor/Actuator repository for libmraa (v0.9.1)
 All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups Pages
Public Member Functions
GroveRotary Class Reference

API for the Grove Rotary Angle Sensor (Knob) More...

Detailed Description

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 range.

// Instantiate a rotary sensor on analog pin A0
// Print sensor name to confirm it initialized properly
cout << knob->name() << endl;
while(true) {
float abs_value = knob->abs_value(); // Absolute raw value
float abs_deg = knob->abs_deg(); // Absolute degrees
float abs_rad = knob->abs_rad(); // Absolute radians
float rel_value = knob->rel_value(); // Relative raw value
float rel_deg = knob->rel_deg(); // Relative degrees
float rel_rad = knob->rel_rad(); // Relative radians
fprintf(stdout, "Absolute: %4d raw %5.2f deg = %3.2f rad Relative: %4d raw %5.2f deg %3.2f rad\n",
(int16_t)abs_value, abs_deg, abs_rad, (int16_t)rel_value, rel_deg, rel_rad);
usleep(2500000); // Sleep for 2.5s
}
groverotary.jpeg

Public Member Functions

 GroveRotary (unsigned int pin)
 
 ~GroveRotary ()
 
float abs_value ()
 
float abs_deg ()
 
float abs_rad ()
 
float rel_value ()
 
float rel_deg ()
 
float rel_rad ()
 
- Public Member Functions inherited from Grove
std::string name ()
 

Additional Inherited Members

- Protected Attributes inherited from Grove
std::string m_name
 

Constructor & Destructor Documentation

GroveRotary ( unsigned int  pin)

Grove rotary angle sensor constructor

Parameters
pinNumber of the analog pin to use

GroveRotary destructor

Member Function Documentation

float abs_value ( )

Gets the absolute raw value from the AIO pin

Returns
Unsigned value from the ADC

Here is the caller graph for this function:

float abs_deg ( )

Gets absolute raw degrees from the AIO pin

Returns
Unsigned degrees from the ADC

Here is the call graph for this function:

Here is the caller graph for this function:

float abs_rad ( )

Gets absolute raw radians from the AIO pin

Returns
Unsigned radians from the ADC

Here is the call graph for this function:

float rel_value ( )

Gets the relative value from the AIO pin

Returns
Signed value from the ADC

Here is the call graph for this function:

Here is the caller graph for this function:

float rel_deg ( )

Gets relative degrees from the AIO pin

Returns
Signed degrees from the ADC

Here is the call graph for this function:

Here is the caller graph for this function:

float rel_rad ( )

Gets relative radians from the AIO pin

Returns
Signed radians from the ADC

Here is the call graph for this function:

Inheritance diagram for GroveRotary:
Inheritance graph
[legend]
Collaboration diagram for GroveRotary:
Collaboration graph
[legend]

The documentation for this class was generated from the following files: