Files
loustique-home/composants/byPanda/septsegments.py

22 lines
624 B
Python
Raw Normal View History

2026-03-30 22:10:28 +02:00
import tm1637
import time as t
2026-04-01 18:39:00 +02:00
_display = None
2026-03-30 22:10:28 +02:00
2026-04-01 18:39:00 +02:00
def get_display():
global _display
if _display is None:
_display = tm1637.TM1637(clk=4, dio=17)
_display.brightness(2)
return _display
2026-03-30 22:10:28 +02:00
2026-03-31 20:36:38 +02:00
def afficher_temperature(temperature, temperature_moyenne):
print(f"Test affichage: Cible {temperature} | Moyenne {temperature_moyenne}")
2026-03-30 22:10:28 +02:00
try:
2026-03-31 20:36:38 +02:00
temp1 = int(temperature)
temp2 = int(temperature_moyenne)
texte_ecran = f"{temp1:02d}{temp2:02d}"
2026-04-01 18:39:00 +02:00
disp = get_display()
disp.show(texte_ecran)
2026-03-30 23:17:08 +02:00
except Exception as e:
2026-03-31 20:36:38 +02:00
print(f"Erreur d'affichage : {e}")