mraa  1.8.0
Low Level Skeleton Library for Communication on GNU/Linux platforms
Public Member Functions | List of all members
Aio Class Reference

Detailed Description

This file defines the aio interface for libmraa

import mraa.Aio;
public class AioA0 {
static {
try {
System.loadLibrary("mraajava");
} catch (UnsatisfiedLinkError e) {
System.err.println(
"Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
e);
System.exit(1);
}
}
public static void main(String[] args) {
Aio a0 = new Aio(0);
for (int i = 100; i > 0; --i) {
int adc_value = a0.read();
float adc_value_float = a0.readFloat();
System.out.println(String.format("ADC A0 read %X - %d", adc_value, adc_value));
System.out.println(String.format("ADC A0 read %.5f", adc_value_float));
Thread.sleep(500);
}
}
}

Public Member Functions

synchronized void delete ()
 
 Aio (int pin)
 
long read ()
 
float readFloat ()
 
Result setBit (int bits)
 
int getBit ()
 

Constructor & Destructor Documentation

Aio ( int  pin)

Aio Constructor, takes a pin number which will map directly to the board number

Parameters
pinchannel number to read ADC inputs

Member Function Documentation

int getBit ( )

Gets the bit value mraa is shifting the analog read to.

Returns
bit value mraa is set return from the read function
long read ( )

Read a value from the AIO pin. By default mraa will shift the raw value up or down to a 10 bit value.

Exceptions
std::invalid_argumentin case of error
Returns
The current input voltage. By default, a 10bit value
float readFloat ( )

Read a value from the AIO pin and return it as a normalized float.

Exceptions
std::invalid_argumentin case of error
Returns
The current input voltage as a normalized float (0.0f-1.0f)
Result setBit ( int  bits)

Set the bit value which mraa will shift the raw reading from the ADC to. I.e. 10bits

Parameters
bitsthe bits the return from read should be i.e 10
Returns
mraa::Result type

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