Code cleanup

This commit is contained in:
root 2018-02-11 14:34:25 +01:00
parent f8bcda88f7
commit 6859aecb2b

View File

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