From 5d688a510ae85b833c22391f5cae0ebbbb239703 Mon Sep 17 00:00:00 2001 From: MRSa Date: Sat, 18 May 2019 00:50:02 +0900 Subject: [PATCH] =?utf8?q?=E3=82=AB=E3=83=A1=E3=83=A9=E3=83=97=E3=83=AD?= =?utf8?q?=E3=83=91=E3=83=86=E3=82=A3=E3=81=AE=E7=94=A8=E6=84=8F=E7=B6=9A?= =?utf8?q?=E3=81=8D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../cameratest/camtest/InformationView.java | 82 +++++---- .../gokigen/cameratest/fuji/PropertyValues.java | 13 +- .../cameratest/fuji/statuses/FujiStatusHolder.java | 191 ++++++++++++++++----- .../cameratest/fuji/statuses/IFujiStatus.java | 9 + .../cameratest/fuji/statuses/Properties.java | 3 +- 5 files changed, 217 insertions(+), 81 deletions(-) diff --git a/app/src/main/java/net/osdn/gokigen/cameratest/camtest/InformationView.java b/app/src/main/java/net/osdn/gokigen/cameratest/camtest/InformationView.java index 8767692..3bcc00d 100644 --- a/app/src/main/java/net/osdn/gokigen/cameratest/camtest/InformationView.java +++ b/app/src/main/java/net/osdn/gokigen/cameratest/camtest/InformationView.java @@ -4,6 +4,7 @@ import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; +import android.graphics.Point; import android.util.AttributeSet; import android.util.Log; @@ -15,10 +16,11 @@ import net.osdn.gokigen.cameratest.fuji.statuses.IFujiStatus; public class InformationView extends AppCompatImageView { private final String TAG = toString(); - private int focusPoint; + private Point focusPoint; private int sd_remain_size; - private int shooting_mode; + private String shooting_mode; private boolean focus_lock; + private boolean isDeviceError; private int battery_level; private int iso; @@ -50,38 +52,51 @@ public class InformationView extends AppCompatImageView private void drawCanvas(Canvas canvas) { - // Clears the canvas. - canvas.drawARGB(255, 0, 0, 0); - - // Rotates the image. - int centerX = canvas.getWidth() / 2; - int centerY = canvas.getHeight() / 2; - - Paint framePaint = new Paint(); - framePaint.setStyle(Paint.Style.STROKE); - framePaint.setColor(Color.WHITE); - - String message = "SD : " + sd_remain_size + " SHT : " + shooting_mode + " ISO : " + iso + " BATT: "; - if (battery_level < 0) - { - message = message + "???"; - } - else + try { - message = message + battery_level + "% "; + // Clears the canvas. + canvas.drawARGB(255, 0, 0, 0); + + // Rotates the image. + int centerX = canvas.getWidth() / 2; + int centerY = canvas.getHeight() / 2; + + Paint framePaint = new Paint(); + framePaint.setStyle(Paint.Style.STROKE); + framePaint.setColor(Color.WHITE); + + String message = shooting_mode + " REMAIN : " + sd_remain_size + " ISO : " + iso + " BATT: "; + if (battery_level < 0) + { + message = message + "???"; + } + else + { + message = message + battery_level + "% "; + } + canvas.drawText(message, centerX, centerY - 50, framePaint); + Log.v(TAG, message); + + + if (focusPoint != null) + { + message = "FOCUS : [" + focusPoint.x + "," + focusPoint.y + "] "; + } + if (focus_lock) + { + message = message + " (LOCKED)"; + } + if (isDeviceError) + { + message = message + " ERROR"; + } + canvas.drawText(message, centerX, centerY, framePaint); + Log.v(TAG, message); } - canvas.drawText(message, centerX, centerY - 50, framePaint); - Log.v(TAG, message); - - - message = "FOCUS : " + focusPoint; - if (focus_lock) + catch (Exception e) { - message = message + " (LOCKED)"; + e.printStackTrace(); } - canvas.drawText(message, centerX, centerY, framePaint); - Log.v(TAG, message); - } /** @@ -91,11 +106,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); + focusPoint = cameraStatus.getFocusPoint(); + sd_remain_size = cameraStatus.getRemainImageSpace(); + shooting_mode = cameraStatus.getShootingMode(); focus_lock = cameraStatus.isFocusLocked(); battery_level = cameraStatus.getBatteryLevel(); + isDeviceError = cameraStatus.isDeviceError(); iso = cameraStatus.getValue(Properties.ISO); } diff --git a/app/src/main/java/net/osdn/gokigen/cameratest/fuji/PropertyValues.java b/app/src/main/java/net/osdn/gokigen/cameratest/fuji/PropertyValues.java index e3902dd..d165e83 100644 --- a/app/src/main/java/net/osdn/gokigen/cameratest/fuji/PropertyValues.java +++ b/app/src/main/java/net/osdn/gokigen/cameratest/fuji/PropertyValues.java @@ -2,6 +2,14 @@ package net.osdn.gokigen.cameratest.fuji; public class PropertyValues { + public static final int SHOOTING_MANUAL =1; + public static final int SHOOTING_PROGRAM =2; + public static final int SHOOTING_APERTURE =3; + public static final int SHOOTING_SHUTTER =4; + public static final int SHOOTING_CUSTOM =5; + public static final int SHOOTING_AUTO =6; + + static final int IMAGE_FORMAT_FINE =2; static final int IMAGE_FORMAT_NORMAL =3; static final int IMAGE_FORMAT_FINE_RAW =4; @@ -51,11 +59,6 @@ public class PropertyValues static final int WHITE_BALANCE_CUSTOM =0X800c; static final int MOVIE_BUTTON_UNAVAILABLE =0; static final int MOVIE_BUTTON_AVAILABLE =1; - static final int SHOOTING_MANUAL =1; - static final int SHOOTING_PROGRAM =2; - static final int SHOOTING_APERTURE_PRIORITY =3; - static final int SHOOTING_SHUTTER_PRIORITY =4; - static final int SHOOTING_AUTO =6; static final int BATTERY_CRITICAL =1; static final int BATTERY_ONE_BAR =2; static final int BATTERY_TWO_BAR =3; diff --git a/app/src/main/java/net/osdn/gokigen/cameratest/fuji/statuses/FujiStatusHolder.java b/app/src/main/java/net/osdn/gokigen/cameratest/fuji/statuses/FujiStatusHolder.java index d9291fe..f620df0 100644 --- a/app/src/main/java/net/osdn/gokigen/cameratest/fuji/statuses/FujiStatusHolder.java +++ b/app/src/main/java/net/osdn/gokigen/cameratest/fuji/statuses/FujiStatusHolder.java @@ -1,10 +1,25 @@ package net.osdn.gokigen.cameratest.fuji.statuses; - +import android.graphics.Point; +import android.graphics.PointF; import android.util.SparseIntArray; +import static net.osdn.gokigen.cameratest.fuji.PropertyValues.SHOOTING_APERTURE; +import static net.osdn.gokigen.cameratest.fuji.PropertyValues.SHOOTING_AUTO; +import static net.osdn.gokigen.cameratest.fuji.PropertyValues.SHOOTING_CUSTOM; +import static net.osdn.gokigen.cameratest.fuji.PropertyValues.SHOOTING_MANUAL; +import static net.osdn.gokigen.cameratest.fuji.PropertyValues.SHOOTING_PROGRAM; +import static net.osdn.gokigen.cameratest.fuji.PropertyValues.SHOOTING_SHUTTER; import static net.osdn.gokigen.cameratest.fuji.statuses.Properties.BATTERY_LEVEL; +import static net.osdn.gokigen.cameratest.fuji.statuses.Properties.BATTERY_LEVEL_2; +import static net.osdn.gokigen.cameratest.fuji.statuses.Properties.DEVICE_ERROR; +import static net.osdn.gokigen.cameratest.fuji.statuses.Properties.FLASH; import static net.osdn.gokigen.cameratest.fuji.statuses.Properties.FOCUS_LOCK; +import static net.osdn.gokigen.cameratest.fuji.statuses.Properties.FOCUS_POINT; +import static net.osdn.gokigen.cameratest.fuji.statuses.Properties.MOVIE_REMAINING_TIME; +import static net.osdn.gokigen.cameratest.fuji.statuses.Properties.SDCARD_REMAIN_SIZE; +import static net.osdn.gokigen.cameratest.fuji.statuses.Properties.SELF_TIMER; +import static net.osdn.gokigen.cameratest.fuji.statuses.Properties.SHOOTING_MODE; class FujiStatusHolder implements IFujiStatus { @@ -12,49 +27,38 @@ class FujiStatusHolder implements IFujiStatus private SparseIntArray statusHolder; /** - * コンストラクタ + * コンストラクタ */ - FujiStatusHolder() - { + 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); + 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 - { + public int getValue(int statusId) { + try { return (statusHolder.get(statusId)); - } - catch (Exception e) - { + } catch (Exception e) { e.printStackTrace(); } return (0); } @Override - public boolean isFocusLocked() - { - try - { + public boolean isFocusLocked() { + try { int status = statusHolder.get(FOCUS_LOCK); - if (status == 1) - { + if (status == 1) { return (true); } - } - catch (Exception e) - { + } catch (Exception e) { e.printStackTrace(); } return (false); @@ -64,40 +68,143 @@ class FujiStatusHolder implements IFujiStatus public int getBatteryLevel() { int level = -1; - try + int status = 0; + try { + status = statusHolder.get(BATTERY_LEVEL); + } catch (Exception e) { + e.printStackTrace(); + } + if (status == 0) { - int status = statusHolder.get(BATTERY_LEVEL); - if ((status == 1)||(status == 6)) + try { + status = statusHolder.get(BATTERY_LEVEL_2); + } catch (Exception e) { + e.printStackTrace(); + } + } + if ((status == 1) || (status == 6)) { + level = 0; + } else if (status == 7) { + level = 20; + } else if ((status == 2) || (status == 8)) { + level = 40; + } else if (status == 9) { + level = 60; + } else if ((status == 3) || (status == 10)) { + level = 80; + } else if ((status == 4) || (status == 11)) { + level = 100; + } + return (level); + } + + @Override + public boolean isDeviceError() + { + try { + int status = statusHolder.get(DEVICE_ERROR); + if (status != 0) { + return (true); + } + } catch (Exception e) { + e.printStackTrace(); + } + return (false); + } + + @Override + public int getFlashStatus() + { + try { + return (statusHolder.get(FLASH)); + } catch (Exception e) { + e.printStackTrace(); + } + return (-1); + } + + @Override + public int getSelfTimerMode() + { + try { + return (statusHolder.get(SELF_TIMER)); + } catch (Exception e) { + e.printStackTrace(); + } + return (-1); + } + + + @Override + public int getRemainImageSpace() + { + try { + return (statusHolder.get(SDCARD_REMAIN_SIZE)); + } catch (Exception e) { + e.printStackTrace(); + } + return (-1); + } + + @Override + public int getMovieImageSpace() + { + try { + return (statusHolder.get(MOVIE_REMAINING_TIME)); + } catch (Exception e) { + e.printStackTrace(); + } + return (-1); + } + + + @Override + public String getShootingMode() + { + String mode = "?"; + try { + int value = statusHolder.get(SHOOTING_MODE); + if (value == SHOOTING_MANUAL) { - level = 0; + mode = "M"; } - else if (status == 7) + else if (value == SHOOTING_PROGRAM) { - level = 20; + mode = "P"; } - else if ((status == 2)||(status == 8)) + else if (value == SHOOTING_APERTURE) { - level = 40; + mode = "A"; } - else if (status == 9) + else if (value == SHOOTING_SHUTTER) { - level = 60; + mode = "S"; } - else if ((status == 3)||(status == 10)) + else if (value == SHOOTING_AUTO) { - level = 80; + mode = "a"; } - else if ((status == 4)||(status == 11)) + else if (value == SHOOTING_CUSTOM) { - level = 100; + mode = "C"; } - } - catch (Exception e) - { + } catch (Exception e) { e.printStackTrace(); } - return (level); + return (mode); } - + @Override + public Point getFocusPoint() + { + try { + int status = statusHolder.get(FOCUS_POINT); + int y = (status & 0xff); + int x = ((status & 0xff00) >>> 8); + return (new Point(x, y)); + } catch (Exception e) { + e.printStackTrace(); + } + return (new Point()); + } } diff --git a/app/src/main/java/net/osdn/gokigen/cameratest/fuji/statuses/IFujiStatus.java b/app/src/main/java/net/osdn/gokigen/cameratest/fuji/statuses/IFujiStatus.java index 1f8ec3b..9cc5f1f 100644 --- a/app/src/main/java/net/osdn/gokigen/cameratest/fuji/statuses/IFujiStatus.java +++ b/app/src/main/java/net/osdn/gokigen/cameratest/fuji/statuses/IFujiStatus.java @@ -1,9 +1,18 @@ package net.osdn.gokigen.cameratest.fuji.statuses; +import android.graphics.Point; + public interface IFujiStatus { int getValue(int statusId); + boolean isDeviceError(); boolean isFocusLocked(); int getBatteryLevel(); + int getFlashStatus(); + int getSelfTimerMode(); + int getRemainImageSpace(); + int getMovieImageSpace(); + String getShootingMode(); + Point getFocusPoint(); } diff --git a/app/src/main/java/net/osdn/gokigen/cameratest/fuji/statuses/Properties.java b/app/src/main/java/net/osdn/gokigen/cameratest/fuji/statuses/Properties.java index 5214e94..777a6a1 100644 --- a/app/src/main/java/net/osdn/gokigen/cameratest/fuji/statuses/Properties.java +++ b/app/src/main/java/net/osdn/gokigen/cameratest/fuji/statuses/Properties.java @@ -2,6 +2,7 @@ package net.osdn.gokigen.cameratest.fuji.statuses; public class Properties { + public static final int BATTERY_LEVEL = 0x5001; public static final int WHITE_BALANCE = 0x5005; public static final int APERTURE = 0x5007; public static final int FOCUS_MODE = 0x500a; @@ -22,7 +23,7 @@ public class Properties 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 BATTERY_LEVEL_2 = 0xd242; public static final int UNKNOWN = 0xffff; } -- 2.11.0