evenements:obc2012:dikogeek
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| obc2012:dikogeek [2013/05/03 16:40] – [Interaction homme/machine] florianh | evenements:obc2012:dikogeek [2024/04/26 14:48] (Version actuelle) – modification externe 127.0.0.1 | ||
|---|---|---|---|
| Ligne 107: | Ligne 107: | ||
| #Import des librairies nécessaires | #Import des librairies nécessaires | ||
| + | import select, time | ||
| + | import sys, tty, termios | ||
| import os | import os | ||
| + | import pygame | ||
| import subprocess, signal | import subprocess, signal | ||
| - | import RPi.GPIO as GPIO | ||
| - | GPIO.setmode(GPIO.BCM) | ||
| from subprocess import Popen, PIPE | from subprocess import Popen, PIPE | ||
| + | from pygame.locals import * | ||
| + | #import RPi.GPIO as GPIO | ||
| + | # | ||
| + | from evdev import InputDevice, | ||
| + | dev = InputDevice('/ | ||
| + | fpid = os.fork() | ||
| + | if fpid!=0: | ||
| + | # | ||
| + | sys.exit(0) | ||
| + | |||
| # | # | ||
| - | GPIO.setup(23, | + | #GPIO.setup(23, |
| - | GPIO.setup(17, | + | #GPIO.setup(17, |
| - | #Création d'une fonction de rappel | + | pygame.init() |
| - | def my_callback(channel): | + | pygame.display.init() |
| - | print ("Lancement clip 1") | + | def accueil(): |
| + | ecran = pygame.display.set_mode((0, | ||
| + | image = pygame.image.load("/ | ||
| + | ecran.blit(image, | ||
| + | pygame.display.flip() # | ||
| + | |||
| + | #Fonction appelé lors d'un appuie bouton | ||
| + | def fct_movie(channel): | ||
| + | ecran = pygame.display.set_mode((0, | ||
| + | image = pygame.image.load("/ | ||
| + | ecran.blit(image, | ||
| + | pygame.display.flip() # | ||
| #Lancement d'un sous process pour récuperer la liste des processes en cours | #Lancement d'un sous process pour récuperer la liste des processes en cours | ||
| - | p = subprocess.Popen([' | + | p = subprocess.Popen([' |
| - | out, err = p.communicate() | + | |
| - | + | ||
| - | #Listing des process | + | |
| - | for line in out.splitlines(): | + | |
| - | #On recherche si le lecteur video est en route | + | |
| - | if ' | + | |
| - | pid = int(line.split(None, | + | |
| - | #On Kill le process | + | |
| - | os.kill(pid, | + | |
| - | #Lencement d'un sous process pour lancer le clip | + | |
| - | p = subprocess.Popen([' | + | |
| - | ocess.PIPE, | + | |
| #Vérifie si le process se termine naturellement | #Vérifie si le process se termine naturellement | ||
| - | | + | |
| - | + | if dev.read_one() is not None: | |
| - | #Si le process c'est terminé naturellement, | + | os.killpg(p.pid, signal.SIGKILL) |
| - | if retcode | + | break |
| - | print " | + | |
| - | os.system(" | + | accueil() |
| - | + | ||
| - | def my_callback2(channel): | + | |
| - | print (" | + | |
| - | p = subprocess.Popen([' | + | |
| - | out, err = p.communicate() | + | |
| - | + | ||
| - | for line in out.splitlines(): | + | |
| - | if ' | + | |
| - | pid = int(line.split(None, | + | |
| - | | + | |
| - | p = subprocess.Popen([' | + | |
| - | rocess.PIPE, | + | |
| - | | + | |
| - | + | ||
| - | if retcode | + | |
| - | print " | + | |
| - | os.system(" | + | |
| - | + | ||
| # | # | ||
| - | GPIO.add_event_detect(17, | + | #GPIO.add_event_detect(17, |
| - | GPIO.add_event_detect(23, | + | #GPIO.add_event_detect(23, |
| - | + | accueil() | |
| - | #Permet de bloquer le programme pour éviter qu'il se termine tout seul | + | for event in dev.read_loop(): |
| - | raw_input("> ") | + | if (event.code == ecodes.KEY_A and event.value == 0): |
| + | fct_movie('fablab' | ||
| + | if (event.code == ecodes.KEY_B and event.value == 0): | ||
| + | fct_movie(2) | ||
| + | if (event.code == ecodes.KEY_C and event.value == 0): | ||
| + | fct_movie(3) | ||
| + | if (event.code == ecodes.KEY_D and event.value == 0): | ||
| + | fct_movie(' | ||
| + | pygame.display.quit() | ||
| + | pygame.quit() | ||
| </ | </ | ||
| - | |||
| - | |||
evenements/obc2012/dikogeek.1367592054.txt.gz · Dernière modification : 2024/04/26 14:48 (modification externe)
