CHDK UI version 2.0 ? - page 9 - General Discussion and Assistance - CHDK Forum supplierdeeply

CHDK UI version 2.0 ?

  • 542 Replies
  • 144502 Views
*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: CHDK UI version 2.0 ?
« Reply #80 on: 05 / June / 2012, 21:00:08 »
Advertisements
...But his question brings up something else I have struggled with a couple times.  It would be nice to be able to add validation to the parameter input fields in the scripting menu. 

Ask and ye shall receive...

Revision 1900 (trunk only) adds a '@range' option to the script handling to allow you to set the min & max allowed values for a script parameter (examples below).

If the range is set to 0..1 the parameter is displayed in the script menu as a boolean on/off toggle instead of an integer value (the actual parameter value is still an integer though).

Simple uBasic test sample (works in Lua as well):
Code: [Select]
@title Range Test
@param a A 1..12
@default a 2
@range a 1 12
@param b B 0..1
@default b 0
@range b 0 1
@param c C -12..12
@default c 0
@range c -12 12

print a
print b
print c

end

Note it is up to the script writer to ensure that the @default value lies within @range - this is not validated when the script is loaded.

(If there are no issues with this I will add it to the release-1.0 code as well so that scripts remain compatible.)

Phil.

« Last Edit: 05 / June / 2012, 21:01:40 by philmoz »
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

Re: CHDK UI version 2.0 ?
« Reply #81 on: 05 / June / 2012, 21:11:06 »
Revision 1900 (trunk only) adds a '@range' option to the script handling to allow you to set the min & max allowed values for a script parameter (examples below).
Thanks philmoz.   Looks like I'm going to need to add a section about "@" statements to the wiki scripting cross reference.    (http://chdk.wikia.com/wiki/CHDK_Scripting_Cross_Reference_Page#All_Scripting_Functions)

While you were in there, did you give any thought to a command to load or store from a parameter set ( e.g. load_param(5) or store_params(7) ) ?

Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: CHDK UI version 2.0 ?
« Reply #82 on: 05 / June / 2012, 21:17:40 »

While you were in there, did you give any thought to a command to load or store from a parameter set ( e.g. load_param(5) or store_params(7) ) ?


Wouldn't that cause confusion - if the user had selected parameter set 3 and the script then loaded set 5 it would not be running with the values set by the user?

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

Re: CHDK UI version 2.0 ?
« Reply #83 on: 05 / June / 2012, 21:19:18 »
Wow that's awesome on both counts; adding the range and telling me about the zoom option changing the increment.  Thanks guys!


Re: CHDK UI version 2.0 ?
« Reply #84 on: 05 / June / 2012, 21:24:29 »
Wouldn't that cause confusion - if the user had selected parameter set 3 and the script then loaded set 5 it would not be running with the values set by the user?
Not sure it would be any worse than what we have now.  If the Save params menu option is enabled,  the script uses the one specified in the Parameter Set menu item immediately above.  If its not enabled,  it just uses the defaults.   At least I think that's how it works.

So if that menu option is enabled,  you ignore the get_params() set_params() lines in the script and use the parameter set specified in the menu.  Otherwise you use / save the one specified in the script. 

Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: CHDK UI version 2.0 ?
« Reply #85 on: 05 / June / 2012, 22:03:03 »
Not sure it would be any worse than what we have now.  If the Save params menu option is enabled,  the script uses the one specified in the Parameter Set menu item immediately above.  If its not enabled,  it just uses the defaults.   At least I think that's how it works.

AFAIK it works like this:

The 'Save params' option doesn't affect loading of parameters from the selected parameter set.
The code will always try and load the values from the parameter set file when you load a script - if there isn't a saved parameter set file it will use the defaults in the script itself.

'Save params' controls whether the current parameter values are saved to the parameter set file.
If it is disabled then they are never saved.
If it is enabled then the current values are saved to the file when you:
- run the script
- change scripts
- change parameter set

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: CHDK UI version 2.0 ?
« Reply #86 on: 05 / June / 2012, 22:11:21 »
I think philmoz is working on user configurable shortcuts although he hasn't exactly said so.

The current shortcut handling code is a bit of a mess.
I think that to add configurable shortcuts will first require some re-work of the existing code, which may take some time.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

Re: CHDK UI version 2.0 ?
« Reply #87 on: 05 / June / 2012, 22:49:27 »
AFAIK it works like this:

The 'Save params' option doesn't affect loading of parameters from the selected parameter set.
The code will always try and load the values from the parameter set file when you load a script - if there isn't a saved parameter set file it will use the defaults in the script itself.

'Save params' controls whether the current parameter values are saved to the parameter set file.
If it is disabled then they are never saved.
If it is enabled then the current values are saved to the file when you:
- run the script
- change scripts
- change parameter set
So when you load a script,  the parameter values are loaded from the values stored in /CHDK/DATA/scriptname_n, where n is loaded from an index stored in /CHDK/DATA/scriptname.cfg ? And "n" gets stored along with the parameter data as described above.

Each script gets its own unique set of ten parameter sets,  but the only way to know ahead of time which one will load is remember what the script index was the last time you saved parameter data ? Or change the index in the menu when you load the script I guess.

Hmmm ... trying to decide if I should even take a crack at adding this to the wiki somewhere.  Not sure I've seen it described in detail before. 

Makes me wonder if anyone has ever actually used this ......



Ported :   A1200    SD940   G10    Powershot N    G16


Re: CHDK UI version 2.0 ?
« Reply #88 on: 05 / June / 2012, 22:53:07 »
The current shortcut handling code is a bit of a mess.
I'm somewhat familiar with that concept.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: CHDK UI version 2.0 ?
« Reply #89 on: 06 / June / 2012, 02:16:01 »
[offtopic]
Sometimes it looks like CHDK has to be almost reverse engineered to understand how does it work :)
We should expect, that one day the code will so far messed, that devs will disassemble the binaries to change anything :D
[/offtopic]
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal