forked from alex-agency/XYC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xyc.sh
1892 lines (1780 loc) · 59.3 KB
/
xyc.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Xiaomi Yi Configurator
# http://www.tawbaware.com
# (c) Tawbaware software, 2015
#
# Description: This script runs inside the Xiaomi Yi camera and allows the user
# to enable RAW file creation, and change photographic options such as
# exposure, ISO, whitebalance, etc. In addition, a photographic time-lapse
# feature is also available. It is designed to be executed and accessed via
# a telnet client running on any phone, computer, tablet, etc.
#
#
# Installation:
#
# 1. Install script at top level of SD card and ensure execute permissions:
# chmod 755 /tmp/fuse_d/xyc.sh
# 2 Optional. If you have custom settings (e.g. bitrate, video size, etc.)
# that you want to be included in the autoexec.ash file, store these commands
# in a file named autoexec.xyc in the same directory as xyc.sh. Also, using
# XYC, set the "Custom Photo Settings" -> "Import additional settings..."
# menu choice to "yes". XYC will copy everything from the autoexec.xyc into
# autoexec.ash whenever it updates autoexec.ash.
# 3. Optional. If you want XYC to operate in a language other than English,
# create a file named xyc_strings.sh in the same directory as xyc.sh. See
# "TRANSLATION STRINGS" section below.
#
# Usage:
#
# 1. Enable wifi, and connect to camera using telnet
# (IP=192.168.42.1, user id="root", no password)
# 2. Run script: /tmp/fuse_d/xyc.sh
#
# Changelog:
#
# 0.3.3 (Oct 2015) - Support latest 1.2.13 firmware
# by Alex - Added support file weight limit to 4GB
# - Added 1440p resolution for test purpose
# - Added ability managing Noise Reduction
# - Added new bitrates for Video Quality (40-50Mb)
# - Added XYC Update feature for automatic download new version
# 0.3.2 (Sep 2015) - Updated YiMax script
# by Alex - Added shadow/highlight/gamma script
# - Added sharpness script
# - Fixed HDR scripts and added HDR Night
# 0.3.1 (Sep 2015) - Ported features from XYC v4.6 https://rendy37.wordpress.com/2015/08/13/xiaomi-yi-configurator-xyc-ubah-script-tanpa-pc/
# by Alex - Added YiMax Movie script http://nutseynuts.blogspot.com/2015/06/xiaomi-yi-action-cam-custom-scripts.html
# - Simplified menu interface
# - Fixed issues
# 0.2.0 (Aug 2015) - Added support for alternate langauges
# - Added support for user settings
# - Standardized menu interface
# 0.1.0 (Aug 2015) - Initial release
# Disclaimer: This software is not created or endorsed by Xiaomi; it relies on
# undocumented features of the Xiaomi Yi. Using this software may void your
# camera's warranty and possibly damage your camera. Use at your own risk!
VERS="0.3.3 Alex"
FUSED=/tmp/fuse_d
SCRIPT_DIR=$(cd `dirname "$0"` && pwd)
WEB=/var/www
if [ ! -d "$FUSED" ]; then
FUSED=$SCRIPT_DIR
if [ -d "$WEB" ]; then
FUSED=$WEB
fi
fi
AASH=${FUSED}/autoexec.ash
PRAWNCONF=${FUSED}/goprawn.config
CORCONF=${FUSED}/coring.config
THIS_SCRIPT="$SCRIPT_DIR/`basename "$0"`"
LANGUAGE_FILE="$SCRIPT_DIR/xyc_strings.sh"
USER_SETTINGS_FILE="$SCRIPT_DIR/autoexec.xyc"
#=============================================================================
#
# TRANSLATION STRINGS
#
# This list of variables contains the user interface strings for the English
# Language. English is the default language for this program, but other
# languages can be easily supported. If you wish to translate xyc to a
# different language, create a file named xyc_strings.sh in the same directory
# as xyc.sh, and store translated versions of (any or all) these XYC_* strings
# in that file.
XYC_MAIN_MENU="Main Menu"
XYC_VIEW_SETTINGS="View custom photo settings"
XYC_EDIT_SETTINGS="Edit custom photo settings"
XYC_VIEW_EDIT_SETTINGS="View/Edit camera settings"
XYC_RESET_SETTINGS="Reset/Delete camera settings"
XYC_CURRENT_SETTINGS="Current custom photo settings"
XYC_CREATE_TIME_LAPSE="Create/Run time-lapse script"
XYC_SHOW_CARD_SPACE="Show SD card space usage"
XYC_RESTART_CAMERA="Restart camera"
XYC_EXIT="Exit"
XYC_BACK="Back"
XYC_SAVE_AND_BACK="<- Save & Back"
XYC_SELECT_OPTION="Select option"
XYC_INVALID_CHOICE="Invalid choice"
XYC_SD_CARD_SPACE="SD Card Space"
XYC_TOTAL="Total"
XYC_USED="Used"
XYC_FREE="Free"
XYC_FILE_COUNTS="File counts"
XYC_ESTIMATED_REMAINING="Estimated remaining file capacity"
XYC_MINUTES="minutes"
XYC_UNKNOWN_OPTION="Warning...unknown option"
XYC_ISO="ISO"
XYC_EXPOSURE="Exposure"
XYC_EXP="Exp"
XYC_AWB="AWB"
XYC_CREATE_RAW="Create RAW"
XYC_RAW="RAW"
XYC_NR="NR"
XYC_IMPORT_USER_SETTINGS="Import additional settings from"
XYC_YES="Yes"
XYC_NO="No"
XYC_Y="y"
XYC_N="n"
XYC_ON="On"
XYC_OFF="Off"
XYC_TIME_LAPSE_PARAMS="TLParams"
XYC_AUTO="Auto"
XYC_ENTER="Enter"
XYC_CHOOSE="Choose"
XYC_ENTER_AWB_PROMPT="Auto-Whitebalance (y/n)"
XYC_CREATE_RAW_PROMPT="Create RAW files (y/n)"
XYC_ENTER_NUM_SHOTS_MENU="Number of images (0=off)"
XYC_ENTER_NUM_SHOTS_PROMPT="Enter number of images (0=off, 1-9999)"
XYC_RUN_ONCE_ONLY_MENU="One-time script"
XYC_RUN_ONCE_ONLY_PROMPT="Run once only? (y=once/n=multi)"
XYC_POWEROFF_WHEN_COMPLETE_MENU="Poweroff when complete"
XYC_POWEROFF_WHEN_COMPLETE_PROMPT="Poweroff when complete (y/n)"
XYC_DELAY_BETWEEN_SHUTTER_MENU="Delay between shutter"
XYC_DELAY_BETWEEN_SHUTTER_PROMPT="Delay between shutter press (secs)"
XYC_RESTART_NOW_PROMPT="Restart camera now (y/n)"
XYC_REBOOTING_NOW="Rebooting now"
XYC_SHUTTING_DOWN_NOW="Shutting down now"
XYC_WRITING="Writing"
XYC_DELETING="Deleting"
XYC_CREATE_HDR="Create/Run HDR script"
XYC_PHOTO_SETTINGS_MENU="Custom Photo Settings Menu"
XYC_CAMERA_SETTINGS_MENU="Camera Settings Menu"
XYC_INCLUDE_USER_SETTINGS_PROMPT="Import additional settings from autoexec.xyc (y/n)"
XYC_TIME_LAPSE_MENU="Time Lapse Menu"
XYC_HDR_MENU="HDR Settings Menu"
XYC_CANNOT_READ="WARNING: Cannot read/access"
XYC_YIMAX_MOVIE="YiMax Movie"
XYC_USER_IMPORT="User Import"
XYC_YIMAX_PROMPT="YiMax Image Optimization (y/n)"
XYC_EXPOSURE_MENU="Exposure Setting"
XYC_ISO_MENU="ISO Setting"
XYC_SEC="sec"
XYC_REMOVING="Removing"
XYC_DELETE_VIDEO_PREVIEW_PROMPT="Delete All Video Preview files (y/n)"
XYC_DELETE_RAW_PROMPT="Delete All RAW files (y/n)"
XYC_HDR="HDR"
XYC_HDR_AUTO_DAY="HDR Auto"
XYC_HDR_AUTO_NIGHT="HDR Auto Night"
XYC_HDR_ADVANCED="HDR Advanced"
XYC_HDR_RESET="Delete HDR"
XYC_HDR_AFTER_RESTART="HDR photos will take after restart!"
XYC_HDR_EXPOSURE="HDR picture Exposure"
XYC_THIRD="Third"
XYC_SECOND="Second"
XYC_FIRST="First"
XYC_AVOID_LIGHT="*AVOID LIGHT*"
XYC_VIDEO_QUALITY="Video Quality"
XYC_DEFAULT="Default"
XYC_VIDEO_RESOLUTION="Video Resolution"
XYC_VIDEO_FREQUENCY="Video Frequency"
XYC_VIDEO_BITRATE="Video Bitrate"
XYC_SHADOW="Shadow Adj"
XYC_SHADOW_PROMPT="Shadow/Highlight/Gamma clipping adjustments (y/n)"
XYC_SHARPNESS="Sharpness"
XYC_SHARPNESS_MENU="Sharpness Menu"
XYC_SHARPNESS_MODE="Sharpness Mode"
XYC_SHARPNESS_FIR="Digital Filter"
XYC_SHARPNESS_COR="Coring"
XYC_RESET_DEFAULT="Reset to Default"
XYC_SHR_MODE_VIDEO="Video"
XYC_SHR_MODE_FAST="Fast Still"
XYC_SHR_MODE_LOWISO="LowISO Still"
XYC_SHR_MODE_HIGHISO="HighISO Still"
XYC_SHARPNESS_FIR_PROMPT="Coefficients of Digital Filter"
XYC_SHARPNESS_COR_PROMPT="Coefficients of Coring (1-255)"
XYC_BIG_FILE="4Gb files"
XYC_BIG_FILE_PROMPT="Set file weight limit to 4GB (y/n)"
XYC_RESOLUTION_WARNING="Warning Resolution"
XYC_NR_MENU="Noise Reduction Menu"
XYC_DISABLE_NR="Disable NR"
XYC_MAX_NR="Max NR"
XYC_CUSTOM_NR="Custom NR"
XYC_CUSTOM_NR_PROMPT="Enter Noise Reduction (0-16383)"
XYC_MAX="Max"
XYC_DISABLE="Disable"
XYC_UPDATING_NOW="Updating now"
XYC_SCRIPT_UPDATE="XYC Update"
#If language file exists, source it to override English language UI strings
if [[ -s "$LANGUAGE_FILE" && -r "$LANGUAGE_FILE" ]]; then
source $LANGUAGE_FILE
fi
#=============================================================================
#Time-lapse params:
TLNUM=10
TLONCE=${XYC_N}
TLOFF=${XYC_Y}
TLDELAY=12
NOUI=0
#Other settings
unset EXITACTION
welcome ()
{
clear
echo ""
echo " * Xiaomi Yi Configurator * "
echo " * 10/23/2015 ${VERS} * "
echo ""
}
showMainMenu ()
{
local REPLY=0
while [ "$EXITACTION" == "" ]
do
echo " ====== ${XYC_MAIN_MENU} ====="
echo " [1] $XYC_VIEW_EDIT_SETTINGS"
echo " [2] $XYC_CREATE_TIME_LAPSE"
echo " [3] $XYC_CREATE_HDR"
echo " [4] $XYC_RESET_SETTINGS"
echo " [5] $XYC_SHOW_CARD_SPACE"
echo " [6] $XYC_RESTART_CAMERA"
echo " [7] $XYC_SCRIPT_UPDATE"
echo " [8] $XYC_EXIT"
read -p "${XYC_SELECT_OPTION}: " REPLY
clear
case $REPLY in
0) cat $AASH;;
1) showSettingsMenu; writeAutoexec $AASH "settings";;
2) showTimeLapseMenu; writeAutoexec $AASH "timelapse";;
3) showHDRMenu; writeAutoexec $AASH "hdr";;
4) removeAutoexec; resetCameraSettings;;
5) showSpaceUsage;;
6) EXITACTION="reboot";;
7) EXITACTION="update";;
8) EXITACTION="nothing";;
*) echo "$XYC_INVALID_CHOICE"; REPLY=0;;
esac
done
}
showSettingsMenu ()
{
local REPLY=0
while [[ $REPLY -gt -1 && $REPLY -lt 13 ]]
do
echo " == ${XYC_CAMERA_SETTINGS_MENU} =="
if [ $EXP -eq 0 ]; then
echo " [1] ${XYC_EXPOSURE} : ${XYC_AUTO}"
else
expView $EXP
echo " [1] ${XYC_EXPOSURE} : $EXPVIEW"
fi
if [ $ISO -eq 0 ]; then
echo " [2] ${XYC_ISO} : ${XYC_AUTO}"
else
echo " [2] ${XYC_ISO} : $ISO"
fi
if [ $AWB == ${XYC_Y} ]; then
echo " [3] ${XYC_AWB} : ${XYC_ON}"
else
echo " [3] ${XYC_AWB} : ${XYC_OFF}"
fi
if [[ -z $NR ]]; then
echo " [4] ${XYC_NR} : ${XYC_DEFAULT}"
elif [ $NR -eq -1 ]; then
echo " [4] ${XYC_NR} : ${XYC_DISABLE}"
elif [ $NR -eq 16383 ]; then
echo " [4] ${XYC_NR} : ${XYC_MAX}"
else
echo " [4] ${XYC_NR} : $NR"
fi
if [ $SHADOW == ${XYC_Y} ]; then
echo " [5] ${XYC_SHADOW} : ${XYC_YES}"
else
echo " [5] ${XYC_SHADOW} : ${XYC_NO}"
fi
if [[ ! -z $SHR ]]; then
echo " [6] ${XYC_SHARPNESS} : $SHR $FIR $COR"
else
echo " [6] ${XYC_SHARPNESS} : ${XYC_DEFAULT}"
fi
if [ $YIMAX == ${XYC_Y} ]; then
echo " [7] ${XYC_YIMAX_MOVIE} : ${XYC_YES}"
else
echo " [7] ${XYC_YIMAX_MOVIE} : ${XYC_NO}"
fi
if [ $RAW == ${XYC_Y} ]; then
echo " [8] ${XYC_CREATE_RAW} : ${XYC_YES}"
else
echo " [8] ${XYC_CREATE_RAW} : ${XYC_NO}"
fi
if [ $RES -eq 0 ]; then
echo " [9] ${XYC_VIDEO_QUALITY}: ${XYC_DEFAULT}"
else
echo " [9] ${XYC_VIDEO_QUALITY}: $RESVIEW"
fi
if [ $BIG_FILE == ${XYC_Y} ]; then
echo " [10] ${XYC_BIG_FILE} : ${XYC_YES}"
else
echo " [10] ${XYC_BIG_FILE} : ${XYC_NO}"
fi
if [ $INC_USER == ${XYC_Y} ]; then
echo " [11] ${XYC_USER_IMPORT} : ${XYC_YES}"
else
echo " [11] ${XYC_USER_IMPORT} : ${XYC_NO}"
fi
echo " [12] ${XYC_SAVE_AND_BACK}"
read -p "${XYC_SELECT_OPTION}: " REPLY
case $REPLY in
1) getExposureInput; clear;;
2) getISOInput; clear;;
3) getAWBInput; clear;;
4) getNRInput; clear;;
5) getShadowInput; clear;;
6) getSharpnessInput; clear;;
7) getYiMaxInput; clear;;
8) getRawInput; clear;;
9) getVideoInput; clear;;
10) getBigFileInput; clear;;
11) getIncludeUserSettings; clear;;
12) clear; return 0;;
*) clear; echo "$XYC_INVALID_CHOICE"; REPLY=0;;
esac
done
}
showTimeLapseMenu ()
{
local REPLY=0
resetDelaySuggestion
while [[ $REPLY -gt -1 && $REPLY -lt 6 ]]
do
echo " ===== ${XYC_TIME_LAPSE_MENU} ====="
echo " [1] ${XYC_ENTER_NUM_SHOTS_MENU} : $TLNUM"
echo " [2] ${XYC_DELAY_BETWEEN_SHUTTER_MENU} : $TLDELAY"
echo " [3] ${XYC_POWEROFF_WHEN_COMPLETE_MENU} : $TLOFF"
echo " [4] ${XYC_RUN_ONCE_ONLY_MENU} : $TLONCE"
echo " [5] $XYC_SAVE_AND_BACK"
read -p "${XYC_SELECT_OPTION}: " REPLY
case $REPLY in
1) getTLNumShots; clear;;
2) getTLDelay; clear;;
3) getTLOff; clear;;
4) getTLOnce; clear;;
5) clear; return 0;;
*) clear; echo "$XYC_INVALID_CHOICE"; REPLY=0;;
esac
done
clear
}
showHDRMenu ()
{
local REPLY=0
while [[ $REPLY -gt -1 && $REPLY -lt 6 ]]
do
if [[ ! -z $AUTAN ]]; then
if [ $ISO -eq 0 ]; then
echo " * ${XYC_ISO} : ${XYC_AUTO}"
else
echo " * ${XYC_ISO} : $ISO"
fi
if [ $AUTAN -eq 2 ]; then
echo " * ${XYC_HDR}1 : 7.9 sec "
echo " * ${XYC_HDR}2 : 5.4 sec "
echo " * ${XYC_HDR}3 : 3.5 sec "
echo " * ${XYC_HDR}4 : 1.8 sec "
echo " * ${XYC_HDR}5 : 1.0 sec "
echo " * ${XYC_HDR}6 : 1/15 sec "
echo ""
elif [ $AUTAN -eq 1 ]; then
echo " * ${XYC_HDR}1 : 1/15 sec "
echo " * ${XYC_HDR}2 : 1/50 sec "
echo " * ${XYC_HDR}3 : 1/245 sec "
echo " * ${XYC_HDR}4 : 1/520 sec "
echo " * ${XYC_HDR}5 : 1/1630 sec"
echo " * ${XYC_HDR}6 : 1/8147 sec"
echo ""
elif [ $AUTAN -eq 0 ]; then
expView $HDR1
echo " * ${XYC_HDR}1 : $EXPVIEW "
expView $HDR2
echo " * ${XYC_HDR}2 : $EXPVIEW "
expView $HDR3
echo " * ${XYC_HDR}3 : $EXPVIEW "
echo ""
fi
fi
echo " == ${XYC_HDR_MENU} =="
echo " [1] ${XYC_HDR_AUTO_NIGHT}"
echo " [2] ${XYC_HDR_AUTO_DAY}"
echo " [3] ${XYC_HDR_ADVANCED}"
echo " [4] ${XYC_HDR_RESET}"
echo " [5] $XYC_SAVE_AND_BACK"
read -p "${XYC_SELECT_OPTION}: " REPLY
case $REPLY in
1) AUTAN=2; HDR1=1; HDR2=300; HDR3=900; getISOInput; clear;;
2) AUTAN=1; HDR1=900; HDR2=1550; HDR3=2047; getISOInput; clear;;
3) AUTAN=0; getHDRInput; getISOInput; clear;;
4) unset AUTAN; clear; return 0;;
5) clear; return 0;;
*) clear; echo "$XYC_INVALID_CHOICE"; REPLY=0;;
esac
done
}
showSpaceUsage ()
{
local JPEG_COUNT=`find ${FUSED} -name *.jpg | wc -l`
local RAW_COUNT=`find ${FUSED} -name *.RAW | wc -l`
local MP4_COUNT=`find ${FUSED} -name *.mp4 | wc -l`
local THM_COUNT=`find ${FUSED} -name *.THM -o -name *thm.mp4 | wc -l`
local SPACE_TOTAL=`df -h ${FUSED} | awk -F " " '/tmp/ {print $2}'`
local SPACE_USED=`df -h ${FUSED} | awk -F " " '/tmp/ {print $3}'`
local SPACE_FREE=`df -h ${FUSED} | awk -F " " '/tmp/ {print $4}'`
local USED_PCT=`df -h ${FUSED} | awk -F " " '/tmp/ {print $5}'`
local SPACE_FREE_KB=`df -k ${FUSED} | awk -F " " '/tmp/ {print $4}'`
local JPEG_LEFT=`expr $SPACE_FREE_KB / 5500`
local RAW_LEFT=`expr $SPACE_FREE_KB / 31000`
local MP4_LEFT=`expr $SPACE_FREE_KB / 88000`
echo "${XYC_SD_CARD_SPACE}:"
echo " ${XYC_TOTAL}=$SPACE_TOTAL, ${XYC_USED}=$SPACE_USED ($USED_PCT), ${XYC_FREE}=$SPACE_FREE"
echo ""
echo "${XYC_FILE_COUNTS}:"
echo " JPEG=$JPEG_COUNT, RAW=$RAW_COUNT, MP4=$MP4_COUNT, THM=$THM_COUNT"
echo ""
echo "${XYC_ESTIMATED_REMAINING}:"
echo " JPEG=$JPEG_LEFT, RAW=$RAW_LEFT, MP4=$MP4_LEFT ${XYC_MINUTES}"
echo ""
getCleanUpInput
clear
}
getCleanUpInput ()
{
read -p "${XYC_DELETE_VIDEO_PREVIEW_PROMPT} [${XYC_ENTER}=n]: " REPLY
if [ "$REPLY" == ${XYC_Y} ]; then
removeAllPreviews
fi
read -p "${XYC_DELETE_RAW_PROMPT} [${XYC_ENTER}=n]: " REPLY
if [ "$REPLY" == ${XYC_Y} ]; then
removeAllRAWs
fi
}
removeAllPreviews ()
{
echo "${XYC_REMOVING} ${FUSED}/DCIM/100MEDIA/*.THM"
rm -f ${FUSED}/DCIM/100MEDIA/*.THM
echo "${XYC_REMOVING} ${FUSED}/DCIM/100MEDIA/*thm.mp4"
rm -f ${FUSED}/DCIM/100MEDIA/*thm.mp4
}
removeAllRAWs ()
{
echo "${XYC_REMOVING} ${FUSED}/DCIM/100MEDIA/*.RAW"
rm -f ${FUSED}/DCIM/100MEDIA/*.RAW
}
parseCommandLine ()
{
while [ $# -gt 0 ]
do
key="$1"
case $key in
-i) ISO=$2; shift;;
-e) EXP=$2; shift;;
-w) AWB=$2; shift;;
-n) NR=$2; shift;;
-r) RAW=$2; shift;;
-y) YIMAX=$2; shift;;
-s) SHADOW=$2; shift;;
-b) BIG_FILE=$2; shift;;
-u) INC_USER=$2; shift;;
-q) NOUI=1;;
*) echo "${XYC_UNKNOWN_OPTION}: $key"; shift;;
esac
shift # past argument or value
done
}
parseExistingAutoexec ()
{
#Parse existing values from autoexec.ash
ISO=`grep "t ia2 -ae exp" $AASH 2>/dev/null | cut -d " " -f 5`
EXP=`grep "t ia2 -ae exp" $AASH 2>/dev/null | cut -d " " -f 6`
grep -q "t ia2 -awb off" $AASH 2>/dev/null
if [ $? -eq 0 ]; then AWB=${XYC_N}; fi
NR=`grep "t ia2 -adj tidx" $AASH 2>/dev/null | cut -d " " -f 6`
grep -q "t app test debug_dump 14" $AASH 2>/dev/null
if [ $? -eq 0 ]; then RAW=${XYC_Y}; fi
grep -q "#UserSettings: y" $AASH 2>/dev/null
if [ $? -eq 0 ]; then INC_USER=${XYC_Y}; fi
grep -q "#TimeLapseParams:" $AASH 2>/dev/null
if [ $? -eq 0 ]; then
TLNUM=`grep "#TimeLapseParams:" $AASH | cut -d " " -f 2`
TLONCE=`grep "#TimeLapseParams:" $AASH | cut -d " " -f 3`
TLOFF=`grep "#TimeLapseParams:" $AASH | cut -d " " -f 4`
TLDELAY=`grep "#TimeLapseParams:" $AASH | cut -d " " -f 5`
fi
grep -q "#HDRParams:" $AASH 2>/dev/null
if [ $? -eq 0 ]; then
AUTAN=`grep "#HDRParams:" $AASH | cut -d " " -f 2`
HDR1=`grep "#HDRParams:" $AASH | cut -d " " -f 3`
HDR2=`grep "#HDRParams:" $AASH | cut -d " " -f 4`
HDR3=`grep "#HDRParams:" $AASH | cut -d " " -f 5`
fi
grep -q "#Sharpness:" $AASH 2>/dev/null
if [ $? -eq 0 ]; then
SHR=`grep "#Sharpness:" $AASH | cut -d " " -f 2`
FIR=`grep "#Sharpness:" $AASH | cut -d " " -f 3`
COR=`grep "#Sharpness:" $AASH | cut -d " " -f 4`
fi
grep -q "#YiMAX-movie script" $AASH 2>/dev/null
if [ $? -eq 0 ]; then YIMAX=${XYC_Y}; fi
grep -q "t ia2 -adj autoknee" $AASH 2>/dev/null
if [ $? -eq 0 ]; then SHADOW=${XYC_Y}; fi
grep -q "writeb 0xC06CC426 0x11" $AASH 2>/dev/null
if [ $? -eq 0 ]; then RES=1; FPS=1; fi
grep -q "writeb 0xC06CC426 0x0F" $AASH 2>/dev/null
if [ $? -eq 0 ]; then RES=1; FPS=2; fi
grep -q "writeb 0xC06CC426 0x34" $AASH 2>/dev/null
if [ $? -eq 0 ]; then RES=1; FPS=3; fi
grep -q "writeb 0xC06CC426 0x17" $AASH 2>/dev/null
if [ $? -eq 0 ]; then RES=2; FPS=1; fi
grep -q "writeb 0xC06CC426 0x16" $AASH 2>/dev/null
if [ $? -eq 0 ]; then RES=2; FPS=2; fi
grep -q "writeb 0xC06CC426 0x0D" $AASH 2>/dev/null
if [ $? -eq 0 ]; then RES=3; FPS=1; fi
grep -q "writeb 0xC06CC426 0x0C" $AASH 2>/dev/null
if [ $? -eq 0 ]; then RES=3; FPS=2; fi
grep -q "writeb 0xC06CC426 0x06" $AASH 2>/dev/null
if [ $? -eq 0 ]; then RES=4; FPS=1; fi
grep -q "writeb 0xC06CC426 0x03" $AASH 2>/dev/null
if [ $? -eq 0 ]; then RES=4; FPS=2; fi
grep -q "writeb 0xC06CC426 0x02" $AASH 2>/dev/null
if [ $? -eq 0 ]; then RES=5; FPS=1; fi
grep -q "writeb 0xC06CC426 0x00" $AASH 2>/dev/null
if [ $? -eq 0 ]; then RES=6; FPS=1; fi
grep -q "0x41A0" $AASH 2>/dev/null
if [ $? -eq 0 ]; then BIT=1; fi
grep -q "0x41C8" $AASH 2>/dev/null
if [ $? -eq 0 ]; then BIT=2; fi
grep -q "0x41F0" $AASH 2>/dev/null
if [ $? -eq 0 ]; then BIT=3; fi
grep -q "0x420C" $AASH 2>/dev/null
if [ $? -eq 0 ]; then BIT=4; fi
grep -q "0x4220" $AASH 2>/dev/null
if [ $? -eq 0 ]; then BIT=5; fi
grep -q "0x4234" $AASH 2>/dev/null
if [ $? -eq 0 ]; then BIT=6; fi
grep -q "0x4248" $AASH 2>/dev/null
if [ $? -eq 0 ]; then BIT=7; fi
grep -q "writew 0xC03A8520 0x2004" $AASH 2>/dev/null
if [ $? -eq 0 ]; then BIG_FILE=${XYC_Y}; fi
}
resetCameraSettings ()
{
unset RES FPS BIT
unset AWB NR SHR FIR COR YIMAX SHADOW BIG_FILE
unset ISO EXP RAW
unset INC_USER
setMissingValues
promptToRestart
}
setMissingValues ()
{
#Set reasonable defaults for any missing values
if [ -z "$ISO" ]; then ISO=0; fi
if [ -z "$EXP" ]; then EXP=0; fi
if [[ "$AWB" != ${XYC_Y} && "$AWB" != ${XYC_N} ]]; then AWB=${XYC_Y}; fi
if [[ "$RAW" != ${XYC_Y} && "$RAW" != ${XYC_N} ]]; then RAW=${XYC_N}; fi
if [[ "$BIG_FILE" != ${XYC_Y} && "$BIG_FILE" != ${XYC_N} ]]; then BIG_FILE=${XYC_N}; fi
if [[ "${INC_USER}" != ${XYC_Y} && "${INC_USER}" != ${XYC_N} ]]; then INC_USER=${XYC_N}; fi
if [[ "$YIMAX" != ${XYC_Y} && "$YIMAX" != ${XYC_N} ]]; then YIMAX=${XYC_N}; fi
if [[ "$SHADOW" != ${XYC_Y} && "$SHADOW" != ${XYC_N} ]]; then SHADOW=${XYC_N}; fi
if [ -z "$RES" ]; then RES=0; FPS=1; BIT=2; else setRESView; fi
}
resetDelaySuggestion ()
{
#Delay should be sum of file write time (WT) and exposure time (ET)
#if delay is too short, then the camera doesn't write the RAW file...
#make delay longer as necessary, depending on shutter speed and SD card
#performance
local WT=12
local ET=0
if [ -n $EXP ]; then
if [ $EXP -eq 0 ]; then ET=1;
elif [ $EXP -lt 30 ]; then ET=8;
elif [ $EXP -lt 50 ]; then ET=7;
elif [ $EXP -lt 90 ]; then ET=6;
elif [ $EXP -lt 150 ]; then ET=5;
elif [ $EXP -lt 200 ]; then ET=4;
elif [ $EXP -lt 300 ]; then ET=3;
elif [ $EXP -lt 400 ]; then ET=2;
elif [ $EXP -lt 1000 ]; then ET=1;
else ET=0;
fi
fi
return `expr $WT + $ET`
}
getExposureInput ()
{
clear
echo " ******** ${XYC_EXPOSURE_MENU} ********* "
echo " * (0)=Auto (12)=1/10 (24)=1/624 * "
echo " * (1)=7.9 (13)=1/15 (25)=1/752 * "
echo " * (2)=7.7 (14)=1/30 (26)=1/1002 * "
echo " * (3)=6.1 (15)=1/50 (27)=1/1244 * "
echo " * (4)=5 (16)=1/60 (28)=1/1630 * "
echo " * (5)=4.6 (17)=1/80 (29)=1/2138 * "
echo " * (6)=2.7 (18)=1/125 (30)=1/2448 * "
echo " * (7)=1 (19)=1/140 (31)=1/2803 * "
echo " * (8)=1 (20)=1/250 (32)=1/3675 * "
echo " * (9)=1/3 (21)=1/320 (33)=1/6316 * "
echo " * (10)=1/5 (22)=1/420 (34)=1/8147 * "
echo " * (11)=1/5 (23)=1/500 ${XYC_SEC} * "
echo " *********************************** "
local REPLY=$EXP
read -p "${XYC_SELECT_OPTION}: 0-34: " REPLY
case $REPLY in
0) EXP=0;;
1) EXP=1;;
2) EXP=8;;
3) EXP=50;;
4) EXP=84;;
5) EXP=100;;
6) EXP=200;;
7) EXP=400;;
8) EXP=500;;
9) EXP=590;;
10) EXP=600;;
11) EXP=700;;
12) EXP=800;;
13) EXP=900;;
14) EXP=1000;;
15) EXP=1100;;
16) EXP=1145;;
17) EXP=1200;;
18) EXP=1275;;
19) EXP=1300;;
20) EXP=1405;;
21) EXP=1450;;
22) EXP=1500;;
23) EXP=1531;;
24) EXP=1600;;
25) EXP=1607;;
26) EXP=1660;;
27) EXP=1700;;
28) EXP=1750;;
29) EXP=1800;;
30) EXP=1825;;
31) EXP=1850;;
32) EXP=1900;;
33) EXP=2000;;
34) EXP=2047;;
esac
}
expView ()
{
case $1 in
0) EXPVIEW="Auto";;
1) EXPVIEW="7.9 sec";;
8) EXPVIEW="7.7 sec";;
50) EXPVIEW="6.1 sec";;
84) EXPVIEW="5 sec";;
100) EXPVIEW="4.6 sec";;
200) EXPVIEW="2.7 sec";;
400) EXPVIEW="1 sec";;
500) EXPVIEW="1 sec";;
590) EXPVIEW="1/3 sec";;
600) EXPVIEW="1/5 sec";;
700) EXPVIEW="1/5 sec";;
800) EXPVIEW="1/10 sec";;
900) EXPVIEW="1/15 sec";;
1000) EXPVIEW="1/30 sec";;
1100) EXPVIEW="1/50 sec";;
1145) EXPVIEW="1/60 sec";;
1200) EXPVIEW="1/80 sec";;
1275) EXPVIEW="1/125 sec";;
1300) EXPVIEW="1/140 sec";;
1405) EXPVIEW="1/250 sec";;
1450) EXPVIEW="1/320 sec";;
1500) EXPVIEW="1/420 sec";;
1531) EXPVIEW="1/500 sec";;
1600) EXPVIEW="1/624 sec";;
1607) EXPVIEW="1/752 sec";;
1660) EXPVIEW="1/1002 sec";;
1700) EXPVIEW="1/1244 sec";;
1750) EXPVIEW="1/1630 sec";;
1800) EXPVIEW="1/2138 sec";;
1825) EXPVIEW="1/2448 sec";;
1850) EXPVIEW="1/2803 sec";;
1900) EXPVIEW="1/3675 sec";;
2000) EXPVIEW="1/6316 sec";;
2047) EXPVIEW="1/8147 sec";;
esac
}
getISOInput ()
{
clear
if [[ -z $AUTAN ]]; then
expView $EXP
echo " * ${XYC_EXPOSURE}: $EXPVIEW "
elif [ $AUTAN -eq 2 ]; then
echo " * ${XYC_HDR}1 : 7.9 sec "
echo " * ${XYC_HDR}2 : 5.4 sec "
echo " * ${XYC_HDR}3 : 3.5 sec "
echo " * ${XYC_HDR}4 : 1.8 sec "
echo " * ${XYC_HDR}5 : 1.0 sec "
echo " * ${XYC_HDR}6 : 1/15 sec "
elif [ $AUTAN -eq 1 ]; then
echo " * ${XYC_HDR}1 : 1/15 sec "
echo " * ${XYC_HDR}2 : 1/50 sec "
echo " * ${XYC_HDR}3 : 1/245 sec "
echo " * ${XYC_HDR}4 : 1/520 sec "
echo " * ${XYC_HDR}5 : 1/1630 sec"
echo " * ${XYC_HDR}6 : 1/8147 sec"
elif [ $AUTAN -eq 0 ]; then
expView $HDR1
echo " * ${XYC_HDR}1 : $EXPVIEW "
expView $HDR2
echo " * ${XYC_HDR}2 : $EXPVIEW "
expView $HDR3
echo " * ${XYC_HDR}3 : $EXPVIEW "
fi
echo ""
echo " *********** ${XYC_ISO_MENU} *********** "
echo " * (0)=Auto (5)=1600 * "
echo " * (1)=100 (6)=3200 * "
echo " * (2)=200 (7)=6400 * "
echo " * (3)=400 (8)=12800 Warning! * "
echo " * (4)=800 (9)=25600 Warning! * "
echo " *********************************** "
local REPLY=$ISO
read -p "${XYC_SELECT_OPTION}: 0-9: " REPLY
case $REPLY in
0) ISO=0;;
1) ISO=100;;
2) ISO=200;;
3) ISO=400;;
4) ISO=800;;
5) ISO=1600;;
6) ISO=3200;;
7) ISO=6400;;
8) ISO=12800;;
9) ISO=25600;;
esac
}
getAWBInput ()
{
clear
local REPLY=$AWB
read -p "${XYC_ENTER_AWB_PROMPT} [${XYC_ENTER}=$AWB]: " REPLY
if [[ "$REPLY" == ${XYC_Y} || "$REPLY" == ${XYC_N} ]]; then AWB=$REPLY; fi
}
getNRInput ()
{
clear
echo " ******* ${XYC_NR_MENU} ****** "
echo " * (0) ${XYC_DEFAULT} * "
echo " * (1) ${XYC_DISABLE_NR} * "
echo " * (2) NR 500 * "
echo " * (3) NR 2048 * "
echo " * (4) ${XYC_MAX_NR} * "
echo " * (5) ${XYC_CUSTOM_NR} * "
echo " *********************************** "
local REPLY
read -p "${XYC_SELECT_OPTION}: " REPLY
case $REPLY in
0) unset NR;;
1) NR=-1;;
2) NR=500;;
3) NR=2048;;
4) NR=16383;;
*) getCustomNRInput;;
esac
}
getCustomNRInput ()
{
clear
local REPLY=$NR
read -p "${XYC_CUSTOM_NR_PROMPT} [${XYC_ENTER}=$NR]: " REPLY
if [ $REPLY -le 16383 -a $REPLY -ge 0 ]; then NR=$REPLY; fi
}
getShadowInput ()
{
clear
local REPLY=$SHADOW
read -p "${XYC_SHADOW_PROMPT} [${XYC_ENTER}=$SHADOW]: " REPLY
if [[ "$REPLY" == ${XYC_Y} || "$REPLY" == ${XYC_N} ]]; then SHADOW=$REPLY; fi
}
getRawInput ()
{
clear
local REPLY=$RAW
read -p "${XYC_CREATE_RAW_PROMPT} [${XYC_ENTER}=$RAW]: " REPLY
if [[ "$REPLY" == ${XYC_Y} || "$REPLY" == ${XYC_N} ]]; then RAW=$REPLY; fi
}
getSharpnessInput ()
{
clear
echo " ********** ${XYC_SHARPNESS_MODE} ********* "
echo " * (0) ${XYC_DEFAULT} * "
echo " * (1) ${XYC_SHR_MODE_VIDEO} * "
echo " * (2) ${XYC_SHR_MODE_FAST} * "
echo " * (3) ${XYC_SHR_MODE_LOWISO} * "
echo " * (4) ${XYC_SHR_MODE_HIGHISO} * "
echo " *********************************** "
local REPLY=$SHR
read -p "${XYC_SELECT_OPTION}: " REPLY
case $REPLY in
0) unset SHR return;;
1) SHR=0;;
2) SHR=1;;
3) SHR=2;;
4) SHR=3;;
esac
if [[ ! -z $SHR ]]; then
getSharpFirInput
fi
}
getSharpFirInput ()
{
clear
local REPLY=$FIR
read -p "${XYC_SHARPNESS_FIR_PROMPT} [${XYC_ENTER}=$FIR]: " REPLY
if [ -n "$REPLY" ]; then
FIR=$REPLY;
elif [ -z "$FIR" ]; then
FIR=100;
fi
getSharpCorInput
}
getSharpCorInput ()
{
clear
local REPLY=$COR
read -p "${XYC_SHARPNESS_COR_PROMPT} [${XYC_ENTER}=$COR]: " REPLY
if [ -n "$REPLY" ]; then
COR=$REPLY;
elif [ -z "$COR" ]; then
COR=104;
fi
}
getYiMaxInput ()
{
clear
local REPLY=$YIMAX
read -p "${XYC_YIMAX_PROMPT} [${XYC_ENTER}=$YIMAX]: " REPLY
if [[ "$REPLY" == ${XYC_Y} || "$REPLY" == ${XYC_N} ]]; then YIMAX=$REPLY; fi
}
getVideoInput ()
{
clear
echo " ********* ${XYC_VIDEO_RESOLUTION} ******** "
echo " * (0) ${XYC_DEFAULT} (4) 1920x1080 * "
echo " * (1) 1280x720 (5) 2304x1296 * "
echo " * (2) 1280x960 (6) 2560x1440 * "
echo " * (3) 1600x1200 * "
echo " *********************************** "
local REPLY=$RES
read -p "${XYC_SELECT_OPTION}: " REPLY
case $REPLY in
0) RES=0; return;;
1) RES=1;;
2) RES=2;;
3) RES=3;;
4) RES=4;;
5) RES=5;;
6) RES=6;;
esac
if [[ $RES -eq 5 || $RES -eq 6 ]]; then
FPS=1; getVideoBitrateInput
else
getVideoFrequencyInput
fi
}
getVideoFrequencyInput ()
{
clear
echo " ********* ${XYC_VIDEO_FREQUENCY} ********* "
echo " * (1) 30 FPS * "
echo " * (2) 60 FPS * "
if [ $RES -eq 1 ]; then
echo " * (3) 120 FPS * "
fi
echo " *********************************** "
local REPLY
read -p "${XYC_SELECT_OPTION}: " REPLY
if [ -ne $REPLY ]; then
REPLY=$FPS
fi
case $REPLY in
1) FPS=1;;
2) FPS=2;;
3) if [ $RES -eq 1 ]; then
FPS=3
else
FPS=1
fi;;
esac
getVideoBitrateInput
}
getVideoBitrateInput ()
{
clear
echo " ********** ${XYC_VIDEO_BITRATE} ********** "
echo " * (1) 20 Mb/s (5) 40 Mb/s * "
echo " * (2) 25 Mb/s (6) 45 Mb/s * "
echo " * (3) 30 Mb/s (7) 50 Mb/s * "
echo " * (4) 35 Mb/s * "
echo " *********************************** "
local REPLY
read -p "${XYC_SELECT_OPTION}: " REPLY
if [ -n "$REPLY" ]; then
BIT=$REPLY;
fi
setRESView
if [ $RES -eq 6 ]; then
showResolutionWarning
fi
}
setRESView ()
{
if [ $RES -eq 1 ]; then
RESVIEW="720p"
if [ $FPS -eq 1 ]; then
RESVIEW="$RESVIEW@30"
elif [ $FPS -eq 2 ]; then
RESVIEW="$RESVIEW@60"
elif [ $FPS -eq 3 ]; then
RESVIEW="$RESVIEW@120"
fi
elif [ $RES -eq 2 ]; then
RESVIEW="960p"
if [ $FPS -eq 1 ]; then
RESVIEW="$RESVIEW@30"
elif [ $FPS -eq 2 ]; then
RESVIEW="$RESVIEW@60"