allowing camera events to trigger lua functions would be wonderful, but strikes me as a more complicated request.
I'm trying to figure out how my code can be loosely coupled. with my current timelapse code, my logging code and exif editing code ends up in my "take a pic" code -
function cam.smartShoot(default_sv,focusDistance, name, calcShotSettings)
local dirCountRename
if (name ~= nil) then
dirCountRename = disk.itemCount("A/DCIM/100CANON")
end
--press shutter half
press("shoot_half")
repeat
sleep(1)
until get_shooting() == true
--get exposure
local bv=get_bv96()
local av=get_av96()
--calc camera settings
shoot_tv, shoot_sv, shoot_av = calcShotSettings(bv,av,default_sv)
set_prop(propcase.TV,shoot_tv)
set_prop(propcase.SV,shoot_sv)
set_prop(propcase.AV,shoot_av)
set_focus(65535)
--press shutter
press("shoot_full")
sleep(1)
release("shoot_full")
sleep(1)
release("shoot_half")
repeat
sleep(1)
until get_shooting() ~= true
--rename file
if (name ~= nil) then
sleepCount = 0
local currentCount
repeat
sleep(1)
sleepCount = sleepCount + 1
--get directory count and currnet directory count
currentCount = disk.itemCount("A/DCIM/100CANON")
until currentCount > dirCountRename
--get from current directory
local currentFile = disk.getNewImage("100CANON")
local image = JPEGImage
image:new(currentFile)
image:SetUserComment("timestamp, " .. date.datetimestamp() .. ", shoot_tv," .. shoot_tv .. ", shoot_sv," .. shoot_sv .. ",shoot_av," .. shoot_av .. ",bv," .. bv .. ",currentFile," .. currentFile .. ",newName," .. name .. ",optical_temp," .. get_temperature(0) .. ",ccd_temp," .. get_temperature(1) .. ", batt_temp," .. get_temperature(2) )
local currentFileDir = string.sub(currentFile,1,16)
--local currentFileNumber = string.sub(currentFile, -8,-5)
local currentFileNumber = string.sub(currentFile, -7,-5)
os.rename(currentFile,currentFileDir..name)
print(currentFileNumber)
log.print("new file name \t",currentFile, "\t current count \t",currentCount)
if(tonumber(currentFileNumber) > 990) then
log.print("cam.smartShoot - restart due to file count")
shut_down()
end
end
--log.print("cam.smartShoot - end")
end
i can see some places where my conditionals could be better, but aside from that, how could this code be improved?