PicoC scripting API

Started by a1ex, January 26, 2013, 01:24:01 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

a1ex

Just added some more APIs:
- key interaction (get_key)
- menu interaction (select a menu item, get/set value)
- DOF and focus info (get_dof: hyperfocal, focus distance, DOF far/near etc)
- set_led
- mic_out (digital output via mic jack)
- focus, focus_setup (in LiveView, like follow focus)
- get/set AFMA

There are some more commented out in picoc/library_ml.c; feel free to implement them.

scrax

Is already possible to add a label to @param?
For example I want to make set param in the script that make the scrip load or save some settings, so t should show Loan and Save instead of On Off, also another idea on something form complex labels with also the value shown.

/*
@title PicoC script's title

@param a First variable name
@range a 0 1
@labels a Load Save

@param b Second variable name
@range b 0 5
@labels b Off 'C-Mode:%d, @range'
*/
I'm using ML2.3 for photography with:
EOS 600DML | EOS 400Dplus | EOS 5D MLbeta5- EF 100mm f/2.8 USM Macro  - EF-S 17-85mm f4-5.6 IS USM - EF 70-200mm f/4 L USM - 580EXII - OsX, PS, LR, RawTherapee, LightZone -no video experience-

a1ex


a1ex

Graphics functions (draw_line, draw_circle, bmp_printf etc) are working.

Anyone would like to write a nice demo script?

photo360

Is it possible with PicoC scripting API to do a special bracketing sequence with/without flash?
I need to take some pictures with flash at some shutter speed and to take the same pictures without flash...
this should work on 5DII with canon speedlite 580EX.

Thanks for your help

Exemple of script:

set_aperture(11);
set_iso(100);
set_shutter(1./160);
"flash off"
takepic();

"flash on"
takepic();

a1ex

I've just added set_flash(1) / set_flash(0), but I have no idea if it works on external flashes.

Also pop_flash() should work for built-in flash.

photo360

Thanks !

Some tests:

set_flash(0)/set_flash(1) works great on canon 50D with external flash (canon speedlite 580 EX) or with built-in flash.
pop_flash() does not work on my 50D. The flash shoud be pop up manually.

set_flash(0)/set_flash(1)  does not work en 5DMKII with canon speedlite 580 EX. the flash fire each time.
It seems that this function works only for canon with build-in flash.

Is there another solution for 5DMKII ?

gerk.raisen

Hello,

please add an API to read the sound dB level so that we can trigger when sound level go up (or also go down) a threshold.

Thank you.

SDX

Audio Remote Shoot does exactly that - it's in the shoot menu.

gerk.raisen

Yes, I know that, but the idea is to have an API to use it within a script.

wolf

You could switch the audio trigger on and off with picoc:

void menu_open();                                     // open ML menu
void menu_close();                                    // close ML menu
void menu_select(char* tab, char* entry);             // select a menu tab and entry (e.g. Overlay, Focus Peak)
int menu_get(char* tab, char* entry);                 // return the raw (integer) value from a menu entry
int menu_set(char* tab, char* entry, int value);      // set a menu entry to some arbitrary value; 1 = success, 0 = failure
char* menu_get_str(char* tab, char* entry);           // return the displayed (string) value from a menu entry
int menu_set_str(char* tab, char* entry, char* value); // set a menu entry to some arbitrary string value (cycles until it gets it); 1 = success, 0 = failure



Kent

Is it possible to add functionality to export AF mode and the settings for AF Case 1 , Case 2 etc.
as a PicoC script ?
5D3 , EF 100 2.8L Macro, EF 24-105 4L, EF 70-200 2.8L IS, EF 400 5.6L, 580 EX II's, RRS BH-55, Gitzo GT5532LS, Pixel King's, ZOOM H4N

a1ex

Ouch, that looks painful...

Kent

5D3 , EF 100 2.8L Macro, EF 24-105 4L, EF 70-200 2.8L IS, EF 400 5.6L, 580 EX II's, RRS BH-55, Gitzo GT5532LS, Pixel King's, ZOOM H4N

Alia5

Would anyone mind extending beep() to beep(int msecs, int frequency)? ;)

scrax

I can't find a way to change image quality with scripts, seems not yet implemented. To explain better my idea this is the script I'm working on:

/*
@title Custom Burst Shot
@param r Number of raw burst
@range r 0 9
@default r 3
@param l Number of L Jpg burst
@range l 0 9
@defaull r 6
@param m Number of M Jpg burst
@range m 1 29
@default m 16
*/
console_hide();
int quality = get_quality();
int key = wait_key();
while(key != SET){
    if (key == SHOOT_FULL){
        if(r != 0){
            set_quality(RAW);
            take_fast_pics(r);
            sleep(0.1);
        }
        if(l != 0){
            set_quality(JPGLF);
            take_fast_pics(l);
            sleep(0.1);
        }
    }
    set_quality(JPGMF);
    take_fast_pics(m);
    sleep(0.1);
    set_quality_to(quality);
}
if (key == SET){
    break;
}

I'm using ML2.3 for photography with:
EOS 600DML | EOS 400Dplus | EOS 5D MLbeta5- EF 100mm f/2.8 USM Macro  - EF-S 17-85mm f4-5.6 IS USM - EF 70-200mm f/4 L USM - 580EXII - OsX, PS, LR, RawTherapee, LightZone -no video experience-

a1ex

Yes, it's not implemented. And since some of these constants are camera-specific, and wrong values cause persistent ERR70 (even if you boot without ML), I'm a bit hesitant to add it.

A common subset (e.g. plain RAW and a few JPEG presets) should be OK though.

scrax

Quote from: a1ex on March 17, 2013, 10:51:03 PM
Yes, it's not implemented. And since some of these constants are camera-specific, and wrong values cause persistent ERR70 (even if you boot without ML), I'm a bit hesitant to add it.

A common subset (e.g. plain RAW and a few JPEG presets) should be OK though.
Totally agree, adding just a safe subset can be enough.

I'm using ML2.3 for photography with:
EOS 600DML | EOS 400Dplus | EOS 5D MLbeta5- EF 100mm f/2.8 USM Macro  - EF-S 17-85mm f4-5.6 IS USM - EF 70-200mm f/4 L USM - 580EXII - OsX, PS, LR, RawTherapee, LightZone -no video experience-

engardeknave

How about listing/renaming files or even triggering a directory creation/change ala the canon menu? I plan to do one of these things after a bracket set to organize the sets.

a1ex

That's difficult, since Canon code also expects a catalog of files (not just what's on the filesystem). If you rename the files from the camera, you'll get ERR70.

engardeknave

What about changing folders exactly as if it were manually done from the menu?

engardeknave

A couple more things.

1. Right now when I have a script continuously running, it says "script running" when I view photos. Then the console pops up when I try to delete a photo by pressing the set button. There's got to be a way to keep a script completely in the background during normal use. Well that's mostly fixed now.

2. Still really, really want to be able to perform a select folder/create folder programmatically exactly the way it is in the Canon menus.

3. It would be great to be able to get the current camera mode.

4. An easy way to execute scripts from a script.

edit: 5. Location of the focus box in liveview. And maybe even the value of the spotmeter.

This new ability to script is extremely exciting.

a1ex

2. This needs reverse engineering, we don't know how to do that.

3. should be easy, I'll add it.

4. sounds interesting, but I'm not sure where it would be useful; can you describe some use case for this?

5. should be easy. You can already use custom spotmeters, see img.c.

Also, we are considering to upgrade the engine to TCC (it's much faster, roughly 1000x, since TCC is a compiler, not an interpreter). Technical discussion: http://www.magiclantern.fm/forum/index.php?topic=4877 . The existing GUI is already working with TCC (just compile with CONFIG_TCC=y instead of CONFIG_PICOC if you want to try it).

The main issues that need to be solved:
- memory usage is a bit higher now (so 60D won't boot with it), but TCC only needs to be loaded when compiling the scripts, and then unloaded.
- compatibility with existing scripts (TCC is more strict, it requires a main function)
- how to stop the scripts? (we could just kill the task, but it's ugly)

The existing API should be easy to port, I don't foresee any difficulties here.

engardeknave

My purpose in running scripts from a script would be to execute scripts at startup from autorun.c, possibly contingent on some conditions, such as camera mode.

The things I want to do so far will actually work in PicoC, but TCC sounds fantastic.

scrax

totally agree for 3 and 4.
I fell the need to call other script too from a main script.
Best of this will be to call a script saved in any folder on the card, so to not fill the 11 limit in the main script folder.
That way we can also build a sort of script library that is used by one of the 11 launcher scripts we can run from ML.
For example Marsu42 request of a beep after bracketing could be a script in /EOS_DIGITAL/ML/script/library/ called from a braketing "launcher" script when finished, maybe triggered by a script option.
Same beep script will then be called also from another "launcher" script.

This is really a simple example that could already be done without this implementation but I think that once added it will be used a lot for more interesting things.

TCC is really fascinating, but will put my questions about it in the other topic.
I'm using ML2.3 for photography with:
EOS 600DML | EOS 400Dplus | EOS 5D MLbeta5- EF 100mm f/2.8 USM Macro  - EF-S 17-85mm f4-5.6 IS USM - EF 70-200mm f/4 L USM - 580EXII - OsX, PS, LR, RawTherapee, LightZone -no video experience-