GPIO pins
Hi, i am trying to add in 2 more GPIO pins but couldnt get the data. Ive tried to change the code to read 2 more gpio pins and expand the save data, but i only get one line and it is not a straight line. It has many oscillations and it runs very fast.
Save Data:
protected String saveData() {
final String CSV_HEADER = String.format("time,adc0,adc1,adc2%n");
String filename = String.format("%s_%tY%<tm%<td-%<tH%<tM%<tS%<tL.csv", getContext().getString(sensorResId), Calendar.getInstance());
try {
FileOutputStream fos = getActivity().openFileOutput(filename, Context.MODE_PRIVATE);
fos.write(CSV_HEADER.getBytes());
LineData data = chart.getLineData();
LineDataSet gpio0DataSet = data.getDataSetByIndex(0), gpio1DataSet = data.getDataSetByIndex(1), gpio2DataSet = data.getDataSetByIndex(2);
for (int i = 0; i < data.getXValCount(); i++) {
fos.write(String.format("%.3f,%.3f,%.3f,%.3f%n", i * samplingPeriod,
gpio0DataSet.getEntryForXIndex(i).getVal(),
gpio1DataSet.getEntryForXIndex(i).getVal(),
gpio2DataSet.getEntryForXIndex(i)).getBytes());
}
fos.close();
return filename;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
This discussion has been closed.
Comments