camera scripts from chdkptp - LUA Scripting - CHDK Forum  

camera scripts from chdkptp

  • 0 Replies
  • 656 Views
*

Offline reyalp

  • ******
  • 14082
camera scripts from chdkptp
« on: 17 / April / 2022, 19:15:03 »
Advertisements
In the chdkptp (starting around r1084), I added some functionality to make it easier to use camera side script with menu paramters from chdkptp. Note this isn't officially 'released' yet (I hope to do that Real Soon Now  :-[) but I figured I'd describe it now since I mentioned it in mlapse's thread.

This change adds a command called 'camscript', and also adds similar functionality to 'remoteshoot'. As usual, 'help camscript' gives a summary of options.

This is intended to make it easier to use scripts with complicated menu options, avoiding the need for manually created 'glue' files or complicated lines with loadfile(...)()

camscript parses the CHDK @ and # parameters, and optionally overrides values using a CHDK saved settings file (CHDK/DATA/scriptname.N) and/or values specified on the command line. It can then execute the script on the camera, or save it to a new script file that has the values hard coded.

The script file and menu settings file may be on the camera or on the PC. Names starting with A/ are assumed to be on the camera (use ./A if you use a local directory name A for some reason)

Some examples:

run A/CHDK/SCRIPTS/TEST/llibtst.lua from the camera with the default menu options
Code: [Select]
camscript -run A/CHDK/SCRIPTS/TEST/llibtst.lua


Save a copy of llibtst.lua on the PC, overriding the menu options do_io and do_os to false.
Code: [Select]
camscript -save=mytest.lua A/CHDK/SCRIPTS/TEST/llibtst.lua  do_io=false do_os=false
The saved script could then be run directly using
Code: [Select]
=<mytest.lua
If it were a shooting script, it also could be used with remoteshoot -script

Run the local file rawopint.lua using saved menu settings number 0 from the camera, overriding interval and number of shots and waiting for the script to finish
Code: [Select]
camscript -run -wait -cfg=A/CHDK/DATA/RAWOPINT.0 rawopint.lua ui_shots=10 ui_interval_s10=20

Create a new settings CFG file on the PC based on saved settings number 2 with some options overridden
Code: [Select]
camscript -cfg=A/CHDK/DATA/RAWOPINT.2 -savecfg=my.cfg rawopint.lua ui_shots=10

For remoteshoot, it is desirable to have some script menu options like number of shots and interval controlled by remoteshoot options. This is supported with "glue template" files. A glue template is a camera side Lua files, where special comments --[!glue:vars] and --[!glue:body] are replaced the menu settings and main script body respectively. Code in between the two can modify the menu values. An example template for the next release of rawopint is here. The -tpl option is used with camscript and remoteshoot to specify the template.

While you can use camscript to generate files for use with remoteshoot, you can also specify scripts, menu settings and templates directly, like
Code: [Select]
rs -jpg -filedummy -camscript=rawopint.lua -tpl=rawopint_chdkptp_tpl.lua -cont=5 -int=2 -menuopts=ui_image_size_e=1,ui_display_mode_t.value=On out/${name}
Note the options are mostly the same, except that to override menu options, you use -menuopts=name1=value,name2=value...


If you use camscript without -run, -save, -savecfg, it just checks that it can parse the script header and any script settings file.
Don't forget what the H stands for.

 

Related Topics