Last active
August 29, 2015 14:17
-
-
Save Others/6e3ef8c922ed1aa0507d to your computer and use it in GitHub Desktop.
The balloon camera program for Catlin Gabel's 2015 high altitude balloon Winterim.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function logData(data) | |
print_screen(-1) | |
print(data) | |
print_screen(false) | |
end | |
function sleepSeconds(seconds) | |
if seconds > 0 then | |
sleep(seconds * 1000) | |
end | |
end | |
function beep() | |
play_sound(6) | |
end | |
function getMoviePlaying() | |
return get_movie_status() == 4 | |
end | |
function getMovieOver() | |
return get_movie_status() < 2 | |
end | |
function takePicture() | |
press("shoot_full") | |
repeat sleep(50) until get_shooting() | |
release("shoot_full") | |
repeat sleep(50) until not get_shooting() | |
logData("[Info] Took picture") | |
end | |
function takeVideo(seconds) | |
press("video") | |
repeat sleep(50) until getMoviePlaying() | |
release("video") | |
sleepSeconds(seconds) | |
press("video") | |
repeat sleep(50) until getMovieOver() | |
release("video") | |
logData("[Info] Took video of length " .. seconds) | |
end | |
function takePicturesForTime(seconds, delay) | |
delay = delay or 0 | |
local startTime = os.time() | |
repeat | |
takePicture() | |
sleepSeconds(delay) | |
until os.difftime(os.time(), startTime) >= seconds | |
logData("[Info] Took pictures for " .. seconds .. " seconds") | |
end | |
--[Todo] write a better schedule | |
sleepSeconds(10) --Wait for the launch to complete | |
launchTime = os.time() --Record the launch time | |
beep() --Alert that pictures are about to be taken | |
while true do | |
takeVideo(10) | |
takePicturesForTime(60) | |
logData("[Info] Ran loop once, we've been running for " .. os.difftime(os.time(), launchTime)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment