Scripting
The desktop versions of the Camera Suite app support scripts (based on the ECMA/Javascript syntax). Scripts contain a chain of camera commands and allow development of powerful camera scenarios, such as time-lapse, reoccuring-events, etc. The app ships with example scripts.
Functions
The scripting language supports a wide range of Javascript functionality, including date/time functions, maths, loops, conditionals, and string functions.
This Section describes Camera Suite specific functions. If you miss a specific function then just contact us.
setCameraMode: Sets the camera mode
setCameraMode("value");
value (string):
- video: enabled video mode.
- photo: enabled photo mode.
- burst: enables burst mode.
setCameraOn: Switch the camera on/off
setCameraOn(value);
value (bool):
- true: turns the camera on.
- false: turns the camera off.
setRecordingOn: Turns recording on/off
setRecordingOn(value);
value (bool):
- true: turns recording on.
- false: turns recording off.
setTimeout: Waits for the given number of milliseconds
setTimeout(value);
value (int):
- The number of milliseconds (= seconds*1000) to wait.
waitUntilDateTime: Wait until the given date
waitUntilDateTime("dateValue", "formatValue");
dateValue (string):
- The date until to wait for. For instance "2015-01-02 14:45:30" waits for the 2nd January 2015, 14:45:30.
formatValue (string, optional):
- The case sensitive format of the dateValue (ISO format). The format of the previous example is for instance "yyyy-MM-dd hh:mm:ss". The default format is "yyyy-MM-dd hh:mm:ss" where "yyyy" is year, "MM" month, "dd" day, "hh" hour, "mm" minutes, and "ss" seconds.
Media functions
Camera Suite 1.0.4 brings functions to list, download, and delete media from the camera. Each media file is identified by a numeric ID.
getLastCapturedMediaItem: Get the ID of the last captured media item.
var mediaItemId = getLastCapturedMediaItem();
getAllMediaItems: Get a list of IDs of all media items
var mediaItemIds = getAllMediaItems();
downloadMediaFromCamera: Add the given media item to the download manager queue
downloadMediaFromCamera(mediaItemId);
mediaItemId (int): the media item id.
deleteMediaFromCamera: Delete the media item from the camera (this cannot be undone!)
deleteMediaFromCamera(mediaItemId);
mediaItemId (int): the media item id.
Examples
Camera Suite ships with a set of examples. The following code shows a time-lapse script which captures one picture every hour (time skew caused by the function calls is not taken into account):
//
// This example captures a time lapse until the script is stopped.
// Between capturing pictures the camera is shut down to save energy.
//
// Run forever until script is stopped:
while (true)
{
// Power on camera
setCameraOn(true);
// Wait 10 seconds until camera is fully powered on
setTimeout(10000);
// Enable "photo" mode on camera
setCameraMode("photo");
// Wait 5 seconds until camera has changed the mode
setTimeout(5000);
// Capture one picture
setRecordingOn(true);
// Wait 5 seconds until camera has finished capturing
setTimeout(5000);
// Power off camera
setCameraOn(false);
// Wait one hour for the next picture
setTimeout(60*60*1000);
}
The following code shows how to download media from the camera:
// Enable "photo" mode on the camera
setCameraMode("photo");
// Wait 5 seconds until camera has changed the mode
setTimeout(5000);
// Capture
setRecordingOn(true);
// Wait 5 seconds until camera has finished capturing
setTimeout(5*1000);
// Get the latest media item name
var latestPhoto = getLastCapturedMediaItem();
// Download latest photo from camera.
// This will add the photo to the download manager queue
downloadMediaFromCamera(latestPhoto);
// We assume that the photo download takes a maximum of 5 seconds thus
// we wait 5 seconds.
setTimeout(5*1000);
// Delete the latest image from the camera
deleteMediaFromCamera(latestPhoto);
// Wait for one second to let the camera delete the media file
setTimeout(1*1000);
The following code shows how to download all media files from the camera:
// Get all media items
var mediaItems = getAllMediaItems();
for (var i=0; i<mediaItems.length; i++)
{
// This will add the media item to the download manager queue
downloadMediaFromCamera(mediaItems[i]);
}