--[[ ******************************** Licence: GPL AstroKam by David Wilson of StarryDave.com based on this script https://chdk.fandom.com/wiki/Meteor_Intervalometer_with_Dark_Frame_Management original script by fudgey modified by waterwingz CHDK 1.3 r3250 or higher @chdk_version 1.3 Lua native calls required ******************************** @title AstroKam by Starry Dave @param s Lights Tv (seconds) @default s 300 @range s 1 99999 @param n Lights per darks/biases @default n 5 @range n 1 99999 @param b Biases Tv (microseconds) @default b 100 @range b 1 999999 @param d LCD on ? @default d 1 @range d 0 1 --]] --DEBUG --s=2 --b=100 --n=2 --d=0 --DEBUG shutter = s*1000000 shutterbias = b dark = 1 light = 1 bias = 1 oldraw = get_raw() oldsubtract = get_raw_nr() set_raw(1) set_raw_nr(1) BL = d set_backlight(BL) local bi=get_buildinfo() if bi.os=="vxworks" then closeproc="CloseMShutter" openproc="OpenMShutter" if (call_event_proc("InitializeAdjustmentFunction") == -1) then error("InitAdjFunc failed") end elseif bi.os=="dryos" then closeproc="CloseMechaShutter" openproc="OpenMechaShutter" if (call_event_proc("Mecha.Create") == -1) then if (call_event_proc("MechaRegisterEventProcedure") == -1) then error("Mecha.Create failed") end end else error("Unknown OS:" .. bi.os) end -- close mechanical shutter function closeshutter() if (call_event_proc(closeproc) == -1) then print("closeshutter failed") end end -- open mechanical shutter function openshutter() if (call_event_proc(openproc) == -1) then print("openshutter failed") end end function newname(prefix) lastJPG = string.format("%s%s%04d%s", get_image_dir(), "/IMG_", get_exp_count(), ".JPG") newJPG = string.format("%s%s%s%02d%02d%02d%s", get_image_dir(), "/", prefix, get_time("h"), get_time("m"), get_time("s"), ".JPG") os.rename(lastJPG, newJPG) lastRAW = string.gsub(lastJPG, "IMG_", "CRW_") lastRAW = string.gsub(lastRAW, "JPG", "DNG") newRAW = string.gsub(newJPG, "JPG", "DNG") os.rename(lastRAW, newRAW) end while true do repeat -- Shoot lights for i = 1,n do openshutter() print("Shooting light#", light) set_tv96_direct(usec_to_tv96(shutter)) shoot() light = light + 1 newname("L_") end --Shoot dark closeshutter() print("Shooting dark#", dark) set_tv96_direct(usec_to_tv96(shutter)) shoot() dark = dark + 1 newname("D_") --Shoot bias closeshutter() print("Shooting bias#", bias) set_tv96_direct(usec_to_tv96(shutterbias)) shoot() bias = bias + 1 newname("B_") until not(is_key("no_key")) -- check for key press if ( is_key("display")) then set_backlight(BL) if BL == 1 then BL=0 else BL=1 end elseif (is_pressed("shoot_full")) then break end end -- restore raw settings set_raw(oldraw) set_raw_nr(oldsubtract)