11package net .sourceforge .smallbasic .ioio ;
22
3- import java .io .IOException ;
4- import java .util .concurrent .BlockingQueue ;
5- import java .util .concurrent .CountDownLatch ;
6- import java .util .concurrent .LinkedBlockingQueue ;
7-
83import ioio .lib .api .AnalogInput ;
94import ioio .lib .api .IOIO ;
105import ioio .lib .api .exception .ConnectionLostException ;
116import ioio .lib .api .exception .IncompatibilityException ;
127import ioio .lib .spi .Log ;
138
14- public class AnalogInputImpl implements AnalogInput , IOTask {
9+ import java .util .concurrent .BlockingQueue ;
10+ import java .util .concurrent .CountDownLatch ;
11+ import java .util .concurrent .LinkedBlockingQueue ;
12+
13+ public class AnalogInputImpl extends IOTask implements AnalogInput {
1514 private static final String TAG = "AnalogInput" ;
1615 private final BlockingQueue <FloatConsumer <AnalogInput >> queue = new LinkedBlockingQueue <>();
1716 private AnalogInput input ;
18- private int pin ;
1917
2018 public AnalogInputImpl () {
2119 super ();
@@ -29,7 +27,7 @@ public int available() throws ConnectionLostException {
2927
3028 @ Override
3129 public void close () {
32- IOService . getInstance (). removeTask ( this );
30+ super . close ( );
3331 input .close ();
3432 input = null ;
3533 }
@@ -64,11 +62,6 @@ public float getVoltageSync() {
6462 return invoke (AnalogInput ::getVoltageSync );
6563 }
6664
67- @ Override
68- public int getPin () {
69- return pin ;
70- }
71-
7265 @ Override
7366 public void loop () throws InterruptedException , ConnectionLostException {
7467 if (!queue .isEmpty ()) {
@@ -81,12 +74,6 @@ public void loop() throws InterruptedException, ConnectionLostException {
8174 }
8275 }
8376
84- public void open (int pin ) throws IOException {
85- Log .i (TAG , "openInput" );
86- this .pin = pin ;
87- IOService .getInstance ().addTask (this );
88- }
89-
9077 @ Override
9178 public float read () throws InterruptedException , ConnectionLostException {
9279 return invoke (AnalogInput ::read );
0 commit comments