Access to CHDK menu via scripts - Script Writing - CHDK Forum

Access to CHDK menu via scripts

  • 16 Replies
  • 5764 Views
Access to CHDK menu via scripts
« on: 09 / January / 2015, 10:56:12 »
Advertisements
In CHDK 1.3 there are scripting commands "enter_alt", "exit_alt", and "get_alt_mode". Can these be used to access the CHDK menu (as opposed to the Canon menu)?

E.g. I would like a script to switch on "Bracketing in continuous" by means of repeated keypresses. I've tried both enter_alt and exit_alt followed by click "menu" in uBASIC on an A470, but all I get is the Canon menu.

Are there any examples of scripts that do this?

Cheers

*

Offline reyalp

  • ******
  • 14126
Re: Access to CHDK menu via scripts
« Reply #1 on: 09 / January / 2015, 16:58:30 »
In CHDK 1.3 there are scripting commands "enter_alt", "exit_alt", and "get_alt_mode". Can these be used to access the CHDK menu (as opposed to the Canon menu)?
Unfortunately, no. You can't send key presses from script to CHDK at the moment. The closest you can get is set_config_value to set the same settings you might set from the menu, but not everything is a config value.

This is desirable feature, particularly for PTP control, but it would require some significant re-working of the keyboard code.

edit:
You should be able to set up bracketing in continuous mode using set_config_value, and this is probably a more reliable way of doing it than key presses, since it doesn't depend on the values starting in a particular state.
Don't forget what the H stands for.

Re: Access to CHDK menu via scripts
« Reply #2 on: 09 / January / 2015, 19:37:25 »
For bracketing in continuous mode,  use

Code: [Select]
set_config_value(150,  n)  -- TV Bracketing where n = 0 for off, 1 to 12 for eV step in 1/3 stop increments
set_config_value(151,  n)  -- AV Bracketing where n = 0 for off, 1 to 12 for eV step in 1/3 stop increments
set_config_value(152,  n)  -- SV bracketing offset value
set_config_value(153,  n)  -- SV bracketing enable where n= 0 for off,  1 for onSV bracketing offset value
set_config_value(154,  n)  -- subject distance offset in mm
set_config_value(155,  n)  -- subject distance bracketing enable where n=0 for off and 1 for onsubject distance offset in mm
set_config_value(156,  n)  -- bracketing type where n = 0 for +/-,  n=1 for +,  n=2 for -
set_config_value(157,  n)  -- disable bracketing on startup,  n=0 for no,   1 for yes

Ported :   A1200    SD940   G10    Powershot N    G16

Re: Access to CHDK menu via scripts
« Reply #3 on: 12 / January / 2015, 15:57:51 »
Thanks, reyalp and Walter, that was a great help. set_config_value is such a powerful command, I was just a little surprised that it has taken me so long to discover it.

Which only brings me back to another point and that is that many of the _Canon_ menu options can only be accessed by keypresses, rather than by set_prop. For example, there is get_drive_mode what will tell you mode the camera is in (single, continuous or timer - by reading out propcase #102/Digic IV), but no corresponding set_drive_mode, presumably because setting propcase #102 changes that propcase, but not the camera's behaviour (at least on the three cameras that I have, ditto for #223 and #224 which are related to the timer issue).

By presetting the timer delay and number of shots I can use keypresses in a script to choose continuous/timer/single mode judiciously by checking get_drive_mode first, but are there any moves afoot to make these functions (single/continuous/timer, timer delay, no of shots) directly programmable?

Cheers, Lee

*

Offline reyalp

  • ******
  • 14126
Re: Access to CHDK menu via scripts
« Reply #4 on: 12 / January / 2015, 16:08:57 »
Which only brings me back to another point and that is that many of the _Canon_ menu options can only be accessed by keypresses, rather than by set_prop.
This is indeed another longstanding issue.

srsa_4c did some good research: http://chdk.setepontos.com/index.php?topic=10624.0

It would be nice to have this functionality in CHDK, but some caution is needed since they manipulate non-volatile memory.
Don't forget what the H stands for.

Re: Access to CHDK menu via scripts
« Reply #5 on: 12 / January / 2015, 19:00:07 »
... but some caution is needed since they manipulate non-volatile memory.
The srsa_4c "how to" in the thread you've linked is a great tool.
I've been using "UI properties" in many of my budding scripts from a while and never had any issue with my cameras.
Did someone reported any bad side effect in the past?
« Last Edit: 12 / January / 2015, 19:40:05 by fabri22 »

*

Offline reyalp

  • ******
  • 14126
Re: Access to CHDK menu via scripts
« Reply #6 on: 12 / January / 2015, 23:17:44 »
I've been using "UI properties" in many of my budding scripts from a while and never had any issue with my cameras.
Did someone reported any bad side effect in the past?
Not that I know of. I would expect it to be pretty safe, but it's hard to be certain and when there is potential for bricking peoples cameras I try to err on the side of caution.
Don't forget what the H stands for.

Re: Access to CHDK menu via scripts
« Reply #7 on: 30 / January / 2015, 14:53:14 »
@waterwingz:

>>For bracketing in continuous mode,  use

Are these the same in ubasic and lua?

I've tried

set_config_value 150 5
for bracketing, but it is still turned off in the CHDK menu

set_config_value 140 2
set_config_value 141 2
to try to set the subjective distance override to infinite

And in the CHDK menu Subjective Distance Override had the values Off/44 (previously Off/0).

Can you point me to a valid table of config ids and values? I am looking at conf.c and both 140 and 150 seem to be defined twice.
« Last Edit: 30 / January / 2015, 15:17:11 by SkepticaLee »

*

Offline reyalp

  • ******
  • 14126
Re: Access to CHDK menu via scripts
« Reply #8 on: 30 / January / 2015, 15:58:19 »
Are these the same in ubasic and lua?
IDs are the same.
Quote
Can you point me to a valid table of config ids and values?
For the IDs, look in  CHDK/LUALIB/GEN/CNF*.lua

The IDs in conf.c have a base value for each CFG file, so tv_bracket_value (in core) is 1150, show_dof (in osd) is 2150. To confuse things further, there's some backward compatible glue so that < 1000 values are handled like they were in 1.2, before the CFG files were split.

Using these in your scripts rather than "magic numbers" is highly recommended (which implicitly means that Lua is highly recommended over ubasic ;))

For the values, your best bet is either to look at the C code, or set the settings you want to know about manually in the CHDK menu, and then query using get_config_value. Things that are checkbox in the UI will generally be 0 for off, 1 for on.
Don't forget what the H stands for.

Re: Access to CHDK menu via scripts
« Reply #9 on: 30 / January / 2015, 19:25:18 »
@waterwingz:

>>For bracketing in continuous mode,  use
My mistake - I got confused and posted the wrong values.  Sorry.

There are "old" config values and "new" config values.  Using the old values, the table should have been :
Code: [Select]
set_config_value(109,  n)  -- TV Bracketing where n = 0 for off, 1 to 12 for eV step in 1/3 stop increments
set_config_value(110,  n)  -- AV Bracketing where n = 0 for off, 1 to 12 for eV step in 1/3 stop increments
set_config_value(111,  n)  -- SV bracketing offset value
set_config_value(112,  n)  -- SV bracketing enable where n= 0 for off,  1 for on
set_config_value(113,  n)  -- subject distance offset in mm
set_config_value(114,  n)  -- subject distance bracketing enable where n=0 for off and 1 for on
set_config_value(115,  n)  -- bracketing type where n = 0 for +/-,  n=1 for +,  n=2 for -
As many newer menu entries do not have "old' values,  it's better to just use the "new" values :
Code: [Select]
set_config_value(1150,  n)  -- TV Bracketing where n = 0 for off, 1 to 12 for eV step in 1/3 stop increments
set_config_value(1151,  n)  -- AV Bracketing where n = 0 for off, 1 to 12 for eV step in 1/3 stop increments
set_config_value(1152,  n)  -- SV bracketing offset value
set_config_value(1153,  n)  -- SV bracketing enable where n= 0 for off,  1 for onSV bracketing offset value
set_config_value(1154,  n)  -- subject distance offset in mm
set_config_value(1155,  n)  -- subject distance bracketing enable where n=0 for off and 1 for on
set_config_value(1156,  n)  -- bracketing type where n = 0 for +/-,  n=1 for +,  n=2 for -
set_config_value(1157,  n)  -- disable bracketing on startup,  n=0 for no,   1 for yes

Alternatively,  in Lua use :
Code: [Select]
cnf=require("gen/cnf_core")
set_config_value(cnf.tv_bracket_value,  n)  -- TV Bracketing where n = 0 for off, 1 to 12 for eV step in 1/3 stop increments
set_config_value(cnf.av_bracket_value,  n)  -- AV Bracketing where n = 0 for off, 1 to 12 for eV step in 1/3 stop increments
set_config_value(cnf.iso_bracket_value,  n)  -- SV bracketing offset value
set_config_value(cnf.iso_bracket_koef,  n)  -- SV bracketing enable where n= 0 for off,  1 for on
set_config_value(cnf.subj_dist_bracket_value,  n)  -- subject distance offset in mm
set_config_value(cnf.subj_dist_bracket_koef,  n)  -- subject distance bracketing enable where n=0 for off and 1 for on
set_config_value(cnf.bracket_type,  n)  -- bracketing type where n = 0 for +/-,  n=1 for +,  n=2 for -
set_config_value(cnf.clear_bracket,  n)  -- disable bracketing on startup,  n=0 for no,   1 for yes
Ported :   A1200    SD940   G10    Powershot N    G16

 

Related Topics


SimplePortal © 2008-2014, SimplePortal