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
|
||||
}
|
||||
|
||||
|
||||
|
||||
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