OSDN Git Service

軽くスタータスの受信も実行してみた。
authorMRSa <mrsa@myad.jp>
Sat, 11 May 2019 14:20:41 +0000 (23:20 +0900)
committerMRSa <mrsa@myad.jp>
Sat, 11 May 2019 14:20:41 +0000 (23:20 +0900)
app/src/main/java/net/osdn/gokigen/cameratest/camtest/InformationView.java
app/src/main/java/net/osdn/gokigen/cameratest/fuji/Properties.java
app/src/main/java/net/osdn/gokigen/cameratest/fuji/statuses/FujiStatusChecker.java
app/src/main/java/net/osdn/gokigen/cameratest/fuji/statuses/FujiStatusHolder.java
app/src/main/java/net/osdn/gokigen/cameratest/fuji/statuses/IFujiStatus.java

index 249aadc..5e9ab31 100644 (file)
@@ -5,14 +5,22 @@ import android.graphics.Canvas;
 import android.graphics.Color;
 import android.graphics.Paint;
 import android.util.AttributeSet;
+import android.util.Log;
 
 import androidx.appcompat.widget.AppCompatImageView;
 
+import net.osdn.gokigen.cameratest.fuji.Properties;
 import net.osdn.gokigen.cameratest.fuji.statuses.IFujiStatus;
 
 public class InformationView extends AppCompatImageView
 {
-    String message = "AAAAA";
+    private final String TAG = toString();
+    private int focusPoint;
+    private int sd_remain_size;
+    private int shooting_mode;
+    private int focus_lock;
+    private int battery_level;
+    private int iso;
 
     public InformationView(Context context) {
         super(context);
@@ -53,7 +61,15 @@ public class InformationView extends AppCompatImageView
         framePaint.setStyle(Paint.Style.STROKE);
         framePaint.setColor(Color.WHITE);
 
+        String message = "SD : " + sd_remain_size + " SHT : " + shooting_mode + " BATT: " + battery_level + " ISO : " + iso;
+        canvas.drawText(message, centerX, centerY - 50, framePaint);
+        Log.v(TAG, message);
+
+
+        message = "FOCUS : " + focusPoint + " F.LOCK : " + focus_lock;
         canvas.drawText(message, centerX, centerY, framePaint);
+        Log.v(TAG, message);
+
     }
 
     /**
@@ -63,8 +79,12 @@ public class InformationView extends AppCompatImageView
      */
     public void drawInformation(IFujiStatus cameraStatus)
     {
-
-
+        focusPoint = cameraStatus.getValue(Properties.FOCUS_POINT);
+        sd_remain_size = cameraStatus.getValue(Properties.SDCARD_REMAIN_SIZE);
+        shooting_mode = cameraStatus.getValue(Properties.SHOOTING_MODE);
+        focus_lock = cameraStatus.getValue(Properties.FOCUS_LOCK);
+        battery_level = cameraStatus.getValue(Properties.BATTERY_LEVEL);
+        iso = cameraStatus.getValue(Properties.ISO);
     }
 
 }
index bf030ec..55f9857 100644 (file)
@@ -2,27 +2,27 @@ package net.osdn.gokigen.cameratest.fuji;
 
 public class Properties
 {
-    static final int WHITE_BALANCE = 0x5005;
-    static final int APERTURE = 0x5007;
-    static final int FOCUS_MODE            = 0x500a;
-    static final int SHOOTING_MODE         = 0x500e;
-    static final int FLASH                 = 0x500c;
-    static final int EXPOSURE_COMPENSATION = 0x5010;
-    static final int SELF_TIMER            = 0x5012;
-    static final int FILM_SIMULATION       = 0xd001;
-    static final int IMAGE_FORMAT          = 0xd018;
-    static final int RECMODE_ENABLE        = 0xd019;
-    static final int F_SS_CONTROL          = 0xd028;
-    static final int ISO                   = 0xd02a;
-    static final int MOVIE_ISO             = 0xd02b;
-    static final int FOCUS_POINT           = 0xd17c;
-    static final int FOCUS_LOCK            = 0xd209;
-    static final int DEVICE_ERROR          = 0xd21b;
-    static final int SDCARD_REMAIN_SIZE        = 0xd229;
-    static final int MOVIE_REMAINING_TIME  = 0xd22a;
-    static final int SHUTTER_SPEED         = 0xd240;
-    static final int IMAGE_ASPECT          = 0xd241;
-    static final int BATTERY_LEVEL         = 0xd242;
-    static final int UNKNOWN  = 0xffff;
+    public static final int WHITE_BALANCE = 0x5005;
+    public static final int APERTURE = 0x5007;
+    public static final int FOCUS_MODE            = 0x500a;
+    public static final int SHOOTING_MODE         = 0x500e;
+    public static final int FLASH                 = 0x500c;
+    public static final int EXPOSURE_COMPENSATION = 0x5010;
+    public static final int SELF_TIMER            = 0x5012;
+    public static final int FILM_SIMULATION       = 0xd001;
+    public static final int IMAGE_FORMAT          = 0xd018;
+    public static final int RECMODE_ENABLE        = 0xd019;
+    public static final int F_SS_CONTROL          = 0xd028;
+    public static final int ISO                   = 0xd02a;
+    public static final int MOVIE_ISO             = 0xd02b;
+    public static final int FOCUS_POINT           = 0xd17c;
+    public static final int FOCUS_LOCK            = 0xd209;
+    public static final int DEVICE_ERROR          = 0xd21b;
+    public static final int SDCARD_REMAIN_SIZE        = 0xd229;
+    public static final int MOVIE_REMAINING_TIME  = 0xd22a;
+    public static final int SHUTTER_SPEED         = 0xd240;
+    public static final int IMAGE_ASPECT          = 0xd241;
+    public static final int BATTERY_LEVEL         = 0xd242;
+    public static final int UNKNOWN  = 0xffff;
 
 }
index 4b7fba8..7d1ca0b 100644 (file)
@@ -73,33 +73,26 @@ public class FujiStatusChecker implements IFujiStatusReceive
         threadIsRunning = false;
     }
 
+
+
     private void statusReceivedImpl(byte[] data)
     {
         boolean isStatusUpdated = false;
         try
         {
-            Log.v(TAG, "status Received. " + data.length + " bytes.");
-
-/*
-RX [00] 7a 00 00 00 02 00 15 10
-RX [01] b1 00 00 00 12 00 1b d2
-RX [02] 00 00 00 00 0c 50 02 00
-RX [03] 00 00 12 50 00 00 00 00
-RX [04] 29 d2 67 04 00 00 2a d2
-RX [05] a1 06 00 00 0e 50 03 00
-RX [06] 00 00 01 50 03 00 00 00
-RX [07] 7c d1 04 04 02 03 09 d2
-RX [08] 01 00 00 00 10 50 b3 fe
-RX [09] ff ff 05 50 02 00 00 00
-RX [10] 28 d0 00 00 00 00 0a 50
-RX [11] 01 80 00 00 41 d2 0a 00
-RX [12] 00 00 18 d0 04 00 00 00
-RX [13] 07 50 90 01 00 00 01 d0
-RX [14] 03 00 00 00 2a d0 40 06
-RX [15] 00 80 0c 00 00 00 03 00
-RX [16] 01 20 b1 00 00 00
-*/
+            int nofStatus = (data[13] * 256) + data[12];
+            Log.v(TAG, "status Received. " + data.length + " bytes. [status : " + nofStatus + "]");
 
+            int statusCount = 0;
+            int index = 14;
+            while ((statusCount < nofStatus)&&(index < data.length))
+            {
+                int dataId = ((((int)data[index + 1]) & 0xff) * 256) + (((int) data[index]) & 0xff);
+                statusHolder.updateValue(dataId, data[index + 2], data[index + 3], data[index +4], data[index + 5]);
+                index = index + 6;
+                statusCount++;
+                isStatusUpdated = true;
+            }
             if (isStatusUpdated)
             {
                 notify.statusUpdated(statusHolder);
index 6293c4a..ad9c028 100644 (file)
@@ -1,14 +1,41 @@
 package net.osdn.gokigen.cameratest.fuji.statuses;
 
+import android.util.Log;
+import android.util.SparseIntArray;
+
 class FujiStatusHolder implements IFujiStatus
 {
+    private final String TAG = toString();
+    private SparseIntArray statusHolder;
+
     /**
      *   コンストラクタ
      */
     FujiStatusHolder()
     {
-
+        statusHolder = new SparseIntArray();
+        statusHolder.clear();
     }
 
+    void updateValue(int id, byte data0, byte data1, byte data2, byte data3)
+    {
+        int value = ((((int) data3)&0xff) << 24) +  ((((int) data2)&0xff) << 16) +  ((((int) data1)&0xff) << 8) + (((int) data0) & 0xff);
+
+        Log.v(TAG, "updateValue() : " + id + "[" + value + "]");
+        statusHolder.put(id, value);
+    }
 
+    @Override
+    public int getValue(int statusId)
+    {
+        try
+        {
+            return (statusHolder.get(statusId));
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return (0);
+    }
 }