mirror of
https://github.com/eclipse/upm.git
synced 2025-07-01 01:11:10 +03:00
hcsr04: Made ISR be used internally and not be exposed to the user. Changed access modifier to private. Removed passing ISR to constructor.
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com> Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:

committed by
Mihai Tudor Panu

parent
e54f5e21c3
commit
1accafa145
@ -22,8 +22,6 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import upm_hcsr04.IsrCallback;
|
||||
|
||||
//NOT TESTED!!!
|
||||
public class HCSR04Sample {
|
||||
|
||||
@ -38,10 +36,8 @@ public class HCSR04Sample {
|
||||
|
||||
// ! [Interesting]
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
HCSR04ISR callback = new HCSR04ISR();
|
||||
upm_hcsr04.HCSR04 sonar = new upm_hcsr04.HCSR04((short) 5, (short) 6);
|
||||
|
||||
upm_hcsr04.HCSR04 sonar = new upm_hcsr04.HCSR04((short) 5, (short) 6, callback);
|
||||
callback.setSonar(sonar);
|
||||
Thread.sleep(1000);
|
||||
|
||||
while (true) {
|
||||
@ -53,24 +49,4 @@ public class HCSR04Sample {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class HCSR04ISR extends IsrCallback {
|
||||
|
||||
private upm_hcsr04.HCSR04 sonar = null;
|
||||
|
||||
public HCSR04ISR() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void setSonar(upm_hcsr04.HCSR04 sonar) {
|
||||
this.sonar = sonar;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
if (sonar != null)
|
||||
sonar.ackEdgeDetected();
|
||||
else
|
||||
System.out.println("No HCSR04ISR instance given to callback");
|
||||
}
|
||||
}
|
||||
// ! [Interesting]
|
Reference in New Issue
Block a user