--[[ ********************************************* Script IntervWO v1.12 Beta 3 Short version without comments (c) Werner_O 2015/03/24 Thx msl Licence: GPL Dieses Skript benötigt CHDK ab Version 1.3.0! ********************************************* @title IntervWO 1.12 Beta 3 @chdk_version 1.3 @param n Anzahl Bilder/Serien (0=inf) @default n 3 @range n 0 10000 @param g Intervallzeit (hour) @default g 0 @range g 0 24 @param i Intervallzeit (min) @default i 0 @range i 0 60 @param j Intervallzeit (sec) @default j 3 @range j 0 60 @param c Startverzögerung (hour) @default c 0 @range c 0 24 @param d Startverzögerung (min) @default d 0 @range d 0 60 @param e Startverzögerung (sec) @default e 5 @range e 0 60 @param z Anzahl Bilder je Unterserie @default z 0 @values z OFF 2 3 4 5 6 7 8 9 @param y Interv.Zeit Unterserie (sec) @default y 1 @range y 0 9 @param l AF-Lock bei 1. Bild/Serie @default l 0 @range l 0 1 @param t Timeout für AF-Lock (sec) @default t 2 @range t 1 5 @param a AE-Lock bei 1. Bild/Serie @default a 0 @range a 0 1 @param f Auto-FixFokus verwenden @default f 0 @values f OFF MAN HYP INF @param m Man. A-FixFokus Distanz (cm) @default m 200 @range m 0 6500 @param u 65m für INF bei A-FixFokus @default u 0 @range u 0 1 @param b Blitzbereitschaft abwarten @default b 0 @range b 0 1 @param p Display aus n. Bild/Serie @default p 0 @values p OFF MAN 1 3 5 10 @param q Zuweisung Display-Taste @default q 1 @values q DISPLAY SET @param s Save Mode (nur P;Tv;Av;M) @default s 1 @range s 0 1 @param v Konsolenoffset vertikal @default v 2 @range v 0 6 @param h Konsolenoffset horizontal @default h 0 @range h 0 9 ]] x1 = h y1 = v x2 = h + 32 y2 = v + 10 set_console_layout(x1, y1, x2, y2) counter = 0 interval = ((g * 3600000) + (i * 60000) + (j * 1000)) delay = ((c * 3600000) + (d * 60000) + (e * 1000)) aflock = l if aflock == 1 then afl_timeout = (t * 1000) else afl_timeout = 1000 end if n == 0 then n = 1000000 end afl_timeout = (t * 1000) aelock = a shoot_half = 0 mfmode = 0 fixfoc = f man_distance = (m * 10) inf_distance = u display_key = q savemode = s flashmode = b flashmode_real = false message1 = "Uuuups..." message2 = "Unbekannter Fehler..." focusmode = "AF für jedes Bild" abort = false ready = true sub_delay = (y * 1000) if z > 0 then sub_count = (z + 1) pics = (n * sub_count) sub_time = ((sub_delay * sub_count) + afl_timeout + 1000) else sub_count = 1 pics = n end lcd = 1 lcd_off = true if p == 0 then lcd_auto = 0 lcd_off = false elseif p == 1 then lcd_auto = 0 elseif p == 2 then lcd_auto = (1 * sub_count) elseif p == 3 then lcd_auto = (3 * sub_count) elseif p == 4 then lcd_auto = (5 * sub_count) elseif p == 5 then lcd_auto = (10 * sub_count) end function print_focus() if focus < 0 then print("Fokus gesetzt auf Unendl. (Auto)") elseif focus < 1000 then print(string.format("Fokus gesetzt auf %d mm", focus)) elseif focus < 10000 then local string1 = string.sub(focus_string, 1, 1) local string2 = string.sub(focus_string, 2, 4) print(string.format("Fokus gesetzt auf %s,%s m", string1, string2)) else local string1 = string.sub(focus_string, 1, 2) local string2 = string.sub(focus_string, 3, 4) print(string.format("Fokus gesetzt auf %s,%s m", string1, string2)) end end function print_time(val, message) if message == nil then message = "" end local t = os.date("*t", val/1000) local d = val/86400000 print(string.format("%s%02dh%02dm%02d,%02ds", message, t.hour+d*24, t.min, t.sec, (val%1000)/10)) end function check_mf() err3 = {} if get_focus_state() < 0 then table.insert(err3, "Die CAM ist im MF-Modus:") if ((aflock == 1) and (fixfoc == 0)) then aflock = 0 table.insert(err3, "AF-Lock wurde deaktiviert!") elseif ((aflock == 1) and (fixfoc > 0)) then aflock = 0 fixfoc = 0 table.insert(err3, "AFL+FixFokus wurden deaktiviert!") elseif ((aflock == 0) and (fixfoc > 0)) then fixfoc = 0 table.insert(err3, "Auto-FixFokus wurde deaktiviert!") else table.insert(err3, "Der Fokus wurde nicht geändert!") end focusmode = "MF-Voreinstellung an der CAM" elseif fixfoc > 0 then table.insert(err3, "Auto-FixFokus ist aktiviert:") mfmode = set_mf(1) sleep(500) if mfmode == 1 then aflock = 0 table.insert(err3, "Die CAM ist im Auto-MF Modus!") else mfmode = 0 set_aflock(1) aflock = 2 table.insert(err3, "Die CAM ist im AF-Lock Modus!") end if fixfoc == 1 then focusmode = "Auto-FixFokus manuelle Distanz" elseif fixfoc == 2 then focusmode = "Auto-FixFokus hyperfok. Distanz" else focusmode = "Auto-FixFokus unendliche Distanz" end elseif aflock == 1 then table.insert(err3, "AF-L 1. Bild/Serie ist aktiviert") focusmode = "AF-Lock vor erstem Bild/Serie" else table.insert(err3, "AF für jedes Bild ist aktiviert") focusmode = "AF für jedes Bild" end for i=1, #err3 do print(err3[i]) end end function set_fixfoc() if fixfoc == 1 then distance = man_distance message3 = "Manueller FixFokus" elseif fixfoc == 2 then distance = get_dofinfo().hyp_dist message3 = "Hyperfokale Distanz" else if inf_distance == 0 then distance = -1 message3 = "Unendl. Distanz (Auto)" else distance = 65000 message3 = "Unendl. Distanz (65m)" end end local countf = 0 local timeout = false set_focus(distance) press("shoot_half") repeat sleep(10) countf = countf + 10 if countf > 1000 then timeout = true end until (get_shooting() or timeout) focus = get_focus() focus_string = tostring(focus) release("shoot_half") print(string.format("%s aktiviert:", message3)) print_focus() end function take_ael_afl() local afl_timer = 0 local timeout = false press("shoot_half") repeat sleep(50) afl_timer = (afl_timer + 50) if (afl_timer > afl_timeout) then timeout = true end until (get_shooting() or timeout) if aflock == 1 then set_aflock(1) focusmode = "AFL bei erstem Bild/Serie" end if aelock == 1 then set_aelock(1) shoot_half = 1 else release("shoot_half") shoot_half = 0 end end function flashfunction() flashmode_current = get_flash_mode() if flashmode_current ~= flashmode_last then if flashmode_current == 2 then flashmode_real = false print("Blitzmodus wurde deaktiviert") else flashmode_real = true print("Blitzmodus wurde aktiviert") end flashmode_last = flashmode_current end end function take_shoot() cls() local exp_count = get_exp_count() pic_last = get_tick_count() if ((flashmode_real == true) and (get_flash_mode() ~= 2)) then if get_flash_ready() == 0 then print("Warte auf den Blitz...") repeat sleep(10) until get_flash_ready() == 1 end end if shoot_half == 1 then press("shoot_full_only") sleep(100) release("shoot_full_only") else shoot() end repeat sleep(10) until (get_exp_count() ~= exp_count) counter = (counter + 1) if pics > 0 then print(string.format("Bild %d von %d", counter, pics)) else print(string.format("Bild %d von unendlich", counter)) end end function take_shoot_subinterval() if ((aelock == 1) or (aflock == 1)) then take_ael_afl() end local sub_counter = 0 repeat sub_interval_counter = get_tick_count() take_shoot() sub_counter = (sub_counter + 1) time_next_shoot = (sub_delay - (get_tick_count() - sub_interval_counter)) if ((time_next_shoot >= 1000) and (sub_counter < sub_count)) then wait_key_pressure() end local sub_sleep_time = (sub_delay - (get_tick_count() - sub_interval_counter)) if flashmode == 1 then flashfunction() end if ((sub_sleep_time > 0) and (sub_counter < sub_count) and (abort == false)) then sleep(sub_sleep_time) end until ((sub_counter == sub_count) or (abort == true)) if aflock == 1 then set_aflock(0) end if aelock == 1 then set_aelock(0) release("shoot_half") shoot_half = 0 end end function wait_key_pressure() local key_starting_time = get_tick_count() local key_interval = (time_next_shoot - 500) local key_time x = time_next_shoot print_time(x, message) repeat if key_interval > 10000 then key_time = 10000 else key_time = key_interval end wait_click(key_time) if ((is_pressed("display") and (display_key == 0)) or (is_pressed("set") and (display_key == 1))) then if flashmode == 1 then flashfunction() end x = ((time_next_shoot) - (get_tick_count() - key_starting_time)) if lcd_off == false then console_redraw() print_time(x, message) else if lcd == 1 then set_lcd_display(0) lcd = 0 else set_lcd_display(1) lcd = 1 console_redraw() print_time(x, message) end end elseif is_pressed("menu") then abort = true end key_interval = ((time_next_shoot - 500) - (get_tick_count() - key_starting_time)) until ((key_interval <= 0) or (abort == true)) end function restore() if lcd == 0 then set_lcd_display(1) end if aflock > 0 then set_aflock(0) end if aelock == 1 then set_aelock(0) end if shoot_half == 1 then release("shoot_half") end if mfmode == 1 then set_mf(0) end cls() if (abort == true) then print("Das Skript wurde abgebrochen") end if counter >= 1 then if #err2 > 0 then for i=1, #err2 do print(err2[i]) end end print(string.format("Anzahl gemachter Bilder = %d", counter)) for i=1, #err3 do print(err3[i]) end print("Verwendeter Fokusmodus:") print(focusmode) if fixfoc > 0 then print(string.format("%s war gewählt:", message3)) print_focus() end if delay > 0 then x = delay message = "Startverzög. Soll = " print_time(x, message) x = (pic_first - delay_counter) message = "Startverzög. Real = " print_time(x, message) end end if counter >= 2 then if sub_count == 1 then if interval > 0 then x = interval message = "Intervall Soll = " print_time(x, message) message = "Intervall Real = " x = (pic_last - pic_first) / (counter - 1) print_time(x, message) else local x = ((counter - 1) * 100000) / (pic_last - pic_first) local x_string = tostring(x) if x >= 100 then integer_part = string.sub(x_string, 1, 1) else integer_part = "0" end local fract_part = tonumber(string.sub(x_string, -2)) print(string.format("bei gemittelt %s,%02d Bildern/sec", integer_part, fract_part)) end end end sleep(3000) console_redraw() end delay_counter = get_tick_count() err1 = {} if get_mode() == false then print("Aktiviere Aufnahmemodus...") set_record(1) sleep(1000) while get_mode() == false do sleep(10) end print("Aufnahmemodus ist nun aktiv!") end if tonumber(string.sub(string.gsub(get_buildinfo().build_number, "%p", ""), 0, 3)) < 130 then table.insert(err1, "Dieses Skript benötigt") table.insert(err1, "CHDK ab Version 1.3.0!") end capmode = require("capmode") cmode = capmode.get_name() if fixfoc == 2 then if not ((cmode == "AV") or (cmode == "M")) then table.insert(err1, "Für die hyperfocale Distanz wird") table.insert(err1, "Programm Av oder M benötigt!") end end rec,vid = get_mode() if vid == true then table.insert(err1, "Videoaufnahme ist aktiv,") table.insert(err1, "bitte erst auschalten!") end if ((sub_count > 1) and (interval < sub_time)) then table.insert(err1, "Das Hauptintervall ist zu kurz") table.insert(err1, "für die Unterintervallserien!") end if savemode == 1 then if ((aelock == 1) and (get_propset() == 2)) then table.insert(err1, "AE-Lock kann bei dieser CAM") table.insert(err1, "zu Skriptabbrüchen führen!") end if not (cmode == "P" or cmode == "TV" or cmode == "AV" or cmode == "M") then table.insert(err1, "Save Mode ist aktiv, bitte") table.insert(err1, "P, Tv, Av oder M wählen!") end end if #err1 == 0 then err2 = {} if ((cmode == "M") and (aelock == 1)) then aelock = 0 table.insert(err2, "Programm M ist aktiv:") table.insert(err2, "AE-Lock wurde deaktiviert!") elseif ((flashmode == 1) and (aelock == 1)) then aelock = 0 table.insert(err2, "Der Blitzmodus ist aktiv:") table.insert(err2, "AE-Lock wurde deaktiviert!") end if #err2 > 0 then for i=1, #err2 do print(err2[i]) end end if flashmode == 1 then flashmode_current = get_flash_mode() flashmode_last = flashmode_current if flashmode_current ~= 2 then flashmode_real = true else flashmode_real = false end end check_mf() if fixfoc > 0 then set_fixfoc() end if (((aflock == 1) or (aelock == 1)) and (sub_count == 1)) then delay_pre = (delay - afl_timeout - 500 - (get_tick_count() - delay_counter)) if ((aflock == 1) and (aelock == 0)) then message = "AF-Lock in: " elseif ((aflock == 0) and (aelock == 1)) then message = "AE-Lock in: " else message = "AF/AE-Lock in: " end if delay_pre >= 1000 then time_next_shoot = delay_pre wait_key_pressure() end take_ael_afl() message = "Erstes Bild in: " else delay_pre = (delay - (get_tick_count() - delay_counter)) if (delay_pre >= 1000) then message = "Erstes Bild in: " time_next_shoot = delay_pre wait_key_pressure() end end delay_post = (delay - (get_tick_count() - delay_counter)) if ((delay_post > 0) and (abort == false)) then if delay_post >= 1000 then x = delay_post print_time(x, message) end sleep(delay_post) end message = "Nächstest Bild in: " end if #err1 == 0 then pic_first = get_tick_count() repeat if abort == false then interval_start = get_tick_count() if sub_count == 1 then take_shoot() else take_shoot_subinterval() end if ((lcd_auto == counter) and (lcd == 1)) then set_lcd_display(0) lcd = 0 end interval_remaining = (interval - (get_tick_count() - interval_start)) if ((counter < pics) and (interval_remaining >= 1000) and (abort == false)) then time_next_shoot = interval_remaining wait_key_pressure() interval_remaining = (interval - (get_tick_count() - interval_start)) end if flashmode == 1 then flashfunction() end if ((interval_remaining > 0) and (abort == false)) then sleep(interval_remaining) end end until (((pics > 0) and (counter == pics)) or (abort == true)) restore() else print("KRITISCHE FEHLER GEFUNDEN:") for i=1, #err1 do print(err1[i]) end sleep(3000) console_redraw() end