Browse Source

make snapshots faster

main
Hendrik Langer 6 years ago
parent
commit
a392999739
  1. 12
      raspberry-environment/display.py

12
raspberry-environment/display.py

@ -231,8 +231,7 @@ if __name__ == '__main__':
GPIO.output(pin_led_ready, GPIO.HIGH)
GPIO.output(pin_led_busy, GPIO.HIGH)
print('file changed')
subprocess.run(['killall', 'fim'], shell=False, check=False)
subprocess.run(['umount', '/mnt'], shell=False, check=False)
subprocess.run(['mount', '-o', 'loop,ro', '-t', 'vfat', '/tmp/usbdisk.img', '/mnt'], shell=False, check=True)
list_of_files = glob.glob('/mnt/*.png')
@ -244,8 +243,13 @@ if __name__ == '__main__':
if list_of_files:
latest_file = max(list_of_files, key=os.path.getctime)
file_name, extension = os.path.splitext(latest_file)
tmpfilename = '/tmp/frame'+extension
print(latest_file)
subprocess.run('fim -d /dev/fb0 -T 1 --autozoom --quiet "'+latest_file+'" &', shell=True)
subprocess.run(['killall', 'fim'], shell=False, check=False)
subprocess.run('cp "'+latest_file+'" "'+tmpfilename+'"', shell=True, check=True)
subprocess.run('fim -d /dev/fb0 -T 1 --autozoom --quiet "'+tmpfilename+'" &', shell=True)
subprocess.run(['umount', '/mnt'], shell=False, check=False)
GPIO.output(pin_led_busy, GPIO.LOW)
def callback_switch(channel):
@ -253,7 +257,7 @@ if __name__ == '__main__':
GPIO.add_event_detect(pin_switch, GPIO.FALLING, callback=callback_switch, bouncetime=250)
watch_delay_call('/tmp/usbdisk.img', callback, 0.5, True, pyinotify.IN_MODIFY)
watch_delay_call('/tmp/usbdisk.img', callback, 0.2, True, pyinotify.IN_MODIFY)
finally:
GPIO.output(pin_led_busy, GPIO.LOW)

Loading…
Cancel
Save