2026-03-27 13:33:32 +01:00
|
|
|
import time
|
2026-04-02 22:20:07 +02:00
|
|
|
import threading
|
|
|
|
|
import alarme
|
2026-03-27 13:33:32 +01:00
|
|
|
from porterfid import SystemePorteRFID
|
2026-04-02 22:20:07 +02:00
|
|
|
import RPi.GPIO as GPIO
|
2026-03-27 13:33:32 +01:00
|
|
|
|
|
|
|
|
porte = SystemePorteRFID()
|
|
|
|
|
|
2026-04-02 22:20:07 +02:00
|
|
|
def call_board1():
|
|
|
|
|
# 1. On lance l'alarme dans son propre thread pour qu'elle ne bloque pas le reste
|
|
|
|
|
thread_alarme = threading.Thread(target=alarme.boucle_principale, daemon=True)
|
|
|
|
|
thread_alarme.start()
|
2026-03-27 13:33:32 +01:00
|
|
|
|
2026-04-02 22:20:07 +02:00
|
|
|
print("[BOARD 1] Système d'alarme lancé en arrière-plan.")
|
2026-04-01 22:23:25 +02:00
|
|
|
|
2026-04-01 15:54:46 +02:00
|
|
|
try:
|
2026-04-02 22:20:07 +02:00
|
|
|
# 2. La boucle principale ne gère plus que le RFID
|
2026-04-01 15:54:46 +02:00
|
|
|
while True:
|
|
|
|
|
porte.mettreAJour()
|
2026-04-02 22:20:07 +02:00
|
|
|
time.sleep(0.3)
|
2026-03-27 13:33:32 +01:00
|
|
|
|
2026-04-01 15:54:46 +02:00
|
|
|
except KeyboardInterrupt:
|
|
|
|
|
print("\nArrêt manuel du programme.")
|
|
|
|
|
finally:
|
2026-04-02 22:20:07 +02:00
|
|
|
# On utilise GPIO.cleanup() directement car alarme.cleanup n'existe pas
|
2026-04-01 15:54:46 +02:00
|
|
|
porte.cleanup()
|
2026-04-02 22:20:07 +02:00
|
|
|
GPIO.cleanup()
|