Code :
#include "EcranLED.h"
LGFXoled oled;
// NOUVELLES DECLARATIONS POUR CODE RAPHAEL
LGFX_Sprite sprite(&oled); // Sprite = buffer secondaire dans lequel sera construite l'image à afficher avant d'être envoyée vers l'écran OLED.
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
bool OLED_on = false; //Si problème avec l'écran, les procédures sont ignorées
int pinBtnOled = 27; //Indiquer ici le pin du bouton pour gérer l'écran/capteur de présence // HP6 adapté à l'installation, mettre 0 si pas bouton et passer ModeBtnOled a 0
//*******BOUTON OLED***********/
//Changement état gérer dans boucle affichage, déconseillé dans l'interruption.
//gestion de la latence du bouton
volatile unsigned long button_time = 0;
int btn_latence = 250; // Latence en ms
volatile bool OledState=true; //Statut oled On/Off (Mettre à la valeur désiré au démarrage)
volatile bool OledChange=true; //Changement sur bouton, true = applique le statut OledState (affichage oui/non)
int ModeBtnOled = 1; // 0 = bouton poussoir (on/off sur écran), 1 = capteur présence ou bouton poussoir pour allumage on (off automatique)
unsigned long DureeAffichage = 40000; //Durée affichage 40 secondes
//******FIN BOUTON OLED ***********/
int MATERIEL_ROUTAGE=-1; //Pour la recherche TRIAC OU RELAIS
int cligSun = 0;
int BoucleOled = 0;
const unsigned char bitmap_Sun[] PROGMEM = {
0x10,0x84, // ...#....#....#..
0x08,0x08, // ....#.......#...
0x01,0xC0, // .......###......
0x07,0xF0, // .....#######....
0x0F,0xF8, // ....#########...
0x6F,0xFB, // .##.#########.##
0x0F,0xF8, // ....#########...
0x07,0xF0, // .....#######....
0x11,0xC4, // ...#...###...#..
0x20,0x02, // ..#...........#.
};
const unsigned char bitmap_Off[] PROGMEM = {
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x1F,0xF8, // ...##########...
0x1F,0xF8, // ...##########...
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
};
const unsigned char bitmap_Signal1[] PROGMEM = {
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x40,0x00, // .#..............
0xDD,0xDC // ##.###.###.###..
};
const unsigned char bitmap_Signal2[] PROGMEM = {
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x04,0x00, // .....#..........
0x0C,0x00, // ....##..........
0x1C,0x00, // ...###..........
0x5C,0x00, // .#.###..........
0xDD,0xDC // ##.###.###.###..
};
const unsigned char bitmap_Signal3[] PROGMEM = {
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x40, // .........#......
0x00,0xC0, // ........##......
0x01,0xC0, // .......###......
0x05,0xC0, // .....#.###......
0x0D,0xC0, // ....##.###......
0x1D,0xC0, // ...###.###......
0x5D,0xC0, // .#.###.###......
0xDD,0xDC // ##.###.###.###..
};
const unsigned char bitmap_Signal4[] PROGMEM = {
0x00,0x04, // .............#..
0x00,0x0C, // ............##..
0x00,0x1C, // ...........###..
0x00,0x1C, // ...........###..
0x00,0x5C, // .........#.###..
0x00,0xDC, // ........##.###..
0x01,0xDC, // .......###.###..
0x05,0xDC, // .....#.###.###..
0x0D,0xDC, // ....##.###.###..
0x1D,0xDC, // ...###.###.###..
0x5D,0xDC, // .#.###.###.###..
0xDD,0xDC // ##.###.###.###..
};
const unsigned char bitmap_Signal0[] PROGMEM = {
0x03,0xE0, // ......#####.....
0x1F,0xFC, // ...###########..
0x3E,0x3E, // ..#####...#####.
0x38,0x7E, // ..###....######.
0x71,0xF7, // .###...#####.###
0x73,0xC7, // .###..####...###
0x77,0x87, // .###.####....###
0x3F,0x0E, // ..######....###.
0x3E,0x1E, // ..#####....####.
0x1F,0xFC, // ...###########..
0x03,0xE0, // ......#####.....
};
const unsigned char bitmap_Logo[] PROGMEM = {
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,0x00,
0x00,0x00,0x00,0x3F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x1F,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x03,0xC1,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x3F,0xC0,0x7F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xFF,0x00,0x3F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0xFE,0x00,0x0F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x07,0xF8,0x00,0x03,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x0F,0xF0,0x60,0x61,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x3F,0xC0,0xE0,0x60,0x7F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x7F,0x80,0xE0,0x60,0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0xFE,0x00,0xE0,0x60,0x0F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0xFC,0x00,0xE0,0x60,0x07,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0xF8,0x00,0xE0,0x60,0x03,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0xF0,0x00,0xE0,0x60,0x01,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0xE0,0x00,0xE0,0x60,0x00,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0xE0,0x00,0xE0,0x60,0x00,0x7C,0x03,0xFE,0x0E,0x07,0xF1,0xFF,0x8F,0xF0,0x00,
0x01,0xE0,0x00,0x60,0x60,0x00,0x7C,0x03,0xFF,0x1E,0x0F,0xF9,0xFF,0x8F,0xF8,0x00,
0x01,0xE0,0x00,0x00,0x00,0x00,0x7C,0x03,0xFE,0x3E,0x0F,0xFC,0xFF,0x8F,0xF8,0x00,
0x01,0xE0,0x01,0xFF,0xF8,0x00,0x7C,0x03,0x00,0x3E,0x0C,0x1C,0x18,0x0C,0x18,0x00,
0x01,0xE0,0x03,0xFF,0xFC,0x00,0x7C,0x03,0x00,0x06,0x0C,0x1C,0x18,0x0C,0x18,0x00,
0x01,0xE0,0x01,0xFF,0xF8,0x00,0x7C,0x03,0x00,0x06,0x0C,0x1C,0x18,0x0C,0x18,0x00,
0x01,0xE0,0x01,0xFF,0xF8,0x00,0x7C,0x03,0x00,0x06,0x0C,0x1C,0x18,0x0C,0x18,0x00,
0x01,0xE0,0x01,0xFF,0xF8,0x00,0x7C,0x03,0x00,0x06,0x0C,0x1C,0x18,0x0C,0x18,0x00,
0x01,0xE0,0x01,0xFF,0xF8,0x00,0x7C,0x03,0xF8,0x06,0x0F,0xFC,0x18,0x0F,0xF8,0x00,
0x01,0xE0,0x01,0xFF,0xF8,0x00,0x7C,0x03,0xF8,0x06,0x0F,0xFC,0x18,0x0F,0xF8,0x00,
0x01,0xE0,0x01,0xFF,0xF8,0x00,0x7C,0x03,0x00,0x06,0x0E,0x1C,0x18,0x0C,0x18,0x00,
0x01,0xE0,0x01,0xFF,0xF8,0x00,0x7C,0x03,0x00,0x06,0x0C,0x1C,0x18,0x0C,0x18,0x00,
0x01,0xE0,0x01,0xFF,0xF8,0x00,0x7C,0x03,0x00,0x06,0x0C,0x1C,0x18,0x0C,0x18,0x00,
0x01,0xE0,0x00,0xFF,0xF0,0x00,0x7C,0x03,0x00,0x06,0x0C,0x1C,0x18,0x0C,0x18,0x00,
0x01,0xE0,0x00,0xFF,0xF0,0x00,0x7C,0x03,0x00,0x06,0x0C,0x1C,0x18,0x0C,0x18,0x00,
0x01,0xE0,0x00,0x7F,0xE0,0x00,0x7C,0x03,0x00,0x0F,0x0C,0x1C,0x18,0x0E,0x38,0x00,
0x01,0xE0,0x00,0x3F,0xC0,0x00,0x7C,0x03,0x00,0x3F,0x8C,0x1C,0x18,0x0F,0xF8,0x00,
0x01,0xE0,0x00,0x0F,0x00,0x00,0x7C,0x03,0x00,0x3F,0x8C,0x0C,0x18,0x0F,0xF0,0x00,
0x01,0xE0,0x00,0x0F,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0xE0,0x00,0x06,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0xE0,0x00,0x06,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0xE0,0x00,0x06,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0xE0,0x00,0x1F,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0xE0,0x00,0x7F,0xC0,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0xE0,0x00,0xFF,0xF0,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0xE0,0x01,0xFF,0xFC,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0xE0,0x00,0x0F,0xFE,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0xE0,0x00,0x03,0xFF,0x80,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0xE0,0x0F,0xE0,0xFF,0xC0,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0xF0,0x7F,0x80,0x3F,0xF1,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0xF9,0xFF,0x00,0x1F,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0xFF,0xFC,0x00,0x07,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0xFF,0xF8,0x00,0x03,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x7F,0xE0,0x00,0x00,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x1F,0xC0,0x00,0x00,0x7F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x0E,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,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
void Init_LED_OLED(void) {
//LEDs et OLRD
//LEDgroupe = 0; //0:pas de LED,1à 9 LEDs, 10 et 11 écran OLED SSD1306 , 12 et 13 OLED SH1106
if (LEDgroupe > 0 && LEDgroupe < 10) { //Simples LEDs
pinMode(LEDyellow[LEDgroupe], OUTPUT);
pinMode(LEDgreen[LEDgroupe], OUTPUT);
}
if (LEDgroupe >= 10) {
bool SD = true; //SSD1306
if (LEDgroupe > 11) SD = false; //SH1106
oled.LGFXoled_init(LEDyellow[LEDgroupe], LEDgreen[LEDgroupe], SD); //SDA , SCL et SSD1306 ou SH1106
InitSSD(); // HP6 Appel initialisation du code Raphael
// HP6 Code intialisation André enlevé
}
}
//****************
//* Gestion LEDs *
//****************
void Gestion_LEDs() {
int retard_min = 100;
int retardI;
cptLEDyellow++;
if ((WiFi.status() != WL_CONNECTED && (ESP32_Type < 10 || ESP32_Type==101)) || (EthernetBug > 0 && ESP32_Type == 10)) { // Attente connexion au Wifi ou ethernet
if (WiFi.getMode() == WIFI_STA) { // en Station mode
cptLEDyellow = (cptLEDyellow + 6) % 10;
cptLEDgreen = cptLEDyellow;
} else { //AP Mode
cptLEDyellow = cptLEDyellow % 10;
cptLEDgreen = (cptLEDyellow + 5) % 10;
}
} else {
for (int i = 0; i < NbActions; i++) {
retardI = Retard[i];
retard_min = min(retard_min, retardI);
}
if (retard_min < 100) {
cptLEDgreen = int((cptLEDgreen + 1 + 8 / (1 + retard_min / 10))) % 10;
} else {
cptLEDgreen = 10;
}
}
if (LEDgroupe > 0 && LEDgroupe < 10) {
int L = 0, H = 1; //LED classique
if (LEDgroupe == 2 || LEDgroupe == 4) { //Inversé pour LED sur carte graphique GPIOs 4,16,17
L = 1;
H = 0;
}
if (cptLEDyellow > 5) {
digitalWrite(LEDyellow[LEDgroupe], L);
} else {
digitalWrite(LEDyellow[LEDgroupe], H);
}
if (cptLEDgreen > 5) {
digitalWrite(LEDgreen[LEDgroupe], L);
} else {
digitalWrite(LEDgreen[LEDgroupe], H);
}
}
if (LEDgroupe >= 10) {
if (cptLEDyellow == 5) { //New puissance dispo
// HP6 Appel du code Raphael
OledAffiche();
// HP6 Code affichage André enlevé
}
if (cptLEDyellow > 200) {
oled.fillRect(0, 0, oled.width(), 16, TFT_BLACK);
PrintCentreO("Puissance Inconnue", -1, 0, 2);
}
}
}
void PrintScroll(String m) {
TelnetPrintln( m);
// HP6 Ne génère plus d'affichage sur l'écran OLED
}
void PrintCentreO(String S, int X, int Y, float Sz) {
if (X < 0) X = oled.width() / 2;
oled.setTextSize(Sz);
int W = oled.textWidth(S);
oled.drawString(S, X - W / 2, Y);
}
void PrintDroiteO(String S, int X, int Y, float Sz) {
// HP6 Ne gère plus cette fonction
}
// **** CODE DE RAPHAEL TRANSFERE ICI ****
//Initialisation
void InitSSD(){
//OLED init
// HP6 Choix d'écran déja fait par l'initialisation des parmètres du routeur avec sélection écran
//FORCE RESET DE L'ECRAN SI PIN PARTICULIER POUR RESET
if(OLED_RESET != -1) {
pinMode (OLED_RESET, OUTPUT);
digitalWrite(OLED_RESET, HIGH);
digitalWrite(OLED_RESET, LOW);
delay(100);
}
if (oled.begin()) {
OLED_on=true;
oled.setRotation(2);
oled.setBrightness(255);
oled.setTextFont(1);
oled.setTextColor(TFT_WHITE, TFT_BLACK);
sprite.createSprite(128, 64);
OledLogo();
//Partie gestion bouton
if(pinBtnOled > 0) {
pinMode(pinBtnOled, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(pinBtnOled), OledBouton, RISING) ;
}
}
}
// CONTENU ECRAN 1
void Ecran1(int info = 0){
if(OLED_on==false || !OledState) {
return;
}
sprite.setTextSize(1);
sprite.setTextColor(TFT_WHITE);
sprite.setCursor(0,1);
//Info première ligne (Ip, Injectée + Heure routé)
switch (info)
{
case 0 :
//IP
if (WiFi.status() == WL_CONNECTED) {
sprite.print(WiFi.localIP().toString());
}
else {
(WiFi.getMode() == WIFI_STA)==false ? sprite.print(WiFi.softAPIP().toString()) : sprite.print(F("Pas de wifi !"));
}
break;
case 1 :
//Info injection et heure routé
sprite.print("I ");sprite.print(EnergieJour_M_Injectee);sprite.print(" Wh");
float H = 0;
sprite.setCursor(64,0);
if(MATERIEL_ROUTAGE != -1 ) H = LesActions[MATERIEL_ROUTAGE].H_Ouvre;
sprite.print("H ");sprite.print(H);
break;
}
//Ligne de séparation
sprite.drawLine(0,13,128,13,TFT_WHITE);
//Puissance sonde maison
sprite.setCursor(0,16);
sprite.println(F("Puissance"));
sprite.setCursor(0,29);
sprite.setTextSize(2);
sprite.print(int(PuissanceS_M - PuissanceI_M));
sprite.setTextSize(1);
//Ouverture du triac/ssr
int Ouv = -1;
if(MATERIEL_ROUTAGE != -1) {
Ouv = 100 - Retard[MATERIEL_ROUTAGE];
}
if(Ouv>0 && info==0) {
//Icone clignote, signale le routage
if(cligSun==0) {
sprite.drawBitmap(92, 0, bitmap_Sun , 16, 10, TFT_WHITE);
cligSun=1;
}
else {
cligSun=0;
sprite.drawBitmap(92, 0, bitmap_Off , 16, 10, TFT_WHITE);
}
}
else {
//Pas de triac/relais...
}
sprite.setCursor(0,38);
if(Ouv == -1) {
sprite.setCursor(73,16);
sprite.print(F("Ouv")); //Triac erreur
sprite.drawRect(60, 16, 10, 33, TFT_WHITE);
sprite.setCursor(82,30);
sprite.print(F(" !"));
}
else {
//Affiche jauge Triac/Relais
sprite.setCursor(72,16);
sprite.print(F("Ouv"));
sprite.drawRect(60, 16, 10, 33, TFT_WHITE);
float t = (float(33)/100)*Ouv;
sprite.fillRect(60+2, 16+(33-int(t)), 10-4 , int(t), TFT_WHITE);
sprite.setTextSize(2);
sprite.setCursor(73,29);
sprite.print(Ouv);
sprite.setTextSize(1);
}
// Affichage de la température canal 0
if (TemperatureValide[0] > 0){
sprite.setCursor(0, 57);
sprite.print(F("T "));
sprite.print(int(temperature[0]));
}
else
{
sprite.setCursor(0, 57);
sprite.print(F("V"));
sprite.print(Version);
}
//Affichage durée de fonctionnement ESP32
int T = int(millis() / 1000);
float DureeOn = float(T) / 3600;
String durOn=String(DureeOn)+"h";
sprite.setCursor(108-(durOn.length()*6),57);
sprite.print(durOn);
}
//BARRE D'ACTION AFFICHÉE SUR ÉCRAN 1
void BarreEtatDroite(int info = 0) { // Affiche une barre d'état WIFI et mode action
if(OLED_on==false || !OledState) {
return;
}
sprite.setTextSize(1);
sprite.setTextColor(TFT_WHITE);
sprite.drawLine(110,13,110,64,TFT_WHITE); //Ligne séparatrice à droite
//Niveau Wifi
if (info == 0) {
if (WiFi.status() == WL_CONNECTED) {
//Icone niveau connection
int NivSignal = int(WiFi.RSSI()) ;
if (NivSignal<-80) {sprite.drawBitmap(112, 0, bitmap_Signal1 , 16, 12, TFT_WHITE); }
else if(NivSignal<-60) {sprite.drawBitmap(112, 0, bitmap_Signal2 , 16, 12, TFT_WHITE); }
else if(NivSignal<-45) {sprite.drawBitmap(112, 0, bitmap_Signal3 , 16, 12, TFT_WHITE); }
else if(NivSignal<-30) {sprite.drawBitmap(112, 0, bitmap_Signal4 , 16, 12, TFT_WHITE); }
}
else {
(WiFi.getMode() == WIFI_STA)==false ? sprite.drawBitmap(112, 0, bitmap_Signal0 , 16, 11, TFT_WHITE) : sprite.drawBitmap(112, 0, bitmap_Signal0 , 16, 11, TFT_WHITE);
}
}
//Mode en cours du Triac/ssr...
int Mode = 0;
float laTemperature = -120;
if (TemperatureValide[0] > 0) { //La température de ce canal est valide
laTemperature = temperature[0];
}
if (MATERIEL_ROUTAGE != -1) Mode = LesActions[MATERIEL_ROUTAGE].TypeEnCours(HeureCouranteDeci, laTemperature, LTARFbin, Retard[MATERIEL_ROUTAGE]);
sprite.setCursor(115,17);
sprite.setTextColor(TFT_WHITE);
if(Mode!=1){
sprite.print(F("OF"));
}
else {
sprite.fillRect(114,16,13,10,TFT_WHITE);
sprite.setTextColor(TFT_BLACK);
sprite.print(F("OF"));
}
sprite.setCursor(115,29);
sprite.setTextColor(TFT_WHITE);
if(Mode!=2){
sprite.print(F("ON"));
}
else {
sprite.fillRect(114,28,13,10,TFT_WHITE);
sprite.setTextColor(TFT_BLACK);
sprite.print(F("ON"));
}
sprite.setCursor(115,41);
sprite.setTextColor(TFT_WHITE);
if(Mode!=3){
sprite.print(F("PW"));
}
else {
sprite.fillRect(114,40,13,10,TFT_WHITE);
sprite.setTextColor(TFT_BLACK);
sprite.print(F("PW"));
}
sprite.setCursor(115,53);
sprite.setTextColor(TFT_WHITE);
if(Mode!=4){
sprite.print(F("TR"));
}
else {
sprite.fillRect(114,52,13,10,TFT_WHITE);
sprite.setTextColor(TFT_BLACK);
sprite.print(F("TR"));
}
sprite.setTextColor(TFT_WHITE);
}
//GESTION DU BOUTON
void OledBouton() {
switch (ModeBtnOled)
{
case 0 :
//Gestion bouton poussoir (allume/éteint)
if (button_time > millis()) break;
OledState = !OledState; // inverse l’état de la variable
button_time = millis() + btn_latence;
OledChange=true;
break;
case 1 :
//Capteur ou bouton avec extinction auto (allume)
if (button_time > millis()) break; //on garde la notion de latence
if (OledState == false) {
OledState = true; // inverse l’état de la variable
button_time = millis() + btn_latence;
OledChange=true;
}
break;
default:
break;
}
}
//PROCEDURE BOUCLE DES ECRANS
void OledAffiche(){
if(OLED_on==false) {
return;
}
if(ModeBtnOled==1 && OledState==true) {
//Contrôle durée d'affichage
if(button_time-btn_latence+DureeAffichage < millis()) {
//Durée affichage dépassé, on éteint
OledState=false;
OledChange=true;
}
}
sprite.fillScreen(0x0000); // Efface le buffer (l'écran)
if (OledChange) {
OledChange=false; //Changement traité
if(OledState) {
BoucleOled=0; //reprise début boucle écran
}
else {
oled.clear();
oled.display();
return;
}
}
if(MATERIEL_ROUTAGE == -1) {
//Recherche matériel
for (int i = 0; i < NbActions; i++) {
if(LesActions[i].Actif != 0 && MATERIEL_ROUTAGE == -1 ) MATERIEL_ROUTAGE=i;
}
}
if (BoucleOled <= 10 ) {
//Ecran 1
BarreEtatDroite(1); //Sans WIFI
Ecran1(1); //Affiche avec entête info
sprite.pushSprite(0, 0); // Publie le buffer sur l'écran sans aucun scintillement
BoucleOled++;
}
else if (BoucleOled <= 12 ) {
//Ecran 2
BarreEtatDroite(0); //Avec niveau WIFI
Ecran1(0); //Affiche avec entête IP
sprite.pushSprite(0, 0); // Publie le buffer sur l'écran sans aucun scintillement
BoucleOled++;
}
else {
BoucleOled=0;
}
}
//AFFICHAGE DU LOGO
void OledLogo() {
oled.clear();
oled.drawBitmap(0, 0, bitmap_Logo , 128, 68, TFT_WHITE);
}