在图上绘制 BLE 实时数据

问题描述

我收到了实时 BLE 数据,我想在图表上显示数据。这是我的代码

@Override
protected void onResume() {
    super.onResume();
    registerReceiver(mGattUpdateReceiver,makeGattUpdateIntentFilter());
    if (mBluetoothLeService != null) {
        boolean result = mBluetoothLeService.connect(mDeviceAddress0,0);
        boolean result1 = mBluetoothLeService.connect(mDeviceAddress1,1);
    }

    
    // The Runnable interface should be implemented by any class whose instances are intended
    // to be executed by a thread. The class must define a method of no arguments called run.
    mTimer = new Runnable()
    {
        @Override
        public void run()
        {
            graphLastXValue += 1.0;
            mSeries0.appendData(new DataPoint(graphLastXValue,getDeviceData0()),true,150);
            mSeries1.appendData(new DataPoint(graphLastXValue,getDeviceData1()),150);
            mHandler.postDelayed(this,1);
        }
    };
    mHandler.postDelayed(mTimer,100);
}

我的问题是:

  1. 代码中2个postDelayed()的函数分别是什么?在我的代码中,我总共延迟了 200 毫秒,对吗?

  2. 如何在新数据到达后立即将新的 BLE 数据添加到图表中,而不是使用固定时间段 postdelay(),好吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)