Android 如何将arduino的串行通信与平板电脑的垂直刷新同步?

Android 如何将arduino的串行通信与平板电脑的垂直刷新同步?,android,bluetooth,arduino,serial-port,Android,Bluetooth,Arduino,Serial Port,我正在尝试将android平板电脑(android 6.0棉花糖)和arduino(Mega 2560)之间的串行通信(通过蓝牙)与平板电脑的垂直刷新同步。我一直在使用Choreographer()来控制显示更新的时间,但是串行通信没有同步到显示更新(它是可变的) 有人知道怎么做吗?我已经从我的应用程序中包含了android代码的相关部分 public void armVSyncHandler() { if(!frameCallbackPending) { frameCa

我正在尝试将android平板电脑(android 6.0棉花糖)和arduino(Mega 2560)之间的串行通信(通过蓝牙)与平板电脑的垂直刷新同步。我一直在使用Choreographer()来控制显示更新的时间,但是串行通信没有同步到显示更新(它是可变的)

有人知道怎么做吗?我已经从我的应用程序中包含了android代码的相关部分

public void armVSyncHandler() {
    if(!frameCallbackPending) {
        frameCallbackPending = true;
        if(frameCallback == null)
        {
            frameCallback = new Choreographer.FrameCallback() {
                @Override
                public void doFrame(long frameTimeNanos) {
                    frameCallbackPending = false;

                    if (blackView.getVisibility() == View.INVISIBLE) {
                        blackView.setVisibility(View.VISIBLE);
                    } else {
                        blackView.setVisibility(View.INVISIBLE);
                    }
                    armVSyncStrobe();                    
                }
            };
        }
        Choreographer.getInstance().postFrameCallback(frameCallback);
    }
}

public void armVSyncStrobe() {
    if(!frameCallbackPendingS) {
        frameCallbackPendingS = true;
        if (frameCallbackS == null)
        {
            frameCallbackS = new Choreographer.FrameCallback() {
                @Override
                public void doFrame(long frameTimeNanos) {
                    frameCallbackPendingS = false;

                    String strobe = getBinaryTime();
                    try {
                        sendData(strobe);
                        Log.d(TAG,"data sent");
                        timeRecordDb.insertData(strobe, "receive: "+tvReceived.getText());
                    }
                    catch (IOException ex) {
                        Log.d(TAG, "data not sent");
                    }
                }
            };
        }
        Choreographer.getInstance().postFrameCallback(frameCallbackS);
    }
}

 public void sendData(String msg) throws IOException
    {
    try {
        mmOutputStream = mmSocket.getOutputStream();
    } catch (IOException e) {}

    msg += "\n";
    mmOutputStream.write(msg.getBytes());
}