fix: encodage

This commit is contained in:
2025-08-21 07:38:58 +02:00
parent fcee080589
commit fc108a4b7f
2 changed files with 29 additions and 9 deletions

View File

@@ -14,23 +14,27 @@ Radio internet WiFi basée sur ESP32 avec interface web intégrée et contrôles
### Utilisation quotidienne ### Utilisation quotidienne
#### Contrôles physiques #### Contrôles physiques
- **🔘 Appui court** : Mise en veille (économie d'énergie) - **🔘 Appui court** : Mise en veille (économie d'énergie)
- **🔘 Appui long (2s)** : Mode sélection de stations (LED clignote 3x) - **🔘 Appui long (2s)** : Mode sélection de stations (LED clignote 3x)
- **🔘 Appui très long (5s)** : Reset WiFi et retour en mode configuration - **🔘 Appui très long (5s)** : Reset WiFi et retour en mode configuration
- **🎛️ Potentiomètre** : - **🎛️ Potentiomètre** :
- Mode normal : Contrôle du volume - Mode normal : Contrôle du volume
- Mode sélection : Choix de la station radio - Mode sélection : Choix de la station radio
#### Interface web #### Interface web
Accédez à l'interface via l'adresse IP de la radio (affichée au démarrage) : Accédez à l'interface via l'adresse IP de la radio (affichée au démarrage) :
- **🎵 Contrôle de lecture** : Play/Stop/Changement de station - **🎵 Contrôle de lecture** : Play/Stop/Changement de station
- **📻 Gestion des stations** : Ajouter/supprimer jusqu'à 10 stations - **📻 Gestion des stations** : Ajouter/supprimer jusqu'à 10 stations
- **🌐 Configuration WiFi** : Modifier les paramètres réseau - **🌐 Configuration WiFi** : Modifier les paramètres réseau
- **📱 Compatible mobile** : Interface responsive - **📱 Compatible mobile** : Interface responsive
### Stations pré-configurées ### Stations pré-configurées
- France Inter - France Inter
- FIP - FIP
- France Info - France Info
- 80s Hits - 80s Hits
- BBC Radio 1 - BBC Radio 1
@@ -38,6 +42,7 @@ Accédez à l'interface via l'adresse IP de la radio (affichée au démarrage) :
## ⚙️ Pour le développeur ## ⚙️ Pour le développeur
### Prérequis ### Prérequis
- **Arduino CLI** installé et configuré - **Arduino CLI** installé et configuré
- **Board ESP32** : `esp32:esp32:esp32` - **Board ESP32** : `esp32:esp32:esp32`
- **Bibliothèques** : - **Bibliothèques** :
@@ -47,11 +52,12 @@ Accédez à l'interface via l'adresse IP de la radio (affichée au démarrage) :
- EEPROM (intégrée) - EEPROM (intégrée)
### Schéma de câblage ### Schéma de câblage
``` ```
ESP32 Pin | Composant ESP32 Pin | Composant
-----------|---------- -----------|----------
25 | I2S_DOUT (vers DAC) 25 | I2S_DOUT (vers DAC)
26 | I2S_LRC (vers DAC) 26 | I2S_LRC (vers DAC)
27 | I2S_BCLK (vers DAC) 27 | I2S_BCLK (vers DAC)
32 | LED de statut 32 | LED de statut
33 | Bouton d'alimentation 33 | Bouton d'alimentation
@@ -59,8 +65,10 @@ ESP32 Pin | Composant
``` ```
### Configuration WiFi ### Configuration WiFi
1. Copiez `wifiinfo.h.sample` vers `wifiinfo.h` 1. Copiez `wifiinfo.h.sample` vers `wifiinfo.h`
2. Modifiez les paramètres par défaut : 2. Modifiez les paramètres par défaut :
```cpp ```cpp
#define WIFI_SSID "VotreSSID" #define WIFI_SSID "VotreSSID"
#define WIFI_PASSWD "VotreMotDePasse" #define WIFI_PASSWD "VotreMotDePasse"
@@ -70,11 +78,13 @@ ESP32 Pin | Composant
### Compilation et upload ### Compilation et upload
#### Méthode simple #### Méthode simple
```bash ```bash
make all # Compile + Upload + Monitor make all # Compile + Upload + Monitor
``` ```
#### Méthode détaillée #### Méthode détaillée
```bash ```bash
make compile # Compilation uniquement make compile # Compilation uniquement
make upload # Upload vers ESP32 make upload # Upload vers ESP32
@@ -82,7 +92,9 @@ make watch # Monitoring série (screen)
``` ```
#### Troubleshooting upload #### Troubleshooting upload
Si l'upload échoue avec "Device or resource busy" : Si l'upload échoue avec "Device or resource busy" :
```bash ```bash
lsof /dev/ttyUSB0 # Vérifier les processus lsof /dev/ttyUSB0 # Vérifier les processus
kill <PID> # Tuer le processus si nécessaire kill <PID> # Tuer le processus si nécessaire
@@ -91,11 +103,13 @@ kill <PID> # Tuer le processus si nécessaire
### Architecture du code ### Architecture du code
#### Fichiers principaux #### Fichiers principaux
- `esp32_radio.ino` : Code principal - `esp32_radio.ino` : Code principal
- `wifiinfo.h` : Configuration WiFi (non versionné) - `wifiinfo.h` : Configuration WiFi (non versionné)
- `Makefile` : Scripts de build - `Makefile` : Scripts de build
#### Fonctions clés #### Fonctions clés
- `setup()` : Initialisation, gestion du réveil, connexion WiFi - `setup()` : Initialisation, gestion du réveil, connexion WiFi
- `loop()` : Boucle principale (audio, web, contrôles) - `loop()` : Boucle principale (audio, web, contrôles)
- `wifi_init()` : Gestion intelligente de la connexion WiFi - `wifi_init()` : Gestion intelligente de la connexion WiFi
@@ -104,6 +118,7 @@ kill <PID> # Tuer le processus si nécessaire
- `handleRoot()` : Interface web principale - `handleRoot()` : Interface web principale
#### Stockage EEPROM #### Stockage EEPROM
```cpp ```cpp
EEPROM_SIZE = 2048 EEPROM_SIZE = 2048
├── WiFi credentials (0-96) ├── WiFi credentials (0-96)
@@ -113,6 +128,7 @@ EEPROM_SIZE = 2048
``` ```
#### Modes de fonctionnement #### Modes de fonctionnement
1. **Normal** : Lecture + contrôles standard 1. **Normal** : Lecture + contrôles standard
2. **Sélection** : Potentiomètre = sélection station 2. **Sélection** : Potentiomètre = sélection station
3. **Configuration** : Point d'accès + interface web 3. **Configuration** : Point d'accès + interface web
@@ -121,9 +137,11 @@ EEPROM_SIZE = 2048
### Personnalisation ### Personnalisation
#### Ajouter des stations par défaut #### Ajouter des stations par défaut
Modifiez `loadStationsFromEEPROM()` ligne 428-441. Modifiez `loadStationsFromEEPROM()` ligne 428-441.
#### Modifier les timeouts #### Modifier les timeouts
```cpp ```cpp
#define CONNECTION_TIMEOUT 10 // Timeout WiFi (secondes) #define CONNECTION_TIMEOUT 10 // Timeout WiFi (secondes)
#define LONG_PRESS_TIME 2000 // Appui long (ms) #define LONG_PRESS_TIME 2000 // Appui long (ms)
@@ -131,9 +149,11 @@ Modifiez `loadStationsFromEEPROM()` ligne 428-441.
``` ```
#### Pins personnalisées #### Pins personnalisées
Modifiez les defines lignes 9-14 selon votre câblage. Modifiez les defines lignes 9-14 selon votre câblage.
### API Web ### API Web
- `GET /` : Interface principale - `GET /` : Interface principale
- `POST /add` : Ajouter station (`name`, `url`) - `POST /add` : Ajouter station (`name`, `url`)
- `POST /delete?id=X` : Supprimer station - `POST /delete?id=X` : Supprimer station

View File

@@ -443,7 +443,7 @@ void loadStationsFromEEPROM() {
// Web server functions // Web server functions
void handleRoot() { void handleRoot() {
String html = "<!DOCTYPE html><html><head><title>ESP32 Radio Config</title>"; String html = "<!DOCTYPE html><html><head><meta charset='UTF-8'><title>ESP32 Radio Config</title>";
html += "<style>body{font-family:Arial;margin:20px}table{border-collapse:collapse;width:100%}"; html += "<style>body{font-family:Arial;margin:20px}table{border-collapse:collapse;width:100%}";
html += "th,td{border:1px solid #ddd;padding:8px;text-align:left}th{background-color:#f2f2f2}"; html += "th,td{border:1px solid #ddd;padding:8px;text-align:left}th{background-color:#f2f2f2}";
html += "input[type=text]{width:90%;padding:5px}button{padding:10px;margin:5px}</style></head><body>"; html += "input[type=text]{width:90%;padding:5px}button{padding:10px;margin:5px}</style></head><body>";
@@ -499,7 +499,7 @@ void handleRoot() {
html += "fetch('/stop',{method:'POST'}).then(()=>location.reload());}"; html += "fetch('/stop',{method:'POST'}).then(()=>location.reload());}";
html += "</script></body></html>"; html += "</script></body></html>";
server.send(200, "text/html", html); server.send(200, "text/html; charset=utf-8", html);
} }
void handleAdd() { void handleAdd() {
@@ -580,7 +580,7 @@ void handleStop() {
} }
void handleWiFiConfig() { void handleWiFiConfig() {
String html = "<!DOCTYPE html><html><head><title>Configuration WiFi</title>"; String html = "<!DOCTYPE html><html><head><meta charset='UTF-8'><title>Configuration WiFi</title>";
html += "<style>body{font-family:Arial;margin:20px}input[type=text],input[type=password]{width:300px;padding:10px;margin:5px 0}"; html += "<style>body{font-family:Arial;margin:20px}input[type=text],input[type=password]{width:300px;padding:10px;margin:5px 0}";
html += "button{padding:10px 20px;margin:10px 5px;font-size:16px}"; html += "button{padding:10px 20px;margin:10px 5px;font-size:16px}";
html += ".back-btn{background-color:#6c757d;color:white;text-decoration:none;padding:10px 20px;display:inline-block;margin:10px 0}</style></head><body>"; html += ".back-btn{background-color:#6c757d;color:white;text-decoration:none;padding:10px 20px;display:inline-block;margin:10px 0}</style></head><body>";
@@ -608,7 +608,7 @@ void handleWiFiConfig() {
html += "<a href='/' class='back-btn'>⬅️ Retour</a>"; html += "<a href='/' class='back-btn'>⬅️ Retour</a>";
html += "</body></html>"; html += "</body></html>";
server.send(200, "text/html", html); server.send(200, "text/html; charset=utf-8", html);
} }
void handleSaveWiFi() { void handleSaveWiFi() {
@@ -632,7 +632,7 @@ void handleSaveWiFi() {
response += "SSID: " + newSSID + "<br>"; response += "SSID: " + newSSID + "<br>";
response += "Appareil: " + newHostname; response += "Appareil: " + newHostname;
server.send(200, "text/html", response); server.send(200, "text/html; charset=utf-8", response);
Serial.println("Nouvelles credentials WiFi sauvegardées, redémarrage..."); Serial.println("Nouvelles credentials WiFi sauvegardées, redémarrage...");
delay(2000); delay(2000);
@@ -641,7 +641,7 @@ void handleSaveWiFi() {
void handleResetWiFi() { void handleResetWiFi() {
resetWiFiCredentials(); resetWiFiCredentials();
server.send(200, "text/html", "Configuration WiFi effacée. Redémarrage en mode configuration..."); server.send(200, "text/html; charset=utf-8", "Configuration WiFi effacée. Redémarrage en mode configuration...");
delay(2000); delay(2000);
ESP.restart(); ESP.restart();
} }