is it possible to have saved settings not visible in the menu of a program? - LUA Scripting - CHDK Forum

is it possible to have saved settings not visible in the menu of a program?

  • 6 Replies
  • 2213 Views
*

Offline Mlapse

  • *****
  • 583
  • S95 S110
Advertisements
I am toying with the thought of another menu for settings.
And although I have made a start with this idea I would like a co-writer to make it really clean & functional.
Because I still don't grasp the syntax fully, leading to a redundant long script.
But that might be a future request.

Now this is on my mind:
Could the menu have settings that are available and saved, but not visible in the standard menu when loading a script.

In scripts we use menu items like:
# test_interval      3     "test Interval" { Off 2sec 5sec 10sec 12sec 15sec 20sec 30sec }
these are visible when you load a script and are saved in *.0 as
#test_interval=3

i was wondering: is it possible that we have menu items that do not show up in the menu, but are saved in the *.0 file and used when the script is loaded?
btw. I am against making the text for these hidden menu items black,
because the back button at the bottom of the script settings page would be after a lot of 'blank' lines

and if possible how should I write these values in the script?
« Last Edit: 28 / September / 2021, 06:35:04 by Mlapse »
frustration is a key ingredient in progress

*

Offline Caefix

  • *****
  • 945
  • Sorry, busy deleting test shots...
Re: is it possible to have saved settings not visible in the menu of a program?
« Reply #1 on: 28 / September / 2021, 13:21:15 »
 :blink: :o :-X
Quote
//-------------------------------------------------------------------
// PURPOSE: Parse script (conf.script_file) for parameters and title
//-------------------------------------------------------------------
// core/gui_script.c  ~~404
static void script_scan()


// and  gui_user_menu.c

#define USER_MENU_IS_SCRIPT     -1

extern CMenu script_submenu; // 132
static void load_user_menu_script_callback(unsigned int btn)
...
All lifetime is a loan from eternity.

*

Offline reyalp

  • ******
  • 14080
Re: is it possible to have saved settings not visible in the menu of a program?
« Reply #2 on: 28 / September / 2021, 13:32:19 »
Could the menu have settings that are available and saved, but not visible in the standard menu when loading a script.
If you're asking whether such a capability exists, the answer is no.

If you're asking for it to be implemented, I don't really understand the purpose. If you don't want the settings exposed to the user, then why make them script parameters? The whole point of script parameters is to expose them to the user in the menu.

If you a configuration that can be edited elsewhere, or state saved separately from script code, just use file IO to load it. You can use the iniLib module included with CHDK, or borrow the serialize/unserialize code from chdkptp rlibs.lua to save/restore values from file in Lua.
Don't forget what the H stands for.

*

Offline Mlapse

  • *****
  • 583
  • S95 S110
Re: is it possible to have saved settings not visible in the menu of a program?
« Reply #3 on: 28 / September / 2021, 14:25:27 »
@Caefix  I'm a bit out of my league here, but i'm suspecting that with #define user_menu_is_script  -1 you remove the whole menu..and that was not my intention

@reyalp too bad it does not exist and i don't think it is worth the effort to create the possibility before I've realised my idea with the standard data set.

the reason why I was wondering this is because I wanted to make 2 menus.
- one with a limited set of params to change (and some hidden that you cannot change in this menu) that will appear when you load the script
- a seperate script that has the full set of changeable params in an OSD layout.

so for now i'll just focus on the same set of params..that's hard enough.
ideally that seperate script should be universal enough to use for any other script that has user settings. 
i feel a bit uneasy as to post what I made so far since it does not do anything. And what is there still has some (visual) flaws.
but here goes....
this has data for SUIx
maybe that will help you to understand what I am thinking. it could be an addition to programming scripts with lots of params.
it might be helpfull f.i. for reyalps rawopint project, since that has a lengthy set of params.
« Last Edit: 28 / September / 2021, 14:52:56 by Mlapse »
frustration is a key ingredient in progress


*

Offline Caefix

  • *****
  • 945
  • Sorry, busy deleting test shots...
Re: is it possible to have saved settings not visible in the menu of a program?
« Reply #4 on: 28 / September / 2021, 14:27:32 »
I am toying with the thought of another menu for settings.
Each Lua-script-header could be a "external menu", scripted & parsed as usual.
Then You need a way to feed it´s data/*.0 to Your script...

Edit: Some bricks...  :)
Code: [Select]
function lstr(x,...)
  if x<0 then x=x-1 end
  return string.sub(...,1,x)
end
 
function rstr(x,...)
  if x<0 then x=string.len(...)+x end
  return string.sub(...,-x,999)
end
 

function include(myfile)
for lin in io.lines(myfile) do
    if lstr(1,lin)=='#' then
       lin=rstr(-1,lin)
       as=assert(loadstring(lin,lin))()
    end
end
collectgarbage()
end
« Last Edit: 18 / October / 2021, 13:48:05 by Caefix »
All lifetime is a loan from eternity.

*

Offline reyalp

  • ******
  • 14080
Re: is it possible to have saved settings not visible in the menu of a program?
« Reply #5 on: 28 / September / 2021, 17:02:28 »
the reason why I was wondering this is because I wanted to make 2 menus.
- one with a limited set of params to change (and some hidden that you cannot change in this menu) that will appear when you load the script
- a seperate script that has the full set of changeable params in an OSD layout.
By "in an OSD layout" do you mean using the CHDK script menu, or something implemented with Lua drawings ? From your example, I guess the second, but maybe only because you don't have a way to do it through the menu?

If you just want a simple version of the script with hard coded values for a bunch of options, you can do that fairly easily in code, like
if not <item that only appears in advanced menu>
 ... set advanced items as lua variables

and then your two versions of the script only need to have different headers. The defaults would have to appear in two places though.

Quote
so for now i'll just focus on the same set of params..that's hard enough.
ideally that seperate script should be universal enough to use for any other script that has user settings. 
I think making this generic enough to work with any script, while providing a better UI than the native menu would be quite challenging. If you want to use Lua UI to configure the script, I'd suggest doing that as a standalone module that writes to a file. You could then have the regular CHDK menu have an item like "show advanced settings" which would tell the script to display the Lua based UI. If you make the module re-usable for other scripts, I'd suggest making a custom menu definition using Lua tables rather than trying to be compatible with chdk menu params. This would give you the flexibility to actually do it better, rather than just replicating the script menu.

Making complicated script configurations manageable is a real problem, and I'm open to trying to improve it, but I don't see "hidden" items as being a very helpful solution. There's also need to balance flexibility with the risk of the menu system turning into a complicated, buggy ad-hock scripting language.
Don't forget what the H stands for.

*

Offline Mlapse

  • *****
  • 583
  • S95 S110
Re: is it possible to have saved settings not visible in the menu of a program?
« Reply #6 on: 29 / September / 2021, 06:43:05 »
A lot of what you write here is also on my mind.

Yes, Lua drawings is because of my limited knowledge. If I had more succes in implementing features the CHDK menu has, I might not have tried this approach.
But still, I think it gives the best oppurtunity to create a comprehensive menu.
Making it possible to create a tree-structure that would involve no scrolling, but moving to a different page that is only used for a sub menu or setting one menu item.

A few years back I have given some A480 & A490 cams away with CHDK and SUIx plus a printed manual.... i still have a few if somebody wants one ;)
The feedback I got led me a.o. to make title headings in the script menu. And these might not be ideal, but improved the understanding and readability nontheless.

But it still is a long list to scroll through. And I was looking at ways to make the list more compact.
The obvious choice to me was combining related features, like in the CHDK menu where you have a on/off bullet with the setting on the same line. Or combining hours and minutes on the same line.

So I started to look into the way the CHDK menu was made, but i could not get that implemented in the CHDK script menu.
And since one line only gives you limited characters, combining setting  might lead to even more cryptic text and from the feedback i got not much people actually read the manual.

This led me to try to make something with Lua drawings.
However, this meant the script would grow a few hundred lines of code and I was reluctant to do this because of performance issues.
So that is where I thought that a seperate menu script would be more usefull, keeping the working script lean and quick.

......And possibly making it generic enough to work with any script....after you copied the relevant dataset from the script you want to use it for.
Alas reading the *.0 file does not give enough data to make it work and pulling it out of a script automatically will need a very strict setup of your script. So making that copy is a manual thing, but it only has to be done once or when you change the parameter set of your script..

Considering that Lua drawings gave me a free hand in how much text there is per setting. (by using multiple lines)
I think it could lead to a more comprehensive menu. Making it easyer to find a setting and set up the script without reading the manual.

About 'hidden' items, a lot of settings are only set once when you first start to use the script.
Like, the day of reboot, display settings, led settings, usb connections etc.
Naturally I moved those to the bottom of the script menu and that is fine too.

But I think these items could be hidden in the regular script menu. Maybe only after the first time when you have set them correctly for your cam model or because default is good enough for most uses.

You can see the same in some of the CF settings:
If you press [SET] you get a few choices on the left hand side, like ISO, bracketing and resolution/file size.
If you press [MENU] you can also find ISO, but then with an extra feature, namely the upper limit of ISO in automatic.

Yes, it is quite challenging to create a comprehensive menu.
And it is a lot of work for something that is only used a few times.
But setting up a script for your specific needs is important and if you get lost in that, it usually leads to not using that feature or that script.

As for developing something separate for a menu, I'd rather use what is available than something that could lead to a buggy ad-hoc scripting language.
In my opinion, that's again an argument for using Lua drawings.

However, there are also some argument why Lua drawings would be the wrong choice.
-the flickering on digic 6 and up cams
smaller things, like how flexible drawings is for creating a clear and obvious menu f.i.
-i tried to increase the size of the active line of text. But with the size setting available (1-4) setting that to 2 wasn't just a few pixels more, but a doubling of text height leading to unreadable large characters in the menu. but maybe that can be solved by setting it to all capitals when active and/or what i've done now, changing bg color of the active line.
« Last Edit: 29 / September / 2021, 09:18:36 by Mlapse »
frustration is a key ingredient in progress

 

Related Topics