From 8b5eee717ca2043d4b0d0eb8378a3051af0ab2fd Mon Sep 17 00:00:00 2001
From: antoinekia <antoinekia@gmail.com>
Date: Tue, 21 Feb 2023 16:27:19 +0100
Subject: [PATCH] cleanup

---
 .gitignore                                    |   1 +
 .../ChestsTrigonometryHelper.cpp              |  24 ---
 formation_web_esp/ChestsTrigonometryHelper.h  |  13 --
 formation_web_esp/LedMatrixHelper.cpp         |  17 --
 formation_web_esp/LedMatrixHelper.h           |  16 --
 formation_web_esp/desktop.ini                 |   2 -
 formation_web_esp/formation_web_esp.ino       | 149 ------------------
 7 files changed, 1 insertion(+), 221 deletions(-)
 create mode 100644 .gitignore
 delete mode 100644 formation_web_esp/ChestsTrigonometryHelper.cpp
 delete mode 100644 formation_web_esp/ChestsTrigonometryHelper.h
 delete mode 100644 formation_web_esp/LedMatrixHelper.cpp
 delete mode 100644 formation_web_esp/LedMatrixHelper.h
 delete mode 100644 formation_web_esp/desktop.ini
 delete mode 100644 formation_web_esp/formation_web_esp.ino

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b3f7f10
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+desktop.ini
\ No newline at end of file
diff --git a/formation_web_esp/ChestsTrigonometryHelper.cpp b/formation_web_esp/ChestsTrigonometryHelper.cpp
deleted file mode 100644
index f0ea503..0000000
--- a/formation_web_esp/ChestsTrigonometryHelper.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-#include "ChestsTrigonometryHelper.h"
-
-double getHorizontalDistanceToRequiredChest(JsonArray requiredChests, int requiredChestIdx, double px, double pz) {
-  if (requiredChestIdx >= requiredChests.size()) return -1.0;
-  double cx = requiredChests[requiredChestIdx]["location"]["x"].as<double>();
-  double cz = requiredChests[requiredChestIdx]["location"]["z"].as<double>();
-  return sqrt(pow(cx-px, 2) + pow(cz-pz, 2));
-}
-
-double getVerticalDistanceToRequiredChest(JsonArray requiredChests, int requiredChestIdx, double py) {
-  if (requiredChestIdx >= requiredChests.size()) return -1.0;  
-  double cy = requiredChests[requiredChestIdx]["location"]["y"].as<double>();
-  return abs(cy-py);
-}
-
-double getAngleDirectionDifferenceToRequiredChest(JsonArray requiredChests, int requiredChestIdx, double px, double pz, double pRot) {
-  if (requiredChestIdx >= requiredChests.size()) return -1.0;  
-  double cx = requiredChests[requiredChestIdx]["location"]["x"].as<double>();
-  double cz = requiredChests[requiredChestIdx]["location"]["z"].as<double>();
-  double angle = pRot - (atan2(px-cx, cz-pz)*180.0/3.1415);
-  if (angle <= -180.0)  angle+=360.0;
-  else if (angle >= 180.0) angle-=360.0;
-  return angle;
-}
\ No newline at end of file
diff --git a/formation_web_esp/ChestsTrigonometryHelper.h b/formation_web_esp/ChestsTrigonometryHelper.h
deleted file mode 100644
index 252a4c2..0000000
--- a/formation_web_esp/ChestsTrigonometryHelper.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef CHESTSTRIGONOMETRYHELPER_H_
-#define CHESTSTRIGONOMETRYHELPER_H_
-
-#include <ArduinoJson.h> 
-
-double getHorizontalDistanceToRequiredChest(JsonArray requiredChests, int requiredChestIdx, double px, double pz);
-
-double getVerticalDistanceToRequiredChest(JsonArray requiredChests, int requiredChestIdx, double py);
-
-double getAngleDirectionDifferenceToRequiredChest(JsonArray requiredChests, int requiredChestIdx, double px, double pz, double pRot);
-
-
-#endif
\ No newline at end of file
diff --git a/formation_web_esp/LedMatrixHelper.cpp b/formation_web_esp/LedMatrixHelper.cpp
deleted file mode 100644
index f8cf7d6..0000000
--- a/formation_web_esp/LedMatrixHelper.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-#include "LedMatrixHelper.h"
-
-MD_MAX72XX mx = MD_MAX72XX(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
-
-void initLedMatrix() {
-  mx.begin();
-  mx.control(MD_MAX72XX::INTENSITY, 0);
-  mx.clear();
-}
-
-void drawMatrix(int matrix[8][8], int filter) {
-  for (int i = 0; i < 8; i++) {
-    for (int j = 0; j < 8; j++) {
-      mx.setPoint(i, j, matrix[i][j] == filter);
-    }
-  }
-}
diff --git a/formation_web_esp/LedMatrixHelper.h b/formation_web_esp/LedMatrixHelper.h
deleted file mode 100644
index 7e14b22..0000000
--- a/formation_web_esp/LedMatrixHelper.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef LEDMATRIXHELPER_H_
-#define LEDMATRIXHELPER_H_
-
-#include <MD_MAX72xx.h>
-#include <SPI.h>
-
-#define HARDWARE_TYPE MD_MAX72XX::GENERIC_HW
-#define MAX_DEVICES 1
-#define CS_PIN      15
-
-void initLedMatrix();
-
-void drawMatrix(int matrix[8][8], int filter);
-
-
-#endif
\ No newline at end of file
diff --git a/formation_web_esp/desktop.ini b/formation_web_esp/desktop.ini
deleted file mode 100644
index cc4e0f9..0000000
--- a/formation_web_esp/desktop.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[.ShellClassInfo]
-IconResource=C:\Program Files\Google\Drive File Stream\70.0.2.0\GoogleDriveFS.exe,23
diff --git a/formation_web_esp/formation_web_esp.ino b/formation_web_esp/formation_web_esp.ino
deleted file mode 100644
index 923e120..0000000
--- a/formation_web_esp/formation_web_esp.ino
+++ /dev/null
@@ -1,149 +0,0 @@
-#include "LedMatrixHelper.h"
-#include "ChestsTrigonometryHelper.h"
-
-#include <ESP8266WiFi.h>
-#include <ESP8266HTTPClient.h>
-#include <WiFiUdp.h>
-#include <PubSubClient.h>
-#include <ArduinoJson.h> 
-#include <string.h>
-#include <Servo.h>
-
-//C'est cadeau pour vous éviter de vous taper du parsing à la main en C :p 
-String getSubTopicAtIndex(String topic, int index) {
-  int found = 0;
-  int strIndex[] = {0, -1};
-  int maxIndex = topic.length()-1;
-  for(int i=0; i<=maxIndex && found<=index; i++){
-    if(topic.charAt(i)=='/' || i==maxIndex){
-        found++;
-        strIndex[0] = strIndex[1]+1;
-        strIndex[1] = (i == maxIndex) ? i+1 : i;
-    }
-  }
-  return found>index ? topic.substring(strIndex[0], strIndex[1]) : "";
-}
-
-Servo compassServo;
-
-
-// ####### 1.a. CONFIGURATION ET DECLARATION DU HOSTPOT WIFI #######
-char ssid[] = "NOM DU RESEAU";     //  le nom du reseau WIFI
-char password[] = "MOT DE PASSE";  // le mot de passe WIFI
-WiFiClient espClient;
-
-// ####### 1.b. DECLARATION DU CLIENT HTTP ET DES VARIABLES DE STOCKAGE DES DONNÉES DE JEU #######
-HTTPClient http;
-int teamPixelArt[8][8];
-StaticJsonDocument<2048> requiredChestsDoc;
-JsonArray requiredChests = requiredChestsDoc.to<JsonArray>();
-
-// ####### 2.a. CONFIGURATION ET DECLARATION DU SERVEUR MQTT #######
-char mqtt_server[] = "IP OU ADRESSE DU SERVEUR";  //adresse IP serveur 
-#define MQTT_USER ""
-#define MQTT_PASS ""
-PubSubClient MQTTclient(espClient);
-
-
-// ####### 1.c. ACQUISITION DU PIXEL ART VIA REQUETE HTTP ET LECTURE DU JSON #######
-void fetchTeamPixelArt() {
-  /* TODO */
-}
-
-// Fonction simple mais si ça peut vous permettre de gagner 2 minutes :)
-bool isColorInTeamPixelArt(int color) {
-  for (int i = 0; i < 8; i++) {
-    for (int j = 0; j < 8; j++) {
-      if (teamPixelArt[i][j] == color) return true;         
-    }
-  }
-  return false;
-}
-
-// ####### 1.d. ACQUISITION DES COFFRES COMPORTANT LES COULEURS DONT NOUS AVONS BESOIN #######
-void fetchRequiredChests() {
-  /* TODO */
-}
-
-
-
-
-
-
-void MQTTconnect() {
-  while (!MQTTclient.connected()) {
-      Serial.print("Attente de la connexion MQTT....");
-      String clientId = "TestClient-";
-      clientId += String(random(0xffff), HEX);
-
-    // test connexion
-    if (MQTTclient.connect(clientId.c_str(),"","")) {
-      Serial.println("connected");
-
-      // ####### 2.b. SOUSCRIPTION AUX TOPICS MQTT DE MON/MES JOUEURS #######        
-      /* TODO */
-
-    } else {  // si echec affichage erreur
-      Serial.print("ECHEC, rc=");
-      Serial.print(MQTTclient.state());
-      Serial.println(" nouvelle tentative dans 5 secondes");
-      delay(5000);
-    }
-  }
-}
-
-void MQTTcallback(char* topic, byte* payload, unsigned int length) {
-  Serial.print("Message MQTT reçu sur [");
-  String topicString = String((char*)topic);
-  Serial.print(topicString);
-  Serial.println("] ");
-  payload[length] = '\0';
-
-  // ####### 2.b. "AIGUILLAGE" DES MESSAGES MQTT SELON LES TOPICS #######
-  // Vous pouvez utiliser la fonction getSubTopicAtIndex(topicString, VOTRE_INDEX)
-  // Par exemple getSubTopicAtIndex(topicString, 1) retournera "AntoineRcbs" 
-  // pour l'entrée topicString = "redTeam/AntoineRcbs/location"
-  /* TODO */
-}
-
-
-// ####### 2.c. Décodage de la donnée (numéro du block de construction tenu) et mise à jour de l'affichage #######
-// On pourra prendre un DynamicJsonDocument de taille 128
-void onConstructionItemHeld(byte* payload, unsigned int length) {
-  /* TODO */
-}
-
-
-
-// ####### 2.c. Décodage du JSON et traitement sur les données extraites pour servo (+bonus affichage) #######
-// On pourra prendre un DynamicJsonDocument de taille 128
-void onPlayerLocationUpdate(byte* payload, unsigned int length) {
-  /* TODO */  
-}
-
-
-
-void setup() { 
-  initLedMatrix();
-  compassServo.attach(D4, 300, 2700);
-  Serial.begin(115200);
-
-  // ####### 1.a. CONNEXION AU WIFI #######
-  /* TODO */
-
-  // ######## 1.c. REQUETE HTTP POUR PIXEL ART ########
-  /* TODO */
-
-  // ######## 1.d. REQUETE HTTP POUR COFFRES ########
-  /* TODO */
-   
-
-  // ####### 2.a. INITIALISATION DU SERVEUR ET DU CALLBACK MQTT #######
-  /* TODO */
-}
-
-void loop() {
-
-  // ####### 2.a. RECONNEXION ET POOLING LOOP MQTT #######  
-  /* TODO */
-}
\ No newline at end of file
-- 
GitLab