血氧資料如下圖的左欄,轉成如右欄的十六進制以便計算出所要的位元數
但範例的Uart專案檔實在是看不懂
目前有幾個問題
@Override
protected void onDataReceived(final byte[] buffer, final int size) {
runOnUiThread(new Runnable() {
String text;
public void run() {
if (mReception != null) {
mReception.append(new String(buffer,0,size));
}
}
});
}
本來理想是先在xml創好TextView,在java檔import進來
很怪異的是新增TextView就無法顯示收值
更何況抓時間、血氧值與心跳數了
因此目前先在Reception把值挑出來看看
不先另存變數
上面的程式碼,比較怪異的是---mReception.append(new String(buffer,0,size));
這個函式並不很好懂
final void append(CharSequence text)
Convenience method: Append the specified text to the TextView's display buffer, upgrading it to BufferType.EDITABLE if it was not already editable.
void append(CharSequence text, int start, int end)
Convenience method: Append the specified text slice to the TextView's display buffer, upgrading it to BufferType.EDITABLE if it was not already editable.
在android developers裡面找到這樣的說明
但跟範例檔的函式並不完全符合
這樣說好了,buffer為一個byte型態的陣列
String為一個暫存的字串,那個函式只是將0~size(最長度)的字元暫存在String
再加到mReception的後面去
但new String()這樣表示又像一個函式,也不確定是否為CharSequence?
很殘念的今天依舊沒進度,卡很久.....