All Zoom / get_user_av_id table - Script Writing - CHDK Forum supplierdeeply

All Zoom / get_user_av_id table

  • 4 Replies
  • 2933 Views
All Zoom / get_user_av_id table
« on: 04 / May / 2015, 18:16:21 »
Advertisements
I'm trying to get the entire zoom step / get_user_av_id table using sx150is-100a-1.4.0-r4153.

The camera only has adjustable aperture I believe (get_nd_present() => 0).

I haven't much converted this to functions yet, but the following code seems to consistently create Av values from zoom 0 to zoom 110 but fails to produce up to 127 (i.e 128 if equating 0 to 1) no matter how much sleep is introduced.

If I restart the script, making other relevant changes, set_zoom = 111 it seems to append the last entries in the log fine.

I'm missing a trick or more here so would appreciate any comment / script improvement as fix:

Code: [Select]
function sd_logzoom(msg)
local logzoomname = "A/zoom_step_av_value.csv"
logzoom = io.open(logzoomname,"a")
logzoom:write("\n",msg,"\n")
logzoom:close()
end

--[[
use erase button to select Av adjustment prior to run
allow 5 secs for zoom to retract if start is at maximum
]]

--if get_nd_present() == 1 then

set_zoom(0)
sleep(5000)

for i = 0, get_zoom_steps() -1, 1 do

sd_logzoom(i + 1)

--[[
for each zoom step initialise the aperture
at the largest available value. This procedure
relies on sufficient sleep value to ensure the
Jog Dial movement has activated
]]

repeat
initial_get_user_av_id = get_user_av_id()
post_levent_to_ui("RotateJogDialLeft",1)
sleep(300)
new_get_user_av_id = get_user_av_id()
until new_get_user_av_id == initial_get_user_av_id

--[[
for each zoom step use JogDial right to step through
and record all available Aperture values. This
procedure relies on sufficient sleep value to ensure the
Jog Dial movement has activated
]]

logavname="A/zoom_step_av_value.csv"
logav=io.open(logavname,"a")

repeat
initial_get_user_av_id = get_user_av_id()
logav:write(initial_get_user_av_id,"|")
post_levent_to_ui("RotateJogDialRight",1)
sleep(300)
new_get_user_av_id = get_user_av_id()
until new_get_user_av_id == initial_get_user_av_id

logav:close()

j = i + 1
set_zoom(j)

repeat
sleep(40)
new_set_zoom = get_zoom()
until new_set_zoom == j

end

--end
   
and "A/zoom_step_av_value.csv" content:

Code: [Select]

1
347|384|416|448|480|512|544|576|
2
347|384|416|448|480|512|544|576|
3
347|384|416|448|480|512|544|576|
4
347|384|416|448|480|512|544|576|
5
347|384|416|448|480|512|544|576|
6
347|384|416|448|480|512|544|576|
7
347|384|416|448|480|512|544|576|
8
347|384|416|448|480|512|544|576|
9
347|384|416|448|480|512|544|576|
10
347|384|416|448|480|512|544|576|
11
347|384|416|448|480|512|544|576|
12
347|384|416|448|480|512|544|576|
13
384|416|448|480|512|544|576|
14
384|416|448|480|512|544|576|
15
384|416|448|480|512|544|576|
16
384|416|448|480|512|544|576|
17
384|416|448|480|512|544|576|
18
384|416|448|480|512|544|576|
19
384|416|448|480|512|544|576|
20
384|416|448|480|512|544|576|
21
384|416|448|480|512|544|576|
22
384|416|448|480|512|544|576|
23
384|416|448|480|512|544|576|
24
384|416|448|480|512|544|576|
25
384|416|448|480|512|544|576|
26
384|416|448|480|512|544|576|
27
384|416|448|480|512|544|576|
28
384|416|448|480|512|544|576|
29
384|416|448|480|512|544|576|
30
384|416|448|480|512|544|576|
31
384|416|448|480|512|544|576|
32
416|448|480|512|544|576|
33
416|448|480|512|544|576|
34
416|448|480|512|544|576|
35
416|448|480|512|544|576|
36
416|448|480|512|544|576|
37
416|448|480|512|544|576|
38
416|448|480|512|544|576|
39
416|448|480|512|544|576|
40
416|448|480|512|544|576|
41
416|448|480|512|544|576|
42
416|448|480|512|544|576|
43
416|448|480|512|544|576|
44
416|448|480|512|544|576|
45
416|448|480|512|544|576|
46
416|448|480|512|544|576|
47
416|448|480|512|544|576|
48
416|448|480|512|544|576|
49
416|448|480|512|544|576|
50
416|448|480|512|544|576|
51
416|448|480|512|544|576|
52
416|448|480|512|544|576|
53
448|480|512|544|576|
54
448|480|512|544|576|
55
448|480|512|544|576|
56
448|480|512|544|576|
57
448|480|512|544|576|
58
448|480|512|544|576|
59
448|480|512|544|576|
60
448|480|512|544|576|
61
448|480|512|544|576|
62
448|480|512|544|576|
63
448|480|512|544|576|
64
448|480|512|544|576|
65
448|480|512|544|576|
66
448|480|512|544|576|
67
448|480|512|544|576|
68
448|480|512|544|576|
69
448|480|512|544|576|
70
448|480|512|544|576|
71
448|480|512|544|576|
72
448|480|512|544|576|
73
448|480|512|544|576|
74
448|480|512|544|576|
75
448|480|512|544|576|
76
448|480|512|544|576|
77
448|480|512|544|576|
78
448|480|512|544|576|
79
448|480|512|544|576|
80
448|480|512|544|576|
81
448|480|512|544|576|
82
448|480|512|544|576|
83
448|480|512|544|576|
84
448|480|512|544|576|
85
448|480|512|544|576|
86
448|480|512|544|576|
87
448|480|512|544|576|
88
448|480|512|544|576|
89
448|480|512|544|576|
90
448|480|512|544|576|
91
448|480|512|544|576|
92
448|480|512|544|576|
93
448|480|512|544|576|
94
448|480|512|544|576|
95
448|480|512|544|576|
96
448|480|512|544|576|
97
448|480|512|544|576|
98
448|480|512|544|576|
99
448|480|512|544|576|
100
448|480|512|544|576|
101
448|480|512|544|576|
102
448|480|512|544|576|
103
448|480|512|544|576|
104
448|480|512|544|576|
105
480|512|544|576|
106
480|512|544|576|
107
480|512|544|576|
108
480|512|544|576|
109
480|512|544|576|
110
480|512|544|576|
111
480|512|544|576|

*

Offline reyalp

  • ******
  • 14037
Re: All Zoom / get_user_av_id table
« Reply #1 on: 05 / May / 2015, 01:12:48 »
but the following code seems to consistently create Av values from zoom 0 to zoom 110 but fails to produce up to 127 (i.e 128 if equating 0 to 1) no matter how much sleep is introduced.
What specifically does the script do when it fails? Does it wait forever in the last repeat loop?

Quote
I'm missing a trick or more here so would appreciate any comment / script improvement as fix:
I don't think you are missing any specific trick, you just need to debug it to find out exactly what is going on.
Don't forget what the H stands for.

Re: All Zoom / get_user_av_id table
« Reply #2 on: 05 / May / 2015, 06:02:39 »
Does it wait forever in the last repeat loop?
Yes.

Print statements now added at start and end of loop and chdkptp screenshot attached (Edit: oh & padding for Av n/a items):

Code: [Select]
function sd_logzoom(msg)
local logzoomname = "A/zoom_step_av_value.csv"
logzoom = io.open(logzoomname,"a")

if msg == 0 then
logzoom:write(msg,"|") else
logzoom:write("\n",msg,"|")
end

logzoom:close()
end

--[[
use erase button to select Av adjustment prior to run
allow 3 secs for zoom to retract if start is at maximum
]]

--if get_nd_present() == 1 then

set_zoom(0)
sleep(3000)

for i = 0, get_zoom_steps(), 1 do

sd_logzoom(i)

--[[
for each zoom step initialise the aperture
at the largest available value. This procedure
relies on sufficient sleep value to ensure the
Jog Dial movement has activated
]]

repeat
initial_get_user_av_id = get_user_av_id()
post_levent_to_ui("RotateJogDialLeft",1)
sleep(300)
new_get_user_av_id = get_user_av_id()
until new_get_user_av_id == initial_get_user_av_id

--[[
for each zoom step use JogDial right to step through
and record all available Aperture values. This
procedure relies on sufficient sleep value to ensure the
Jog Dial movement has activated
]]

logavname="A/zoom_step_av_value.csv"
logav=io.open(logavname,"a")

count_repeat = 1

repeat
initial_get_user_av_id = get_user_av_id()
logav:write(initial_get_user_av_id,"|")
post_levent_to_ui("RotateJogDialRight",1)
sleep(300)
new_get_user_av_id = get_user_av_id()
count_repeat = count_repeat + 1
until new_get_user_av_id == initial_get_user_av_id

--pad out n/a entries
if count_repeat == 7 then
logav:write("|")
end

if count_repeat == 6 then
logav:write("|","|")
end

if count_repeat == 5 then
logav:write("|","|","|")
end

if count_repeat == 4 then
logav:write("|","|","|","|")
end
--end padding

logav:close()

current_zoom_step = get_zoom()
print("current_zoom_step = "..current_zoom_step)

j = i + 1
set_zoom(j)

repeat
sleep(40)
new_set_zoom = get_zoom()
until new_set_zoom == j

print("new_zoom_step = "..new_set_zoom)

end

--end

Edit:

PS: a new chdkptp win32.zip for download would be really handy at the minute to allow this http://chdk.setepontos.com/index.php?topic=6231.msg119292#msg119292

Code: [Select]
= <myfile.lua
 :-* 
« Last Edit: 05 / May / 2015, 15:42:57 by andrew.stephens.754365 »

*

Offline reyalp

  • ******
  • 14037
Re: All Zoom / get_user_av_id table
« Reply #3 on: 05 / May / 2015, 16:39:04 »
Yes.

Print statements now added at start and end of loop and chdkptp screenshot attached
So, after the final set_zoom, the either get_zoom isn't correctly reporting the change, or the zoom doesn't get set to exactly the requested value.

I'd suspect the second case. If this is happening, you need to update your logic to account for it, perhaps by putting a timeout in the loop that waits for the zoom change. The correct way to dealing with this will depend on the exact behavior. For example, when set_zoom(112) is called, does the zoom not change at all, or does it go past the requested value? If it isn't changing at all, what happens if you just continue and call set_zoom(113)

I'm pretty sure I've seen get_zoom returning slightly different values than expected. I think in the case I saw it changed after half press, but I may be misremembering.

Quote
PS: a new chdkptp win32.zip for download would be really handy at the minute to allow this http://chdk.setepontos.com/index.php?topic=6231.msg119292#msg119292

Code: [Select]
= <myfile.lua
There haven't been any C code changes, so you could just use the latest lua files from svn.
Don't forget what the H stands for.


Re: All Zoom / get_user_av_id table
« Reply #4 on: 06 / May / 2015, 04:41:31 »
The correct way to dealing with this will depend on the exact behavior.
Ah, of course - silly me.

This is v.inelegant, leaves most/all questions open - but works for now. On timeout I zoomed back to zero then back out to the sticking point. I still need to understand var scope better so that is not pretty either but must suffice for a first lua script:

Code: [Select]
function set_the_zoom(msg1)
set_zoom(msg1)

--allow 3 secs for zoom to retract if start is at maximum
if msg1 == 0 then
sleep(3000)
end

local cum_time
local new_set_zoom
local count_repeat = 1
local sleep_time = 40
local timeout = 5000

repeat
sleep(sleep_time)

cum_time = count_repeat * sleep_time
print("approx_cum_time_awaiting_zoom_change = "..cum_time)
count_repeat = count_repeat + 1
--original testing zoom "stuck" at i=110, this is dirty fix:
if cum_time > timeout then
set_zoom(0)
sleep(3000)
set_zoom(msg1)
sleep(3000)

end

new_set_zoom = get_zoom()
until new_set_zoom == msg1

print("new_zoom_step = "..new_set_zoom)

end

function sd_logzoom(msg2)
local logzoomname = "A/zoom_step_av_value.csv"
logzoom = io.open(logzoomname,"a")

if msg2 == 0 then
logzoom:write(msg2,"|") else
logzoom:write("\n",msg2,"|")
end

logzoom:close()
end

--[[
before running:
use erase button to select Av adjustment
copy empty file to "A/zoom_step_av_value.csv"
]]

--if get_nd_present() == 1 then

-- since return get_zoom_steps() is 128, subtract 1:
for i = 0, get_zoom_steps() - 1, 1 do

set_the_zoom(i)
sd_logzoom(i)

--[[
for each zoom step initialise the aperture
at the largest available value. This procedure
relies on sufficient sleep value to ensure the
Jog Dial movement has activated
]]

repeat
initial_get_user_av_id = get_user_av_id()
post_levent_to_ui("RotateJogDialLeft",1)
sleep(300)
new_get_user_av_id = get_user_av_id()
until new_get_user_av_id == initial_get_user_av_id

--[[
for each zoom step use JogDial right to step through
and record all available Aperture values. This
procedure relies on sufficient sleep value to ensure the
Jog Dial movement has activated
]]

logavname="A/zoom_step_av_value.csv"
logav=io.open(logavname,"a")

av_count_repeat = 1

repeat
initial_get_user_av_id = get_user_av_id()
logav:write(initial_get_user_av_id,"|")
post_levent_to_ui("RotateJogDialRight",1)
sleep(300)
new_get_user_av_id = get_user_av_id()
av_count_repeat = av_count_repeat + 1
until new_get_user_av_id == initial_get_user_av_id

--pad out n/a entries
if av_count_repeat == 7 then
logav:write("|")
end

if av_count_repeat == 6 then
logav:write("|","|")
end

if av_count_repeat == 5 then
logav:write("|","|","|")
end

if av_count_repeat == 4 then
logav:write("|","|","|","|")
end
--end padding

logav:close()

end

--end

And results:
Code: [Select]
0|347|384|416|448|480|512|544|576|
1|347|384|416|448|480|512|544|576|
2|347|384|416|448|480|512|544|576|
3|347|384|416|448|480|512|544|576|
4|347|384|416|448|480|512|544|576|
5|347|384|416|448|480|512|544|576|
6|347|384|416|448|480|512|544|576|
7|347|384|416|448|480|512|544|576|
8|347|384|416|448|480|512|544|576|
9|347|384|416|448|480|512|544|576|
10|347|384|416|448|480|512|544|576|
11|347|384|416|448|480|512|544|576|
12|384|416|448|480|512|544|576|
13|384|416|448|480|512|544|576|
14|384|416|448|480|512|544|576|
15|384|416|448|480|512|544|576|
16|384|416|448|480|512|544|576|
17|384|416|448|480|512|544|576|
18|384|416|448|480|512|544|576|
19|384|416|448|480|512|544|576|
20|384|416|448|480|512|544|576|
21|384|416|448|480|512|544|576|
22|384|416|448|480|512|544|576|
23|384|416|448|480|512|544|576|
24|384|416|448|480|512|544|576|
25|384|416|448|480|512|544|576|
26|384|416|448|480|512|544|576|
27|384|416|448|480|512|544|576|
28|384|416|448|480|512|544|576|
29|384|416|448|480|512|544|576|
30|384|416|448|480|512|544|576|
31|416|448|480|512|544|576||
32|416|448|480|512|544|576||
33|416|448|480|512|544|576||
34|416|448|480|512|544|576||
35|416|448|480|512|544|576||
36|416|448|480|512|544|576||
37|416|448|480|512|544|576||
38|416|448|480|512|544|576||
39|416|448|480|512|544|576||
40|416|448|480|512|544|576||
41|416|448|480|512|544|576||
42|416|448|480|512|544|576||
43|416|448|480|512|544|576||
44|416|448|480|512|544|576||
45|416|448|480|512|544|576||
46|416|448|480|512|544|576||
47|416|448|480|512|544|576||
48|416|448|480|512|544|576||
49|416|448|480|512|544|576||
50|416|448|480|512|544|576||
51|416|448|480|512|544|576||
52|448|480|512|544|576|||
53|448|480|512|544|576|||
54|448|480|512|544|576|||
55|448|480|512|544|576|||
56|448|480|512|544|576|||
57|448|480|512|544|576|||
58|448|480|512|544|576|||
59|448|480|512|544|576|||
60|448|480|512|544|576|||
61|448|480|512|544|576|||
62|448|480|512|544|576|||
63|448|480|512|544|576|||
64|448|480|512|544|576|||
65|448|480|512|544|576|||
66|448|480|512|544|576|||
67|448|480|512|544|576|||
68|448|480|512|544|576|||
69|448|480|512|544|576|||
70|448|480|512|544|576|||
71|448|480|512|544|576|||
72|448|480|512|544|576|||
73|448|480|512|544|576|||
74|448|480|512|544|576|||
75|448|480|512|544|576|||
76|448|480|512|544|576|||
77|448|480|512|544|576|||
78|448|480|512|544|576|||
79|448|480|512|544|576|||
80|448|480|512|544|576|||
81|448|480|512|544|576|||
82|448|480|512|544|576|||
83|448|480|512|544|576|||
84|448|480|512|544|576|||
85|448|480|512|544|576|||
86|448|480|512|544|576|||
87|448|480|512|544|576|||
88|448|480|512|544|576|||
89|448|480|512|544|576|||
90|448|480|512|544|576|||
91|448|480|512|544|576|||
92|448|480|512|544|576|||
93|448|480|512|544|576|||
94|448|480|512|544|576|||
95|448|480|512|544|576|||
96|448|480|512|544|576|||
97|448|480|512|544|576|||
98|448|480|512|544|576|||
99|448|480|512|544|576|||
100|448|480|512|544|576|||
101|448|480|512|544|576|||
102|448|480|512|544|576|||
103|448|480|512|544|576|||
104|480|512|544|576||||
105|480|512|544|576||||
106|480|512|544|576||||
107|480|512|544|576||||
108|480|512|544|576||||
109|480|512|544|576||||
110|480|512|544|576||||
111|480|512|544|576||||
112|480|512|544|576||||
113|480|512|544|576||||
114|480|512|544|576||||
115|480|512|544|576||||
116|480|512|544|576||||
117|480|512|544|576||||
118|480|512|544|576||||
119|480|512|544|576||||
120|480|512|544|576||||
121|480|512|544|576||||
122|480|512|544|576||||
123|480|512|544|576||||
124|480|512|544|576||||
125|480|512|544|576||||
126|480|512|544|576||||
127|480|512|544|576||||
I'm pretty sure I've seen get_zoom returning slightly different values than expected. I think in the case I saw it changed after half press, but I may be misremembering.
Ok, I hope that sticks in memory somewhere - I do remember over/undershoot while clicking buttons
http://chdk.setepontos.com/index.php?topic=11667.msg117844#msg117844

I don't have a local svn (although I guess it's part of chdk-shell) - i'll try to look into that.

Thanks.
« Last Edit: 06 / May / 2015, 11:44:00 by andrew.stephens.754365 »

 

Related Topics