微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在图上绘制 BLE 实时数据

如何解决在图上绘制 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 举报,一经查实,本站将立刻删除。