simple code for scriptless remote - General Discussion and Assistance - CHDK Forum  

simple code for scriptless remote

  • 8 Replies
  • 7982 Views
*

Offline whoever

  • ****
  • 280
  • IXUS950
simple code for scriptless remote
« on: 30 / July / 2008, 12:29:26 »
Advertisements
Recent SDM and "collaborative" juciphox builds feature scriptless remote, i.e. the ability to use a USB remote shutter in the conventional way. The corresponding codebase is apparently due to the stereo-photographer Masuji Suto. The code is rather versatile and oriented on stereo-photographers' needs. It is also rather involved.

I've been using much simpler code, which I would like to share. It's confined to core\kbd.c, in the function kbd_process(), the code additions easily spotted through the enclosing comments:

Code: [Select]
/*-- ----------------- Alex scriptless remote additions start --------------------*/
static int remoteHalfShutter=0, remoteFullShutter=0, remoteShooting=0, remoteClickTimer=0;
#define REMOTE_MAX_CLICK_LENGTH 50
/*-------------------- Alex scriptless remote additions end ---------------------*/
long kbd_process()
{
/* Alternative keyboard mode stated/exited by pressing print key.
 * While running Alt. mode shoot key will start a script execution.
 */

    if (kbd_blocked){
/*------------------- Alex scriptless remote additions start --------------------*/
        if (remoteShooting) {

          if (remoteHalfShutter) {
            if (get_usb_power(1)) {
              if (remoteClickTimer < REMOTE_MAX_CLICK_LENGTH) {
                remoteHalfShutter=0;
                remoteFullShutter=1;
                kbd_key_press(KEY_SHOOT_FULL);
              }
              return 1;
            } else {
              --remoteClickTimer;
              if ( remoteClickTimer == 0 ) {
                kbd_key_release_all();
                remoteHalfShutter=0;
                remoteShooting=0;
                kbd_blocked=0;
                return 0;
              }
            }
          }

          if (remoteFullShutter) {
            if (get_usb_power(1)) {
              return 1;
            } else {
              kbd_key_release_all();
              remoteFullShutter=0;
              remoteShooting=0;
              kbd_blocked=0;
              return 0;
            }
          }

        }
/*-------------------- Alex scriptless remote additions end ---------------------*/
if (key_pressed){
            if (kbd_is_key_pressed(conf.alt_mode_button)) {
                ++key_pressed;
                if (key_pressed==CAM_EMUL_KEYPRESS_DELAY) {
                    kbd_key_press(conf.alt_mode_button);
                }
                if (key_pressed==(CAM_EMUL_KEYPRESS_DELAY+CAM_EMUL_KEYPRESS_DURATION)) {
                    kbd_key_release_all();
                    key_pressed = 2;
            kbd_blocked = 0;
//            gui_kbd_leave();
                }
            } else if (kbd_get_pressed_key() == 0) {
                gui_kbd_enter();
        key_pressed = 0;
            }   
    return 1;
}

if (kbd_is_key_pressed(conf.alt_mode_button)){
    key_pressed = 2;
    kbd_blocked = 0;
    gui_kbd_leave();
    return 1;
}

if (kbd_is_key_pressed(KEY_SHOOT_FULL)){
    if (!state_kbd_script_run){
                script_console_clear();
                script_console_add_line(lang_str(LANG_CONSOLE_TEXT_STARTED));
script_start();
    } else {
                script_console_add_line(lang_str(LANG_CONSOLE_TEXT_INTERRUPTED));
script_end();
    }
}

if (state_kbd_script_run)
    process_script();
else {
    gui_kbd_process();
}
    } else {

        //if (kbd_is_key_pressed(KEY_SHOOT_HALF) && kbd_is_key_pressed(conf.alt_mode_button)) return 0;

if (!key_pressed && kbd_is_key_pressed(conf.alt_mode_button)){
    kbd_blocked = 1;
    key_pressed = 1;
    kbd_key_release_all();
//     gui_kbd_enter();
    return 1;
}
 
/*------------------- Alex scriptless remote additions start --------------------*/
        if (conf.remote_enable && key_pressed != 2 && get_usb_power(1)) {
          remoteShooting = 1;
          remoteHalfShutter = 1;
          remoteClickTimer = REMOTE_MAX_CLICK_LENGTH;
          kbd_blocked = 1;
          kbd_key_release_all();
          kbd_key_press(KEY_SHOOT_HALF);
          return 1;
        }
/*-------------------- Alex scriptless remote additions end ---------------------*/

if (key_pressed == 2) {
if (kbd_is_key_pressed(conf.alt_mode_button))
return 1; // wait until released before unblocking kbd
else
key_pressed = 0;
}

if (conf.use_zoom_mf && kbd_use_zoom_as_mf()) {
    return 1;
}

other_kbd_process(); // processed other keys in not <alt> mode
    }

    return kbd_blocked;
}

Then, if USB remote is enabled, pressing/releasing remote button is equivalent to pressing/releasing the shutter halfway. To take a shot, do a "reversed click", i.e. momentarily release and again depress the remote button whithin 0.5s, which will "push" the shutter all the way.


Re: simple code for scriptless remote
« Reply #1 on: 01 / August / 2008, 06:31:59 »
This looks great. I wanted to expand the functionality of a USB remote shutter release script to enable using the zoom buttons on my camera.

Now I found this and it looks very interesting.

Q1: Should your code check wether the camera is set on manual focus? because then you could shoot at the first press of the button on the remote control. This is faster and more useful on many ocasions.

Q2: Can you post a link to a custom build , so I can try this on my S5 powershot? I lack the means of compiling myself the sourcecode.

Thanks , can't hardly wait to try this out.

*

Offline whoever

  • ****
  • 280
  • IXUS950
Re: simple code for scriptless remote
« Reply #2 on: 01 / August / 2008, 08:09:51 »
The code as it stands is intentionally made simple, it does not do any such checks, although they can be easily implemented.

You didn't mention which f/w version your cam has, so i attach builds for both. As before any CHDK upgrade, it is advisable to remove /CHDK/CHDK.CFG from the card and store it elsewhere along with your current DISKBOOT.BIN

Please write back with the results.
« Last Edit: 01 / August / 2008, 08:43:09 by whoever »

Re: simple code for scriptless remote
« Reply #3 on: 06 / August / 2008, 05:18:58 »
Great work! Works wonders.

1. Checking wether camera is in manual focus mode might be usefull because you don't have to press twice the remote button. Could speed up things. Anyway the camera does not attempt to focus if it is already set to Manual , so this is not a big problem

2. By default Remote USB option is disabled, the purpose of the code is to enable use of remote USB, so it might be better to set it on from the begining. :)

3. My firmware is S5IS_101b. Wasn't sure, but tried both of them.

4. I tried the following build , CHDK/MoreBest - CHDK Wiki , but it is utterly slow : every time after I shoot with the remote, it seems to go into ALT mode , and if I want to zoom in or out , it takes about 0.5 sec until zooming starts. The little blue LED blinks. So your enhacement is great, hope you can get it onto a standard build !

Cheers!


*

Offline whoever

  • ****
  • 280
  • IXUS950
Re: simple code for scriptless remote
« Reply #4 on: 06 / August / 2008, 06:49:39 »
Glad that it works for you.

1. Checking wether camera is in manual focus mode might be usefull because you don't have to press twice the remote button. Could speed up things. Anyway the camera does not attempt to focus if it is already set to Manual , so this is not a big problem
Try the attached build, it should work as you wish, i.e. shoots on first press if the focusing is in the manual mode. The corresponding code is also there.

Quote
2. By default Remote USB option is disabled, the purpose of the code is to enable use of remote USB, so it might be better to set it on from the begining. :)
That won't work so far as i can see, since if the remote is automatically enabled by the USB signal, then how can it be disabled to allow for file transfer?

Quote
4. I tried the following build , CHDK/MoreBest - CHDK Wiki , but it is utterly slow : every time after I shoot with the remote, it seems to go into ALT mode , and if I want to zoom in or out , it takes about 0.5 sec until zooming starts. The little blue LED blinks. So your enhacement is great, hope you can get it onto a standard build !
It's highly specialized code for stereophotography freaks. Don't know if it's only my personal trouble, but it hangs my cam if used in burst mode... If the blue LED is blinking after a shot, you are probably saving RAW.

Re: simple code for scriptless remote
« Reply #5 on: 06 / August / 2008, 07:21:04 »
Glad that it works for you.

1. Checking wether camera is in manual focus mode might be usefull because you don't have to press twice the remote button. Could speed up things. Anyway the camera does not attempt to focus if it is already set to Manual , so this is not a big problem
Try the attached build, it should work as you wish, i.e. shoots on first press if the focusing is in the manual mode. The corresponding code is also there.

Thanks for the quick reply! The new build works as stated. Tried burst mode +/- AF , works in Video record (takes picture).

Great work!

2. By default Remote USB option is disabled, the purpose of the code is to enable use of remote USB, so it might be better to set it on from the begining. :)
That won't work so far as i can see, since if the remote is automatically enabled by the USB signal, then how can it be disabled to allow for file transfer?

Solved this one too, it saves my setting, so no need to do it every time it starts.


4. I tried the following build , CHDK/MoreBest - CHDK Wiki , but it is utterly slow : every time after I shoot with the remote, it seems to go into ALT mode , and if I want to zoom in or out , it takes about 0.5 sec until zooming starts. The little blue LED blinks. So your enhacement is great, hope you can get it onto a standard build !
It's highly specialized code for stereophotography freaks. Don't know if it's only my personal trouble, but it hangs my cam if used in burst mode... If the blue LED is blinking after a shot, you are probably saving RAW.

Did not express myself right: the blue LED blinks,but for a short moment <ALT> appears onscreen.


Doesn't matter anymore! Great work, thanks again!

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: simple code for scriptless remote
« Reply #6 on: 06 / August / 2008, 07:27:17 »
are you the one who opened a bugreport in the assembla? if not, why didnt you open a thread about this behaviour here?
try deleting the cchdk.cfg file and see if this behaviour persists.

*

Offline whoever

  • ****
  • 280
  • IXUS950
Re: simple code for scriptless remote
« Reply #7 on: 06 / August / 2008, 07:41:49 »
If you're talking to me and referring to this
Quote
but it hangs my cam if used in burst mode...
then no, I'm not the one. And I'm not really a MoreBest tester, so that's why I didn't open any threads. Then again, it's a SDM specific code after all...


*

Offline Jucifer

  • *****
  • 251
  • [A710IS]
Re: simple code for scriptless remote
« Reply #8 on: 07 / August / 2008, 08:35:12 »
code added to juciphox

 

Related Topics