distancesensor.java

来自「单片机上的java虚拟机 用winavr 编译」· Java 代码 · 共 73 行

JAVA
73
字号
package nanovm.nibo.drivers;/** * Encapsulates the information about the five * IR-reflex-sensors. You will have to call the update Method first to get * actual values. * @author Nils Springob */public class DistanceSensor {  /**   * Maximum value from IR-sensor   */  public static final int MAXIMUM = 255;    /**   * Minimum value from IR-sensor   */  public static final int MINIMUM = 0;    /**   * ID of the left IR-sensor   */  public static final int LEFT        = 4;    /**   * ID of the left front IR-sensor   */  public static final int LEFT_FRONT  = 3;    /**   * ID of the front IR-sensor   */  public static final int FRONT       = 2;    /**   * ID of the right front IR-sensor   */  public static final int RIGHT_FRONT = 1;    /**   * ID of the right IR-sensor   */  public static final int RIGHT       = 0;    /**   * update all values   */  public static native void update();    /**   * get the value of the IR-reflex-sensor with the given ID   * @param sensor ID of the IR-sensor   * @return value of the IR-sensor   */  public static native int getSensor(int sensor);  /**   * enable and disable the IR-reflex-sensors   * @param enable true to enable sensors   */  public static native void setEnabled(boolean enable);  /**   * get status of IR-reflex-sensors   * @return true when sensors are enabled   */  public static native boolean getEnabled();  }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?