-
Notifications
You must be signed in to change notification settings - Fork 0
/
lexi.lua
149 lines (128 loc) · 3.03 KB
/
lexi.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
-- MagicLantern long exposure intervalometer for stacking
-- v0.01 by Pizzi DellaMaremma
-- ********************************************************
require("logger")
TestBeepNoShutter = 0
--local log = logger("LEXI.LOG")
--log:write("LEXI - Init logging\n")
lexi = menu.new
{
parent = "Shoot",
name = "LExI",
help = "Long Exposure Intervalometer (w/reps)",
submenu =
{
{
name = "Enable",
help = "Enable LEXI",
choices = {"Off","On"}
},
{
name = "Initial delay",
help = "Initial delay after shutter start.",
min = 5,
max = 20,
value = 10,
unit = UNIT.TIME
},
{
name = "Exposure length",
help = "Length of the exposure.",
min = 0,
max = 900,
value = 20,
unit = UNIT.TIME
},
{
name = "Delay",
help = "Delay between shoots.",
min = 5,
max = 30,
value = 8,
unit = UNIT.TIME
},
{
name = "Repetitions",
help = "Number of repetitions.",
min = 1,
max = 999,
value = 1,
unit = UNIT.INT
},
{
name = "Debug",
help = "Enable logfile inside ML directory.",
choices = {"Off", "On"},
value = "Off"
},
}
}
-- Utility function: countdown in seconds
function countdown(sec)
while sec > 0 do
display.notify_box(string.format("Starting in %ss", sec))
task.yield(1000)
sec = sec - 1
end
end
-- Add some checks to verify before starting (return bool)
function check_control() -- Check before starting cycle
-- Bulb mode
if camera.mode ~= MODE.BULB then
display.notify_box("LEXI checks - Not in Bulb!")
return false
end
-- TO REMOVE
-- display.notify_box(string.format("Camera AF: %s", lens.af))
-- task.yield(10000)
-- TO REMOVE
if lens.af == true then
display.notify_box("LEXI checks - Disable AF!")
return false
end
return true
end
-- Main function
function main(init_delay, exp_length, dly, reps) -- Execute the cycle
display.notify_box("Starting LEXI...")
task.yield(500)
-- Initial delay
countdown(init_delay)
-- Repeated shots
local n = 1
for i = reps, 0, -1 do
display.notify_box(string.format("Running shot %s", n))
if TestBeepNoShutter == 0 then
camera.bulb(exp_length)
task.yield(10)
else
beep(1,50)
task.yield(600 + camera.shutter.ms)
end
-- Delay between shots
if n < reps then
countdown(dly)
elseif n == reps then
break
end
n = n + 1 -- Increment n (shot number)
end
end
-- Trigger function
function event.keypress(key)
-- check halfshutter and enable
if key == KEY.HALFSHUTTER and lexi.submenu["Enable"].value == "On" then
-- Check function
if check_control() == true then
-- Call the cycle
main(
lexi.submenu["Initial delay"].value,
lexi.submenu["Exposure length"].value,
lexi.submenu["Delay"].value,
lexi.submenu["Repetitions"].value
)
-- ERROR: BLOCK NEW CYCLE
lexi.submenu["Enable"].value = "Off"
end
end
end