--[[ @title VarTL NoVF @param t Time to wait @default t 5 @param d LCD-off after ... pics @default d 5 @param w Countdown in sec @default w 3 @param e Fixfocus @default e 1 @param s EV-Shift x*(1/3EV) @default s 0 @param u Flash 0=auto 1=on 2=off @default u 2 @param q Quality (0,1,2) @default q 2 @param r Pixel (0..4,6,8) @default r 3 @param l ..LOGS/logDATE.txt off/on @default l 0 @param c Start hour @default c 0 @param f End hour @default f 23 ]] -------------------------------------------------------------------------------- -- in the above list, variable names must consist of one letter only ----------- -- for the sake of readability, rename them now: ------------------------------- -------------------------------------------------------------------------------- paramTimeBetweenPictures = t paramCountPicturesToTurnDisplayOff = d paramStartCountdown = w paramDoLockAutofocus = e paramShiftEV = s paramFlashMode = u paramPictureQuality = q paramPictureResolution = r paramDoWriteLog = l paramStartHour = c paramEndHour = f -------------------------------------------------------------------------------- -------------------------- end renaming user params ---------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- ------- added by me (Tiefflieger) to make the script work on my ixus 65 -------- -------------------------------------------------------------------------------- --override chdk function to always return 1000 function get_jpg_count() return 1000; end -------------------------------------------------------------------------------- ------- end added by me (Tiefflieger) to make the script work on my ixus 65 ---- -------------------------------------------------------------------------------- --[[ writes a log entry to the specified file ]] function writeEntryToLog(logFileName, logEntry) --print("writeEntryToLog: " .. logFileName .. " " .. logEntry); if paramDoWriteLog > 0 then file=io.open(logFileName,"a") file:write(logEntry) file:close() end end ---- --[[ writes a log entry to the specified file to do this, it automatically reads the current status of the camera (such as temperatures and current time) logFileName: filename where to write the log to pictureId: Number of Picture tv: time value bv: brightness value ]] function writeToLog(logFileName, pictureId, tv, bv) if paramDoWriteLog > 0 then logEntry = "\n" .. pictureId .. "\t" .. tv .. "\t" .. bv .. "\t"; logEntry = logEntry .. get_vbatt() .. "\t" .. os.date("%X") .. "\t"; logEntry = logEntry .. get_temperature(0) .. "\t" .. get_temperature(1); logEntry = logEntry .. "\t" .. get_temperature(2); writeEntryToLog(logFileName, logEntry); end end ----- --[[ gets display mode 0 = show info icons 1 = Do not show info icons 2 = LCD off 3 = EVF ]] function getDisplayMode() -- set default display mode to 0 result = 0; propset = get_propset(); if propset == 1 then result = get_prop(181); elseif propset == 2 then result = get_prop(105); elseif propset == 3 then result = get_prop(105); end return result end ----- --[[ set display mode 0 = show info icons 1 = Do not show info icons 2 = LCD off 3 = EVF ]] function setDisplayMode(newDisplayMode) errorCount = 1 repeat click ("display") sleep(10) errorCount = errorCount + 1 until getDisplayMode() == newDisplayMode or errorCount >= 20 if errorCount >= 20 then print("setDisplayMode failed") end end ---- --[[ set flash mode 0 = auto flash 1 = flash on 2 = flash off ]] function setFlashMode( newFlashMode ) propset = get_propset(); if propset == 1 then set_prop(16, newFlashMode) elseif propset == 2 then set_prop(143, newFlashMode) elseif propset == 3 then set_prop(143, newFlashMode) end end ---- --[[ get picture quality 0 = Superfine 1 = Fine 2 = Normal ]] function getPictureQuality() -- set default picture quality to 1 result = 1; propset = get_propset(); if propset == 1 then result = get_prop(23) elseif propset == 2 then result = get_prop(57) elseif propset == 3 then result = get_prop(57) end return result end ---- --[[ set picture quality 0 = Superfine 1 = Fine 2 = Normal ]] function setPictureQuality(newQuality) propset = get_propset(); if propset == 1 then set_prop(23, newQuality) elseif propset == 2 then set_prop(57, newQuality) elseif propset == 3 then set_prop(57, newQuality) end end ---- --[[ gets resolution of pictures 0 = L 1 = M1 2 = M2 3 = M3 4 = S 5 = RAW (on g9) 6 = Postcard 8 = W ]] function getPictureResolution() --set default resolution to 0 result = 0 propset = get_propset(); if propset == 1 then result = get_prop(24) elseif propset == 2 then result = get_prop(218) elseif propset == 3 then result = get_prop(220) end return result end ---- --[[ sets resolution of pictures 0 = L 1 = M1 2 = M2 3 = M3 4 = S 5 = RAW (on g9) 6 = Postcard 8 = W ]] function setPictureResolution(newResolution) propset = get_propset(); if propset == 1 then set_prop(24, newResolution) elseif propset == 2 then set_prop(218, newResolution) elseif propset == 3 then set_prop(220, newResolution) end end ---- function setTVForNextPicture( newTV ) propset = get_propset(); if propset == 1 then set_prop(69, newTV) elseif propset == 2 then set_prop(262, newTV) elseif propset == 3 then set_prop(264, newTV) end end ---- function printlcd() click ("print") end ---- function countdown() for h = 1 , paramStartCountdown do m = paramStartCountdown - h + 1 print ("countdown:",m,"secs") sleep (940) end cls() end ---- function shooting(logFileName) -- writeEntryToLog(logFileName, "1"); check1=get_exp_count() -- writeEntryToLog(logFileName, "2"); print ("Photo ",phc) -- writeEntryToLog(logFileName, "3"); press ("shoot_half") writeEntryToLog(logFileName, "4"); repeat bla = "nein" if get_shooting() then bla = "ja" end -- writeEntryToLog(logFileName, "5" .. bla); until get_shooting() == true -- writeEntryToLog(logFileName, "6"); -- sleep(3000); if phc==1 and paramDoLockAutofocus == 1 then set_aflock(1) end -- writeEntryToLog(logFileName, "7"); z=get_tv96() bv=get_bv96() if z<=0 then -- writeEntryToLog(logFileName, "8"); calcshoot() print("shutter: ",y," sec") -- writeEntryToLog(logFileName, "9"); writeToLog(logFileName, phc, y, bv); setTVForNextPicture(g); else if z>0 and z<=32 then y="0,8" howlong=1600 end --how long to sleep to let the cam work if z>32 and z<=64 then y="0,6" howlong=1200 end if z>64 and z<=96 then y="0,5" howlong=1000 end if z>96 and z<=128 then y="0,4" howlong=800 end if z>128 and z<=160 then y="0,3" howlong=600 end if z>160 and z<=192 then y="0,25" end if z>192 and z<=224 then y="0,2" end if z>224 and z<=256 then y="0,167" end if z>256 and z<=288 then y="0,125" end if z>288 and z<=320 then y="0,1" end if z>320 and z<=352 then y="0,077" end if z>352 and z<=384 then y="0,067" end if z>384 and z<=416 then y="0,05" end if z>416 and z<=448 then y="0,04" end if z>448 and z<=480 then y="0,033" end if z>480 and z<=512 then y="0,025" end if z>512 and z<=544 then y="0,02" end if z>544 and z<=576 then y="0,017" end if z>576 and z<=608 then y="0,013" end if z>608 and z<=640 then y="0,01" end if z>640 and z<=672 then y="0,008" end if z>672 and z<=704 then y="0,006" end if z>704 and z<=736 then y="0,005" end if z>736 and z<=768 then y="0,004" end if z>768 and z<=800 then y="0,0031" end if z>800 and z<=832 then y="0,0025" end if z>832 and z<=864 then y="0,002" end if z>864 and z<=896 then y="0,0016" end if z>896 and z<=928 then y="0,0013" end if z>928 and z<=960 then y="0,001" end if z>960 and z<=992 then y="0,0008" end if z>992 and z<=1024 then y="0,00063" end if z>1024 and z<=1056 then y="0,0005" end print("shutter: ",y," sec") writeToLog(logFileName, phc, y, bv); end click ("shoot_full") if z<=128 then print("sleep: ",howlong/2," msec") sleep(howlong-80) --80msec, so the sleep time doesn't affect the interval and script wakes up before the cam is done print("end of sleep") else sleep(10) end repeat until get_shooting() == false ----lcdoff print- if lc > paramCountPicturesToTurnDisplayOff then if getDisplayMode()~=2 then sleep(1) printlcd() end end ----- release ("shoot_half") if lc == paramCountPicturesToTurnDisplayOff then if getDisplayMode()~=2 then sleep(1) printlcd() end end check2=get_exp_count() if check2==check1 then repeat check2=get_exp_count() until check2~=check1 end toblink = (((paramTimeBetweenPictures * 1000) /10) *1) if toblink>1500 then toblink=1500 end if paramTimeBetweenPictures > 0 then set_led(7,1) r=get_tick_count() while stilltowait(r)>toblink and br~=1 do chill(stilltowait(r)-toblink) end if br~=1 then blinkled(toblink) end set_led(7,0) end lc=lc+1 phc=phc+1 end --- function chill(waitforclick) wait_click (waitforclick) if is_pressed "shoot_half" then br=1 end if is_pressed "display" then printlcd() if getDisplayMode()~=2 then lc=0 end end end ---- function blinkled(blinktime) stat=1 repeat stat=stat*-1 if stat>0 then set_led(7,stat) end if stat<0 then set_led(7,0) end sleep(100) blinktime=blinktime-100 until blinktime<=0 end ---- function calcshoot() bv=get_bv96() sv=get_sv96() av=get_av96() g=bv+sv-av if 0>=g and g>-32 then g=0 y="1" howlong=2000 end --how long to sleep to let the cam work if -32>=g and g>-64 then g=-32 y="1,3" howlong=2600 end if -64>=g and g>-96 then g=-64 y="1,6" howlong=3200 end if -96>=g and g>-128 then g=-96 y="2" howlong=4000 end if -128>=g and g>-160 then g=-128 y="2,5" howlong=5000 end if -160>=g and g>-192 then g=-160 y="3,2" howlong=6400 end if -192>=g and g>-224 then g=-192 y="4" howlong=8000 end if -224>=g and g>-256 then g=-224 y="5" howlong=10000 end if -256>=g and g>-288 then g=-256 y="6,3" howlong=12600 end if -288>=g and g>-320 then g=-288 y="8" howlong=16000 end if -320>=g and g>-352 then g=-320 y="10" howlong=20000 end if -352>=g and g>-384 then g=-352 y="12,7" howlong=25400 end if -384>=g and g>-416 then g=-384 y="16" howlong=32000 end if -416>=g and g>-448 then g=-416 y="20" howlong=40000 end if -448>=g and g>-480 then g=-448 y="25,4" howlong=50800 end if -480>=g and g>-512 then g=-480 y="32" howlong=64000 end if -512>=g and g>-544 then g=-512 y="40,3" howlong=80600 end if -544>=g and g>-576 then g=-544 y="50,8" howlong=10160 end if -576>=g then g=-576 y="64" howlong=128000 end limit=-320 if paramShiftEV ~= 0 and g<=limit then --possibility to add EV-shift at night in 1/3 Ev steps -->enjoy with care (reason in the next comment line) g = g - (paramShiftEV * 32) if g>limit then g=limit end --everything <10 sec will be 10 sek (increases the time when shutterspeed=10 sek) !!! if g==0 then y="1" howlong=2000 end --how long to sleep to let the cam work if g==-32 then y="1,3" howlong=2600 end if g==-64 then y="1,6" howlong=3200 end if g==-96 then y="2" howlong=4000 end if g==-128 then y="2,5" howlong=5000 end if g==-160 then y="3,2" howlong=6400 end if g==-192 then y="4" howlong=8000 end if g==-224 then y="5" howlong=10000 end if g==-256 then y="6,3" howlong=12600 end if g==-288 then y="8" howlong=16000 end if g==-320 then y="10" howlong=20000 end if g==-352 then y="12,7" howlong=25400 end if g==-384 then y="16" howlong=32000 end if g==-416 then y="20" howlong=40000 end if g==-448 then y="25,4" howlong=50800 end if g==-480 then y="32" howlong=64000 end if g==-512 then y="40,3" howlong=80600 end if g==-544 then y="50,8" howlong=10160 end if g==-576 then y="64" howlong=128000 end end end ----- function stilltowait(started) now = get_tick_count() rest = (paramTimeBetweenPictures * 1000 + 1)-(now-started) return rest end -------------------------------------------------------------------------------- ------------------------start script-------------------------------------------- -------------------------------------------------------------------------------- if paramDoWriteLog > 0 then paramDoWriteLog = 1 else paramDoWriteLog = 0 end if paramTimeBetweenPictures < 0 then paramTimeBetweenPictures = 0 end if paramCountPicturesToTurnDisplayOff < 1 then paramCountPicturesToTurnDisplayOff = 1 end if paramDoLockAutofocus > 0 then paramDoLockAutofocus = 1 else paramDoLockAutofocus = 0 end if paramFlashMode > 2 then paramFlashMode = 2 end if paramFlashMode < 0 then paramFlashMode = 0 end if paramStartCountdown < 0 then paramStartCountdown = 0 end if paramPictureQuality < 0 then paramPictureQuality = 0 end if paramPictureQuality > 2 then paramPictureQuality = 2 end if paramPictureResolution < 0 then paramPictureResolution = 0 end if paramPictureResolution > 8 then paramPictureResolution = 8 end if paramStartHour < 0 then paramStartHour = 0 end if paramStartHour > 23 then paramStartHour = 23 end if paramEndHour < 0 then paramEndHour = 0 end if paramEndHour > 23 then paramEndHour = 23 end phc=1 lc=1 logFileName = "A/CHDK/LOGS/log" .. os.date("%d%m%H%M") .. ".txt" --print("Logfilename: " .. logFileName); -------------------------------------------------------------------------------- ----- start backup settings so we can restore them when ending the script ------ -------------------------------------------------------------------------------- --backup LCD settings backupDisplayMode = getDisplayMode() --backup Flash settings backupFlashMode = get_flash_mode() --backup RAW settings backupRawMode = get_raw() --backup Resolution settings backupResolution = getPictureResolution() backupQuality = getPictureQuality() -------------------------------------------------------------------------------- ------ end backup settings so we can restore them when ending the script ------- -------------------------------------------------------------------------------- --presets if get_IS_mode()~=3 then print("Turn IS off! ") print("to prevent") print("bad results") sleep (2000) end cls() setFlashMode(paramFlashMode) set_raw(0) print("RAW is off") setPictureResolution(paramPictureResolution) setPictureQuality(paramPictureQuality) if backupDisplayMode~=0 then setDisplayMode(0) end newLogEntry = "PicId\tTV\tBV\tvoltage\tclock\toptic\tCCD\tBattery" writeEntryToLog(logFileName, newLogEntry) --run-------------------------------------------------------------------------------------------------------- countdown() countRemainingPictures = get_jpg_count() print("remainingpics: " .. countRemainingPictures) if countRemainingPictures > 1 then repeat nowHour = tonumber(os.date("%H")); if paramStartHour > paramEndHour then if nowHour >= paramStartHour and nowHour <= 23 then shooting(logFileName) countRemainingPictures = get_jpg_count() elseif nowHour >= 0 and nowHour <= paramEndHour then shooting(logFileName) countRemainingPictures = get_jpg_count() else print(nowHour .. ":" .. os.date("%M") .. " wrong time") print("5 mins sleep") chill(300000) end end if paramStartHour <= paramEndHour then if nowHour >= paramStartHour and nowHour <= paramEndHour then shooting(logFileName) countRemainingPictures = get_jpg_count() else print(nowHour .. ":" .. os.date("%M") .. " wrong time") print("5 mins sleep") chill(300000) end end until countRemainingPictures == 1 or br==1 end --restore settings of LCD,flash,RAW, resolution and quality and exit----- set_aflock(0) if get_flash_mode() ~= backupFlashMode then setFlashMode(backupFlashMode) end set_raw(backupRawMode) setPictureResolution(backupResolution) setPictureQuality(backupQuality) if br==1 then print("script canceled...") newLogEntry = "\nscript canceled\t\t\t\t" .. os.date("%X") writeEntryToLog(logFileName, newLogEntry) else print("card is full..."); newLogEntry = "\ncard is full\t\t\t\t" .. os.date("%X"); writeToLog(logFileName, 0, 0, 0); writeEntryToLog(logFileName, newLogEntry); end sleep(1000) if getDisplayMode() ~= backupDisplayMode then setDisplayMode(backupDisplayMode) end