1 package net.osdn.gokigen.gr2control.camera.fuji_x.wrapper;
3 import android.util.Log;
4 import android.util.SparseIntArray;
6 import androidx.annotation.NonNull;
7 import androidx.annotation.Nullable;
8 import androidx.collection.SparseArrayCompat;
9 import androidx.fragment.app.FragmentActivity;
11 import net.osdn.gokigen.gr2control.R;
12 import net.osdn.gokigen.gr2control.camera.ICameraStatus;
13 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.FujiXReplyMessageReceiver;
14 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.IFujiXCommandPublisher;
15 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.messages.SetPropertyValue;
16 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.values.IFujiXBatteryMode;
17 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.values.IFujiXCameraProperties;
18 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.values.IFujiXFSSControl;
19 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.values.IFujiXFilmSimulation;
20 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.values.IFujiXFlashMode;
21 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.values.IFujiXFocusingMode;
22 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.values.IFujiXImageAspectMode;
23 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.values.IFujiXImageFormatMode;
24 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.values.IFujiXShootingMode;
25 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.values.IFujiXTimerMode;
26 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.values.IFujiXWhiteBalanceMode;
27 import net.osdn.gokigen.gr2control.liveview.ICameraStatusUpdateNotify;
29 import java.util.ArrayList;
30 import java.util.List;
31 import java.util.Locale;
33 class FujiXStatusHolder
35 private final String TAG = toString();
36 private final FragmentActivity activity;
37 private final IFujiXCommandPublisher publisher;
38 private static final boolean logcat = true;
39 private SparseIntArray statusHolder;
40 private SparseArrayCompat<String> statusNameArray;
42 FujiXStatusHolder(@NonNull FragmentActivity activity, @NonNull IFujiXCommandPublisher publisher)
44 statusHolder = new SparseIntArray();
47 this.activity = activity;
48 this.publisher = publisher;
49 statusNameArray = new SparseArrayCompat<>();
50 prepareStatusNameArray();
53 private void prepareStatusNameArray()
55 statusNameArray.clear();
56 statusNameArray.append(IFujiXCameraProperties.BATTERY_LEVEL, IFujiXCameraProperties.BATTERY_LEVEL_STR);
57 statusNameArray.append(IFujiXCameraProperties.WHITE_BALANCE, IFujiXCameraProperties.WHITE_BALANCE_STR);
58 statusNameArray.append(IFujiXCameraProperties.APERTURE, IFujiXCameraProperties.APERTURE_STR);
59 statusNameArray.append(IFujiXCameraProperties.FOCUS_MODE, IFujiXCameraProperties.FOCUS_MODE_STR);
60 statusNameArray.append(IFujiXCameraProperties.SHOOTING_MODE, IFujiXCameraProperties.SHOOTING_MODE_STR);
61 statusNameArray.append(IFujiXCameraProperties.FLASH, IFujiXCameraProperties.FLASH_STR);
62 statusNameArray.append(IFujiXCameraProperties.EXPOSURE_COMPENSATION, IFujiXCameraProperties.EXPOSURE_COMPENSATION_STR);
63 statusNameArray.append(IFujiXCameraProperties.SELF_TIMER, IFujiXCameraProperties.SELF_TIMER_STR);
64 statusNameArray.append(IFujiXCameraProperties.FILM_SIMULATION, IFujiXCameraProperties.FILM_SIMULATION_STR);
65 statusNameArray.append(IFujiXCameraProperties.IMAGE_FORMAT, IFujiXCameraProperties.IMAGE_FORMAT_STR);
66 statusNameArray.append(IFujiXCameraProperties.RECMODE_ENABLE, IFujiXCameraProperties.RECMODE_ENABLE_STR);
67 statusNameArray.append(IFujiXCameraProperties.F_SS_CONTROL, IFujiXCameraProperties.F_SS_CONTROL_STR);
68 statusNameArray.append(IFujiXCameraProperties.ISO, IFujiXCameraProperties.ISO_STR);
69 statusNameArray.append(IFujiXCameraProperties.MOVIE_ISO, IFujiXCameraProperties.MOVIE_ISO_STR);
70 statusNameArray.append(IFujiXCameraProperties.FOCUS_POINT, IFujiXCameraProperties.FOCUS_POINT_STR);
71 statusNameArray.append(IFujiXCameraProperties.DEVICE_ERROR, IFujiXCameraProperties.DEVICE_ERROR_STR);
72 statusNameArray.append(IFujiXCameraProperties.IMAGE_FILE_COUNT, IFujiXCameraProperties.IMAGE_FILE_COUNT_STR);
73 statusNameArray.append(IFujiXCameraProperties.SDCARD_REMAIN_SIZE, IFujiXCameraProperties.SDCARD_REMAIN_SIZE_STR);
74 statusNameArray.append(IFujiXCameraProperties.FOCUS_LOCK, IFujiXCameraProperties.FOCUS_LOCK_STR);
75 statusNameArray.append(IFujiXCameraProperties.MOVIE_REMAINING_TIME, IFujiXCameraProperties.MOVIE_REMAINING_TIME_STR);
76 statusNameArray.append(IFujiXCameraProperties.SHUTTER_SPEED, IFujiXCameraProperties.SHUTTER_SPEED_STR);
77 statusNameArray.append(IFujiXCameraProperties.IMAGE_ASPECT, IFujiXCameraProperties.IMAGE_ASPECT_STR);
78 statusNameArray.append(IFujiXCameraProperties.BATTERY_LEVEL_2, IFujiXCameraProperties.BATTERY_LEVEL_2_STR);
79 statusNameArray.append(IFujiXCameraProperties.UNKNOWN_DF00, IFujiXCameraProperties.UNKNOWN_DF00_STR);
80 statusNameArray.append(IFujiXCameraProperties.PICTURE_JPEG_COUNT, IFujiXCameraProperties.PICTURE_JPEG_COUNT_STR);
81 statusNameArray.append(IFujiXCameraProperties.UNKNOWN_D400, IFujiXCameraProperties.UNKNOWN_D400_STR);
82 statusNameArray.append(IFujiXCameraProperties.UNKNOWN_D401, IFujiXCameraProperties.UNKNOWN_D401_STR);
83 statusNameArray.append(IFujiXCameraProperties.UNKNOWN_D52F, IFujiXCameraProperties.UNKNOWN_D52F_STR);
84 statusNameArray.append(IFujiXCameraProperties.UNKNOWN_D245, IFujiXCameraProperties.UNKNOWN_D245_STR);
85 statusNameArray.append(IFujiXCameraProperties.UNKNOWN_DF41, IFujiXCameraProperties.UNKNOWN_DF41_STR);
86 statusNameArray.append(IFujiXCameraProperties.UNKNOWN_DF26, IFujiXCameraProperties.UNKNOWN_DF26_STR);
87 statusNameArray.append(IFujiXCameraProperties.UNKNOWN_DF27, IFujiXCameraProperties.UNKNOWN_DF27_STR);
90 void updateValue(@Nullable ICameraStatusUpdateNotify notifier, int id, byte data0, byte data1, byte data2, byte data3)
94 int value = ((((int) data3) & 0xff) << 24) + ((((int) data2) & 0xff) << 16) + ((((int) data1) & 0xff) << 8) + (((int) data0) & 0xff);
95 int currentValue = statusHolder.get(id, -1);
96 //logcat(String.format(Locale.US, " STATUS [id: 0x%04x] 0x%08x(%d) -> 0x%08x(%d)", id, currentValue, currentValue, value, value));
97 if ((notifier != null) && (currentValue != value))
99 statusHolder.put(id, value);
100 //logcat(String.format(Locale.US," STATUS UPDATE [id: 0x%04x] 0x%08x(%d) -> 0x%08x(%d)", id, currentValue, currentValue, value, value));
101 updateDetected(notifier, id, currentValue, value);
110 private void updateDetected(@NonNull ICameraStatusUpdateNotify notifier, int id, int previous, int current)
114 //String idName = statusNameArray.get(id, "Unknown");
115 //logcat(String.format(Locale.US, " << UPDATE STATUS >> id: 0x%04x[%s] 0x%08x(%d) -> 0x%08x(%d)", id, idName, previous, previous, current, current));
118 case IFujiXCameraProperties.FOCUS_LOCK:
119 updateFocusedStatus(notifier, previous, current);
121 case IFujiXCameraProperties.SHOOTING_MODE:
122 updatedTakeMode(notifier, previous, current);
124 case IFujiXCameraProperties.BATTERY_LEVEL:
125 case IFujiXCameraProperties.BATTERY_LEVEL_2:
126 updateBatteryLevel(notifier, previous, current);
128 case IFujiXCameraProperties.FOCUS_MODE:
129 updateFocusMode(notifier, previous, current);
131 case IFujiXCameraProperties.APERTURE:
132 updateAperture(notifier, previous, current);
134 case IFujiXCameraProperties.SHUTTER_SPEED:
135 updateShutterSpeed(notifier, previous, current);
137 case IFujiXCameraProperties.WHITE_BALANCE:
138 updateWhiteBalance(notifier, previous, current);
140 case IFujiXCameraProperties.EXPOSURE_COMPENSATION:
141 updateExposureCompensation(notifier, previous, current);
143 case IFujiXCameraProperties.ISO:
144 updateIsoSensitivity(notifier, previous, current);
146 case IFujiXCameraProperties.DEVICE_ERROR:
147 updateDeviceError(notifier, previous, current);
149 case IFujiXCameraProperties.SELF_TIMER:
150 updateSelfTimer(notifier, previous, current);
152 case IFujiXCameraProperties.SDCARD_REMAIN_SIZE:
153 updateSdCardRemainSize(notifier, previous, current);
155 case IFujiXCameraProperties.MOVIE_REMAINING_TIME:
156 updateMovieRemainTime(notifier, previous, current);
158 case IFujiXCameraProperties.FOCUS_POINT:
159 updateFocusPoint(notifier, previous, current);
161 case IFujiXCameraProperties.F_SS_CONTROL:
162 updateFSSControl(notifier, previous, current);
164 case IFujiXCameraProperties.IMAGE_ASPECT:
165 updateImageAspect(notifier, previous, current);
167 case IFujiXCameraProperties.FILM_SIMULATION:
168 updateFilmSimulation(notifier, previous, current);
170 case IFujiXCameraProperties.FLASH:
171 updateFlashMode(notifier, previous, current);
173 case IFujiXCameraProperties.IMAGE_FORMAT:
174 updateImageFormat(notifier, previous, current);
176 case IFujiXCameraProperties.UNKNOWN_D245:
177 case IFujiXCameraProperties.UNKNOWN_DF41:
178 case IFujiXCameraProperties.UNKNOWN_DF26:
179 case IFujiXCameraProperties.UNKNOWN_DF27:
181 updateUnknownValue(id, previous, current);
191 private void updateImageFormat(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
196 case IFujiXImageFormatMode.IMAGE_FORMAT_RAW:
199 case IFujiXImageFormatMode.IMAGE_FORMAT_FINE:
202 case IFujiXImageFormatMode.IMAGE_FORMAT_NORMAL:
205 case IFujiXImageFormatMode.IMAGE_FORMAT_FINE_RAW:
208 case IFujiXImageFormatMode.IMAGE_FORMAT_NORMAL_RAW:
212 value = "UNKNOWN : " + current;
215 logcat(" Image Format : " + value);
218 private void updateFlashMode(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
223 case IFujiXFlashMode.FLASH_AUTO:
226 case IFujiXFlashMode.FLASH_OFF:
229 case IFujiXFlashMode.FLASH_FILL:
232 case IFujiXFlashMode.FLASH_REDEYE_AUTO:
233 value = "REDEYE_AUTO";
235 case IFujiXFlashMode.FLASH_REDEYE_FILL:
236 value = "REDEYE_FILL";
238 case IFujiXFlashMode.FLASH_EXTERNAL_SYNC:
239 value = "EXTERNAL_SYNC";
241 case IFujiXFlashMode.FLASH_ON:
244 case IFujiXFlashMode.FLASH_REDEYE:
247 case IFujiXFlashMode.FLASH_REDEYE_ON:
250 case IFujiXFlashMode.FLASH_REDEYE_SYNC:
251 value = "REDEYE_SYNC";
253 case IFujiXFlashMode.FLASH_REDEYE_REAR:
254 value = "REDEYE_REAR";
256 case IFujiXFlashMode.FLASH_SLOW_SYNC:
259 case IFujiXFlashMode.FLASH_REAR_SYNC:
262 case IFujiXFlashMode.FLASH_COMMANDER:
265 case IFujiXFlashMode.FLASH_DISABLE:
268 case IFujiXFlashMode.FLASH_ENABLE:
272 value = " UNKNOWN : " + current;
275 logcat(" FLASH MODE : " + value);
278 private void updateFilmSimulation(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
283 case IFujiXFilmSimulation.FILM_SIMULATION_PROVIA:
284 value = IFujiXFilmSimulation.FILM_SIMULATION_PROVIA_STR;
286 case IFujiXFilmSimulation.FILM_SIMULATION_VELVIA:
287 value = IFujiXFilmSimulation.FILM_SIMULATION_VELVIA_STR;
289 case IFujiXFilmSimulation.FILM_SIMULATION_ASTIA:
290 value = IFujiXFilmSimulation.FILM_SIMULATION_ASTIA_STR;
292 case IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME:
293 value = IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME_STR;
295 case IFujiXFilmSimulation.FILM_SIMULATION_SEPIA:
296 value = IFujiXFilmSimulation.FILM_SIMULATION_SEPIA_STR;
298 case IFujiXFilmSimulation.FILM_SIMULATION_PRO_NEG_HI:
299 value = IFujiXFilmSimulation.FILM_SIMULATION_PRO_NEG_HI_STR;
301 case IFujiXFilmSimulation.FILM_SIMULATION_PRO_NEG_STD:
302 value = IFujiXFilmSimulation.FILM_SIMULATION_PRO_NEG_STD_STR;
304 case IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME_Y_FILTER:
305 value = IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME_Y_FILTER_STR;
307 case IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME_R_FILTER:
308 value = IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME_R_FILTER_STR;
310 case IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME_G_FILTER:
311 value = IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME_G_FILTER_STR;
313 case IFujiXFilmSimulation.FILM_SIMULATION_CLASSIC_CHROME:
314 value = IFujiXFilmSimulation.FILM_SIMULATION_CLASSIC_CHROME_STR;
316 case IFujiXFilmSimulation.FILM_SIMULATION_ACROS:
317 value = IFujiXFilmSimulation.FILM_SIMULATION_ACROS_STR;
319 case IFujiXFilmSimulation.FILM_SIMULATION_ACROS_Y:
320 value = IFujiXFilmSimulation.FILM_SIMULATION_ACROS_Y_STR;
322 case IFujiXFilmSimulation.FILM_SIMULATION_ACROS_R:
323 value = IFujiXFilmSimulation.FILM_SIMULATION_ACROS_R_STR;
325 case IFujiXFilmSimulation.FILM_SIMULATION_ACROS_G:
326 value = IFujiXFilmSimulation.FILM_SIMULATION_ACROS_G_STR;
328 case IFujiXFilmSimulation.FILM_SIMULATION_ETERNA:
329 value = IFujiXFilmSimulation.FILM_SIMULATION_ETERNA_STR;
331 case IFujiXFilmSimulation.FILM_SIMULATION_CLASSIC_NEGATIVE:
332 value = IFujiXFilmSimulation.FILM_SIMULATION_CLASSIC_NEGATIVE_STR;
334 case IFujiXFilmSimulation.FILM_SIMULATION_ETERNA_BLEACH_BYPASS:
335 value = IFujiXFilmSimulation.FILM_SIMULATION_ETERNA_BLEACH_BYPASS_STR;
338 value = "??? " + current;
341 logcat(" FILM SIMULATION : " + value);
344 private void updateImageAspect(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
349 case IFujiXImageAspectMode.IMAGE_ASPECT_S_3x2:
352 case IFujiXImageAspectMode.IMAGE_ASPECT_S_16x9:
355 case IFujiXImageAspectMode.IMAGE_ASPECT_S_1x1:
358 case IFujiXImageAspectMode.IMAGE_ASPECT_M_3x2:
361 case IFujiXImageAspectMode.IMAGE_ASPECT_M_16x9:
364 case IFujiXImageAspectMode.IMAGE_ASPECT_M_1x1:
367 case IFujiXImageAspectMode.IMAGE_ASPECT_L_3x2:
370 case IFujiXImageAspectMode.IMAGE_ASPECT_L_16x9:
373 case IFujiXImageAspectMode.IMAGE_ASPECT_L_1x1:
377 value = "? " + current;
380 logcat(" Image Aspect : " + value);
384 private void updateFSSControl(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
389 case IFujiXFSSControl.F_SS_CTRL_BOTH:
392 case IFujiXFSSControl.F_SS_CTRL_F:
395 case IFujiXFSSControl.F_SS_CTRL_SS:
398 case IFujiXFSSControl.F_SS_CTRL_NONE:
402 value = "? " + current;
405 logcat(" F_SS : " + value);
408 private void updateUnknownValue(int id, int previous, int current)
410 logcat(String.format(Locale.US,"<< UPDATE UNKNOWN STATUS >> id: 0x%04x 0x%08x(%d) -> 0x%08x(%d)", id, previous, previous, current, current));
413 private void updateFocusPoint(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
415 logcat(String.format(Locale.ENGLISH, " Focus Point : %x ", current));
418 private void updateMovieRemainTime(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
420 logcat(" MOVIE REMAIN : " + current);
423 private void updateSdCardRemainSize(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
425 logcat(" SDCARD REMAIN : " + current);
428 private void updateSelfTimer(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
435 case IFujiXTimerMode.TIMER_OFF:
439 case IFujiXTimerMode.TIMER_1SEC:
443 case IFujiXTimerMode.TIMER_2SEC:
447 case IFujiXTimerMode.TIMER_5SEC:
451 case IFujiXTimerMode.TIMER_10SEC:
465 logcat(" SELF TIMER IS OFF (" + value + ")");
469 logcat(" SELF TIMER IS " + value + " sec.");
473 private void updateDeviceError(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
477 notifier.updateWarning("ERROR " + current);
481 private void updateIsoSensitivity(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
486 int isoValue = (0x0000ffff & current);
487 if ((0xffff0000 & current) != 0)
489 iso = "AUTO_" + isoValue;
491 else if (isoValue > 12800)
493 iso = "H" + isoValue;
496 else if (isoValue < 200)
498 iso = "L" + isoValue;
509 logcat(" ISO SENSITIVITY : " + iso);
510 notifier.updateIsoSensitivity(iso);
513 private void updateExposureCompensation(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
515 String exposureCompensation = "";
518 float value = ((float) current / 1000.0f);
519 exposureCompensation = String.format(Locale.ENGLISH, "%+1.1f", value);
525 notifier.updatedExposureCompensation(exposureCompensation);
528 private void updateWhiteBalance(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
535 case IFujiXWhiteBalanceMode.WHITE_BALANCE_AUTO:
538 case IFujiXWhiteBalanceMode.WHITE_BALANCE_FINE:
541 case IFujiXWhiteBalanceMode.WHITE_BALANCE_INCANDESCENT:
542 value = "Incandescent";
544 case IFujiXWhiteBalanceMode.WHITE_BALANCE_FLUORESCENT_1:
545 value = "Fluorescent 1";
547 case IFujiXWhiteBalanceMode.WHITE_BALANCE_FLUORESCENT_2:
548 value = "Fluorescent 2";
550 case IFujiXWhiteBalanceMode.WHITE_BALANCE_FLUORESCENT_3:
551 value = "Fluorescent 3";
553 case IFujiXWhiteBalanceMode.WHITE_BALANCE_SHADE:
556 case IFujiXWhiteBalanceMode.WHITE_BALANCE_UNDERWATER:
557 value = "Underwater";
559 case IFujiXWhiteBalanceMode.WHITE_BALANCE_TEMPERATURE:
562 case IFujiXWhiteBalanceMode.WHITE_BALANCE_CUSTOM:
574 notifier.updatedWBMode(value);
577 private void updateShutterSpeed(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
579 String shutterSpeed = "--";
582 if ((0x80000000 & current) != 0)
584 int value = 0x0fffffff & current;
585 shutterSpeed = ("1/" + (value / 1000));
589 shutterSpeed = (current + "");
596 notifier.updatedShutterSpeed(shutterSpeed);
599 private void updateAperture(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
601 String aperature = "---";
604 float value = ((float) current / 100.0f);
605 aperature = String.format(Locale.ENGLISH, "%1.1f", value);
611 notifier.updatedAperture(aperature);
614 private void updateFocusMode(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
619 if (current == IFujiXFocusingMode.FOCUS_MANUAL)
623 else if (current == IFujiXFocusingMode.FOCUS_CONTINUOUS_AUTO)
627 else if (current == IFujiXFocusingMode.FOCUS_SINGLE_AUTO)
633 mode = mode + current;
635 logcat(" Focus Mode : " + mode);
638 private void updateFocusedStatus(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
643 notifier.updateFocusedStatus(true, true);
648 notifier.updateFocusedStatus(false, false);
652 private void updatedTakeMode(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
657 case IFujiXShootingMode.SHOOTING_MANUAL:
660 case IFujiXShootingMode.SHOOTING_PROGRAM:
663 case IFujiXShootingMode.SHOOTING_APERTURE:
666 case IFujiXShootingMode.SHOOTING_SHUTTER:
669 case IFujiXShootingMode.SHOOTING_CUSTOM:
672 case IFujiXShootingMode.SHOOTING_AUTO:
676 mode = mode + current;
679 notifier.updatedTakeMode(mode);
682 private void updateBatteryLevel(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
685 if ((current == IFujiXBatteryMode.BATTERY_CRITICAL) || (current == IFujiXBatteryMode.BATTERY_126S_CRITICAL))
689 else if (current == IFujiXBatteryMode.BATTERY_126S_ONE_BAR)
693 else if ((current == IFujiXBatteryMode.BATTERY_ONE_BAR) || (current == IFujiXBatteryMode.BATTERY_126S_TWO_BAR))
697 else if (current == IFujiXBatteryMode.BATTERY_126S_THREE_BAR)
701 else if ((current == IFujiXBatteryMode.BATTERY_TWO_BAR) || (current == IFujiXBatteryMode.BATTERY_126S_FOUR_BAR))
705 else // if ((current == IFujiXBatteryMode.BATTERY_FULL) || (current == IFujiXBatteryMode.BATTERY_126S_FULL))
709 notifier.updateRemainBattery(level);
714 * 認識したカメラのステータス名称のリストを応答する
717 private List<String> getAvailableStatusNameList()
719 ArrayList<String> selection = new ArrayList<>();
722 for (int index = 0; index < statusHolder.size(); index++)
724 int key = statusHolder.keyAt(index);
725 selection.add(statusNameArray.get(key, String.format(Locale.US, "0x%04x", key)));
736 List<String> getAvailableItemList(String listKey)
738 if ((listKey == null)||(listKey.isEmpty()))
741 return (getAvailableStatusNameList());
743 if (listKey.matches(ICameraStatus.EFFECT))
745 return (getAvailableEffectItemList());
747 if (listKey.matches(ICameraStatus.AE))
749 return (new ArrayList<>());
751 if (listKey.matches(ICameraStatus.WHITE_BALANCE))
753 return (getAvailableResourceArrayItemList(R.array.fuji_x_white_balance));
755 if (listKey.matches(ICameraStatus.ISO_SENSITIVITY))
757 return (getAvailableResourceArrayItemList(R.array.fuji_x_iso_sensitivity));
759 if (listKey.matches(ICameraStatus.FLASH_XV))
761 return (getAvailableResourceArrayItemList(R.array.fuji_x_flash_control));
763 if (listKey.matches(ICameraStatus.SELF_TIMER))
765 return (getAvailableResourceArrayItemList(R.array.fuji_x_timer_control));
768 ///// 選択可能なステータスの一覧を取得する : でも以下はアイテム名の一覧... /////
770 ArrayList<String> selection = new ArrayList<>();
773 for (int index = 0; index < statusHolder.size(); index++)
775 int key = statusHolder.keyAt(index);
776 selection.add(statusNameArray.get(key));
784 return (new ArrayList<>());
787 private List<String> getAvailableEffectItemList()
789 // EFFECTの選択肢をリストにして返す : Film Simulation にした。
790 ArrayList<String> selection = new ArrayList<>();
791 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_PROVIA_STR);
792 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_VELVIA_STR);
793 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_ASTIA_STR);
794 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME_STR);
795 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_SEPIA_STR);
796 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_PRO_NEG_HI_STR);
797 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_PRO_NEG_STD_STR);
798 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME_Y_FILTER_STR);
799 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME_R_FILTER_STR);
800 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME_G_FILTER_STR);
801 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_CLASSIC_CHROME_STR);
802 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_ACROS_STR);
803 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_ACROS_Y_STR);
804 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_ACROS_R_STR);
805 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_ACROS_G_STR);
806 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_ETERNA_STR);
807 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_CLASSIC_NEGATIVE_STR);
808 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_ETERNA_BLEACH_BYPASS_STR);
812 private List<String> getAvailableResourceArrayItemList(int id)
814 // リソースのの選択肢をリストにして返す
815 ArrayList<String> selection = new ArrayList<>();
817 String[] items = activity.getResources().getStringArray(id);
818 for (String item : items)
820 Log.v(TAG, " SELECTION : " + item);
826 private String getCurrentEffectStatus()
828 // EFFECTの現在状態を応答する : FILM Simulationにした
831 int value = statusHolder.get(IFujiXCameraProperties.FILM_SIMULATION);
832 List<String> itemList = getAvailableEffectItemList();
833 if ((value >= IFujiXFilmSimulation.FILM_SIMULATION_MIN)&&(value < itemList.size()))
835 return (itemList.get(value - 1));
845 private String getCurrentWhiteBalanceStatus()
847 // White Balanceの現在状態を取得する
850 int value = statusHolder.get(IFujiXCameraProperties.WHITE_BALANCE);
851 String[] items = activity.getResources().getStringArray(R.array.fuji_x_white_balance);
852 String[] itemValues = activity.getResources().getStringArray(R.array.fuji_x_white_balance_value);
854 for (String itemValue : itemValues)
856 int itemValueInt = Integer.parseInt(itemValue);
857 if (itemValueInt == value)
859 return (items[index]);
871 private String getCurrentIsoSensitivityStatus()
876 int current = statusHolder.get(IFujiXCameraProperties.ISO);
877 int isoValue = (0x0000ffff & current);
878 if ((0xffff0000 & current) != 0)
880 iso = "AUTO_" + isoValue;
882 else if (isoValue > 12800)
884 iso = "H" + isoValue;
887 else if (isoValue < 200)
889 iso = "L" + isoValue;
900 logcat(" ISO SENSITIVITY : " + iso);
904 private String getCurrentFlashStatus()
909 int current = statusHolder.get(IFujiXCameraProperties.FLASH);
910 String[] items = activity.getResources().getStringArray(R.array.fuji_x_flash_control);
911 String[] itemValues = activity.getResources().getStringArray(R.array.fuji_x_flash_control_value);
913 for (String itemValue : itemValues)
915 int itemValueInt = Integer.parseInt(itemValue, 16);
916 if (itemValueInt == current)
918 return (items[index]);
930 private String getCurrentSelfTimerStatus()
932 String selfTimer = "";
935 int current = statusHolder.get(IFujiXCameraProperties.SELF_TIMER);
936 String[] items = activity.getResources().getStringArray(R.array.fuji_x_timer_control);
937 String[] itemValues = activity.getResources().getStringArray(R.array.fuji_x_timer_control_value);
939 for (String itemValue : itemValues)
941 int itemValueInt = Integer.parseInt(itemValue, 16);
942 if (itemValueInt == current)
944 return (items[index]);
956 private void setEffectItem(String value)
961 List<String> itemList = getAvailableEffectItemList();
962 for (String item : itemList)
964 if (item.matches(value))
967 publisher.enqueueCommand(new SetPropertyValue(new FujiXReplyMessageReceiver(" Set Film Simulation", true), IFujiXCameraProperties.FILM_SIMULATION, 4, index));
979 private void setCurrentWhiteBalanceStatus(String value)
981 // White Balanceを設定する
984 String[] items = activity.getResources().getStringArray(R.array.fuji_x_white_balance);
985 String[] itemValues = activity.getResources().getStringArray(R.array.fuji_x_white_balance_value);
987 for (String item : items)
989 if (item.matches(value))
992 String itemValue = itemValues[index];
993 int itemValueInt = Integer.parseInt(itemValue);
994 publisher.enqueueCommand(new SetPropertyValue(new FujiXReplyMessageReceiver(" Set White Balance", true), IFujiXCameraProperties.WHITE_BALANCE, 4, itemValueInt));
1002 e.printStackTrace();
1006 private void setCurrentIsoSensitivityStatus(String value)
1011 String[] items = activity.getResources().getStringArray(R.array.fuji_x_iso_sensitivity);
1012 String[] itemValues = activity.getResources().getStringArray(R.array.fuji_x_iso_sensitivity_value);
1014 for (String item : items)
1016 //Log.v(TAG, " ===== ISO : " + value + " " + item + " ===== ");
1017 if (item.matches(value))
1020 String itemValue = itemValues[index];
1021 int itemValueInt = (int) Long.parseLong(itemValue,16);
1022 logcat(" SET ISO SENSITIVITY : " + value + " " + itemValueInt);
1023 publisher.enqueueCommand(new SetPropertyValue(new FujiXReplyMessageReceiver(" Set ISO", true), IFujiXCameraProperties.ISO, 4, itemValueInt));
1031 e.printStackTrace();
1035 private void setCurrentFlashStatus(String value)
1040 String[] items = activity.getResources().getStringArray(R.array.fuji_x_flash_control);
1041 String[] itemValues = activity.getResources().getStringArray(R.array.fuji_x_flash_control_value);
1043 for (String item : items)
1045 Log.v(TAG, " ===== FLASH : " + value + " " + item + " ===== ");
1046 if (item.matches(value))
1049 String itemValue = itemValues[index];
1050 int itemValueInt = (int) Long.parseLong(itemValue,16);
1051 logcat(" SET FLASH : " + value + " " + itemValueInt);
1052 publisher.enqueueCommand(new SetPropertyValue(new FujiXReplyMessageReceiver(" Set FLASH", true), IFujiXCameraProperties.FLASH, 4, itemValueInt));
1060 e.printStackTrace();
1064 private void setSelfTimerStatus(String value)
1069 String[] items = activity.getResources().getStringArray(R.array.fuji_x_timer_control);
1070 String[] itemValues = activity.getResources().getStringArray(R.array.fuji_x_timer_control_value);
1072 for (String item : items)
1074 Log.v(TAG, " ===== SELF-TIMER : " + value + " " + item + " ===== ");
1075 if (item.matches(value))
1078 String itemValue = itemValues[index];
1079 int itemValueInt = (int) Long.parseLong(itemValue,16);
1080 logcat(" SET SELF-TIMER : " + value + " " + itemValueInt);
1081 publisher.enqueueCommand(new SetPropertyValue(new FujiXReplyMessageReceiver(" Set SELF-TIMER", true), IFujiXCameraProperties.SELF_TIMER, 4, itemValueInt));
1089 e.printStackTrace();
1093 String getItemStatus(String key)
1095 if (key.matches(ICameraStatus.EFFECT))
1097 return (getCurrentEffectStatus());
1099 if (key.matches(ICameraStatus.WHITE_BALANCE))
1101 return (getCurrentWhiteBalanceStatus());
1103 if (key.matches(ICameraStatus.ISO_SENSITIVITY))
1105 return (getCurrentIsoSensitivityStatus());
1107 if (key.matches(ICameraStatus.FLASH_XV))
1109 return (getCurrentFlashStatus());
1111 if (key.matches(ICameraStatus.SELF_TIMER))
1113 return (getCurrentSelfTimerStatus());
1115 if (key.matches(ICameraStatus.TAKE_MODE))
1121 int strIndex = key.indexOf("x");
1122 Log.v(TAG, "getItemStatus() : " + key + " [" + strIndex + "]");
1125 key = key.substring(strIndex + 1);
1128 int id = Integer.parseInt(key, 16);
1129 int value = statusHolder.get(id);
1130 logcat("getItemStatus() value : " + value + " key : " + key + " [" + id + "]");
1132 return (value + "");
1136 e.printStackTrace();
1140 for (int index = 0; index < statusNameArray.size(); index++)
1142 int id = statusNameArray.keyAt(index);
1143 String strKey = statusNameArray.valueAt(index);
1144 if (key.contentEquals(strKey))
1146 int value = statusHolder.get(id);
1147 return (value + "");
1153 e.printStackTrace();
1155 return ("? [" + key + "]");
1158 void setItemStatus(@NonNull String key, @NonNull String value)
1162 logcat(" setStatus(" + key + ", " + value + ")");
1163 if (key.matches(ICameraStatus.EFFECT))
1165 setEffectItem(value);
1167 else if (key.matches(ICameraStatus.WHITE_BALANCE))
1169 setCurrentWhiteBalanceStatus(value);
1171 else if (key.matches(ICameraStatus.ISO_SENSITIVITY))
1173 setCurrentIsoSensitivityStatus(value);
1175 else if (key.matches(ICameraStatus.FLASH_XV))
1177 setCurrentFlashStatus(value);
1179 else if (key.matches(ICameraStatus.SELF_TIMER))
1181 setSelfTimerStatus(value);
1187 e.printStackTrace();
1191 private void dumpStatus()
1195 Log.v(TAG, " - - - status - - - ");
1196 for (int index = 0; index < statusHolder.size(); index++)
1198 int key = statusHolder.keyAt(index);
1199 int value = statusHolder.get(key);
1200 Log.v(TAG, String.format("id : 0x%x value : %d (0x%x) ", key, value, value));
1202 Log.v(TAG, " - - - status - - - ");
1206 e.printStackTrace();
1210 private void logcat(String message)
1214 Log.v(TAG, message);