Author Topic: Lua Scripting (lua.mo)  (Read 232803 times)

dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 3218
  • 60Da / 1100D / EOSM
Re: LUA Scripting (lua.mo)
« Reply #50 on: May 25, 2015, 04:53:44 PM »
the Lua bindings are in these files:
modules/lua/lua.c
modules/lua/lua_battery.c
modules/lua/lua_camera.c
modules/lua/lua_common.h
modules/lua/lua_console.c
modules/lua/lua_constants.c
modules/lua/lua_display.c
modules/lua/lua_dryos.c
modules/lua/lua_globals.c
modules/lua/lua_interval.c
modules/lua/lua_key.c
modules/lua/lua_lens.c
modules/lua/lua_lv.c
modules/lua/lua_menu.c
modules/lua/lua_movie.c
modules/lua/lua_property.c
modules/lua/lua_task.c

You can also use bitbucket to look at a diff of the branch:
https://bitbucket.org/hudson/magic-lantern/branch/lua#diff

garry23

  • Contributor
  • Hero Member
  • *****
  • Posts: 2217
Re: LUA Scripting (lua.mo)
« Reply #51 on: May 25, 2015, 05:21:56 PM »
Sorry, I still can't find the source.

I've looked everywhere.

For example, I can't find this file: modules/lua/lua_lens.c

Sorry to be a pain and thick, but can you give me an explicit link to: modules/lua/lua_lens.c

Cheers

dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 3218
  • 60Da / 1100D / EOSM
Re: LUA Scripting (lua.mo)
« Reply #52 on: May 25, 2015, 08:06:39 PM »

garry23

  • Contributor
  • Hero Member
  • *****
  • Posts: 2217
Re: LUA Scripting (lua.mo)
« Reply #53 on: May 25, 2015, 08:24:17 PM »
 :)

katrina@seafever.ie

  • New to the forum
  • *
  • Posts: 6
Re: LUA Scripting (lua.mo)
« Reply #54 on: June 01, 2015, 12:09:37 PM »
Hi

Is it possible to trigger video on the 5D mark2 for time lapse purposes using lua scripting?

Thanks
Katrina

dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 3218
  • 60Da / 1100D / EOSM
Re: LUA Scripting (lua.mo)
« Reply #55 on: June 01, 2015, 12:49:11 PM »

katrina@seafever.ie

  • New to the forum
  • *
  • Posts: 6
Re: LUA Scripting (lua.mo)
« Reply #56 on: June 02, 2015, 12:15:25 AM »
Thanks for your reply Dave

I had a look at the link

What is meant to go between the brackets in the lines

Start () and stop ()

Is that a video duration or a time interval?

I have not installed, reviewed, scripted or done anything before with Magic Lantern and I'm a bit uncertain that I can write a script

Is there a script already written which will trigger record for 20 seconds every day - with an interval of 24 hours?

Thanks again
Katrina

dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 3218
  • 60Da / 1100D / EOSM
Re: LUA Scripting (lua.mo)
« Reply #57 on: June 02, 2015, 01:53:14 AM »
movie.start() and movie.stop() don't take any parameters. To record a 20s movie you can do something like this:

Code: [Select]
movie.start()
msleep(20000)
movie.stop()

For more info see this example: http://davidmilligan.github.io/ml-lua/examples/recdelay.lua.html

Taking a video once a day may be some trouble, as you can't really keep LiveView on that long (even if you could it probably wouldn't be a good idea).

katrina@seafever.ie

  • New to the forum
  • *
  • Posts: 6
Re: LUA Scripting (lua.mo)
« Reply #58 on: June 02, 2015, 10:46:32 AM »
Thanks again

if LiveView needs to be on for the script to run, this solution probably won't work for me then.

Can Live view not be switched on by the script?

Sorrry, as I said, I have no experience in this?

I believe that there is a light sensor interveralometer available - which might work better

Thanks again
 Katrina

dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 3218
  • 60Da / 1100D / EOSM
Re: LUA Scripting (lua.mo)
« Reply #59 on: June 02, 2015, 01:00:52 PM »
You can turn on and off photo LV, but there's no way to switch to movie mode/LV. Programmatically switching Canon modes is possible (there was an old feature called movie mode remap), but it is dangerous and has caused cameras to be temporarily bricked, so all such capability has been removed from ML.

You can pause LV though. I suppose this works in movie LV. I don't know if this will prevent the camera from shutting off LV after 30 mins or not (there is a way that's been implemented for raw recording, but it is not currently exposed for scripts).

katrina@seafever.ie

  • New to the forum
  • *
  • Posts: 6
Re: LUA Scripting (lua.mo)
« Reply #60 on: June 02, 2015, 06:06:03 PM »
Thanks again for letting me know the limitations and functions...

However, I'm sorry but I am still not sure if I should proceed in getting ML and trying to create this script - perhaps there is somebody else who is doing this or has tried it?

If not - what's your advice - do you think I should try the script or not?

Thanks
Katrina

Walter Schulz

  • Contributor
  • Hero Member
  • *****
  • Posts: 8254
Re: LUA Scripting (lua.mo)
« Reply #61 on: June 02, 2015, 06:16:21 PM »
What are your requirements?

As far as I could find out right now:
- You have a cam, 5D2. Unattended. No one is looking after it for quite some days/weeks/months ...
- All 24 hours there is a 20 second video shot to be taken.

Corrections and more details, if necessary, please.
Do you have an external power supply?

katrina@seafever.ie

  • New to the forum
  • *
  • Posts: 6
Re: LUA Scripting (lua.mo)
« Reply #62 on: June 02, 2015, 11:33:37 PM »
Hi

All the above mentioned is correct, the camera is locked in place and powered by the AC adapter, the scene is an old house in ruin which is slowly being taken over by vegetation.

I have a series of these type of shoots to perform for a film, which is still in development. (lots of ruin, decay and renewal)

I have never used ML, but I met an Italian in the Azores last week who was very certain ML would work 8)...

I tried firstly doing time lapse photos with an intervalometer - taking a pic every 5 minutes for several weeks and trying to bracket and select only the pics in similar light  - but the light here in Ireland is way too sporadic... no two days are ever the same and with natural shadows changing on the door frames etc - it just didn't work.

Currently I am visiting the house frequently and shooting video myself, which is then taken into the adobe premiere and dissolves into each other to see the transition - but this is not a good long term solution.

I have no other information - only if you think it will work and can support me I would love to try it.

Thank you again
Katrina

Walter Schulz

  • Contributor
  • Hero Member
  • *****
  • Posts: 8254
Re: LUA Scripting (lua.mo)
« Reply #63 on: June 03, 2015, 09:50:35 AM »
Tried to find another solution but failed. Problem with 5D2 is - as dmilligan pointed out - you have to enable Liveview in movie mode. There are cams not having this problem. 7D for instance has a movie mode switch and with switch set will startup in movie mode.

You tried Auto-ETTR to solve exposure problem using stills?

katrina@seafever.ie

  • New to the forum
  • *
  • Posts: 6
Re: LUA Scripting (lua.mo)
« Reply #64 on: June 03, 2015, 10:40:20 AM »
Thanks Walter

NO, I didn't try  Auto-ETTR - I have never used ML at all.

I will look into it - but, from a quick scan I don;t know if that will even work... bearing in mind the sun's position, height, cloud cover etc - I used can't see photo solution working - even though it would be nice... maybe if I get the correct funding decision this month I might buy the 7D and keep it for time lapse - are you confident it will work with the 7D? - is there a cheaper camera that it would work on?

Thanks again for your help
Katrina

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 12564
Re: LUA Scripting (lua.mo)
« Reply #65 on: June 03, 2015, 11:36:31 AM »
The easiest - and portable - way to shut down LiveView in movie mode is to go to play mode (and then turn the display off).

On 5D2, there's no dedicated hardware switch for movie mode. So, on the contrary - on this camera, enabling and disabling movie mode can be done without problems, since the only way to do it is from the menus. The 50D is very similar. All the other cameras have a hardware switch, so you can't safely switch between photo and movie mode from ML (that switch is handled by a secondary processor, which we don't fully understand yet - the MPU - so faking the mode dial position on the main CPU is not enough, though it seems to work at first sight).

Walter Schulz

  • Contributor
  • Hero Member
  • *****
  • Posts: 8254
Re: LUA Scripting (lua.mo)
« Reply #66 on: June 03, 2015, 06:14:29 PM »
Thanks, a1ex, for correction!

Setup in mind:
----
Timer for AC adapter, cam switched to ON. Timer will startup cam. ML + modules will run (Debug tab -> Modules debug -> Load modules after crash ON). Loading script
- Wait short time
- Start movie recording
- After 20 seconds stop movie recording

Wait some minute and timer will cut power.

----
Any errors within this concept?


rambler

  • New to the forum
  • *
  • Posts: 6
Re: LUA Scripting (lua.mo)
« Reply #67 on: June 03, 2015, 06:17:37 PM »
@Katrina
It seems you intend to run a very long timelapse. I doubt anyone has tested this with a DSLR. Note that cameras are not designed to run for months on end, so it is probable, or almost certain, that it will fail after some days or weeks. And since it is possible to damage a DSLR programmatically, you may not want to try. It may be possible to use a trick long since known for P&S Canons in the CHDK community: if the power switch is set to “on” and power is applied, the camera will go “on”. Thus, with a programmable power supply, the camera can be switched on for only the duration required to take a couple of shots or a short video. This works on 550D, but I have no idea if it works on the others. And I have a gut feeling that it a dangerous practice with a DSLR.

May I suggest you consider another, far cheaper alternative: rather than use a Canon DSLR with ML, think of a Canon P&S with CHDK, where long timelapses is a proven and well tested concept. For the price of a DSLR you can get half a dozen of decent P&S. Video quality will probably be not as good, unless you pick one of the high-end models, which are expensive though. But then, are you sure you need video, 20s every day? Why not a still shot, or a few of them, which can then be combined into a nice hi-res timelapse video? If you need further advice on this, ask nicely at the CHDK forum, explaining your project and needs, and a few nice people out there will surely be more than happy to provide you with any general or practical advice.

garry23

  • Contributor
  • Hero Member
  • *****
  • Posts: 2217
Re: LUA Scripting (lua.mo)
« Reply #68 on: June 03, 2015, 07:04:13 PM »
Just to add my input to rambler's; having used CHDK with scripting (S95 and G11), I have to agree that it a very serious option for those doing 'unusual' things, ie away from 'normal' timelapse sequences. Especially if money is an issue ;-)

I found the CHDK scripting environment very accessible.

As I say: just my humble view.

Cheers

Garry

Totte

  • New to the forum
  • *
  • Posts: 26
Re: LUA Scripting (lua.mo)
« Reply #69 on: June 09, 2015, 01:52:01 PM »
OK, finally time to play with this: I've checked out the LUA branch and compiled it for the 5D2 on my Linux machine. I end up with an empty doc folder but I've assumed that I can ignore that for now.

I copy everything from the zip file to my ML card and after enabling the LUA module I find the LUA Menu Test under Debug, but I don't see a separate LUA menu. After copying the scripts/lib folder from the source to the CF card I also see the Sokoban game with its own menu. I guess the make file will eventually be updated to include this folder in the zip target?

So where am I supposed to select which of the other scripts in the scripts folder to run, like how to invoke editor.lua? Is it just me being stupid, or am I still missing some vital LUA component on the CF card, or should I be investigating my build environment and make output?

Thanks for any help!

Licaon_Kter

  • Hero Member
  • *****
  • Posts: 519
  • M
Re: LUA Scripting (lua.mo)
« Reply #70 on: June 09, 2015, 05:28:04 PM »
See my reply to dmilligan here ( modify your ML and rerun make ): https://bitbucket.org/hudson/magic-lantern/issue/2297/shoot-mode-ca-and-hdr-backlight-control#comment-18586259


I guess you are missing the /scripts/LIB folder maybe?

Totte

  • New to the forum
  • *
  • Posts: 26
Re: LUA Scripting (lua.mo)
« Reply #71 on: June 09, 2015, 06:11:32 PM »
Yes I was missing the /scripts/lib folder but like I said I copied it manually and then got to the point where I can play Sokoban ;D

Now trying to figure out where/how to run the rest of the LUA scripts in the scripts folder. Being all new to LUA I wouldn't be able to tell how this is supposed to work.

Licaon_Kter

  • Hero Member
  • *****
  • Posts: 519
  • M
Re: LUA Scripting (lua.mo)
« Reply #72 on: June 09, 2015, 07:27:08 PM »
Those scripts that make a menu are visible ( sokoban, copy2m ).
I actually cloned copy2m and use it's framework to do something else, but a word of warning, if you do that either remove the original script from the card/folder or rename the menu/functions if not it will loop and eventually freeze/crash ( it did on my M so your results may vary ).

Totte

  • New to the forum
  • *
  • Posts: 26
Re: LUA Scripting (lua.mo)
« Reply #73 on: June 09, 2015, 08:48:43 PM »
That makes sense, except that I don't see any trace of copy2m. Only Games is added to the top menu, with Sokoban as a sub-item. I guess I can make a copy of Sokoban and see how that goes. Thanks for the warning about the naming!

Does anyone have another precompiled LUA-compatible binary for the 5D2 that behaves better? If so I would gladly jump to learning and running LUA scripts ASAP.

dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 3218
  • 60Da / 1100D / EOSM
Re: LUA Scripting (lua.mo)
« Reply #74 on: June 10, 2015, 02:53:07 AM »
All scripts are run immediately on startup. They may or may not have menu items, and their menus can show up anywhere. copy2m shows up in the 'Prefs' menu, several of the other scripts show up in the Debug menu, some scripts may not even have a menu item

I would suggest turning the 'console' on (Debug >Modules debug > Show Console), any errors are going to be logged there. There should also be messages about scripts being loaded and other informational things.

I've also greatly expanded the general lua documentation so see http://davidmilligan.github.io/ml-lua/