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/kap_uav.lua
Views: 1798
--[[12KAP UAV Exposure Control Script v3.13-- Released under GPL by waterwingz and wayback/peabody4http://chdk.wikia.com/wiki/KAP_%26_UAV_Exposure_Control_Script56@title KAP UAV 3.17@param i Shot Interval (sec)8@default i 159@range i 2 12010@param s Total Shots (0=infinite)11@default s 012@range s 0 1000013@param j Power off when done?14@default j 015@range j 0 116@param e Exposure Comp (stops)17@default e 618@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.0019@param d Start Delay Time (sec)20@default d 021@range d 0 1000022@param y Tv Min (sec)23@default y 024@values y None 1/60 1/100 1/200 1/400 1/64025@param t Target Tv (sec)26@default t 527@values t 1/100 1/200 1/400 1/640 1/800 1/1000 1/1250 1/1600 1/200028@param x Tv Max (sec)29@default x 330@values x 1/1000 1/1250 1/1600 1/2000 1/5000 1/1000031@param f Av Low(f-stop)32@default f 433@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.034@param a Av Target (f-stop)35@default a 736@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.037@param m Av Max (f-stop)38@default m 1339@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.040@param p ISO Min41@default p 142@values p 80 100 200 400 800 1250 160043@param q ISO Max144@default q 245@values q 100 200 400 800 1250 160046@param r ISO Max247@default r 348@values r 100 200 400 800 1250 160049@param n Allow use of ND filter?50@default n 151@values n No Yes52@param z Zoom position53@default z 054@values z Off 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%55@param c Focus @ Infinity Mode56@default c 057@values c None @Shot AFL MF58@param v Video Interleave (shots)59@default v 060@values v Off 1 5 10 25 50 10061@param w Video Duration (sec)62@default w 1063@range w 5 30064@param u USB Shot Control?65@default u 066@values u None On/Off OneShot PWM67@param b Backlight Off?68@default b 069@range b 0 170@param l Logging71@default l 372@values l Off Screen SDCard Both73--]]7475props=require("propcase")76capmode=require("capmode")7778-- convert user parameter to usable variable names and values79tv_table = { -320, 576, 640, 736, 832, 896, 928, 960, 992, 1024, 1056, 1180, 1276}80tv96target = tv_table[t+3]81tv96max = tv_table[x+8]82tv96min = tv_table[y+1]83sv_table = { 381, 411, 507, 603, 699, 761, 795 }84sv96min = sv_table[p+1]85sv96max1 = sv_table[q+2]86sv96max2 = sv_table[r+2]87av_table = { 171, 192, 218, 265, 285, 322, 347, 384, 417, 446, 477, 510, 543, 576 }88av96target = av_table[a+1]89av96minimum = av_table[f+1]90av96max = av_table[m+1]91ec96adjust = (e - 6)*3292video_table = { 0, 1, 5, 10, 25, 50, 100 }93video_mode = video_table[v+1]94video_duration = w95interval = i*100096max_shots = s97poff_if_done = j98start_delay = d99backlight = b100log_mode= l101focus_mode = c102usb_mode = u103if ( z==0 ) then zoom_setpoint = nil else zoom_setpoint = (z-1)*10 end104105-- initial configuration values106nd96offset=3*96 -- ND filter's number of equivalent f-stops (f * 96)107infx = 50000 -- focus lock distance in mm (approximately 55 yards)108shot_count = 0 -- shot counter109blite_timer = 300 -- backlight off delay in 100mSec increments110old_console_timeout = get_config_value( 297 )111shot_request = false -- pwm mode flag to request a shot be taken112113-- check camera Av configuration ( variable aperture and/or ND filter )114if n==0 then -- use of nd filter allowed?115if get_nd_present()==1 then -- check for ND filter only116Av_mode = 0 -- 0 = ND disabled and no iris available117else118Av_mode = 1 -- 1 = ND disabled and iris available119end120else121Av_mode = get_nd_present()+1 -- 1 = iris only , 2=ND filter only, 3= both ND & iris122end123124function printf(...)125if ( log_mode == 0) then return end126local str=string.format(...)127if (( log_mode == 1) or (log_mode == 3)) then print(str) end128if ( log_mode > 1 ) then129local logname="A/KAP.log"130log=io.open(logname,"a")131log:write(os.date("%Y%b%d %X ")..string.format(...),"\n")132log:close()133end134end135136tv_ref = { -- note : tv_ref values set 1/2 way between shutter speed values137-608, -560, -528, -496, -464, -432, -400, -368, -336, -304,138-272, -240, -208, -176, -144, -112, -80, -48, -16, 16,13948, 80, 112, 144, 176, 208, 240, 272, 304, 336,140368, 400, 432, 464, 496, 528, 560, 592, 624, 656,141688, 720, 752, 784, 816, 848, 880, 912, 944, 976,1421008, 1040, 1072, 1096, 1129, 1169, 1192, 1225, 1265, 1376 }143144tv_str = {145">64",146"64", "50", "40", "32", "25", "20", "16", "12", "10", "8.0",147"6.0", "5.0", "4.0", "3.2", "2.5", "2.0", "1.6", "1.3", "1.0", "0.8",148"0.6", "0.5", "0.4", "0.3", "1/4", "1/5", "1/6", "1/8", "1/10", "1/13",149"1/15", "1/20", "1/25", "1/30", "1/40", "1/50", "1/60", "1/80", "1/100", "1/125",150"1/160", "1/200", "1/250", "1/320", "1/400", "1/500", "1/640", "1/800", "1/1000","1/1250",151"1/1600","1/2000","1/2500","1/3200","1/4000","1/5000","1/6400","1/8000","1/10000","hi" }152153function print_tv(val)154if ( val == nil ) then return("-") end155local i = 1156while (i <= #tv_ref) and (val > tv_ref[i]) do i=i+1 end157return tv_str[i]158end159160av_ref = { 160, 176, 208, 243, 275, 304, 336, 368, 400, 432, 464, 480, 496, 512, 544, 592, 624, 656, 688, 720, 752, 784 }161av_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"}162163function print_av(val)164if ( val == nil ) then return("-") end165local i = 1166while (i <= #av_ref) and (val > av_ref[i]) do i=i+1 end167return av_str[i]168end169170sv_ref = { 370, 397, 424, 456, 492, 523, 555, 588, 619, 651, 684, 731, 779, 843, 907 }171sv_str = {"n/a","80","100","120","160","200","250","320","400","500","640","800","1250","1600","3200","hi"}172173function print_sv(val)174if ( val == nil ) then return("-") end175local i = 1176while (i <= #sv_ref) and (val > sv_ref[i]) do i=i+1 end177return sv_str[i]178end179180function pline(message, line) -- print line function181fg = 258 bg=259182183end184185-- switch between shooting and playback modes186function switch_mode( m )187if ( m == 1 ) then188if ( get_mode() == false ) then189set_record(1) -- switch to shooting mode190while ( get_mode() == false ) do191sleep(100)192end193sleep(1000)194end195else196if ( get_mode() == true ) then197set_record(0) -- switch to playback mode198while ( get_mode() == true ) do199sleep(100)200end201sleep(1000)202end203end204end205206-- focus lock and unlock207function lock_focus()208if (focus_mode > 1) then -- focus mode requested ?209if ( focus_mode == 2 ) then -- method 1 : set_aflock() command enables MF210if (chdk_version==120) then211set_aflock(1)212set_prop(props.AF_LOCK,1)213else214set_aflock(1)215end216if (get_prop(props.AF_LOCK) == 1) then printf(" AFL enabled") else printf(" AFL failed ***") end217else -- mf mode requested218if (chdk_version==120) then -- CHDK 1.2.0 : call event proc or levents to try and enable MF mode219if call_event_proc("SS.Create") ~= -1 then220if call_event_proc("SS.MFOn") == -1 then221call_event_proc("PT_MFOn")222end223elseif call_event_proc("RegisterShootSeqEvent") ~= -1 then224if call_event_proc("PT_MFOn") == -1 then225call_event_proc("MFOn")226end227end228if (get_prop(props.FOCUS_MODE) == 0 ) then -- MF not set - try levent PressSw1AndMF229post_levent_for_npt("PressSw1AndMF")230sleep(500)231end232elseif (chdk_version >= 130) then -- CHDK 1.3.0 : set_mf()233if ( set_mf(1) == 0 ) then set_aflock(1) end -- as a fall back, try setting AFL is set_mf fails234end235if (get_prop(props.FOCUS_MODE) == 1) then printf(" MF enabled") else printf(" MF enable failed ***") end236end237sleep(1000)238set_focus(infx)239sleep(1000)240end241end242243function unlock_focus()244if (focus_mode > 1) then -- focus mode requested ?245if (focus_mode == 2 ) then -- method 1 : AFL246if (chdk_version==120) then247set_aflock(0)248set_prop(props.AF_LOCK,0)249else250set_aflock(0)251end252if (get_prop(props.AF_LOCK) == 0) then printf(" AFL unlocked") else printf(" AFL unlock failed") end253else -- mf mode requested254if (chdk_version==120) then -- CHDK 1.2.0 : call event proc or levents to try and enable MF mode255if call_event_proc("SS.Create") ~= -1 then256if call_event_proc("SS.MFOff") == -1 then257call_event_proc("PT_MFOff")258end259elseif call_event_proc("RegisterShootSeqEvent") ~= -1 then260if call_event_proc("PT_MFOff") == -1 then261call_event_proc("MFOff")262end263end264if (get_prop(props.FOCUS_MODE) == 1 ) then -- MF not reset - try levent PressSw1AndMF265post_levent_for_npt("PressSw1AndMF")266sleep(500)267end268elseif (chdk_version >= 130) then -- CHDK 1.3.0 : set_mf()269if ( set_mf(0) == 0 ) then set_aflock(0) end -- fall back so reset AFL is set_mf fails270end271if (get_prop(props.FOCUS_MODE) == 0) then printf(" MF disabled") else printf(" MF disable failed") end272end273sleep(100)274end275end276277-- zoom position278function update_zoom(zpos)279local count = 0280if(zpos ~= nil) then281zstep=((get_zoom_steps()-1)*zpos)/100282printf("setting zoom to "..zpos.." percent step="..zstep)283sleep(200)284set_zoom(zstep)285sleep(2000)286press("shoot_half")287repeat288sleep(100)289count = count + 1290until (get_shooting() == true ) or (count > 40 )291release("shoot_half")292end293end294295-- restore camera settings on shutdown296function restore()297set_config_value(121,0) -- USB remote disable298set_config_value(297,old_console_timeout) -- restore console timeout value299if (backlight==1) then set_lcd_display(1) end -- display on300unlock_focus()301if( zoom_setpoint ~= nil ) then update_zoom(0) end302if( shot_count >= max_shots) and ( max_shots > 1) then303if ( poff_if_done == 1 ) then -- did script ending because # of shots done ?304printf("power off - shot count at limit") -- complete power down305sleep(2000)306post_levent_to_ui('PressPowerButton')307else308set_record(0) end -- just retract lens309end310end311312-- Video mode313function check_video(shot)314local capture_mode315if ((video_mode>0) and(shot>0) and (shot%video_mode == 0)) then316unlock_focus()317printf("Video mode started. Button:"..tostring(video_button))318if( video_button ) then319click "video"320else321capture_mode=capmode.get()322capmode.set('VIDEO_STD')323press("shoot_full")324sleep(300)325release("shoot_full")326end327local end_second = get_day_seconds() + video_duration328repeat329wait_click(500)330until (is_key("menu")) or (get_day_seconds() > end_second)331if( video_button ) then332click "video"333else334press("shoot_full")335sleep(300)336release("shoot_full")337capmode.set(capture_mode)338end339printf("Video mode finished.")340sleep(1000)341lock_focus()342return(true)343else344return(false)345end346end347348-- PWM USB pulse functions349350function ch1up()351printf(" * usb pulse = ch1up")352shot_request = true353end354355function ch1mid()356printf(" * usb pulse = ch1mid")357if ( get_mode() == false ) then358switch_mode(1)359lock_focus()360end361end362363function ch1down()364printf(" * usb pulse = ch1down")365switch_mode(0)366end367368function ch2up()369printf(" * usb pulse = ch2up")370update_zoom(100)371end372373function ch2mid()374printf(" * usb pulse = ch2mid")375if ( zoom_setpoint ~= nil ) then update_zoom(zoom_setpoint) else update_zoom(50) end376end377378function ch2down()379printf(" * usb pulse = ch2down")380update_zoom(0)381end382383function pwm_mode(pulse_width)384if pulse_width > 0 then385if pulse_width < 5 then ch1up()386elseif pulse_width < 8 then ch1mid()387elseif pulse_width < 11 then ch1down()388elseif pulse_width < 14 then ch2up()389elseif pulse_width < 17 then ch2mid()390elseif pulse_width < 20 then ch2down()391else printf(" * usb pulse width error") end392end393end394395-- Basic exposure calculation using shutter speed and ISO only396-- called for Tv-only and ND-only cameras (cameras without an iris)397function basic_tv_calc()398tv96setpoint = tv96target399av96setpoint = nil400local min_av = get_prop(props.MIN_AV)401-- calculate required ISO setting402sv96setpoint = tv96setpoint + min_av - bv96meter403-- low ambient light ?404if (sv96setpoint > sv96max2 ) then -- check if required ISO setting is too high405sv96setpoint = sv96max2 -- clamp at max2 ISO if so406tv96setpoint = math.max(bv96meter+sv96setpoint-min_av,tv96min) -- recalculate required shutter speed down to Tv min407-- high ambient light ?408elseif (sv96setpoint < sv96min ) then -- check if required ISO setting is too low409sv96setpoint = sv96min -- clamp at minimum ISO setting if so410tv96setpoint = bv96meter + sv96setpoint - min_av -- recalculate required shutter speed and hope for the best411end412end413414415-- Basic exposure calculation using shutter speed, iris and ISO416-- called for iris-only and "both" cameras (cameras with an iris & ND filter)417function basic_iris_calc()418tv96setpoint = tv96target419av96setpoint = av96target420-- calculate required ISO setting421sv96setpoint = tv96setpoint + av96setpoint - bv96meter422-- low ambient light ?423if (sv96setpoint > sv96max1 ) then -- check if required ISO setting is too high424sv96setpoint = sv96max1 -- clamp at first ISO limit425av96setpoint = bv96meter + sv96setpoint - tv96setpoint -- calculate new aperture setting426if ( av96setpoint < av96min ) then -- check if new setting is goes below lowest f-stop427av96setpoint = av96min -- clamp at lowest f-stop428sv96setpoint = tv96setpoint + av96setpoint - bv96meter -- recalculate ISO setting429if (sv96setpoint > sv96max2 ) then -- check if the result is above max2 ISO430sv96setpoint = sv96max2 -- clamp at highest ISO setting if so431tv96setpoint = math.max(bv96meter+sv96setpoint-av96setpoint,tv96min) -- recalculate required shutter speed down to tv minimum432end433end434-- high ambient light ?435elseif (sv96setpoint < sv96min ) then -- check if required ISO setting is too low436sv96setpoint = sv96min -- clamp at minimum ISO setting if so437tv96setpoint = bv96meter + sv96setpoint - av96setpoint -- recalculate required shutter speed438if (tv96setpoint > tv96max ) then -- check if shutter speed now too fast439tv96setpoint = tv96max -- clamp at maximum shutter speed if so440av96setpoint = bv96meter + sv96setpoint - tv96setpoint -- calculate new aperture setting441if ( av96setpoint > av96max ) then -- check if new setting is goes above highest f-stop442av96setpoint = av96max -- clamp at highest f-stop443tv96setpoint = bv96meter + sv96setpoint - av96setpoint -- recalculate shutter speed needed and hope for the best444end445end446end447end448449-- calculate exposure for cams without adjustable iris or ND filter450function exposure_Tv_only()451insert_ND_filter = nil452basic_tv_calc()453end454455-- calculate exposure for cams with ND filter only456function exposure_NDfilter()457insert_ND_filter = false458basic_tv_calc()459if (tv96setpoint > tv96max ) then -- check if shutter speed now too fast460insert_ND_filter = true -- flag the ND filter to be inserted461bv96meter = bv96meter - nd96offset -- adjust meter for ND offset462basic_tv_calc() -- start over, but with new meter value463bv96meter = bv96meter + nd96offset -- restore meter for later logging464end465end466467-- calculate exposure for cams with adjustable iris only468function exposure_iris()469insert_ND_filter = nil470basic_iris_calc()471end472473-- calculate exposure for cams with both adjustable iris and ND filter474function exposure_both()475insert_ND_filter = false -- NOTE : assume ND filter never used automatically by Canon firmware476basic_iris_calc()477if (tv96setpoint > tv96max ) then -- check if shutter speed now too fast478insert_ND_filter = true -- flag the ND filter to be inserted479bv96meter = bv96meter - nd96offset -- adjust meter for ND offset480basic_iris_calc() -- start over, but with new meter value481bv96meter = bv96meter + nd96offset -- restore meter for later logging482end483end484485-- ========================== Main Program =================================486487set_console_layout(1 ,1, 45, 14 )488489printf("KAP 3.1 started - press MENU to exit")490bi=get_buildinfo()491printf("%s %s-%s %s %s %s", bi.version, bi.build_number, bi.build_revision, bi.platform, bi.platsub, bi.build_date)492chdk_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))493if ( tonumber(bi.build_revision) > 0 ) then494build = tonumber(bi.build_revision)495else496build = tonumber(string.match(bi.build_number,'-(%d+)$'))497end498499if ((chdk_version<120) or ((chdk_version==120)and(build<3276)) or ((chdk_version==130)and(build<3383))) then500printf("CHDK 1.2.0 build 3276 or higher required")501else502if( props.CONTINUOUS_AF == nil ) then caf=-999 else caf = get_prop(props.CONTINUOUS_AF) end503if( props.SERVO_AF == nil ) then saf=-999 else saf = get_prop(props.SERVO_AF) end504cmode = capmode.get_name()505printf("Mode:%s,Continuous_AF:%d,Servo_AF:%d", cmode,caf,saf)506printf(" Tv:"..print_tv(tv96target).." max:"..print_tv(tv96max).." min:"..print_tv(tv96min).." ecomp:"..(ec96adjust/96).."."..(math.abs(ec96adjust*10/96)%10) )507printf(" Av:"..print_av(av96target).." minAv:"..print_av(av96minimum).." maxAv:"..print_av(av96max) )508printf(" ISOmin:"..print_sv(sv96min).." ISO1:"..print_sv(sv96max1).." ISO2:"..print_sv(sv96max2) )509printf(" MF mode:"..focus_mode.." Video:"..video_mode.." USB:"..usb_mode)510printf(" AvM:"..Av_mode.." int:"..(interval/1000).." Shts:"..max_shots.." Dly:"..start_delay.." B/L:"..backlight)511sleep(500)512513if (start_delay > 0 ) then514printf("entering start delay of ".. start_delay.." seconds")515sleep( start_delay*1000 )516end517518-- enable USB remote in USB remote moded519if (usb_mode > 0 ) then520set_config_value(121,1) -- make sure USB remote is enabled521if (get_usb_power(1) == 0) then -- can we start ?522printf("waiting on USB signal")523repeat wait_click(20) until ((get_usb_power(1) == 1) or ( is_key("menu")))524else sleep(1000) end525printf("USB signal received")526end527528-- switch to shooting mode529switch_mode(1)530531-- set zoom position532update_zoom(zoom_setpoint)533-- lock focus at infinity534lock_focus()535-- disable flash and AF assist lamp536set_prop(props.FLASH_MODE, 2) -- flash off537set_prop(props.AF_ASSIST_BEAM,0) -- AF assist off if supported for this camera538set_config_value( 297, 60) -- set console timeout to 60 seconds539540if (usb_mode > 2 ) then repeat until (get_usb_power(2) == 0 ) end -- flush pulse buffer541next_shot_time = get_tick_count()542script_exit = false543if( get_video_button() == 1) then video_button = true else video_button = false end544set_console_layout(2 ,0, 45, 4 )545repeat546547if( ( (usb_mode < 2 ) and ( next_shot_time <= get_tick_count() ) )548or ( (usb_mode == 2 ) and (get_usb_power(2) > 0 ) )549or ( (usb_mode == 3 ) and (shot_request == true ) ) ) then550551-- time to insert a video sequence ?552if( check_video(shot_count) == true) then next_shot_time = get_tick_count() end553554-- intervalometer timing555next_shot_time = next_shot_time + interval556557-- set focus at infinity ? (maybe redundant for AFL & MF mode but makes sure it's set right)558if (focus_mode > 0) then559set_focus(infx)560sleep(100)561end562563-- check exposure564local count = 0565local timeout = false566press("shoot_half")567repeat568sleep(50)569count = count + 1570if (count > 40 ) then timeout = true end571until (get_shooting() == true ) or (timeout == true)572573-- shoot in auto mode if meter reading invalid, else calculate new desired exposure574if ( timeout == true ) then575release("shoot_half")576repeat sleep(50) until get_shooting() == false577shoot() -- shoot in Canon auto mode if we don't have a valid meter reading578shot_count = shot_count + 1579printf(string.format('IMG_%04d.JPG',get_exp_count()).." : shot in auto mode, meter reading invalid")580else581-- get meter reading values (and add in exposure compensation)582bv96raw=get_bv96()583bv96meter=bv96raw-ec96adjust584tv96meter=get_tv96()585av96meter=get_av96()586sv96meter=get_sv96()587588-- set minimum Av to larger of user input or current min for zoom setting589av96min= math.max(av96minimum,get_prop(props.MIN_AV))590if (av96target < av96min) then av96target = av96min end591592-- calculate required setting for current ambient light conditions593if (Av_mode == 1) then exposure_iris()594elseif (Av_mode == 2) then exposure_NDfilter()595elseif (Av_mode == 3) then exposure_both()596else exposure_Tv_only()597end598599-- set up all exposure overrides600set_tv96_direct(tv96setpoint)601set_sv96(sv96setpoint)602if( av96setpoint ~= nil) then set_av96_direct(av96setpoint) end603604if(Av_mode > 1) and (insert_ND_filter == true) then -- ND filter available and needed?605set_nd_filter(1) -- activate the ND filter606nd_string="NDin"607else608set_nd_filter(2) -- make sure the ND filter does not activate609nd_string="NDout"610end611612-- and finally shoot the image613press("shoot_full_only")614sleep(100)615release("shoot_full")616repeat sleep(50) until get_shooting() == false617shot_count = shot_count + 1618619-- update shooting statistic and log as required620shot_focus=get_focus()621if(shot_focus ~= -1) and (shot_focus < 20000) then622focus_string=" foc:"..(shot_focus/1000).."."..(((shot_focus%1000)+50)/100).."m"623if(focus_mode>0) then624error_string=" **WARNING : focus not at infinity**"625end626else627focus_string=" foc:infinity"628error_string=nil629end630printf(string.format('%d) IMG_%04d.JPG',shot_count,get_exp_count()))631printf(" meter : Tv:".. print_tv(tv96meter) .." Av:".. print_av(av96meter) .." Sv:"..print_sv(sv96meter).." "..bv96raw ..":"..bv96meter)632printf(" actual: Tv:".. print_tv(tv96setpoint).." Av:".. print_av(av96setpoint).." Sv:"..print_sv(sv96setpoint))633printf(" AvMin:".. print_av(av96min).." NDF:"..nd_string..focus_string )634635if ((max_shots>0) and (shot_count >= max_shots)) then script_exit = true end636637shot_request = false -- reset shot request flag638639end640collectgarbage()641end642643-- check if USB remote enabled in intervalometer mode and USB power is off -> pause if so644if ((usb_mode == 1 ) and (get_usb_power(1) == 0)) then645printf("waiting on USB signal")646unlock_focus()647switch_mode(0)648repeat wait_click(20) until ((get_usb_power(1) == 1) or ( is_key("menu")))649switch_mode(1)650lock_focus()651if ( is_key("menu")) then script_exit = true end652printf("USB wait finished")653sleep(100)654end655656if (usb_mode == 3 ) then pwm_mode(get_usb_power(2)) end657658if (blite_timer > 0) then659blite_timer = blite_timer-1660if ((blite_timer==0) and (backlight==1)) then set_lcd_display(0) end661end662663if( error_string ~= nil) then664draw_string( 16, 144, string.sub(error_string.." ",0,42), 258, 259)665end666667wait_click(100)668669if( not( is_key("no_key"))) then670if ((blite_timer==0) and (backlight==1)) then set_lcd_display(1) end671blite_timer=300672if ( is_key("menu") ) then script_exit = true end673end674675until (script_exit==true)676printf("script halt requested")677restore()678end679680--[[ end of file ]]--681682683684685