How to set camera time with scripts "lua or uBasic"? - page 2 - Script Writing - CHDK Forum

How to set camera time with scripts "lua or uBasic"?

  • 22 Replies
  • 13369 Views
*

Offline reyalp

  • ******
  • 14082
Re: How to set camera time with scripts "lua or uBasic"?
« Reply #10 on: 20 / December / 2011, 23:57:04 »
Advertisements
so, if the eventproc wasn't registered what should I do?
Find the function the registers it. On D10, the following worked for me
Code: [Select]
call_event_proc('FA.Create')
call_event_proc('InitializeAdjustmentFunction')
call_event_proc('SetMinute',54)

edit:
lua_call_Native is the only option you need to change from defaults to enable calling events procs. If you didn't do that, you'd get a very obvious runtime error when you tried to use call_event_proc.
« Last Edit: 20 / December / 2011, 23:59:12 by reyalp »
Don't forget what the H stands for.

Re: How to set camera time with scripts "lua or uBasic"?
« Reply #11 on: 21 / December / 2011, 08:38:26 »
Hi Reyalp:

Again, thank you so much for your help.   :)
I am good to go.

This works!
Quote
call_event_proc('FA.Create')
call_event_proc('InitializeAdjustmentFunction')
call_event_proc('SetMinute',54)

Re: How to set camera time with scripts "lua or uBasic"?
« Reply #12 on: 20 / February / 2013, 10:31:06 »
This is my first post.  I have a canon a620 connected to win xp sp3 running CHDK 100f.  I was able to get the motion detection script (.lua) to work, wow thats awesome.  I would like to be able to set the camera up and catch the moon as it rises or sets over the hills east / west of my house.  I play around with surveying and so If I set the camera up at a known spot I can use it to "watch" the moon rise / set.  Then if I know the exact time (1/100 ths of a second are fine) I can calculate a very precise azimuth.  To do this I need to have some way of setting the time on the camera.

I read the thread here and built this script

setminute.lua
********* cut here ******
--[[
@title setminute
lua_call_Native
call_event_proc('FA.Create')
call_event_proc('InitializeAdjustmentFunction')
call_event_proc('SetMinute',54)
******** end script ******

but it does not seem to work.  Any help will be apreciated.  As an aside another good freeware program for post processing of images is ImageJ, a java tool developed by a fellow at NIH.


*

Offline srsa_4c

  • ******
  • 4451
Re: How to set camera time with scripts "lua or uBasic"?
« Reply #13 on: 20 / February / 2013, 10:57:24 »
canon a620
This camera is about the same generation as reyalp's a540, so his examples will work for you. Specifically: you don't need FA.Create. Also, lua_call_Native is not a command or function, it refers to a CHDK build time option, remove it from the script.
The script will work if you use a recent development release from the "unstable" autobuild, just locate and enable "Enable Lua Native Calls" in the "Miscellaneous" menu.


*

Offline msl

  • *****
  • 1280
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: How to set camera time with scripts "lua or uBasic"?
« Reply #14 on: 20 / February / 2013, 11:02:35 »
The script has not the correct Lua script spelling. Moreover you have to enable the 'native calls' function in the CHDK menu as srsa_4c wrote.

Code: (lua) [Select]
--[[
@title setminute
]]
call_event_proc('FA.Create')
call_event_proc('InitializeAdjustmentFunction')
call_event_proc('SetMinute',54)
CHDK-DE:  CHDK-DE links

Re: How to set camera time with scripts "lua or uBasic"?
« Reply #15 on: 20 / February / 2013, 14:55:48 »
srsa_4c and msl  thanks for the replies.  I do not understand the procedure specified by srsa_4c.  I d/loaded the file
a620-100f-1.2.0-2584-full.zip but I could not find a place to enable the lua native calls.  I am guessing that this is an option if I d/load the source files and compile them myself? 

Having not done that yet I'm getting the message
: 4 attempt to call global 'call_event-proc' (a null value)
Press shutter to close
*** INTERUPTED ***

I'm a rank beginner and would need to find the source files and make the adjustments to the compile script and I would need to find a compiler to use.  I've compiled some C / C++ using TINYC.exe

This CHDK is so powerfull I am amazed.  The math functions that are available may enable running an entire ephemeris or an autopilot.  This is awesome.

Again thanks. 

Re: How to set camera time with scripts "lua or uBasic"?
« Reply #16 on: 20 / February / 2013, 15:00:55 »
srsa_4c and msl  thanks for the replies.  I do not understand the procedure specified by srsa_4c.  I d/loaded the file
a620-100f-1.2.0-2584-full.zip but I could not find a place to enable the lua native calls.  I am guessing that this is an option if I d/load the source files and compile them myself? 
Its now an option in the CHDK Miscellaneous items menu on recent 1.2.0 releases (like the one you downloaded).  No need to compile anything for yourself.
« Last Edit: 20 / February / 2013, 15:10:10 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline srsa_4c

  • ******
  • 4451
Re: How to set camera time with scripts "lua or uBasic"?
« Reply #17 on: 20 / February / 2013, 16:11:02 »
Its now an option in the CHDK Miscellaneous items menu on recent 1.2.0 releases (like the one you downloaded).  No need to compile anything for yourself.
Funny. Just tried on one of my cameras, and I had to reset the settings for that menu entry to show correctly.
CHDK Settings -> Reset Options to Default

If I switch to another language (and back to English, doesn't matter afterwards), "Enable Lua Native Calls" becomes "Exposure Control (No Flash)". This looks like a bug.
edit: The language files of CHDK 1.1 and 1.2 are not compatible (why?).

@swkong
Reset your CHDK settings or delete CHDK/CCHDK3.CFG from your card. When upgrading from CHDK 1.1 to 1.2, be sure to update the language files too (if you're using a menu language other than English).
« Last Edit: 20 / February / 2013, 16:34:46 by srsa_4c »


*

Offline rudi

  • ***
  • 129
  • A590IS_101B, SX260HS_100B
Re: How to set camera time with scripts "lua or uBasic"?
« Reply #18 on: 20 / February / 2013, 16:45:05 »
: 4 attempt to call global 'call_event-proc' (a null value)
If there a type writing error in script? It should be call_event_proc.

Re: How to set camera time with scripts "lua or uBasic"?
« Reply #19 on: 20 / February / 2013, 17:16:47 »
OK I found the enable option in the misc menu.
I must have made a typo - vice _.

So this is getting there.  But it would be better if I could just get the script to auto run once when the camera was connected to the computer.  I keep the computer synchronized to a time server and I've checked it with telephone calls to my favorite radio station (WWV in Fort Collins Colorado, my home town).  If I select the script to run "once" what is that "once" after I turn the camera on?  "Once" a day? "Once" a shutter press?  Its a pain to have to edit the minutes so I can set them.  I would like to just be able to set the year, month, day, hour, minutes and second automatically when I connect the camera to the USB port. 

This will take some playing around.  I've already found the date and time statements/commands in the lua syntax page at <   http://www.lua.org/pil/22.1.html   >.  This would be a nice "standard" feature for CHDK.  I still haven't figured out what is going on when you set the time manually.  Is the time set when you change one of the elements or when you click the menu button?  This is a problem with almost any electronic device.  For what I am trying to do mili seconds would be nice but 1/10 of a second would probably be OK.

Thanks for the help.  I feel younger, like before USNET was swampped with spam and folks were so kind.  :xmas

 

Related Topics