Initial commit

This commit is contained in:
2026-03-31 13:17:21 +02:00
commit 7eeecff042
6821 changed files with 3514215 additions and 0 deletions

View File

@@ -0,0 +1,78 @@
#include <Arduino.h>
#include <WiFi.h>
#include <ESPAsyncWebSrv.h>
#include <SPIFFS.h>
#include <esp_system.h>
const char* ssid = "Box-gut-2.4G";
const char* password = "Rut@b@g@93";
AsyncWebServer server(80);
File imageFile;
void connectToWiFi() {
WiFi.begin(ssid, password);
Serial.print("Connexion en cours au réseau Wi-Fi...");
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.print(".");
}
Serial.println("\nConnecté au réseau Wi-Fi");
Serial.print("Adresse IP : ");
Serial.println(WiFi.localIP());
}
void setupSPIFFS() {
if (SPIFFS.begin()) {
Serial.println("Système de fichiers SPIFFS monté avec succès");
} else {
Serial.println("Erreur lors du montage du système de fichiers SPIFFS");
}
}
void setup() {
Serial.begin(115200);
setupSPIFFS();
connectToWiFi();
server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) {
request->send(SPIFFS, "/index.html");
});
server.on("/sendImageChunk", HTTP_POST, [](AsyncWebServerRequest * request) {
if (!request->hasParam("imageChunk", true)) {
request->send(400, "text/plain", "Erreur : aucun paquet reçu.");
return;
}
String imageChunk = request->getParam("imageChunk", true)->value();
//Serial.println(imageChunk);
if (imageChunk == "Begin") {
imageFile = SPIFFS.open("/current_img.h", "w");
imageFile.print("const uint16_t image_data[] = {");
Serial.println("debut de l'ecriture du fichier");
} else if (imageChunk == "End") {
imageFile = SPIFFS.open("/current_img.h", "a");
imageFile.print("};");
imageFile.close();
Serial.println("Fichier current_img.h fermé avec succès.");
esp_restart();
} else {
imageFile = SPIFFS.open("/current_img.h", "a");
imageFile.print(imageChunk);
}
imageFile.close(); // Fermez le fichier ici
imageChunk = String();
imageFile = File();
request->send(200, "text/plain", "Paquet reçu et ajouté !");
});
server.begin();
}
void loop() {
// Laissez cette fonction vide, car nous n'avons pas besoin de boucler ici.
}

View File

@@ -0,0 +1,117 @@
#include "XL9535_driver.h"
#include "Wire.h"
void XL9535::writeRegister(uint8_t reg, uint8_t *data, uint8_t len) {
_wire->beginTransmission(_address);
_wire->write(reg);
for (uint8_t i = 0; i < len; i++) {
_wire->write(data[i]);
}
_wire->endTransmission();
}
uint8_t XL9535::readRegister(uint8_t reg, uint8_t *data, uint8_t len) {
_wire->beginTransmission(_address);
_wire->write(reg);
_wire->endTransmission();
_wire->requestFrom(_address, len);
uint8_t index = 0;
while (index < len)
data[index++] = _wire->read();
return 0;
}
void XL9535::begin(bool A0, bool A1, bool A2, TwoWire *wire) {
_address = XL9535_IIC_ADDRESS | (A2 << 3) | (A1 << 2) | (A0 << 1);
_wire = wire;
is_found = true;
_wire->beginTransmission(_address);
if (!_wire->endTransmission()) {
Serial.println("Found xl9535");
} else {
Serial.println("xl9535 not found");
is_found = false;
}
}
void XL9535::pinMode(uint8_t pin, uint8_t mode) {
if (is_found) {
uint8_t port = 0;
if (pin > 7) {
readRegister(XL9535_CONFIG_PORT_1_REG, &port, 1);
if (mode == OUTPUT) {
port = port & (~(1 << (pin - 10)));
} else {
port = port | (1 << (pin - 10));
}
writeRegister(XL9535_CONFIG_PORT_1_REG, &port, 1);
} else {
readRegister(XL9535_CONFIG_PORT_0_REG, &port, 1);
if (mode == OUTPUT) {
port = port & (~(1 << pin));
} else {
port = port | (1 << pin);
}
writeRegister(XL9535_CONFIG_PORT_0_REG, &port, 1);
}
} else {
Serial.println("xl9535 not found");
}
}
void XL9535::pinMode8(uint8_t port, uint8_t pin, uint8_t mode) {
if (is_found) {
uint8_t _pin = (mode != OUTPUT) ? pin : ~pin;
if (port) {
writeRegister(XL9535_CONFIG_PORT_1_REG, &_pin, 1);
} else {
writeRegister(XL9535_CONFIG_PORT_0_REG, &_pin, 1);
}
} else {
Serial.println("xl9535 not found");
}
}
void XL9535::digitalWrite(uint8_t pin, uint8_t val) {
if (is_found) {
uint8_t port = 0;
uint8_t reg_data = 0;
if (pin > 7) {
readRegister(XL9535_OUTPUT_PORT_1_REG, &reg_data, 1);
reg_data = reg_data & (~(1 << (pin - 10)));
port = reg_data | val << (pin - 10);
writeRegister(XL9535_OUTPUT_PORT_1_REG, &port, 1);
} else {
readRegister(XL9535_OUTPUT_PORT_0_REG, &reg_data, 1);
reg_data = reg_data & (~(1 << pin));
port = reg_data | val << pin;
writeRegister(XL9535_OUTPUT_PORT_0_REG, &port, 1);
}
} else {
Serial.println("xl9535 not found");
}
}
int XL9535::digitalRead(uint8_t pin) {
if (is_found) {
int state = 0;
uint8_t port = 0;
if (pin > 7) {
readRegister(XL9535_INPUT_PORT_1_REG, &port, 1);
state = port & (pin - 10) ? 1 : 0;
} else {
readRegister(XL9535_INPUT_PORT_0_REG, &port, 1);
state = port & pin ? 1 : 0;
}
return state;
} else {
Serial.println("xl9535 not found");
}
return 0;
}
void XL9535::read_all_reg() {
uint8_t data;
for (uint8_t i = 0; i < 8; i++) {
readRegister(i, &data, 1);
Serial.printf("0x%02x : 0x%02X \r\n", i, data);
}
}

View File

@@ -0,0 +1,37 @@
#pragma once
#include "Arduino.h"
#include "Wire.h"
#define XL9535_IIC_ADDRESS 0X20
#define XL9535_INPUT_PORT_0_REG 0X00
#define XL9535_INPUT_PORT_1_REG 0X01
#define XL9535_OUTPUT_PORT_0_REG 0X02
#define XL9535_OUTPUT_PORT_1_REG 0X03
#define XL9535_INVERSION_PORT_0_REG 0X04
#define XL9535_INVERSION_PORT_1_REG 0X05
#define XL9535_CONFIG_PORT_0_REG 0X06
#define XL9535_CONFIG_PORT_1_REG 0X07
class XL9535 {
public:
XL9535(){};
~XL9535(){};
void begin(bool A0 = 0, bool A1 = 0, bool A2 = 0, TwoWire *wire = &Wire);
void pinMode(uint8_t pin, uint8_t mode);
void pinMode8(uint8_t port, uint8_t pin, uint8_t mode);
void digitalWrite(uint8_t pin, uint8_t val);
int digitalRead(uint8_t pin);
void read_all_reg();
protected:
void writeRegister(uint8_t reg, uint8_t *data, uint8_t len);
uint8_t readRegister(uint8_t reg, uint8_t *data, uint8_t len);
uint8_t _address;
TwoWire *_wire;
bool is_found;
};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,124 @@
<!DOCTYPE html>
<html>
<head>
<title>Transfert d'image vers ESP32</title>
</head>
<body>
<h1>Transfert d'image vers ESP32</h1>
<form id="imageForm">
<input type="file" id="imageInput" accept="image/*">
<input type="submit" value="Envoyer">
</form>
<div id="result">
<!-- L'image convertie en tableau C sera affichée ici -->
</div>
<script>
const form = document.getElementById("imageForm");
const input = document.getElementById("imageInput");
input.addEventListener("change", function () {
const file = input.files[0];
if (file) {
const reader = new FileReader();
const chunkSize = 1024; // Taille du paquet (en octets)
reader.onload = function(event) {
const image = new Image();
image.src = event.target.result;
image.onload = function() {
const canvas = document.createElement("canvas");
canvas.width = 480;
canvas.height = 480;
const context = canvas.getContext("2d");
context.drawImage(image, 0, 0, 480, 480);
const imageData = context.getImageData(0, 0, 480, 480).data;
const outputArray = [];
for (let i = 0; i < imageData.length; i += 4) {
const r = imageData[i];
const g = imageData[i + 1];
const b = imageData[i + 2];
const rgb565 = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);
outputArray.push(`0x${rgb565.toString(16).toUpperCase()}, `);
}
const resultDiv = document.getElementById("result");
resultDiv.innerHTML = `<h2>Image convertie en tableau C :</h2><pre id="completeData">${outputArray.join("")}</pre>`;
};
};
reader.readAsDataURL(file);
}
});
form.addEventListener("submit", function (event) {
event.preventDefault(); // Empêche l'envoi du formulaire
const completeData = document.getElementById("completeData").textContent;
const chunkSize = 1024*4; // Taille du paquet (en octets)
const chunks = chunkString(completeData, chunkSize); // Divisez les données en paquets
// Fonction pour diviser une chaîne de caractères en morceaux de taille donnée
function chunkString(str, size) {
const chunks = [];
for (let i = 0; i < str.length; i += size) {
chunks.push(str.slice(i, i + size));
}
return chunks;
}
// Ajoutez "Begin" au début et "End" à la fin
chunks.unshift("Begin");
chunks.push("End");
// Fonction pour envoyer un paquet à l'ESP32 avec délai
// Fonction pour envoyer un paquet à l'ESP32 avec délai
function sendChunksWithDelay(chunks, index) {
if (index < chunks.length) {
const chunk = chunks[index];
// Afficher le paquet dans la console
//console.log(`Envoi du paquet ${index + 1}: ${chunk}`);
// Créez un objet FormData pour envoyer le paquet
const formData = new FormData();
formData.append("imageChunk", chunk);
// Envoyez le paquet à l'ESP32
fetch("/sendImageChunk", {
method: "POST",
body: formData,
})
.then((response) => {
if (response.ok) {
console.log(`Paquet ${index + 1}/${chunks.length} envoyé avec succès à l'ESP32.`);
} else {
throw new Error("Erreur lors de l'envoi du paquet.");
}
})
.catch((error) => {
console.error(error);
})
.finally(() => {
// Planifiez l'envoi du prochain paquet après un délai de 1000 millisecondes (1 seconde)
setTimeout(() => {
sendChunksWithDelay(chunks, index + 1);
}, 10);
});
}
}
// Commencez l'envoi des chunks avec délai, en commençant par le premier (index 0)
sendChunksWithDelay(chunks, 0);
});
</script>
</body>
</html>

View File

@@ -0,0 +1,57 @@
#pragma once
#define WIFI_SSID "xinyuandianzi"
#define WIFI_PASSWORD "AA15994823428"
#define EXAMPLE_LCD_PIXEL_CLOCK_HZ (8 * 1000 * 1000)
#define EXAMPLE_LCD_BK_LIGHT_ON_LEVEL 1
#define EXAMPLE_LCD_BK_LIGHT_OFF_LEVEL !EXAMPLE_LCD_BK_LIGHT_ON_LEVEL
#define EXAMPLE_PIN_NUM_BK_LIGHT 46
#define EXAMPLE_PIN_NUM_HSYNC 47
#define EXAMPLE_PIN_NUM_VSYNC 41
#define EXAMPLE_PIN_NUM_DE 45
#define EXAMPLE_PIN_NUM_PCLK 42
// #define EXAMPLE_PIN_NUM_DATA0 44
#define EXAMPLE_PIN_NUM_DATA1 21
#define EXAMPLE_PIN_NUM_DATA2 18
#define EXAMPLE_PIN_NUM_DATA3 17
#define EXAMPLE_PIN_NUM_DATA4 16
#define EXAMPLE_PIN_NUM_DATA5 15
#define EXAMPLE_PIN_NUM_DATA6 14
#define EXAMPLE_PIN_NUM_DATA7 13
#define EXAMPLE_PIN_NUM_DATA8 12
#define EXAMPLE_PIN_NUM_DATA9 11
#define EXAMPLE_PIN_NUM_DATA10 10
#define EXAMPLE_PIN_NUM_DATA11 9
// #define EXAMPLE_PIN_NUM_DATA12 43
#define EXAMPLE_PIN_NUM_DATA13 7
#define EXAMPLE_PIN_NUM_DATA14 6
#define EXAMPLE_PIN_NUM_DATA15 5
#define EXAMPLE_PIN_NUM_DATA16 3
#define EXAMPLE_PIN_NUM_DATA17 2
#define EXAMPLE_PIN_NUM_DISP_EN -1
// The pixel number in horizontal and vertical
#define EXAMPLE_LCD_H_RES 480
#define EXAMPLE_LCD_V_RES 480
#define IIC_SCL_PIN 48
#define IIC_SDA_PIN 8
#define SD_CLK_PIN 39
#define SD_CMD_PIN 40
#define SD_D0_PIN 38
#define BAT_VOLT_PIN 4
#define TP_INT_PIN 1
#define BOOT_BTN_PIN 0
/* XL9535 --- PIN - P0*/
#define TP_RES_PIN 1
#define PWR_EN_PIN 2
#define LCD_CS_PIN 3
#define LCD_SDA_PIN 4
#define LCD_CLK_PIN 5
#define LCD_RST_PIN 6
#define SD_CS_PIN 7