test commit après reinstall
This commit is contained in:
@@ -140,8 +140,6 @@ String to_include = R"=(
|
|||||||
table.deleteRow(-1); // Supprime la dernière ligne
|
table.deleteRow(-1); // Supprime la dernière ligne
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (field_chart && !chart) {
|
if (field_chart && !chart) {
|
||||||
var ctx = field_chart.getContext('2d');
|
var ctx = field_chart.getContext('2d');
|
||||||
chart = new Chart(ctx, {
|
chart = new Chart(ctx, {
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ ESP8266WebServer server(80);
|
|||||||
|
|
||||||
void ICACHE_RAM_ATTR handleInterrupt();
|
void ICACHE_RAM_ATTR handleInterrupt();
|
||||||
|
|
||||||
|
#define HOSTNAME "ESP8266_RADIATEUR"
|
||||||
|
|
||||||
// Dimmer
|
// Dimmer
|
||||||
#include <RBDdimmer.h>//
|
#include <RBDdimmer.h>//
|
||||||
|
|
||||||
@@ -30,11 +32,13 @@ void ICACHE_RAM_ATTR handleInterrupt();
|
|||||||
#define zerocross 12 // D6 for boards with CHANGEBLE input pins
|
#define zerocross 12 // D6 for boards with CHANGEBLE input pins
|
||||||
#define pas 5
|
#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, 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
|
//dimmerLamp dimmer(outputPin); //initialase port for dimmer for MEGA, Leonardo, UNO, Arduino M0, Arduino Zero
|
||||||
|
|
||||||
int outVal = 0;
|
|
||||||
|
|
||||||
String webpage = R"=(
|
String webpage = R"=(
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
@@ -42,22 +46,61 @@ String webpage = R"=(
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>LED Control</title>
|
<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>
|
<style>
|
||||||
body {
|
body {
|
||||||
|
align-content: center;
|
||||||
|
background-color: #3498db;
|
||||||
|
color: white;
|
||||||
|
display: flex;
|
||||||
font-family: 'Arial', sans-serif;
|
font-family: 'Arial', sans-serif;
|
||||||
background-color: #f2f2f2;
|
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
justify-content: space-around;
|
justify-content: space-around;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
height: 100vh;
|
width: 300px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.control-container {
|
.control-container {
|
||||||
background: #C0C0C0;
|
background: #66cc66;
|
||||||
width: 128px;
|
width: 256px;
|
||||||
height: 64px;
|
height: 64px;
|
||||||
margin: 10px;
|
margin: 10px;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -90,7 +133,7 @@ String webpage = R"=(
|
|||||||
position: relative;
|
position: relative;
|
||||||
width: 150px;
|
width: 150px;
|
||||||
height: 150px;
|
height: 150px;
|
||||||
background-color: #3498db;
|
background-color: #005599;
|
||||||
border: 10px solid #2c3e50;
|
border: 10px solid #2c3e50;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
@@ -102,6 +145,29 @@ String webpage = R"=(
|
|||||||
background-color: #2980b9;
|
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 {
|
.button-content {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
@@ -111,9 +177,40 @@ String webpage = R"=(
|
|||||||
font-size: 1.5rem;
|
font-size: 1.5rem;
|
||||||
text-align: center;
|
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>
|
</style>
|
||||||
</head>
|
</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">
|
<div class="control-container" id="LEDn">
|
||||||
<button onclick="alert('on');">ON</button>
|
<button onclick="alert('on');">ON</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -124,7 +221,6 @@ String webpage = R"=(
|
|||||||
|
|
||||||
<div class="control-container" id="pwmminus">
|
<div class="control-container" id="pwmminus">
|
||||||
<a href="/minus?value=10">Minus</a>
|
<a href="/minus?value=10">Minus</a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="control-container" id="pwmstop">
|
<div class="control-container" id="pwmstop">
|
||||||
@@ -132,28 +228,27 @@ String webpage = R"=(
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="arcade-button">
|
<div class="arcade-button">
|
||||||
<div class="button-content">@@pwmCount@@</div>
|
<div class="button-content" id='current_value'>@@pwmCount@@</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
)=";
|
)=";
|
||||||
|
|
||||||
bool led;
|
|
||||||
int pwm;
|
|
||||||
int pwmCount;
|
void ledON(){
|
||||||
//
|
led=1;
|
||||||
//void ledON(){
|
digitalWrite(LEDn, led);
|
||||||
// led=1;
|
handleRoot();
|
||||||
// digitalWrite(LEDn, led);
|
|
||||||
// handleRoot();
|
}
|
||||||
//
|
|
||||||
//}
|
void ledOFF(){
|
||||||
//
|
led=0;
|
||||||
//void ledOFF(){
|
digitalWrite(LEDn, led);
|
||||||
// led=0;
|
handleRoot();
|
||||||
// digitalWrite(LEDn, led);
|
}
|
||||||
// handleRoot();
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
//pwm functions - if pwm is set to 1/-1 it will in-/decrease pwmCounter in loop()
|
//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){
|
void handleRoot(void){
|
||||||
String page = webpage;
|
String page = webpage;
|
||||||
page.replace("@@pwmCount@@", String(pwmCount));
|
page.replace("@@pwmCount@@", String(pwmCount));
|
||||||
|
page.replace("@@IP@@", String(WiFi.localIP().toString()));
|
||||||
//Serial.println(page);
|
//Serial.println(page);
|
||||||
server.send(200, "text/html", page);
|
server.send(200, "text/html", page);
|
||||||
}
|
}
|
||||||
@@ -319,18 +415,27 @@ String generateKey()
|
|||||||
|
|
||||||
IPAddress getIP(String macId)
|
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);
|
return IPAddress (192, 168, 1, 222); //IPAddress(192, 168, strtol(fstc, 0, 16), strtol(secc, 0, 16));
|
||||||
String sec = macId.substring(2);
|
|
||||||
|
|
||||||
char fstc[fst.length() + 1];
|
}
|
||||||
fst.toCharArray(fstc, fst.length() + 1);
|
|
||||||
|
|
||||||
char secc[sec.length() + 1];
|
void handleData()
|
||||||
sec.toCharArray(secc, fst.length() + 1);
|
{
|
||||||
|
String JSON = F("");
|
||||||
return IPAddress(192, 168, strtol(fstc, 0, 16), strtol(secc, 0, 16));
|
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("/plus", plus);
|
||||||
server.on("/exact", exact);
|
server.on("/exact", exact);
|
||||||
server.on("/stop", stopPWM);
|
server.on("/stop", stopPWM);
|
||||||
|
server.on("/getData", handleData);
|
||||||
//initialize variables__________________
|
//initialize variables__________________
|
||||||
pwm = 0;
|
pwm = 0;
|
||||||
pwmCount= 0;
|
pwmCount= 0;
|
||||||
@@ -378,7 +484,7 @@ void setup()
|
|||||||
ArduinoOTA.setPort(8266);
|
ArduinoOTA.setPort(8266);
|
||||||
|
|
||||||
// Hostname defaults to esp8266-[ChipID]
|
// Hostname defaults to esp8266-[ChipID]
|
||||||
// ArduinoOTA.setHostname("myesp8266");
|
ArduinoOTA.setHostname(HOSTNAME);
|
||||||
|
|
||||||
// No authentication by default
|
// No authentication by default
|
||||||
// ArduinoOTA.setPassword("admin");
|
// ArduinoOTA.setPassword("admin");
|
||||||
|
|||||||
Reference in New Issue
Block a user