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.
- El proveedor de ubicación fusionado no obtiene ubicación a menos que GPS esté activado
- NFC no puede enviar datos de Android 4.0.3
- Android Múltiples secuencias de clics en textview
- Reconocimiento de voz Java como androides
- Diseño lib - CoordinatorLayout / CollapsingToolbarLayout con GridView / listView
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; }
- Error de solicitud de HTTP POST de Android: error de socket EACCES (Permiso denegado)
- No se puede iniciar la actividad ComponentInfo {com.example.countryselect / com.example.countryselect.OfferSelect}
- Cómo obtener el objeto Mat desde el byte en openCV android?
- OutOfMemoryError crear bitmaps
- ¿Por qué HttpUrlConnection está lanzando una SSLException mientras está en una conexión de datos móvil?
- Libstreaming: utilice VLC como cliente RTSP
- Cómo convertir valores de cadena a lista de matriz de entero - Android
- Recicle el mapa de bits de ImageView
- Android: Error al usar el mapa de bits para mostrar la imagen usando el estudio de Android
- Vinculación a bibliotecas preconfiguradas con NDK usando gradle