每40ms更新一次SmartEyeglass显示屏

时间:2015-08-18 12:49:14

标签: android user-interface sony-smarteyeglass

我在Sony SmartEyeglass的屏幕上创建了一个位图,如下所示:

private void updateLayout(){
    this.showBitmap(bitmap);
}

现在我想每40毫秒左右更新一次。

我尝试从另一个帖子一次又一次地调用它并添加this.clearDisplay()但它不起作用。

如何定期更新显示器?


更新

我使用了下面建议的代码。
结果:与前一个重叠的图像不会从屏幕上清除。

尝试在重绘之前添加canvas.drawRect(new Rect(0, 0, 500, 500), paint); 结果:它仍然闪烁,但现在也不会显示新图像。

有没有人对SmartEyeglass上的实时图形有任何经验。 使用不同的消息重新加载扩展名不是一个选项!

2 个答案:

答案 0 :(得分:1)

通过创建postDelayed()处理程序,您可以定期运行方法。

你的代码应该是这样的。

Handler handler = new Handler();

@Override
protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      handler.post(sendData);
}

@Override
protected void onDestroy() {
      super.onDestroy();
      handler.removeCallbacks(sendData);
}

private void updateLayout(){
    this.showBitmap(bitmap);
}


private final Runnable sendData = new Runnable(){
    public void run(){
        try {
            //your method need to call here

                    updateLayout();

            handler.postDelayed(this, 1000);  // 1000 milliseconds means 1 sec.. here you can change your time limit     
        }
        catch (Exception e) {
            e.printStackTrace();
        }   
    }
};

答案 1 :(得分:1)

而不是showBitmap使用SmartEyeglassControlUtils.showBitmapWithCallback。这样,在完成SmartEyeglass上的渲染过程后,您将收到onResultShowBitmap中的回调。

在该回调中,您可以再次致电showBitmapWithCallback,以尽快更新显示。

速度受限于连接速度所以:

  1. 考虑使用POWER_MODE_HIGH在SmartEyeglass和手机之间建立wifi连接
  2. 考虑使用showBitmapWithCallback(Bitmap bitmap, int x, int y, int transactionNumber)定义x,y位置,并仅发送需要更新的Bitmap部分。