public class ADC extends Object
ADC adc = new ADC(0,0); // adc channel 0 with sampling interval of 0, which disables automatic // sampling so listeners can not be used for (int i=0;i<100;i++) // take 100 samples, one every five seconds { System.out.println("\r\nSample: " + adc.getValue() + " mV"); Thread.sleep(5000*1); }
ADCListener
,
DAC
Constructor and Description |
---|
ADC(int channel,
int interval)
Creates a new instance of the ADC class.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(ADCListener listener)
Registers listeners to receive sample values.
|
void |
clearListener()
Removes all listener objects which have been previously added to the
list table of listener objects.
|
int |
getChannel()
Gets the channel.
|
int |
getInterval()
Gets the current interval.
|
int |
getValue()
Gets a single sample value.
|
void |
release()
Stops and removes the listeners and releases all HW resources.
|
void |
removeListener(ADCListener listener)
Removes a listener object which has been previously added to the internal
list table of listener objects.
|
public ADC(int channel, int interval) throws IOException
channel
- Selects the adc input channel. Valid values are 0 or 1.interval
- Sampling interval in ms with a resolution of 60/13 ms. Valid values are from 100 to 30.000
or 0 for no sampling.IOException
- if an error occursADCListener
public int getValue() throws IOException
IOException
- if an error occurspublic int getInterval()
public int getChannel()
public void addListener(ADCListener listener)
listener
- The ADCListener object to be registered.ADCListener
,
removeListener(com.cinterion.io.ADCListener)
public void removeListener(ADCListener listener)
listener
- The ADCListener object to be removed from the list.ADCListener
,
addListener(com.cinterion.io.ADCListener)
public void clearListener()
public void release() throws IOException
IOException
- if an error occursADC
Copyright (c) 1990, 2012, Oracle and/or its affiliates. All rights reserved.