I wanted to plot real time data via http://www.android-graphview.org/ for data acquired in a Bluetooth thread.
Thread code:
InputStream tmpIn = mSocket.getInputStream();
while (true) {
try {
BufferedReader r = new BufferedReader(new InputStreamReader(tmpIn));
String line;
while ((line = r.readLine()) != null) {
final String tmp = line;
runOnUiThread(new Runnable() {
@Override
public void run() {
addData(Integer.parseInt(tmp));
}
});
}
} catch (IOException e) {
Log.e("BT",
"BtConnectionThread run while loop: problem reading");
e.printStackTrace();
break;
}
}
}
Activity code:
public void addData(int data){
series.appendData(new DataPoint(lastx,data),true,winSize);
lastx++;
}
This works perfectly, but gets extremely laggy over time. The BT thread receives data with 100Hz - after the first few hundred data sets the memory usage is immense and the graph begins to lag. Is there a workaround or an alternative ringbuffer implementation?
Additional i wanted to disable the x-axis legend, but couln't find any command to archive this.
Regards, Lukas