From 5ec80b9a74a49ea64edb68ca4d63c0964bfb933f Mon Sep 17 00:00:00 2001 From: MRSa Date: Sat, 16 Jan 2021 00:54:12 +0900 Subject: [PATCH] =?utf8?q?Theta=E3=81=AE=E3=82=AA=E3=83=97=E3=82=B7?= =?utf8?q?=E3=83=A7=E3=83=B3=E8=A8=AD=E5=AE=9A=E3=82=92=E3=81=99=E3=81=93?= =?utf8?q?=E3=81=97=E6=95=B4=E7=90=86=E3=81=A8=E8=BF=BD=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../gokigen/a01c/ICameraStatusUpdateNotify.java | 29 ----- .../jp/sfjp/gokigen/a01c/ICameraStatusWatcher.java | 3 +- .../java/jp/sfjp/gokigen/a01c/MainActivity.java | 66 +--------- .../thetacamerawrapper/ThetaCameraController.kt | 4 +- .../thetacamerawrapper/ThetaFeatureDispatcher.kt | 118 ++++++++++++++--- .../operation/ThetaOptionUpdateControl.kt | 8 +- .../thetacamerawrapper/status/ICameraStatus.java | 38 +----- .../status/ThetaCameraStatusWatcher.kt | 143 +++++++++++++++------ wear/src/main/res/values/arrays.xml | 73 +++++++++-- 9 files changed, 270 insertions(+), 212 deletions(-) delete mode 100644 wear/src/main/java/jp/sfjp/gokigen/a01c/ICameraStatusUpdateNotify.java diff --git a/wear/src/main/java/jp/sfjp/gokigen/a01c/ICameraStatusUpdateNotify.java b/wear/src/main/java/jp/sfjp/gokigen/a01c/ICameraStatusUpdateNotify.java deleted file mode 100644 index bde4e8b..0000000 --- a/wear/src/main/java/jp/sfjp/gokigen/a01c/ICameraStatusUpdateNotify.java +++ /dev/null @@ -1,29 +0,0 @@ -package jp.sfjp.gokigen.a01c; - -/** - * - */ -public interface ICameraStatusUpdateNotify -{ - void updateCameraStatus(final String message); - void updatedExposureCompensation(String xv); - void updateRemainBattery(final double percentage); - void updateCaptureMode(final String message); - -/* - void updateDriveMode(String driveMode); - void updateAeLockState(boolean isAeLocked); - //void updateCameraStatus(String message); - void updateLevelGauge(String orientation, float roll, float pitch); - - void updatedTakeMode(String mode); - void updatedShutterSpeed(String tv); - void updatedAperture(String av); - void updatedMeteringMode(String meteringMode); - void updatedWBMode(String wbMode); - void updateFocusedStatus(boolean focused, boolean focusLocked); - void updateIsoSensitivity(String sv); - void updateWarning(String warning); - void updateStorageStatus(String status); -*/ -} diff --git a/wear/src/main/java/jp/sfjp/gokigen/a01c/ICameraStatusWatcher.java b/wear/src/main/java/jp/sfjp/gokigen/a01c/ICameraStatusWatcher.java index 256838c..d7e41f1 100644 --- a/wear/src/main/java/jp/sfjp/gokigen/a01c/ICameraStatusWatcher.java +++ b/wear/src/main/java/jp/sfjp/gokigen/a01c/ICameraStatusWatcher.java @@ -4,7 +4,6 @@ import androidx.annotation.NonNull; public interface ICameraStatusWatcher { - void prepareStatusWatch(); - void startStatusWatch(@NonNull ICameraStatusUpdateNotify notifier); + void startStatusWatch(); void stopStatusWatch(); } diff --git a/wear/src/main/java/jp/sfjp/gokigen/a01c/MainActivity.java b/wear/src/main/java/jp/sfjp/gokigen/a01c/MainActivity.java index 053b285..554a1be 100644 --- a/wear/src/main/java/jp/sfjp/gokigen/a01c/MainActivity.java +++ b/wear/src/main/java/jp/sfjp/gokigen/a01c/MainActivity.java @@ -37,7 +37,7 @@ import jp.sfjp.gokigen.a01c.thetacamerawrapper.ThetaCameraController; * メインのActivity * */ -public class MainActivity extends AppCompatActivity implements IChangeScene, IShowInformation, ICameraStatusReceiver, IDialogDismissedNotifier, ICameraStatusUpdateNotify +public class MainActivity extends AppCompatActivity implements IChangeScene, IShowInformation, ICameraStatusReceiver, IDialogDismissedNotifier { private final String TAG = toString(); static final int REQUEST_NEED_PERMISSIONS = 1010; @@ -532,8 +532,7 @@ public class MainActivity extends AppCompatActivity implements IChangeScene, IS ICameraStatusWatcher watcher = currentCoordinator.getStatusWatcher(); if (watcher != null) { - watcher.prepareStatusWatch(); - watcher.startStatusWatch(this); + watcher.startStatusWatch(); } } catch (Exception e) @@ -946,65 +945,4 @@ public class MainActivity extends AppCompatActivity implements IChangeScene, IS } }); } - - @Override - public void updateCaptureMode(String message) - { - try - { - setMessage(IShowInformation.AREA_1, Color.WHITE, message); - } - catch (Exception ee) - { - ee.printStackTrace(); - } - } - - @Override - public void updateCameraStatus(String message) - { - try - { - setMessage(IShowInformation.AREA_5, Color.WHITE, message); - } - catch (Exception ee) - { - ee.printStackTrace(); - } - } - - @Override - public void updatedExposureCompensation(String xv) - { - try - { - setMessage(IShowInformation.AREA_6, Color.WHITE, xv); - } - catch (Exception ee) - { - ee.printStackTrace(); - } - } - - @Override - public void updateRemainBattery(double percentageDouble) - { - int color = Color.YELLOW; - if (percentageDouble < 0.5d) - { - if (percentageDouble < 0.3d) - { - color = Color.RED; - } - try - { - int percentage = (int) Math.ceil(percentageDouble * 100.0d); - setMessage(IShowInformation.AREA_7, color, "Bat: " + percentage + "%"); - } - catch (Exception ee) - { - ee.printStackTrace(); - } - } - } } diff --git a/wear/src/main/java/jp/sfjp/gokigen/a01c/thetacamerawrapper/ThetaCameraController.kt b/wear/src/main/java/jp/sfjp/gokigen/a01c/thetacamerawrapper/ThetaCameraController.kt index 329ae25..38f94da 100644 --- a/wear/src/main/java/jp/sfjp/gokigen/a01c/thetacamerawrapper/ThetaCameraController.kt +++ b/wear/src/main/java/jp/sfjp/gokigen/a01c/thetacamerawrapper/ThetaCameraController.kt @@ -35,7 +35,7 @@ class ThetaCameraController(val context: AppCompatActivity, private val focusFra private val singleShot = ThetaSingleShotControl(sessionIdHolder, this, this) private val movieShot = ThetaMovieRecordingControl(context, sessionIdHolder, this, showInformation, this) private val optionSet = ThetaOptionUpdateControl(sessionIdHolder) - private val statusWatcher = ThetaCameraStatusWatcher(this, this) + private val statusWatcher = ThetaCameraStatusWatcher(this, this, showInformation) private var takeMode = "P" override fun connectFinished() @@ -260,7 +260,7 @@ class ThetaCameraController(val context: AppCompatActivity, private val focusFra { if (!(::featureDispatcher.isInitialized)) { - featureDispatcher = ThetaFeatureDispatcher(context, statusDrawer, camera, accessWrapper, liveImageView, optionSet, sessionIdHolder.isApiLevelV21(), this) + featureDispatcher = ThetaFeatureDispatcher(context, statusDrawer, camera, accessWrapper, liveImageView, optionSet, this, this) } return (featureDispatcher) } diff --git a/wear/src/main/java/jp/sfjp/gokigen/a01c/thetacamerawrapper/ThetaFeatureDispatcher.kt b/wear/src/main/java/jp/sfjp/gokigen/a01c/thetacamerawrapper/ThetaFeatureDispatcher.kt index 8039e72..a2c2bc5 100644 --- a/wear/src/main/java/jp/sfjp/gokigen/a01c/thetacamerawrapper/ThetaFeatureDispatcher.kt +++ b/wear/src/main/java/jp/sfjp/gokigen/a01c/thetacamerawrapper/ThetaFeatureDispatcher.kt @@ -13,9 +13,12 @@ import jp.sfjp.gokigen.a01c.olycamerawrapper.property.IOlyCameraProperty import jp.sfjp.gokigen.a01c.olycamerawrapper.takepicture.IBracketingShotStyle import jp.sfjp.gokigen.a01c.thetacamerawrapper.operation.ThetaOptionUpdateControl -class ThetaFeatureDispatcher(val context: AppCompatActivity, val statusDrawer: IShowInformation, val camera: ICameraController, private val preferences: PreferenceDataStore, val liveImageView: ILiveImageStatusNotify, val optionSet : ThetaOptionUpdateControl, val useOSCv2 : Boolean, val statusHolder : IThetaStatusHolder): ICameraFeatureDispatcher +class ThetaFeatureDispatcher(val context: AppCompatActivity, val statusDrawer: IShowInformation, val camera: ICameraController, private val preferences: PreferenceDataStore, val liveImageView: ILiveImageStatusNotify, val optionSet : ThetaOptionUpdateControl, val statusHolder : IThetaStatusHolder, val sessionIdProvider : IThetaSessionIdProvider): ICameraFeatureDispatcher { - private var exposureCompensation : Int = 6 + private var exposureCompensationIndex : Int = 6 + private var exposureProgramIndex : Int = 1 + private var thetaFilterModeIndex : Int = 0 + private var thetaWhiteBalanceIndex : Int = 0 /** * 指定した機能を実行する @@ -54,9 +57,16 @@ class ThetaFeatureDispatcher(val context: AppCompatActivity, val statusDrawer: I changeExposureBiasValueDown() ICameraFeatureDispatcher.FEATURE_EXPOSURE_BIAS_UP -> // 露出補正を1段階上げる changeExposureBiasValueUp() + ICameraFeatureDispatcher.FEATURE_SHOW_FAVORITE_DIALOG -> // FILTER MODE (SHOW_FAVORITE_DIALOG) + changeFilterMode() + ICameraFeatureDispatcher.FEATURE_CHAGE_AE_LOCK_MODE -> // Exposure Program(AE LOCKのON/OFF切り替え) + changeExposureProgram() + ICameraFeatureDispatcher.FEATURE_WB_DOWN -> // ホワイトバランスを選択 + changeWhiteBalanceDown() + ICameraFeatureDispatcher.FEATURE_WB_UP -> // ホワイトバランスを選択 + changeWhiteBalanceUp() + /* - ICameraFeatureDispatcher.FEATURE_CHAGE_AE_LOCK_MODE -> // AE LOCKのON/OFF切り替え - changeAeLockMode() ICameraFeatureDispatcher.FEATURE_APERTURE_DOWN -> // 絞り値を1段階下げる changeApertureValueDown() ICameraFeatureDispatcher.FEATURE_APERTURE_UP -> // 絞り値を1段階上げる @@ -83,10 +93,6 @@ class ThetaFeatureDispatcher(val context: AppCompatActivity, val statusDrawer: I changeIsoSensitivityDown() ICameraFeatureDispatcher.FEATURE_ISO_UP -> // ISO感度を選択 changeIsoSensitivityUp() - ICameraFeatureDispatcher.FEATURE_WB_DOWN -> // ホワイトバランスを選択 - changeWhiteBalanceDown() - ICameraFeatureDispatcher.FEATURE_WB_UP -> // ホワイトバランスを選択 - changeWhiteBalanceUp() ICameraFeatureDispatcher.FEATURE_QUALITY_MOVIE_DOWN -> // 動画撮影クオリティを選択 changeMovieQualityModeDown() ICameraFeatureDispatcher.FEATURE_QUALITY_MOVIE_UP -> // 動画撮影クオリティを選択 @@ -247,6 +253,50 @@ class ThetaFeatureDispatcher(val context: AppCompatActivity, val statusDrawer: I } /** + * フィルター + * + */ + private fun changeFilterMode() + { + try + { + thetaFilterModeIndex++ + if (thetaFilterModeIndex > MAX_FILTER_SELECTION) + { + thetaFilterModeIndex = 0 + } + val optionStr = context.resources.getStringArray(R.array.theta_filter_set_value)[thetaFilterModeIndex] + optionSet.setOptions(optionStr, sessionIdProvider.sessionId.isEmpty()) + } + catch (e : Exception) + { + e.printStackTrace() + } + } + + /** + * Exposure Program + * + */ + private fun changeExposureProgram() + { + try + { + exposureProgramIndex++ + if (exposureProgramIndex > MAX_EXPOSURE_PROGRAM) + { + exposureProgramIndex = 0 + } + val optionStr = context.resources.getStringArray(R.array.exposure_program_value)[exposureProgramIndex] + optionSet.setOptions(optionStr, sessionIdProvider.sessionId.isEmpty()) + } + catch (e : Exception) + { + e.printStackTrace() + } + } + + /** * AF/MFの切り替えを行う */ private fun toggleAfMf() @@ -306,12 +356,12 @@ class ThetaFeatureDispatcher(val context: AppCompatActivity, val statusDrawer: I { try { - if (exposureCompensation > 0) + if (exposureCompensationIndex > 0) { - exposureCompensation-- + exposureCompensationIndex-- - val optionStr = context.resources.getStringArray(R.array.exposure_compensation_value)[exposureCompensation] - optionSet.setOptions(optionStr, useOSCv2) + val optionStr = context.resources.getStringArray(R.array.exposure_compensation_value)[exposureCompensationIndex] + optionSet.setOptions(optionStr, sessionIdProvider.sessionId.isEmpty()) } } catch (e : Exception) @@ -328,12 +378,12 @@ class ThetaFeatureDispatcher(val context: AppCompatActivity, val statusDrawer: I { try { - if (exposureCompensation < MAX_EXPOSURE_COMPENSATION) + if (exposureCompensationIndex < MAX_EXPOSURE_COMPENSATION) { - exposureCompensation++ + exposureCompensationIndex++ - val optionStr = context.resources.getStringArray(R.array.exposure_compensation_value)[exposureCompensation] - optionSet.setOptions(optionStr, useOSCv2) + val optionStr = context.resources.getStringArray(R.array.exposure_compensation_value)[exposureCompensationIndex] + optionSet.setOptions(optionStr, sessionIdProvider.sessionId.isEmpty()) } } catch (e : Exception) @@ -477,8 +527,20 @@ class ThetaFeatureDispatcher(val context: AppCompatActivity, val statusDrawer: I */ private fun changeWhiteBalanceDown() { - val propertyProxy = camera.cameraPropertyProvider - propertyProxy.updateCameraPropertyDown(IOlyCameraProperty.WB_MODE) + try + { + if (thetaWhiteBalanceIndex > 0) + { + thetaWhiteBalanceIndex-- + + val optionStr = context.resources.getStringArray(R.array.white_balance_value)[thetaWhiteBalanceIndex] + optionSet.setOptions(optionStr, sessionIdProvider.sessionId.isEmpty()) + } + } + catch (e : Exception) + { + e.printStackTrace() + } } /** @@ -487,8 +549,20 @@ class ThetaFeatureDispatcher(val context: AppCompatActivity, val statusDrawer: I */ private fun changeWhiteBalanceUp() { - val propertyProxy = camera.cameraPropertyProvider - propertyProxy.updateCameraPropertyUp(IOlyCameraProperty.WB_MODE) + try + { + if (thetaWhiteBalanceIndex < MAX_WHITE_BALANCE) + { + thetaWhiteBalanceIndex++ + + val optionStr = context.resources.getStringArray(R.array.white_balance_value)[thetaWhiteBalanceIndex] + optionSet.setOptions(optionStr, sessionIdProvider.sessionId.isEmpty()) + } + } + catch (e : Exception) + { + e.printStackTrace() + } } /** @@ -682,5 +756,9 @@ class ThetaFeatureDispatcher(val context: AppCompatActivity, val statusDrawer: I private val TAG = ThetaFeatureDispatcher::class.java.simpleName private const val MAX_EXPOSURE_COMPENSATION = 12 // exposureCompensation + private const val MAX_EXPOSURE_PROGRAM = 4 // exposureProgram + private const val MAX_FILTER_SELECTION = 4 // _filter + private const val MAX_WHITE_BALANCE = 11 // whiteBalance + } } diff --git a/wear/src/main/java/jp/sfjp/gokigen/a01c/thetacamerawrapper/operation/ThetaOptionUpdateControl.kt b/wear/src/main/java/jp/sfjp/gokigen/a01c/thetacamerawrapper/operation/ThetaOptionUpdateControl.kt index 527be36..cf3d33a 100644 --- a/wear/src/main/java/jp/sfjp/gokigen/a01c/thetacamerawrapper/operation/ThetaOptionUpdateControl.kt +++ b/wear/src/main/java/jp/sfjp/gokigen/a01c/thetacamerawrapper/operation/ThetaOptionUpdateControl.kt @@ -15,15 +15,15 @@ class ThetaOptionUpdateControl(private val sessionIdProvider: IThetaSessionIdPro */ fun setOptions(options: String, useOSCv2: Boolean, callBack: IOperationCallback? = null) { - Log.v(TAG, "setOptions() useOSCv2 : $useOSCv2 MSG : $options") + Log.v(TAG, "setOptions() OSCv2:$useOSCv2 MSG : $options") try { val thread = Thread { try { val setOptionsUrl = "http://192.168.1.1/osc/commands/execute" - val postData = if (useOSCv2) "{\"name\":\"camera.setOptions\",\"parameters\":{\"timeout\":0, \"options\": {\"$options\"}}}" else "{\"name\":\"camera.setOptions\",\"parameters\":{\"sessionId\": \"" + sessionIdProvider.sessionId + "\", \"options\": { $options }}}" - Log.v(TAG, " OPTIONS : $postData") + val postData = if (useOSCv2) "{\"name\":\"camera.setOptions\",\"parameters\":{\"timeout\":0, \"options\": {$options}}}" else "{\"name\":\"camera.setOptions\",\"parameters\":{\"sessionId\": \"" + sessionIdProvider.sessionId + "\", \"options\": { $options }}}" + // Log.v(TAG, " OPTIONS : $postData") val result: String? = httpClient.httpPostWithHeader(setOptionsUrl, postData, null, "application/json;charset=utf-8", timeoutMs) if ((result != null) && (result.isNotEmpty())) { @@ -32,7 +32,7 @@ class ThetaOptionUpdateControl(private val sessionIdProvider: IThetaSessionIdPro } else { - Log.v(TAG, "setOptions() reply is null or empty.") + Log.v(TAG, "setOptions() reply is null or empty. $postData") callBack?.operationExecuted(-1, "") } } diff --git a/wear/src/main/java/jp/sfjp/gokigen/a01c/thetacamerawrapper/status/ICameraStatus.java b/wear/src/main/java/jp/sfjp/gokigen/a01c/thetacamerawrapper/status/ICameraStatus.java index c4dd47f..d6e29ca 100644 --- a/wear/src/main/java/jp/sfjp/gokigen/a01c/thetacamerawrapper/status/ICameraStatus.java +++ b/wear/src/main/java/jp/sfjp/gokigen/a01c/thetacamerawrapper/status/ICameraStatus.java @@ -6,11 +6,6 @@ import java.util.List; public interface ICameraStatus { - @NonNull List getStatusList(final @NonNull String key); - @NonNull String getStatus(final @NonNull String key); - //void setStatus(final @NonNull String key, final @NonNull String value); - - String THETA_BATTERY_LEVEL = "batteryLevel"; String THETA_CAPTURE_STATUS = "_captureStatus"; String THETA_RECORDING_SEC = "_recordedTime"; @@ -26,37 +21,6 @@ public interface ICameraStatus String THETA_ISO_SENSITIVITY = "iso"; String THETA_SHUTTER_SPEED = "shutterSpeed"; String THETA_WHITE_BALANCE = "whiteBalance"; + String THETA_FILTER = "_filter"; - /* - String BATTERY = "battery"; - String STATE = "state"; - String FOCUS_MODE = "focusMode"; - String AF_MODE = "AFMode"; - - String RESOLUTION = "reso"; - String DRIVE_MODE = "shootMode"; - String WHITE_BALANCE = "WBMode"; - - String AE = "meteringMode"; - - String AE_STATUS_MULTI = "multi"; - String AE_STATUS_ESP = "ESP"; - String AE_STATUS_SPOT = "spot"; - String AE_STATUS_PINPOINT = "Spot"; - String AE_STATUS_CENTER = "center"; - String AE_STATUS_CENTER2 = "Ctr-Weighted"; - - String EFFECT = "effect"; - String TAKE_MODE = "exposureMode"; - String IMAGESIZE = "stillSize"; - String MOVIESIZE = "movieSize"; - - String APERATURE = "av"; - String SHUTTER_SPEED = "tv"; - String ISO_SENSITIVITY = "sv"; - String EXPREV = "xv"; - String FLASH_XV = "flashxv"; - - String TAKE_MODE_MOVIE = "movie"; - */ } diff --git a/wear/src/main/java/jp/sfjp/gokigen/a01c/thetacamerawrapper/status/ThetaCameraStatusWatcher.kt b/wear/src/main/java/jp/sfjp/gokigen/a01c/thetacamerawrapper/status/ThetaCameraStatusWatcher.kt index 5393e09..8c99d7a 100644 --- a/wear/src/main/java/jp/sfjp/gokigen/a01c/thetacamerawrapper/status/ThetaCameraStatusWatcher.kt +++ b/wear/src/main/java/jp/sfjp/gokigen/a01c/thetacamerawrapper/status/ThetaCameraStatusWatcher.kt @@ -1,42 +1,34 @@ package jp.sfjp.gokigen.a01c.thetacamerawrapper.status +import android.graphics.Color import android.util.Log -import jp.sfjp.gokigen.a01c.ICameraStatusUpdateNotify import jp.sfjp.gokigen.a01c.ICameraStatusWatcher -import jp.sfjp.gokigen.a01c.thetacamerawrapper.IThetaStatusHolder +import jp.sfjp.gokigen.a01c.IShowInformation import jp.sfjp.gokigen.a01c.thetacamerawrapper.IThetaSessionIdProvider +import jp.sfjp.gokigen.a01c.thetacamerawrapper.IThetaStatusHolder import jp.sfjp.gokigen.a01c.thetacamerawrapper.status.ICameraStatus.* import jp.sfjp.gokigen.a01c.utils.SimpleHttpClient import org.json.JSONObject -class ThetaCameraStatusWatcher(private val sessionIdProvider: IThetaSessionIdProvider, private val statusHolder : IThetaStatusHolder) : ICameraStatus, ICameraStatusWatcher +class ThetaCameraStatusWatcher(private val sessionIdProvider: IThetaSessionIdProvider, private val statusHolder: IThetaStatusHolder, private val showInformation: IShowInformation) : ICameraStatusWatcher { private val httpClient = SimpleHttpClient() private var whileFetching = false private var currentBatteryLevel : Double = 0.0 private var currentExposureCompensation : Double = 0.0 private var currentCaptureMode : String = "" + private var currentExposureProgram : String = "" private var currentCaptureStatus : String = "" private var currentBatteryStatus : String = "" private var currentWhiteBalance : String = "" + private var currentFilter : String = "" - - override fun getStatusList(key: String): List + override fun startStatusWatch() { - return (ArrayList()) + startStatusWatch1() } - override fun getStatus(key: String): String - { - return ("") - } - - override fun startStatusWatch(notifier: ICameraStatusUpdateNotify) - { - startStatusWatch1(notifier) - } - - private fun startStatusWatch1(notifier: ICameraStatusUpdateNotify) + private fun startStatusWatch1() { if (whileFetching) { @@ -50,7 +42,7 @@ class ThetaCameraStatusWatcher(private val sessionIdProvider: IThetaSessionIdPro try { val getOptionsUrl = "http://192.168.1.1/osc/commands/execute" - val postData = if (sessionIdProvider.sessionId.isEmpty()) "{\"name\":\"camera.getOptions\",\"parameters\":{\"timeout\":0, \"optionNames\" : [ \"aperture\",\"captureMode\",\"exposureCompensation\",\"exposureProgram\",\"iso\",\"shutterSpeed\",\"whiteBalance\"] }" else "{\"name\":\"camera.getOptions\",\"parameters\":{\"sessionId\": \"" + sessionIdProvider.sessionId + "\", \"optionNames\" : [ \"aperture\",\"captureMode\",\"exposureCompensation\",\"exposureProgram\",\"iso\",\"shutterSpeed\",\"whiteBalance\"] }}" + val postData = if (sessionIdProvider.sessionId.isEmpty()) "{\"name\":\"camera.getOptions\",\"parameters\":{\"timeout\":0, \"optionNames\" : [ \"aperture\",\"captureMode\",\"exposureCompensation\",\"exposureProgram\",\"iso\",\"shutterSpeed\",\"_filter\",\"whiteBalance\"] }" else "{\"name\":\"camera.getOptions\",\"parameters\":{\"sessionId\": \"" + sessionIdProvider.sessionId + "\", \"optionNames\" : [ \"aperture\",\"captureMode\",\"exposureCompensation\",\"exposureProgram\",\"iso\",\"shutterSpeed\",\"_filter\",\"whiteBalance\"] }}" Log.v(TAG, " >>>>> START STATUS WATCH : $getOptionsUrl $postData") while (whileFetching) @@ -59,7 +51,7 @@ class ThetaCameraStatusWatcher(private val sessionIdProvider: IThetaSessionIdPro if (!(response.isNullOrEmpty())) { // ステータスデータ受信 - checkStatus1(response, notifier) + checkStatus1(response) } try { @@ -84,7 +76,7 @@ class ThetaCameraStatusWatcher(private val sessionIdProvider: IThetaSessionIdPro } } - private fun checkStatus1(response : String, notifier: ICameraStatusUpdateNotify) + private fun checkStatus1(response: String) { try { @@ -97,10 +89,18 @@ class ThetaCameraStatusWatcher(private val sessionIdProvider: IThetaSessionIdPro { Log.v(TAG, " EXPREV : $currentExposureCompensation => $exposureCompensation") currentExposureCompensation = exposureCompensation - notifier.updatedExposureCompensation(String.format("%1.1f",currentExposureCompensation)) + if (currentExposureCompensation == 0.0) + { + // 補正なしの時には数値を表示しない + showInformation.setMessage(IShowInformation.AREA_6, Color.WHITE, "") + } + else + { + showInformation.setMessage(IShowInformation.AREA_6, Color.WHITE, String.format("%1.1f", currentExposureCompensation)) + } } } - catch (e : Exception) + catch (e: Exception) { e.printStackTrace() } @@ -112,9 +112,17 @@ class ThetaCameraStatusWatcher(private val sessionIdProvider: IThetaSessionIdPro { Log.v(TAG, " WB : $currentWhiteBalance => $whiteBalance") currentWhiteBalance = whiteBalance + if (currentWhiteBalance == "auto") + { + showInformation.setMessage(IShowInformation.AREA_7, Color.WHITE, "") + } + else + { + showInformation.setMessage(IShowInformation.AREA_7, Color.WHITE, currentWhiteBalance) + } } } - catch (e : Exception) + catch (e: Exception) { e.printStackTrace() } @@ -125,24 +133,61 @@ class ThetaCameraStatusWatcher(private val sessionIdProvider: IThetaSessionIdPro if (captureMode != currentCaptureMode) { Log.v(TAG, " CAPTURE MODE : $currentCaptureMode -> $captureMode") - notifier.updateCaptureMode(captureMode) currentCaptureMode = captureMode - statusHolder.setCaptureMode(captureMode) + statusHolder.captureMode = captureMode + showInformation.setMessage(IShowInformation.AREA_1, Color.WHITE, captureMode) + } + } + catch (e: Exception) + { + e.printStackTrace() + } + + try + { + val exposureProgram = stateObject.getString(THETA_EXPOSURE_PROGRAM) + if (exposureProgram != currentExposureProgram) + { + Log.v(TAG, " EXPOSURE PROGRAM : $currentExposureProgram -> $exposureProgram") + currentExposureProgram = exposureProgram + //showInformation.setMessage(IShowInformation.AREA_8, Color.WHITE, currentExposureProgram) } } - catch (e : Exception) + catch (e: Exception) + { + e.printStackTrace() + } + + try + { + val filterValue = stateObject.getString(THETA_FILTER) + if (filterValue != currentFilter) + { + Log.v(TAG, " FILTER : $currentFilter -> $filterValue") + currentFilter = filterValue + if (currentFilter == "off") + { + showInformation.setMessage(IShowInformation.AREA_5, Color.WHITE, "") + } + else + { + showInformation.setMessage(IShowInformation.AREA_5, Color.WHITE, currentFilter) + } + } + } + catch (e: Exception) { e.printStackTrace() } } - catch (ee : Exception) + catch (ee: Exception) { ee.printStackTrace() } } - private fun startStatusWatch0(notifier: ICameraStatusUpdateNotify) + private fun startStatusWatch0() { if (whileFetching) { @@ -163,7 +208,7 @@ class ThetaCameraStatusWatcher(private val sessionIdProvider: IThetaSessionIdPro if (!(response.isNullOrEmpty())) { // ステータスデータ受信 - checkStatus0(response, notifier) + checkStatus0(response) } try { @@ -188,7 +233,7 @@ class ThetaCameraStatusWatcher(private val sessionIdProvider: IThetaSessionIdPro } } - private fun checkStatus0(response : String, notifier: ICameraStatusUpdateNotify) + private fun checkStatus0(response: String) { try { @@ -201,10 +246,10 @@ class ThetaCameraStatusWatcher(private val sessionIdProvider: IThetaSessionIdPro { Log.v(TAG, " BATTERY : $currentBatteryLevel => $batteryLevel") currentBatteryLevel = batteryLevel - notifier.updateRemainBattery(currentBatteryLevel) + updateRemainBattery(currentBatteryLevel) } } - catch (e : Exception) + catch (e: Exception) { e.printStackTrace() } @@ -218,7 +263,7 @@ class ThetaCameraStatusWatcher(private val sessionIdProvider: IThetaSessionIdPro currentBatteryStatus = batteryStatus } } - catch (e : Exception) + catch (e: Exception) { e.printStackTrace() } @@ -231,36 +276,52 @@ class ThetaCameraStatusWatcher(private val sessionIdProvider: IThetaSessionIdPro Log.v(TAG, " CAPTURE STATUS : $currentCaptureStatus -> $captureStatus") if (captureStatus != "idle") { - notifier.updateCameraStatus(captureStatus) + showInformation.setMessage(IShowInformation.AREA_5, Color.WHITE, captureStatus) } currentCaptureStatus = captureStatus } } - catch (e : Exception) + catch (e: Exception) { e.printStackTrace() } } - catch (ee : Exception) + catch (ee: Exception) { ee.printStackTrace() } } - override fun stopStatusWatch() + private fun updateRemainBattery(percentageDouble: Double) { - whileFetching = false + var color = Color.YELLOW + if (percentageDouble < 0.5) + { + if (percentageDouble < 0.3) + { + color = Color.RED + } + try + { + val percentage = Math.ceil(percentageDouble * 100.0).toInt() + showInformation.setMessage(IShowInformation.AREA_7, color, "Bat: $percentage%") + } + catch (ee: java.lang.Exception) + { + ee.printStackTrace() + } + } } - override fun prepareStatusWatch() + override fun stopStatusWatch() { - // + whileFetching = false } companion object { private val TAG = ThetaCameraStatusWatcher::class.java.simpleName private const val timeoutMs = 1500 - private const val loopWaitMs : Long = 660 + private const val loopWaitMs : Long = 350 } } diff --git a/wear/src/main/res/values/arrays.xml b/wear/src/main/res/values/arrays.xml index c946e66..2df0607 100644 --- a/wear/src/main/res/values/arrays.xml +++ b/wear/src/main/res/values/arrays.xml @@ -27,19 +27,66 @@ - "exposureCompensation" : -2.0 - "exposureCompensation" : -1.7 - "exposureCompensation" : -1.3 - "exposureCompensation" : -1.0 - "exposureCompensation" : -0.7 - "exposureCompensation" : -0.3 - "exposureCompensation" : 0.0 - "exposureCompensation" : 0.3 - "exposureCompensation" : 0.7 - "exposureCompensation" : 1.0 - "exposureCompensation" : 1.3 - "exposureCompensation" : 1.7 - "exposureCompensation" : 2.0 + \"exposureCompensation\" : -2.0 + \"exposureCompensation\" : -1.7 + \"exposureCompensation\" : -1.3 + \"exposureCompensation\" : -1.0 + \"exposureCompensation\" : -0.7 + \"exposureCompensation\" : -0.3 + \"exposureCompensation\" : 0.0 + \"exposureCompensation\" : 0.3 + \"exposureCompensation\" : 0.7 + \"exposureCompensation\" : 1.0 + \"exposureCompensation\" : 1.3 + \"exposureCompensation\" : 1.7 + \"exposureCompensation\" : 2.0 + + + + M + P + S + I + A + + + + \"exposureProgram\" : 1 + \"exposureProgram\" : 2 + \"exposureProgram\" : 4 + \"exposureProgram\" : 9 + \"exposureProgram\" : 3 + + + + off + DRc + NR + HDR + Hh hdr + + + + \"_filter\" : \"off\" + \"_filter\" : \"DR Comp\" + \"_filter\" : \"Noise Reduction\" + \"_filter\" : \"hdr\" + \"_filter\" : \"Hh hdr\" + + + + \"whiteBalance\" : \"auto\" + \"whiteBalance\" : \"daylight\" + \"whiteBalance\" : \"shade\" + \"whiteBalance\" : \"cloudy-daylight\" + \"whiteBalance\" : \"incandescent\" + \"whiteBalance\" : \"_warmWhiteFluorescent\" + \"whiteBalance\" : \"_dayLightFluorescent\" + \"whiteBalance\" : \"_dayWhiteFluorescent\" + \"whiteBalance\" : \"fluorescent\" + \"whiteBalance\" : \"_bulbFluorescent\" + \"whiteBalance\" : \"_colorTemperature\" + \"whiteBalance\" : \"_underwater\" \ No newline at end of file -- 2.11.0