|
|
| (7 intermediate revisions by one user not shown) |
| Line 1: |
Line 1: |
| − |
This script was written to demonstrate and test the various methods used to extend battery life when using an intervalometer (time lapse) script. |
+ |
This script was written to demonstrate and test the various methods known to extend battery life when using an intervalometer (time lapse) script. These are : |
| |
|
|
|
| − |
Discussion thread for this script is here : [http://chdk.setepontos.com/index.php?topic=9049 Battery Miser Intervalometer] . Save it with .lua file extension - something like '''miser.lua''' |
+ |
#Lock the autofocus. |
| |
+ |
#Turn the backlight off. |
| |
+ |
#<span style="line-height:21px;">Turn the display off (on camera that supports that - typically models with an OVF)\</span> |
| |
+ |
#<span style="line-height:21px;">Switch to playback mode between shots.</span> |
| |
+ |
#<span style="line-height:21px;">Enter sleep mode between shots (on cameras with a "short cut" button)</span> |
| |
+ |
Testing indicates that the using the first two methods will extend battery life about 20%. The other three methods can double or even quadruple battery life. |
| |
|
|
|
| − |
--[[ |
+ |
Discussion thread for this script is here : [http://chdk.setepontos.com/index.php?topic=9049 Battery Intervalometer] . Save it with .lua file extension - something like '''miser2.lua''' |
| − |
@title Battery Miser 5.5 |
+ |
|
| − |
@param s Interval (sec) |
+ |
<syntaxhighlight lang="lua"> |
| − |
@default s 60 |
+ |
--[[ |
| − |
@param b Turn Backlight Off |
+ |
@title Battery Miser 6.1 |
| − |
@default b 0 |
+ |
@param s Interval (sec) |
| − |
@range b 0 1 |
+ |
@default s 60 |
| − |
@param d Turn Display Off |
+ |
@param b Turn Backlight Off |
| − |
@default d 0 |
+ |
@default b 0 |
| − |
@range d 0 1 |
+ |
@range b 0 1 |
| − |
@param p Wait in Playback Mode |
+ |
@param d Turn Display Off |
| − |
@default p 0 |
+ |
@default d 0 |
| − |
@range p 0 1 |
+ |
@range d 0 1 |
| − |
@param a Enable AF Lock |
+ |
@param p Wait in Playback Mode |
| − |
@default a 0 |
+ |
@default p 0 |
| − |
@range a 0 1 |
+ |
@range p 0 1 |
| − |
@param l Log to File |
+ |
@param k Use shortcut key to sleep |
| − |
@default l 1 |
+ |
@default k 0 |
| − |
@range l 0 1 |
+ |
@range k 0 1 |
| − |
@param r Lens Retract Delay (sec) |
+ |
@param a Enable AF Lock |
| − |
@default r 60 |
+ |
@default a 0 |
| − |
@param v Batttery Stop Voltage (mV) |
+ |
@range a 0 1 |
| − |
@default v 1000 |
+ |
@param l Log to File |
| − |
@range v 0 10000 |
+ |
@default l 1 |
| − |
--]] |
+ |
@range l 0 1 |
| − |
|
+ |
@param r Lens Retract Delay (sec) |
| − |
props=require("propcase") |
+ |
@default r 60 |
| − |
|
+ |
@param v Batttery Stop Voltage (mV) |
| − |
function restore() |
+ |
@default v 1000 |
| − |
set_backlight(1) |
+ |
@range v 0 10000 |
| − |
set_aflock(0) |
+ |
--]] |
| − |
end |
+ |
|
| − |
|
+ |
props=require("propcase") |
| − |
function log_to_file( string ) |
+ |
|
| − |
if ( l == 1 ) then |
+ |
shortcut_key="print" -- edit this if using shortcut key to enter sleep mode |
| − |
print_screen(-10) |
+ |
sleep_mode=false |
| − |
print(string) |
+ |
|
| − |
print_screen(false) |
+ |
|
| − |
else |
+ |
function restore() |
| − |
print(string) |
+ |
set_backlight(1) |
| − |
end |
+ |
set_aflock(0) |
| − |
end |
+ |
sleep_disable() |
| − |
|
+ |
end |
| − |
function switch_mode( m ) -- change between shooting and playback mode |
+ |
|
| − |
if ( m == 1 ) then |
+ |
function sleep_enable() |
| − |
if ( get_mode() == false ) then |
+ |
if( sleep_mode==false) then |
| − |
print("switching to record mode") |
+ |
print("enter sleep mode via shortcut") |
| − |
set_record(1) |
+ |
press(shortcut_key) |
| − |
while ( get_mode() == false ) do |
+ |
sleep(2000) |
| − |
sleep(100) |
+ |
release(shortcut_key) |
| − |
end |
+ |
sleep_mode=true |
| |
+ |
end |
| |
+ |
end |
| |
+ |
|
| |
+ |
function sleep_disable() |
| |
+ |
if( sleep_mode==true) then |
| |
+ |
print("exit sleep mode via shortcut") |
| |
+ |
press(shortcut_key) |
| |
+ |
sleep(2000) |
| |
+ |
release(shortcut_key) |
| |
+ |
sleep_mode=false |
| |
+ |
end |
| |
+ |
end |
| |
+ |
|
| |
+ |
|
| |
+ |
function log_to_file( string ) |
| |
+ |
if ( l == 1 ) then |
| |
+ |
print_screen(-10) |
| |
+ |
print(string) |
| |
+ |
print_screen(false) |
| |
+ |
else |
| |
+ |
print(string) |
| |
+ |
end |
| |
+ |
end |
| |
+ |
|
| |
+ |
|
| |
+ |
function switch_mode( m ) -- change between shooting and playback mode |
| |
+ |
if ( m == 1 ) then |
| |
+ |
if ( get_mode() == false ) then |
| |
+ |
print("switching to record mode") |
| |
+ |
set_record(1) |
| |
+ |
while ( get_mode() == false ) do |
| |
+ |
sleep(100) |
| |
+ |
end |
| |
+ |
end |
| |
+ |
else |
| |
+ |
if ( get_mode() == true ) then |
| |
+ |
print("switching to playback mode") |
| |
+ |
set_record(0) |
| |
+ |
while ( get_mode() == true ) do |
| |
+ |
sleep(100) |
| |
+ |
end |
| |
end |
|
end |
| − |
else |
+ |
end |
| − |
if (( get_mode() == true ) and ( p == 1 )) then |
+ |
end |
| − |
print("switching to playback mode") |
+ |
|
| − |
set_record(0) |
+ |
function display_off() -- turn off display by pressing DISP button |
| − |
while ( get_mode() == true ) do |
+ |
print("blanking display") |
| − |
sleep(100) |
+ |
count=5 |
| − |
end |
+ |
disp_save = get_prop(props.DISPLAY_MODE) |
| − |
end |
+ |
repeat |
| |
+ |
disp = get_prop(props.DISPLAY_MODE) |
| |
+ |
if ( disp ~= 2 ) then |
| |
+ |
click("display") |
| |
+ |
sleep(500) |
| |
+ |
end |
| |
+ |
count=count-1 |
| |
+ |
until ((disp==2) or (count==0)) |
| |
+ |
if ( count>0 ) then |
| |
+ |
print("display blanked") |
| |
+ |
else |
| |
+ |
print("unable to blank the display") |
| |
+ |
end |
| |
+ |
end |
| |
+ |
|
| |
+ |
set_console_layout(0,0,45,12) |
| |
+ |
|
| |
+ |
if ( l==1 ) then |
| |
+ |
print_screen(-10) |
| |
+ |
print(" ") |
| |
+ |
print("============================================") |
| |
+ |
print(os.date("%d.%m.%y %X")) |
| |
+ |
print("interval=",s,"retract=",r,"AFL=",a) |
| |
+ |
print("backlight=",b,"playback_idle=",p) |
| |
+ |
print("display off=",d, "vbatt cutout=", v) |
| |
+ |
print("sleep mode=",k,"logging=",d) |
| |
+ |
print("============================================") |
| |
+ |
print_screen(false) |
| |
+ |
end |
| |
+ |
|
| |
+ |
sleep(2000) |
| |
+ |
|
| |
+ |
shotcount=0 |
| |
+ |
interval=s*1000 |
| |
+ |
retract=r*1000 |
| |
+ |
b=1-b |
| |
+ |
|
| |
+ |
|
| |
+ |
switch_mode(1) |
| |
+ |
|
| |
+ |
if( a == 1 ) then -- focus lock ? |
| |
+ |
press( "shoot_half" ) |
| |
+ |
while ( get_shooting() == true ) do |
| |
+ |
sleep(100) |
| |
end |
|
end |
| − |
end |
+ |
release("shoot_half") |
| − |
|
+ |
set_aflock(1) |
| − |
set_console_layout(0,0,45,12) |
+ |
print( "--focus locked") |
| − |
|
+ |
sleep(500) |
| − |
if ( l==1 ) then |
+ |
end |
| − |
print_screen(-10) |
+ |
|
| − |
print(" ") |
+ |
if ( d==1 ) then -- turn display off ? |
| − |
print("============================================") |
+ |
if( p==1 ) then |
| − |
print(os.date("%d.%m.%y %X")) |
+ |
print("**Warning: Wait in Playback mode") |
| − |
print("interval=",s,"retract=",r,"AFL=",a) |
+ |
print("**conflicts with Display Off mode.") |
| − |
print("backlight=",b,"playback_idle=",p) |
+ |
print("**Disabling Playback Idle mode") |
| − |
print("display off=",d, "vbatt cutout=", v) |
+ |
sleep(2000) |
| − |
print("logging=",d) |
+ |
p=0 |
| − |
print("============================================") |
+ |
end |
| − |
print_screen(false) |
+ |
display_off() |
| − |
end |
+ |
sleep(5000) |
| − |
|
+ |
end |
| − |
sleep(2000) |
+ |
|
| − |
|
+ |
|
| − |
shotcount=0 |
+ |
battery = get_vbatt() |
| − |
interval=s*1000 |
+ |
nextshot=get_tick_count() |
| − |
retract=r*1000 |
+ |
start=nextshot |
| − |
b=1-b |
+ |
abort = false |
| − |
|
+ |
|
| − |
switch_mode(1) |
+ |
|
| − |
|
+ |
-- intervalometer loop starts here |
| − |
if( a == 1 ) then -- focus lock ? |
+ |
|
| − |
press( "shoot_half" ) |
+ |
repeat |
| − |
while ( get_shooting() == true ) do |
+ |
switch_mode(1) |
| − |
sleep(100) |
+ |
print("short wait =", (nextshot-get_tick_count())/1000 ) |
| − |
end |
+ |
while (nextshot > get_tick_count()) do |
| − |
release("shoot_half") |
+ |
set_backlight(b) |
| − |
set_aflock(1) |
|
| − |
print( "--focus locked") |
|
| |
sleep(500) |
|
sleep(500) |
| − |
end |
+ |
end |
| − |
|
+ |
|
| − |
if ( d==1 ) then -- turn display off ? |
+ |
shotcount = shotcount + 1 |
| − |
if( p==1 ) then |
+ |
tic = get_tick_count()-start |
| − |
print("**Warning: Wait in Playback mode") |
+ |
nextshot = nextshot + interval |
| − |
print("**conflicts with Display Off mode.") |
+ |
lens_retract = get_tick_count() + retract |
| − |
print("**Disabling Playback Idle mode") |
+ |
log_to_file(string.format("shot:%d %2.2d:%2.2d %d.%2.2dV", shotcount, tic/3600000, (tic%3600000)/60000, battery/1000, (battery%1000)/10)) |
| − |
sleep(2000) |
+ |
|
| − |
p=0 |
+ |
if (k==1) then sleep_disable() end |
| − |
end |
+ |
|
| − |
print("blanking display") |
+ |
shoot() |
| − |
sleep(2000) |
+ |
|
| − |
count=5 |
+ |
sleep(200) |
| − |
disp_save = get_prop(props.DISPLAY_MODE) |
+ |
|
| − |
repeat |
+ |
if( p==1) then switch_mode(0) end |
| − |
disp = get_prop(props.DISPLAY_MODE) |
+ |
|
| − |
if ( disp ~= 2 ) then |
+ |
if (k==1) then sleep_enable() end |
| − |
click("display") |
+ |
|
| − |
sleep(500) |
+ |
print( "next shot wait ..", (nextshot-get_tick_count())/1000 ) |
| − |
end |
+ |
repeat |
| − |
count=count-1 |
+ |
if( (p==1) and (lens_retract < (get_tick_count()+2000) )) then |
| − |
until ((disp==2) or (count==0)) |
+ |
switch_mode(1) |
| − |
if ( count>0 ) then |
+ |
switch_mode(0) |
| − |
print("display blanked") |
+ |
lens_retract = get_tick_count() + retract |
| − |
else |
+ |
end |
| − |
print("unable to blank the display") |
|
| − |
end |
|
| − |
sleep(5000) |
|
| − |
end |
|
| − |
|
|
| − |
battery = get_vbatt() |
|
| − |
nextshot=get_tick_count() |
|
| − |
start=nextshot |
|
| − |
abort = false |
|
| − |
|
|
| − |
-- intervalometer loop starts here |
|
| − |
|
|
| − |
repeat |
|
| − |
switch_mode(1) |
|
| − |
print("short wait =", (nextshot-get_tick_count())/1000 ) |
|
| − |
while (nextshot > get_tick_count()) do |
|
| |
set_backlight(b) |
|
set_backlight(b) |
| − |
sleep(500) |
+ |
battery = (get_vbatt() + (battery*15)) / 16 |
| − |
end |
+ |
if ( battery < v ) then abort=true end |
| − |
|
+ |
if ( is_pressed("menu")) then abort=true end |
| − |
shotcount = shotcount + 1 |
+ |
sleep(100) |
| − |
tic = get_tick_count()-start |
+ |
until ((nextshot < (get_tick_count()+3000) ) or abort) |
| − |
nextshot = nextshot + interval |
+ |
until ( abort ) |
| − |
lens_retract = get_tick_count() + retract |
+ |
|
| − |
log_to_file(string.format("shot:%d %2.2d:%2.2d %d.%2.2dV", shotcount, tic/3600000, (tic%3600000)/60000, battery/1000, (battery%1000)/10)) |
+ |
-- all done - user abort or battery below limit |
| − |
|
+ |
|
| − |
shoot() |
+ |
if( battery < v ) then |
| − |
|
+ |
log_to_file("battery limit reached") |
| − |
sleep(200) |
+ |
else |
| − |
|
+ |
log_to_file("user abort") |
| − |
switch_mode(0) |
+ |
end |
| − |
print( "next shot wait ..", (nextshot-get_tick_count())/1000 ) |
+ |
|
| − |
repeat |
+ |
if ( d==1 ) then |
| − |
if( lens_retract < (get_tick_count()+2000) ) then |
+ |
print("unblanking display") |
| − |
switch_mode(1) |
+ |
count=5 |
| − |
switch_mode(0) |
+ |
repeat |
| − |
lens_retract = get_tick_count() + retract |
+ |
disp = get_prop(props.DISPLAY_MODE) |
| − |
end |
+ |
if ( disp ~= disp_save) then |
| − |
set_backlight(b) |
+ |
click("display") |
| − |
battery = (get_vbatt() + (battery*15)) / 16 |
+ |
sleep(500) |
| − |
if ( battery < v ) then abort=true end |
+ |
end |
| − |
if ( is_pressed("menu")) then abort=true end |
+ |
count=count-1 |
| − |
sleep(100) |
+ |
until ((disp==disp_save) or (count==0)) |
| − |
until ((nextshot < (get_tick_count()+3000) ) or abort) |
+ |
end |
| − |
until ( abort ) |
+ |
restore() |
| − |
|
+ |
|
| − |
-- all done - user abort or battery below limit |
+ |
|
| − |
|
+ |
</syntaxhighlight> |
| − |
if( battery < v ) then |
|
| − |
log_to_file("battery limit reached") |
|
| − |
else |
|
| − |
log_to_file("user abort") |
|
| − |
end |
|
| − |
|
|
| − |
if ( d==1 ) then |
|
| − |
print("unblanking display") |
|
| − |
count=5 |
|
| − |
repeat |
|
| − |
disp = get_prop(props.DISPLAY_MODE) |
|
| − |
if ( disp ~= disp_save) then |
|
| − |
click("display") |
|
| − |
sleep(500) |
|
| − |
end |
|
| − |
count=count-1 |
|
| − |
until ((disp==disp_save) or (count==0)) |
|
| − |
end |
|
| − |
restore() |
|
| − |
<span style="line-height:13.981481552124023px;white-space:pre;"> |
|
| − |
</span> |
|
| |
[[Category:Intervalometer]] |
|
[[Category:Intervalometer]] |
| |
[[Category:Scripts]] |
|
[[Category:Scripts]] |