OSDN Git Service

WPZ2で、撮影画像・動画画像のサイズを変更、表示できるようにする。
[gokigen/mangle.git] / app / src / main / java / jp / osdn / gokigen / gokigenassets / camera / vendor / pixpro / wrapper / status / PixproStatusHolder.kt
1 package jp.osdn.gokigen.gokigenassets.camera.vendor.pixpro.wrapper.status
2
3 import android.graphics.Color
4 import android.util.Log
5 import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraStatus
6 import jp.osdn.gokigen.gokigenassets.camera.vendor.pixpro.wrapper.command.IPixproCommandPublisher
7 import jp.osdn.gokigen.gokigenassets.camera.vendor.pixpro.wrapper.command.messages.base.PixproCommandOnlyCallback
8 import jp.osdn.gokigen.gokigenassets.camera.vendor.pixpro.wrapper.command.messages.specific.*
9 import java.lang.Exception
10 import java.util.*
11
12 class PixproStatusHolder
13 {
14     companion object
15     {
16         private val TAG = PixproStatusHolder::class.java.simpleName
17     }
18
19     private var statusConvert = PixproStatusConvert(this)
20     private lateinit var commandPublisher : IPixproCommandPublisher
21
22     private var currentTakeMode = ""
23     private var currentFlashMode = ""
24     private var currentWhiteBalance = ""
25     private var currentIsoSensitivity = ""
26     private var currentExposureCompensation = ""
27     private var currentShutterSpeed = ""
28     private var currentRemainBattery = ""
29     private var currentCaptureMode = ""
30     private var currentImageSize = ""
31     private var currentMovieSize = ""
32
33     fun setCommandPublisher(commandPublisher : IPixproCommandPublisher)
34     {
35         this.commandPublisher = commandPublisher
36     }
37
38     fun updateValue(key: String, value: String)
39     {
40         when (key)
41         {
42             ICameraStatus.TAKE_MODE -> { currentTakeMode = value }
43             ICameraStatus.SHUTTER_SPEED -> { currentShutterSpeed = value }
44             ICameraStatus.EXPREV -> { currentExposureCompensation = value }
45             ICameraStatus.ISO_SENSITIVITY -> { currentIsoSensitivity = value }
46             ICameraStatus.WHITE_BALANCE -> { currentWhiteBalance = value }
47             ICameraStatus.TORCH_MODE -> { currentFlashMode = value }
48             ICameraStatus.BATTERY -> { currentRemainBattery = value }
49             ICameraStatus.CAPTURE_MODE -> { currentCaptureMode = value }
50             ICameraStatus.IMAGE_SIZE -> { currentImageSize = value }
51             ICameraStatus.MOVIE_SIZE -> { currentMovieSize = value }
52
53             //ICameraStatus.APERTURE -> { }
54             //ICameraStatus.AE -> { }
55             //ICameraStatus.EFFECT -> { }
56             //ICameraStatus.FOCUS_STATUS -> { }
57             else -> { }
58         }
59     }
60
61     fun getAvailableItemList(key: String?): List<String?>
62     {
63         try
64         {
65             return (when (key) {
66                 ICameraStatus.TAKE_MODE -> statusConvert.getAvailableTakeMode()
67                 ICameraStatus.SHUTTER_SPEED -> statusConvert.getAvailableShutterSpeed()
68                 ICameraStatus.APERTURE -> statusConvert.getAvailableAperture()
69                 ICameraStatus.EXPREV -> statusConvert.getAvailableExpRev()
70                 ICameraStatus.CAPTURE_MODE -> statusConvert.getAvailableCaptureMode()
71                 ICameraStatus.ISO_SENSITIVITY -> statusConvert.getAvailableIsoSensitivity()
72                 ICameraStatus.WHITE_BALANCE -> statusConvert.getAvailableWhiteBalance()
73                 ICameraStatus.AE -> statusConvert.getAvailableMeteringMode(currentTakeMode)
74                 ICameraStatus.EFFECT -> statusConvert.getAvailablePictureEffect()
75                 ICameraStatus.TORCH_MODE -> statusConvert.getAvailableTorchMode()
76                 //ICameraStatus.BATTERY -> statusConvert.getAvailableRemainBattery()
77                 //ICameraStatus.FOCUS_STATUS -> statusConvert.getAvailableFocusStatus()
78                 else -> ArrayList()
79             })
80             //Log.v(TAG, " ----- getAvailableItemList($key) ")
81             //sendCamGetSettingCmd("colormode")
82         }
83         catch (e: Exception)
84         {
85             e.printStackTrace()
86         }
87         return (ArrayList())
88     }
89
90     fun getItemStatusColor(key: String): Int
91     {
92         return (when (key) {
93             ICameraStatus.BATTERY -> getRemainBatteryColor()
94             ICameraStatus.CAPTURE_MODE -> getCaptureModeColor()
95             else -> Color.WHITE
96         })
97     }
98
99     fun getItemStatus(orgKey: String): String
100     {
101         return (when (orgKey) {
102             ICameraStatus.TAKE_MODE -> getTakeMode()
103             ICameraStatus.SHUTTER_SPEED -> getShutterSpeed()
104             //ICameraStatus.APERTURE -> getAperture()
105             ICameraStatus.EXPREV -> getExpRev()
106             ICameraStatus.CAPTURE_MODE -> getCaptureMode()
107             ICameraStatus.ISO_SENSITIVITY -> getIsoSensitivity()
108             ICameraStatus.WHITE_BALANCE -> getWhiteBalance()
109             ICameraStatus.AE -> getMeteringMode()
110             ICameraStatus.EFFECT -> getPictureEffect()
111             ICameraStatus.BATTERY -> getRemainBattery()
112             ICameraStatus.TORCH_MODE -> getTorchMode()
113             //ICameraStatus.FOCUS_STATUS -> getfocusStatus()
114             else -> ""
115         })
116     }
117
118     private fun getCaptureModeColor() : Int
119     {
120         if (currentCaptureMode.length > 1)
121         {
122             return (Color.RED)
123         }
124         return (Color.WHITE)
125     }
126
127     private fun getRemainBatteryColor() : Int
128     {
129         return (Color.WHITE)
130     }
131
132     private fun getTakeMode() : String
133     {
134         return (currentTakeMode)
135     }
136
137     private fun getShutterSpeed() : String
138     {
139         return (currentShutterSpeed)
140     }
141
142     private fun getExpRev() : String
143     {
144         return (currentExposureCompensation)
145     }
146
147     private fun getIsoSensitivity() : String
148     {
149         return ("ISO:$currentIsoSensitivity")
150     }
151
152     private fun getRemainBattery() : String
153     {
154         return (currentRemainBattery)
155     }
156
157     private fun getWhiteBalance() : String
158     {
159         return ("WB: $currentWhiteBalance")
160     }
161
162     private fun getMeteringMode() : String
163     {
164         return (when (currentTakeMode) {
165             "Video" -> { currentMovieSize }
166             else -> { currentImageSize }
167         })
168         // return ("Size")
169     }
170
171     private fun getPictureEffect() : String
172     {
173         return ("Zoom")
174     }
175
176     private fun getCaptureMode() : String
177     {
178         return (currentCaptureMode)
179     }
180
181     private fun getTorchMode() : String
182     {
183         return ("Flash: $currentFlashMode")
184     }
185
186     fun setItemStatus(key: String, value: String)
187     {
188         Log.v(TAG, " setItemStatus(key:$key, value:$value)")
189         try
190         {
191             when (key) {
192                 ICameraStatus.TAKE_MODE -> setTakeMode(value)
193                 ICameraStatus.SHUTTER_SPEED -> setShutterSpeed(value)
194                 //ICameraStatus.APERTURE -> setAperture(value)
195                 ICameraStatus.EXPREV -> setExpRev(value)
196                 ICameraStatus.CAPTURE_MODE -> updateValue(key, value)
197                 ICameraStatus.ISO_SENSITIVITY -> setIsoSensitivity(value)
198                 ICameraStatus.WHITE_BALANCE -> setWhiteBalance(value)
199                 ICameraStatus.AE -> setMeteringMode(value)
200                 ICameraStatus.EFFECT -> setPictureEffect(value)
201                 ICameraStatus.TORCH_MODE -> setTorchMode(value)
202                 //ICameraStatus.BATTERY -> setRemainBattery(value)
203                 //ICameraStatus.FOCUS_STATUS -> setfocusStatus(value)
204                 else -> return
205             }
206         }
207         catch (e: Exception)
208         {
209             e.printStackTrace()
210         }
211     }
212
213     private fun setTakeMode(value: String)
214     {
215         try
216         {
217             if (!::commandPublisher.isInitialized)
218             {
219                 // 未初期化の場合はコマンドを送らない
220                 return
221             }
222             Log.v(TAG, " setTakeMode($value)")
223             when (value)
224             {
225                 "P" -> commandPublisher.enqueueCommand(PixproChangeMode(PixproCommandOnlyCallback(), 0x01))
226                 "M" -> commandPublisher.enqueueCommand(PixproChangeMode(PixproCommandOnlyCallback(), 0x08))
227                 "ASCN" -> commandPublisher.enqueueCommand(PixproChangeMode(PixproCommandOnlyCallback(), 0x20))
228                 "Video" -> commandPublisher.enqueueCommand(PixproChangeVideoMode(PixproCommandOnlyCallback()))
229                 "Cont. Shot" -> commandPublisher.enqueueCommand(PixproChangeMode(PixproCommandOnlyCallback(), 0x00, 0x08))
230                 else -> { }
231             }
232         }
233         catch (e: Exception)
234         {
235             e.printStackTrace()
236         }
237     }
238
239     private fun setShutterSpeed(value: String)
240     {
241         try
242         {
243
244             if (!::commandPublisher.isInitialized)
245             {
246                 // 未初期化の場合はコマンドを送らない
247                 return
248             }
249             Log.v(TAG, " setShutterSpeed($value)")
250             when (value)
251             {
252                 "1/2000" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x01))
253                 "1/1600" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x02))
254                 "1/1200" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x03))
255                 "1/1000" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x04))
256                 "1/800" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x05))
257                 "1/600" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x06))
258                 "1/500" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x07))
259                 "1/400" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x08))
260                 "1/320" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x09))
261                 "1/250" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x0a))
262                 "1/200" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x0b))
263                 "1/160" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x0c))
264                 "1/125" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x0d))
265                 "1/100" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x0e))
266                 "1/80" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x0f))
267                 "1/60" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x10))
268                 "1/50" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x11))
269                 "1/40" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x12))
270                 "1/30" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x13))
271                 "1/25" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x14))
272                 "1/20" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x15))
273                 "1/15" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x16))
274                 "1/13" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x17))
275                 "1/10" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x18))
276                 "1/8" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x19))
277                 "1/6" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x1a))
278                 "1/5" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x1b))
279                 "1/4" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x1c))
280                 "1/3" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x1d))
281                 "1/2.5" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x1e))
282                 "1/2" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x1f))
283                 "1/1.6" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x20))
284                 "1/1.3" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x21))
285                 "1s" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x22))
286                 "1.3s" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x23))
287                 "1.5s" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x24))
288                 "2s" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x25))
289                 "2.5s" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x26))
290                 "3s" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x27))
291                 "4s" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x28))
292                 "5s" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x29))
293                 "6s" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x2a))
294                 "8s" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x2b))
295                 "10s" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x2c))
296                 "13s" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x2d))
297                 "15s" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x2e))
298                 "20s" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x2f))
299                 "25s" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x30))
300                 "30s" -> commandPublisher.enqueueCommand(PixproChangeShutterSpeed(PixproCommandOnlyCallback(), 0x31))
301                 else -> { }
302             }
303         }
304         catch (e: Exception)
305         {
306             e.printStackTrace()
307         }
308     }
309
310
311     private fun setMeteringMode(value: String)
312     {
313         try
314         {
315             if (!::commandPublisher.isInitialized)
316             {
317                 // 未初期化の場合はコマンドを送らない
318                 return
319             }
320             Log.v(TAG, " setMeteringMode($value)")
321             when (value)
322             {
323                 "4608x3456" -> commandPublisher.enqueueCommand(PixproChangeImageSize(PixproCommandOnlyCallback(), 0x00010000))  // 4608x3456
324                 "4608x3072" -> commandPublisher.enqueueCommand(PixproChangeImageSize(PixproCommandOnlyCallback(), 0x00004000))  // 4608x3072
325                 "4608x2592" -> commandPublisher.enqueueCommand(PixproChangeImageSize(PixproCommandOnlyCallback(), 0x00001000))  // 4608x2592
326                 "3648x2736" -> commandPublisher.enqueueCommand(PixproChangeImageSize(PixproCommandOnlyCallback(), 0x00000400))  // 3648x2736
327                 "2592x1944" -> commandPublisher.enqueueCommand(PixproChangeImageSize(PixproCommandOnlyCallback(), 0x00000020))  // 2592x1944
328                 "2048x1536" -> commandPublisher.enqueueCommand(PixproChangeImageSize(PixproCommandOnlyCallback(), 0x00000008))  // 2048x1536
329                 "1920x1080" -> commandPublisher.enqueueCommand(PixproChangeImageSize(PixproCommandOnlyCallback(), 0x00000004))  // 1920x1080
330                 "640x480" -> commandPublisher.enqueueCommand(PixproChangeImageSize(PixproCommandOnlyCallback(), 0x00000001))  // 640x480
331                 "1280x720 30p" -> commandPublisher.enqueueCommand(PixproChangeVideoSize(PixproCommandOnlyCallback(), 0x00040000))  // 1280x720 30p
332                 "640x480 30p" -> commandPublisher.enqueueCommand(PixproChangeVideoSize(PixproCommandOnlyCallback(), 0x00000040))  // 640x480 30p
333                 "640x480 120p" -> commandPublisher.enqueueCommand(PixproChangeVideoSize(PixproCommandOnlyCallback(), 0x00000100))  // 640x480  120p
334                 "1920×1080 30p" -> commandPublisher.enqueueCommand(PixproChangeVideoSize(PixproCommandOnlyCallback(), 0x00400000))  // 1920x1080 30p
335                 "1280x720 60p" -> commandPublisher.enqueueCommand(PixproChangeVideoSize(PixproCommandOnlyCallback(), 0x00080000))  // 1280x720  60p
336                 else -> { }
337             }
338         }
339         catch (e: Exception)
340         {
341             e.printStackTrace()
342         }
343     }
344
345
346     private fun setIsoSensitivity(value: String)
347     {
348         try
349         {
350             if (!::commandPublisher.isInitialized)
351             {
352                 // 未初期化の場合はコマンドを送らない
353                 return
354             }
355             Log.v(TAG, " setIsoSensitivity($value)")
356             when (value)
357             {
358                 "AUTO" -> commandPublisher.enqueueCommand(PixproChangeIsoSensitivity(PixproCommandOnlyCallback(), 0x00))
359                 "100" -> commandPublisher.enqueueCommand(PixproChangeIsoSensitivity(PixproCommandOnlyCallback(), 0x01))
360                 "200" -> commandPublisher.enqueueCommand(PixproChangeIsoSensitivity(PixproCommandOnlyCallback(), 0x02))
361                 "400" -> commandPublisher.enqueueCommand(PixproChangeIsoSensitivity(PixproCommandOnlyCallback(), 0x03))
362                 "800" -> commandPublisher.enqueueCommand(PixproChangeIsoSensitivity(PixproCommandOnlyCallback(), 0x04))
363                 "1600" -> commandPublisher.enqueueCommand(PixproChangeIsoSensitivity(PixproCommandOnlyCallback(), 0x05))
364                 "3200" -> commandPublisher.enqueueCommand(PixproChangeIsoSensitivity(PixproCommandOnlyCallback(), 0x06))
365                 else -> { }
366             }
367         }
368         catch (e: Exception)
369         {
370             e.printStackTrace()
371         }
372     }
373
374     private fun setExpRev(value: String)
375     {
376         try
377         {
378             if (!::commandPublisher.isInitialized)
379             {
380                 // 未初期化の場合はコマンドを送らない
381                 return
382             }
383             Log.v(TAG, " setExpRev($value)")
384             when (value)
385             {
386                 "-3.0" -> commandPublisher.enqueueCommand(PixproChangeExposureCompensation(PixproCommandOnlyCallback(), 0x00))
387                 "-2.7" -> commandPublisher.enqueueCommand(PixproChangeExposureCompensation(PixproCommandOnlyCallback(), 0x01))
388                 "-2.3" -> commandPublisher.enqueueCommand(PixproChangeExposureCompensation(PixproCommandOnlyCallback(), 0x02))
389                 "-2.0" -> commandPublisher.enqueueCommand(PixproChangeExposureCompensation(PixproCommandOnlyCallback(), 0x03))
390                 "-1.7" -> commandPublisher.enqueueCommand(PixproChangeExposureCompensation(PixproCommandOnlyCallback(), 0x04))
391                 "-1.3" -> commandPublisher.enqueueCommand(PixproChangeExposureCompensation(PixproCommandOnlyCallback(), 0x05))
392                 "-1.0" -> commandPublisher.enqueueCommand(PixproChangeExposureCompensation(PixproCommandOnlyCallback(), 0x06))
393                 "-0.7" -> commandPublisher.enqueueCommand(PixproChangeExposureCompensation(PixproCommandOnlyCallback(), 0x07))
394                 "-0.3" -> commandPublisher.enqueueCommand(PixproChangeExposureCompensation(PixproCommandOnlyCallback(), 0x08))
395                 "0.0" -> commandPublisher.enqueueCommand(PixproChangeExposureCompensation(PixproCommandOnlyCallback(), 0x09))
396                 "+0.3" -> commandPublisher.enqueueCommand(PixproChangeExposureCompensation(PixproCommandOnlyCallback(), 0x0a))
397                 "+0.7" -> commandPublisher.enqueueCommand(PixproChangeExposureCompensation(PixproCommandOnlyCallback(), 0x0b))
398                 "+1.0" -> commandPublisher.enqueueCommand(PixproChangeExposureCompensation(PixproCommandOnlyCallback(), 0x0c))
399                 "+1.3" -> commandPublisher.enqueueCommand(PixproChangeExposureCompensation(PixproCommandOnlyCallback(), 0x0d))
400                 "+1.7" -> commandPublisher.enqueueCommand(PixproChangeExposureCompensation(PixproCommandOnlyCallback(), 0x0e))
401                 "+2.0" -> commandPublisher.enqueueCommand(PixproChangeExposureCompensation(PixproCommandOnlyCallback(), 0x0f))
402                 "+2.3" -> commandPublisher.enqueueCommand(PixproChangeExposureCompensation(PixproCommandOnlyCallback(), 0x10))
403                 "+2.7" -> commandPublisher.enqueueCommand(PixproChangeExposureCompensation(PixproCommandOnlyCallback(), 0x11))
404                 "+3.0" -> commandPublisher.enqueueCommand(PixproChangeExposureCompensation(PixproCommandOnlyCallback(), 0x12))
405                 else -> { }
406             }
407         }
408         catch (e: Exception)
409         {
410             e.printStackTrace()
411         }
412     }
413
414     private fun setWhiteBalance(value: String)
415     {
416         try
417         {
418             if (!::commandPublisher.isInitialized)
419             {
420                 // 未初期化の場合はコマンドを送らない
421                 return
422             }
423             Log.v(TAG, " setWhiteBalance($value)")
424             when (value)
425             {
426                 "AUTO" -> commandPublisher.enqueueCommand(PixproWhiteBalance(PixproCommandOnlyCallback(), 0x01))
427                 "Daylight" -> commandPublisher.enqueueCommand(PixproWhiteBalance(PixproCommandOnlyCallback(), 0x02))
428                 "Cloudy" -> commandPublisher.enqueueCommand(PixproWhiteBalance(PixproCommandOnlyCallback(), 0x04))
429                 "Fluorescent" -> commandPublisher.enqueueCommand(PixproWhiteBalance(PixproCommandOnlyCallback(), 0x10))
430                 "Fluorescent CWF" -> commandPublisher.enqueueCommand(PixproWhiteBalance(PixproCommandOnlyCallback(), 0x20)) //
431                 "Incandescent" -> commandPublisher.enqueueCommand(PixproWhiteBalance(PixproCommandOnlyCallback(), 0x80))    //
432                 "Unknown" -> commandPublisher.enqueueCommand(PixproWhiteBalance(PixproCommandOnlyCallback(), 0x40))         //
433                 "Other" -> commandPublisher.enqueueCommand(PixproWhiteBalance(PixproCommandOnlyCallback(), 0x08))           // 不明...
434                 else -> { }
435             }
436         }
437         catch (e: Exception)
438         {
439             e.printStackTrace()
440         }
441     }
442
443     private fun setPictureEffect(value: String)
444     {
445         try
446         {
447             if (!::commandPublisher.isInitialized)
448             {
449                 // 未初期化の場合はコマンドを送らない
450                 return
451             }
452             Log.v(TAG, " setPictureEffect($value)")
453             when (value)
454             {
455                 "(+) Zoom In" -> commandPublisher.enqueueCommand(PixproExecuteZoom(PixproCommandOnlyCallback(), 1))
456                 "(-) Zoom Out" -> commandPublisher.enqueueCommand(PixproExecuteZoom(PixproCommandOnlyCallback(), -1))
457                 else -> { }
458             }
459         }
460         catch (e: Exception)
461         {
462             e.printStackTrace()
463         }
464     }
465
466
467     private fun setTorchMode(value: String)
468     {
469         try
470         {
471             if (!::commandPublisher.isInitialized)
472             {
473                 // 未初期化の場合はコマンドを送らない
474                 return
475             }
476             Log.v(TAG, " setTorchMode($value)")
477             when (value)
478             {
479                 "OFF" -> commandPublisher.enqueueCommand(PixproFlashOff(PixproCommandOnlyCallback()))
480                 "ON" -> commandPublisher.enqueueCommand(PixproFlashOn(PixproCommandOnlyCallback()))
481                 "AUTO" -> commandPublisher.enqueueCommand(PixproFlashAuto(PixproCommandOnlyCallback()))
482                 else -> { }
483             }
484         }
485         catch (e: Exception)
486         {
487             e.printStackTrace()
488         }
489     }
490 }