upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Public Member Functions

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

Detailed Description

Basic UPM module for the 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.

rotary.jpg
// Instantiate a rotary sensor on analog pin A0
upm::Rotary knob(0);
// 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);
upm_delay_us(2500000); // Sleep for 2.5s
}

Public Member Functions

 Rotary (unsigned int pin)
 
 ~Rotary ()
 
float abs_value ()
 
float abs_deg ()
 
float abs_rad ()
 
float rel_value ()
 
float rel_deg ()
 
float rel_rad ()
 
std::string name ()
 

Constructor & Destructor Documentation

Rotary ( unsigned int  pin)

Rotary angle sensor constructor

Parameters
pinNumber of the analog pin to use
~Rotary ( )

Rotary 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:


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