upm  0.3.1
Sensor/Actuator repository for libmraa (v0.7.2)
Public Member Functions

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

Detailed Description

Very basic UPM module for Grove rotary angle sensor (knob) on analog. Provides a set of functions to read the absolute pin value, degrees or radians and another to do the same relative to the center of the knob's 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 analog pin to use

GroveRotary Destructor

Member Function Documentation

float abs_value ( )

Get absolute raw value from AIO pin

Returns
the unsigned value from the ADC

Here is the caller graph for this function:

float abs_deg ( )

Get absolute raw degrees from AIO pin

Returns
the unsigned degrees from the ADC

Here is the call graph for this function:

Here is the caller graph for this function:

float abs_rad ( )

Get absolute raw radians from AIO pin

Returns
the unsigned radians from the ADC

Here is the call graph for this function:

float rel_value ( )

Get the relative value from the pin

Returns
the signed value from the ADC

Here is the call graph for this function:

Here is the caller graph for this function:

float rel_deg ( )

Get relative degrees from AIO pin

Returns
the signed degrees from the ADC

Here is the call graph for this function:

Here is the caller graph for this function:

float rel_rad ( )

Get relative radians from AIO pin

Returns
the 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: