set_zoom problems in uBASIC & Lua scripts - page 5 - General Discussion and Assistance - CHDK Forum

set_zoom problems in uBASIC & Lua scripts

  • 91 Replies
  • 42838 Views
Re: set_zoom problems in uBASIC & Lua scripts - help wanted with testing
« Reply #40 on: 20 / November / 2011, 00:14:33 »
Advertisements
a better script for testing this stuff  - runs the zoom in and out without needing to press keys

Code: [Select]
--[[
@title Autozoom
@param r zoom speed
@default r 1
]]

function zoomout()
  p=get_zoom()
  if p<s-1 then p=p+1
end
  print("zoom to ",p)
  set_zoom(p)
end


function zoomin()
  p=get_zoom()
  if p>0 then p=p-1
end
  print("zoom to ",p)
  set_zoom(p)
end

--start script

set_console_layout(10, 0, 40, 14)
set_aflock(1)

s=get_zoom_steps()
print ("started - zoom steps=", s)
set_zoom_speed(r)
print("zoom speed set to ",r)

set_zoom(0)

repeat
  sleep(100)
  for i = 1,s do
zoomout() ;
sleep(r*1000) ;
  end
  for i = 1,s do
zoomin() ;
sleep(r*1000) ;
  end
  until false

Ported :   A1200    SD940   G10    Powershot N    G16

Re: set_zoom problems in uBASIC & Lua scripts - help wanted with testing
« Reply #41 on: 20 / November / 2011, 04:58:47 »
I'm testing your last script at the moment. It incremented zoom to maximum and then started to go back. But going back it stopped at zoom=72 putting the line "zoom set to 72" again and again. Is the code correct?

---
Now the same with "zoom set to 111". I'm starting again.
---

Nevertheless camera didn't crash. SX130is with 1.01c firmware. CHDK 1418 compiled by my own (I have some changes in luascript.c however not related to zoom).

I'm still watching my camera further:)
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick

Re: set_zoom problems in uBASIC & Lua scripts - help wanted with testing
« Reply #42 on: 20 / November / 2011, 08:55:44 »
I'm testing your last script at the moment. It incremented zoom to maximum and then started to go back. But going back it stopped at zoom=72 putting the line "zoom set to 72" again and again. Is the code correct?
The code is correct.  However, my cameras have only 11 and 14 zoom steps - I wasn't thinking about cameras with a hundred steps like the SX130.  I suspect what is happening is that stepping one increment at a time results in too small a mechanical movement occasionally and the camera ignores the next request.

Try this - it takes larger zoom steps.
Code: [Select]
--[[
@title MegaAutozoom
@param r zoom speed
@default r 2
]]

function zoomout()
  p=get_zoom()
  if p<s-10 then p=p+10
end
  print("zoom to ",p)
  set_zoom(p)
end


function zoomin()
  p=get_zoom()
  if p>9 then p=p-10
end
  print("zoom to ",p)
  set_zoom(p)
end

--start script

set_console_layout(10, 0, 40, 14)
set_aflock(1)

s=get_zoom_steps()
print ("started - zoom steps=", s)
set_zoom_speed(r)
print("zoom speed set to ",r)

set_zoom(0)

repeat
  sleep(100)
  for i = 1,s do
zoomout() ;
sleep(r*1000) ;
  end
  for i = 1,s do
zoomin() ;
sleep(r*1000) ;
  end
  until false
Ported :   A1200    SD940   G10    Powershot N    G16

Re: set_zoom problems in uBASIC & Lua scripts - help wanted with testing
« Reply #43 on: 20 / November / 2011, 09:19:40 »
Same now:

Code: [Select]
zoom to 80
zoom to 90
zoom to 100
zoom to 110
zoom to 120
zoom to 120
zoom to 120
zoom to 120
zoom to 120
zoom to 120
zoom to 120
(and so on)

It's printing "zoom to 120" at the moment...

---
I left ALT mode and zoomed out a little. After back into ALT the script continued zooming in up to 121. And did not start zoom out.

So once again I left ALT mode, zoomed completely out and continue the script in ALT. It zoomed in and now it goes back.

---
Thinking about it - it seems like for runs more times than camera zoom steps (so it prints zoom-in too many times). Maybe there's some bug in get_zoom_steps() ?
« Last Edit: 20 / November / 2011, 09:23:35 by outslider »
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick


Re: set_zoom problems in uBASIC & Lua scripts - help wanted with testing
« Reply #44 on: 20 / November / 2011, 09:30:27 »
At start camera shows zoom steps to be 128.

And there's other problem - I accidentaly run this script being in play mode with closed lens - it crashed my camera. I tried then to run the script in play mode with open lens - didn't crash and of course didn't zoom. The playmode crash however shows, that CHDK maybe should do some sanity befor force to zoom while in play mode?
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick

Re: set_zoom problems in uBASIC & Lua scripts - help wanted with testing
« Reply #45 on: 20 / November / 2011, 09:54:19 »
Thinking about it - it seems like for runs more times than camera zoom steps (so it prints zoom-in too many times). Maybe there's some bug in get_zoom_steps() ?

You found it - change the loops to  for i = 1,s/10 do

The playmode crash however shows, that CHDK maybe should do some sanity befor force to zoom while in play mode?
I'm only willing to work so hard for a test script.  There is a way to detect if you are in shooting mode or playback mode from a script and change to shooting if necessary.
« Last Edit: 20 / November / 2011, 09:56:35 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

Re: set_zoom problems in uBASIC & Lua scripts - solved for the G10
« Reply #46 on: 20 / November / 2011, 10:12:44 »
With reyalp's patient help,  the zoom problem for the G10 is solved. 

I had "tested" the G12 patches in generic/wrappers.c to the function lens_set_zoom_point() and decided that they did not work for the G10.  However,  I missed an additional change that had been made for the G12 in function lens_set_focus_pos().   Once we tracked that down by working backwards through  lens_set_zoom_point(),  things started working.

Unfortunately,  this does not solve the problem with the SD940 (and likely the SD780 and SD980).  That seems to be an issue with AE rather than AF functions, although using CHDK to lock the exposure and ISO does not solve the problem.

I'll submit a patch for the G10 to the autobuild.  I bet the G11 has the same problem though ....
« Last Edit: 20 / November / 2011, 11:57:32 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline titbb

  • *
  • 38
Re: set_zoom problems in uBASIC & Lua scripts - help wanted with testing
« Reply #47 on: 21 / November / 2011, 12:08:31 »
An Error Has Occurred!
You have exceeded the limit of 5 personal messages per hour.

Lame!

@waterwingz
the autozoom script keeps on working, tested 3x
the manual one keeps crashing on me when i go too fast. every time, and the log i send you is from the manual one


Re: set_zoom problems in uBASIC & Lua scripts - help wanted with testing
« Reply #48 on: 21 / November / 2011, 12:29:10 »
Thank titbb.   I've attached the log.  This is an interesting bug - it crashes my SD940 all the time,  it only crashes your SD980 when zoom requests are made too fast (apparently).   One SD780 user reports no crashes - the other gets lots of them.   

Update :    The SD940 reports 11 zoom steps but crashes when set_zoom(10) is called.  If I change the autozoom.lua code to only go from 0 to 9,  and set the step interval to 1 second,  its seems to be willing to run all day.  If I set the step interval to 5 seconds,  it never makes it through even one complete cycle.  Can you try 5 seconds with yours ?

Also,  I just notice that the script set zoom speed to the step size too.  Not sure I really want to do that -slows down the zoom speed when you slow down how fast zoom steps happen.  Might be part of the problem with the script.
« Last Edit: 21 / November / 2011, 13:08:01 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

Re: set_zoom problems in uBASIC & Lua scripts - help wanted with testing
« Reply #49 on: 21 / November / 2011, 13:45:47 »
I started capturing ROMLOG files  (attached) as I tried different scripts.   Seems to be crashing in different places each time - I guess I need to do the same thing over & over and collect ROMLOGs rather than just collect as I go working with scripts.

I created this as well.  Proves the crash when set_zoom(10) even though there are supposed to be 11 steps.  If is set the max step variable "e" to 9 the script will run a long time (minutes) but still eventually shuts down.

Code: [Select]
--[[
@title Zoom(10) and Zoom(0)
@param s zoom speed
@default s 2
@param e end step
@default e 10
@param t step time
@default t 2
]]

set_console_layout(10, 0, 40, 14)

steps=get_zoom_steps()
print ("started - zoom steps=", steps)
set_zoom_speed(s)
print("zoom speed set to ",s)
print("zoom stop set to ",e)
print("zoom step time set to ",t)

repeat
print("zoom to 0")
set_zoom(0)
sleep(t*1000)
print("zoom to ",e)
set_zoom(e)
sleep(t*1000)
  until false
« Last Edit: 21 / November / 2011, 14:06:14 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

 

Related Topics