Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/Tools/CHDK-Scripts/Cannon S100/3DR_EAI_S100.lua
Views: 1799
1--[[23KAP UAV Exposure Control Script v3.24-- Released under GPL by waterwingz and wayback/peabody5http://chdk.wikia.com/wiki/KAP_%26_UAV_Exposure_Control_Script673DR EAI 1.0 is a fork of KAP 3.1 with settings specific to Canon cameras triggered off the Pixhawk autopilot.8Changelog:9-Modified Tv, Av, and ISO settings for the Canon SX26010-Added an option to turn the GPS on and off11-Added control of GPS settings in Main Loop12-Changed USB OneShot mode to listen for 100ms command pulse from Pixhawk13-Adapted for S100 settings1415@title 3DR EAI 1.0 - Lets Map!16@param i Shot Interval (sec)17@default i 218@range i 2 12019@param s Total Shots (0=infinite)20@default s 021@range s 0 1000022@param j Power off when done?23@default j 024@range j 0 125@param e Exposure Comp (stops)26@default e 627@values e -2.0 -1.66 -1.33 -1.0 -0.66 -0.33 0.0 0.33 0.66 1.00 1.33 1.66 2.0028@param d Start Delay Time (sec)29@default d 030@range d 0 1000031@param y Tv Min (sec)32@default y 533@values y None 1/60 1/100 1/200 1/400 1/64034@param t Target Tv (sec)35@default t 736@values t 1/100 1/200 1/400 1/640 1/800 1/1000 1/1250 1/1600 1/200037@param x Tv Max (sec)38@default x 439@values x 1/1000 1/1250 1/1600 1/2000 1/3200 1/5000 1/1000040@param f Av Low(f-stop)41@default f 142@values f 1.8 2.0 2.2 2.6 2.8 3.2 3.5 4.0 4.5 5.0 5.6 6.3 7.1 8.043@param a Av Target (f-stop)44@default a 245@values a 1.8 2.0 2.2 2.6 2.8 3.2 3.5 4.0 4.5 5.0 5.6 6.3 7.1 8.046@param m Av Max (f-stop)47@default m 1348@values m 1.8 2.0 2.2 2.6 2.8 3.2 3.5 4.0 4.5 5.0 5.6 6.3 7.1 8.049@param p ISO Min50@default p 051@values p 80 100 200 400 800 1250 160052@param q ISO Max153@default q 154@values q 100 200 400 800 1250 160055@param r ISO Max256@default r 357@values r 100 200 400 800 1250 160058@param n Allow use of ND filter?59@default n 060@values n No Yes61@param z Zoom position62@default z 063@values z Off 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%64@param c Focus @ Infinity Mode65@default c 366@values c None @Shot AFL MF67@param v Video Interleave (shots)68@default v 069@values v Off 1 5 10 25 50 10070@param w Video Duration (sec)71@default w 1072@range w 5 30073@param u Trigger Type74@default u 275@values u Interval Cont. USB PWM76@param g GPS On77@default g 178@range g 0 179@param b Backlight Off?80@default b 181@range b 0 182@param l Logging83@default l 384@values l Off Screen SDCard Both85--]]8687props=require("propcase")88capmode=require("capmode")8990-- convert user parameter to usable variable names and values91tv_table = { -320, 576, 640, 736, 832, 896, 928, 960, 992, 1024, 1056, 1113, 1180, 1276}92tv96target = tv_table[t+3]93tv96max = tv_table[x+8]94tv96min = tv_table[y+1]95sv_table = { 381, 411, 507, 603, 699, 761, 795 }96sv96min = sv_table[p+1]97sv96max1 = sv_table[q+2]98sv96max2 = sv_table[r+2]99av_table = { 171, 192, 218, 265, 285, 322, 347, 384, 417, 446, 477, 510, 543, 576 }100av96target = av_table[a+1]101av96minimum = av_table[f+1]102av96max = av_table[m+1]103ec96adjust = (e - 6)*32104video_table = { 0, 1, 5, 10, 25, 50, 100 }105video_mode = video_table[v+1]106video_duration = w107interval = i*1000108max_shots = s109poff_if_done = j110start_delay = d111backlight = b112log_mode= l113focus_mode = c114usb_mode = u115gps = g116if ( z==0 ) then zoom_setpoint = nil else zoom_setpoint = (z-1)*10 end117118-- initial configuration values119nd96offset=3*96 -- ND filter's number of equivalent f-stops (f * 96)120infx = 50000 -- focus lock distance in mm (approximately 55 yards)121shot_count = 0 -- shot counter122blite_timer = 300 -- backlight off delay in 100mSec increments123old_console_timeout = get_config_value( 297 )124shot_request = false -- pwm mode flag to request a shot be taken125126-- check camera Av configuration ( variable aperture and/or ND filter )127if n==0 then -- use of nd filter allowed?128if get_nd_present()==1 then -- check for ND filter only129Av_mode = 0 -- 0 = ND disabled and no iris available130else131Av_mode = 1 -- 1 = ND disabled and iris available132end133else134Av_mode = get_nd_present()+1 -- 1 = iris only , 2=ND filter only, 3= both ND & iris135end136137function printf(...)138if ( log_mode == 0) then return end139local str=string.format(...)140if (( log_mode == 1) or (log_mode == 3)) then print(str) end141if ( log_mode > 1 ) then142local logname="A/3DR_EAI_log.log"143log=io.open(logname,"a")144log:write(os.date("%Y%b%d %X ")..string.format(...),"\n")145log:close()146end147end148149tv_ref = { -- note : tv_ref values set 1/2 way between shutter speed values150-608, -560, -528, -496, -464, -432, -400, -368, -336, -304,151-272, -240, -208, -176, -144, -112, -80, -48, -16, 16,15248, 80, 112, 144, 176, 208, 240, 272, 304, 336,153368, 400, 432, 464, 496, 528, 560, 592, 624, 656,154688, 720, 752, 784, 816, 848, 880, 912, 944, 976,1551008, 1040, 1072, 1096, 1129, 1169, 1192, 1225, 1265, 1376 }156157tv_str = {158">64",159"64", "50", "40", "32", "25", "20", "16", "12", "10", "8.0",160"6.0", "5.0", "4.0", "3.2", "2.5", "2.0", "1.6", "1.3", "1.0", "0.8",161"0.6", "0.5", "0.4", "0.3", "1/4", "1/5", "1/6", "1/8", "1/10", "1/13",162"1/15", "1/20", "1/25", "1/30", "1/40", "1/50", "1/60", "1/80", "1/100", "1/125",163"1/160", "1/200", "1/250", "1/320", "1/400", "1/500", "1/640", "1/800", "1/1000","1/1250",164"1/1600","1/2000","1/2500","1/3200","1/4000","1/5000","1/6400","1/8000","1/10000","hi" }165166function print_tv(val)167if ( val == nil ) then return("-") end168local i = 1169while (i <= #tv_ref) and (val > tv_ref[i]) do i=i+1 end170return tv_str[i]171end172173av_ref = { 160, 176, 208, 243, 275, 304, 336, 368, 400, 432, 464, 480, 496, 512, 544, 592, 624, 656, 688, 720, 752, 784 }174av_str = {"n/a","1.8", "2.0","2.2","2.6","2.8","3.2","3.5","4.0","4.5","5.0","5.6","5.9","6.3","7.1","8.0","9.0","10.0","11.0","13.0","14.0","16.0","hi"}175176function print_av(val)177if ( val == nil ) then return("-") end178local i = 1179while (i <= #av_ref) and (val > av_ref[i]) do i=i+1 end180return av_str[i]181end182183sv_ref = { 370, 397, 424, 456, 492, 523, 555, 588, 619, 651, 684, 731, 779, 843, 907 }184sv_str = {"n/a","80","100","120","160","200","250","320","400","500","640","800","1250","1600","3200","hi"}185186function print_sv(val)187if ( val == nil ) then return("-") end188local i = 1189while (i <= #sv_ref) and (val > sv_ref[i]) do i=i+1 end190return sv_str[i]191end192193function pline(message, line) -- print line function194fg = 258 bg=259195196end197198-- switch between shooting and playback modes199function switch_mode( m )200if ( m == 1 ) then201if ( get_mode() == false ) then202set_record(1) -- switch to shooting mode203while ( get_mode() == false ) do204sleep(100)205end206sleep(1000)207end208else209if ( get_mode() == true ) then210set_record(0) -- switch to playback mode211while ( get_mode() == true ) do212sleep(100)213end214sleep(1000)215end216end217end218219-- focus lock and unlock220function lock_focus()221if (focus_mode > 1) then -- focus mode requested ?222if ( focus_mode == 2 ) then -- method 1 : set_aflock() command enables MF223if (chdk_version==120) then224set_aflock(1)225set_prop(props.AF_LOCK,1)226else227set_aflock(1)228end229if (get_prop(props.AF_LOCK) == 1) then printf(" AFL enabled") else printf(" AFL failed ***") end230else -- mf mode requested231if (chdk_version==120) then -- CHDK 1.2.0 : call event proc or levents to try and enable MF mode232if call_event_proc("SS.Create") ~= -1 then233if call_event_proc("SS.MFOn") == -1 then234call_event_proc("PT_MFOn")235end236elseif call_event_proc("RegisterShootSeqEvent") ~= -1 then237if call_event_proc("PT_MFOn") == -1 then238call_event_proc("MFOn")239end240end241if (get_prop(props.FOCUS_MODE) == 0 ) then -- MF not set - try levent PressSw1AndMF242post_levent_for_npt("PressSw1AndMF")243sleep(500)244end245elseif (chdk_version >= 130) then -- CHDK 1.3.0 : set_mf()246if ( set_mf(1) == 0 ) then set_aflock(1) end -- as a fall back, try setting AFL is set_mf fails247end248if (get_prop(props.FOCUS_MODE) == 1) then printf(" MF enabled") else printf(" MF enable failed ***") end249end250sleep(1000)251set_focus(infx)252sleep(1000)253end254end255256function unlock_focus()257if (focus_mode > 1) then -- focus mode requested ?258if (focus_mode == 2 ) then -- method 1 : AFL259if (chdk_version==120) then260set_aflock(0)261set_prop(props.AF_LOCK,0)262else263set_aflock(0)264end265if (get_prop(props.AF_LOCK) == 0) then printf(" AFL unlocked") else printf(" AFL unlock failed") end266else -- mf mode requested267if (chdk_version==120) then -- CHDK 1.2.0 : call event proc or levents to try and enable MF mode268if call_event_proc("SS.Create") ~= -1 then269if call_event_proc("SS.MFOff") == -1 then270call_event_proc("PT_MFOff")271end272elseif call_event_proc("RegisterShootSeqEvent") ~= -1 then273if call_event_proc("PT_MFOff") == -1 then274call_event_proc("MFOff")275end276end277if (get_prop(props.FOCUS_MODE) == 1 ) then -- MF not reset - try levent PressSw1AndMF278post_levent_for_npt("PressSw1AndMF")279sleep(500)280end281elseif (chdk_version >= 130) then -- CHDK 1.3.0 : set_mf()282if ( set_mf(0) == 0 ) then set_aflock(0) end -- fall back so reset AFL is set_mf fails283end284if (get_prop(props.FOCUS_MODE) == 0) then printf(" MF disabled") else printf(" MF disable failed") end285end286sleep(100)287end288end289290-- zoom position291function update_zoom(zpos)292local count = 0293if(zpos ~= nil) then294zstep=((get_zoom_steps()-1)*zpos)/100295printf("setting zoom to "..zpos.." percent step="..zstep)296sleep(200)297set_zoom(zstep)298sleep(2000)299press("shoot_half")300repeat301sleep(100)302count = count + 1303until (get_shooting() == true ) or (count > 40 )304release("shoot_half")305end306end307308-- restore camera settings on shutdown309function restore()310set_config_value(121,0) -- USB remote disable311set_config_value(297,old_console_timeout) -- restore console timeout value312if (backlight==1) then set_lcd_display(1) end -- display on313unlock_focus()314if( zoom_setpoint ~= nil ) then update_zoom(0) end315if( shot_count >= max_shots) and ( max_shots > 1) then316if ( poff_if_done == 1 ) then -- did script ending because # of shots done ?317printf("power off - shot count at limit") -- complete power down318sleep(2000)319post_levent_to_ui('PressPowerButton')320else321set_record(0) end -- just retract lens322end323end324325-- Video mode326function check_video(shot)327local capture_mode328if ((video_mode>0) and(shot>0) and (shot%video_mode == 0)) then329unlock_focus()330printf("Video mode started. Button:"..tostring(video_button))331if( video_button ) then332click "video"333else334capture_mode=capmode.get()335capmode.set('VIDEO_STD')336press("shoot_full")337sleep(300)338release("shoot_full")339end340local end_second = get_day_seconds() + video_duration341repeat342wait_click(500)343until (is_key("menu")) or (get_day_seconds() > end_second)344if( video_button ) then345click "video"346else347press("shoot_full")348sleep(300)349release("shoot_full")350capmode.set(capture_mode)351end352printf("Video mode finished.")353sleep(1000)354lock_focus()355return(true)356else357return(false)358end359end360361-- PWM USB pulse functions362363function ch1up()364printf(" * usb pulse = ch1up")365shot_request = true366end367368function ch1mid()369printf(" * usb pulse = ch1mid")370if ( get_mode() == false ) then371switch_mode(1)372lock_focus()373end374end375376function ch1down()377printf(" * usb pulse = ch1down")378switch_mode(0)379end380381function ch2up()382printf(" * usb pulse = ch2up")383update_zoom(100)384end385386function ch2mid()387printf(" * usb pulse = ch2mid")388if ( zoom_setpoint ~= nil ) then update_zoom(zoom_setpoint) else update_zoom(50) end389end390391function ch2down()392printf(" * usb pulse = ch2down")393update_zoom(0)394end395396function pwm_mode(pulse_width)397if pulse_width > 0 then398if pulse_width < 5 then ch1up()399elseif pulse_width < 8 then ch1mid()400elseif pulse_width < 11 then ch1down()401elseif pulse_width < 14 then ch2up()402elseif pulse_width < 17 then ch2mid()403elseif pulse_width < 20 then ch2down()404else printf(" * usb pulse width error") end405end406end407408-- Basic exposure calculation using shutter speed and ISO only409-- called for Tv-only and ND-only cameras (cameras without an iris)410function basic_tv_calc()411tv96setpoint = tv96target412av96setpoint = nil413local min_av = get_prop(props.MIN_AV)414-- calculate required ISO setting415sv96setpoint = tv96setpoint + min_av - bv96meter416-- low ambient light ?417if (sv96setpoint > sv96max2 ) then -- check if required ISO setting is too high418sv96setpoint = sv96max2 -- clamp at max2 ISO if so419tv96setpoint = math.max(bv96meter+sv96setpoint-min_av,tv96min) -- recalculate required shutter speed down to Tv min420-- high ambient light ?421elseif (sv96setpoint < sv96min ) then -- check if required ISO setting is too low422sv96setpoint = sv96min -- clamp at minimum ISO setting if so423tv96setpoint = bv96meter + sv96setpoint - min_av -- recalculate required shutter speed and hope for the best424end425end426427428-- Basic exposure calculation using shutter speed, iris and ISO429-- called for iris-only and "both" cameras (cameras with an iris & ND filter)430function basic_iris_calc()431tv96setpoint = tv96target432av96setpoint = av96target433-- calculate required ISO setting434sv96setpoint = tv96setpoint + av96setpoint - bv96meter435-- low ambient light ?436if (sv96setpoint > sv96max1 ) then -- check if required ISO setting is too high437sv96setpoint = sv96max1 -- clamp at first ISO limit438av96setpoint = bv96meter + sv96setpoint - tv96setpoint -- calculate new aperture setting439if ( av96setpoint < av96min ) then -- check if new setting is goes below lowest f-stop440av96setpoint = av96min -- clamp at lowest f-stop441sv96setpoint = tv96setpoint + av96setpoint - bv96meter -- recalculate ISO setting442if (sv96setpoint > sv96max2 ) then -- check if the result is above max2 ISO443sv96setpoint = sv96max2 -- clamp at highest ISO setting if so444tv96setpoint = math.max(bv96meter+sv96setpoint-av96setpoint,tv96min) -- recalculate required shutter speed down to tv minimum445end446end447-- high ambient light ?448elseif (sv96setpoint < sv96min ) then -- check if required ISO setting is too low449sv96setpoint = sv96min -- clamp at minimum ISO setting if so450tv96setpoint = bv96meter + sv96setpoint - av96setpoint -- recalculate required shutter speed451if (tv96setpoint > tv96max ) then -- check if shutter speed now too fast452tv96setpoint = tv96max -- clamp at maximum shutter speed if so453av96setpoint = bv96meter + sv96setpoint - tv96setpoint -- calculate new aperture setting454if ( av96setpoint > av96max ) then -- check if new setting is goes above highest f-stop455av96setpoint = av96max -- clamp at highest f-stop456tv96setpoint = bv96meter + sv96setpoint - av96setpoint -- recalculate shutter speed needed and hope for the best457end458end459end460end461462-- calculate exposure for cams without adjustable iris or ND filter463function exposure_Tv_only()464insert_ND_filter = nil465basic_tv_calc()466end467468-- calculate exposure for cams with ND filter only469function exposure_NDfilter()470insert_ND_filter = false471basic_tv_calc()472if (tv96setpoint > tv96max ) then -- check if shutter speed now too fast473insert_ND_filter = true -- flag the ND filter to be inserted474bv96meter = bv96meter - nd96offset -- adjust meter for ND offset475basic_tv_calc() -- start over, but with new meter value476bv96meter = bv96meter + nd96offset -- restore meter for later logging477end478end479480-- calculate exposure for cams with adjustable iris only481function exposure_iris()482insert_ND_filter = nil483basic_iris_calc()484end485486-- calculate exposure for cams with both adjustable iris and ND filter487function exposure_both()488insert_ND_filter = false -- NOTE : assume ND filter never used automatically by Canon firmware489basic_iris_calc()490if (tv96setpoint > tv96max ) then -- check if shutter speed now too fast491insert_ND_filter = true -- flag the ND filter to be inserted492bv96meter = bv96meter - nd96offset -- adjust meter for ND offset493basic_iris_calc() -- start over, but with new meter value494bv96meter = bv96meter + nd96offset -- restore meter for later logging495end496end497498-- ========================== Main Program =================================499500set_console_layout(1 ,1, 45, 14 )501502--printf("KAP 3.1 started - press MENU to exit")503printf("3DR EAI 1.0 Canon SX260 - Lets Map!")504printf("Based On KAP 3.1")505printf("Press the shutter button to pause")506bi=get_buildinfo()507printf("%s %s-%s %s %s %s", bi.version, bi.build_number, bi.build_revision, bi.platform, bi.platsub, bi.build_date)508chdk_version= tonumber(string.sub(bi.build_number,1,1))*100 + tonumber(string.sub(bi.build_number,3,3))*10 + tonumber(string.sub(bi.build_number,5,5))509if ( tonumber(bi.build_revision) > 0 ) then510build = tonumber(bi.build_revision)511else512build = tonumber(string.match(bi.build_number,'-(%d+)$'))513end514515if ((chdk_version<120) or ((chdk_version==120)and(build<3276)) or ((chdk_version==130)and(build<3383))) then516printf("CHDK 1.2.0 build 3276 or higher required")517else518if( props.CONTINUOUS_AF == nil ) then caf=-999 else caf = get_prop(props.CONTINUOUS_AF) end519if( props.SERVO_AF == nil ) then saf=-999 else saf = get_prop(props.SERVO_AF) end520cmode = capmode.get_name()521printf("Mode:%s,Continuous_AF:%d,Servo_AF:%d", cmode,caf,saf)522printf(" Tv:"..print_tv(tv96target).." max:"..print_tv(tv96max).." min:"..print_tv(tv96min).." ecomp:"..(ec96adjust/96).."."..(math.abs(ec96adjust*10/96)%10) )523printf(" Av:"..print_av(av96target).." minAv:"..print_av(av96minimum).." maxAv:"..print_av(av96max) )524printf(" ISOmin:"..print_sv(sv96min).." ISO1:"..print_sv(sv96max1).." ISO2:"..print_sv(sv96max2) )525printf(" MF mode:"..focus_mode.." Video:"..video_mode.." USB:"..usb_mode)526printf(" AvM:"..Av_mode.." int:"..(interval/1000).." Shts:"..max_shots.." Dly:"..start_delay.." B/L:"..backlight)527sleep(500)528529if (start_delay > 0 ) then530printf("entering start delay of ".. start_delay.." seconds")531sleep( start_delay*1000 )532end533534-- CAMERA CONFIGURATION -535-- FIND config table here http://subversion.assembla.com/svn/chdk/trunk/core/conf.c536set_config_value(2,0) --Save raw: off537if (gps==1) then538set_config_value(282,1) --turn GPS on539--set_config_value(278,1) --show GPS symbol540set_config_value(261,1) --wait for signal time541set_config_value(266,5) --battery shutdown percentage542end543544-- enable USB remote in USB remote moded545if (usb_mode > 0 ) then546set_config_value(121,1) -- make sure USB remote is enabled547if (get_usb_power(1) == 0) then -- can we start ?548printf("waiting on USB signal")549repeat wait_click(20) until ((get_usb_power(1) == 1) or ( is_key("menu")))550--changed sleep from 1000 to 500551else sleep(500) end552printf("USB signal received")553end554555-- switch to shooting mode556switch_mode(1)557558-- set zoom position559update_zoom(zoom_setpoint)560-- lock focus at infinity561lock_focus()562-- disable flash and AF assist lamp563set_prop(props.FLASH_MODE, 2) -- flash off564set_prop(props.AF_ASSIST_BEAM,0) -- AF assist off if supported for this camera565set_config_value( 297, 60) -- set console timeout to 60 seconds566567if (usb_mode > 2 ) then repeat until (get_usb_power(2) == 0 ) end -- flush pulse buffer568next_shot_time = get_tick_count()569script_exit = false570if( get_video_button() == 1) then video_button = true else video_button = false end571set_console_layout(2 ,0, 45, 4 )572repeat573--BB: Set get_usb_power(2) > 7 for a 70/100s pulse574--BB: Could consider a max threshold to prevent erroneous trigger events575--eg. get_usb_power(2) > 7 && get_usb_power(2) < 13576if( ( (usb_mode < 2 ) and ( next_shot_time <= get_tick_count() ) )577or ( (usb_mode == 2 ) and (get_usb_power(2) > 7 ) )578or ( (usb_mode == 3 ) and (shot_request == true ) ) ) then579580-- time to insert a video sequence ?581if( check_video(shot_count) == true) then next_shot_time = get_tick_count() end582583-- intervalometer timing584next_shot_time = next_shot_time + interval585586-- set focus at infinity ? (maybe redundant for AFL & MF mode but makes sure it's set right)587if (focus_mode > 0) then588set_focus(infx)589sleep(100)590end591592-- check exposure593local count = 0594local timeout = false595press("shoot_half")596repeat597sleep(50)598count = count + 1599if (count > 40 ) then timeout = true end600until (get_shooting() == true ) or (timeout == true)601602-- shoot in auto mode if meter reading invalid, else calculate new desired exposure603if ( timeout == true ) then604release("shoot_half")605repeat sleep(50) until get_shooting() == false606shoot() -- shoot in Canon auto mode if we don't have a valid meter reading607shot_count = shot_count + 1608printf(string.format('IMG_%04d.JPG',get_exp_count()).." : shot in auto mode, meter reading invalid")609else610-- get meter reading values (and add in exposure compensation)611bv96raw=get_bv96()612bv96meter=bv96raw-ec96adjust613tv96meter=get_tv96()614av96meter=get_av96()615sv96meter=get_sv96()616617-- set minimum Av to larger of user input or current min for zoom setting618av96min= math.max(av96minimum,get_prop(props.MIN_AV))619if (av96target < av96min) then av96target = av96min end620621-- calculate required setting for current ambient light conditions622if (Av_mode == 1) then exposure_iris()623elseif (Av_mode == 2) then exposure_NDfilter()624elseif (Av_mode == 3) then exposure_both()625else exposure_Tv_only()626end627628-- set up all exposure overrides629set_tv96_direct(tv96setpoint)630set_sv96(sv96setpoint)631if( av96setpoint ~= nil) then set_av96_direct(av96setpoint) end632633if(Av_mode > 1) and (insert_ND_filter == true) then -- ND filter available and needed?634set_nd_filter(1) -- activate the ND filter635nd_string="NDin"636else637set_nd_filter(2) -- make sure the ND filter does not activate638nd_string="NDout"639end640641-- and finally shoot the image642press("shoot_full_only")643sleep(100)644release("shoot_full")645repeat sleep(50) until get_shooting() == false646shot_count = shot_count + 1647648-- update shooting statistic and log as required649shot_focus=get_focus()650if(shot_focus ~= -1) and (shot_focus < 20000) then651focus_string=" foc:"..(shot_focus/1000).."."..(((shot_focus%1000)+50)/100).."m"652if(focus_mode>0) then653error_string=" **WARNING : focus not at infinity**"654end655else656focus_string=" foc:infinity"657error_string=nil658end659printf(string.format('%d) IMG_%04d.JPG',shot_count,get_exp_count()))660printf(" meter : Tv:".. print_tv(tv96meter) .." Av:".. print_av(av96meter) .." Sv:"..print_sv(sv96meter).." "..bv96raw ..":"..bv96meter)661printf(" actual: Tv:".. print_tv(tv96setpoint).." Av:".. print_av(av96setpoint).." Sv:"..print_sv(sv96setpoint))662printf(" AvMin:".. print_av(av96min).." NDF:"..nd_string..focus_string )663664if ((max_shots>0) and (shot_count >= max_shots)) then script_exit = true end665666shot_request = false -- reset shot request flag667668end669collectgarbage()670end671672-- check if USB remote enabled in intervalometer mode and USB power is off -> pause if so673if ((usb_mode == 1 ) and (get_usb_power(1) == 0)) then674printf("waiting on USB signal")675unlock_focus()676switch_mode(0)677repeat wait_click(20) until ((get_usb_power(1) == 1) or ( is_key("menu")))678switch_mode(1)679lock_focus()680if ( is_key("menu")) then script_exit = true end681printf("USB wait finished")682sleep(100)683end684685if (usb_mode == 3 ) then pwm_mode(get_usb_power(2)) end686687if (blite_timer > 0) then688blite_timer = blite_timer-1689if ((blite_timer==0) and (backlight==1)) then set_lcd_display(0) end690end691692if( error_string ~= nil) then693draw_string( 16, 144, string.sub(error_string.." ",0,42), 258, 259)694end695696wait_click(100)697698if( not( is_key("no_key"))) then699if ((blite_timer==0) and (backlight==1)) then set_lcd_display(1) end700blite_timer=300701if ( is_key("menu") ) then script_exit = true end702end703704until (script_exit==true)705printf("script halt requested")706restore()707end708709--[[ end of file ]]--710711712713714