Bouton Quitter admin + boucle reconnexion caméra améliorée
- Admin onglet Système : bouton Quitter (gris) pour fermer l'appli - Reconnexion caméra : max 10 tentatives (~30s) puis bascule en mode simulation ; le loop sim reprend la détection automatique toutes les 10s Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -828,17 +828,24 @@ class PB:
|
||||
if self.cam: self.cam.exit()
|
||||
except: pass
|
||||
self.cam = None; errs = 0
|
||||
while True:
|
||||
time.sleep(3)
|
||||
_usb_reset_done()
|
||||
try:
|
||||
c = gp.Camera(); c.init()
|
||||
self.cam = c; self.prev_actif = True
|
||||
print("Caméra reconnectée automatiquement")
|
||||
break
|
||||
except Exception as re:
|
||||
print(f"Reconnexion échouée: {re}")
|
||||
_nb_retry = 0
|
||||
while _nb_retry < 10:
|
||||
_nb_retry += 1
|
||||
time.sleep(3)
|
||||
_usb_reset_done()
|
||||
try:
|
||||
c = gp.Camera(); c.init()
|
||||
self.cam = c; self.prev_actif = True
|
||||
print("Caméra reconnectée automatiquement")
|
||||
break
|
||||
except Exception as re:
|
||||
print(f"Reconnexion échouée ({_nb_retry}): {re}")
|
||||
else:
|
||||
# 10 tentatives échouées → bascule en simulation
|
||||
self.sim = True
|
||||
print("Caméra introuvable → mode simulation")
|
||||
errs = 0
|
||||
else:
|
||||
time.sleep(0.3)
|
||||
else:
|
||||
time.sleep(0.05)
|
||||
@@ -1913,6 +1920,7 @@ class PB:
|
||||
sq=self._txt("Scanner","xxs",T["texte2"],False); self.scr.blit(sq,(qx+100-sq.get_width()//2,qy+208))
|
||||
# Boutons système
|
||||
y2=card.bottom+20
|
||||
rq=pygame.Rect(W//2-540,y2,160,68); self._btn(rq,(80,80,80),"Quitter","sm"); btns["quitter"]=rq
|
||||
rb=pygame.Rect(W//2-360,y2,320,68); self._btn(rb,(255,152,0),"Redémarrer","sm"); btns["reboot"]=rb
|
||||
re=pygame.Rect(W//2+40,y2,320,68); self._btn(re,(244,67,54),"Éteindre","sm"); btns["shutdown"]=re
|
||||
|
||||
@@ -2093,6 +2101,7 @@ class PB:
|
||||
elif R("lim_m").collidepoint(pos): self._admin_adj("compteur","limite",-50,50,9999)
|
||||
elif R("lim_p").collidepoint(pos): self._admin_adj("compteur","limite",+50,50,9999)
|
||||
elif R("reconnect_cam").collidepoint(pos): threading.Thread(target=self._reconnect_cam,daemon=True).start()
|
||||
elif R("quitter").collidepoint(pos): running=False
|
||||
elif R("reboot").collidepoint(pos): subprocess.Popen(["sudo","reboot"])
|
||||
elif R("shutdown").collidepoint(pos): subprocess.Popen(["sudo","shutdown","-h","now"])
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user