Skip to content

Commit

Permalink
bux fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricardosgeral committed Feb 26, 2019
1 parent 2a36149 commit 764463a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
4 changes: 0 additions & 4 deletions camera_timelapse.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,3 @@ def run(self):
self.CaptureImage()


def delImages(picsLocation):
for f in os.listdir(picsLocation):
if re.search(".jpg", f): # if the file has the extension .jpg
os.remove(os.path.join(picsLocation, f)) #remove the file
12 changes: 4 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,10 @@ def read_display_write(e_rdw): # read and display data in page "record" and writ

# check if timelapse, movie and delete photos are selected
doTimelapse = nxlib.nx_getValue(ser, nxApp.ID_doTimeLapse[0], nxApp.ID_doTimeLapse[1]) # 1 = yes
doMovie = nxlib.nx_getValue(ser, nxApp.ID_doVideo[0], nxApp.ID_doVideo[1])
delImages = nxlib.nx_getValue(ser, nxApp.ID_delImages[0], nxApp.ID_delImages[1])
doMovie = nxlib.nx_getValue(ser, nxApp.ID_doVideo[0], nxApp.ID_doVideo[1]) # 1 = yes
delImages = nxlib.nx_getValue(ser, nxApp.ID_delImages[0], nxApp.ID_delImages[1]) # 1 = yes
# parameters required for the video
control = nxlib.nx_getValue(ser, nxApp.ID_choiceVideoDur[0], nxApp.ID_choiceVideoDur[1])
control = nxlib.nx_getValue(ser, nxApp.ID_choiceVideoDur[0], nxApp.ID_choiceVideoDur[1]) # 0 = freq; 1 = max duration
freq = nxlib.nx_getText(ser, nxApp.ID_freqPics[0], nxApp.ID_freqPics[1])
max_vid_dur = nxlib.nx_getText(ser, nxApp.ID_maxVideoDur[0], nxApp.ID_maxVideoDur[1])
interval = nxlib.nx_getText(ser, nxApp.ID_interval[0], nxApp.ID_interval[1])
Expand Down Expand Up @@ -432,13 +432,9 @@ def read_display_write(e_rdw): # read and display data in page "record" and writ
### time to make video
if doMovie == 1:
# make video in a separate thread
t_movie = movie.makemovie(picsLocation, testname[:-4], control, freq, max_vid_dur, elapsed, interval)
t_movie = movie.makemovie(picsLocation, testname[:-4], control, freq, max_vid_dur, elapsed, interval, delImages)
t_movie.start()

if delImages == 1:
# delete images
cm.delImages(picsLocation)

# disconnect from database
test_end() # morse code sounds to alert for final test

Expand Down
11 changes: 10 additions & 1 deletion movie_timelapse.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
import threading
import subprocess
import datetime
import re

class makemovie(threading.Thread):

def __init__(self, picsLocation, testname, control, freq, max_vid_dur, elapsed, interval):
def __init__(self, picsLocation, testname, control, freq, max_vid_dur, elapsed, interval, delImages):
# initialize the inherited Thread object
threading.Thread.__init__(self)
self.daemon = True
Expand All @@ -15,6 +17,7 @@ def __init__(self, picsLocation, testname, control, freq, max_vid_dur, elapsed,
self.max_vid_dur=max_vid_dur
self.elapsed=elapsed
self.interval=interval
self.delImages = delImages
# create a data lock
self.my_lock = threading.Lock()

Expand All @@ -32,5 +35,11 @@ def MovieMaker(self):
process.wait(timeout=10)
print('time-lapse movie done')

# delete images if desired
if self.delImages == 1:
for f in os.listdir(self.picsLocation):
if re.search(".jpg", f): # if the file has the extension .jpg
os.remove(os.path.join(self.picsLocation, f)) # remove the file
print('time-lapse images deleted')
def run(self):
self.MovieMaker()
2 changes: 1 addition & 1 deletion shutdown_reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ def reboot_pi():

def shutdown_pi():
nxlib.nx_setsys(ser, 'bkcmd',0) # sets in NEXTION 'no return error/success codes'
nxlib.nx_setcmd_1par(ser,'page',10) # sends screen to page 9 "shutdown"
nxlib.nx_setcmd_1par(ser,'page',11) # sends screen to page 9 "shutdown"

0 comments on commit 764463a

Please sign in to comment.