félicitations

This commit is contained in:
2026-04-03 18:35:33 +02:00
parent 9770617cd4
commit f275ad60f0
6 changed files with 154 additions and 164 deletions

View File

@@ -3,48 +3,44 @@ import time as t
from septsegments import afficher_temperature
from DHT11 import lire_temperature
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
# --- Configuration des Pins ---
bouton_up = 23
bouton_down = 24
GPIO.setup(bouton_up, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(bouton_down, GPIO.IN, pull_up_down=GPIO.PUD_UP)
# --- Variables Globales Partagées ---
temperature_cible = 18
def setup_boutons():
"""Initialisation des GPIO (à appeler au début)"""
GPIO.setmode(GPIO.BCM)
GPIO.setup(bouton_up, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(bouton_down, GPIO.IN, pull_up_down=GPIO.PUD_UP)
def test_boutons():
global temperature_cible
setup_boutons()
temperature_DHT = lire_temperature()
temperature_cible = 18
etatPrecedent_up = GPIO.input(bouton_up)
etatPrecedent_down = GPIO.input(bouton_down)
etatPrecedent_up = GPIO.input(bouton_up)
etatPrecedent_down = GPIO.input(bouton_down)
print("Thermostat lancé ! Appuie sur UP (23) ou DOWN (24).")
print(f"Thermostat lancé ! Cible actuelle : {temperature_cible}°C")
afficher_temperature(temperature_DHT, temperature_cible)
while True:
etat_up = GPIO.input(bouton_up)
etat_down = GPIO.input(bouton_down)
if etat_up != etatPrecedent_up:
if etat_up == 0:
print("Bouton UP Appuyé ⬆️")
temperature_cible += 1
if temperature_cible >= 40:
temperature_cible = 40
afficher_temperature(temperature_DHT, temperature_cible)
etatPrecedent_up = etat_up
if etat_up == 0 and etatPrecedent_up == 1:
temperature_cible = min(40, temperature_cible + 1)
print(f"Bouton UP -> Nouvelle cible : {temperature_cible}")
afficher_temperature(lire_temperature(), temperature_cible)
if etat_down != etatPrecedent_down:
if etat_down == 0:
print("Bouton DOWN Appuyé ⬇️")
temperature_cible -= 1
if temperature_cible <= 0:
temperature_cible = 0
afficher_temperature(temperature_DHT, temperature_cible)
etatPrecedent_down = etat_down
t.sleep(0.05)
if etat_down == 0 and etatPrecedent_down == 1:
temperature_cible = max(0, temperature_cible - 1)
print(f"Bouton DOWN -> Nouvelle cible : {temperature_cible}")
afficher_temperature(lire_temperature(), temperature_cible)
etatPrecedent_up = etat_up
etatPrecedent_down = etat_down
t.sleep(0.05)