CHDK Wiki
(Adding categories)
Tags: Visual edit apiedit
(15 intermediate revisions by 3 users not shown)
Line 1: Line 1:
CHDK allows you to automate your camera by running "scripts", small and simple programs written by end-users and executed on the camera. Currently, CHDK allows you to use scripts written in [[Lua]] (filetype: <tt>*.lua</tt>) and [[UBASIC|uBASIC]] (filetype: <tt>*.bas</tt>). The file extension indicates how the script should be parsed. There are scripts for exposure bracketing, focus bracketing, intervalometer and many more.
+
CHDK allows you to automate your camera by running "scripts" - small and simple programs written by end-users and executed on the camera. Currently, CHDK allows you to use scripts written in [[Lua]] (file names: <tt>*.lua</tt>) and [[UBASIC|uBASIC]] (file names: <tt>*.bas</tt>). The file extension indicates how the script should be parsed. There are scripts for many applications like for exposure bracketing, focus bracketing, intervalometers and more available here : [[User Written Scripts]]
 
==Differences between Lua and UBASIC==
 
 
uBASIC was the first scripting language supported in CHDK and is a smaller language (both in memory size and extensiveness of features). Lua came later and can be found in CHDK builds > version 0.5 / changeset 512. In general Lua scripts will use more memory and run faster. Some scripts use particular implementation details of one or the other language and will need some re-factoring (re-writing the flow and content of the program) in order to accomplish the same goals
 
   
 
==Running a script==
 
==Running a script==
Line 18: Line 14:
 
===Running a Lua script===
 
===Running a Lua script===
 
* The script should be saved with the filename extension <tt>.lua</tt> in the CHDK scripts folder <tt>chdk/scripts</tt>
 
* The script should be saved with the filename extension <tt>.lua</tt> in the CHDK scripts folder <tt>chdk/scripts</tt>
* Lua scripts support libraries, place these files in either <tt>chdk/scripts</tt> or <tt>chdk/lualib</tt> (see [[Lua_syntax#Libraries|Lua syntax: Libraries]]).
+
* Lua scripts support libraries, place these files in either <tt>chdk/scripts</tt> or <tt>chdk/lualib</tt> (see [[Lua/Lua_syntax#Libraries|Lua syntax: Libraries]]).
   
 
===Running a uBASIC script===
 
===Running a uBASIC script===
 
* The script should be saved with the filename extension <tt>.bas</tt> in the CHDK scripts folder <tt>chdk/scripts</tt>
 
* The script should be saved with the filename extension <tt>.bas</tt> in the CHDK scripts folder <tt>chdk/scripts</tt>
   
 
==Differences between Lua and UBASIC==
==Setting up a development environment==
 
   
  +
uBASIC was the first scripting language supported in CHDK. Lua came later and can be found in every CHDK build released since the year 2008. In general, Lua scripts will run faster and provide more features that uBASIC but the Lua language is not as well know as the many variants of BASIC.
For help in setting up a Lua development environment, see [[Lua Dev Environment]]. Scripts can be tested locally and then uploaded to the camera. You may wish to build CHDK without some components (such as games) to increase the available memory on the camera.
 
   
 
==Useful Links==
For setting up a UBASIC development environment see [[UBASIC/TutorialScratchpad]] and [http://www.zenoshrdlu.com/kapstuff/zubdb.html UBDebug]
 
 
==Links==
 
   
  +
* [[CHDK_Scripting_Cross_Reference_Page|CHDK Scripting Cross Reference Page]]
 
* [[Script commands]] - New uBASIC and Lua scripting commands
 
* [[Script commands]] - New uBASIC and Lua scripting commands
 
* The [http://chdk.setepontos.com/index.php?board=7.25 script board] on the [[http://chdk.setepontos.com/index.php CHDK forums]]
 
* The [http://chdk.setepontos.com/index.php?board=7.25 script board] on the [[http://chdk.setepontos.com/index.php CHDK forums]]
* [[CHDK_firmware_usage/MoreBest#New_uBASIC_and_LUA_Scripting_Commands.21|New uBasic &amp; Lua scripting commands]], descriptions of newly introduced scripting commands
 
   
 
===Lua===
 
===Lua===
Line 49: Line 43:
   
 
====Scripts====
 
====Scripts====
* [[UBASIC/Scripts| User written uBASIC scripts]]
+
* [[uBASIC/Scripts| User written scripts]]
  +
 
==Setting up a development environment==
  +
 
For help in setting up a Lua development environment, see [[Lua Development Environment]]. Scripts can be tested locally and then uploaded to the camera. You may wish to build CHDK without some components to increase the available memory on the camera.
  +
 
For setting up a UBASIC development environment see [[UBASIC/TutorialScratchpad]] and [http://www.zenoshrdlu.com/kapstuff/zubdb.html UBDebug]
 
[[Category:Lua]]
 
[[Category:Lua]]
[[Category:UBASIC]]
+
[[Category:uBASIC]]
 
[[Category:Development]]
 
[[Category:Development]]
 
[[Category:Scripts]]
 
[[Category:Scripts]]
[[Category:Scripting]]
 

Revision as of 14:11, 13 December 2015

CHDK allows you to automate your camera by running "scripts" - small and simple programs written by end-users and executed on the camera. Currently, CHDK allows you to use scripts written in Lua (file names: *.lua) and uBASIC (file names: *.bas). The file extension indicates how the script should be parsed. There are scripts for many applications like for exposure bracketing, focus bracketing, intervalometers and more available here : User Written Scripts

Running a script

Script

The Script Menu

Script

Running a Script - Exposure Bracketing

Overview

  • Download or write your own script and place it in the chdk/scripts/ folder of your SD-card with the proper extension (.lua for Lua scripts, .bas for UBASIC scripts).
  • Enter the script menu, load the script, adjust the parameters to your liking and leave the menu.
  • While still in <ALT> mode just press the shutter button and the script will start. A mini console will be displayed while you run the script.
  • Note: set the Review parameter in the NORMAL camera menu to "off", other options like "x sec" or "hold" will interfere with the execution of scripts.
  • You may interrupt a running script by just pressing the shutter button again. Or pause a running script by exiting <ALT> mode, if paused the script will resume right where it left off when re-entering <ALT> mode.

Running a Lua script

  • The script should be saved with the filename extension .lua in the CHDK scripts folder chdk/scripts
  • Lua scripts support libraries, place these files in either chdk/scripts or chdk/lualib (see Lua syntax: Libraries).

Running a uBASIC script

  • The script should be saved with the filename extension .bas in the CHDK scripts folder chdk/scripts

Differences between Lua and UBASIC

uBASIC was the first scripting language supported in CHDK. Lua came later and can be found in every CHDK build released since the year 2008. In general, Lua scripts will run faster and provide more features that uBASIC but the Lua language is not as well know as the many variants of BASIC.

Useful Links

Lua

  • Lua - An introduction to Lua on CHDK
  • Lua Reference - Describes additional and/or changed scripting commands for the Lua scripting language
  • Lua Syntax - Basic syntax for Lua scripts

Scripts

uBASIC

Scripts

Setting up a development environment

For help in setting up a Lua development environment, see Lua Development Environment. Scripts can be tested locally and then uploaded to the camera. You may wish to build CHDK without some components to increase the available memory on the camera.

For setting up a UBASIC development environment see UBASIC/TutorialScratchpad and UBDebug