test commit après reinstall
This commit is contained in:
@@ -38,26 +38,26 @@ const char* adminPassword = "setaou"; // Mot de passe pour la connexion
|
||||
//#define PIN_DIMMER_OUTPUT 18 // D8
|
||||
//#define PIN_DIMMER_ZEROCROSS 19 // 12 // D6 for boards with CHANGEBLE input pins
|
||||
#ifdef ESP8266
|
||||
#define PIN_SOFTWARE_SERIAL_RX D4 // GPIO2
|
||||
#define PIN_SOFTWARE_SERIAL_TX D2 // GPIO4
|
||||
#define PIN_SOFTWARE_SERIAL_RX D4 // GPIO2
|
||||
#define PIN_SOFTWARE_SERIAL_TX D2 // GPIO4
|
||||
#elif defined(ESP32)
|
||||
//#define PZEM true
|
||||
#define PIN_LED 2
|
||||
#define SERIAL_BLUE_SOLAR true
|
||||
#define SERIAL_XY6020L true
|
||||
//#define SERIAL_XY6020L_2 true
|
||||
//#define PZEM true
|
||||
#define PIN_LED 2
|
||||
#define SERIAL_BLUE_SOLAR true
|
||||
#define SERIAL_XY6020L true
|
||||
//#define SERIAL_XY6020L_2 true
|
||||
|
||||
|
||||
#define PIN_SOFTWARE_SERIAL_RX 4
|
||||
#define PIN_SOFTWARE_SERIAL_TX 5
|
||||
#define PIN_SOFTWARE_SERIAL_RX2 25
|
||||
#define PIN_SOFTWARE_SERIAL_TX2 26
|
||||
#define PIN_SOFTWARE_SERIAL_TX3 32
|
||||
#define PIN_SOFTWARE_SERIAL_RX3 33
|
||||
#define PIN_SOFTWARE_SERIAL_RX 4
|
||||
#define PIN_SOFTWARE_SERIAL_TX 5
|
||||
#define PIN_SOFTWARE_SERIAL_RX2 25
|
||||
#define PIN_SOFTWARE_SERIAL_TX2 26
|
||||
#define PIN_SOFTWARE_SERIAL_TX3 32
|
||||
#define PIN_SOFTWARE_SERIAL_RX3 33
|
||||
|
||||
#define PIN_REGULATION 21
|
||||
// #define PIN_DALLAS 26 // D5
|
||||
//#define PIN_HALL 33
|
||||
#define PIN_REGULATION 21
|
||||
// #define PIN_DALLAS 26 // D5
|
||||
//#define PIN_HALL 33
|
||||
|
||||
#endif
|
||||
|
||||
@@ -146,21 +146,21 @@ dimmerLamp dimmer(PIN_DIMMER_OUTPUT, PIN_DIMMER_ZEROCROSS); //initialase port fo
|
||||
// DALLAS
|
||||
/////////////////////////////////////////
|
||||
#ifdef PIN_DALLAS
|
||||
float temperature = 0;
|
||||
float temperature = 0;
|
||||
|
||||
#include <OneWire.h>
|
||||
#include <DallasTemperature.h>
|
||||
#define onewirepin PIN_DALLAS // DATA pin of DS18B20 wired to pin DALLAS of Arduino
|
||||
#include <OneWire.h>
|
||||
#include <DallasTemperature.h>
|
||||
#define onewirepin PIN_DALLAS // DATA pin of DS18B20 wired to pin DALLAS of Arduino
|
||||
|
||||
OneWire oneWire(onewirepin);
|
||||
DallasTemperature sensors(&oneWire);
|
||||
OneWire oneWire(onewirepin);
|
||||
DallasTemperature sensors(&oneWire);
|
||||
|
||||
// find the DeviceAddress of your DS18B20 with the sketch DS18B20_address_reporter
|
||||
// then replace the 8-byte ID below with the reported one
|
||||
// find the DeviceAddress of your DS18B20 with the sketch DS18B20_address_reporter
|
||||
// then replace the 8-byte ID below with the reported one
|
||||
|
||||
DeviceAddress Probe = { 0x28, 0xFF, 0x61, 0x1D, 0x76, 0x04, 0x00, 0x34 };
|
||||
DeviceAddress Probe = { 0x28, 0xFF, 0x61, 0x1D, 0x76, 0x04, 0x00, 0x34 };
|
||||
|
||||
float printTemperature(DeviceAddress deviceAddress);
|
||||
float printTemperature(DeviceAddress deviceAddress);
|
||||
#endif
|
||||
|
||||
void blink();
|
||||
@@ -216,26 +216,26 @@ unsigned long lastTimeRead = millis();
|
||||
// PZEM for arduino
|
||||
// -----------------
|
||||
#ifdef PZEM
|
||||
#include <PZEM004Tv30.h>
|
||||
#include <PZEM004Tv30.h>
|
||||
|
||||
#ifdef ESP8266
|
||||
#define PIN_PZEM_1 D5
|
||||
#define PIN_PZEM_2 D6
|
||||
PZEM004Tv30 pzem(PIN_PZEM_1, PIN_PZEM_2);
|
||||
#ifdef ESP8266
|
||||
#define PIN_PZEM_1 D5
|
||||
#define PIN_PZEM_2 D6
|
||||
PZEM004Tv30 pzem(PIN_PZEM_1, PIN_PZEM_2);
|
||||
|
||||
#elif defined(ESP32)
|
||||
#elif defined(ESP32)
|
||||
|
||||
#define RXD2 16
|
||||
#define TXD2 17
|
||||
PZEM004Tv30 pzem(&Serial2);
|
||||
#endif
|
||||
#define RXD2 16
|
||||
#define TXD2 17
|
||||
PZEM004Tv30 pzem(&Serial2);
|
||||
#endif
|
||||
|
||||
double voltage;
|
||||
double current;
|
||||
double pf;
|
||||
double power;
|
||||
double energy;
|
||||
double frequency;
|
||||
double voltage;
|
||||
double current;
|
||||
double pf;
|
||||
double power;
|
||||
double energy;
|
||||
double frequency;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -245,49 +245,49 @@ void setup() {
|
||||
// initialize digital pin LED_BUILTIN as an output.
|
||||
Serial.begin(115200);
|
||||
|
||||
#ifdef PZEM
|
||||
#ifdef ESP32
|
||||
#ifdef PZEM
|
||||
#ifdef ESP32
|
||||
Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PIN_TENSION
|
||||
#ifdef PIN_TENSION
|
||||
pinMode(PIN_TENSION, INPUT);
|
||||
#endif
|
||||
#ifdef PIN_HALL
|
||||
#endif
|
||||
#ifdef PIN_HALL
|
||||
pinMode(PIN_HALL, INPUT);
|
||||
delay(200);
|
||||
getHall();
|
||||
#endif
|
||||
#ifdef PIN_POWER
|
||||
#endif
|
||||
#ifdef PIN_POWER
|
||||
pinMode(PIN_POWER, OUTPUT);
|
||||
#endif
|
||||
#ifdef PIN_LED
|
||||
#endif
|
||||
#ifdef PIN_LED
|
||||
pinMode(PIN_LED, OUTPUT);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
pinMode(PIN_INJECTION, OUTPUT);
|
||||
pinMode(PIN_CHARGE, OUTPUT);
|
||||
#ifdef PIN_BATTERIE
|
||||
#ifdef PIN_BATTERIE
|
||||
pinMode(PIN_BATTERIE, OUTPUT);
|
||||
#endif
|
||||
#ifdef PIN_REGULATION
|
||||
#endif
|
||||
#ifdef PIN_REGULATION
|
||||
|
||||
#ifdef ESP32
|
||||
#ifdef ESP32
|
||||
// ledcAttachPin(PIN_REGULATION, 0); // assign a led pins to a channel
|
||||
// // Initialize channels
|
||||
// // channels 0-15, resolution 1-16 bits, freq limits depend on resolution
|
||||
// // ledcSetup(uint8_t channel, uint32_t freq, uint8_t resolution_bits);
|
||||
// ledcSetup(0, 4000, 8); // 12 kHz PWM, 8-bit resolution
|
||||
pinMode(PIN_REGULATION, OUTPUT);
|
||||
#else
|
||||
#else
|
||||
pinMode(PIN_REGULATION, OUTPUT); // set mtorPin as output
|
||||
#endif
|
||||
#endif
|
||||
#ifdef SERIAL_BLUE_SOLAR
|
||||
#ifdef ESP32
|
||||
#endif
|
||||
#endif
|
||||
#ifdef SERIAL_BLUE_SOLAR
|
||||
#ifdef ESP32
|
||||
Serial1.begin(19200, SERIAL_8N1, PIN_SOFTWARE_SERIAL_RX, PIN_SOFTWARE_SERIAL_TX); // Rx = 4, Tx = 5 will work for ESP32, S2, S3 and C3
|
||||
#else
|
||||
#else
|
||||
// Serial port configuration
|
||||
//Baud rate:19200
|
||||
//Data bits: 8
|
||||
@@ -295,12 +295,12 @@ void setup() {
|
||||
//Stop bits: 1
|
||||
//Flow control: None
|
||||
victronSerial.begin(19200); //, SWSERIAL_8N1);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
char tmpBuf[30]; // text buffer for serial messages
|
||||
|
||||
#ifdef SERIAL_XY6020L
|
||||
#ifdef ESP32
|
||||
#ifdef SERIAL_XY6020L
|
||||
#ifdef ESP32
|
||||
xy6020l xy(Serial2, 0x01, 50, XY6020_OPT_SKIP_SAME_HREG_VALUE | XY6020_OPT_NO_HREG_UPDATE);
|
||||
|
||||
Serial2.begin(115200, SERIAL_8N1, PIN_SOFTWARE_SERIAL_RX2, PIN_SOFTWARE_SERIAL_TX2); // Rx = 4, Tx = 5 will work for ESP32, S2, S3 and C3
|
||||
@@ -314,8 +314,8 @@ void setup() {
|
||||
Mem.sOVP = 1300;
|
||||
Mem.sOCP = 620;
|
||||
Mem.sOPP = 1040;
|
||||
Mem.sOHPh= 0;
|
||||
Mem.sOHPm= 0;
|
||||
Mem.sOHPh = 0;
|
||||
Mem.sOHPm = 0;
|
||||
Mem.sOAH = 0;
|
||||
Mem.sOWH = 0;
|
||||
Mem.sOTP = 61;
|
||||
@@ -331,11 +331,11 @@ void setup() {
|
||||
|
||||
sprintf( tmpBuf, "Modele 1 :%04X Version 1 :%04X\n", xy.getModel(), xy.getVersion() );
|
||||
Serial.print(tmpBuf);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_XY6020L_2
|
||||
#ifdef ESP32
|
||||
#ifdef SERIAL_XY6020L_2
|
||||
#ifdef ESP32
|
||||
|
||||
// xy6020l xy2(Serial3, 0x01, 50, XY6020_OPT_SKIP_SAME_HREG_VALUE | XY6020_OPT_NO_HREG_UPDATE);
|
||||
|
||||
@@ -350,8 +350,8 @@ void setup() {
|
||||
Mem2.sOVP = 1300;
|
||||
Mem2.sOCP = 619;
|
||||
Mem2.sOPP = 1041;
|
||||
Mem2.sOHPh= 0;
|
||||
Mem2.sOHPm= 0;
|
||||
Mem2.sOHPh = 0;
|
||||
Mem2.sOHPm = 0;
|
||||
Mem2.sOAH = 0;
|
||||
Mem2.sOWH = 0;
|
||||
Mem2.sOTP = 60;
|
||||
@@ -367,8 +367,8 @@ void setup() {
|
||||
|
||||
sprintf( tmpBuf, "Modele 2 :%04X Version 2 :%04X\n", xy.getModel(), xy.getVersion() );
|
||||
Serial.print(tmpBuf);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
delay(10);
|
||||
@@ -411,7 +411,7 @@ void setup() {
|
||||
//server.on("/test", HTTP_GET, handleTestConnection);
|
||||
server.on("/slider", HTTP_POST, handleUpdate);
|
||||
|
||||
#ifdef SERIAL_BLUE_SOLAR
|
||||
#ifdef SERIAL_BLUE_SOLAR
|
||||
|
||||
// Initialisation de l'EEPROM
|
||||
EEPROM.begin(EEPROM_SIZE); //sizeof(To_Store) + sizeof(config));
|
||||
@@ -433,7 +433,7 @@ void setup() {
|
||||
to_store.total_elements = 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
configTime(0, 0, "pool.ntp.org", "time.nist.gov");
|
||||
// Synchronize time
|
||||
@@ -444,19 +444,19 @@ void setup() {
|
||||
lastSyncMillis = millis();
|
||||
|
||||
// Dimmer
|
||||
#ifdef PIN_DIMMER_OUTPUT
|
||||
#ifdef PIN_DIMMER_OUTPUT
|
||||
server.on("/minus", minus);
|
||||
server.on("/plus", plus);
|
||||
server.on("/exact", exact);
|
||||
server.on("/zero", stopPWM);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PIN_REGULATION
|
||||
#ifdef PIN_REGULATION
|
||||
server.on("/minus_reg", minus_reg);
|
||||
server.on("/plus_reg", plus_reg);
|
||||
server.on("/exact_reg", exact_reg);
|
||||
server.on("/zero_reg", stop_reg);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//initialize variables__________________
|
||||
pwm = 0;
|
||||
@@ -464,18 +464,18 @@ void setup() {
|
||||
// Dimmer
|
||||
Serial.println("Dimmer Program is starting...");
|
||||
delay(1000);
|
||||
#ifdef PIN_DIMMER_OUTPUT
|
||||
#ifdef PIN_DIMMER_OUTPUT
|
||||
dimmer.begin(NORMAL_MODE, ON); //dimmer initialisation: name.begin(MODE, STATE)
|
||||
Serial.println("Set value");
|
||||
dimmer.setState(ON_OFF_typedef::OFF);
|
||||
dimmer.setPower(pwm); // setPower(0-100%);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Démarrer le serveur
|
||||
server.begin();
|
||||
Serial.println("Serveur Web démarré");
|
||||
|
||||
#ifdef PIN_DALLAS
|
||||
#ifdef PIN_DALLAS
|
||||
|
||||
sensors.begin (); // Initialize the sensor and set resolution level
|
||||
sensors.setResolution(Probe, 10);
|
||||
@@ -486,13 +486,13 @@ void setup() {
|
||||
Serial.println (sensors.getDeviceCount());
|
||||
Serial.print ("Getting temperatures... ");
|
||||
Serial.println ();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PZEM
|
||||
#ifdef PZEM
|
||||
Serial.println("-------PZEM-----------"); // Start Print Test to Line 2
|
||||
pzem.resetEnergy();
|
||||
delay(1000);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
///////////////////////////////////
|
||||
// UPDATE OTA
|
||||
@@ -555,17 +555,17 @@ void loop() {
|
||||
|
||||
#ifdef SERIAL_XY6020L
|
||||
xy.task();
|
||||
// if(xy.HRegUpdated()) {
|
||||
// double vIn = xy.getInV();
|
||||
// xy.setCV(500);
|
||||
// }
|
||||
// if(xy.HRegUpdated()) {
|
||||
// double vIn = xy.getInV();
|
||||
// xy.setCV(500);
|
||||
// }
|
||||
#endif
|
||||
#ifdef SERIAL_XY6020L_2
|
||||
xy2.task();
|
||||
// if(xy.HRegUpdated()) {
|
||||
// double vIn = xy.getInV();
|
||||
// xy.setCV(500);
|
||||
// }
|
||||
// if(xy.HRegUpdated()) {
|
||||
// double vIn = xy.getInV();
|
||||
// xy.setCV(500);
|
||||
// }
|
||||
#endif
|
||||
|
||||
if (millis() - lastTimeRead >= analogReadInterval)//read ldr periodically
|
||||
@@ -577,8 +577,8 @@ void loop() {
|
||||
|
||||
if (millis() - lastUpdateTime >= updateInterval || lastUpdateTime == 0) {
|
||||
|
||||
// digitalWrite(PIN_LED, HIGH);
|
||||
// delay(500);
|
||||
// digitalWrite(PIN_LED, HIGH);
|
||||
// delay(500);
|
||||
unsigned long currentMillis = millis();
|
||||
time_t elapsedTime = (currentMillis - lastSyncMillis) / 1000;
|
||||
localTime = currentTime + elapsedTime;
|
||||
@@ -599,60 +599,60 @@ void loop() {
|
||||
|
||||
cleanValues();
|
||||
#endif
|
||||
//#ifdef SERIAL_XY6020L
|
||||
// printMem();
|
||||
//#endif
|
||||
//#ifdef SERIAL_XY6020L_2
|
||||
// printMem();
|
||||
//#endif
|
||||
//#ifdef SERIAL_XY6020L
|
||||
// printMem();
|
||||
//#endif
|
||||
//#ifdef SERIAL_XY6020L_2
|
||||
// printMem();
|
||||
//#endif
|
||||
// Mettre à jour le temps de la dernière mise à jour
|
||||
lastUpdateTime = millis();
|
||||
#ifdef PIN_TENSION
|
||||
getTension();
|
||||
#endif
|
||||
// digitalWrite(PIN_LED, LOW);
|
||||
// delay(500);
|
||||
// digitalWrite(PIN_LED, LOW);
|
||||
// delay(500);
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////////////////////
|
||||
// ///////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef SERIAL_XY6020L
|
||||
|
||||
#endif
|
||||
|
||||
// //////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
}
|
||||
|
||||
void handleRoot() {
|
||||
// IPAddress clientIP = server.client().remoteIP();
|
||||
// Serial.println("Client IP: " + clientIP.toString());
|
||||
//
|
||||
// if (!isLocalIP(clientIP)) {
|
||||
// // Vérifie si le mot de passe est correct
|
||||
// if (server.hasArg("password")) {
|
||||
// String passwordParam = server.arg("password");
|
||||
// if (passwordParam == adminPassword) {
|
||||
// server.send(200, "text/html", "<h1>Accès autorisé</h1>");
|
||||
// } else {
|
||||
// server.send(401, "text/html", "<h1>Mot de passe incorrect</h1>");
|
||||
// }
|
||||
// } else {
|
||||
// server.send(401, "text/html", "<form action='/' method='get'>"
|
||||
// "<label for='password'>Mot de passe:</label><br>"
|
||||
// "<input type='password' id='password' name='password'><br>"
|
||||
// "<input type='submit' value='Se connecter'>"
|
||||
// "</form>");
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
// IPAddress clientIP = server.client().remoteIP();
|
||||
// Serial.println("Client IP: " + clientIP.toString());
|
||||
//
|
||||
// if (!isLocalIP(clientIP)) {
|
||||
// // Vérifie si le mot de passe est correct
|
||||
// if (server.hasArg("password")) {
|
||||
// String passwordParam = server.arg("password");
|
||||
// if (passwordParam == adminPassword) {
|
||||
// server.send(200, "text/html", "<h1>Accès autorisé</h1>");
|
||||
// } else {
|
||||
// server.send(401, "text/html", "<h1>Mot de passe incorrect</h1>");
|
||||
// }
|
||||
// } else {
|
||||
// server.send(401, "text/html", "<form action='/' method='get'>"
|
||||
// "<label for='password'>Mot de passe:</label><br>"
|
||||
// "<input type='password' id='password' name='password'><br>"
|
||||
// "<input type='submit' value='Se connecter'>"
|
||||
// "</form>");
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
|
||||
|
||||
// bool connectionStatus = testDomoticzConnection();
|
||||
// String connectionIcon = connectionStatus
|
||||
// ? "<i class='fas fa-check-circle' style='color: green;'></i>"
|
||||
// : "<i class='fas fa-times-circle' style='color: red;'></i>";
|
||||
// bool connectionStatus = testDomoticzConnection();
|
||||
// String connectionIcon = connectionStatus
|
||||
// ? "<i class='fas fa-check-circle' style='color: green;'></i>"
|
||||
// : "<i class='fas fa-times-circle' style='color: red;'></i>";
|
||||
|
||||
#ifdef PIN_HALL
|
||||
getHall();
|
||||
@@ -780,14 +780,14 @@ void handleRoot() {
|
||||
|
||||
#ifdef TUYA
|
||||
|
||||
to_add.replace("@@VALUE@@", String(String(conso_apparente).toFloat(),1) + " W");
|
||||
to_add.replace("@@VALUE@@", String(String(conso_apparente).toFloat(), 1) + " W");
|
||||
to_add.replace("@@LABEL@@", "Conso apparente");
|
||||
to_add.replace("@@KEY@@", "IND_CONSO");
|
||||
|
||||
indicators += to_add;
|
||||
to_add = indicator;
|
||||
|
||||
to_add.replace("@@VALUE@@", String(String(production).toFloat(),1) + " W");
|
||||
to_add.replace("@@VALUE@@", String(String(production).toFloat(), 1) + " W");
|
||||
to_add.replace("@@LABEL@@", "Production");
|
||||
to_add.replace("@@KEY@@", "IND_PROD");
|
||||
|
||||
@@ -955,9 +955,9 @@ void handleStop() {
|
||||
|
||||
setCC(xy, 0);
|
||||
|
||||
#ifdef SERIAL_XY6020L_2
|
||||
#ifdef SERIAL_XY6020L_2
|
||||
setCC2(xy2, 0);
|
||||
#endif
|
||||
#endif
|
||||
delay(200);
|
||||
digitalWrite(PIN_CHARGE, LOW);
|
||||
delay(200);
|
||||
@@ -1001,18 +1001,18 @@ void handleStart() {
|
||||
}
|
||||
|
||||
void injection() {
|
||||
#ifdef PIN_DIMMER_OUTPUT
|
||||
#ifdef PIN_DIMMER_OUTPUT
|
||||
dimmer.setState(ON_OFF_typedef::OFF);
|
||||
#endif
|
||||
#ifdef PIN_POWER
|
||||
#endif
|
||||
#ifdef PIN_POWER
|
||||
digitalWrite(PIN_POWER, HIGH);
|
||||
delay(200);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PIN_BATTERIE
|
||||
#ifdef PIN_BATTERIE
|
||||
digitalWrite(PIN_BATTERIE, HIGH);
|
||||
delay(200);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
digitalWrite(PIN_CHARGE, LOW);
|
||||
delay(200);
|
||||
@@ -1021,14 +1021,14 @@ void injection() {
|
||||
digitalWrite(PIN_INJECTION, HIGH);
|
||||
delay(200);
|
||||
|
||||
#ifdef PIN_BATTERIE
|
||||
#ifdef PIN_BATTERIE
|
||||
digitalWrite(PIN_BATTERIE, HIGH);
|
||||
delay(200);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PIN_REGULATION
|
||||
#ifdef PIN_REGULATION
|
||||
setReg(0);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
void handleInjection() {
|
||||
|
||||
@@ -1040,7 +1040,7 @@ void handleInjection() {
|
||||
|
||||
void stopInjection()
|
||||
{
|
||||
#ifdef PIN_BATTERIE
|
||||
#ifdef PIN_BATTERIE
|
||||
digitalWrite(PIN_BATTERIE, LOW);
|
||||
delay(200);
|
||||
#endif
|
||||
@@ -1060,7 +1060,7 @@ void handleStopInjection() {
|
||||
|
||||
void charge()
|
||||
{
|
||||
#ifdef PIN_DIMMER_OUTPUT
|
||||
#ifdef PIN_DIMMER_OUTPUT
|
||||
dimmer.setState(ON_OFF_typedef::ON);
|
||||
#endif
|
||||
Serial.println("charge");
|
||||
@@ -1102,9 +1102,9 @@ void stopCharge()
|
||||
#ifdef PIN_REGULATION
|
||||
setReg(0);
|
||||
#endif
|
||||
#ifdef SERIAL_XY6020L
|
||||
#ifdef SERIAL_XY6020L
|
||||
setCC(xy, 0);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void handleStopCharge() {
|
||||
|
||||
@@ -140,8 +140,6 @@ String to_include = R"=(
|
||||
table.deleteRow(-1); // Supprime la dernière ligne
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (field_chart && !chart) {
|
||||
var ctx = field_chart.getContext('2d');
|
||||
chart = new Chart(ctx, {
|
||||
|
||||
@@ -22,6 +22,8 @@ ESP8266WebServer server(80);
|
||||
|
||||
void ICACHE_RAM_ATTR handleInterrupt();
|
||||
|
||||
#define HOSTNAME "ESP8266_RADIATEUR"
|
||||
|
||||
// Dimmer
|
||||
#include <RBDdimmer.h>//
|
||||
|
||||
@@ -30,11 +32,13 @@ void ICACHE_RAM_ATTR handleInterrupt();
|
||||
#define zerocross 12 // D6 for boards with CHANGEBLE input pins
|
||||
#define pas 5
|
||||
|
||||
bool led;
|
||||
int pwm;
|
||||
int pwmCount;
|
||||
|
||||
dimmerLamp dimmer(outputPin, zerocross); //initialase port for dimmer for ESP8266, ESP32, Arduino due boards
|
||||
//dimmerLamp dimmer(outputPin); //initialase port for dimmer for MEGA, Leonardo, UNO, Arduino M0, Arduino Zero
|
||||
|
||||
int outVal = 0;
|
||||
|
||||
String webpage = R"=(
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
@@ -42,22 +46,61 @@ String webpage = R"=(
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>LED Control</title>
|
||||
<link type='text/css' rel='stylesheet' href='http://192.168.1.3:81/velux/style.css'>
|
||||
<script>
|
||||
var xmlHttp01=createXmlHttpObject();
|
||||
var previous_value = 10;
|
||||
function createXmlHttpObject(){
|
||||
if(window.XMLHttpRequest){
|
||||
xmlHttp=new XMLHttpRequest();
|
||||
}else{
|
||||
xmlHttp=new ActiveXObject('Microsoft.XMLHTTP');
|
||||
}
|
||||
return xmlHttp;
|
||||
}
|
||||
function process(){
|
||||
if(xmlHttp01.readyState==0 || xmlHttp01.readyState==4){
|
||||
xmlHttp01.open('GET','getData',true);
|
||||
xmlHttp01.onreadystatechange=handleServerResponse;
|
||||
xmlHttp01.send(null);
|
||||
}
|
||||
setTimeout('process()', 30000);
|
||||
}
|
||||
function handleServerResponse(){
|
||||
var field = document.getElementById('current_value');
|
||||
if(field && xmlHttp01.readyState == 4 && xmlHttp01.status == 200){
|
||||
const json_obj = JSON.parse(xmlHttp01.response);
|
||||
// console.log(xmlHttp01.response);
|
||||
const values = Object.values(json_obj);
|
||||
var value = values[1]
|
||||
if (value != previous_value) {
|
||||
let button = document.querySelector('.arcade-button');
|
||||
button.classList.add('gradient'); // Ajoute l'effet
|
||||
setTimeout(() => button.classList.remove('gradient'), 3000);
|
||||
previous_value = value;
|
||||
}
|
||||
field.textContent = value
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
body {
|
||||
align-content: center;
|
||||
background-color: #3498db;
|
||||
color: white;
|
||||
display: flex;
|
||||
font-family: 'Arial', sans-serif;
|
||||
background-color: #f2f2f2;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
.control-container {
|
||||
background: #C0C0C0;
|
||||
width: 128px;
|
||||
background: #66cc66;
|
||||
width: 256px;
|
||||
height: 64px;
|
||||
margin: 10px;
|
||||
display: flex;
|
||||
@@ -90,7 +133,7 @@ String webpage = R"=(
|
||||
position: relative;
|
||||
width: 150px;
|
||||
height: 150px;
|
||||
background-color: #3498db;
|
||||
background-color: #005599;
|
||||
border: 10px solid #2c3e50;
|
||||
border-radius: 50%;
|
||||
overflow: hidden;
|
||||
@@ -102,6 +145,29 @@ String webpage = R"=(
|
||||
background-color: #2980b9;
|
||||
}
|
||||
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
align-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
header {
|
||||
background-color: #003366;
|
||||
padding: 1rem;
|
||||
text-align: center;
|
||||
}
|
||||
.header_info {
|
||||
display: flex;
|
||||
}
|
||||
.header_info h2 {
|
||||
margin: 0 10px;
|
||||
}
|
||||
h1, h2 {
|
||||
color: white;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.button-content {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
@@ -111,9 +177,40 @@ String webpage = R"=(
|
||||
font-size: 1.5rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* Effet Flash */
|
||||
.arcade-button.flash {
|
||||
animation: flash 0.3s;
|
||||
}
|
||||
|
||||
@keyframes flash {
|
||||
0% { background-color: #005599; }
|
||||
50% { background-color: red; }
|
||||
100% { background-color: #005599; }
|
||||
}
|
||||
|
||||
/* Animation fluide entre rouge et orange */
|
||||
@keyframes smoothGradient {
|
||||
0% { background-color: #005599; }
|
||||
50% { background-color: orange; }
|
||||
100% { background-color: #005599; }
|
||||
}
|
||||
|
||||
.arcade-button.gradient {
|
||||
animation: smoothGradient 3s ease-in-out; /* Durée ajustable */
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<body onload='process()'>
|
||||
<div class="container">
|
||||
<header>
|
||||
<h1>Surplux solaire</h1>
|
||||
<div class="header_info">
|
||||
<h2>@@IP@@</h2>
|
||||
|
||||
</div>
|
||||
|
||||
</header>
|
||||
<div class="control-container" id="LEDn">
|
||||
<button onclick="alert('on');">ON</button>
|
||||
</div>
|
||||
@@ -124,7 +221,6 @@ String webpage = R"=(
|
||||
|
||||
<div class="control-container" id="pwmminus">
|
||||
<a href="/minus?value=10">Minus</a>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="control-container" id="pwmstop">
|
||||
@@ -132,28 +228,27 @@ String webpage = R"=(
|
||||
</div>
|
||||
|
||||
<div class="arcade-button">
|
||||
<div class="button-content">@@pwmCount@@</div>
|
||||
<div class="button-content" id='current_value'>@@pwmCount@@</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
)=";
|
||||
|
||||
bool led;
|
||||
int pwm;
|
||||
int pwmCount;
|
||||
//
|
||||
//void ledON(){
|
||||
// led=1;
|
||||
// digitalWrite(LEDn, led);
|
||||
// handleRoot();
|
||||
//
|
||||
//}
|
||||
//
|
||||
//void ledOFF(){
|
||||
// led=0;
|
||||
// digitalWrite(LEDn, led);
|
||||
// handleRoot();
|
||||
//}
|
||||
|
||||
|
||||
void ledON(){
|
||||
led=1;
|
||||
digitalWrite(LEDn, led);
|
||||
handleRoot();
|
||||
|
||||
}
|
||||
|
||||
void ledOFF(){
|
||||
led=0;
|
||||
digitalWrite(LEDn, led);
|
||||
handleRoot();
|
||||
}
|
||||
|
||||
|
||||
//pwm functions - if pwm is set to 1/-1 it will in-/decrease pwmCounter in loop()
|
||||
@@ -222,6 +317,7 @@ void setPwm(int pwm)
|
||||
void handleRoot(void){
|
||||
String page = webpage;
|
||||
page.replace("@@pwmCount@@", String(pwmCount));
|
||||
page.replace("@@IP@@", String(WiFi.localIP().toString()));
|
||||
//Serial.println(page);
|
||||
server.send(200, "text/html", page);
|
||||
}
|
||||
@@ -319,18 +415,27 @@ String generateKey()
|
||||
|
||||
IPAddress getIP(String macId)
|
||||
{
|
||||
IPAddress ip; //(192, 168, 1, 222);
|
||||
// IPAddress ip (192, 168, 1, 222);
|
||||
//
|
||||
// String fst = macId.substring(0, 2);
|
||||
// String sec = macId.substring(2);
|
||||
//
|
||||
// char fstc[fst.length() + 1];
|
||||
// fst.toCharArray(fstc, fst.length() + 1);
|
||||
//
|
||||
// char secc[sec.length() + 1];
|
||||
// sec.toCharArray(secc, fst.length() + 1);
|
||||
|
||||
String fst = macId.substring(0, 2);
|
||||
String sec = macId.substring(2);
|
||||
return IPAddress (192, 168, 1, 222); //IPAddress(192, 168, strtol(fstc, 0, 16), strtol(secc, 0, 16));
|
||||
|
||||
char fstc[fst.length() + 1];
|
||||
fst.toCharArray(fstc, fst.length() + 1);
|
||||
}
|
||||
|
||||
char secc[sec.length() + 1];
|
||||
sec.toCharArray(secc, fst.length() + 1);
|
||||
|
||||
return IPAddress(192, 168, strtol(fstc, 0, 16), strtol(secc, 0, 16));
|
||||
void handleData()
|
||||
{
|
||||
String JSON = F("");
|
||||
JSON += "{\"id\":\"current\", \"value\":" + String(pwmCount) + "}";
|
||||
JSON += "";
|
||||
server.send(200, "application/json", JSON);
|
||||
|
||||
}
|
||||
|
||||
@@ -355,6 +460,7 @@ void setup()
|
||||
server.on("/plus", plus);
|
||||
server.on("/exact", exact);
|
||||
server.on("/stop", stopPWM);
|
||||
server.on("/getData", handleData);
|
||||
//initialize variables__________________
|
||||
pwm = 0;
|
||||
pwmCount= 0;
|
||||
@@ -378,7 +484,7 @@ void setup()
|
||||
ArduinoOTA.setPort(8266);
|
||||
|
||||
// Hostname defaults to esp8266-[ChipID]
|
||||
// ArduinoOTA.setHostname("myesp8266");
|
||||
ArduinoOTA.setHostname(HOSTNAME);
|
||||
|
||||
// No authentication by default
|
||||
// ArduinoOTA.setPassword("admin");
|
||||
|
||||
Reference in New Issue
Block a user