• R/O
  • HTTP
  • SSH
  • HTTPS

A01d: Commit

OPC(Olympus Air)用望遠鏡アプリ。


Commit MetaInfo

Revisãodba98e378b542e367bc24a6d3a47df41ce53e586 (tree)
Hora2020-02-16 13:29:55
AutorMRSa <mrsa@myad...>
CommiterMRSa

Mensagem de Log

ズームイン・ズームアウトの操作をできるようにする。

Mudança Sumário

Diff

--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/canon/operation/CanonFocusingControl.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/canon/operation/CanonFocusingControl.java
@@ -26,7 +26,6 @@ public class CanonFocusingControl implements IFocusingControl, IPtpIpCommandCall
2626 private static final int FOCUS_MOVE = 17;
2727 private static final int FOCUS_UNLOCK = 18;
2828
29-
3029 //private final Activity context;
3130 private final PtpIpCommandPublisher commandPublisher;
3231 private final IAutoFocusFrameDisplay frameDisplayer;
@@ -59,7 +58,6 @@ public class CanonFocusingControl implements IFocusingControl, IPtpIpCommandCall
5958 maxPointLimitHeight = 4000.0f;
6059 }
6160 Log.v(TAG, "FOCUS RESOLUTION : " + maxPointLimitWidth + "," + maxPointLimitHeight);
62-
6361 }
6462 catch (Exception e)
6563 {
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/canon/operation/CanonZoomLensControl.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/canon/operation/CanonZoomLensControl.java
@@ -1,18 +1,64 @@
11 package net.osdn.gokigen.a01d.camera.canon.operation;
22
3+import android.app.Activity;
4+import android.content.SharedPreferences;
5+import android.util.Log;
6+
7+import androidx.annotation.NonNull;
8+import androidx.preference.PreferenceManager;
9+
310 import net.osdn.gokigen.a01d.camera.IZoomLensControl;
11+import net.osdn.gokigen.a01d.camera.canon.wrapper.command.messages.specific.CanonSetDevicePropertyValue;
12+import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommandCallback;
13+import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.PtpIpCommandPublisher;
14+import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
15+
16+import static net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpMessages.SEQ_SET_DEVICE_PROPERTY;
417
5-public class CanonZoomLensControl implements IZoomLensControl
18+public class CanonZoomLensControl implements IZoomLensControl, IPtpIpCommandCallback
619 {
7- public CanonZoomLensControl()
8- {
20+ private final String TAG = this.toString();
21+
22+ private float maxZoomMagnification;
23+ private float zoomStep;
24+ private float currentZoomPosition = 1.0f;
25+ private final PtpIpCommandPublisher commandPublisher;
26+ private boolean isDrivingZoom = false;
927
28+ public CanonZoomLensControl(@NonNull Activity context, @NonNull PtpIpCommandPublisher commandPublisher)
29+ {
30+ this.commandPublisher = commandPublisher;
31+ try
32+ {
33+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
34+ String zoomSize = preferences.getString(IPreferencePropertyAccessor.CANON_ZOOM_MAGNIFICATION, IPreferencePropertyAccessor.CANON_ZOOM_MAGNIFICATION_DEFAULT_VALUE);
35+ String zoomResolution = preferences.getString(IPreferencePropertyAccessor.CANON_ZOOM_RESOLUTION, IPreferencePropertyAccessor.CANON_ZOOM_RESOLUTION_DEFAULT_VALUE);
36+
37+ this.maxZoomMagnification = (float) Integer.parseInt(zoomSize);
38+ float zoomResolutionFloat = (float) Integer.parseInt(zoomResolution);
39+ if (zoomResolutionFloat < 5.0f)
40+ {
41+ zoomResolutionFloat = 5.0f;
42+ }
43+ else if (zoomResolutionFloat > 100.0f)
44+ {
45+ zoomResolutionFloat = 100.0f;
46+ }
47+ zoomStep = maxZoomMagnification / zoomResolutionFloat;
48+ Log.v(TAG, "ZOOM MAGNIFICATION : " + maxZoomMagnification + " [step: " + this.zoomStep + "]");
49+ }
50+ catch (Exception e)
51+ {
52+ e.printStackTrace();
53+ maxZoomMagnification = 0.0f;
54+ zoomStep = 1.0f;
55+ }
1056 }
1157
1258 @Override
1359 public boolean canZoom()
1460 {
15- return (false);
61+ return (!(maxZoomMagnification < 1.0f));
1662 }
1763
1864 @Override
@@ -24,42 +70,94 @@ public class CanonZoomLensControl implements IZoomLensControl
2470 @Override
2571 public float getMaximumFocalLength()
2672 {
27- return (0);
73+ return (maxZoomMagnification);
2874 }
2975
3076 @Override
3177 public float getMinimumFocalLength()
3278 {
33- return (0);
79+ return (1.0f);
3480 }
3581
3682 @Override
3783 public float getCurrentFocalLength()
3884 {
39- return (0);
85+ return (currentZoomPosition);
4086 }
4187
4288 @Override
4389 public void driveZoomLens(float targetLength)
4490 {
45-
91+ int targetLengthInt;
92+ try
93+ {
94+ if (targetLength > maxZoomMagnification)
95+ {
96+ targetLengthInt = (int) Math.ceil(maxZoomMagnification * 10.0f);
97+ targetLength = maxZoomMagnification;
98+ }
99+ else if (targetLength < 1.0f)
100+ {
101+ targetLengthInt = 10;
102+ targetLength = 1.0f;
103+ }
104+ else
105+ {
106+ targetLengthInt = Math.round(targetLength * 10.0f);
107+ }
108+ commandPublisher.enqueueCommand(new CanonSetDevicePropertyValue(this, SEQ_SET_DEVICE_PROPERTY, false, 0, 30, 0xd055, targetLengthInt));
109+ currentZoomPosition = targetLength;
110+ isDrivingZoom = true;
111+ }
112+ catch (Exception e)
113+ {
114+ e.printStackTrace();
115+ }
46116 }
47117
48118 @Override
49119 public void driveZoomLens(boolean isZoomIn)
50120 {
51-
121+ float targetLength = currentZoomPosition + ((isZoomIn)? zoomStep : -zoomStep);
122+ if (targetLength < 1.0f)
123+ {
124+ targetLength = 1.0f;
125+ }
126+ else if (targetLength > maxZoomMagnification)
127+ {
128+ targetLength = maxZoomMagnification;
129+ }
130+ driveZoomLens(targetLength);
52131 }
53132
54133 @Override
55134 public void moveInitialZoomPosition()
56135 {
57-
136+ driveZoomLens(1.0f);
58137 }
59138
60139 @Override
61140 public boolean isDrivingZoomLens()
62141 {
142+ return (isDrivingZoom);
143+ }
144+
145+ @Override
146+ public void receivedMessage(int id, byte[] rx_body)
147+ {
148+ isDrivingZoom =false;
149+ Log.v(TAG, " ZOOM FINISHED. : " + currentZoomPosition);
150+ }
151+
152+ @Override
153+ public void onReceiveProgress(int currentBytes, int totalBytes, byte[] rx_body)
154+ {
155+ Log.v(TAG, " " + currentBytes + "/" + totalBytes);
156+ }
157+
158+ @Override
159+ public boolean isReceiveMulti()
160+ {
63161 return (false);
64162 }
65163 }
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/canon/wrapper/CanonInterfaceProvider.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/canon/wrapper/CanonInterfaceProvider.java
@@ -66,10 +66,10 @@ public class CanonInterfaceProvider implements IPtpIpInterfaceProvider, IDisplay
6666 commandPublisher = new PtpIpCommandPublisher(CAMERA_IP, CONTROL_PORT);
6767 liveViewControl = new CanonLiveViewControl(context, this, 10); //
6868 asyncReceiver = new PtpIpAsyncResponseReceiver(CAMERA_IP, ASYNC_RESPONSE_PORT);
69- statusChecker = new CanonStatusChecker(activity, commandPublisher, CAMERA_IP, EVENT_PORT);
69+ statusChecker = new CanonStatusChecker(context, commandPublisher, CAMERA_IP, EVENT_PORT);
7070 canonConnection = new CanonConnection(context, provider, this, statusChecker);
7171 cameraInformation = new CanonCameraInformation();
72- zoomControl = new CanonZoomLensControl();
72+ zoomControl = new CanonZoomLensControl(context, commandPublisher);
7373 this.statusListener = statusListener;
7474 this.runmode = new PtpIpRunMode();
7575 this.informationReceiver = informationReceiver;
--- a/app/src/main/java/net/osdn/gokigen/a01d/preference/IPreferencePropertyAccessor.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/preference/IPreferencePropertyAccessor.java
@@ -70,6 +70,11 @@ public interface IPreferencePropertyAccessor
7070 String CANON_FOCUS_XY = "canon_focus_xy";
7171 String CANON_FOCUS_XY_DEFAULT_VALUE = "6000,4000";
7272
73+ String CANON_ZOOM_MAGNIFICATION = "canon_zoom_magnification";
74+ String CANON_ZOOM_MAGNIFICATION_DEFAULT_VALUE = "0";
75+
76+ String CANON_ZOOM_RESOLUTION = "canon_zoom_resolution";
77+ String CANON_ZOOM_RESOLUTION_DEFAULT_VALUE = "25";
7378
7479 /*
7580 int CHOICE_SPLASH_SCREEN = 10;
--- a/app/src/main/java/net/osdn/gokigen/a01d/preference/canon/CanonPreferenceFragment.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/preference/canon/CanonPreferenceFragment.java
@@ -127,6 +127,12 @@ public class CanonPreferenceFragment extends PreferenceFragmentCompat implements
127127 if (!items.containsKey(IPreferencePropertyAccessor.CANON_FOCUS_XY)) {
128128 editor.putString(IPreferencePropertyAccessor.CANON_FOCUS_XY, IPreferencePropertyAccessor.CANON_FOCUS_XY_DEFAULT_VALUE);
129129 }
130+ if (!items.containsKey(IPreferencePropertyAccessor.CANON_ZOOM_MAGNIFICATION)) {
131+ editor.putString(IPreferencePropertyAccessor.CANON_ZOOM_MAGNIFICATION, IPreferencePropertyAccessor.CANON_ZOOM_MAGNIFICATION_DEFAULT_VALUE);
132+ }
133+ if (!items.containsKey(IPreferencePropertyAccessor.CANON_ZOOM_RESOLUTION)) {
134+ editor.putString(IPreferencePropertyAccessor.CANON_ZOOM_RESOLUTION, IPreferencePropertyAccessor.CANON_ZOOM_RESOLUTION_DEFAULT_VALUE);
135+ }
130136 if (!items.containsKey(IPreferencePropertyAccessor.CONNECTION_METHOD)) {
131137 editor.putString(IPreferencePropertyAccessor.CONNECTION_METHOD, IPreferencePropertyAccessor.CONNECTION_METHOD_DEFAULT_VALUE);
132138 }
--- a/app/src/main/res/values-ja/strings.xml
+++ b/app/src/main/res/values-ja/strings.xml
@@ -249,4 +249,11 @@
249249 <string name="pref_summary_use_osc_theta_v21"> </string>
250250 <string name="theta_connect_response_ng">応答がありません。</string>
251251
252+ <string name="pref_canon_zoom_magnification">ズーム最大倍率</string>
253+ <string name="pref_summary_canon_zoom_magnification">カメラのズーム倍率を設定してください (0 : ズームなし)</string>
254+
255+ <string name="pref_canon_zoom_resolution">ズームステップ</string>
256+ <string name="pref_summary_canon_zoom_resolution">ズームを何段階にするか指定します (標準: 25)</string>
257+
258+
252259 </resources>
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -253,4 +253,10 @@
253253 <string name="pref_summary_use_osc_theta_v21"> </string>
254254 <string name="theta_connect_response_ng">Did not receive any response.</string>
255255
256+ <string name="pref_canon_zoom_magnification">Zoom magnification</string>
257+ <string name="pref_summary_canon_zoom_magnification">set zoom magnification (0 : no zoom)</string>
258+
259+ <string name="pref_canon_zoom_resolution">Zoom Step</string>
260+ <string name="pref_summary_canon_zoom_resolution"> </string>
261+
256262 </resources>
--- a/app/src/main/res/xml/preferences_canon.xml
+++ b/app/src/main/res/xml/preferences_canon.xml
@@ -26,6 +26,18 @@
2626 android:title="@string/pref_cat_camera">
2727
2828 <EditTextPreference
29+ android:key="canon_zoom_magnification"
30+ android:title="@string/pref_canon_zoom_magnification"
31+ android:defaultValue="0"
32+ android:summary="@string/pref_summary_canon_zoom_magnification" />
33+
34+ <EditTextPreference
35+ android:key="canon_zoom_resolution"
36+ android:title="@string/pref_canon_zoom_resolution"
37+ android:defaultValue="25"
38+ android:summary="@string/pref_summary_canon_zoom_resolution" />
39+
40+ <EditTextPreference
2941 android:key="canon_focus_xy"
3042 android:title="@string/pref_canon_focus_xy"
3143 android:defaultValue="6000,4000"
Show on old repository browser