0f0a10bae75c3d74e962ebe39c87edac35385ddc
[des2015.git] / mart / ev3 / ex2 / nl / ru / des / sensors / UltraSoneSensor.java
1 package nl.ru.des.sensors;
2
3 import lejos.hardware.Button;
4 import lejos.hardware.sensor.EV3UltrasonicSensor;
5 import nl.ru.des.LCDPrinter;
6
7 public class UltraSoneSensor extends SuperSensor {
8 private float limit;
9
10 public UltraSoneSensor(EV3UltrasonicSensor ultraSone) {
11 super(ultraSone.getDistanceMode());
12 calibrate();
13 }
14
15 private void calibrate(){
16 LCDPrinter.print("Calibrate ultrasone, place object in the turn radius...");
17 Button.waitForAnyPress();
18 fetchSample(true);
19 limit = samples[0];
20 LCDPrinter.print("Limit: " + limit);
21 }
22
23 public boolean getCurrentStatus(){
24 fetchSample();
25 return samples[0]<limit;
26 }
27 }