manual focus with display off - Script Writing - CHDK Forum  

manual focus with display off

  • 7 Replies
  • 5359 Views
manual focus with display off
« on: 31 / December / 2014, 06:06:41 »
Advertisements
I am using the lapse.lua script for my timelapse projects it works well but I want to be able to to set manual focus and leave it. This is for macro work and work with a reversed lens on a G7 and G10

Is there a script for this already or can the lapse.lua be modified so it doesn't mess around with my focus???

Re: manual focus with display off
« Reply #1 on: 31 / December / 2014, 10:56:47 »
I am using the lapse.lua script for my timelapse projects it works well but I want to be able to to set manual focus and leave it.
There are thousands and thousands of scripts for CHDK available to download.   We have no way of knowing what script "lapse.lua" does unless you either attach a copy of the script or a link to the script.

Quote
Is there a script for this already or can the lapse.lua be modified so it doesn't mess around with my focus???
If you put your camera into MF mode and set the focus (all using the normal Canon way of doing that)  then when the a script shoots that setting should stay locked where you set it.  Unless the script has code that specifically tries to change the focus.   So we would need to see the script to comment on your situaiton.
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 14120
Re: manual focus with display off
« Reply #2 on: 31 / December / 2014, 13:42:04 »
If you put your camera into MF mode and set the focus (all using the normal Canon way of doing that)  then when the a script shoots that setting should stay locked where you set it.  Unless the script has code that specifically tries to change the focus.   So we would need to see the script to comment on your situaiton.
This may not be the case if you used Canon MF mode. Turning off the display with the disp button cancels MF on (most?) cams. I don't recall if set_lcd_display does edit: confirmed it doesn't cancel MF, on A540 at least. IIRC AF lock is not canceled.
« Last Edit: 31 / December / 2014, 14:35:26 by reyalp »
Don't forget what the H stands for.

Re: manual focus with display off
« Reply #3 on: 31 / December / 2014, 13:46:27 »
deepest apologies, I looked for the name of the script in the script and couldn't find it - it's the one on the link below.
I think the camera automatically goes into AF mode when the display is turned off.

http://chdk.wikia.com/wiki/Lua/Scripts:_Accurate_Intervalometer_with_power-saving_and_pre-focus


*

Offline reyalp

  • ******
  • 14120
Re: manual focus with display off
« Reply #4 on: 31 / December / 2014, 14:45:22 »
deepest apologies, I looked for the name of the script in the script and couldn't find it - it's the one on the link below.
I think the camera automatically goes into AF mode when the display is turned off.

http://chdk.wikia.com/wiki/Lua/Scripts:_Accurate_Intervalometer_with_power-saving_and_pre-focus
That script tries to use AF Lock, I'm not sure how that will interact if you have already used MF.

It uses set_lcd_display to turn off the screen, which in my testing does not cancel MF, but it's possible this could vary among cameras.
Don't forget what the H stands for.

Re: manual focus with display off
« Reply #5 on: 01 / January / 2015, 05:40:43 »
Pretty sure If I leave the screen on the MF is maintained

Re: manual focus with display off
« Reply #6 on: 01 / January / 2015, 09:36:47 »
Pretty sure If I leave the screen on the MF is maintained
Just go through that script and delete every line that uses  set_aflock() .   
Ported :   A1200    SD940   G10    Powershot N    G16

Re: manual focus with display off
« Reply #7 on: 01 / January / 2015, 17:05:01 »
I tried deleting all references to focusing just to prove that it was too rough an idea to work, and to my horror it bricked my camera - well ok that's a lie - it seems to work with a quick test on my desk. I can maintain macro/ close focusing based on my in initial manual focus and when the script turns the display off things seem to stay ok.

The code I trashed is below - I haven't marked it up or anything

Code: [Select]
--[[
Authors: Fraser McCrossan
         Alfredo Pironti
Torben S.
Tested on G9, A2000, should work on most cameras.

An accurate intervalometer script, with pre-focus and screen power off options.
http://chdk.wikia.com/wiki/Lua/Scripts:_Accurate_Intervalometer_with_power-saving_and_pre-focus

Added on Dec 22, 2013:  Fixed display off functionality to use the recently added set_lcd_display CHDK function

Features:
 - input is frame interval plus total desired run-time (or "endless")
 - displays frame count, frame total and remaining time after each frame
   (in endless mode, displays frame count and elapsed time)
 - honours the "Display" button during frame delays (so you can
   get it running then turn off the display to save power)
 - can turn off the display a given number of frames after starting
   (might take a couple of frames longer to cycle to correct mode)
 - can pre-focus before starting then go to manual focus mode
 - use SET button to exit

 See bottom of script for main loop.
]]

--[[
@title Time-lapse
@param s Secs/frame
@default s 3
@param h Sequence hours
@default h 0
@param m Sequence minutes
@default m 0
@param e Endless?
@default e 1
@range e 0 1
@param f Fix focus at start?
@default f 0
@range f 0 1
@param d Display off frame 0=never
@default d 3
--]]

-- convert parameters into readable variable names
secs_frame, hours, minutes, endless, focus_at_start, display_off_frame = s, h, m, (e == 1), (f == 1), d

-- sanitize parameters
if secs_frame <= 0 then
secs_frame = 1
end
if hours < 0 then
hours = 0
end
if minutes <= 0 then
minutes = 1
end
if display_off_frame < 0 then
display_off_frame = 0
end

props = require "propcase"

-- derive actual running parameters from the more human-friendly input
-- parameters
function calculate_parameters (seconds_per_frame, hours, minutes)
   local ticks_per_frame = 1000 * secs_frame -- ticks per frame
   local total_frames = (((hours * 3600 + minutes * 60) - 1) / secs_frame) + 1 -- total frames
   return ticks_per_frame, total_frames
end

function print_status (frame, total_frames, ticks_per_frame, endless, free)
   if endless then
      local h, m, s = ticks_to_hms(frame * ticks_per_frame)
      print("#" .. frame .. ", " .. h .. "h " .. m .. "m " .. s .. "s")
   else
      if frame < total_frames then
        local h, m, s = ticks_to_hms(ticks_per_frame * (total_frames - frame))
      print(frame .. "/" .. total_frames .. ", " .. h .. "h" .. m .. "m" .. s .. "s/" .. free .. " left")
  else
    print(frame .. "/" .. total_frames .. ", " .. free .. " left")
  end
   end
end

function ticks_to_hms (ticks)
   local secs = (ticks + 500) / 1000 -- round to nearest seconds
   local s = secs % 60
   secs = secs / 60
   local m = secs % 60
   local h = secs / 60
   return h, m, s
end

-- sleep, but using wait_click(); return true if a key was pressed, else false
function next_frame_sleep (frame, start_ticks, ticks_per_frame, total_frames)
   -- this calculates the number of ticks between now and the time of
   -- the next frame
if frame == total_frames then
    return false
    end
   local next_frame = start_ticks + frame * ticks_per_frame
   local sleep_time = next_frame - get_tick_count()
   if sleep_time < 1 then
      sleep_time = 1
   end
   wait_click(sleep_time)
   return not is_key("no_key")
end

-- delay for the appropriate amount of time, but respond to
-- the display key (allows turning off display to save power)
-- return true if we should exit, else false
function frame_delay (frame, start_ticks, ticks_per_frame, total_frames)
   -- this returns true while a key has been pressed, and false if
   -- none
   while next_frame_sleep (frame, start_ticks, ticks_per_frame, total_frames) do
      -- honour the display button
      if is_key("display") then
-- vvvvvvv  CHANGED  vvvvvvv
-- click("display")
set_lcd_display(1)
display_off_frame = frame + display_off_frame
-- ^^^^^^^  CHANGED  ^^^^^^^
      end
      -- if set key is pressed, indicate that we should stop
      if is_key("set") then
-- vvvvvvv  ADDED  vvvvvvv
set_lcd_display(1)
-- ^^^^^^^  ADDED  ^^^^^^^
return true
      end
   end
   return false
end

-- if the display mode is not the passed mode, click display and return true
-- otherwise return false
-- vvvvvvv  REMOVED  vvvvvvv
--function seek_display_mode(mode)
--   if get_prop(props.DISPLAY_MODE) == mode then
--      return false
--   else
--      click "display"
--      return true
--   end
--end
-- ^^^^^^^  REMOVED  ^^^^^^^

-- wait for "name" button click until timeout.
-- returns true if button was clicked, false if timeout expired
function wait_button(timeout, name)
if timeout < 1 then
return false
end
local cur_timeout = timeout
local start_time = get_tick_count()
while cur_timeout > 0 do
wait_click(cur_timeout)
if is_key("no_key") then
-- timeout expired
return false
else
if is_key(name) then
-- user clicked requested key
return true
end
end
-- user clicked an unwanted key, we continue sleeping
local now = get_tick_count()
local elapsed = now - start_time
start_time = now
cur_timeout = cur_timeout - elapsed
end
return false
end


-- ^^^^^^^  CHANGED  ^^^^^^^


ticks_per_frame, total_frames = calculate_parameters(secs_frame, hours, minutes)

frame = 1
-- vvvvvvv  REMOVED  vvvvvvv
-- original_display_mode = get_prop(props.DISPLAY_MODE)
-- target_display_mode = 2 -- off
-- ^^^^^^^  REMOVED  ^^^^^^^

print "Press SET to exit"

start_ticks = get_tick_count()

while endless or frame <= total_frames do
   local free = get_jpg_count() - 1 -- to account for the one we're going to make
   -- in CHDK 1.2 we could check the return value of shoot()
   -- but get_jpg_count() gives more compatibility
   if free < 0 then
    print "Memory full"
    break
   end
   print_status(frame, total_frames, ticks_per_frame, endless, free)
-- vvvvvvv  CHANGED  vvvvvvv
   if display_off_frame > 0 and frame > display_off_frame then
      -- seek_display_mode(target_display_mode)
  set_lcd_display(0)
-- ^^^^^^^  CHANGED  ^^^^^^^
   end
   shoot()
   if frame_delay(frame, start_ticks, ticks_per_frame, total_frames) then
      print "User quit"
      break
   end
   frame = frame + 1
end

-- restore display mode
-- vvvvvvv  REMOVED  vvvvvvv
--if display_off_frame > 0 then
--   while seek_display_mode(original_display_mode) do
--      sleep(1000)
--   end
--end
-- ^^^^^^^  REMOVED  ^^^^^^^

restore()


 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal