CHDK Wiki
Register
No edit summary
Line 7: Line 7:
 
Commands should have the form, that is presented below for ''print ''command.
 
Commands should have the form, that is presented below for ''print ''command.
   
==print==
+
==print - just an example==
 
''languages: uBASIC, Lua.''
 
''languages: uBASIC, Lua.''
   
Line 20: Line 20:
 
Above lines will display following text on virtual console:
 
Above lines will display following text on virtual console:
 
Hello World!
 
Hello World!
 
   
 
=Camera operation commands=
 
=Camera operation commands=

Revision as of 16:29, 25 December 2011

Note: This page is designed to replace Script commands page in future. Currently it is just a stub.

To documentation writers

It is well known, that documentation should be clear to prevent confusions and avoid many questions from users. This new version of script commands documentation is designed to provide new, complete informations about commands, their usage and examples of code, where this can be used.

I'm sure, that these commands should be ordered by type, for example: shooting-related, hardware-related, console and drawing related. The next odrer should be alphabetical.

The form

Commands should have the form, that is presented below for print command.

print - just an example

languages: uBASIC, Lua.

This command provides you a method to display a text on scripting virtual console. Each string will be displayed in new line. Argument may be string or number.

Usage in Lua:

print("Hello World!")

Usage in uBASIC:

print "Hello World!"


Above lines will display following text on virtual console:

Hello World!

Camera operation commands

click

Languages: uBASIC, Lua. This command emulates short pressing ot the appropriate button. That means it works as if you perss and immediately release the button.

Usage in Lua:

click("button_name")

Usage in uBASIC:

click "button_name"


For example if you want to camera think that you clicked "left" button you should do:

Example in Lua:

click("left")


List of buttons that can be used:

  • shoot_half
  • shoot_full
  • left
  • right
  • up
  • down
  • set
  • zoom_in
  • zoom_out
  • display
  • menu
  • (others?)

Note 1: click command have an impact to the Canon firmware, not CHDK. So if you click "shoot_full" from a script you'll not end the script but take a shoot rather.

Note 2: see also press and release commands.


get_shooting

Languages: uBASIC, Lua. Commands is used to check, wheter camera is able to take shoot at the moment and all pre-shooting processses are already done. For example when you half press shoot button camera might check focus, exposure and other things. If this is the case when get_shooting comand is run it returns false. If camera is able to shoot the command returns true.

Usage in Lua:

​x = get_shooting()

Usage in uBASIC:

get_shooting x


If camera is able to take a shoot and whole pre-shooting process is done then x will contain true, otherwise - false.

Example of usage (Lua):

​press("shoot_half")
repeat
    sleep(50)
    until get_shooting() == true
click("shoot_full")
release("shoot_half")

Above code emulates half-pressing of shoot button, than waits until camera will be able to take a photo. Then just fully presses shoot button to make a shoot. Above code works essentially like shoot command.


press

Languages: uBASIC, Lua.

Emulates pressing of appropriate button. That means it works as if you press and hold (not release) the button.Still holding the button is the main difference between press and click command.

Usage in Lua:

press("button_name")

Usage in uBASIC:

press "button_name"


If you want to half-press and hold shoot button (e.g. to get focus) do:

Example in Lua:

press("shoot_half")


Note: do not forget of releasing the button.

See also: click and release commands.


release

Languages: uBASIC, Lua.

Emulates releasing of the button which pressing was emulated by press command.

Usage in Lua:

release("button_name")

Usage in uBASIC:

​release "button_name"


Example in Lua:

press("shoot_half")
repeat
    sleep(50)
    until get_shooting() == true
click("shoot_full")
release("shoot_half")


Note 1: without release command camera would 'think' that half-shoot button is still pressed.

Note 2: releasing of shoot_full button is not needed in above code because it wass clicked not pressed.

See also: press and click commands.


shoot

Languages: uBASIC, Lua.

This command causes camera to perform whole shooting action: it involves all processess that camera do before shoot (just like half pressing shoot button) and then shoots. For example: if in AUTO, P, Tv, Av, or any SCN modes, using the "shoot" command causes the camera to check focus and exposure for each shot. When "shoot" is used in intervalometer scripts this far surpasses the camera's own built-in intervalometer in that the camera only sets exposure and focus once for the initial exposure, as if it was only using the "click 'shoot_full'" command. This "shoot" command in an intervalometer script allows it to compensate for all the things that can change over the course of many minutes and hours.

Usage in Lua:

​shoot()

Usage in uBASIC:

​shoot

Shoot function takes no arguments.