Set A Static Focus Intervolometer - page 2 - LUA Scripting - CHDK Forum

Set A Static Focus Intervolometer

  • 16 Replies
  • 8303 Views
Re: Set A Static Focus Intervolometer
« Reply #10 on: 05 / July / 2009, 17:55:07 »
Advertisements
Don't seem to work with Digic II propcases.
[/quote]

Have you tried daylapse.bas?  I put in the propcase test for DigicII but no feedback yet for DigicII cams.

Daylapse successfully restores MF mode after idle, and sets nominated distance -- static focus.

Re: Set A Static Focus Intervolometer
« Reply #11 on: 16 / July / 2009, 05:00:41 »
I have also been working on an intervalometer with the focus set at infinity. It is designed to record road trips.

I used Fraser McCrossan's 'Accurate Intervalometer with power-saving and pre-focus' as a starting point and have stripped his code down to reduce power consumption.

I also added an occasional light reading, by default every 10 mins. It shoots until either the battery or SD card fail but it does give a warning message saying what's wrong.

However, this is my first attempt at a uBASIC or LUA script and my A460 objects to something. It doesn't have a problem with the original LUA script so it's my fault.

The message is 'uBASIC:1 Unk stmt'.

I would greatly appreciate help debugging it.

Many thanks



Code: [Select]


--[[
Author: Andrew baisley
Heavily based on Fraser McCrossan's 'Accurate Intervalometer with power-saving and pre-focus'
Many, many thanks

Tested on A460, should work on most cameras.

An accurate intervalometer script designed for shooting road trips.

Features:
* focus fixed at infinity
* power saving
* endless loop until power or memory fail
* occasional light reading.
--]]

--[[
@title Cycle Lapse
@param s Secs per frame
@default s 10
@param m Mins per light reading
@default m 10
--]]

-- convert parameters into readable variable names
secs_frame, mins_per_reading = s, m

props = require "propcase"

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

-- switch to autofocus mode, focus on infinity, then go to manual focus mode
function light_reading()
   set_aflock(0)
   press("shoot_half")
   sleep(2000)
   set_focus(65535)
   set_aflock(1)
   release("shoot_half")
   sleep(500)
end

-- switch off display, setting 2
while seek_display_mode(2) do
   sleep(1000)
end

set_aflock(1)
light_reading()
start_ticks = get_tick_count()
ticks_per_frame = 1000 * secs_frame
frames_per_meter = mins_per_reading * 60 / secs_frame
frame = 1

-- shoot until battery or card fails
while get_vbatt >= 2150 and get_free_disk_space >= 200000  do
   set_backlight(0)
   shoot()
   if frame % frames_per_meter == 0 then light_reading() end
   wait( (start_ticks + frame * ticks_per_frame) - get_tick_count() )
   frame = frame + 1
end

-- backlight on
set_backlight(1)

-- display on, setting = 0
while seek_display_mode(0) do
   sleep(1000)
end


-- restore focus mode
set_aflock(0)

-- print warning messages and sound alarm
if get_vbatt < 2200 then print("** CHANGE BATTERY **") end
if get_free_disk_space < 100000 then print("++ CHANGE MEMORY CARD ++") end
play_sound(7)




*

Offline fe50

  • ******
  • 3139
  • IXUS50 & 860, SX10 Star WARs-Star RAWs
    • fe50
Re: Set A Static Focus Intervolometer
« Reply #12 on: 16 / July / 2009, 05:57:17 »
Hello & welcome, ajb1970 !
The message is 'uBASIC:1 Unk stmt'.
Your script is a Lua scrip, it must be named script.lua !
The error message indicates that the file is not identified as a lua script - all files with other extensions than .lua are processed as uBasic script.

Note: Windows labels text files with .txt by default but doesn't show this extension; so maybe the true (full) file name is script.lua.txt although you see script.lua in Windows Explorer or in the Notepad editor...

Re: Set A Static Focus Intervolometer
« Reply #13 on: 16 / July / 2009, 06:15:43 »
The script is properly named.

Is there a maximum filename length? Or disallowed characters?


Re: Set A Static Focus Intervolometer
« Reply #14 on: 16 / July / 2009, 06:26:55 »
Renamed my script as cycle.lua and it works!!!

Thanks for your help

*

Offline fe50

  • ******
  • 3139
  • IXUS50 & 860, SX10 Star WARs-Star RAWs
    • fe50
Re: Set A Static Focus Intervolometer
« Reply #15 on: 16 / July / 2009, 07:04:43 »
Is there a maximum filename length? Or disallowed characters?
Just for the file...

On DryOS based cameras filenames with 8.3 characters should be used, long filenames will be shown in short format & could make trouble...
VxWorks based cameras (as the A460) can use long filenames.

...if you don't know the camera's OS, go to the camera's wikia page, e.g. A460...

Re: Set A Static Focus Intervolometer
« Reply #16 on: 16 / July / 2009, 07:19:50 »
Having said everything was hunky dory...it isn't.

It runs, but fails to take any shots and eventually turns itself off.

Have you any tips for debugging techniques?

 

Related Topics