Automatic Playback button press - SD4000 - Script Writing - CHDK Forum supplierdeeply

Automatic Playback button press - SD4000

  • 27 Replies
  • 12296 Views
Automatic Playback button press - SD4000
« on: 16 / June / 2017, 20:28:46 »
Advertisements
This could be the simplest solution for SD4000 hangs after taking shots at 1/15s and slower. It doesn't involve build modifications nor Canon firmware modifications. It is very, very simple.

My autorun script, extended:

@title SD4000 Bootup
@chdk_version 1.4.1
sleep 500                                                                                 
if autostarted = 0 then goto "Exit"
if get_drive_mode = 0 then
  press "shoot_half"
  sleep 1000
  release "shoot_half"
endif
:Exit
  cls
  exit_alt 0
:Loop
wait_click 99999
  if is_key "shoot_full_only" then get_tv a
  if a < 13 then
sleep 5000
  set_record(0)
  sleep 5000
  set_record(1)
goto "Loop"

end

The loop works as intended, but there is no difference between shoot_half and shoot_full. Set_record command activates on half press already, regardless of selected shutter speed in Av, which should NOT happen. I tried all combinations (shoot, shoot_full, shoot_full_only). The first part of the script works fine, and it seems that shoot_half is properly recognized. Why isn't it recognized in the loop I wrote? The idea is to check shutter speed for taken shot, and then, if shutter speed is 1/15s or slower, automatically go to playback mode, then go back to recording mode after 5000ms. Times will have to be adjusted of course. There is a table for shutter speed values at one of the CHDK pages (13 = 1/20, 12 = 1/15). Maybe Tv96 is required for SD4000? Maybe something else?

Also, instead of activating playback mode, one could also activate Alt, and then exit Alt - but what is the command? This could be even better as shutter button would stop the script and one could stay in Alt, then go to playback/image review etc.

This is the solution I want, and the only one realistic for SD4000. Automatic image review doesn't do what I want, I tested it. This could be handy if you don't want to review images but need to prevent the hangs (sometimes one could forget to press the buttons!).

The problem is marked in red: is_key must be SHOOT FULL, not HALF PRESS, and the value for shutter speed must be correct for Canon SD4000/IXUS 300 HS.

Can this be done?

*

Offline reyalp

  • ******
  • 14082
Re: Automatic Playback button press - SD4000
« Reply #1 on: 16 / June / 2017, 23:04:35 »
I really have no idea what you are trying to accomplish with this script, but FWIW get_drive_mode is almost certainly not what you want. It tells you whether the camera is in continuous, single shot or timer (http://chdk.wikia.com/wiki/Script_commands#get_drive_mode) not whether the camera is in play or rec mode. Use get_mode to find out if the camera is in play or rec.
Don't forget what the H stands for.

Re: Automatic Playback button press - SD4000
« Reply #2 on: 16 / June / 2017, 23:12:57 »
In addition to reyalp's comment, you probably need to better understand how uBASIC  if  statements are structured.  That's why your loop is not working as you expect.

Also, the action of code after an exit_alt statement (i.e. CHDK no longer in ALT mode) is not defined.  Strange things can happen.

For reference : CHDK Scripting Cross Reference
« Last Edit: 16 / June / 2017, 23:27:59 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Automatic Playback button press - SD4000
« Reply #3 on: 17 / June / 2017, 04:30:59 »
I really have no idea what you are trying to accomplish with this script, but FWIW get_drive_mode is almost certainly not what you want. It tells you whether the camera is in continuous, single shot or timer (http://chdk.wikia.com/wiki/Script_commands#get_drive_mode) not whether the camera is in play or rec mode. Use get_mode to find out if the camera is in play or rec.

Well waterwingz left it that way in my previous topic? It seemed strange to me, why get_drive_mode. I will change it to get_mode. Actually, according to scripting page it should be if get_alt_mode = 1 to check if cam is in Alt.

I also found enter_alt command. Going to need this. But, what should follow exit_alt 0 in my script? Perhaps this is the problem. There is nothing about it at the scripting page - it only states the correct syntax, which is exit_alt 0.


Re: Automatic Playback button press - SD4000
« Reply #4 on: 17 / June / 2017, 06:35:49 »
After more testing and trying different combinations, I can definitely tell the loop works.

This is the problem:

if is_key "shoot_full_only" then get_tv a
  if a < 13 then...

The camera waits for click but refuses to differentiate between SHOOT_FULL and ANY BUTTON CLICK - even click on Menu, or Set button goes on to

                     ...sleep 5000
  set_record(0)
  sleep 5000
  set_record(1)
goto "Loop"

This is strange, because it obviously works in the first part of the script which enables recording mode by half pressing the shutter.

How to make it work for shoot_full only, and what is the value for 1/15s shutter speed? I found the syntax, it should be

wait_click 99999
  if is_key "shoot_full_only" then...

but it runs the code for ANY click, not only shoot_full as I want it to.

Re: Automatic Playback button press - SD4000
« Reply #5 on: 17 / June / 2017, 07:31:13 »
Well waterwingz left it that way in my previous topic?
I fixed your invalid syntax - I did not spend any time trying to understand what you were trying to accomplish with the script.

This is the problem:
if is_key "shoot_full_only" then get_tv a
  if a < 13 then...
As I also said earlier, you need to understand how uBASIC  if  statements are structured.  From that link :



Hint : what does the endif statement do? How does the syntax of the matching if statement change when you use an endif ?

Edit :  the updated version of CHDK for your camera is now available for download in the autobuild.  Testing with that might be more useful than continuing to try work around the buggy release you are using.
« Last Edit: 17 / June / 2017, 07:34:44 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Automatic Playback button press - SD4000
« Reply #6 on: 17 / June / 2017, 08:33:50 »
I tried the latest beta build. It doesn't prevent the camera from hanging at slow shutter speeds. No build can fix that, it's memory management issue. The build prevents the lens from retracting while in Alt, but, for example, changes the aperture in the background when using the jog wheel in Alt. God knows what else is messed up.

I actually own the camera and shoot pictures with it - try being more analytical about my reports and findings.

It appears that mixing Jog wheel and buttons on SD4000 required some "weird" key mapping system in Canon's original firmware which makes CHDK a bit more difficult to run on this model. This is why reyalp's and the test build I've just tried fixed some things, but broke others. Key maps FLUCTUATE between modes and various operations performed on camera. It's like "up" button becomes "down" button, etc. Keys are constantly shifted, depending on the actions performed on camera. Not much can be done about this. Still, jog wheel is incredibly convenient solution, it's much better than front control ring for pocketability.

Jog wheel is, of course, clicky, with 12 positions.

The hangs which sometimes happen at slower shutter speeds might be eliminated by disabling JPEG noise reduction. That would free up RAM and CPU in great extent. Even my DSLR hangs a bit at slower shutter speeds, hence the Error 26: capture timeout on SD4000. But disabling JPEG noise reduction is impossible to achieve without modifying Canon's original JPEG engine in ROM firmware, which would most certainly damage the camera.

Fortunately, there's a workaround for almost every problem!

I wanted to run this script only to press less buttons on some occasions. I explained carefully what the script needs to do. If you know the solution for the script drop it, if not, never mind...

This is the latest version:

:Loop
wait_click 99999
  if is_key "shoot_full" then goto "shutter"
  else goto "loop"
  :Shutter
     get_tv a
     if a < 13 then sleep 5000
     set_record(0)
     sleep 5000
     set_record(1)
     else goto "loop"
   endif
goto "Loop"
end

But the chances are this will never work, due to the fluctuating key mapping. Only Canon's original firmware knows precisely which key is which at particular moment, and CHDK is only trying to guess.

Do you understand the problem now?

Re: Automatic Playback button press - SD4000
« Reply #7 on: 17 / June / 2017, 09:11:17 »
Do you understand the problem now?
Yup.
Ported :   A1200    SD940   G10    Powershot N    G16


Re: Automatic Playback button press - SD4000
« Reply #8 on: 17 / June / 2017, 09:24:47 »
I can now definitely confirm is_key does NOT work with SD4000 due to the reasons I explained in previous post.
We also established that all focus commands end in failure, and manual focusing (S.D.O.) is not possible.

Nevertheless, I would highly recommend this camera to anyone! With a couple of workarounds, it shoots wonderful RAWs in low light while still being truly pocketable.

IMHO, it's the best value for money, as the lens, sensor size and camera size are matched very well. Who needs 20MP 30MB RAWs from G7 X which look like 3MP [admin: avoid swearing please], and are actually larger than my D3300 RAWs!?  :haha :haha :haha :haha
« Last Edit: 17 / June / 2017, 09:26:47 by Robert1975 »

Re: Automatic Playback button press - SD4000
« Reply #9 on: 17 / June / 2017, 09:39:01 »
I can now definitely confirm is_key does NOT work with SD4000 due to the reasons I explained in previous post.
If you are basing this conclusion on the script fragment you posted, you might want to look closer.  Your use of the if then else constructs is still wrong and the way you have the capitalization of the labels means the script cannot run.
« Last Edit: 17 / June / 2017, 09:40:35 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

 

Related Topics