Code cleanup
This commit is contained in:
parent
f8bcda88f7
commit
6859aecb2b
28
photobox.py
28
photobox.py
@ -215,15 +215,11 @@ def waitForBegin():
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def countdown(camera, pad, img, flash):
|
def countdown(camera, pad, img):
|
||||||
sleep(PIC_INTERVAL)
|
sleep(PIC_INTERVAL)
|
||||||
o = camera.add_overlay(pad.tostring(), size=img.size)
|
o = camera.add_overlay(pad.tostring(), size=img.size)
|
||||||
o.alpha = OVERLAY_ALPHA
|
o.alpha = OVERLAY_ALPHA
|
||||||
o.layer = 3
|
o.layer = 3
|
||||||
# if flash:
|
|
||||||
# GPIO.output(7, GPIO.HIGH)
|
|
||||||
# sleep(0.01)
|
|
||||||
# GPIO.output(7, GPIO.LOW)
|
|
||||||
sleep(TEXT_INTERVAL)
|
sleep(TEXT_INTERVAL)
|
||||||
camera.remove_overlay(o)
|
camera.remove_overlay(o)
|
||||||
|
|
||||||
@ -245,7 +241,7 @@ def makePhotos():
|
|||||||
# COUNTDOWN
|
# COUNTDOWN
|
||||||
GPIO.output(7, GPIO.HIGH)
|
GPIO.output(7, GPIO.HIGH)
|
||||||
for i in range(0, COUNTDOWN):
|
for i in range(0, COUNTDOWN):
|
||||||
countdown(camera, pad_cdn[i], img_cdn[i], True)
|
countdown(camera, pad_cdn[i], img_cdn[i])
|
||||||
GPIO.output(7, GPIO.LOW)
|
GPIO.output(7, GPIO.LOW)
|
||||||
|
|
||||||
# SHOTS
|
# SHOTS
|
||||||
@ -300,7 +296,7 @@ def chooseImages():
|
|||||||
cancel = False
|
cancel = False
|
||||||
any_choice = False
|
any_choice = False
|
||||||
while not cancel and (not save or not any_choice):
|
while not cancel and (not save or not any_choice):
|
||||||
# reset save (due to no choice made)
|
# reset save (if nothing selected)
|
||||||
save = False
|
save = False
|
||||||
|
|
||||||
# draw background
|
# draw background
|
||||||
@ -336,6 +332,7 @@ def chooseImages():
|
|||||||
i = int(floor((pos[0] - BORDER / 2) / (THUMB_WIDTH + BORDER)))
|
i = int(floor((pos[0] - BORDER / 2) / (THUMB_WIDTH + BORDER)))
|
||||||
if i >= 0 and i < SHOT_COUNT:
|
if i >= 0 and i < SHOT_COUNT:
|
||||||
choices[i] = (choices[i] + 1) % 2
|
choices[i] = (choices[i] + 1) % 2
|
||||||
|
|
||||||
elif pos[1] < 100:
|
elif pos[1] < 100:
|
||||||
# top menu buttons
|
# top menu buttons
|
||||||
if pos[0] > 0 and pos[0] < 266:
|
if pos[0] > 0 and pos[0] < 266:
|
||||||
@ -349,9 +346,6 @@ def chooseImages():
|
|||||||
any_choice = True
|
any_choice = True
|
||||||
break
|
break
|
||||||
|
|
||||||
# END: choice
|
|
||||||
#~ print("# END: choice")
|
|
||||||
|
|
||||||
return (choices, save)
|
return (choices, save)
|
||||||
|
|
||||||
|
|
||||||
@ -368,26 +362,24 @@ def saveImages(choices):
|
|||||||
os.rename("tmp%s.jpg" % i, IMAGE_DIR + "/original/" + filename)
|
os.rename("tmp%s.jpg" % i, IMAGE_DIR + "/original/" + filename)
|
||||||
copyfile(IMAGE_DIR + "/original/" + filename, IMAGE_DIR + "/todo/" + filename)
|
copyfile(IMAGE_DIR + "/original/" + filename, IMAGE_DIR + "/todo/" + filename)
|
||||||
|
|
||||||
# show message
|
|
||||||
screen.fill(COLOR_BACK)
|
|
||||||
screen.blit(saved, saved_rect)
|
|
||||||
pygame.display.flip()
|
|
||||||
sleep(2)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
while 1:
|
while 1:
|
||||||
waitForBegin()
|
waitForBegin()
|
||||||
|
|
||||||
makePhotos()
|
makePhotos()
|
||||||
(choices, save) = chooseImages()
|
(choices, save) = chooseImages()
|
||||||
|
|
||||||
if save:
|
if save:
|
||||||
saveImages(choices);
|
saveImages(choices);
|
||||||
|
screen.fill(COLOR_BACK)
|
||||||
|
screen.blit(saved, saved_rect)
|
||||||
|
pygame.display.flip()
|
||||||
else:
|
else:
|
||||||
# show message
|
|
||||||
screen.fill(COLOR_BACK)
|
screen.fill(COLOR_BACK)
|
||||||
screen.blit(canceled, canceled_rect)
|
screen.blit(canceled, canceled_rect)
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
|
|
||||||
sleep(2)
|
sleep(2)
|
||||||
|
|
||||||
|
|
||||||
pygame.quit()
|
pygame.quit()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user