|
|
@ -13,6 +13,10 @@ import time |
|
|
|
import subprocess |
|
|
|
import glob |
|
|
|
|
|
|
|
pin_led_ready=27 |
|
|
|
pin_led_busy=5 |
|
|
|
pin_switch=13 |
|
|
|
|
|
|
|
try: |
|
|
|
import RPi.GPIO as GPIO |
|
|
|
except RuntimeError: |
|
|
@ -125,15 +129,17 @@ def os_echo_bin(filename, string): |
|
|
|
def send_keypress(): |
|
|
|
with open('/dev/hidg0', 'wb') as f: |
|
|
|
f.write(bytearray(b'\x00\x00\x04\x00\x00\x00\x00\x00')) #press the A-button |
|
|
|
time.sleep(0.05) |
|
|
|
f.write(bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')) #release all keys |
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
GPIO.setmode(GPIO.BCM) |
|
|
|
GPIO.setup(18, GPIO.OUT) |
|
|
|
GPIO.setup(23, GPIO.OUT) |
|
|
|
GPIO.output(18, GPIO.LOW) |
|
|
|
GPIO.output(23, GPIO.LOW) |
|
|
|
GPIO.setup(pin_led_ready, GPIO.OUT) |
|
|
|
GPIO.setup(pin_led_busy, GPIO.OUT) |
|
|
|
GPIO.setup(pin_switch, GPIO.IN, pull_up_down=GPIO.PUD_UP) |
|
|
|
GPIO.output(pin_led_ready, GPIO.LOW) |
|
|
|
GPIO.output(pin_led_busy, GPIO.LOW) |
|
|
|
|
|
|
|
g="/sys/kernel/config/usb_gadget/freezer/" |
|
|
|
|
|
|
@ -219,8 +225,8 @@ if __name__ == '__main__': |
|
|
|
# if paths: |
|
|
|
# for path in paths: |
|
|
|
# print(' {0}'.format(path)) |
|
|
|
GPIO.output(18, GPIO.HIGH) |
|
|
|
GPIO.output(23, GPIO.HIGH) |
|
|
|
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) |
|
|
@ -234,14 +240,18 @@ if __name__ == '__main__': |
|
|
|
latest_file = max(list_of_files, key=os.path.getctime) |
|
|
|
print(latest_file) |
|
|
|
subprocess.run('fim -d /dev/fb0 -T 1 --autozoom --quiet "'+latest_file+'" &', shell=True) |
|
|
|
GPIO.output(23, GPIO.LOW) |
|
|
|
GPIO.output(pin_led_busy, GPIO.LOW) |
|
|
|
|
|
|
|
def callback_switch(channel): |
|
|
|
send_keypress() |
|
|
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
|
|
|
finally: |
|
|
|
GPIO.output(23, GPIO.LOW) |
|
|
|
GPIO.output(18, GPIO.LOW) |
|
|
|
GPIO.output(pin_led_busy, GPIO.LOW) |
|
|
|
GPIO.output(pin_led_ready, GPIO.LOW) |
|
|
|
subprocess.run(['killall', 'fim'], shell=False, check=False) |
|
|
|
subprocess.run(['umount', '/mnt'], shell=False, check=False) |
|
|
|
os_echo(g+"UDC", "") |
|
|
|