Retrasos en aplicaciones de Android GraphView en tiempo real

Estoy utilizando GraphView en Android para trazar datos en tiempo real (ECG), recibidos de Bluetooth (BLE) conectado sensor.

Después de un tiempo (5-10 seg = 500-1000 puntos) la aplicación se vuelve extremadamente lenta y laggy.

La velocidad de salida de datos del sensor es de 100 Hz y los datos se reciben y se representan tan pronto como se generan (cada 10 ms).

Como se indica en ocasiones similares, sólo conservo los datos que necesito mostrar. Traté de minimizar la vista (2 segundos = 200 puntos), probar la aplicación en diferentes dispositivos Android, pero el problema insiste. ¿Algunas ideas?

import com.jjoe64.graphview.GraphView; import com.jjoe64.graphview.series.DataPoint; import com.jjoe64.graphview.series.LineGraphSeries; import com.jjoe64.graphview.GridLabelRenderer; 

 //GraphView init static LinearLayout GraphView1; static GraphView graphView1; static LineGraphSeries<DataPoint> Series1; static LinearLayout GraphView2; static GraphView graphView2; static LineGraphSeries<DataPoint> Series2; static LinearLayout GraphView3; static GraphView graphView3; static LineGraphSeries<DataPoint> Series3; private static int Xview = 5; private static int maxpoints = 500; private static double xstep = 0.01d; private static double graph2LastXValue = 0; static boolean AutoScrollX = true; 

Inicializar Graphview para el canal 1 (init_ch2 () y init_ch3 () de forma similar):

 void init_ch1(){ GraphView1 = (LinearLayout) findViewById(R.id.Channel1); Series1 = new LineGraphSeries<DataPoint>(new DataPoint[] {new DataPoint(0, 0)}); graphView1 = new GraphView(this); graphView1.getViewport().setYAxisBoundsManual(Yview_manual); graphView1.getViewport().setMinX(0); graphView1.getViewport().setMaxX(Xview); graphView1.getViewport().setScrollable(true); graphView1.getViewport().setScalable(true); graphView1.getGridLabelRenderer().setGridStyle(GridLabelRenderer.GridStyle.BOTH); graphView1.getGridLabelRenderer().setGridColor(Color.DKGRAY); graphView1.getGridLabelRenderer().setHorizontalLabelsVisible(false); graphView1.getGridLabelRenderer().setVerticalLabelsVisible(true); graphView1.getGridLabelRenderer().setNumHorizontalLabels(6); graphView1.getGridLabelRenderer().setNumVerticalLabels(3); graphView1.getGridLabelRenderer().setVerticalLabelsColor(Color.WHITE); graphView1.getGridLabelRenderer().reloadStyles(); Series1.setThickness(6); Series1.setColor(Color.GREEN); graphView1.addSeries(Series1); // data GraphView1.addView(graphView1); } 

Llamada llamada cuando se reciben nuevos datos:

 public void updateECGCals(BluetoothGattCharacteristic characteristic) { Integer data1, data2, data3; data1 = ReceiveChannelData(characteristic, i*CH_DATA_SIZE); data2 = ReceiveChannelData(characteristic, i*CH_DATA_SIZE+3); data3 = ReceiveChannelData(characteristic, i*CH_DATA_SIZE+6); String strIncom1 = Integer.toString(data1); // create string from bytes array String strIncom2 = Integer.toString(data2); // create string from bytes array String strIncom3 = Integer.toString(data3); // create string from bytes array Series1.appendData(new DataPoint(graph2LastXValue,Double.parseDouble(strIncom1)),AutoScrollX,maxpoints); Series2.appendData(new DataPoint(graph2LastXValue,Double.parseDouble(strIncom2)),AutoScrollX,maxpoints); Series3.appendData(new DataPoint(graph2LastXValue,Double.parseDouble(strIncom3)),AutoScrollX,maxpoints); //X-axis control if (graph2LastXValue >= Xview) { Series1.resetData(new DataPoint[]{}); Series2.resetData(new DataPoint[]{}); Series3.resetData(new DataPoint[]{}); graph2LastXValue = 0; } else graph2LastXValue += xstep; graphView1.getViewport().setMinX(0); graphView1.getViewport().setMaxX(Xview); graphView2.getViewport().setMinX(0); graphView2.getViewport().setMaxX(Xview); graphView3.getViewport().setMinX(0); graphView3.getViewport().setMaxX(Xview); } private static Integer ReceiveChannelData(BluetoothGattCharacteristic c, int offset) { Integer output_code; Integer MSByte = c.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT8, offset); Integer MDByte = c.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT8, offset+1); Integer LSByte = c.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT8, offset+2); output_code = (MSByte << 16) + (MDByte << 8) + LSByte; return output_code; } 

  • Pase el objeto en el que se incrusta una clase java como parámetro
  • ¿Por qué está agregando un OnClickListener dentro onBindViewHolder de un RecyclerView.Adapter considerado mala práctica?
  • Cómo mostrar una columna de dos columnas ListView en Android?
  • Reconocimiento de imágenes - Descriptor binario representación en Mat - OpenCV Android
  • Android: ¿Dónde poner el código onCreate () de la actividad en un fragmento?
  • Tipo no coincidente: no se puede convertir de StringBuilder a String
  • Array / Lista enlazada: ¿el rendimiento depende de la * dirección * del recorrido?
  • Recibo un mensaje de error cuando ejecuto JNI android app A / libc: Señal fatal 11 (SIGSEGV) en 0xdeadd00d (código = 1), hilo 17729
  • Configuración de las reglas proguard en android, sólo puede cifrar el código?
  • Android - Creación de una imagen animada de tipo analógico para el movimiento
  • N-Puzzle pseudo-aleatorio barajar?
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.