From 5e26adcd4dec946a5b2c422cde7136ac25dfa9f3 Mon Sep 17 00:00:00 2001
From: "nicolas.albanesi" <nicolas.albanesi@etu.hesge.ch>
Date: Thu, 29 Jun 2023 17:04:05 +0200
Subject: [PATCH] Added some stuff for esp com with hepialight

---
 hepialight/main.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/hepialight/main.py b/hepialight/main.py
index 4384b2ff..32ba92e2 100644
--- a/hepialight/main.py
+++ b/hepialight/main.py
@@ -1,5 +1,6 @@
 id = [0,0]
 matsize = [0, 0]
+esp_dir = 0
  
 
 # Display and images functions
@@ -107,6 +108,7 @@ def update_id(new_id):
 
 # Handle the commands received via UART
 def handle_receive(msg, msg_bytes, d):
+    global esp_dir
  
     print("Received from {} : {}".format(d, msg))
 
@@ -140,6 +142,7 @@ def handle_receive(msg, msg_bytes, d):
         x, y = msg.split(";")[-1].split(",")
         print("Matsize : {} {}".format(x, y))
         matsize = [int(x), int(y)]
+        envoyer_msg(esp_dir, "MATSIZE:{},{}".format(x, y))
 
     elif msg.startswith("TEXT"):
         msgs = msg.split(";")
@@ -164,11 +167,16 @@ def handle_receive(msg, msg_bytes, d):
 
     elif msg == "OK":
         update_id(id)
+        esp_dir = d
 
 
 # Main
 afficher_texte("Ready", VERT, speed=0.01)
 
+# Try to find the ESP and start the initialisation
+envoyer_msg(S, "ESP")
+envoyer_msg(O, "ESP")
+
 while True:
 
     for d in [N, S, E, O]:
-- 
GitLab