Nantes Université

Skip to content
Extraits de code Groupes Projets
Vérifiée Valider e791d0b5 rédigé par Nils Van Zuijlen's avatar Nils Van Zuijlen
Parcourir les fichiers

fix(affichage): launch in process instead of thread

parent 9d6d844c
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
import time import time
import pygame import pygame
import os from pathlib import Path
import sys import sys
import random import random
...@@ -10,6 +10,8 @@ frame_count = 0 ...@@ -10,6 +10,8 @@ frame_count = 0
labgreen = (51, 202, 127) labgreen = (51, 202, 127)
labblue = (0, 54, 103) labblue = (0, 54, 103)
IMAGES_FOLDER = Path(__file__).parent / "images"
def load_image(name): def load_image(name):
image = pygame.image.load(name) image = pygame.image.load(name)
return image return image
...@@ -18,13 +20,9 @@ def gen_next_think_time(): ...@@ -18,13 +20,9 @@ def gen_next_think_time():
class Affichage: class Affichage:
def __init__(self): def __init__(self):
pygame.init() pygame.init()
if __name__=="__main__":
os.chdir("images")
else:
os.chdir(os.path.join("robot", "afficheur", "images"))
self.logo_lab = load_image("logo_lab.jpg") self.logo_lab = load_image(IMAGES_FOLDER / "logo_lab.jpg")
self.thonk = load_image("thonk.png") self.thonk = load_image(IMAGES_FOLDER / "thonk.png")
if sys.platform == "linux": if sys.platform == "linux":
self.screen = pygame.display.set_mode((800, 480), pygame.FULLSCREEN) self.screen = pygame.display.set_mode((800, 480), pygame.FULLSCREEN)
else:#if we aren't on a raspberry pi we should use the windowed mode for testing else:#if we aren't on a raspberry pi we should use the windowed mode for testing
......
...@@ -4,7 +4,7 @@ from robot.actionneurs.com_arduino_i2c import sendI2CData ...@@ -4,7 +4,7 @@ from robot.actionneurs.com_arduino_i2c import sendI2CData
from robot.actionneurs.op_codes import * from robot.actionneurs.op_codes import *
from robot.afficheur.affichage_statique_thread import main from robot.afficheur.affichage_statique_thread import main
import time import time
import threading import multiprocessing
class DemoSquareRobot(Robot): class DemoSquareRobot(Robot):
...@@ -12,7 +12,7 @@ class DemoSquareRobot(Robot): ...@@ -12,7 +12,7 @@ class DemoSquareRobot(Robot):
start_position = pl.PositionRobot(pl.PointImage(200, 200), 60) start_position = pl.PositionRobot(pl.PointImage(200, 200), 60)
def execute_strategy(self): def execute_strategy(self):
score = threading.Thread(target=main,args=(40,)) score = multiprocessing.Process(target=main, args=(40,))
score.start() score.start()
#on allume le ruban de led en vert au début du match #on allume le ruban de led en vert au début du match
sendI2CData("LLRs1") sendI2CData("LLRs1")
......
from robot import Robot from robot import Robot
from robot.movement import positionLib as pl from robot.movement import positionLib as pl
import time as t import time as t
import multiprocessing
class DemoRobot(Robot): class DemoRobot(Robot):
score = threading.Thread(target=main,args=(52,))
score.start()
def execute_strategy(self): def execute_strategy(self):
t.sleep(100)#devrait permettre de tester l'affichage score = multiprocessing.Process(target=main, args=(52,))
score.start()
t.sleep(100) #devrait permettre de tester l'affichage
def run(): def run():
......
...@@ -4,7 +4,7 @@ from robot.actionneurs.com_arduino_i2c import sendI2CData ...@@ -4,7 +4,7 @@ from robot.actionneurs.com_arduino_i2c import sendI2CData
from robot.actionneurs.op_codes import * from robot.actionneurs.op_codes import *
from robot.afficheur.affichage_statique_thread import main from robot.afficheur.affichage_statique_thread import main
import time import time
import threading import multiprocessing
class DemoSquareRobot(Robot): class DemoSquareRobot(Robot):
...@@ -12,7 +12,7 @@ class DemoSquareRobot(Robot): ...@@ -12,7 +12,7 @@ class DemoSquareRobot(Robot):
start_position = pl.PositionRobot(pl.PointImage(2800, 200), -60) start_position = pl.PositionRobot(pl.PointImage(2800, 200), -60)
def execute_strategy(self): def execute_strategy(self):
score = threading.Thread(target=main,args=(52,)) score = multiprocessing.Process(target=main, args=(52,))
score.start() score.start()
#on allume le ruban de led en vert au début du match #on allume le ruban de led en vert au début du match
sendI2CData("LLRs1") sendI2CData("LLRs1")
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter