first commit

This commit is contained in:
Jérôme Delacotte
2025-03-06 11:15:32 +01:00
commit 7b30d6e298
5276 changed files with 2108927 additions and 0 deletions

View File

@@ -0,0 +1,230 @@
//extern "C" {
//#include "user_interface.h"
//}
// Need for getVcc
ADC_MODE(ADC_VCC);
/////////////////////
// Domoticz Classe
/////////////////////
#include "Domoticz.h"
Domoticz domo("192.168.0.10", "8080", "Livebox-37cc", "8A6060920A8A86896F770F2C47");
#include "Modules.h"
Modules modules;
Params * params;
#include "Ecran.h"
Ecran * ecran;
#include "Cube.h"
// Convert image to char array http://www.digole.com/tools/PicturetoC_Hex_converter.php
// Hex values that represent Bitcoin logo
char bitcoin[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0x60, 0x70,
0x18, 0x18, 0x18, 0x0C, 0x0C, 0x06, 0x06, 0x06, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x06, 0x06,
0x06, 0x0C, 0x0C, 0x18, 0x18, 0x18, 0x70, 0x60, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0x38, 0x1E, 0x07, 0x03,
0x01, 0x80, 0xC0, 0xF0, 0xF8, 0xF8, 0x3E, 0x3E, 0x3E, 0x3F, 0x3F, 0x03, 0x03, 0x03, 0x3F, 0x03,
0x03, 0x03, 0x3F, 0x3F, 0x7F, 0x7E, 0xFE, 0xFE, 0xF8, 0xF8, 0xF0, 0xC0, 0x80, 0x01, 0x03, 0x07,
0x1E, 0x38, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFC, 0x1F, 0x03,
0x00, 0x00, 0x00, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFE, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3E, 0x3E, 0x3E, 0x3E, 0x1C, 0x00, 0x00, 0x00, 0x40, 0xE1, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x03, 0x1F, 0xFC, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0x3F, 0xFC, 0xC0, 0x00, 0x00, 0x00, 0x07, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x3F,
0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x3E, 0x1E, 0x00, 0x00, 0x00, 0x00,
0xC1, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x07, 0x00, 0x00, 0x00, 0xC0, 0xFC, 0x3F, 0x03, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x1E, 0x3C, 0x60, 0xE0, 0x80, 0x80, 0x03, 0x07,
0x0F, 0x1F, 0x3E, 0x3E, 0x7E, 0x7E, 0x7E, 0x60, 0xE0, 0xE0, 0xFE, 0xE0, 0xE0, 0xE0, 0x7E, 0x7E,
0x7E, 0x7F, 0x3F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x80, 0x80, 0xE0, 0x60, 0x3C, 0x1E, 0x03, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x03, 0x06, 0x06, 0x0C, 0x0C, 0x18, 0x18, 0x18, 0x30, 0x30, 0x30, 0x20, 0x60, 0x60, 0x60,
0x60, 0x20, 0x30, 0x30, 0x30, 0x18, 0x18, 0x18, 0x0C, 0x0C, 0x06, 0x06, 0x03, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
char puma[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x07,0x80,0x00,0x00,0x00,0x00,0x1c,0x00,0x00
,0x00,0x00,0x1f,0xf8,0x00,0x00,0x00,0x00,0x7e,0x00,0x00
,0x00,0x00,0x3f,0xfe,0x00,0x00,0x00,0x00,0xfc,0x00,0x00
,0x00,0x00,0x3f,0xff,0x80,0x00,0x00,0x01,0xf8,0x00,0x00
,0x00,0x00,0x3f,0xff,0xe0,0x00,0x00,0x03,0xc0,0x00,0x00
,0x00,0x00,0x1f,0xff,0xf0,0x00,0x00,0x03,0x80,0x00,0x00
,0x00,0x00,0x01,0xff,0xfc,0x00,0x00,0x07,0x00,0x00,0x00
,0x00,0x00,0x00,0xff,0xfe,0x00,0x00,0x06,0x00,0x00,0x00
,0x00,0x00,0x7f,0xff,0xff,0x80,0x00,0x0c,0x00,0x00,0x00
,0x00,0x00,0x7f,0xff,0xff,0xc0,0x00,0x08,0x00,0x00,0x00
,0x00,0x00,0x77,0xff,0xff,0xf0,0x00,0x18,0x00,0x00,0x00
,0x00,0x00,0x00,0xf9,0xff,0xf8,0x00,0x30,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x7f,0xfe,0x00,0x70,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x3f,0xff,0xc1,0xe0,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x0f,0xff,0xff,0xc0,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x03,0xff,0xff,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x0f,0xff,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x80,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x80,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xc0,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xc0,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0xc0,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0xc0,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0xc0,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xc0,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xc0,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xf0,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
// domoticz
String macID = "";
void setup()
{
Serial.begin(9600);
/* sda scl */
Wire.pins(SDA, SCL);
Wire.begin(SDA, SCL);
// Conversion d'objet en pointeur
Params p;
params = &p;
Ecran e;
ecran = &e;
ecran->LcdBitmap(LCD_X, LCD_Y, bitcoin); // display Bitcoin Logo LCD_X
// ecran->gotoXY(0,0); ecran->LcdString("Init :"); ecran->LcdString(domo._domoticz);
domo.initWifi();
macID = domo.generateKey();
ecran->LcdString(0, 0, domo._domoticz);
ecran->LcdChar(0, 10, "ID : "); ecran->LcdString(40, 10, macID);
ecran->u8g2->sendBuffer();
domo.getIdFromDomoticz(macID, params);
modules.barometre();
//readTemp();
printInfo();
for (int i = 0; i <= 100; i+=10) {
ecran->LcdClear();
ecran->drawRect(1, 1, LCD_X -1, LCD_Y -1);
ecran->drawJauge(10, 24, LCD_X -10, 34, i, "Jauge");
ecran->u8g2->sendBuffer();
delay(100);
}
Cube cube(ecran);
cube.draw();
// Graph g;
// g.title = "Graph";
// g.axe_x = "x";
// g.axe_y = "y";
// Point ps[50];
// for (int i = 0; i < 100; i+=5) {
// Point p(i, i);
// ps[i] = p;
// }
//
// ecran->LcdClear();
// ecran->drawGraph(g);
// ecran->u8g2->sendBuffer();
// ecran->intro();
delay(2000);
// Test Json
domo.readTempDayValues(params->esp8266_id);
// modules.sleep(params->sleepTime);
}
void loop() { }
//void sleepWifi()
//{
// //Time to let the WiFi go to sleep!
// Serial.println("Sleeping...");
// WiFi.disconnect();
// WiFi.mode(WIFI_OFF);
// WiFi.forceSleepBegin(params->sleepTime * 1000000L); //In uS. Must be same length as your delay
// delay(params->sleepTime * 1000); //Hang out at 15mA for 6 seconds
// WiFi.mode(WIFI_STA);
// Serial.println("Awake!");
//}
void printInfo()
{
Serial.println("Dans printInfo " + params->esp8266_id);
boolean connected = domo.connect();
// Domoticz format /json.htm?type=command&param=udevice&idx=IDX&nvalue=0&svalue=TEMP;HUM;HUM_STAT
if (connected && params->esp8266_id != "") {
Serial.println("Dans set temperature");
//domo.executeJson();
String svalue = String(modules.temp) + ";" + String(modules.humidity) + ";0";
// ecran->gotoXY(0,5); ecran->LcdChar("T: "); ecran->LcdString(String(modules.temp));
Serial.println(svalue);
domo.executeJson("/json.htm?type=command&param=udevice&idx=" + params->esp8266_id, svalue, "0");
domo._client.stop();
delay(200);
}
connected = domo.connect();
if (connected && params->esp8266_id_Vcc != "") {
Serial.print(" Envoi tension ");
Serial.print(params->esp8266_id_Vcc);
Serial.print(" ");
String vcc = domo.readVcc();
Serial.println(vcc);
// ecran->gotoXY(0,10); ecran->LcdChar("Vcc:"); ecran->LcdString(vcc);
// domo._client.print("GET /json.htm?type=command&param=udevice&idx=");
domo.executeJson("/json.htm?type=command&param=udevice&idx=" + params->esp8266_id_Vcc, vcc, "0");
domo._client.stop();
}
}