Exemplo n.º 1
0
  public void onSensorChanged(SensorEvent event) {
    String valuesString = "";
    int counter = 0;
    for (float value : event.values) {
      valuesString += String.format("%d) %f ", counter++, value);
    }
    valuesString += " , " + pressureHistory.size();
    textViewPressure.setText(valuesString);

    double value = pressureSmoothingWin.push((double) event.values[0]);
    // Number[] series1Numbers = {event.values[0], event.values[1],
    // event.values[2]};
    // get rid the oldest sample in history:
    if (pressureHistory.size() > HISTORY_SIZE) {
      pressureHistory.removeFirst();
    }
    // add the latest history sample:
    pressureHistory.addLast(value); // event.values[0]);

    value = altitudeSmoothingWin.push((double) event.values[1]);
    if (altitudeHistory.size() > HISTORY_SIZE) {
      altitudeHistory.removeFirst();
    }
    altitudeHistory.addLast(value); // event.values[0]);

    value = tempSmoothingWin.push((double) event.values[2]);
    if (tempHistory.size() > HISTORY_SIZE) {
      tempHistory.removeFirst();
    }
    tempHistory.addLast(value);
    if (cooler++ % 2 == 0) return;
    // update the plot with the updated history Lists:
    if (sensorId == 0) {
      pressureHistorySeries.setModel(pressureHistory, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY);
      preHistoryPlot.setRangeLabel("Pressure (hPa)");
    } else if (sensorId == 1) {
      pressureHistorySeries.setModel(altitudeHistory, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY);
      preHistoryPlot.setRangeLabel("Altitude (m)");
    } else {
      pressureHistorySeries.setModel(tempHistory, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY);
      preHistoryPlot.setRangeLabel("Temperature (ºC)");
    }

    // redraw the Plots:
    preHistoryPlot.redraw();
  }
    private void graphLine(Number X1, Number Y1, Number X2, Number Y2, SimpleXYSeries ser) {
      LinkedList<Number> points = new LinkedList<Number>();
      points.add(X1);
      points.add(Y1);
      points.add(X2);
      points.add(Y2);

      ser.setModel(points, ArrayFormat.XY_VALS_INTERLEAVED);
    }
Exemplo n.º 3
0
 private void plotTemperatureHistory() {
   SensorHistory temperatureLongHistory =
       new SensorHistory(
           Environment.getExternalStorageDirectory().getPath() + "/Sensors/temperature.dat");
   longHistoryPlot.setRangeLabel("Temperature (ºC)");
   longHistoryPlot.getRangeLabelWidget().pack();
   longHistorySeries.setModel(temperatureLongHistory, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY);
   longHistoryPlot.redraw();
 }
Exemplo n.º 4
0
 private void plotAltitudeHistory() {
   SensorHistory altitudeLongHistory =
       new SensorHistory(
           Environment.getExternalStorageDirectory().getPath() + "/Sensors/altitude.dat");
   longHistoryPlot.setRangeLabel("Altitude (m)");
   longHistoryPlot.getRangeLabelWidget().pack();
   longHistorySeries.setModel(altitudeLongHistory, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY);
   longHistoryPlot.redraw();
 }