Code to improve error messages from press/click/release in a Lua script - General Discussion and Assistance - CHDK Forum  

Code to improve error messages from press/click/release in a Lua script

  • 0 Replies

I have implemented a small error message improvement for Lua scripts:

Whilst trying to write a script - incidentally, to switch my G9 in and out of continuous shooting mode - I kept finding that my scripts would run without any errors *but* simply did not do the right thing. Chipping away lines of script I eventually found that the following 1 line script would run and do nowt:

Code: [Select]
You will have spotted my mistake: there is no key called "timer" on the G9, so it is an error to try to press it. But trying to press another button that doesn't exist on the G9, as this Lua script does

Code: [Select]
*will* generate an error message, "unknown key".

The code I've attached will catch the problem in the first script and generate the error message "key not available on this camera".

About the attachment:
I'm afraid I'm not a wizz at diff/patch and when I attempted to generate a patch from my local SVN against the revision that represents the trunk905 sources it - obviously - pulled in this change *and* my earlier one about continuous mode bracketing. I've tried to separate the two and just include the relevant items, hopefully the file is usable... Except it leaves out the addition of the following declaration into include/platform.h

Code: [Select]
int kbd_key_exists(long key);
which I placed immediately above that for

Code: [Select]
void kbd_key_press(long key);
void kbd_key_release(long key);
Also, because of the mass duplication of the code in the platform/*/kbd.c files, a short routine has to be added into *all* of the camera-specific kbd.c files - and I've only included it into the two that I can test with.

So, now the camera is telling me that pressing "timer" isn't going to ever work, back to figuring out what, if anything, *will* let a Lua script put a camera into continuous shooting mode and then back out again...


Related Topics