Android Open Source - android-weather-station Sensor






From Project

Back to project page android-weather-station.

License

The source code is released under:

Apache License

If you think the Android project android-weather-station listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package de.grundid.weather.sensor;
// w  w  w. j  a  va  2 s.  c  o  m
public abstract class Sensor {

  protected final int SENSOR_TEMP = 1;
  protected final int SENSOR_FEUCHTE = 2;
  protected final int SENSOR_LUFTDRUCK = 3;
  protected final int SENSOR_HELLIGKEIT = 4;
  protected byte[] data = new byte[8];

  public Sensor(byte[] data) {
    init(data);
  }

  protected void init(byte[] data) {
    this.data[0] = data[0];
    for (int x = 1; x < 7; x++) {
      this.data[x] = (byte)(data[x] & (byte)0x7F);
    }
    this.data[7] = data[7];
  }

  public byte getStartByte() {
    return data[0];
  }

  public byte getTyp() {
    return data[1];
  }

  public byte getEndByte() {
    return data[7];
  }

  public byte getByte(int x) {
    return data[x];
  }

  public static int calc14Bit(byte b1, byte b2) {
    int data = (int)(((int)b1 << 7) | (int)b2);
    if ((data & 0x2000) == 0x2000) {
      return (data - 0x4000);
    }
    else {
      return data;
    }
  }

  @Override
  public String toString() {
    String buffer = "";
    for (int x = 0; x < 8; x++) {
      buffer += Integer.toHexString(data[x]) + " ";
    }
    return buffer;
  }
};




Java Source Code List

de.grundid.weather.Beeper.java
de.grundid.weather.Constants.java
de.grundid.weather.MainActivity.java
de.grundid.weather.SensorHandler.java
de.grundid.weather.SerialDataHandler.java
de.grundid.weather.io.AttachedDeviceHandler.java
de.grundid.weather.io.ConnectedUsbDevice.java
de.grundid.weather.io.PermissionBroadcastReceiver.java
de.grundid.weather.io.SerialReceiverListener.java
de.grundid.weather.io.SerialReceiver.java
de.grundid.weather.io.UsbConnectionException.java
de.grundid.weather.sensor.InsideSensor.java
de.grundid.weather.sensor.LightSensor.java
de.grundid.weather.sensor.OutsideSensor.java
de.grundid.weather.sensor.SensorFactory.java
de.grundid.weather.sensor.SensorListener.java
de.grundid.weather.sensor.Sensor.java
de.grundid.weather.sensor.WeatherLogger.java
de.grundid.weather.utils.Utils.java