supplierdeeply

Triggering flashlight from code in A470/102C

  • 28 Replies
  • 3573 Views
*

Offline vi

  • *
  • 26
  • Publish
    Triggering flashlight from code in A470/102C
    « on: 24 / June / 2010, 19:44:44 »
    Advertisements
    I want be able just to trigger flashlight in play mode with lens contracted. Just strobe without any capturing (I've already implemented "just AF LED").

    I've tried to insert the code:
                         StartEFCharge(NULL);
                         while(!IsStrobeChargeCompleted()) msleep(10);
                         StopEFCharge();       
                         struct { long type; long bright1; long bright2 } q = {1, 1, 1};
                         StartInternalPreFlash(&q);

    But liker can't find these functions for A470. grepping showed signs of presence of such functions only in ixus60_sd600.
    And I don't know how to add these functions. And I don't know where to get addresses of them.

    How to trigger the flash from code? All other posts and "dataghost" branch are outdated (2008) and with no signs of A* models.

    P.S. my hacked CHDK for A470: http://github.com/vi/chdk-vi/commits/master

    *

    Offline fudgey

    • *****
    • 1705
    • a570is

    *

    Offline vi

    • *
    • 26
  • Publish
    Re: Triggering flashlight from code in A470/102C
    « Reply #2 on: 14 / July / 2010, 05:47:49 »
    Yes, related. But isn't that call_event_proc deciphered and executed inside CHDK?

    CHDK for A470 doesn't know about "StartEFCharge" or "StartInternalPreFlash", I've found about it only in some other platform code (which was actually discussed on the forum).

    How to find addresses of these functions?

    Or call_event_proc strings are executed not by CHDK, but by usual firmware so it knows about all functions?

    *

    Offline fudgey

    • *****
    • 1705
    • a570is
  • Publish
    Re: Triggering flashlight from code in A470/102C
    « Reply #3 on: 14 / July / 2010, 13:15:30 »
    http://chdk.wikia.com/wiki/LUA/LUA_Reference/Native_Function_Calls
    http://chdk.wikia.com/wiki/Event_Procedure

    All that is sort of new, which is why CHDK probably uses ROM entry points (stubs in the platform tree) found from fw dumps to access some functions that would be available as event procedures.


    *

    Offline vi

    • *
    • 26
  • Publish
    Re: Triggering flashlight from code in A470/102C
    « Reply #4 on: 15 / July / 2010, 08:24:49 »
    Thanks, I didn't know that  official firmware has such call-by-name feature.

    Actually tried the script, it works, it flashes 3 times. It works in "sleep" mode.

    But it does not [yet] work in Play mode (it just crashes), so experimenting with it further. I want to be able to turn of a camera, trigger the flashlight and turn off it without that "buzz" of expanding and contracting lens. Also non-standard uses of flashlight can require to place it directly near <something> and expanded lens is the problem there.
    « Last Edit: 15 / July / 2010, 08:27:24 by vi »

    *

    Offline reyalp

    • ******
    • 9882
  • Publish
    Re: Triggering flashlight from code in A470/102C
    « Reply #5 on: 15 / July / 2010, 16:08:00 »
    But it does not [yet] work in Play mode (it just crashes), so experimenting with it further.
    I would expect you are triggering some kind of sanity check in the canon code. If you look at the crash log ( http://chdk.wikia.com/wiki/LUA/Scripts:Standard/Test/Romlog ) I suspect you will find an assert. If this is true, I suspect it will be difficult to bypass for these functions. You might have to hunt for lower level stuff to control the flash hardware directly. Be warned that this is an area where hardware damage may well be possible.
    Don't forget what the H stands for.

    *

    Offline vi

    • *
    • 26
  • Publish
    Re: Triggering flashlight from code in A470/102C
    « Reply #6 on: 15 / July / 2010, 17:31:05 »
    It looks more like unregistered handler issue.

    If I switch camera to record mode and then back to play mode the script works.

    Update: it is indeed some assert: "ASSERT!! CntFlash.c Line 683"
    « Last Edit: 15 / July / 2010, 19:41:12 by vi »

    *

    Offline vi

    • *
    • 26
  • Publish
    Re: Triggering flashlight from code in A470/102C
    « Reply #7 on: 15 / July / 2010, 19:21:18 »
    Experimented with this new feature:

    1. Must first switch to record mode [and back] to enable StartInternalPreFlash.
    2. If I start StartEFCharge and leave if without "StopEFCharge" nothing bad happens. It just stops charging automatically.
    3. If trigger StartInternalPreFlash without properly charged flashlight, it can just fizzle. Also it can return, but postpone the flash to some other moment.
    4. StartInternalPreFlash gets control to about a second and does not preempt to CHDK code.
    5. Can call StartInternalPreFlash multiple times after charging. One maximum power flash (power=0), about three average power flashes (power=30), many weak flashes (power=10). "Lighthouse" mode works (although "disco" mode not).
    6. Maximum power is maximum. I feel heat coming from the flashlight by skin when it flashes. (suddenly looking into it is like looking into a laser pointer).
    7. Minimum power is minimum. I can look into it without discomfort. It can flash continuously every second in minimum mode like metronome for at least 5 minutes.

    Further things that will be useful:
    1. Trigger flashlight without first switching to record mode.
    2. Faster equivalent of StartInternalPreFlash to allow rapid mini-flashes (this can be useful in long exposure captures).


    *

    Offline fudgey

    • *****
    • 1705
    • a570is
  • Publish
    Re: Triggering flashlight from code in A470/102C
    « Reply #8 on: 16 / July / 2010, 01:14:14 »
    Does it allow you to call StartInternalPreFlash after power savings has drawn the lens back in after switching from REC back to PLAY + waiting a while?

    *

    Offline reyalp

    • ******
    • 9882
  • Publish
    Re: Triggering flashlight from code in A470/102C
    « Reply #9 on: 16 / July / 2010, 01:39:03 »
    It looks more like unregistered handler issue.

    If I switch camera to record mode and then back to play mode the script works.

    Update: it is indeed some assert: "ASSERT!! CntFlash.c Line 683"
    Looks like this is due to sub_FFCA2800 (on a470 100e) returning non-zero when called from FFD87CE4. It looks like there are some variables you could try poking. Too bad you can't see the return value, it would tell you which check failed.
    Don't forget what the H stands for.

     

    Related Topics