From 8cc39eafa30be353de6a550373be657f9c0d1003 Mon Sep 17 00:00:00 2001 From: MRSa Date: Tue, 16 Feb 2021 23:41:17 +0900 Subject: [PATCH] =?utf8?q?LED=E3=81=AE=E5=88=B6=E5=BE=A1=E9=83=A8=E5=88=86?= =?utf8?q?=E3=82=92=E4=BD=9C=E3=82=8A=E3=81=93=E3=81=BF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../gokigen/thetathoughtshutter/MainActivity.kt | 108 +++++++++------------ .../theta/ThetaHardwearControl.kt | 11 ++- 2 files changed, 58 insertions(+), 61 deletions(-) diff --git a/app/src/main/java/jp/osdn/gokigen/thetathoughtshutter/MainActivity.kt b/app/src/main/java/jp/osdn/gokigen/thetathoughtshutter/MainActivity.kt index bb4035d..cd793b4 100644 --- a/app/src/main/java/jp/osdn/gokigen/thetathoughtshutter/MainActivity.kt +++ b/app/src/main/java/jp/osdn/gokigen/thetathoughtshutter/MainActivity.kt @@ -1,6 +1,7 @@ package jp.osdn.gokigen.thetathoughtshutter import android.os.Bundle +import android.util.Log import android.view.KeyEvent import com.theta360.pluginlibrary.activity.PluginActivity import com.theta360.pluginlibrary.callback.KeyCallback @@ -16,6 +17,11 @@ class MainActivity : PluginActivity() private val thetaHardwareControl = ThetaHardwareControl(this) private val applicationStatus : MyApplicationStatus = MyApplicationStatus() + companion object + { + private val TAG = MainActivity::class.java.simpleName + } + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -26,39 +32,27 @@ class MainActivity : PluginActivity() setKeyCallback(object : KeyCallback { override fun onKeyDown(keyCode: Int, event: KeyEvent?) { -/* - if (keyCode == KeyReceiver.KEYCODE_MEDIA_RECORD) // Modeボタン - { - - } - if (keyCode == KeyReceiver.KEYCODE_CAMERA) // Shutterボタン - { - - } - if (keyCode == KeyReceiver.KEYCODE_FUNCTION) // Fnボタン (Z1のみ) - { - } - if (keyCode == KeyReceiver.KEYCODE_WLAN_ON_OFF) // Wirelessボタン - { - - } -*/ } override fun onKeyUp(keyCode: Int, event: KeyEvent?) { if (keyCode == KeyReceiver.KEYCODE_CAMERA) // Shutterボタン { - if (applicationStatus.status == MyApplicationStatus.Status.Connected) + when (applicationStatus.status) { - // EEGからの情報を取得して撮影する - applicationStatus.status = MyApplicationStatus.Status.Scanning - } - else if (applicationStatus.status == MyApplicationStatus.Status.Scanning) - { - // スタンバイ状態に戻す - applicationStatus.status = MyApplicationStatus.Status.Connected + MyApplicationStatus.Status.Connected -> { + // EEGからの情報を取得して撮影する + applicationStatus.status = MyApplicationStatus.Status.Scanning + } + MyApplicationStatus.Status.Scanning -> { + // スタンバイ状態に戻す + applicationStatus.status = MyApplicationStatus.Status.Connected + } + else -> { + // ダミー処理 (仮にEEG接続失敗のステータスにする) + applicationStatus.status = MyApplicationStatus.Status.FailedInitialize + } } } if (keyCode == KeyReceiver.KEYCODE_WLAN_ON_OFF) // Wirelessボタン @@ -69,21 +63,6 @@ class MainActivity : PluginActivity() applicationStatus.status = MyApplicationStatus.Status.Searching } } -/* - if (keyCode == KeyReceiver.KEYCODE_MEDIA_RECORD) // Modeボタン - { - - } - if (keyCode == KeyReceiver.KEYCODE_FUNCTION) // Fnボタン (Z1のみ) - { - - } -*/ - updateStatus(applicationStatus.status) - } - - override fun onKeyLongPress(keyCode: Int, event: KeyEvent?) - { if (keyCode == KeyReceiver.KEYCODE_MEDIA_RECORD) // Modeボタン { if (applicationStatus.status == MyApplicationStatus.Status.Searching) @@ -98,22 +77,20 @@ class MainActivity : PluginActivity() } } /* - if (keyCode == KeyReceiver.KEYCODE_CAMERA) // Shutterボタン - { - - } if (keyCode == KeyReceiver.KEYCODE_FUNCTION) // Fnボタン (Z1のみ) { } - if (keyCode == KeyReceiver.KEYCODE_WLAN_ON_OFF) // Wirelessボタン - { - - } */ updateStatus(applicationStatus.status) } + + override fun onKeyLongPress(keyCode: Int, event: KeyEvent?) + { + + } }) + updateStatus(applicationStatus.status) } private fun updateStatus(currentStatus : MyApplicationStatus.Status) @@ -122,28 +99,39 @@ class MainActivity : PluginActivity() { when (currentStatus) { MyApplicationStatus.Status.Initialized -> { - thetaHardwareControl.controlLED(LedTarget.LED3, 1500, LedColor.BLUE) - thetaHardwareControl.controlLED(LedTarget.LED7, 0, LedColor.BLUE) + Log.v(TAG, " INITIALIZED") + thetaHardwareControl.controlLED(LedTarget.LED3, 1500, LedColor.GREEN) // WIFIランプ + thetaHardwareControl.controlLED(LedTarget.LED6, -1, LedColor.BLUE) // Liveランプ (OFF) + thetaHardwareControl.controlLED(LedTarget.LED7, -1, LedColor.RED) // 赤ランプ } MyApplicationStatus.Status.Searching -> { - thetaHardwareControl.controlLED(LedTarget.LED3, 250, LedColor.BLUE) - thetaHardwareControl.controlLED(LedTarget.LED7, 0, LedColor.BLUE) + Log.v(TAG, " SEARCHING") + thetaHardwareControl.controlLED(LedTarget.LED3, 250, LedColor.GREEN) // WIFIランプ + thetaHardwareControl.controlLED(LedTarget.LED7, -1, LedColor.RED) // 赤ランプ } MyApplicationStatus.Status.Connected -> { - thetaHardwareControl.controlLED(LedTarget.LED3, 1, LedColor.BLUE) - thetaHardwareControl.controlLED(LedTarget.LED7, 0, LedColor.BLUE) + Log.v(TAG, " CONNECTED") + thetaHardwareControl.controlLED(LedTarget.LED3, 0, LedColor.GREEN) // WIFIランプ + thetaHardwareControl.controlLED(LedTarget.LED7, -1, LedColor.RED) // 赤ランプ } MyApplicationStatus.Status.Scanning -> { - thetaHardwareControl.controlLED(LedTarget.LED3, 1, LedColor.BLUE) - thetaHardwareControl.controlLED(LedTarget.LED7, 1, LedColor.BLUE) + Log.v(TAG, " SCANNING") + thetaHardwareControl.controlLED(LedTarget.LED3, 0, LedColor.GREEN) // WIFIランプ + thetaHardwareControl.controlLED(LedTarget.LED7, 0, LedColor.RED) // 赤ランプ } MyApplicationStatus.Status.FailedInitialize -> { - thetaHardwareControl.controlLED(LedTarget.LED3, 250, LedColor.RED) - thetaHardwareControl.controlLED(LedTarget.LED7, 0, LedColor.BLUE) + Log.v(TAG, " FAILED INITIALIZE") + thetaHardwareControl.controlLED(LedTarget.LED3, 250, LedColor.GREEN) // WIFIランプ + thetaHardwareControl.controlLED(LedTarget.LED6, -1, LedColor.BLUE) // Liveランプ (OFF) + thetaHardwareControl.controlLED(LedTarget.LED7, 250, LedColor.RED) // 赤ランプ } else -> { - thetaHardwareControl.controlLED(LedTarget.LED3, 0, LedColor.BLUE) - thetaHardwareControl.controlLED(LedTarget.LED7, 0, LedColor.BLUE) + Log.v(TAG, " UNDEFINED") + thetaHardwareControl.controlLED(LedTarget.LED3, -1, LedColor.GREEN) // WIFIランプ + thetaHardwareControl.controlLED(LedTarget.LED4, -1, LedColor.BLUE) // カメラランプ + thetaHardwareControl.controlLED(LedTarget.LED5, -1, LedColor.BLUE) // ムービーランプ + thetaHardwareControl.controlLED(LedTarget.LED6, 0, LedColor.BLUE) // Liveランプ (ON) + thetaHardwareControl.controlLED(LedTarget.LED7, -1, LedColor.RED) // 赤ランプ } } } diff --git a/app/src/main/java/jp/osdn/gokigen/thetathoughtshutter/theta/ThetaHardwearControl.kt b/app/src/main/java/jp/osdn/gokigen/thetathoughtshutter/theta/ThetaHardwearControl.kt index 0c52f1d..6609f4a 100644 --- a/app/src/main/java/jp/osdn/gokigen/thetathoughtshutter/theta/ThetaHardwearControl.kt +++ b/app/src/main/java/jp/osdn/gokigen/thetathoughtshutter/theta/ThetaHardwearControl.kt @@ -17,7 +17,16 @@ class ThetaHardwareControl(private val activity: PluginActivity) : IThetaHardwar try { when (period) { - 0 -> activity.notificationLedShow(device) + 0 -> { + if (device == LedTarget.LED3) + { + activity.notificationLed3Show(color) + } + else + { + activity.notificationLedShow(device) + } + } -1 -> activity.notificationLedHide(device) else -> activity.notificationLedBlink(device, color, period) } -- 2.11.0