• R/O
  • HTTP
  • SSH
  • HTTPS

BLEControl: コミット

BLE通信を行うためのアプリ。


コミットメタ情報

リビジョン3700f9888a182a701f9848cd55d5e2101379ee07 (tree)
日時2020-04-04 00:24:47
作者MRSa <mrsa@myad...>
コミッターMRSa

ログメッセージ

RAWデータ表示の準備。

変更サマリ

差分

--- a/app/src/main/java/net/osdn/gokigen/blecontrol/lib/ble/connect/eeg/MindWaveCommunication.java
+++ b/app/src/main/java/net/osdn/gokigen/blecontrol/lib/ble/connect/eeg/MindWaveCommunication.java
@@ -98,7 +98,17 @@ public class MindWaveCommunication implements BleDeviceFinder.BleScanResult
9898 return;
9999 }
100100
101- SimpleLogDumper.dump_bytes("RECV SPP : ", data);
101+ if ((data.length == 8)||(data.length == 9))
102+ {
103+ int value = ((data[5] & 0xff) * 256) + (data[6] & 0xff);
104+ if (value > 32768)
105+ {
106+ value = value - 65536;
107+ }
108+ dataReceiver.receivedRawData(value);
109+ return;
110+ }
111+ SimpleLogDumper.dump_bytes("RECV SPP [" + data.length + "] ", data);
102112 }
103113 catch (Exception e)
104114 {
@@ -175,6 +185,12 @@ public class MindWaveCommunication implements BleDeviceFinder.BleScanResult
175185 {
176186 try
177187 {
188+ if (foundDevice)
189+ {
190+ // すでに見つかっている
191+ Log.v(TAG, " ALREADY FIND.");
192+ return;
193+ }
178194 foundDevice = true;
179195 final BluetoothSocket btSocket = device.createRfcommSocketToServiceRecord(UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"));
180196 Thread thread = new Thread(new Runnable() {
--- a/app/src/main/java/net/osdn/gokigen/blecontrol/lib/data/brainwave/BrainwaveDataHolder.java
+++ b/app/src/main/java/net/osdn/gokigen/blecontrol/lib/data/brainwave/BrainwaveDataHolder.java
@@ -1,12 +1,17 @@
11 package net.osdn.gokigen.blecontrol.lib.data.brainwave;
22
3+import android.util.Log;
4+
35 import androidx.annotation.NonNull;
46
57 import net.osdn.gokigen.blecontrol.lib.ui.brainwave.IBrainwaveDataDrawer;
68
79 public class BrainwaveDataHolder implements IBrainwaveDataReceiver
810 {
11+ private final String TAG = toString();
12+
913 private final IBrainwaveDataDrawer dataDrawer;
14+ private int value;
1015
1116 public BrainwaveDataHolder(@NonNull IBrainwaveDataDrawer dataDrawer)
1217 {
@@ -14,10 +19,17 @@ public class BrainwaveDataHolder implements IBrainwaveDataReceiver
1419 }
1520
1621 @Override
17- public void receivedRawData(byte value)
22+ public void receivedRawData(int value)
1823 {
24+ Log.v(TAG, " receivedRawData() : " + value);
1925
26+ this.value = value;
2027
2128 dataDrawer.drawGraph();
2229 }
30+
31+ public int getValue()
32+ {
33+ return (value);
34+ }
2335 }
--- a/app/src/main/java/net/osdn/gokigen/blecontrol/lib/data/brainwave/IBrainwaveDataReceiver.java
+++ b/app/src/main/java/net/osdn/gokigen/blecontrol/lib/data/brainwave/IBrainwaveDataReceiver.java
@@ -2,5 +2,5 @@ package net.osdn.gokigen.blecontrol.lib.data.brainwave;
22
33 public interface IBrainwaveDataReceiver
44 {
5- void receivedRawData(byte value);
5+ void receivedRawData(int value);
66 }
--- a/app/src/main/java/net/osdn/gokigen/blecontrol/lib/ui/brainwave/BrainwaveRawGraphView.java
+++ b/app/src/main/java/net/osdn/gokigen/blecontrol/lib/ui/brainwave/BrainwaveRawGraphView.java
@@ -2,6 +2,8 @@ package net.osdn.gokigen.blecontrol.lib.ui.brainwave;
22
33 import android.content.Context;
44 import android.graphics.Canvas;
5+import android.graphics.Color;
6+import android.graphics.Paint;
57 import android.util.AttributeSet;
68 import android.util.Log;
79 import android.view.View;
@@ -37,7 +39,7 @@ public class BrainwaveRawGraphView extends View implements IBrainwaveDataDrawer
3739 {
3840 try
3941 {
40-
42+ Log.v(TAG, " initialize.");
4143 }
4244 catch (Exception e)
4345 {
@@ -63,15 +65,26 @@ public class BrainwaveRawGraphView extends View implements IBrainwaveDataDrawer
6365
6466 private void drawCanvas(Canvas canvas)
6567 {
66- //int centerX = canvas.getWidth() / 2;
67- //int centerY = canvas.getHeight() / 2;
68+ int centerX = canvas.getWidth() / 2;
69+ int centerY = canvas.getHeight() / 2;
6870
6971 Log.v(TAG, " Canvas SIZE : (" + canvas.getWidth() + "," + canvas.getHeight() +" )");
7072
7173 int rangeHeight = canvas.getHeight();
74+ int rangeWidth = canvas.getWidth();
7275
7376 // Clears the canvas.
7477 canvas.drawARGB(255, 0, 0, 0);
78+
79+ // 背景真ん中のライン
80+ Paint bgLine = new Paint();
81+ bgLine.setColor(Color.DKGRAY);
82+ canvas.drawLine(0, centerY, rangeWidth, centerY, bgLine);
83+
84+
85+ Paint paint = new Paint();
86+ paint.setColor(Color.WHITE);
87+ canvas.drawText("[" + dataHolder.getValue() + "]", centerX, centerY, paint);
7588 }
7689
7790
@@ -80,6 +93,9 @@ public class BrainwaveRawGraphView extends View implements IBrainwaveDataDrawer
8093 */
8194 private void drawInformationMessages(Canvas canvas)
8295 {
96+ Paint paint = new Paint();
97+ paint.setColor(Color.DKGRAY);
98+ canvas.drawText("[" + canvas.getWidth() + "," + canvas.getHeight() + "]", 20, 20, paint);
8399
84100 }
85101
--- a/build.gradle
+++ b/build.gradle
@@ -7,7 +7,7 @@ buildscript {
77
88 }
99 dependencies {
10- classpath 'com.android.tools.build:gradle:3.6.1'
10+ classpath 'com.android.tools.build:gradle:3.6.2'
1111
1212 // NOTE: Do not place your application dependencies here; they belong
1313 // in the individual module build.gradle files
旧リポジトリブラウザで表示