upm  0.4.1
Sensor/Actuator repository for libmraa (v0.8.0)
Public Member Functions | List of all members

API for the A110X Hall Effect sensors. More...

Detailed Description

UPM module for the A110X (A1101, A1102, A1103, A1104, and A1106) Hall Effect sensors. It outputs a digital signal indicating whether it is detecting a magnetic field with south polarity perpendicular to the sensor element.

a110x.jpg

An example showing a simple test for the presence of a field

// Instantiate an A110X sensor on digital pin D2
upm_a110x.A110X hall = new upm_a110x.A110X(2);
// check every second for the presence of a magnetic field (south polarity)
while(true){
if(hall.magnetDetected())
System.out.println("Magnet (south polarity) detected.");
else
System.out.println("No magnet detected.");
Thread.sleep(1000);
}

An example demonstrating the use of an interrupt handler to count pulses

// Instantiate an A110X sensor on digital pin D2
upm_a110x.A110X hall = new upm_a110x.A110X(2);
// This example uses a user-supplied interrupt handler to count
// pulses that occur when a magnetic field of the correct polarity
// is detected. This could be used to measure the rotations per
// minute (RPM) of a rotor for example.
IsrCallback callback = new A110XISR();
hall.installISR(callback);
while(true){
System.out.println("Counter: " + counter);
Thread.sleep(1000);
}

Public Member Functions

synchronized void delete ()
 
 A110X (int pin)
 
boolean magnetDetected ()
 
void installISR (IsrCallback cb)
 
void uninstallISR ()
 

Constructor & Destructor Documentation

A110X ( int  pin)

A110x digital sensor constructor

Parameters
pinDigital pin to use

Member Function Documentation

void installISR ( IsrCallback  cb)

Installs an interrupt service routine (ISR) to be called when the appropriate magnetic field is detected

Parameters
fptrPointer to a function to be called on interrupt
argPointer to an object to be supplied as an argument to the ISR.
boolean magnetDetected ( )

Determines whether a magnetic field of south polarity has been detected

Returns
True if magnetic field detected
void uninstallISR ( )

Uninstalls the previously installed ISR


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