Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.42 KB | None | 0 0
  1.  
  2. import RPi.GPIO as GPIO
  3. from time import sleep
  4. import os
  5. from subprocess import check_output
  6.  
  7. GPIO.setmode(GPIO.BCM)
  8. GPIO.setup(21, GPIO.IN, pull_up_down=GPIO.PUD_UP)
  9. status = 0
  10.  
  11. while True:
  12.     input_state = GPIO.input(21)
  13.        if input_state == False:
  14.         if status == 0:
  15.         print('AV')
  16.         status = 1
  17.         #Switch to AV
  18.         os.system("sudo killall emulationstation; tvservice -c \"PAL 4:3\"; fbset -depth 8; fbset -depth 16; emulationstation")
  19.        else:
  20.         print('HDMI')
  21.         status = 0
  22.         #Switch to HDMI
  23.         os.system("sudo killall emulationstation; tvservice -p; fbset -depth 8; fbset -depth 16; emulationstation")
  24.        time.sleep(0.2)
  25. RAW Paste Data
  26.  
  27. import RPi.GPIO as GPIO
  28. from time import sleep
  29. import os
  30. from subprocess import check_output
  31.  
  32. GPIO.setmode(GPIO.BCM)
  33. GPIO.setup(21, GPIO.IN, pull_up_down=GPIO.PUD_UP)
  34. status = 0
  35.  
  36. while True:
  37.     input_state = GPIO.input(21)
  38.     if input_state == False:
  39.         if status == 0:
  40.             print('AV')
  41.             status = 1
  42.             #Switch to AV
  43.             os.system("sudo killall emulationstation; tvservice -c \"PAL 4:3\"; fbset -depth 8; fbset -depth 16; emulationstation")
  44.     else:
  45.         print('HDMI')
  46.         status = 0
  47.         #Switch to HDMI
  48.         os.system("sudo killall emulationstation; tvservice -p; fbset -depth 8; fbset -depth 16; emulationstation")
  49.         time.sleep(0.2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement