--[[ ********************************************* Licence: GPL (c) Werner_O 2014/10/28 Thx msl v1.09 alpha Dieses Skript benötigt CHDK ab Version 1.3.0! ********************************************* @title IntervWO @param n Bildanzahl (0=unendlich) @default n 3 @range n 0 10000 @param i Intervallzeit grob (min) @default i 0 @range i 0 1440 @param j Intervallzeit mittel (sec) @default j 3 @range j 0 59 @param k Intervallzeit fein (100ms) @default k 0 @range k 0 9 @param c Startverzög. grob (min) @default c 0 @range c 0 720 @param d Startverzög. fein (sec) @default d 2 @range d 0 60 @param l AF-/AE-Lock verwenden @default l 0 @range l 0 1 @param h Festen Fokus verwenden @default h 0 @values h OFF MAN HYP INF @param m Man. Fokus Distanz (cm) @default m 200 @range m 0 100000 @param p Display aus nach Bild-Nr @default p 0 @values p OFF MAN 1 3 5 10 @param s Save Mode (nur P;Tv;Av;M) @default s 1 @range s 0 1 ]] -- Definitionen der verwendeten Variablen: pics = n interval = (i * 60000) + (j * 1000) + (k * 100) delay = (c * 60000) + (d * 1000) if l == 1 then aflock = 1 aelock = 1 else aflock = 0 aelock = 0 end shoot_half = 0 mfmode = 0 fixfoc = h mfdistance = m * 10 lcd = 1 savemode = s ready = true counter = 0 delay_counter = 0 shoot_counter = 0 message1 = "Uuuups..." message2 = "Unbekannter Fehler" focusmode = "AF für jedes Bild" -- Definitionen zu "Display aus...": lcd_man = false lcd_err = false if p == 0 then --Wahr bei Vorwahl OFF lcd_auto = 0 elseif p == 2 then --Wahr bei Vorwahl Bild 1 lcd_auto = 1 elseif p == 3 then --Wahr bei Vorwahl Bild 3 lcd_auto = 3 elseif p == 4 then --Wahr bei Vorwahl Bild 5 lcd_auto = 5 elseif p == 5 then --Wahr bei Vorwahl Bild 10 lcd_auto = 10 elseif p == 1 then --Wahr bei Vorwahl MAN lcd_auto = 0 if interval < 5000 then --Wahr bei einer Intervallzeit < 5 sec lcd_err = true --Führt später zu einem Skriptabbruch else lcd_man = true --Die Taste DISPLAY kann das LCD später ein-/ausschalten end end -- Definition Konsolen-Layout: set_console_layout(0, 0, 32, 10) -- Definition Unterfunktion print_focus() zur Anzeige der Fokusdistanz: function print_focus() if (focus < 0) then --Wahr bei Fokus = unendlich print("Fokus gesetzt auf Unendlich") elseif (focus < 1000) then --Wahr bei Fokus < 1 m print(string.format("Fokus gesetzt auf %d mm", focus)) elseif (focus < 10000 ) then --Wahr bei Fokus >= 1 m bis < 10 m 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 --Wahr bei Fokus >= 10 m 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 -- Definition Unterfunktion print_time() zur Anzeige der Intervall-Längen: 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 -- Definition Unterfunktion check_mf() function check_mf() if get_focus_state() < 0 then --Wahr bei aktiviertem MF if (aflock == 1 and fixfoc == 0) then aflock = 0 print("Die Kamera ist im MF-Modus:") print("AF-L wurde deaktiviert!") focusmode = "MF manuell via Cam" elseif fixfoc > 0 then aflock = 0 focusmode = "MF geänd. vom Skript" end else if fixfoc > 0 then mfmode = set_mf(1) sleep(500) if mfmode == 1 then aflock = 0 focusmode = "MF auto via Skript" else set_aflock(1) aflock = 2 focusmode = "AFL auto via Skript" end end end end -- Definition Unterfunktion set_fixfoc() zum Einstellen eines festen Fokus function set_fixfoc() if fixfoc == 1 then distance = mfdistance message3 = "Manueller Fokus" elseif fixfoc == 2 then distance = get_dofinfo().hyp_dist message3 = "Hyperfokale Distanz" else distance = -1 message3 = "Unendliche Distanz" end local count = 0 local timeout = false set_focus(distance) press("shoot_half") repeat sleep(50) count = count + 1 if count > 40 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 -- Definition Unterfunktion wait_key_pressure() function wait_key_pressure() repeat local interval_click = interval - (get_tick_count() - shoot_counter) - 1000 wait_click(interval_click) if is_pressed("display") then if lcd == 1 then set_lcd_display(0) lcd = 0 else set_lcd_display(1) lcd = 1 console_redraw() end end until interval - (get_tick_count() - shoot_counter) < 2000 --Wahr ab einem Restintervall kleiner 2 sec end -- Definition Unterfunktion restore() für Skriptabbruch bzw. Skriptende: 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() print(string.format("Fokusmodus: %s", focusmode)) if counter >= 2 then if fixfoc > 0 then print(string.format("%s war gewählt:", message3)) print_focus() end print(string.format("Anzahl gemachter Bilder = %d", counter)) if interval > 0 then message = "Intervall Soll = " local x = interval 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 sleep(3000) console_redraw() end end -- DIVERSE SYSTEMABFRAGEN FÜR GGFS. NÖTIGEN SKRIPTABBRUCH: capmode = require("capmode") -- Einbindung der Lua-Bibliothek capmode.lua aus dem Ordner A/CHDK/LUALIB cmode = capmode.get_name() -- Feststellung des Namens der eingestellten Aufnahmefunktion -- Abfrage zur hyperfokalen Distanz, welche nur bei den Programmen Av oder M möglich sein soll: if fixfoc == 2 then if not (cmode == "AV" or cmode == "M") then fixfoc = -1 end end rec,vid = get_mode() -- Abfrage CHDK-Version mit Abbruch bei einer erkannten Version kleiner als 1.3.0 if tonumber(string.sub(string.gsub(get_buildinfo().build_number, "%p", ""), 0, 3)) < 130 then ready = false message1 = "Dieses Skript benötigt" message2 = "CHDK ab Version 1.3.0!" elseif vid == true then -- Abbruch bei laufender Videoaufnahme ready = false message1 = "Videoaufnahme ist aktiv," message2 = "bitte erst auschalten!" elseif fixfoc < 0 then ready = false message1 = "Für hyperfocale Distanz wird" message2 = "Programm Av oder M benötigt!" else -- Überprüft bei aktivertem Save Mode, ob die Kamera im Modus P, TV, AV oder M ist: if savemode == 1 then if not (cmode == "P" or cmode == "TV" or cmode == "AV" or cmode == "M") then ready = false message1 = "Save Mode aktiv, bitte" message2 = "P, Tv, Av oder M wählen!" end end end -- Überprüft, ob das manuelle Aktivieren/Deaktiveren des LCD bei Skriptstart zugelassen wurde: if ready == true then if lcd_err == true then ready = false message1 = "Eine man. LCD-Abschaltung be-" message2 = "nötigt Interv.-Zeiten >= 5 sec!" end end -- ANFANG HAUPTSKRIPT: if ready == true then delay_counter = get_tick_count() -- Zeitnahme für die Startverzögerung -- Setzt die Kamera in den Aufnahmemodus, wenn das Skript im Wiedergabemodus gestartet wurde: if get_mode() == false then print("Aktiviere Aufnahmemodus..") set_record(1) sleep(1000) while get_mode() == false do sleep(50) end print("Aufnahmemodus nun aktiv!") end if (cmode == "M") and (aelock == 1) then aelock = 0 print("Programm M ist aktiv:") print("AE-L wurde deaktiviert!") end if (aflock == 1) or (fixfoc > 0) then check_mf() end if fixfoc > 0 then set_fixfoc() end if (aflock == 1 or aelock == 1) then -- Wahr vor der ersten Aufnahme mit aktiviertem AF- und/oder AE-Lock press("shoot_half") repeat sleep(50) until get_shooting() == true if aflock == 1 then set_aflock(1) focusmode = "AFL bei erstem Bild" end if aelock == 1 then set_aelock(1) end shoot_half = 1 --Aufnahmen werden folgend nur via press/release "shoot_full_only" ausgeführt end -- ANFANG HAUPTSCHLEIFE: delay_real = delay - (get_tick_count() - delay_counter) if delay_real > 0 then print("Warte Verzögerung ab...") sleep(delay_real) end repeat if counter == 0 then pic_first = get_tick_count() end local count2 = get_exp_count() shoot_counter = get_tick_count() pic_last = get_tick_count() if shoot_half == 1 then press("shoot_full_only") repeat sleep(50) until get_exp_count() ~= count2 release("shoot_full_only") else shoot() repeat sleep(50) until get_exp_count() ~= count2 end cls() 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 if (counter < pics) or (pics == 0) then print("Warte Intervallzeit ab...") end if lcd_auto > 0 then --Wahr bei aktiviertem automatischem LCD-Off if (lcd_auto == (counter - 1)) then set_lcd_display(0) lcd = 0 elseif (counter == (pics - 1)) then --Wahr nach dem vorletzten Bild der Intervallserie set_lcd_display(1) lcd = 1 console_redraw() end elseif lcd_man == true then --Wahr bei aktiviertem manuellem LCD-On/Off if counter < pics then wait_key_pressure() --Führe das Unterprogamm für die Tastaturabfrage aus else --Wahr nach dem letzten Bild der Intervallserie if lcd == 0 then set_lcd_display(1) --Das Display wird wieder eingeschaltet lcd = 1 console_redraw() end end end if counter < pics then interval_real = interval - (get_tick_count() - shoot_counter) if (interval_real > 0) and (counter < pics or pics == 0) then sleep(interval_real) end end until (pics > 0) and (counter == pics) restore() else print("FEHLER:") print(message1) print(message2) sleep(3000) end