• R/O
  • HTTP
  • SSH
  • HTTPS

BLEControl: コミット

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


コミットメタ情報

リビジョン196eef4f1f1bdfe76ed531cf5e2aaa6fdba19e24 (tree)
日時2020-04-03 00:20:30
作者MRSa <mrsa@myad...>
コミッターMRSa

ログメッセージ

グラフを描く準備まで。

変更サマリ

差分

--- 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
@@ -12,6 +12,7 @@ import net.osdn.gokigen.blecontrol.lib.SimpleLogDumper;
1212 import net.osdn.gokigen.blecontrol.lib.ble.R;
1313 import net.osdn.gokigen.blecontrol.lib.ble.connect.BleDeviceFinder;
1414 import net.osdn.gokigen.blecontrol.lib.ble.connect.ITextDataUpdater;
15+import net.osdn.gokigen.blecontrol.lib.data.brainwave.IBrainwaveDataReceiver;
1516
1617 import java.io.ByteArrayOutputStream;
1718 import java.io.InputStream;
@@ -24,13 +25,15 @@ public class MindWaveCommunication implements BleDeviceFinder.BleScanResult
2425
2526 private final FragmentActivity context;
2627 private final ITextDataUpdater dataUpdater;
28+ private final IBrainwaveDataReceiver dataReceiver;
2729 private BleDeviceFinder deviceFinder = null;
2830 private boolean foundDevice = false;
2931
30- public MindWaveCommunication(@NonNull FragmentActivity context, @NonNull ITextDataUpdater dataUpdater)
32+ public MindWaveCommunication(@NonNull FragmentActivity context, @NonNull ITextDataUpdater dataUpdater, @NonNull IBrainwaveDataReceiver dataReceiver)
3133 {
3234 this.context = context;
3335 this.dataUpdater = dataUpdater;
36+ this.dataReceiver = dataReceiver;
3437 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
3538 {
3639 this.deviceFinder = new BleDeviceFinder(context, dataUpdater, this);
--- /dev/null
+++ b/app/src/main/java/net/osdn/gokigen/blecontrol/lib/data/brainwave/BrainwaveDataHolder.java
@@ -0,0 +1,23 @@
1+package net.osdn.gokigen.blecontrol.lib.data.brainwave;
2+
3+import androidx.annotation.NonNull;
4+
5+import net.osdn.gokigen.blecontrol.lib.ui.brainwave.IBrainwaveDataDrawer;
6+
7+public class BrainwaveDataHolder implements IBrainwaveDataReceiver
8+{
9+ private final IBrainwaveDataDrawer dataDrawer;
10+
11+ public BrainwaveDataHolder(@NonNull IBrainwaveDataDrawer dataDrawer)
12+ {
13+ this.dataDrawer = dataDrawer;
14+ }
15+
16+ @Override
17+ public void receivedRawData(byte value)
18+ {
19+
20+
21+ dataDrawer.drawGraph();
22+ }
23+}
--- /dev/null
+++ b/app/src/main/java/net/osdn/gokigen/blecontrol/lib/data/brainwave/IBrainwaveDataReceiver.java
@@ -0,0 +1,6 @@
1+package net.osdn.gokigen.blecontrol.lib.data.brainwave;
2+
3+public interface IBrainwaveDataReceiver
4+{
5+ void receivedRawData(byte value);
6+}
--- a/app/src/main/java/net/osdn/gokigen/blecontrol/lib/ui/brainwave/BrainwaveConnection.java
+++ b/app/src/main/java/net/osdn/gokigen/blecontrol/lib/ui/brainwave/BrainwaveConnection.java
@@ -11,6 +11,7 @@ import androidx.fragment.app.FragmentActivity;
1111 import net.osdn.gokigen.blecontrol.lib.ble.R;
1212 import net.osdn.gokigen.blecontrol.lib.ble.connect.ITextDataUpdater;
1313 import net.osdn.gokigen.blecontrol.lib.ble.connect.eeg.MindWaveCommunication;
14+import net.osdn.gokigen.blecontrol.lib.data.brainwave.IBrainwaveDataReceiver;
1415 import net.osdn.gokigen.blecontrol.lib.ui.SnackBarMessage;
1516
1617 public class BrainwaveConnection implements View.OnClickListener, ITextDataUpdater
@@ -22,12 +23,12 @@ public class BrainwaveConnection implements View.OnClickListener, ITextDataUpdat
2223 private final MindWaveCommunication communicator;
2324 private final SnackBarMessage messageToShow;
2425
25- BrainwaveConnection(@NonNull FragmentActivity context, @NonNull SelectDevice deviceSelection, @NonNull BrainwaveMobileViewModel viewModel)
26+ BrainwaveConnection(@NonNull FragmentActivity context, @NonNull SelectDevice deviceSelection, @NonNull BrainwaveMobileViewModel viewModel, @NonNull IBrainwaveDataReceiver dataReceiver)
2627 {
2728 this.context = context;
2829 this.deviceSelection = deviceSelection;
2930 this.viewModel = viewModel;
30- this.communicator = new MindWaveCommunication(context, this);
31+ this.communicator = new MindWaveCommunication(context, this, dataReceiver);
3132 this.messageToShow = new SnackBarMessage(context, false);
3233 }
3334
--- a/app/src/main/java/net/osdn/gokigen/blecontrol/lib/ui/brainwave/BrainwaveMobileFragment.java
+++ b/app/src/main/java/net/osdn/gokigen/blecontrol/lib/ui/brainwave/BrainwaveMobileFragment.java
@@ -21,6 +21,7 @@ import androidx.lifecycle.ViewModelProviders;
2121
2222 import net.osdn.gokigen.blecontrol.lib.ble.MyBleAdapter;
2323 import net.osdn.gokigen.blecontrol.lib.ble.R;
24+import net.osdn.gokigen.blecontrol.lib.data.brainwave.BrainwaveDataHolder;
2425
2526 import java.util.List;
2627
@@ -28,12 +29,16 @@ public class BrainwaveMobileFragment extends Fragment implements BrainwaveConnec
2829 {
2930 private final String TAG = toString();
3031 private List<String> bondedDeviceList = null;
32+ private BrainwaveDataHolder dataHolder = null;
3133 private int selectedDevicePosition = 0;
3234
3335 public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
3436 {
3537 final BrainwaveMobileViewModel brainwaveViewModel = ViewModelProviders.of(this).get(BrainwaveMobileViewModel.class);
3638 View root = inflater.inflate(R.layout.fragment_brainwave, container, false);
39+ final BrainwaveRawGraphView cameraLiveImageView = root.findViewById(R.id.cameraLiveImageView);
40+ dataHolder = new BrainwaveDataHolder(cameraLiveImageView);
41+ cameraLiveImageView.setDataHolder(dataHolder);
3742 final TextView textView = root.findViewById(R.id.text_brainwave);
3843 brainwaveViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
3944 @Override
@@ -50,7 +55,7 @@ public class BrainwaveMobileFragment extends Fragment implements BrainwaveConnec
5055 prepareDeviceSelection(context, root);
5156
5257 // Connect Button
53- final BrainwaveConnection eegConnection = new BrainwaveConnection(context, this, brainwaveViewModel);
58+ final BrainwaveConnection eegConnection = new BrainwaveConnection(context, this, brainwaveViewModel, dataHolder);
5459 final Button queryButton = root.findViewById(R.id.connect_to_eeg);
5560 if (queryButton != null)
5661 {
--- 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
@@ -8,9 +8,12 @@ import android.view.View;
88
99 import androidx.annotation.NonNull;
1010
11-public class BrainwaveRawGraphView extends View
11+import net.osdn.gokigen.blecontrol.lib.data.brainwave.BrainwaveDataHolder;
12+
13+public class BrainwaveRawGraphView extends View implements IBrainwaveDataDrawer
1214 {
1315 private final String TAG = this.toString();
16+ private BrainwaveDataHolder dataHolder = null;
1417
1518 public BrainwaveRawGraphView(@NonNull Context context)
1619 {
@@ -50,8 +53,11 @@ public class BrainwaveRawGraphView extends View
5053
5154 // Show Message(Overwrite)
5255 drawInformationMessages(canvas);
56+ }
5357
54-
58+ public void setDataHolder(BrainwaveDataHolder dataHolder)
59+ {
60+ this.dataHolder = dataHolder;
5561 }
5662
5763
@@ -62,6 +68,8 @@ public class BrainwaveRawGraphView extends View
6268
6369 Log.v(TAG, " Canvas SIZE : (" + canvas.getWidth() + "," + canvas.getHeight() +" )");
6470
71+ int rangeHeight = canvas.getHeight();
72+
6573 // Clears the canvas.
6674 canvas.drawARGB(255, 0, 0, 0);
6775 }
@@ -75,5 +83,10 @@ public class BrainwaveRawGraphView extends View
7583
7684 }
7785
86+ @Override
87+ public void drawGraph()
88+ {
89+ postInvalidate();
90+ }
7891 }
7992
--- /dev/null
+++ b/app/src/main/java/net/osdn/gokigen/blecontrol/lib/ui/brainwave/IBrainwaveDataDrawer.java
@@ -0,0 +1,7 @@
1+package net.osdn.gokigen.blecontrol.lib.ui.brainwave;
2+
3+public interface IBrainwaveDataDrawer
4+{
5+ void drawGraph();
6+
7+}
旧リポジトリブラウザで表示