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

set_zoom problems in uBASIC & Lua scripts

  • 91 Replies
  • 46862 Views
set_zoom problems in uBASIC & Lua scripts
« on: 09 / November / 2011, 22:17:24 »
Advertisements
I need some help from the CHDK user community.  The following simple script should let you zoom in and out under script control using the Left and Right buttons on the back of your camera. Save it as zoomtest.bas in the script subdirectory on your SD card and see if it works on your camera please ?

Update : a better test script posted here autozoom.lua

Code: [Select]
@title zoom test
@param r zoom speed
@default r 2

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

:loop
  sleep 100
  wait_click
  print "click "
  is_key k "right"
  if k=1 then goto "zoomout"
  is_key k "left"
  if k=1 then goto "zoomin"
  goto "loop"

:zoomout
  get_zoom p
  if p<s then p=p+1
  print "zoom to ",p
  set_zoom p
  goto "loop"

:zoomin
  get_zoom p
  if p>0 then p=p-1
  print "zoom to ",p
  set_zoom p
  goto "loop"

end


When I run this script on my IXUS120-SD940 or on my G10, it causes the camera to shutdown after a random number of zoom steps ( <10 ).   I believe the code to be correct (?) so therefore the set_zoom command might be buggy. Before I start digging into the CHDK source code,  I would like to know how well this script works on your camera ?

Thank in advance !

Update : Lua version (zoomtest.lua) - same random shutdown problem too.
Code: [Select]
--[[
@title zoom test
@param r zoom speed
@default r 2
]]

function zoomout()
  p=get_zoom()
  if p<s 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)

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

repeat
  sleep(100)
  wait_click()
  print("click ")
  if is_pressed("right") then zoomout()
end
  if is_pressed("left") then zoomin()
end
  until false


« Last Edit: 20 / July / 2012, 21:33:46 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline srsa_4c

  • ******
  • 4451
Re: set_zoom problems in uBASIC & Lua scripts - help wanted with testing
« Reply #1 on: 09 / November / 2011, 23:28:48 »
Hi!

Tried the ubasic one, works well, no crash (A420, vxworks).  :)
Slight correction: s=get_zoom_steps-1

Re: set_zoom problems in uBASIC & Lua scripts - help wanted with testing
« Reply #2 on: 09 / November / 2011, 23:46:10 »
Tried the ubasic one, works well, no crash (A420, vxworks).
Slight correction: s=get_zoom_steps-1
Thanks - that's good to know.  Right now I have two cameras that don't work,  but there is a common factor in the guy who did both ports so who knows ?

 I actually thought about the s=get_zoom_steps-1 but never got it to run long enough to find out what happens if you go over the upper limit.

Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: set_zoom problems in uBASIC & Lua scripts - help wanted with testing
« Reply #3 on: 10 / November / 2011, 02:02:11 »
Works fine on G12 & SX30; but these both have heavily customised versions of lens_set_zoom_point().

One thing to try is in lens_set_zoom_point() is to change the line:
    while (zoom_busy) ;
to
    while (zoom_busy) msleep(10);

This is one of the changes I made for the G12 and SX30.
The original code is a tight infinite loop which can hang because zoom_busy doesn't get set and the task that sets it never gets any CPU time (at least that's what appears to happen).

The S95 hack to this function is another method of achieving the same result.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)


*

Offline blackhole

  • *****
  • 942
  • A590IS 101b
    • Planetary astrophotography
Re: set_zoom problems in uBASIC & Lua scripts - help wanted with testing
« Reply #4 on: 10 / November / 2011, 04:17:35 »
Works fine on A590.

Re: set_zoom problems in uBASIC & Lua scripts - help wanted with testing
« Reply #5 on: 10 / November / 2011, 04:43:48 »
Works fine on S95

*

Offline msl

  • *****
  • 1280
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: set_zoom problems in uBASIC & Lua scripts - help wanted with testing
« Reply #6 on: 10 / November / 2011, 05:36:49 »
Works fine on A720.

Works not on SX220. The script runs without zoom settings. Probably the SX220 needs the same correction like the G12 or SX30.

msl
CHDK-DE:  CHDK-DE links

*

Offline msl

  • *****
  • 1280
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: set_zoom problems in uBASIC & Lua scripts - help wanted with testing
« Reply #7 on: 10 / November / 2011, 06:25:46 »
I tested both zoom busy correction methods in lens_set_zoom_point(). The S95 variant works. The G12&SX30 method had no effect.

With this change the scripts works also on the SX220.

msl
CHDK-DE:  CHDK-DE links


*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: set_zoom problems in uBASIC & Lua scripts - help wanted with testing
« Reply #8 on: 10 / November / 2011, 06:56:50 »
I tested both zoom busy correction methods in lens_set_zoom_point(). The S95 variant works. The G12&SX30 method had no effect.

With this change the scripts works also on the SX220.

msl

Try the change I mentioned above - adding a msleep call to the while (zoom_busy) loop.
This should achieve the same result as the S95 code.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline msl

  • *****
  • 1280
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: set_zoom problems in uBASIC & Lua scripts - help wanted with testing
« Reply #9 on: 10 / November / 2011, 07:25:54 »
Yes, you're right.

Adding msleep(10) also works fine.

msl
CHDK-DE:  CHDK-DE links

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal