source: trunk/CHDK/SCRIPTS/TEST/ubtest.bas @ 3421

Revision 3291, 3.9 KB checked in by reyalp, 4 months ago (diff)

add more keys to ubtest.bas from nafraf in http://chdk.setepontos.com/index.php?topic=650.1270

Line 
1@title ubasic functionality test
2@param a interactive
3@default a 1
4@param b sleep between tests sec/10
5@default b 5
6rem test various ubasic commands
7
8b=b*100
9
10rem fail flag
11f=0
12
13rem output to CHDK/LOGS/LOG_0001.TXT
14print_screen 1
15print "test plat", get_platform_id, "pset",get_propset
16
17print "sleep/tick test"
18s=get_tick_count
19sleep 500
20t=get_tick_count
21r=t-s
22print "start",s,"end",t,"dif",r
23rem per line yield means we might not be exactly 500
24if r < 500 or r > 550 then
25        gosub "set_fail"
26        print "failed"
27endif
28
29rem key input test
30if a <> 1 then goto "keyin_done"
31
32rem note not all keys are valid on all cameras
33print "key test - set to end"
34do
35        wait_click 1000
36    if is_key "up"        then print "up"
37    if is_key "down"      then print "down"
38    if is_key "left"      then print "left"
39    if is_key "right"     then print "right"
40    if is_key "remote"    then print "remote"
41    if is_key "display"   then print "disp"
42    if is_key "menu"      then print "menu"
43    if is_key "set"       then print "set"
44    if is_key "erase"     then print "erase"
45    if is_key "zoom_in"   then print "zoom in"
46    if is_key "zoom_out"  then print "zoom out"
47    if is_key "mode"      then print "mode"
48    if is_key "help"      then print "help"
49    if is_key "video"     then print "video"
50    if is_key "playback"  then print "playback"
51until is_key "set"
52
53sleep b
54
55:keyin_done
56print "key press test"
57rem opening menu and moving up and down should be safe and work everywhere
58press "menu"
59sleep 50
60release "menu"
61sleep 1000
62click "down"
63sleep 1000
64click "up"
65sleep 1000
66click "menu"
67sleep b
68
69rem mode switch test
70if get_mode=1 then
71        print "try to switch to rec"
72        c=0
73        set_record 1
74        while get_mode=1 and c < 20
75                sleep 100
76                c = c  + 1
77        wend
78        if c = 20 then
79                print "switching to rec failed"
80rem can't continue if not rec
81                gosub "set_fail"
82                goto "the_end"
83        endif
84else
85        print "already in rec"
86endif
87
88rem TODO some cameras need additional sleep between play->rec and mode switch (g12, ?)
89sleep 1000
90
91c = get_capture_mode
92print "current mode ",c
93
94if c <> 2 then
95rem I think all cameras have P (might be called manual)
96        print "try switch to P"
97        set_capture_mode 2
98        print "new mode", get_capture_mode
99        if get_capture_mode <> 2 then
100                gosub "set_fail"
101        endif
102endif
103rem TODO should switch to A (1) and back to P to test mode switching
104
105n=get_exp_count
106print "exp_count", n
107rem half shot and read exposure values
108c = 0
109press "shoot_half"
110while get_shooting <> 1 and c < 30
111        sleep 100
112        c = c + 1
113wend
114if c = 30 then
115        print "halfshoot failed"
116        gosub "set_fail"
117endif
118p=get_av96
119s=get_sv96
120t=get_tv96
121print "Av", p, "Sv", s, "Tv", t
122print "shot - default",get_exp_count + 1
123press "shoot_full"
124sleep 50
125release "shoot_full"
126release "shoot_half"
127
128while get_shooting <> 0
129        sleep 100
130wend
131
132rem a little more to make sure shooting is really done
133sleep 500
134
135print "exp_count", get_exp_count
136n=n+1
137if n <> get_exp_count then
138        print "exp count or shot fail"
139        gosub "set_fail"
140endif
141
142rem if auto Tv > 1/250, use -2 stop otherwise +2
143if t > 768 then
144        print "shoot Tv-2",get_exp_count + 1
145        set_tv96_direct t-192
146else
147        print "shoot Tv+2",get_exp_count + 1
148        set_tv96_direct t+192
149endif
150shoot
151
152sleep b
153
154rem if out Sv > 200, use -2 stop, otherwise +2
155if s > 576 then
156        print "shoot Sv-2",get_exp_count + 1
157
158        set_sv96 s-192
159else
160        print "shoot Sv+2",get_exp_count + 1
161        set_sv96 s+192
162endif
163shoot
164
165sleep b
166
167rem get nd filter - 0=no ND, iris assumed; 1=nd, no iris; 2=both
168if get_nd_present = 0 or get_nd_present = 2 then
169rem TODO valid ranges depend on zoom hard to tell what to use
170        print "cam has iris"
171endif
172
173if get_nd_present > 0 then
174        print "shoot ND in",get_exp_count + 1
175        set_nd_filter 1
176        shoot
177
178        sleep b
179
180        print "shoot ND out",get_exp_count + 1
181        set_nd_filter 2
182        shoot
183
184        sleep b
185endif
186
187goto "the_end"
188
189rem subs
190:set_fail
191        f=f+1
192        return
193
194rem final cleanup
195:the_end
196if f > 0 then
197        print "failed ",f
198else
199        print "ok"
200endif
201print_screen 0
202rem this should not appear in the log
203
204print "done"
205
Note: See TracBrowser for help on using the repository browser.