exit_alt issues - General Discussion and Assistance - CHDK Forum

exit_alt issues

  • 6 Replies
  • 5497 Views
exit_alt issues
« on: 19 / May / 2014, 14:53:04 »
Advertisements
Cool, I have added some comments back in below. I love documentation ;-)

The last line of code does sometimes not exit the <ALT> mode. <snip>  Any tips?

When in doubt, a few sleep() commands can help if there is a timing problem.  Also, you are techniclaly supposed to have an "end" statement at the last line of a uBASIC script.

Something like this :

Code: [Select]
@title TTL settD
rem DESCRIPTION:
rem WHAT:   This script turns on the TTL mode for the flash if it was not on already.
rem WHEN:   This is useful for e.g. underwater photography with Canon S95.
rem WHY:    In 'Manual' mode the factory firmware doesn't support TTL.
rem HOW:    The script can be set to auto run. No more worries.

rem HISTORY:
rem 2012-01-05 Initial script written by jamesinsummer from:
rem     http://chdk.setepontos.com/index.php?topic=5876.msg68670
rem 2012-06-13 Initial adaptation by jurgenfd in same thread.
rem 2014-05-19 JFD Adding auto exit for speedy usage.

if autostarted =1 then
   sleep 2000
endif

get_prop 121 b

if b=0 then
    print "Still TTL"
else
    set_prop 121 0
    print "Now TTL"
endif
sleep 1000
exit_alt 0
sleep 1000
end
If that helps,  you can try gradually decreasing the various sleep times until it stops working reliably.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: exit_alt issues
« Reply #1 on: 19 / May / 2014, 16:22:28 »
Script as written with the three extra sleep statements (without brackets I understand), never exits the <ALT> mode, no matter how I test it.
It seems like the 'exit_alt' statement is never executed when the 'end' is present.
Perhaps the 'end' statement causes the script to stay in <ALT> mode?

I have tested it with and without EOL after the 'end'. Does that even matter ;-)?
In both cases the same result: stays in <ALT> mode.

Removing just the 'end' statement doesn't help. It seems that the 'sleep' statement can bring it back into <ALT> because the <ALT> menu actually disappears for 1 s. Looks like it comes back into <ALT> right after the sleep.

Replacing the last 'sleep' by the 'end' so we have just:
Code: [Select]
sleep 1000
exit_alt 0
end
keeps it in the same problem.

Finally removing the 'end' so that we have 
Code: [Select]
sleep 1000
exit_alt 0
would still not leave the <ALT> mode all the time. Sometimes it does.

I removed the other 3 sleeps and set the final one to 4s. In addition I removed the print statements. All to no avail. More ideas? Should I try the other scripting language?

Re: exit_alt issues
« Reply #2 on: 19 / May / 2014, 17:03:13 »
Script as written with the three extra sleep statements (without brackets I understand), never exits the <ALT> mode, no matter how I test it.
So I did a little testing too.  Even translated script to Lua.

What I found is that (on my A1200) the script seems to actually exit <ALT> but the <ALT> logo stays at the bottom of the screen.  Try running the script and then doing a half-press (focus) followed by a full_press (shoot).  It takes a picture on my camera that way - even though the <ALT> symbol is still there. That's not supposed to happen when the camera is in ALT mode.

If I play with it a bit more, the Canon menus seem to run in parallel with CHDK <ALT> mode - like both ALT and Canon mode are getting the key presses.

Definitely a bug there somewhere.
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 14126
Re: exit_alt issues
« Reply #3 on: 25 / May / 2014, 17:50:08 »
I've checked in a possible workaround in trunk changeset 3446

It seems to resolve the problem and not break anything else obviously, but I don't think it's really the right solution. We a large number of different variables that track the alt state in some form or other, so it's a bit confusing.

The original comment says
" Restore old handler - prevent calling MD draw after module unloaded"

It seems like it might be more to the point to just make gui_script_draw not call the MD stuff if script isn't running.

The PTP code has it's own special cases to handle scripts that enter and leave alt. There should probably be a generic script_enter_alt and script_leave_alt or something.

Another potential issue is that scriptGuiHandler is only set when the script is first run from the gui, so if you use exit_alt and enter_alt, you will never get back to the original state. PTP will also never use scriptGuiHandler, presumably meaning the MD grid will never be drawn.

The whole logic of show_md_grid is not clear to me, it looks like it's specifically set up to show briefly after script stops, but the old_gui_handler stuff is set up to override this.
Don't forget what the H stands for.

Re: exit_alt issues
« Reply #4 on: 12 / June / 2014, 12:21:47 »
I’m still interested in a fix as this will make my underwater photography so much easier/dependable! Who do I talk to ;-)

Re: exit_alt issues
« Reply #5 on: 12 / June / 2014, 12:36:37 »
I’m still interested in a fix as this will make my underwater photography so much easier/dependable! Who do I talk to ;-)
Reyalp checked a fix into the 1.3.0 branch of CHDK.  Have you tried the latest version of that?
Ported :   A1200    SD940   G10    Powershot N    G16

Re: exit_alt issues
« Reply #6 on: 12 / June / 2014, 15:06:03 »
Cool, I found the new build and now the exit is dependable!
I have removed most sleep statements in my code posted below for reference.

Thanks!

Code: [Select]
@title TTL setter
rem DESCRIPTION:
rem WHAT:   This script turns on the TTL mode for the flash if it was not on already.
rem WHEN:   This is useful for e.g. underwater photography with Canon S95.
rem WHY:    In 'Manual' mode the factory firmware doesn't support TTL.
rem HOW:    The script can be set to auto run. No more worries.

rem HISTORY:
rem 2012-01-05 Initial script written by jamesinsummer from:
rem     http://chdk.setepontos.com/index.php?topic=5876.msg68670
rem 2012-06-13 Initial adaptation by jurgenfd in same thread.
rem 2014-05-19 Adding auto exit for speedy usage.
rem 2014-06-12 Removed most sleep commands.

get_prop 121 b

if b=0 then
    print "Still TTL"
else
    set_prop 121 0
    print "Set to TTL"
endif
sleep 1000
exit_alt 0

 

Related Topics


SimplePortal © 2008-2014, SimplePortal