import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
+import android.graphics.Point;
import android.util.AttributeSet;
import android.util.Log;
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;
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);
-
}
/**
*/
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);
}
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;
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;
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
{
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);
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());
+ }
}
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();
}
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;
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;
}