The ADCListener interface defines the capabilities for receiving
measured values from the ADC hardware interfaces. When the user wants to
receive these values, an implementation class for ADCListener
interface must be created first.
The adcValues method of this class must contain the processing code for
the adc voltage values. This code shall leave the listener context as soon as possible
(i.e. running a new thread). While the callback method does not return
it cannot be called again if new values are available, so some samples may be discarded.
After creating an instance of the ADCListener class, this class
instance has to be passed as a parameter to the ADC.addListener
method. After that, the callback methods will be called by the runtime
system at the intervals in which new samples are available, but not faster as
every second. If the sampling interval is faster multiple values come with one callback.
Example
ADC adc = new ADC(0,100); // sampling interval of 100ms will give you around 10
// sample values in one callback
Listener listener = new Listener();
adc.addListener(listener);
....
class Listener implements ADCListener {
public void adcValues(int[] values) {
System.out.println("\r\nListener: number of vals " + values.length);
for(int i=0; i<values.length; i++)
{
System.out.println("\r\n"+ i +"value is " + values[i] + " mV");
}
}
}